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


PHP SugarController::action_save方法代码示例

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


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

示例1: unset

 function action_save()
 {
     $old_id = $this->bean->id;
     // create new version
     unset($this->bean->id);
     parent::action_save();
     // redirect to new version
     $this->return_id = $this->bean->id;
     // hide old version
     $this->bean->mark_deleted($old_id);
 }
开发者ID:santara12,项目名称:OpenQuotesAndContracts,代码行数:11,代码来源:controller.php

示例2: testaction_save

 public function testaction_save()
 {
     $SugarController = new SugarController();
     $SugarController->setModule('Users');
     $SugarController->loadBean();
     //execute the method and check if it either works or throws an mysql exception.
     //Fail if it throws any other exception.
     try {
         $SugarController->action_save();
     } catch (Exception $e) {
         $this->assertStringStartsWith('mysqli_query()', $e->getMessage());
     }
     $this->assertTrue(true);
 }
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:14,代码来源:SugarControllerTest.php

示例3: getJSONobj

 function action_save()
 {
     if (empty($this->bean->id)) {
         parent::action_save();
     }
     $this->removeCategories();
     // NOTE: call from_html _before_ calling $json->decode... WTF!
     $json = getJSONobj();
     // workaround for #276
     $hiddenFieldContent = $_POST['categoryHiddenField'];
     if (!empty($hiddenFieldContent)) {
         $categoryHiddenField = $json->decode(from_html($hiddenFieldContent));
         //$GLOBALS['log']->error("product catalog tree structure: ". var_export($categoryHiddenField,true));
         // for each category store its subcategories in the subcategories attribute (saveCategories()) and store the ids of the root categories in the category_ids fields of the product catalog
         $this->bean->category_ids = implode(' ', $this->saveCategories($categoryHiddenField));
     } else {
         $GLOBALS['log']->warn("field 'item' which is neccessary for creating category structure does not exist");
     }
     parent::action_save();
 }
开发者ID:santara12,项目名称:OpenQuotesAndContracts,代码行数:20,代码来源:controller.php

示例4: empty

 function action_save()
 {
     $isDuplicate = empty($_REQUEST['record']) && empty($_REQUEST['return_id']);
     // check if there are any modifications
     $modified = hasBeenModified($this->bean, array());
     if (!$isDuplicate && !$modified) {
         return;
         // skip save if this is not a duplicate and nothing been modified
     }
     //2.0 We determine to what catalog category belongs
     if (!empty($this->bean->relatedcategory_id)) {
         $category = new oqc_Category();
         if ($category->retrieve($this->bean->relatedcategory_id)) {
             $this->bean->catalog_id = $category->catalog_id;
         }
     }
     // save id of user that created the old version
     global $timedate;
     $dateCreated = $timedate->to_db($this->bean->date_entered);
     $createdById = $this->bean->created_by;
     $old_id = $this->begin_new_version();
     parent::action_save();
     $this->end_new_version($old_id);
     $this->initializeUniqueIdentifier();
     $this->save_packaged_products();
     $this->saveAttachedDocuments();
     $this->saveProductOptions();
     $this->saveImageWithResize();
     $this->updateRelatedProducts($old_id);
     //$GLOBALS['log']->error("Dates are: ". $this->bean->date_entered );
     // the new contract should have the same creator and creation date as the previous version, fix for #486
     if ($dateCreated) {
         $this->bean->date_entered = $dateCreated;
     }
     if ($createdById) {
         $this->bean->created_by = $createdById;
     }
     if (!isset($_POST['assigned_user_id'])) {
         $this->bean->assigned_user_id = $this->bean->created_by;
     }
     //2.1 set this only if it is not in $_POST
     parent::action_save();
 }
开发者ID:santara12,项目名称:OpenQuotesAndContracts,代码行数:43,代码来源:controller.php

示例5: action_save

 function action_save()
 {
     $old_id = null;
     $isLinked = false;
     if (isset($_POST['isLinked'])) {
         $isLinked = $_POST['isLinked'] == 'true' ? true : false;
     }
     // create new version of Addition and update Contract idsofadditions field	since we are creating new version of Addition
     if (!$isLinked && !empty($this->bean->contractid)) {
         if (!$this->bean->is_latest) {
             $latestVersion = $this->bean->getLatestRevision();
             $old_id = $latestVersion->id;
             $this->bean->version = intval($latestVersion->version + 1);
         } else {
             $old_id = $this->bean->id;
             $this->bean->version = intval($this->bean->version + 1);
         }
         //$GLOBALS['log']->fatal('going branch 1');
         unset($this->bean->id);
         unset($this->bean->{$this->bean->table_name . '_number'});
         $this->bean->deleted = 0;
         $this->bean->nextrevisions = '';
         $this->bean->is_latest = 1;
         //1.7.6
         $this->bean->previousrevision = $old_id;
         SugarController::action_save();
         //retrieve saved bean for oqc...number that is created during save
         $oqc_fld_number = $this->bean->table_name . '_number';
         $savedBean = new $this->bean->object_name();
         if ($savedBean->retrieve($this->bean->id)) {
             $this->bean->{$oqc_fld_number} = intval($savedBean->{$oqc_fld_number});
         }
         // 1.7.6 Keep generated svnumber for all future references
         if (empty($this->bean->svnumber)) {
             $this->bean->fill_in_svnumber();
         }
         $this->bean->oqc_delete_relationships($this->bean->id);
         // deleting documents and services- will be recreated during save
         //Recreate relationship to original contract
         $contract = 'oqc_contract';
         $this->bean->load_relationship($contract);
         $this->bean->oqc_contract->add($this->bean->contractid);
         //Update idsofadditions linked of contract
         $linkedContract = new oqc_Contract();
         if ($linkedContract->retrieve($this->bean->contractid)) {
             $linkedContract->idsofadditions = str_replace($old_id, $this->bean->id, $linkedContract->idsofadditions);
             $linkedContract->save();
         }
     } elseif ($isLinked) {
         if ($this->bean->deleted == 1) {
             $this->bean->mark_undeleted($this->bean->id);
         }
         $this->bean->deleted = 0;
         $this->bean->is_latest = 1;
         //$GLOBALS['log']->fatal('going branch 3');
         //retrieve saved bean for oqc...number that is created during save
         $oqc_fld_number = $this->bean->table_name . '_number';
         $savedBean = new $this->bean->object_name();
         if ($savedBean->retrieve($this->bean->id)) {
             $this->bean->{$oqc_fld_number} = intval($savedBean->{$oqc_fld_number});
         }
         // 1.7.6 Keep generated svnumber for all future references
         if (empty($this->bean->svnumber)) {
             $this->bean->fill_in_svnumber();
         }
         $this->bean->oqc_delete_relationships($this->bean->id);
         // deleting documents and services- will be recreated during save
         //Recreate relationship to original contract
         $contract = 'oqc_contract';
         $this->bean->load_relationship($contract);
         $this->bean->oqc_contract->add($this->bean->contractid);
         // Add new addition to the list of idsofadditions
         $linkedContract = new oqc_Contract();
         if ($linkedContract->retrieve($this->bean->contractid)) {
             $linkedContract->idsofadditions = $linkedContract->idsofadditions . " " . $this->bean->id;
             $linkedContract->save();
         }
     }
     if (isset($_POST['servicesVAT'])) {
         $this->bean->vat = $_POST['servicesVAT'];
     } else {
         if (isset($_POST['servicesOnceVAT'])) {
             $this->bean->vat = $_POST['servicesOnceVAT'];
         }
     }
     $this->saveAttachedDocuments();
     $this->saveTextblocks();
     $this->saveServices();
     if (!isset($_POST['assigned_user_id'])) {
         $this->bean->assigned_user_id = $this->bean->created_by;
     }
     //2.1 set this only if it is not in $_POST
     SugarController::action_save();
     // redirect to new version
     $this->return_id = $this->bean->id;
     $this->return_module = $this->module;
     // If previous version exist, hide it and update nextrevision field
     if ($old_id != '') {
         $oldBean = new $this->bean->object_name();
         if ($oldBean->retrieve($old_id)) {
//.........这里部分代码省略.........
开发者ID:santara12,项目名称:OpenQuotesAndContracts,代码行数:101,代码来源:controller.php

示例6: unset

 function action_save()
 {
     global $timedate;
     $old_id = null;
     $isLinked = false;
     if (isset($_POST['isLinked'])) {
         $isLinked = $_POST['isLinked'] == 'true' ? true : false;
     }
     //$GLOBALS['log']->fatal('isLinked variable is '.$isLinked . ' POST is '. $_POST['isLinked'] );
     // create a detached version without quote references
     if (!$isLinked && empty($this->bean->offeringid)) {
         if ($this->bean->is_latest) {
             $old_id = $this->bean->id;
             $this->bean->version = $this->bean->version + 1;
         } else {
             $latestRevision = $this->bean->getLatestRevision($this->bean->id);
             $old_id = $latestRevision->id;
             $this->bean->version = $latestRevision->version + 1;
         }
         //$GLOBALS['log']->fatal('going branch 1');
         unset($this->bean->id);
         unset($this->bean->{$this->bean->table_name . '_number'});
         $this->bean->deleted = 0;
         $this->bean->nextrevisions = '';
         $this->bean->is_latest = 1;
         //1.7.6
         $this->bean->idsofadditions = '';
         //2.0RC2 remove additions since this is new version of Contract
         $this->bean->previousrevision = $old_id;
         parent::action_save();
         //retrieve saved bean for oqc...number that is created during save
         $oqc_fld_number = $this->bean->table_name . '_number';
         $savedBean = new $this->bean->object_name();
         if ($savedBean->retrieve($this->bean->id)) {
             $this->bean->{$oqc_fld_number} = intval($savedBean->{$oqc_fld_number});
         }
         // 1.7.6 Keep generated svnumber for all future references
         if (empty($this->bean->svnumber)) {
             $this->bean->fill_in_svnumber();
         }
     } elseif (!empty($this->bean->offeringid) && !$isLinked) {
         //$GLOBALS['log']->fatal('going branch 2');
         if ($this->bean->is_latest == 0 && $this->bean->deleted == 0) {
             return header("Location: index.php?action=DetailView&module={$this->bean->object_name}&record={$this->bean->id}");
             // do nothing user is modifying old record; otherwise it is just created from Quote
         }
         //$GLOBALS['log']->fatal('going branch 2a');
         if ($this->bean->deleted == 1) {
             $this->bean->mark_undeleted($this->bean->id);
             $old_id = $this->bean->previousrevision;
         }
         $this->bean->deleted = 0;
         $this->bean->is_latest = 1;
         //1.7.6 addition
         $this->bean->idsofadditions = '';
         //2.0RC2 remove additions since this is new version of Contract
         $this->bean->oqc_cleanup_document_revision($this->bean->id);
         //delete document revision that is no longer valid after modification
         if (empty($this->bean->svnumber)) {
             $this->bean->fill_in_svnumber();
         }
         $this->bean->oqc_delete_relationships($this->bean->id);
         // deleting documents and services- will be recreated during save
     } elseif ($isLinked) {
         if ($this->bean->deleted == 1) {
             $this->bean->mark_undeleted($this->bean->id);
         }
         $this->bean->deleted = 0;
         $this->bean->is_latest = 1;
         $this->bean->idsofadditions = '';
         //2.0RC2 remove additions since this is new version of Contract
         $old_id = $this->bean->previousrevision;
         //$GLOBALS['log']->fatal('going branch 3');
         //retrieve saved bean for oqc...number that is created during save
         $oqc_fld_number = $this->bean->table_name . '_number';
         $savedBean = new $this->bean->object_name();
         if ($savedBean->retrieve($this->bean->id)) {
             $this->bean->{$oqc_fld_number} = intval($savedBean->{$oqc_fld_number});
         }
         // 1.7.6 Keep generated svnumber for all future references
         if (empty($this->bean->svnumber)) {
             $this->bean->fill_in_svnumber();
         }
         $this->bean->oqc_delete_relationships($this->bean->id);
         // deleting documents and services- will be recreated during save
         //Add related Quote to subpanel
         if ($this->bean->object_name == 'oqc_Contract') {
             $quote = 'oqc_offering';
             $this->bean->load_relationship($quote);
             $this->bean->{$quote}->add($this->bean->offeringid);
         }
     }
     if (isset($_POST['servicesVAT'])) {
         $this->bean->vat = $_POST['servicesVAT'];
     } else {
         if (isset($_POST['servicesOnceVAT'])) {
             $this->bean->vat = $_POST['servicesOnceVAT'];
         }
     }
     $this->saveAttachedDocuments();
//.........这里部分代码省略.........
开发者ID:santara12,项目名称:OpenQuotesAndContracts,代码行数:101,代码来源:oqc_ContractBaseController.php

示例7: action_save

 public function action_save()
 {
     $item = BeanFactory::getBean('xInventories');
     if ($this->bean->new_with_id == true) {
         // new bean want to update xinventory must be implemented in xInventoryRecord bean class;
     } else {
         if ($this->pre_operation != $this->bean->operation || $this->pre_quantity != $this->bean->quantity || $this->pre_xinventory_id != $this->bean->xinventory_id) {
             if ($this->pre_xinventory_id == $this->bean->xinventory_id) {
                 if ($item->retrieve($this->bean->xinventory_id) != null) {
                     if ($this->pre_operation == $this->bean->operation) {
                         $diff = $this->bean->quantity - $this->pre_quantity;
                         if ($this->bean->operation == 'in') {
                             $item->quantity += $diff;
                         } else {
                             $item->quantity -= $diff;
                         }
                     } else {
                         // operation changed
                         if ($this->pre_operation == 'in') {
                             $item->quantity -= $this->pre_quantity;
                             $item->quantity -= $this->bean->quantity;
                         } else {
                             $item->quantity += $this->pre_quantity;
                             $item->quantity += $this->bean->quantity;
                         }
                     }
                     if ($item->quantity < 0) {
                         $item->quantity = 0;
                     }
                     $item->save();
                 }
             } else {
                 // xinventory id changed
                 if ($item->retrieve($this->pre_xinventory_id) != null) {
                     if ($this->pre_operation == 'in') {
                         $item->quantity -= $this->pre_quantity;
                         if ($item->quantity < 0) {
                             $item->quantity = 0;
                         }
                     } else {
                         $item->quantity += $this->pre_quantity;
                     }
                     $item->save();
                 }
                 if ($item->retrieve($this->bean->xinventory_id) != null) {
                     if ($this->bean->operation == 'in') {
                         $item->quantity += $this->bean->quantity;
                     } else {
                         $item->quantity -= $this->bean->quantity;
                         if ($item->quantity < 0) {
                             $item->quantity = 0;
                         }
                     }
                     $item->save();
                 }
             }
         }
     }
     parent::action_save();
 }
开发者ID:sunmo,项目名称:snowlotus,代码行数:60,代码来源:controller.php


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