Next4Me
 All Classes Files Functions Variables
CmplxTemplate.php
Go to the documentation of this file.
1 <?php
26 class Application_Model_CmplxTemplate extends Zend_Db_Table
27 {
28  //============ Start getTplContext =================================================
35  function getTplContext($entity){
36  $this->TplContext = new Application_Model_TplContext();
37  $this->TplContextCondition = new Application_Model_TplContextCondition();
38  $this->TplContextFactor = new Application_Model_TplContextFactor();
39 
40  $tplContext=array();
41  $tplContextCondition=array();
42  $tplContextFactor=array();
43  $tplContextRowset=$this->TplContext->getTplContext($entity);
44  if($tplContextRowset['resultId']=="0"){
45  foreach ($tplContextRowset['resultCode']['entity'] as $tplContextRow){
46  $tplContextCondition=array();
47  $data=array("IdTplContext"=>$tplContextRow['IdTplContext'], "IdTplContextCondition"=>'0', "IdUserAccount"=>$entity['IdUserAccount'], "UserAccountType"=>$entity['UserAccountType']);
48  $tplContextConditionRowset=$this->TplContextCondition->getTplContextCondition($data);
49 
50  if($tplContextConditionRowset['resultId']=="0"){
51  foreach ($tplContextConditionRowset['resultCode']['entity'] as $tplContextConditionRow){
52  $tplContextFactor=array();
53  $data=array("IdTplContextFactor"=>'0', "IdTplContextCondition"=>$tplContextConditionRow['IdTplContextCondition'], "IdUserAccount"=>$entity['IdUserAccount'], "UserAccountType"=>$entity['UserAccountType']);
54  $tplContextFactorRowset=$this->TplContextFactor->getTplContextFactor($data);
55 
56  if($tplContextFactorRowset['resultId']=="0"){
57  foreach($tplContextFactorRowset['resultCode']['entity'] as $tplContextFactorRow){
58  $tplContextFactor[]=array("IdTplContextFactor"=>$tplContextFactorRow['IdTplContextFactor'],
59  "Name"=>$tplContextFactorRow['Name'],
60  "Type"=>$tplContextFactorRow['Type'],
61  "Function"=>$tplContextFactorRow['Function'],
62  "Value"=>$tplContextFactorRow['Value'],
63  "IdTplContextCondition"=>$tplContextFactorRow['IdTplContextCondition']);
64  }
65  }
66 
67  $tplContextCondition[]=array("IdTplContextCondition"=>$tplContextConditionRow['IdTplContextCondition'],
68  "IdTplContext"=>$tplContextConditionRow['IdTplContext'],
69  "Name"=>$tplContextConditionRow['Name'],
70  "Description"=>$tplContextConditionRow['Description'],
71  "IdContext"=>$tplContextConditionRow['IdContext'],
72  "TplContextFactor"=>$tplContextFactor);
73 
74  }
75  }
76  $tplContext[]=array("IdTplContext"=>$tplContextRow['IdTplContext'],
77  "Name"=>$tplContextRow['Name'],
78  "Description"=>$tplContextRow['Description'],
79  "TplContextCondition"=>$tplContextCondition);
80 
81  }
82 
83  $result=array("resultId"=>$tplContextRowset['resultId'], "resultCode"=>$tplContext);
84  }else{
85  $result=array("resultId"=>$tplContextRowset['resultId'], "resultCode"=>$tplContextRowset['resultCode']);
86  }
87  return array("commit"=>"1","entity"=>$result);
88  }
89  //============ End getTplContext =================================================
90 
91  //============ Start getTplActionType =================================================
98  function getTplActionType($entity){
99  $this->TplActionType = new Application_Model_TplActionType();
100  $this->TplActionTypeAlert = new Application_Model_TplActionTypeAlert();
101  $this->TplActionTypeNextAction = new Application_Model_TplActionTypeNextAction();
102  $this->TplActionTypeProperty = new Application_Model_TplActionTypeProperty();
103  $this->TplActionTypeResult = new Application_Model_TplActionTypeResult();
104 
105  $tplActionType=array();
106 
107  $tplActionTypeRowset=$this->TplActionType->getTplActionType($entity);
108  if($tplActionTypeRowset['resultId']=="0"){
109  foreach ($tplActionTypeRowset['resultCode']['entity'] as $tplActionTypeRow){
110 
111  $data=array("IdTplActionType"=>$tplActionTypeRow['IdTplActionType'],
112  "IdTplActionTypeAlert"=>'0',
113  "IdTplActionTypeNextAction"=>'0',
114  "IdTplActionTypeProperty"=>'0',
115  "IdTplActionTypeResult"=>'0',
116  "IdUserAccount"=>$entity['IdUserAccount'],
117  "UserAccountType"=>$entity['UserAccountType']);
118 
119  $tplActionTypeAlert = array();
120  $tplActionTypeNextAction = array();
121  $tplActionTypeProperty = array();
122  $tplActionTypeResult = array();
123 
124  $tplActionTypeAlertRowset=$this->TplActionTypeAlert->getTplActionTypeAlert($data);
125  if($tplActionTypeAlertRowset['resultId']=="0"){
126  foreach ($tplActionTypeAlertRowset['resultCode']['entity'] as $tplActionTypeAlertRow){
127  $tplActionTypeAlert[] =array("IdTplActionTypeAlert"=>$tplActionTypeAlertRow['IdTplActionTypeAlert'],
128  "IdTplActionType"=>$tplActionTypeAlertRow['IdTplActionType'],
129  "AlertName"=>$tplActionTypeAlertRow['AlertName'],
130  "AlertChannel"=>$tplActionTypeAlertRow['AlertChannel'],
131  "AlertTargetType"=>$tplActionTypeAlertRow['AlertTargetType'],
132  "TimeBefore"=>$tplActionTypeAlertRow['TimeBefore']);
133  }
134  }
135 
136  $tplActionTypeNextActionRowset=$this->TplActionTypeNextAction->getTplActionTypeNextAction($data);
137  if($tplActionTypeNextActionRowset['resultId']=="0"){
138  foreach ($tplActionTypeNextActionRowset['resultCode']['entity'] as $tplActionTypeNextActionRow){
139  $tplActionTypeNextAction[] =array("IdTplActionTypeNextAction"=>$tplActionTypeNextActionRow['IdTplActionTypeNextAction'],
140  "IdTplActionType"=>$tplActionTypeNextActionRow['IdTplActionType'],
141  "Name"=>$tplActionTypeNextActionRow['Name'],
142  "Description"=>$tplActionTypeNextActionRow['Description'],
143  "IsRecursive"=>$tplActionTypeNextActionRow['IsRecursive']);
144  }
145  }
146 
147  $tplActionTypePropertyRowset=$this->TplActionTypeProperty->getTplActionTypeProperty($data);
148  if($tplActionTypePropertyRowset['resultId']=="0"){
149  foreach ($tplActionTypePropertyRowset['resultCode']['entity'] as $tplActionTypePropertyRow){
150  $tplActionTypeProperty[] =array("IdTplActionTypeProperty"=>$tplActionTypePropertyRow['IdTplActionTypeProperty'],
151  "IdTplActionType"=>$tplActionTypePropertyRow['IdTplActionType'],
152  "PropertyName"=>$tplActionTypePropertyRow['PropertyName'],
153  "PropertyType"=>$tplActionTypePropertyRow['PropertyType'],
154  "Description"=>$tplActionTypePropertyRow['Description'],
155  "PropertyString"=>$tplActionTypePropertyRow['PropertyString'],
156  "PropertyDate"=>$tplActionTypePropertyRow['PropertyDate'],
157  "PropertyValue"=>$tplActionTypePropertyRow['PropertyValue']);
158  }
159  }
160 
161  $tplActionTypeResultRowset=$this->TplActionTypeResult->getTplActionTypeResult($data);
162  if($tplActionTypeResultRowset['resultId']=="0"){
163  foreach ($tplActionTypeResultRowset['resultCode']['entity'] as $tplActionTypeResultRow){
164  $tplActionTypeResult[] =array("IdTplActionTypeResult"=>$tplActionTypeResultRow['IdTplActionTypeResult'],
165  "IdTplActionType"=>$tplActionTypeResultRow['IdTplActionType'],
166  "Name"=>$tplActionTypeResultRow['Name'],
167  "Description"=>$tplActionTypeResultRow['Description'],
168  "IsSucces"=>$tplActionTypeResultRow['IsSucces'],
169  "IdTplActionTypeNextAction"=>$tplActionTypeResultRow['IdTplActionTypeNextAction']);
170  }
171  }
172  $tplActionType[]=array("IdTplActionType"=>$tplActionTypeRow['IdTplActionType'],
173  "IdTplContext"=>$tplActionTypeRow['IdTplContext'],
174  "Name"=>$tplActionTypeRow['Name'],
175  "Icon"=>$tplActionTypeRow['Icon'],
176  "DurataImplicita"=>$tplActionTypeRow['DurataImplicita'],
177  "TplActionTypeAlert"=>$tplActionTypeAlert,
178  "TplActionTypeNextAction"=>$tplActionTypeNextAction,
179  "TplActionTypeProperty"=>$tplActionTypeProperty,
180  "TplActionTypeResult"=>$tplActionTypeResult);
181 
182  }
183 
184  $result=array("resultId"=>$tplActionTypeRowset['resultId'], "resultCode"=>$tplActionType);
185  }else{
186  $result=array("resultId"=>$tplActionTypeRowset['resultId'], "resultCode"=>$tplActionTypeRowset['resultCode']);
187  }
188  return array("commit"=>"1","entity"=>$result);
189  }
190  //============ End getTplActionType =================================================
191 
192  //============ Start getTplAsset =================================================
199  function getTplAsset($entity){
200  $this->TplAsset = new Application_Model_TplAsset();
201  $this->TplAssetProperty = new Application_Model_TplAssetProperty();
202  $this->TplAssetPropertyMicroflow = new Application_Model_TplAssetPropertyMicroflow();
203 
204  $tplAsset = array();
205  $tplAssetProperty = array();
206  $tplAssetPropertyMicroflow = array();
207 
208  $tplAssetRowset=$this->TplAsset->getTplAsset($entity);
209  if($tplAssetRowset['resultId']=="0"){
210  foreach ($tplAssetRowset['resultCode']['entity'] as $tplAssetRow){
211  $tplAssetProperty=array();
212  $data=array("IdTplAsset"=>$tplAssetRow['IdTplAsset'], "IdTplAssetProperty"=>'0', "IdUserAccount"=>$entity['IdUserAccount'], "UserAccountType"=>$entity['UserAccountType']);
213  $tplAssetPropertyRowset=$this->TplAssetProperty->getTplAssetProperty($data);
214 
215  if($tplAssetPropertyRowset['resultId']=="0"){
216  foreach ($tplAssetPropertyRowset['resultCode']['entity'] as $tplAssetPropertyRow){
217  $tplAssetPropertyMicroflow=array();
218  $data=array("IdTplAssetPropertyMicroflow"=>'0', "IdTplAssetProperty"=>$tplAssetPropertyRow['IdTplAssetProperty'], "IdUserAccount"=>$entity['IdUserAccount'], "UserAccountType"=>$entity['UserAccountType']);
219  $tplAssetPropertyMicroflowRowset=$this->TplAssetPropertyMicroflow->getTplAssetPropertyMicroflow($data);
220 
221  if($tplAssetPropertyMicroflowRowset['resultId']=="0"){
222  foreach($tplAssetPropertyMicroflowRowset['resultCode']['entity'] as $tplAssetPropertyMicroflowRow){
223  $tplAssetPropertyMicroflow[]=array("IdTplAssetPropertyMicroflow"=>$tplAssetPropertyMicroflowRow['IdTplAssetPropertyMicroflow'],
224  "IdTplAssetProperty"=>$tplAssetPropertyMicroflowRow['IdTplAssetProperty'],
225  "IdTplMf"=>$tplAssetPropertyMicroflowRow['IdTplMf']);
226  }
227  }
228 
229  $tplAssetProperty[]=array("IdTplAssetProperty"=>$tplAssetPropertyRow['IdTplAssetProperty'],
230  "IdTplAsset"=>$tplAssetPropertyRow['IdTplAsset'],
231  "Name"=>$tplAssetPropertyRow['Name'],
232  "PropertyType"=>$tplAssetPropertyRow['PropertyType'],
233  "PropertyImplicitValue"=>$tplAssetPropertyRow['PropertyImplicitValue'],
234  "PropertyString"=>$tplAssetPropertyRow['PropertyString'],
235  "PropertyDate"=>$tplAssetPropertyRow['PropertyDate'],
236  "PropertyValue"=>$tplAssetPropertyRow['PropertyValue'],
237  "TplAssetPropertyMicroflow"=>$tplAssetPropertyMicroflow);
238 
239  }
240  }
241  $tplAsset[]=array("IdTplAsset"=>$tplAssetRow['IdTplAsset'],
242  "Name"=>$tplAssetRow['Name'],
243  "TplAssetProperty"=>$tplAssetProperty);
244 
245  }
246 
247  $result=array("resultId"=>$tplAssetRowset['resultId'], "resultCode"=>$tplAsset);
248  }else{
249  $result=array("resultId"=>$tplAssetRowset['resultId'], "resultCode"=>$tplAssetRowset['resultCode']);
250  }
251  return array("commit"=>"1","entity"=>$result);
252  }
253  //============ End getTplAsset =================================================
254 
255  //============ Start getTplMicroflow =================================================
262  function getTplMicroflow($entity){
263  $this->TplMicroflow = new Application_Model_TplMicroflow();
264  $this->TplMicroflowAction = new Application_Model_TplMicroflowAction();
265  $this->TplMicroflowActionResult = new Application_Model_TplMicroflowActionResult();
266  $this->TplMicroflowNextAction = new Application_Model_TplMicroflowNextAction();
267 
268  $tplMicroflow = array();
269  $tplMicroflowAction = array();
270  $tplMicroflowActionResult = array();
271  $tplMicroflowNextAction = array();
272 
273  $tplMicroflowRowset=$this->TplMicroflow->getTplMicroflow($entity);
274  if($tplMicroflowRowset['resultId']=="0"){
275  foreach ($tplMicroflowRowset['resultCode']['entity'] as $tplMicroflowRow){
276  $tplMicroflowAction=array();
277  $data=array("IdTplMicroflow"=>$tplMicroflowRow['IdTplMicroflow'], "IdTplMicroflowAction"=>'0', "IdUserAccount"=>$entity['IdUserAccount'], "UserAccountType"=>$entity['UserAccountType']);
278  $tplMicroflowActionRowset=$this->TplMicroflowAction->getTplMicroflowAction($data);
279 
280  if($tplMicroflowActionRowset['resultId']=="0"){
281  foreach ($tplMicroflowActionRowset['resultCode']['entity'] as $tplMicroflowActionRow){
282  $tplMicroflowActionResult=array();
283  $data=array("IdTplMicroflowActionResult"=>'0', "IdTplMicroflowAction"=>$tplMicroflowActionRow['IdTplMicroflowAction'], "IdUserAccount"=>$entity['IdUserAccount'], "UserAccountType"=>$entity['UserAccountType']);
284  $tplMicroflowActionResultRowset=$this->TplMicroflowActionResult->getTplMicroflowActionResult($data);
285 
286  if($tplMicroflowActionResultRowset['resultId']=="0"){
287  foreach($tplMicroflowActionResultRowset['resultCode']['entity'] as $tplMicroflowActionResultRow){
288 
289  $tplMicroflowNextAction=array();
290  $data=array("IdTplMicroflowAction"=>'0', "IdTplMicroflowNextAction"=>$tplMicroflowActionResultRow['IdTplMicroflowNextAction'], "IdUserAccount"=>$entity['IdUserAccount'], "UserAccountType"=>$entity['UserAccountType']);
291  $tplMicroflowNextActionRowset=$this->TplMicroflowNextAction->getTplMicroflowNextAction($data);
292 
293  if($tplMicroflowNextActionRowset['resultId']=="0"){
294  foreach($tplMicroflowNextActionRowset['resultCode']['entity'] as $tplMicroflowNextActionRow){
295  $tplMicroflowNextAction[]=array("IdTplMicroflowNextAction"=>$tplMicroflowNextActionRow['IdTplMicroflowNextAction'],
296  "IdTplMicroflowAction"=>$tplMicroflowNextActionRow['IdTplMicroflowAction'],
297  "Name"=>$tplMicroflowNextActionRow['Name'],
298  "Description"=>$tplMicroflowNextActionRow['Description'],
299  "IsRecursive"=>$tplMicroflowNextActionRow['IsRecursive'],
300  "IdTplActionTypeNextAction"=>$tplMicroflowNextActionRow['IdTplActionTypeNextAction']);
301  }
302  }
303  $tplMicroflowActionResult[]=array("IdTplMicroflowActionResult"=>$tplMicroflowActionResultRow['IdTplMicroflowActionResult'],
304  "IdTplMicroflowAction"=>$tplMicroflowActionResultRow['IdTplMicroflowAction'],
305  "Name"=>$tplMicroflowActionResultRow['Name'],
306  "Description"=>$tplMicroflowActionResultRow['Description'],
307  "IsSuccess"=>$tplMicroflowActionResultRow['IsSuccess'],
308  "IdTplMicroflowNextAction"=>$tplMicroflowActionResultRow['IdTplMicroflowNextAction'],
309  "IdTplActionTypeResult"=>$tplMicroflowActionResultRow['IdTplActionTypeResult'],
310  "TplMicroflowNextAction"=>$tplMicroflowNextAction);
311  }
312  }
313 
314  $tplMicroflowAction[]=array("IdTplMicroflowAction"=>$tplMicroflowActionRow['IdTplMicroflowAction'],
315  "IdTplMicroflow"=>$tplMicroflowActionRow['IdTplMicroflow'],
316  "IdTplActionType"=>$tplMicroflowActionRow['IdTplActionType'],
317  "Name"=>$tplMicroflowActionRow['Name'],
318  "Description"=>$tplMicroflowActionRow['Description'],
319  "IdTplContext"=>$tplMicroflowActionRow['IdTplContext'],
320  "TplMicroflowActionResult"=>$tplMicroflowActionResult);
321 
322  }
323  }
324  $tplMicroflow[]=array("IdTplMicroflow"=>$tplMicroflowRow['IdTplMicroflow'],
325  "Name"=>$tplMicroflowRow['Name'],
326  "IdTplAssetProperty"=>$tplMicroflowRow['IdTplAssetProperty'],
327  "TplMicroflowAction"=>$tplMicroflowAction);
328 
329  }
330 
331  $result=array("resultId"=>$tplMicroflowRowset['resultId'], "resultCode"=>$tplMicroflow);
332  }else{
333  $result=array("resultId"=>$tplMicroflowRowset['resultId'], "resultCode"=>$tplMicroflowRowset['resultCode']);
334  }
335  return array("commit"=>"1","entity"=>$result);
336  }
337  //============ End getTplMicroflow =================================================
338 }