当前位置: 首页>>代码示例>>PHP>>正文


PHP x2base::update方法代码示例

本文整理汇总了PHP中x2base::update方法的典型用法代码示例。如果您正苦于以下问题:PHP x2base::update方法的具体用法?PHP x2base::update怎么用?PHP x2base::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在x2base的用法示例。


在下文中一共展示了x2base::update方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $users = User::getNames();
     $fields = Fields::model()->findAllByAttributes(array('modelName' => 'Product'));
     foreach ($fields as $field) {
         if ($field->type == 'link') {
             $fieldName = $field->fieldName;
             $type = ucfirst($field->linkType);
             if (is_numeric($model->{$fieldName}) && $model->{$fieldName} != 0) {
                 eval("\$lookupModel={$type}::model()->findByPk(" . $model->{$fieldName} . ");");
                 if (isset($lookupModel)) {
                     $model->{$fieldName} = $lookupModel->name;
                 }
             }
         }
     }
     if (isset($_POST['Product'])) {
         $temp = $model->attributes;
         $model->setX2Fields($_POST['Product']);
         // generate history
         $action = new Actions();
         $action->associationType = 'product';
         $action->associationId = $model->id;
         $action->associationName = $model->name;
         $action->assignedTo = Yii::app()->user->getName();
         $action->completedBy = Yii::app()->user->getName();
         $action->dueDate = time();
         $action->completeDate = time();
         $action->visibility = 1;
         $action->complete = 'Yes';
         $action->actionDescription = "Update: {$model->name}\n            Type: {$model->type}\n            Price: {$model->price}\n            Currency: {$model->currency}\n            Inventory: {$model->inventory}";
         $action->save();
         parent::update($model, $temp, '0');
     }
     $this->render('update', array('model' => $model, 'users' => $users));
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:42,代码来源:ProductsController.php

示例2: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $users = User::getNames();
     $fields = Fields::model()->findAllByAttributes(array('modelName' => "Products"));
     foreach ($fields as $field) {
         if ($field->type == 'link') {
             $fieldName = $field->fieldName;
             $type = ucfirst($field->linkType);
             if (is_numeric($model->{$fieldName}) && $model->{$fieldName} != 0) {
                 eval("\$lookupModel={$type}::model()->findByPk(" . $model->{$fieldName} . ");");
                 if (isset($lookupModel)) {
                     $model->{$fieldName} = $lookupModel->name;
                 }
             }
         }
     }
     if (isset($_POST['Product'])) {
         $temp = $model->attributes;
         foreach ($_POST['Product'] as $name => $value) {
             if ($value == $model->getAttributeLabel($name)) {
                 $_POST['Product'][$name] = '';
             }
         }
         foreach ($_POST as $key => $arr) {
             $pieces = explode("_", $key);
             if (isset($pieces[0]) && $pieces[0] == 'autoselect') {
                 $newKey = $pieces[1];
                 if (isset($_POST[$newKey . "_id"]) && $_POST[$newKey . "_id"] != "") {
                     $val = $_POST[$newKey . "_id"];
                 } else {
                     $field = Fields::model()->findByAttributes(array('fieldName' => $newKey));
                     if (isset($field)) {
                         $type = ucfirst($field->linkType);
                         if ($type != "Contacts") {
                             eval("\$lookupModel={$type}::model()->findByAttributes(array('name'=>'{$arr}'));");
                         } else {
                             $names = explode(" ", $arr);
                             $lookupModel = Contacts::model()->findByAttributes(array('firstName' => $names[0], 'lastName' => $names[1]));
                         }
                         if (isset($lookupModel)) {
                             $val = $lookupModel->id;
                         } else {
                             $val = $arr;
                         }
                     }
                 }
                 $model->{$newKey} = $val;
             }
         }
         foreach (array_keys($model->attributes) as $field) {
             if (isset($_POST['Product'][$field])) {
                 $model->{$field} = $_POST['Product'][$field];
                 $fieldData = Fields::model()->findByAttributes(array('modelName' => 'Products', 'fieldName' => $field));
                 if ($fieldData->type == 'assignment' && $fieldData->linkType == 'multiple') {
                     $model->{$field} = Accounts::parseUsers($model->{$field});
                 } elseif ($fieldData->type == 'date') {
                     $model->{$field} = strtotime($model->{$field});
                 }
             }
         }
         // generate history
         $action = new Actions();
         $action->associationType = 'product';
         $action->associationId = $model->id;
         $action->associationName = $model->name;
         $action->assignedTo = Yii::app()->user->getName();
         $action->completedBy = Yii::app()->user->getName();
         $action->dueDate = time();
         $action->completeDate = time();
         $action->visibility = 1;
         $action->complete = 'Yes';
         $action->actionDescription = "Update: <b>{$model->name}</b>\n\t\t\t\tType: <b>{$model->type}</b>\n\t\t\t\tPrice: <b>{$model->price}</b>\n\t\t\t\tCurrency: <b>{$model->currency}</b>\n\t\t\t\tInventory: <b>{$model->inventory}</b>";
         $action->save();
         parent::update($model, $temp, '0');
     }
     $this->render('update', array('model' => $model, 'users' => $users));
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:83,代码来源:DefaultController.php

示例3: update

 public function update($model, $oldAttributes, $api)
 {
     $dueDate = strtotime($model->dueDate);
     $model->dueDate = $dueDate === false ? '' : $dueDate;
     //date('Y-m-d',$dueDate).' 23:59:59';	// default to being due by 11:59 PM
     $association = $this->getAssociation($model->associationType, $model->associationId);
     if ($association != null) {
         $model->associationName = $association->name;
     } else {
         $model->associationName = 'None';
         $model->associationId = 0;
     }
     if (!is_numeric($model->assignedTo)) {
         // assigned to user
         $profile = ProfileChild::model()->findByAttributes(array('username' => $model->assignedTo));
         $profile->updateGoogleCalendarEvent($model);
         // update action in Google Calendar if user has a Google Calendar
     }
     if ($api == 0) {
         parent::update($model, $oldAttributes, $api);
     } else {
         return parent::update($model, $oldAttributes, $api);
     }
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:24,代码来源:DefaultController.php

示例4: update

 public function update($model, $oldAttributes, $api = 0)
 {
     // process currency into an INT
     //            $model->quoteAmount = $this->parseCurrency($model->quoteAmount,false);
     $arr = $model->associatedContacts;
     if (isset($model->associatedContacts)) {
         foreach ($model->associatedContacts as $contact) {
             $rel = new Relationships();
             $rel->firstType = 'Contacts';
             $rel->firstId = $contact;
             $rel->secondType = 'Sales';
             $rel->secondId = $model->id;
             if ($rel->firstId != "" && $rel->secondId != "") {
                 $rel->save();
             }
         }
         $model->associatedContacts = Sales::parseContacts($arr);
     }
     $model->lastUpdated = time();
     // if($model->expectedCloseDate!=""){
     // $model->expectedCloseDate=strtotime($model->expectedCloseDate);
     // }
     parent::update($model, $oldAttributes, '0');
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:24,代码来源:DefaultController.php

示例5: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $users = User::getNames();
     if (isset($_POST['Templates'])) {
         $temp = $model->attributes;
         $model->setX2Fields($_POST['Templates']);
         parent::update($model, $temp, '0');
     }
     $this->render('update', array('model' => $model, 'users' => $users));
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:16,代码来源:TemplatesController.php

示例6: update

 public function update($model, $oldAttributes, $api)
 {
     // now in Actions::beforeSave()
     /* $model->dueDate = Formatter::parseDateTime($model->dueDate);
     
               if($model->completeDate)
               $model->completeDate = Formatter::parseDateTime($model->completeDate);
     
               $association = $this->getAssociation($model->associationType,$model->associationId);
     
               if($association != null) {
               $model->associationName = $association->name;
               } else {
               $model->associationName = 'None';
               $model->associationId = 0;
               } */
     // now in Actions::synchGoogleCalendar()
     /* if( !is_numeric($model->assignedTo)) { // assigned to user
        $profile = Profile::model()->findByAttributes(array('username'=>$model->assignedTo));
        if(isset($profile)) // prevent error for actions assigned to 'Anyone'
        $profile->updateGoogleCalendarEvent($model); // update action in Google Calendar if user has a Google Calendar
        } else { // Assigned to group
        $groups = Yii::app()->db->createCommand()->select('userId')->from('x2_group_to_user')->where("groupId={$model->assignedTo}")->queryAll();
        foreach($groups as $group) {
        $profile = Profile::model()->findByPk($group['userId']);
        if(isset($profile)) // prevent error for actions assigned to 'Anyone'
        $profile->updateGoogleCalendarEvent($model);
        }
        } */
     if ($api == 0) {
         parent::update($model, $oldAttributes, $api);
     } else {
         return parent::update($model, $oldAttributes, $api);
     }
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:35,代码来源:ActionsController.php

示例7: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $name = 'Marketing';
     parent::update($model, $name);
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:11,代码来源:MarketingController.php

示例8: update

 public function update($model, $oldAttributes, $api)
 {
     if ($api == 0) {
         parent::update($model, $oldAttributes, $api);
     } else {
         return parent::update($model, $oldAttributes, $api);
     }
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:8,代码来源:DefaultController.php

示例9: update

 public function update($model, $oldAttributes, $api)
 {
     // process currency into an INT
     $model->annualRevenue = $this->parseCurrency($model->annualRevenue, false);
     if ($api == 0) {
         parent::update($model, $oldAttributes, $api);
     } else {
         return parent::update($model, $oldAttributes, $api);
     }
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:10,代码来源:DefaultController.php

示例10: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     if (isset($_POST['Campaign'])) {
         $oldAttributes = $model->attributes;
         $model->setX2Fields($_POST['Campaign']);
         parent::update($model, $oldAttributes, 0);
     }
     $this->render('update', array('model' => $model));
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:15,代码来源:DefaultController.php

示例11: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $users = User::getNames();
     $fields = Fields::model()->findAllByAttributes(array('modelName' => "Templates"));
     foreach ($fields as $field) {
         if ($field->type == 'link') {
             $fieldName = $field->fieldName;
             $type = ucfirst($field->linkType);
             if (is_numeric($model->{$fieldName}) && $model->{$fieldName} != 0) {
                 eval("\$lookupModel={$type}::model()->findByPk(" . $model->{$fieldName} . ");");
                 if (isset($lookupModel)) {
                     $model->{$fieldName} = $lookupModel->name;
                 }
             }
         } elseif ($field->type == 'date') {
             $fieldName = $field->fieldName;
             $model->{$fieldName} = date("Y-m-d", $model->{$fieldName});
         }
     }
     if (isset($_POST['Templates'])) {
         $temp = $model->attributes;
         foreach ($_POST['Templates'] as $name => $value) {
             if ($value == $model->getAttributeLabel($name)) {
                 $_POST['Templates'][$name] = '';
             }
         }
         foreach ($_POST as $key => $arr) {
             $pieces = explode("_", $key);
             if (isset($pieces[0]) && $pieces[0] == 'autoselect') {
                 $newKey = $pieces[1];
                 if (isset($_POST[$newKey . "_id"]) && $_POST[$newKey . "_id"] != "") {
                     $val = $_POST[$newKey . "_id"];
                 } else {
                     $field = Fields::model()->findByAttributes(array('fieldName' => $newKey));
                     if (isset($field)) {
                         $type = ucfirst($field->linkType);
                         if ($type != "Contacts") {
                             eval("\$lookupModel={$type}::model()->findByAttributes(array('name'=>'{$arr}'));");
                         } else {
                             $names = explode(" ", $arr);
                             if (count($names) > 1) {
                                 $lookupModel = Contacts::model()->findByAttributes(array('firstName' => $names[0], 'lastName' => $names[1]));
                             }
                         }
                         if (isset($lookupModel)) {
                             $val = $lookupModel->id;
                         } else {
                             $val = $arr;
                         }
                     }
                 }
                 $model->{$newKey} = $val;
             }
         }
         $temp = $model->attributes;
         foreach (array_keys($model->attributes) as $field) {
             if (isset($_POST['Templates'][$field])) {
                 $model->{$field} = $_POST['Templates'][$field];
                 $fieldData = Fields::model()->findByAttributes(array('modelName' => 'Templates', 'fieldName' => $field));
                 if ($fieldData->type == 'assignment' && $fieldData->linkType == 'multiple') {
                     $model->{$field} = Accounts::parseUsers($model->{$field});
                 } elseif ($fieldData->type == 'date') {
                     $model->{$field} = strtotime($model->{$field});
                 }
             }
         }
         parent::update($model, $temp, '0');
     }
     $this->render('update', array('model' => $model, 'users' => $users));
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:76,代码来源:DefaultController.php


注:本文中的x2base::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。