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


PHP Period::save方法代码示例

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


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

示例1: getCurrentPeriod

 /**
  * Returns current period instance
  *
  * @return <Doctrine_Object> instance of Period
  */
 public static function getCurrentPeriod()
 {
     $date = Period::getCurPeriodDate();
     $oPeriod = PeriodTable::getInstance()->findOneByDate($date);
     if (!$oPeriod instanceof Period) {
         // выставить новые тарифы на новый период
         UserTable::setNewTariffs();
         $oPeriod = new Period();
         // вычислить стоимость 1к знаков
         if (($prev = Period::getPrevPeriod()) === false) {
             $price1k = SettingTable::getOptionByName('price1k')->getValue();
         } else {
             // рассчитать веса пользователей
             UserTable::countWeights($prev);
             if (($price1k = VoteTable::getVoted1k($prev)) === false) {
                 $price1k = $prev->get1k();
             }
         }
         $oPeriod->set1k(number_format((double) $price1k, 2));
         // выставить процент
         $oPeriod->setR2rShare(number_format(Setting::getValueByName('percent_r2r'), 2, '.', ''));
         // --
         $oPeriod->setDate($date);
         $oPeriod->save();
         //throw new sfException('Cannot get current period. Error in DB data');
     }
     return $oPeriod;
 }
开发者ID:rollmax,项目名称:read2read,代码行数:33,代码来源:Period.class.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'show' page.
  */
 public function actionCreate()
 {
     $model = new Period();
     if (isset($_POST['Period'])) {
         $model->attributes = $_POST['Period'];
         $model->dateStart = User::parseDate($model->dateStart);
         $model->dateEnd = User::parseDate($model->dateEnd);
         $model->companyId = Yii::app()->user->getState('selectedCompanyId');
         if ($model->save()) {
             ChangeLog::addLog('ADD', 'Period', $model->toString());
             if (Yii::app()->user->getState('selectedPeriodId') == 0) {
                 $usersModel = User::model()->findbyPk(Yii::app()->user->id);
                 $usersModel->selectedPeriodId = $model->id;
                 $usersModel->confirmPassword = $usersModel->password;
                 $usersModel->save();
                 $usersModel->setStates(true);
                 $this->redirect(array('accountType/create'));
             } else {
                 $this->redirect(array('admin', 'id' => $model->id));
             }
         }
     }
     $model->dateStart = User::getDateFormatted(date('Y') . '-01-01');
     $model->dateEnd = User::getDateFormatted(date('Y') . '-12-31');
     $model->dateChanged = User::getDateFormatted(date('Y-m-d'));
     $this->render('create', array('model' => $model));
 }
开发者ID:Jride,项目名称:accounting-thaiconnections,代码行数:31,代码来源:PeriodController.php

示例3: move_down

 /**
  * This method will move current period down in sorting order.
  */
 public function move_down()
 {
     if (isset($this->id) && intval($this->id) > 0) {
         $down_period = new Period();
         $down_period->order_by('sorting', 'asc')->limit(1);
         $down_period->where('sorting >', $this->sorting);
         $down_period->get();
         if ($down_period->exists()) {
             $upsort = $down_period->sorting;
             $down_period->sorting = $this->sorting;
             if ($down_period->save()) {
                 $my_period = new Period();
                 $my_period->get_where(array('id' => $this->id));
                 $my_period->sorting = $upsort;
                 if ($my_period->save()) {
                     $this->sorting = $upsort;
                 }
             }
         }
     }
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:24,代码来源:period.php

示例4: getCurrentPeriod

 /**
  * @return Period
  */
 public static function getCurrentPeriod()
 {
     if (!self::$current) {
         $start = new DateTime();
         $start->setDate($start->format('Y'), $start->format('n'), 1)->setTime(0, 0, 0);
         $end = clone $start;
         $end = $end->modify('+' . cal_days_in_month(CAL_GREGORIAN, $start->format('n'), $start->format('Y')) . ' day')->modify('-1 sec');
         $period = Period::model()->findByAttributes(array('period_from' => $start->format(Task::DF_INTER), 'period_to' => $end->format(Task::DF_INTER)));
         if ($period == NULL) {
             $period = new Period();
             $period->period_from = $start->format(Task::DF_INTER);
             $period->period_to = $end->format(Task::DF_INTER);
             $period->status = self::STATUS_ACTIVE;
             $period->name = $start->format('F, Y');
             try {
                 $period->save();
             } catch (Exception $e) {
             }
         }
         self::$current = $period;
     }
     return self::$current;
 }
开发者ID:nsarvar,项目名称:performance,代码行数:26,代码来源:Period.php

示例5: update

 public function update()
 {
     $this->load->library('form_validation');
     $period_id = intval($this->input->post('period_id'));
     $this->form_validation->set_rules('period_id', 'id', 'required');
     $this->form_validation->set_rules('period[name]', 'lang:admin_periods_form_field_name', 'required|callback__is_unique_name_not_in[' . $period_id . ']');
     $this->form_validation->set_message('_is_unique_name_not_in', $this->lang->line('admin_periods_form_error_message_is_unique_name_not_in'));
     if ($this->form_validation->run()) {
         $period = new Period();
         $period->get_by_id($period_id);
         if ($period->exists()) {
             $period_data = $this->input->post('period');
             $period->from_array($period_data, array('name'));
             $this->_transaction_isolation();
             $this->db->trans_begin();
             if ($period->save() && $this->db->trans_status()) {
                 $this->db->trans_commit();
                 $this->messages->add_message('lang:admin_periods_flash_message_save_successful', Messages::MESSAGE_TYPE_SUCCESS);
                 $this->_action_success();
             } else {
                 $this->db->trans_rollback();
                 $this->messages->add_message('lang:admin_periods_flash_message_save_failed', Messages::MESSAGE_TYPE_ERROR);
             }
         } else {
             $this->messages->add_message('lang:admin_periods_error_period_not_found', Messages::MESSAGE_TYPE_ERROR);
         }
         redirect(create_internal_url('admin_periods/index'));
     } else {
         $this->edit();
     }
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:31,代码来源:periods.php

示例6: list_import_lamsfet_courses_and_courses_terms

function list_import_lamsfet_courses_and_courses_terms(&$courses_terms, $courses)
{
    echo 'Starting courses import (' . count($courses_terms) . ') and periods import (' . count($courses) . ') ';
    $periods = array();
    if (count($courses_terms)) {
        foreach ($courses_terms as $course_term) {
            $periods[$course_term->year][$course_term->term] = isset($periods[$course_term->year][$course_term->term]) ? $periods[$course_term->year][$course_term->term] : new stdClass();
            $periods[$course_term->year][$course_term->term]->name = (strtoupper($course_term->term) == 'Z' ? 'Zimný semester ' : 'Letný semester ') . $course_term->year;
            $periods[$course_term->year][$course_term->term]->_list_id = NULL;
            $periods[$course_term->year][$course_term->term]->ids[] = $course_term->id;
        }
    }
    reset($periods);
    krsort($periods);
    if (count($periods)) {
        foreach ($periods as $year => $data) {
            reset($periods[$year]);
            ksort($periods[$year]);
            reset($periods[$year]);
        }
    }
    reset($periods);
    echo '... structure prepared ... [';
    $sorting = 1;
    if (count($periods)) {
        foreach ($periods as $year => $year_row) {
            if (count($year_row)) {
                foreach ($year_row as $term => $period) {
                    $list_period = new Period();
                    $list_period->name = $period->name;
                    $list_period->sorting = $sorting;
                    $list_period->save();
                    $periods[$year][$term]->_list_id = $list_period->id;
                    $sorting++;
                    echo '.';
                }
            }
        }
    }
    if (count($courses_terms) && count($courses)) {
        foreach ($courses_terms as $course_term) {
            $list_course = new Course();
            $list_course->name = $courses[$course_term->course_id]->name;
            $list_course->period_id = $periods[$course_term->year][$course_term->term]->_list_id;
            $list_course->capacity = 0;
            $list_course->groups_change_deadline = 0;
            $list_course->allow_subscription_to = '1970-01-01 00:00:00';
            $list_course->save();
            $courses_terms[$course_term->id]->_list_id = $list_course->id;
            echo '.';
        }
    }
    echo '] ... done' . "\n";
}
开发者ID:andrejjursa,项目名称:list-lms,代码行数:54,代码来源:lamsfet_helper.php

示例7: importCompany

 private function importCompany($fileNameAndPath)
 {
     $allAccounts = array();
     $dom = new domDocument();
     if (!$dom->load($fileNameAndPath)) {
         throw new CException(Yii::t('lazy8', 'input file could not be xml parsed'));
     }
     $root = $dom->documentElement;
     if ($root->nodeName != "lazy8webport") {
         $this->hasErrors = true;
         $this->errors = array(array(Yii::t('lazy8', 'Upload failed.  This is not a valid file.'), Yii::t('lazy8', 'Select a file and try again')));
         $this->render('showimport');
         return 0;
     }
     if ($root->getAttribute('version') > 1.0) {
         $this->errors = array(array(Yii::t('lazy8', 'There maybe problems because this is a file version greater then this programs version'), Yii::t('lazy8', 'Select a file and try again')));
     }
     $nodeCompanys = $root->getElementsByTagName('company');
     unset($root);
     unset($dom);
     $this->lastImportedPeriod = 0;
     foreach ($nodeCompanys as $nodeCompany) {
         //make sure the company code is unique
         $modelCompany = new Company();
         $code = $nodeCompany->getAttribute('code');
         $code--;
         //make sure the company code is valid. Change if not.
         do {
             $code++;
             $comptest = Company::model()->find(array('condition' => 'code=' . $code));
         } while ($comptest !== null);
         //create the company
         $modelCompany = new Company();
         $modelCompany->code = $code;
         $modelCompany->name = $nodeCompany->getAttribute('name');
         $modelCompany->lastAbsTransNum = $nodeCompany->getAttribute('lastAbsTransNum');
         if (!$modelCompany->save()) {
             throw new CException(Yii::t('lazy8', 'Could not create the company, bad paramters') . ';' . var_export($modelCompany->getErrors()));
         }
         try {
             $allAccounts = array();
             $nodesAccountTypes = $nodeCompany->getElementsByTagName('accounttype');
             foreach ($nodesAccountTypes as $nodeAccountType) {
                 $modelAccountType = new AccountType();
                 $modelAccountType->companyId = $modelCompany->id;
                 $modelAccountType->code = $nodeAccountType->getAttribute('code');
                 $modelAccountType->name = $nodeAccountType->getAttribute('name');
                 $modelAccountType->sortOrder = $nodeAccountType->getAttribute('sortorder');
                 $modelAccountType->isInBalance = $nodeAccountType->getAttribute('isinbalance') == "1" ? 1 : 0;
                 if (!$modelAccountType->save()) {
                     $modelCompany->delete();
                     throw new CException(Yii::t('lazy8', 'Could not create the AccountType, bad paramters') . ';name=' . $modelAccountType->name . ';' . serialize($modelAccountType->getErrors()));
                 }
                 $nodesAccounts = $nodeAccountType->getElementsByTagName('account');
                 foreach ($nodesAccounts as $nodeAccount) {
                     $modelAccount = new Account();
                     $modelAccount->companyId = $modelCompany->id;
                     $modelAccount->code = $nodeAccount->getAttribute('code');
                     $modelAccount->accountTypeId = $modelAccountType->id;
                     $modelAccount->name = $nodeAccount->getAttribute('name');
                     if (!$modelAccount->save()) {
                         $modelCompany->delete();
                         throw new CException(Yii::t('lazy8', 'Could not create the Account, bad paramters') . ';' . serialize($modelAccount->getErrors()));
                     }
                     $allAccounts[$modelAccount->code] = $modelAccount->id;
                     unset($nodeAccount);
                     unset($modelAccount);
                 }
                 unset($modelAccountType);
                 unset($nodeAccountType);
             }
             unset($nodesAccountTypes);
             $allCustomers = array();
             $nodesCustomers = $nodeCompany->getElementsByTagName('customer');
             foreach ($nodesCustomers as $nodeCustomer) {
                 $modelCustomer = new Customer();
                 $modelCustomer->companyId = $modelCompany->id;
                 $modelCustomer->code = $nodeCustomer->getAttribute('code');
                 $modelCustomer->accountId = $this->FindAccountIdFromCode($nodeCustomer->getAttribute('accountcode'), $modelCompany->id, $allAccounts, 'customercode=' . $modelCustomer->code, $this->errors, true);
                 $modelCustomer->name = $nodeCustomer->getAttribute('name');
                 $modelCustomer->desc = $nodeCustomer->getAttribute('desc');
                 if (!$modelCustomer->save()) {
                     $modelCompany->delete();
                     throw new CException(Yii::t('lazy8', 'Could not create the Customer, bad paramters') . ';' . serialize($modelCustomer->getErrors()));
                 }
                 $allCustomers[$modelCustomer->code] = $modelCustomer->id;
                 unset($modelCustomer);
                 unset($nodeCustomer);
             }
             unset($nodesCustomers);
             $nodesPeriods = $nodeCompany->getElementsByTagName('period');
             foreach ($nodesPeriods as $nodePeriod) {
                 $modelPeriod = new Period();
                 $modelPeriod->companyId = $modelCompany->id;
                 $modelPeriod->dateStart = $nodePeriod->getAttribute('datestart');
                 $modelPeriod->dateEnd = $nodePeriod->getAttribute('dateend');
                 $modelPeriod->lastPeriodTransNum = $nodePeriod->getAttribute('lastperiodtransnum');
                 if (!$modelPeriod->save()) {
                     $modelCompany->delete();
                     throw new CException(Yii::t('lazy8', 'Could not create the period, bad paramters') . ';' . serialize($modelPeriod->getErrors()));
//.........这里部分代码省略.........
开发者ID:Jride,项目名称:accounting-thaiconnections,代码行数:101,代码来源:CompanyController.php


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