當前位置: 首頁>>代碼示例>>PHP>>正文


PHP GroupReduction::delete方法代碼示例

本文整理匯總了PHP中GroupReduction::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP GroupReduction::delete方法的具體用法?PHP GroupReduction::delete怎麽用?PHP GroupReduction::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GroupReduction的用法示例。


在下文中一共展示了GroupReduction::delete方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: postProcess

 public function postProcess()
 {
     global $currentIndex;
     $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
     if (Tools::isSubmit('deleteGroupReduction')) {
         if ($this->tabAccess['delete'] === '1') {
             if (!($id_group_reduction = Tools::getValue('id_group_reduction'))) {
                 $this->_errors[] = Tools::displayError('Invalid group reduction ID');
             } else {
                 $groupReduction = new GroupReduction((int) $id_group_reduction);
                 if (!$groupReduction->delete()) {
                     $this->_errors[] = Tools::displayError('An error occurred while deleting the group reduction');
                 } else {
                     Tools::redirectAdmin($currentIndex . '&update' . $this->table . '&id_group=' . (int) Tools::getValue('id_group') . '&conf=1&token=' . $token);
                 }
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     }
     if (Tools::isSubmit('submitAddGroupReduction')) {
         if ($this->tabAccess['add'] === '1') {
             if (!($obj = $this->loadObject())) {
                 return;
             }
             $groupReduction = new GroupReduction();
             if (!($id_category = Tools::getValue('id_category')) or !Validate::isUnsignedId($id_category)) {
                 $this->_errors[] = Tools::displayError('Wrong category ID');
             } elseif (!($reduction = Tools::getValue('reductionByCategory')) or !Validate::isPrice($reduction)) {
                 $this->_errors[] = Tools::displayError('Invalid reduction (must be a percentage)');
             } elseif (Tools::getValue('reductionByCategory') > 100 or Tools::getValue('reductionByCategory') < 0) {
                 $this->_errors[] = Tools::displayError('Reduction value is incorrect');
             } elseif (GroupReduction::doesExist((int) $obj->id, $id_category)) {
                 $this->_errors[] = Tools::displayError('A reduction already exists for this category.');
             } else {
                 $groupReduction->id_category = (int) $id_category;
                 $groupReduction->id_group = (int) $obj->id;
                 $groupReduction->reduction = (double) $reduction / 100;
                 if (!$groupReduction->add()) {
                     $this->_errors[] = Tools::displayError('An error occurred while adding a category group reduction.');
                 } else {
                     Tools::redirectAdmin($currentIndex . '&update' . $this->table . '&id_group=' . (int) Tools::getValue('id_group') . '&conf=3&token=' . $this->token);
                 }
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to add here.');
         }
     }
     if (Tools::isSubmit('submitAddgroup')) {
         if ($this->tabAccess['add'] === '1') {
             if (Tools::getValue('reduction') > 100 or Tools::getValue('reduction') < 0) {
                 $this->_errors[] = Tools::displayError('Reduction value is incorrect');
             } else {
                 $id_group_reductions = Tools::getValue('gr_id_group_reduction');
                 $reductions = Tools::getValue('gr_reduction');
                 if ($id_group_reductions) {
                     foreach ($id_group_reductions as $key => $id_group_reduction) {
                         if (!Validate::isUnsignedId($id_group_reductions[$key]) or !Validate::isPrice($reductions[$key])) {
                             $this->_errors[] = Tools::displayError('Invalid reduction (must be a percentage)');
                         } elseif ($reductions[$key] > 100 or $reductions[$key] < 0) {
                             $this->_errors[] = Tools::displayError('Reduction value is incorrect');
                         } else {
                             $groupReduction = new GroupReduction((int) $id_group_reductions[$key]);
                             $groupReduction->reduction = $reductions[$key] / 100;
                             if (!$groupReduction->update()) {
                                 $this->_errors[] = Tools::displayError('Cannot update group reductions');
                             }
                         }
                     }
                 }
                 if (!sizeof($this->_errors)) {
                     parent::postProcess();
                 }
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to add here.');
         }
     } elseif (isset($_GET['delete' . $this->table])) {
         if ($this->tabAccess['delete'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject())) {
                 if ($object->id == 1) {
                     $this->_errors[] = Tools::displayError('You cannot delete default group.');
                 } else {
                     if ($object->delete()) {
                         Tools::redirectAdmin($currentIndex . '&conf=1&token=' . $token);
                     }
                     $this->_errors[] = Tools::displayError('An error occurred during deletion.');
                 }
             } else {
                 $this->_errors[] = Tools::displayError('An error occurred while deleting object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } else {
         parent::postProcess();
     }
 }
開發者ID:greench,項目名稱:prestashop,代碼行數:98,代碼來源:AdminGroups.php


注:本文中的GroupReduction::delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。