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


PHP Tax::save方法代码示例

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


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

示例1: store

 /**
  * Store a newly created branch in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Tax::$rules, Tax::$messages);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $tax = new Tax();
     $tax->name = Input::get('name');
     $tax->rate = Input::get('rate');
     $tax->save();
     return Redirect::route('taxes.index')->withFlashMessage('Tax successfully created!');
 }
开发者ID:kenkode,项目名称:umash-1,代码行数:17,代码来源:TaxController.php

示例2: actionCreate

 public function actionCreate()
 {
     $model = new Tax();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Tax'])) {
         $model->attributes = $_POST['Tax'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:rinodung,项目名称:yii-shop,代码行数:13,代码来源:TaxController.php

示例3: actionUpload

 public function actionUpload()
 {
     parent::actionUpload();
     $folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/';
     // folder for uploaded files
     $file = $folder . basename($_FILES['uploadfile']['name']);
     if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
         $row = 0;
         if (($handle = fopen($file, "r")) !== FALSE) {
             while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                 if ($row > 0) {
                     $model = Tax::model()->findByPk((int) $data[0]);
                     if ($model === null) {
                         $model = new Tax();
                     }
                     $model->taxid = (int) $data[0];
                     $model->taxcode = $data[1];
                     $model->taxvalue = $data[2];
                     $model->description = $data[3];
                     $model->recordstatus = (int) $data[4];
                     try {
                         if (!$model->save()) {
                             $this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]);
                         }
                     } catch (Exception $e) {
                         $this->messages = $this->messages . $e->getMessage();
                     }
                 }
                 $row++;
             }
         } else {
             $this->messages = $this->messages . ' memory or harddisk full';
         }
         fclose($handle);
     } else {
         $this->messages = $this->messages . ' check your directory permission';
     }
     if ($this->messages == '') {
         $this->messages = 'success';
     }
     echo $this->messages;
 }
开发者ID:bylinggha,项目名称:Capella-ERP-Indonesia,代码行数:42,代码来源:TaxController.php

示例4: generateEuropeTaxRule

 private function generateEuropeTaxRule()
 {
     $euro_vat_array = self::$europe_vat_array;
     $euro_tax_rule_grp_id = TaxRulesGroup::getIdByName((string) $this->european_vat_name);
     if (!$euro_tax_rule_grp_id) {
         // Create it
         $trg = new TaxRulesGroup();
         $trg->name = (string) $this->european_vat_name;
         $trg->active = 1;
         if (!$trg->save()) {
             $this->_errors[] = Tools::displayError('Tax rule cannot be saved.');
             return false;
         }
         $euro_tax_rule_grp_id = (int) $trg->id;
     }
     $tax_rules_euro_group = TaxRule::getTaxRulesByGroupId((int) Context::getContext()->language->id, (int) $euro_tax_rule_grp_id);
     $euro_group_taxes_rules = array();
     foreach ($tax_rules_euro_group as $tax_rule) {
         $euro_group_taxes_rules[] = $tax_rule;
     }
     foreach ($euro_vat_array as $euro_vat_name => $euro_vat_details) {
         $posted_euro_vat = 'euro_vat_' . (string) $euro_vat_details['iso_country'];
         $posted_available_vat = 'available_vat_' . (string) $euro_vat_details['iso_country'];
         $country_id = Country::getByIso((string) $euro_vat_details['iso_country']);
         if (Tools::isSubmit($posted_euro_vat)) {
             if (!Tools::isSubmit($posted_available_vat)) {
                 $id_tax_found = Tax::getTaxIdByName((string) $euro_vat_name);
                 if ($id_tax_found !== false) {
                     $tax = new Tax((int) $id_tax_found);
                 } else {
                     $tax = new Tax();
                 }
                 $tax->name[(int) Configuration::get('PS_LANG_DEFAULT')] = (string) $euro_vat_name;
                 $tax->rate = (double) $euro_vat_details['rate'];
                 $tax->active = 1;
                 if ($tax->validateFields(false, true) !== true || $tax->validateFieldsLang(false, true) !== true) {
                     $this->_errors[] = Tools::displayError('Invalid tax properties.');
                     continue;
                 }
                 if (!$tax->save()) {
                     $this->_errors[] = Tools::displayError('An error occurred while saving the tax: ');
                     continue;
                 }
                 $id_tax_rule = $this->getTaxRuleIdFromUnique($euro_tax_rule_grp_id, $country_id, $id_tax_found);
                 if ($id_tax_rule !== false) {
                     $tr = new TaxRule((int) $id_tax_rule);
                 } else {
                     $tr = new TaxRule();
                 }
                 $tr->id_tax_rules_group = (int) $euro_tax_rule_grp_id;
                 $tr->id_country = (int) $country_id;
                 $tr->id_state = 0;
                 $tr->id_county = 0;
                 $tr->zipcode_from = 0;
                 $tr->zipcode_to = 0;
                 $tr->behavior = 0;
                 $tr->description = '';
                 $tr->id_tax = (int) $tax->id;
                 $tr->save();
             } else {
                 $assoc_id_tax = (int) Tools::getValue($posted_available_vat);
                 $id_tax_rule = $this->getTaxRuleIdFromUnique($euro_tax_rule_grp_id, $country_id, $assoc_id_tax);
                 if ($id_tax_rule !== false) {
                     $tr = new TaxRule((int) $id_tax_rule);
                 } else {
                     $tr = new TaxRule();
                 }
                 $tr->id_tax_rules_group = (int) $euro_tax_rule_grp_id;
                 $tr->id_country = (int) $country_id;
                 $tr->id_state = 0;
                 $tr->id_county = 0;
                 $tr->zipcode_from = 0;
                 $tr->zipcode_to = 0;
                 $tr->behavior = 0;
                 $tr->description = '';
                 $tr->id_tax = (int) $assoc_id_tax;
                 $tr->save();
             }
         } else {
             $this->_errors[] = Tools::displayError('Invalid parameters received');
         }
     }
 }
开发者ID:EliosIT,项目名称:PS_AchatFilet,代码行数:83,代码来源:eurovatgenerator.php

示例5: add_tax

 /**
  * Adds tax to the system
  *
  * @param string $passkey
  * @param int $intNo
  * @param string $strTax
  * @param float $fltMax
  * @param int $blnCompounded
  * @return string
  */
 public function add_tax($passkey, $intNo, $strTax, $fltMax, $blnCompounded)
 {
     if (!$this->check_passkey($passkey)) {
         return self::FAIL_AUTH;
     }
     if ($intNo > 5) {
         _xls_log(sprintf("SOAP ERROR : System can only handle %s number of taxes. Specified %s", 5, $intNo));
         return self::UNKNOWN_ERROR;
     }
     // Loads tax
     $tax = Tax::LoadByLS($intNo);
     if (!$tax) {
         $tax = new Tax();
         $tax->lsid = $intNo;
     }
     $tax->tax = $strTax;
     $tax->max_tax = $fltMax;
     $tax->compounded = $blnCompounded;
     if (!$tax->save()) {
         _xls_log("SOAP ERROR : Error adding tax {$strTax} " . print_r($tax->getErrors(), true));
         return self::UNKNOWN_ERROR . " Error adding tax {$strTax} " . print_r($tax->getErrors(), true);
     }
     return self::OK;
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:34,代码来源:LegacysoapController.php

示例6: add_tax

 /**
  * Adds tax to the system
  *
  * @param string $passkey
  * @param int $intNo
  * @param int $intTaxRateId
  * @param string $strTax
  * @param float $fltMax
  * @param int $blnCompounded
  * @return string
  * @throws SoapFault
  * @soap
  */
 public function add_tax($passkey, $intNo, $intTaxRateId, $strTax, $fltMax, $blnCompounded)
 {
     self::check_passkey($passkey);
     //Remove if we have this tax already, just readd
     Tax::model()->deleteAllByAttributes(array('id' => $intTaxRateId));
     Tax::model()->deleteAllByAttributes(array('lsid' => $intNo));
     // Loads tax
     $tax = Tax::LoadByLS($intNo);
     if (!$tax) {
         $tax = new Tax();
         $tax->id = $intTaxRateId;
         $tax->lsid = $intNo;
     }
     $tax->tax = $strTax;
     $tax->max_tax = $fltMax;
     $tax->compounded = $blnCompounded;
     if (!$tax->save()) {
         $strMsg = "Error adding tax {$strTax}";
         Yii::log("SOAP ERROR : {$strMsg} " . print_r($tax->getErrors(), true), CLogger::LEVEL_ERROR, 'application.' . __CLASS__ . "." . __FUNCTION__);
         throw new SoapFault($strMsg, WsSoapException::ERROR_UNKNOWN);
     }
     return self::OK;
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:36,代码来源:SoapController.php


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