Автор: Magnus Rosenbaum (dev@cmr.cx)
Наследование: extends Relation
Пример #1
0
 function scanpassword($password)
 {
     $lower = false;
     $upper = false;
     $specialchar = false;
     $number = false;
     $possibilities = 0;
     $special = '!@#$%&*<>-_!@#$%&*<>-_';
     for ($i = 0; $i < strlen($password); $i++) {
         if (preg_match("/[a-z]/", $password[$i]) && !$lower) {
             $possibilities += 26;
             $lower = true;
         }
         if (preg_match('/[A-Z]/', $password[$i]) && !$upper) {
             $possibilities += 26;
             $upper = true;
         }
         if (preg_match('/[0-9]/', $password[$i]) && !$number) {
             $possibilities += 10;
             $number = true;
         }
         if (strpbrk($password[$i], $special) && !$specialchar) {
             $possibilities += 15;
             $specialchar = true;
         }
     }
     $product['product'] = pow($possibilities, strlen($password)) / 4000000000;
     $product['possibilities'] = $possibilities;
     $product['quantity'] = strlen($password);
     $objPeriod = new Period();
     $product['possibilities'] = $objPeriod->mountPossibilities($product);
     return $product;
 }
Пример #2
0
 public function format(Period $period)
 {
     // this method actually has a pretty bad smell on it.
     // it does what it's supposed to, but at one point or another it should be
     // refactored to use a combination of
     // the strategy and chain of responsibility-pattern
     // so the variants can be customized
     if ($period->getYears() != 0) {
         return $this->doFormat($this->lang, 'years', $period->getYears());
     }
     if ($period->getMonths() != 0) {
         return $this->doFormat($this->lang, 'months', $period->getMonths());
     }
     if ($period->getDays() != 0) {
         $amount = $period->getDays();
         // if the amount of days is larger than 6 we'll want to
         // express it in weeks instead
         if ($amount > 6 || $amount < -6) {
             $amount = intval($amount / 7);
             return $this->doFormat($this->lang, 'weeks', $amount);
         } else {
             return $this->doFormat($this->lang, 'days', $amount);
         }
     }
     if ($period->getHours() != 0) {
         return $this->doFormat($this->lang, 'hours', $period->getHours());
     }
     if ($period->getMinutes() != 0) {
         return $this->doFormat($this->lang, 'minutes', $period->getMinutes());
     }
     return $this->doFormat($this->lang, 'justNow', 0);
 }
Пример #3
0
 public function actionIndex()
 {
     $model = new Period('search');
     $model->unsetAttributes();
     if (isset($_GET['Period'])) {
         $model->attributes = $_GET['Period'];
     }
     $this->render('list', array('model' => $model));
 }
Пример #4
0
 public static function getVoted1k(Period $period)
 {
     $q = Doctrine_Query::create()->select('v.*')->from('Vote v')->where('v.id_period = ?', $period->getId())->andWhere('v.weight > 50')->execute()->getFirst();
     if ($q) {
         return $q->getPrice();
     } else {
         return false;
     }
 }
Пример #5
0
 public static function getSoldArticlesQuery(User $user, Period $period, $c_sort = null)
 {
     if (!is_null($c_sort)) {
         $sortby = $c_sort['sortby'];
         $order = $c_sort['order'];
     } else {
         $sortby = 'pub_date';
         $order = 'desc';
     }
     $q = Doctrine_Query::create()->select('c.id, sum(t.amount) as sell_sum, count(cp.id) as sell_count')->from('Content c')->leftJoin('c.Category ct')->leftJoin('c.ContentPurchase cp')->leftJoin('cp.Transaction t with t.id_period = ?', $period->getId())->where('c.id_user = ?', $user->getId())->andWhere('c.state = "public"')->groupBy('c.id')->orderBy("{$sortby} {$order}");
     return $q;
 }
Пример #6
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $Database = new \mysqli(TEST_DB_HOST, TEST_DB_USER, TEST_DB_PASSWORD, TEST_DB);
     $oPeriod = new Period($Database);
     $oPeriod->setPeriodType('monthly');
     $this->object = new Data($Database, $oPeriod);
     $sSql = "DELETE FROM `dim_l1`";
     $this->object->getDbConnection()->query($sSql);
     $sSql = "DELETE FROM `dim_l2`";
     $this->object->getDbConnection()->query($sSql);
     $sSql = "DELETE FROM `dim_l3`";
     $this->object->getDbConnection()->query($sSql);
     $sSql = "INSERT INTO `dim_table` (`id`, `table_name`) VALUES (" . self::TEST_TABLE_ID . ", 'test_table')";
     $this->object->getDbConnection()->query($sSql);
 }
Пример #7
0
 /**
  * This is construct base of the class.
  *
  * A public constructor; initializes the variable $instanceDataBase.
  *
  */
 public function __construct($instanceDataBase)
 {
     parent::__construct($instanceDataBase);
     Period::setDataOperationBusiness($instanceDataBase);
     Period::getBusiness();
     Period::getDescriptionBusiness();
 }
Пример #8
0
 /**
  * Return R2R percent
  *
  * @return int
  */
 public static function getR2RPercent()
 {
     /*
     $option = SettingTable::getOptionByName('percent_r2r');
     return (int)$option->getValue();
     */
     return (double) Period::getCurrentPeriod()->getR2rShare();
 }
Пример #9
0
 public function getAllInvoicePeriods()
 {
     // status
     $all_periods = Period::orderBy('id', 'ASC')->get(['id', 'description']);
     $periods = [];
     foreach ($all_periods as $period) {
         $periods[] = (object) ['value' => $period->id, 'label' => utf8_encode($period->description)];
     }
     return $periods;
 }
 public function run()
 {
     DB::table('periods')->delete();
     Period::create(array('start' => '8:00', 'end' => '9:30', 'total' => 10, 'current' => 2, 'schedule_id' => 1));
     Period::create(array('start' => '9:30', 'end' => '10:30', 'total' => 10, 'current' => 6, 'schedule_id' => 1));
     Period::create(array('start' => '10:30', 'end' => '12:00', 'total' => 10, 'current' => 0, 'schedule_id' => 1));
     Period::create(array('start' => '13:00', 'end' => '14:30', 'total' => 10, 'current' => 10, 'schedule_id' => 3));
     Period::create(array('start' => '14:30', 'end' => '16:30', 'total' => 10, 'current' => 0, 'schedule_id' => 3));
     Period::create(array('start' => '16:30', 'end' => '18:00', 'total' => 8, 'current' => 3, 'schedule_id' => 3));
 }
Пример #11
0
 /**
  * Delete this period or related object.
  * If no parameters are set, this method deletes current period and re-sort all other periods.
  * @param DataMapper|string $object related object to delete from relation.
  * @param string $related_field relation internal name.
  */
 public function delete($object = '', $related_field = '')
 {
     if (empty($object) && !is_array($object) && !empty($this->id)) {
         $lower_periods = new Period();
         $lower_periods->order_by('sorting', 'asc');
         $lower_periods->where('sorting > ', $this->sorting);
         $lower_periods->get_iterated();
         $ids = array();
         foreach ($lower_periods as $lower_period) {
             $ids[] = $lower_period->id;
         }
         if (count($ids) > 0) {
             $this->db->set('sorting', 'sorting-1', FALSE);
             $this->db->where_in('id', $ids);
             $this->db->update('periods');
         }
     }
     parent::delete($object, $related_field);
 }
Пример #12
0
 /**
  * Show Visit stats
  *
  * @param sfWebRequest $request
  */
 public function executeVisit(sfWebRequest $request)
 {
     $this->form = new CategorySelectForm();
     $iCategoryId = 1;
     $iPeriodId = Period::getCurrentPeriod()->getId();
     if ($request->getParameter('category', false)) {
         $this->form->bind($request->getParameter($this->form->getName()));
         $iCategoryId = $this->form->getValue('id_category');
         $this->form->setDefault('id_category', $iCategoryId);
     }
     $this->aFullData = StatisticsTable::getInstance()->getFullStatistics($iPeriodId);
     $this->aDataByCategory = StatisticsTable::getInstance()->getFullStatistics($iPeriodId, $iCategoryId);
 }
Пример #13
0
 /**
  * Enter description here...
  *
  * @param int $user_id
  * @param int $period_id
  * @return BalanceUser
  */
 public static function getByUserIdAndPeriodId($user_id, $period_id = 0)
 {
     if ($period_id == 0) {
         $period_id = Period::getCurrentPeriod()->getId();
     }
     $q = Doctrine_Query::create()->from('BalanceUser bu')->where('bu.id_user=?', $user_id)->andWhere('bu.id_period=?', $period_id)->limit(1);
     $balance = $q->fetchOne();
     if (false === $balance) {
         BalanceUser::setInitialRecord($user_id, $period_id);
         $balance = self::getByUserIdAndPeriodId($user_id, $period_id);
         //throw new sfException('Cannot get Balance for User: '******' period: '.$period_id.'. Error in DB data');
     }
     return $balance;
 }
Пример #14
0
 public function postInsert($event)
 {
     $oStatistics = new Statistics();
     $oStatistics->setCategoryId($this->getId());
     try {
         $iPeriod = Period::getCurrentPeriod();
     } catch (sfException $e) {
         return;
     }
     if (false !== $iPeriod) {
         $oStatistics->setPeriodId($iPeriod);
         $oStatistics->save();
     }
 }
Пример #15
0
 public function executeIndex(sfWebRequest $request)
 {
     // sorting
     if ($request->getParameter('sort') && $this->isValidSortColumn($request->getParameter('sort'))) {
         $this->setSort(array($request->getParameter('sort'), $request->getParameter('sort_type')));
     }
     // pager
     if ($request->getParameter('page')) {
         $this->setPage($request->getParameter('page'));
     }
     $this->pager = $this->getPager();
     $this->sort = $this->getSort();
     $user = new User();
     $this->dataArray = array('amountSum' => $user->getUserAmountSum('uuser', Period::getCurrentPeriod()->getId()), 'sellPurchaseSum' => $user->getUserSellPurchaseSum('uuser', Period::getCurrentPeriod()->getId()));
 }
Пример #16
0
 public static function getPrevPeriod()
 {
     $now = explode('-', Period::getCurPeriodDate());
     $nowYear = $now[0];
     $nowMonth = $now[1];
     if ($nowMonth - 1 == 0) {
         $prevMonth = 12;
         $prevYear = $nowYear - 1;
     } else {
         $prevMonth = $nowMonth - 1;
         $prevYear = $nowYear;
     }
     $prevMonth = substr('0' . $prevMonth, -2);
     $oPeriod = PeriodTable::getInstance()->findOneByDate($prevYear . '-' . $prevMonth);
     return $oPeriod;
 }
Пример #17
0
 public static function genMassPayWM($pay = true)
 {
     $max_id = Doctrine_Query::create()->select('max(bu.was_paid_id) as bu_max')->from('BalanceUser bu')->where('bu.was_paid > 0')->execute()->getFirst()->getBuMax();
     $q = Doctrine_Query::create()->select("bu.id_user, u.account_number as account_number, sum(bu.payable) as to_pay,\n                group_concat(p.date separator '|') as p_date, group_concat(bu.id separator '|') as for_ids")->from('BalanceUser bu')->innerJoin('bu.User u')->innerJoin('bu.Period p')->where('bu.was_paid = 0')->andWhere('bu.payable > 0')->andWhere("u.utype = 'puser'")->andWhere('bu.id_period != ?', Period::getCurrentPeriod()->getId())->groupBy('bu.id_user')->execute();
     $min_payout = (double) Setting::getValueByName('minPayout');
     $out = array();
     $out_num = 0;
     foreach ($q as $rec) {
         if (preg_match('/^R[0-9]{12}$/', $rec->getAccountNumber()) && $rec->getToPay() >= $min_payout) {
             if ($pay === true) {
                 $max_id = (int) $max_id + 1;
                 $bu_ids = explode('|', $rec->getForIds());
                 foreach ($bu_ids as $bu_id) {
                     $bu = BalanceUserTable::getInstance()->findOneById($bu_id);
                     $bu->setWasPaidId($max_id);
                     $bu->save();
                 }
                 $per = array();
                 $per_dates = explode('|', $rec->getPDate());
                 foreach ($per_dates as $p_date) {
                     $p_date_t = explode('-', $p_date);
                     $per[] = $p_date_t[1] . '/' . $p_date_t[0];
                 }
                 $row = array();
                 $row[] = $rec->getAccountNumber();
                 // номер кошелька
                 $row[] = $rec->getToPay();
                 // сумма тут надо разобраться с валютой
                 $row[] = mb_convert_encoding('Выплата за ', 'cp1251', 'utf-8') . join(', ', $per) . '. read2read.ru, payId:' . $max_id;
                 // комментарий к выплате
                 $row[] = $max_id;
                 // номер платежа
                 $out[] = join(';', $row);
             } else {
                 $out_num += $rec->getToPay();
             }
         }
     }
     if ($pay === true) {
         return join(PHP_EOL, $out);
     } else {
         return (int) $out_num;
     }
 }
Пример #18
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->period = Period::getCurrentPeriod();
     $this->user = $this->getUSer()->getGuardUser();
     $this->form = new UserVoteForm();
     if ($this->user->isVoted()) {
         $this->redirect('profile_p_vote1k_all');
     }
     if ($request->getParameter('create-vote') != '') {
         if ($this->user->hasVote()->count() == 0) {
             if ($this->processForm($request, $this->form)) {
                 $vote = $this->form->save();
                 $vote->setUser($this->user);
                 $vote->setPeriod($this->period);
                 $vote->setWeight($this->user->getWeight());
                 $vote->save();
                 VoteTable::getInstance()->setPositions();
             }
         }
     }
 }
Пример #19
0
 /**
  * U_User посмотрел категорию. Учитываем только один заход за день
  *
  * @param int $iUserId
  * @param int $iCategoryId
  */
 public static function uuserViewCategory($iUserId = 0, $iCategoryId = 0)
 {
     $q = Doctrine_Query::create()->select('sc.user_id')->from('StatisticsCategory sc')->where('sc.visit_date = CURDATE()')->andWhere('sc.category_id = ?', $iCategoryId)->andWhere('sc.user_id = ?', $iUserId)->limit(1);
     if (false !== $q->fetchOne()) {
         return;
     }
     // No first visit
     // New u_user
     $oStatsCategory = new StatisticsCategory();
     $oStatsCategory->setCategoryId($iCategoryId);
     $oStatsCategory->setUserId($iUserId);
     $oStatsCategory->setVisitDate(date('Y-m-d'));
     $oStatsCategory->save();
     // Update category stats
     $oStatistics = StatisticsTable::getInstance()->getFullStatistics(Period::getCurrentPeriod(), $iCategoryId);
     if (!$oStatistics instanceof Statistics) {
         throw new sfException('Cannon get Statistics object');
     }
     $callMethodGet = 'get' . date('j') . 'Login';
     $callMethodSet = 'set' . date('j') . 'Login';
     $oStatistics->{$callMethodSet}($oStatistics->{$callMethodGet}() + 1);
     $oStatistics->save();
 }
Пример #20
0
 /**
  * Execute Login Form action
  *
  * @param sfWebRequest $request
  */
 public function executeLoginForm(sfWebRequest $request)
 {
     $this->form = new LoginForm();
     if ($request->isMethod('post') && null !== $request->getParameter($this->form->getName())) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $values = $this->form->getValues();
             $this->getUser()->signin($values['user'], true);
             $oUser = $this->getUser()->getGuardUser();
             if ($oUser->getLastLogin() != date("Y-m-d") && $oUser->getUtype() == 'uuser') {
                 // statistic writing
                 // set last login
                 $oUser->setLastLogin(date("Y-m-d"));
                 $oUser->save();
                 // get current statistic raw
                 $oStatistics = StatisticsTable::getInstance()->getFullStatistics(Period::getCurrentPeriod()->getId());
                 // update login statistic
                 $oStatistics->set(date("j") . '_login', $oStatistics->get(date("j") . '_login') + 1);
                 $oStatistics->save();
             }
             return $this->getController()->redirect('@homepage');
         }
     }
 }
Пример #21
0
/**
 * @package MantisBT
 * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
 * @copyright Copyright (C) 2002 - 2013  MantisBT Team - mantisbt-dev@lists.sourceforge.net
 * @link http://www.mantisbt.org
 */
/**
 * MantisBT Core API's
 */
require_once 'core.php';
require_once 'Period.php';
require_once 'graph_api.php';
access_ensure_project_level(config_get('view_summary_threshold'));
$f_width = gpc_get_int('width', 600);
$t_ar = plugin_config_get('bar_aspect');
$t_interval = new Period();
$t_interval->set_period_from_selector('interval');
$f_show_as_table = gpc_get_bool('show_table', FALSE);
$f_summary = gpc_get_bool('summary', FALSE);
$t_interval_days = $t_interval->get_elapsed_days();
if ($t_interval_days <= 14) {
    $t_incr = 60 * 60;
    // less than 14 days, use hourly
} else {
    if ($t_interval_days <= 92) {
        $t_incr = 24 * 60 * 60;
        // less than three months, use daily
    } else {
        $t_incr = 7 * 24 * 60 * 60;
        // otherwise weekly
    }
Пример #22
0
require_api('gpc_api.php');
require_api('html_api.php');
require_api('plugin_api.php');
require_js('jscalendar/calendar.js');
require_js('jscalendar/lang/calendar-en.js');
require_js('jscalendar/calendar-setup.js');
require_css('calendar-blue.css');
access_ensure_project_level(config_get('view_summary_threshold'));
$f_interval = gpc_get_int('interval', 0);
$t_today = date('Y-m-d');
$f_type = gpc_get_int('graph_type', 0);
$f_show_as_table = gpc_get_bool('show_table', false);
html_page_top1(plugin_lang_get('graph_page'));
$t_path = config_get('path');
html_page_top2();
$t_period = new Period();
$t_period->set_period_from_selector('interval');
$t_types = array(0 => plugin_lang_get('select'), 2 => plugin_lang_get('select_bystatus'), 3 => plugin_lang_get('select_summbystatus'), 4 => plugin_lang_get('select_bycat'), 6 => plugin_lang_get('select_both'));
$t_show = array(0 => plugin_lang_get('show_as_graph'), 1 => plugin_lang_get('show_as_table'));
?>
		<form name="graph_form" method="post" action="<?php 
echo plugin_page('bug_graph_page.php');
?>
">
			<table class="width100" cellspacing="1">

				<tr>
					<td>
						<?php 
echo get_dropdown($t_types, 'graph_type', $f_type);
?>
Пример #23
0
 /**
  * @param $idBranch
  * @return array
  */
 protected function _getAvailablePeriods($idBranch)
 {
     $periodModel = new Period();
     return $periodModel->getAvailablePeriods($idBranch);
 }
Пример #24
0
 private function inject_courses()
 {
     $periods = new Period();
     $periods->order_by('sorting', 'asc');
     $periods->get_iterated();
     $data = array(NULL => '');
     if ($periods->exists()) {
         foreach ($periods as $period) {
             $period->course->order_by_with_constant('name', 'asc')->get_iterated();
             if ($period->course->exists() > 0) {
                 foreach ($period->course as $course) {
                     $data[$period->name][$course->id] = $course->name;
                 }
             }
         }
     }
     $this->parser->assign('courses', $data);
 }
Пример #25
0
 public function puserDailyPayment(User $oUser, BalanceSystem $oBalanceSystem, array &$aTariffs)
 {
     $this->setPeriod(Period::getCurrentPeriod());
     $this->setOperation('charges_service');
     $fAmount = $aTariffs[$oUser->getTariff()];
     $this->setAmount($fAmount);
     // Sender
     $this->setIdSender($oUser->getId());
     $this->setSenderBalanceBefore($oUser->getBalans());
     // Set user balance and save
     $itog = $oUser->getBalans() - $fAmount;
     if ($itog < 0) {
         $oUser->setIsBlocked(1);
         $oUser->save();
         return;
     }
     $oUser->setBalans($oUser->getBalans() - $fAmount);
     $oUser->save();
     //
     $this->setSenderBalanceAfter($oUser->getBalans());
     // Recipient - Read2Read
     $this->setIdReceiver(0);
     $this->setReceiverBalanceBefore(0);
     $this->setReceiverBalanceAfter(0);
     $sGetMethod = 'getCharges' . ucfirst($oUser->getTariff());
     $sSetMethod = 'setCharges' . ucfirst($oUser->getTariff());
     $bal = $oBalanceSystem->{$sGetMethod}();
     $bal += $fAmount;
     $oBalanceSystem->{$sSetMethod}($bal);
     $oBalanceSystem->save();
     $oBalanceUser = BalanceUserTable::getByUserIdAndPeriodId($oUser->getId());
     $oBalanceUser->setUsePayment($oBalanceUser->getUsePayment() + $fAmount);
     $oBalanceUser->save();
     // Save transaction
     $this->save();
     if ($itog < $fAmount) {
         $oUser->setIsBlocked(1);
         $oUser->save();
     }
 }
 public function insert_records()
 {
     $periods = Period::all();
     $accounts = RegisterAccount::all();
     $peirod_num = $periods->count();
     $account_num = $accounts->count();
     for ($i = 0; $i < 2000; ++$i) {
         $record = new RegisterRecord();
         $account = $accounts[rand(0, $account_num - 1)];
         $period = $periods[rand(0, $peirod_num - 1)];
         $dt = rand(0, 99) < 90 ? $this->get_random_datetime() : date('Y-m-d H:i:s');
         $record->created_at = $dt;
         $record->start = date('Y-m-d H:i:s', strtotime($dt) + 3600);
         if (rand(0, 1)) {
             $record->return_date = $this->get_random_date();
         }
         $record->status = rand(0, 1);
         $record->fee = 1.0;
         if (rand(0, 1)) {
             $record->advice = "abcd1234";
         }
         $record->account_id = $account->id;
         $record->user_id = $account->user_id;
         $record->period_id = $period->id;
         $record->doctor_id = $period->schedule->doctor_id;
         $period->current += 1;
         $period->save();
         $record->save();
         $message = new Message();
         $message->from_uid = $record->user_id;
         $message->to_uid = $record->doctor->user->id;
         $message->content = $record->user->real_name . '挂号';
         $message->timestamp = strtotime($dt);
         $message->status = 3;
         $message->save();
     }
 }
 $orgstreet2 = $org->street2;
 $orgstreet3 = $org->street3;
 $orgcity = $org->city;
 $orgstate = $org->state;
 $orgcountry_name = $org->country_name;
 $orgemail = $org->email;
 $orgurl = $org->url;
 $orgtel1 = $org->tel_1;
 $orgtel2 = $org->tel_2;
 $orgfax = $org->fax;
 $periodfrom_id = $_POST['periodfrom_id'];
 $periodto_id = $_POST['periodto_id'];
 $reportlevel = $_POST['reportlevel'];
 $showzero = $_POST['showzero'];
 $showaccountcode = $_POST['showaccountcode'];
 $period = new Period();
 if ($period->fetchPeriod($periodfrom_id)) {
     $header[1] = $period->period_name;
 } else {
     $header[1] = "Unknown";
 }
 if ($period->fetchPeriod($periodto_id)) {
     $header[2] = $period->period_name;
 } else {
     $header[2] = "Unknown";
 }
 if ($showaccountcode == "on") {
     $orderby = "ORDER BY ac.classtype,a.accountcode_full";
 } else {
     $orderby = "ORDER BY ac.classtype,a.accountcode_full,a.placeholder desc,a.accounts_name";
 }
 private function getBlankTempTrans($rownum, $invDate = null)
 {
     $comp = Company::model()->findbyPk(Yii::app()->user->getState('selectedCompanyId'));
     $per = Period::model()->findbyPk(Yii::app()->user->getState('selectedPeriodId'));
     $model = new TempTrans();
     $model->rownum = $rownum;
     $model->regDate = date('Y-m-d');
     if ($invDate == null) {
         $invDate = $model->regDate;
     }
     $model->invDate = $invDate;
     $model->changedBy = Yii::app()->user->getState('displayname');
     $model->dateChanged = $model->regDate;
     $model->periodNum = $per->lastPeriodTransNum + 1;
     $model->companyNum = $comp->lastAbsTransNum + 1;
     $model->notesheader = '';
     $model->fileInfo = '';
     $model->fileInfo = 1;
     $model->accountId = 0;
     $model->customerId = 0;
     $model->donorId = 0;
     $model->notes = '';
     $model->amountdebit = "";
     $model->amountcredit = "";
     $model->userId = Yii::app()->user->id;
     $model->save();
     $cLoc = CLocale::getInstance('en');
     $model->invDate = User::getDateFormatted($model->invDate, $cLoc);
     $model->regDate = User::getDateFormatted($model->regDate, $cLoc);
     $model->dateChanged = $model->regDate;
     return $model;
 }
Пример #29
0
 /**
  * ajoute un prix
  * @param int $obj_id
  * @param int $grp_id
  * @param int $per_id
  * @param int $pri_credit
  * @return String $csvResult
  */
 public function addPrice($obj_id, $grp_id, $per_id, $pri_credit)
 {
     $rtn = new ComplexData();
     $obj = new Object($obj_id);
     if ($obj->getState() != 1) {
         $rtn->addLine(array($obj->getState(), 0));
         return $rtn->csvArrays();
     }
     $grp = new Group($grp_id);
     if ($grp->getState() != 1) {
         $rtn->addLine(array($grp->getState(), 0));
         return $rtn->csvArrays();
     }
     $per = new Period($per_id);
     if ($per->getState() != 1) {
         $rtn->addLine(array($per->getState(), 0));
         return $rtn->csvArrays();
     }
     $price = new Price(0, $obj, $grp, $per, $pri_credit);
     $rtn->addLine(array($price->getState(), $price->getId()));
     return $rtn->csvArrays();
 }
Пример #30
0
Login::access("member");


if (!empty($_GET['id'])) {
	$ballot = new Ballot($_GET['id']);
	if (!$ballot->id) {
		error(_("This ballot does not exist!"));
	}
	$period = new Period($ballot->period);
	if ($period->state=="ballot_preparation") {
		warning(_("Ballot preparation has already begun, so ballots can not be changed anymore."));
		redirect("ballots.php?period=".$period->id);
	}
} else {
	$period = new Period(@$_GET['period']);
	if (!$period) {
		error(_("The requested period does not exist!"));
	}
	if ($period->state=="ballot_preparation") {
		warning(_("Ballot preparation has already begun, so ballots can not be changed anymore."));
		redirect("ballots.php?period=".$period->id);
	}
	if ($period->state=="ballot_assignment") {
		warning(_("Ballot assignment has already begun, so ballot applications are not allowed anymore."));
		redirect("ballots.php?period=".$period->id);
	}
	$ballot = new Ballot;
	$ballot->period = $period->id;
}