public function loadModel($id)
 {
     if (($model = Employee::model()->findByPk($id)) === null) {
         throw new CHttpException(404, Yii::t('TeamModule.team', 'Page was not found!'));
     }
     return $model;
 }
示例#2
0
 private function getModel()
 {
     if (!$this->isGuest && $this->_model === null) {
         $this->_model = Employee::model()->findByPk($this->id, array('select' => 'role'));
     }
     return $this->_model;
 }
 public function loadModel($id)
 {
     if (($model = Employee::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
 public function run()
 {
     $models = Employee::model()->cache($this->controller->yupe->coreCacheTime)->published()->contactWidget()->findAll(['order' => 't.widget_sort']);
     if (empty($models)) {
         return;
     }
     $this->render($this->view, ['models' => $models, 'title' => $this->title]);
 }
 public function run()
 {
     $models = Employee::model()->published()->findAll(['order' => 't.sort']);
     if (empty($models)) {
         return;
     }
     $this->render($this->view, ['models' => $models, 'title' => $this->title]);
 }
 /**
  * Страница отдельного сотрудника
  */
 public function actionShow($alias)
 {
     $model = Employee::model()->published()->with(array('department' => array('scopes' => 'published'), 'projects' => array('scopes' => 'published', 'order' => 'projects.sort ASC')))->findByAlias($alias);
     if (!$model) {
         throw new CHttpException(404);
     }
     $this->render('item', array('model' => $model));
 }
示例#7
0
 public function getEmployeeIdFromClerkId($clerkId, $throwException = true)
 {
     $e = Employee::model()->findByAttributes(array('id' => $clerkId, 'wlabel_id' => Yii::app()->user->getWhitelabelId()));
     if ($e == null) {
         if ($throwException) {
             throw new CHttpException(400, 'Invalid request. No clerk found!');
         } else {
             return null;
         }
     }
     return $e->employee_id;
 }
示例#8
0
 public function authenticate()
 {
     $record = Employee::model()->findByAttributes(array('name' => $this->username));
     $hash = CPasswordHelper::hashPassword($record->password);
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!CPasswordHelper::verifyPassword($this->password, $hash)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $record->employee_id;
             $this->setState('title', $record->name);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
示例#9
0
 public function authenticate()
 {
     // Производим стандартную аутентификацию, описанную в руководстве.
     $user = Employee::model()->find('LOWER(login)=?', array(strtolower($this->username)));
     if ($user === null || md5($this->password) !== $user->password) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         // В качестве идентификатора будем использовать id, а не username,
         // как это определено по умолчанию. Обязательно нужно переопределить
         // метод getId(см. ниже).
         $this->_id = $user->employee_id;
         // Далее логин нам не понадобится, зато имя может пригодится
         // в самом приложении. Используется как Yii::app()->user->name.
         // realName есть в нашей модели. У вас это может быть name, firstName
         // или что-либо ещё.
         $this->username = $user->name;
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     if (strpos($this->username, "@")) {
         $user = RbacUser::model()->findByAttributes(array('user_email' => $this->username));
     } else {
         $user = RbacUser::model()->findByAttributes(array('user_name' => $this->username));
         $ph = new PasswordHash(Yii::app()->params['phpass']['iteration_count_log2'], Yii::app()->params['phpass']['portable_hashes']);
     }
     if ($user === null) {
         if (strpos($this->username, "@")) {
             $this->errorCode = self::ERROR_EMAIL_INVALID;
         } else {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         }
     } elseif (!$ph->CheckPassword($this->password, $user->user_password)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
         //else if($user->status==0&&Yii::app()->getModule('user')->loginNotActiv==false)
         //	$this->errorCode=self::ERROR_STATUS_NOTACTIV;
     } elseif ($user->status == 0) {
         $this->errorCode = self::ERROR_STATUS_BAN;
     } else {
         $this->_id = $user->id;
         $this->username = $user->user_name;
         // title column as username
         $this->errorCode = self::ERROR_NONE;
         $employeeId = $user->employee_id;
         // Store employee ID in a session:
         //$this->setState('employeeid',$employeeId);
         Yii::app()->session['employeeid'] = $employeeId;
         Yii::app()->session['userid'] = $user->id;
         $employee = Employee::model()->findByPk($employeeId);
         Yii::app()->session['emp_fullname'] = $employee->first_name . ' ' . $employee->last_name;
         //Saving User Login & out timing
         Yii::app()->session['unique_id'] = uniqid();
         $login_time = Date('Y-m-d H:i:s');
         //UserLog::model()->saveUserlog(Yii::app()->session['unique_id'], Yii::app()->session->sessionID,Yii::app()->session['userid'],$employeeId,$user->user_name,$login_time);
     }
     return !$this->errorCode;
 }
 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) {
                     $empid = Employee::model()->findbyattributes(array('oldnik' => $data[0]));
                     $model = new Employeeschedule();
                     if ($empid != null) {
                         $model = Employeeschedule::model()->findByattributes(array('employeeid' => $empid->employeeid, 'month' => $data[2], 'year' => $data[3]));
                         if ($model == null) {
                             $model = new Employeeschedule();
                         }
                         $model->employeeid = $empid->employeeid;
                         $model->month = $data[2];
                         $model->year = $data[3];
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[4]));
                         if ($d != null) {
                             $model->d1 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[5]));
                         if ($d != null) {
                             $model->d2 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[6]));
                         if ($d != null) {
                             $model->d3 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[7]));
                         if ($d != null) {
                             $model->d4 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[8]));
                         if ($d != null) {
                             $model->d5 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[9]));
                         if ($d != null) {
                             $model->d6 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[10]));
                         if ($d != null) {
                             $model->d7 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[11]));
                         if ($d != null) {
                             $model->d8 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[12]));
                         if ($d != null) {
                             $model->d9 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[13]));
                         if ($d != null) {
                             $model->d10 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[14]));
                         if ($d != null) {
                             $model->d11 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[15]));
                         if ($d != null) {
                             $model->d12 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[16]));
                         if ($d != null) {
                             $model->d13 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[17]));
                         if ($d != null) {
                             $model->d14 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[18]));
                         if ($d != null) {
                             $model->d15 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[19]));
                         if ($d != null) {
                             $model->d16 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[20]));
                         if ($d != null) {
                             $model->d17 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[21]));
                         if ($d != null) {
                             $model->d18 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[22]));
                         if ($d != null) {
                             $model->d19 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[23]));
                         if ($d != null) {
                             $model->d20 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[24]));
                         if ($d != null) {
                             $model->d21 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[25]));
                         if ($d != null) {
                             $model->d22 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[26]));
                         if ($d != null) {
                             $model->d23 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[27]));
                         if ($d != null) {
                             $model->d24 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[28]));
                         if ($d != null) {
                             $model->d25 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[29]));
                         if ($d != null) {
                             $model->d26 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[30]));
                         if ($d != null) {
                             $model->d27 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[31]));
                         if ($d != null) {
                             $model->d28 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[32]));
                         if ($d != null) {
                             $model->d29 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[33]));
                         if ($d != null) {
                             $model->d30 = $d->absscheduleid;
                         }
                         $d = Absschedule::model()->findbyattributes(array('absschedulename' => $data[34]));
                         if ($d != null) {
                             $model->d31 = $d->absscheduleid;
                         }
                         $model->recordstatus = Wfgroup::model()->findstatusbyuser('insempsched');
                     }
                     try {
                         if (!$model->save()) {
                             $this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]);
                         } else {
                             $a = Yii::app()->user->name;
                             $connection = Yii::app()->db;
                             $transaction = $connection->beginTransaction();
                             try {
                                 $sql = 'call ApproveEmployeeSchedule(:vid, :vlastupdateby)';
                                 $command = $connection->createCommand($sql);
                                 $command->bindvalue(':vid', $model->employeescheduleid, PDO::PARAM_INT);
                                 $command->bindvalue(':vlastupdateby', $a, PDO::PARAM_STR);
                                 $command->execute();
                                 $transaction->commit();
                             } catch (Exception $e) {
                                 $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;
 }
示例#12
0
 public function verifyDelete()
 {
     $advertiserId = $this->advertiser_id;
     if (Employee::model()->findByAttributes(array('advertiser_id' => $this->advertiser_id))) {
         throw new CHttpException(400, 'You cannot delete advertiser that contains some employees!');
     }
     if (PurchasedPlan::model()->findByAttributes(array('advertiser_id' => $this->advertiser_id))) {
         throw new CHttpException(400, 'You cannot delete advertiser that has some purchased plans!');
     }
     return true;
 }
示例#13
0
echo Yii::t('TeamModule.team', 'Fields with');
?>
    <span class="required">*</span>
    <?php 
echo Yii::t('TeamModule.team', 'are required.');
?>
</div>

<?php 
echo $form->errorSummary($model);
?>

<div class="row">
    <div class="col-sm-3">
        <?php 
echo $form->dropDownListGroup($model, 'chief_id', ['widgetOptions' => ['data' => Employee::model()->employeeList, 'htmlOptions' => ['class' => 'popover-help', 'empty' => Yii::t('TeamModule.team', '--choose--'), 'data-original-title' => $model->getAttributeLabel('chief_id'), 'data-content' => $model->getAttributeDescription('chief_id')]]]);
?>
    </div>
    <div class="col-sm-4">
        <?php 
echo $form->dropDownListGroup($model, 'status', ['widgetOptions' => ['data' => $model->statusList, 'htmlOptions' => ['class' => 'popover-help', 'empty' => Yii::t('TeamModule.team', '--choose--'), 'data-original-title' => $model->getAttributeLabel('status'), 'data-content' => $model->getAttributeDescription('status')]]]);
?>
    </div>
</div>

<div class="row">
    <div class="col-sm-7">
        <?php 
echo $form->textFieldGroup($model, 'title', ['widgetOptions' => ['htmlOptions' => ['data-original-title' => $model->getAttributeLabel('title'), 'data-content' => $model->getAttributeDescription('title')]]]);
?>
    </div>
示例#14
0
 public function getEmployeeList()
 {
     return CHtml::listData(Employee::model()->findAll(), 'id', 'name');
 }
示例#15
0
<br>
<div class="span8">
<div class="form">

<?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'officials-form', 'type' => 'horizontal', 'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
?>

	<p class="note" id="requiredation">Fields with <span class="required">*</span> are required.</p>

	<?php 
echo $form->errorSummary($model);
?>

	<?php 
echo $form->dropDownListRow($model, 'emp_id', CHtml::listData(Employee::model()->findAll(array('condition' => 'position <= 3')), 'emp_id', 'Fullname'));
?>

	<?php 
echo $form->datePickerRow($model, 'start_date', array('prepend' => '<i class="icon-calendar"></i>', 'options' => array('format' => 'yyyy-mm-dd')));
?>

	<?php 
echo $form->datePickerRow($model, 'end_date', array('prepend' => '<i class="icon-calendar"></i>', 'options' => array('format' => 'yyyy-mm-dd')));
?>

	<div class="form-actions">
	<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Submit' : 'Save', 'htmlOptions' => array('confirm' => 'Do you want to continue?')));
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'reset', 'type' => 'warning', 'label' => 'Reset', 'htmlOptions' => array('style' => 'margin-left:1%;')));
?>
示例#16
0
文件: Loan.php 项目: edsan/opf
 public function getBorrower()
 {
     $models = Employee::model()->findAll(array("order" => "first_name"));
     $list = Chtml::listData($models, 'employee_id', 'fullname');
     return $list;
 }
示例#17
0
 static function ImportEmployee()
 {
     // Делаем запись в таблицу отчетов импорта
     $logreport = new Logreport();
     $logreport->logreport_date = date('Y-m-d');
     $logreport->save();
     self::$logreport_id = $logreport->logreport_id;
     // Идем по файлам импорта из 1С (сотрудники.txt - Сотрудники)
     foreach (['сотрудники.txt'] as $filename) {
         self::$filename = mb_convert_encoding('imp/' . $filename, 'Windows-1251', 'UTF-8');
         if (file_exists(self::$filename)) {
             ini_set('max_execution_time', 1000);
             // 1000 seconds
             ini_set('memory_limit', 1073741824);
             // 1Gbyte Max Memory
             // Определяем показатели импорта
             self::$logreport_errors = 0;
             // Не загружено записей из-за ошибок
             self::$logreport_additions = 0;
             // Записей добавлено
             self::$logreport_amount = 0;
             // Всего записей
             $i = 0;
             $handle = @fopen(self::$filename, "r");
             if ($handle) {
                 while (($subject = fgets($handle, 4096)) !== false) {
                     $i++;
                     $pattern = '/^(.+?)\\|(Поликлиника №\\s?[1,2,3] )?(.+?)\\|(.+?)\\|/ui';
                     preg_match($pattern, $subject, $matches);
                     if ($matches[0] !== NULL) {
                         $pattern = '/(^Поликлиника №)\\s?([1,2,3])\\s?$/ui';
                         $matches[2] = preg_replace($pattern, 'Взрослая $1$2', mb_strtolower($matches[2], 'UTF-8'));
                         if ($matches[3] === 'Поликлиника профилактических осмотров') {
                             $matches[2] = $matches[3];
                         }
                         $pattern = '/^(.+) БУ "Нижневартовская городская поликлиника"$/ui';
                         $matches[3] = preg_replace($pattern, '$1', $matches[3]);
                         $employee_fio = $matches[1];
                         $location = self::AssignLocationForEmployeeImport($matches[3], $matches[2]);
                         $id_dolzh = self::AssignDolzh($matches[4]);
                         // На случай если Здание у сотрудника не определено
                         $buildsql = $location->id_build === null ? 'id_build IS NULL' : 'id_build = :id_build';
                         // Находим сотрудника в базе, если не находим создаем новую запись
                         $Employee = Employee::model()->Find('employee_fio LIKE :employee_fio and id_dolzh = :id_dolzh and id_podraz = :id_podraz and ' . $buildsql, array_merge([':employee_fio' => $employee_fio, ':id_dolzh' => $id_dolzh, ':id_podraz' => $location->id_podraz], $location->id_build === null ? [] : [':id_build' => $location->id_build]));
                         if ($Employee === null) {
                             $Employee = new Employee();
                             $Employee->attributes = ['employee_fio' => $employee_fio, 'id_dolzh' => $id_dolzh, 'id_podraz' => $location->id_podraz, 'id_build' => $location->id_build];
                             $Employeelog = new Employeelog();
                             $Employeelog->id_logreport = self::$logreport_id;
                             $Employeelog->employeelog_type = 1;
                             $Employeelog->employeelog_filename = mb_convert_encoding(self::$filename, 'UTF-8', 'Windows-1251');
                             $Employeelog->employeelog_rownum = $i;
                             $Employeelog->employeelog_message = 'Запись добавлена.';
                             $Employee->scenario = 'import1c';
                             if ($Employee->validate()) {
                                 self::$logreport_additions++;
                                 $Employee->save(false);
                             } else {
                                 $Employeelog->employeelog_type = 3;
                                 $Employeelog->employeelog_message = 'Ошибка при добавлении записи: ';
                                 foreach ($Employee->getErrors() as $fields) {
                                     $Employeelog->employeelog_message .= implode(' ', $fields) . ' ';
                                 }
                                 self::$logreport_errors++;
                             }
                             $Employeelog->employee_fio = $Employee->employee_fio;
                             $Employeelog->dolzh_name = Dolzh::model()->findbyPk($Employee->id_dolzh)->dolzh_name;
                             $Employeelog->podraz_name = Podraz::model()->findbyPk($Employee->id_podraz)->podraz_name;
                             if ($Employee->id_build !== null) {
                                 $Employeelog->build_name = Build::model()->findbyPk($Employee->id_build)->build_name;
                             }
                             $Employeelog->save(false);
                         }
                     } elseif (trim($subject) !== '') {
                         $Employeelog = new Employeelog();
                         $Employeelog->id_logreport = self::$logreport_id;
                         $Employeelog->employeelog_type = 3;
                         $Employeelog->employeelog_filename = mb_convert_encoding(self::$filename, 'UTF-8', 'Windows-1251');
                         $Employeelog->employeelog_rownum = $i;
                         $Employeelog->employeelog_message = 'Ошибка при добавлении записи: Не пройдено регулярное выражение /^(.+?)\\|(Поликлиника №\\s?[1,2,3] )?(.+?)\\|(.+?)\\|/ui';
                         $Employeelog->save(false);
                         self::$logreport_errors++;
                     }
                 }
                 fclose($handle);
             }
             $logreport->logreport_additions += self::$logreport_additions;
             $logreport->logreport_errors += self::$logreport_errors;
             $logreport->logreport_amount = $i;
             $logreport->save();
         }
     }
     echo '<BR>Подразделения:<BR>';
     ARData::Data(Podraz::model(), Podraz::model()->Test())->PrintData();
     echo '<BR>Должности:<BR>';
     ARData::Data(Dolzh::model(), Dolzh::model()->Test())->PrintData();
     echo '<BR>Сотрудники:<BR>';
     ARData::Data(Employee::model(), Employee::model()->Test())->PrintData();
     echo '<BR>Лог:<BR>';
     ARData::Data(Employeelog::model(), Employeelog::model()->Test())->PrintData();
 }
示例#18
0
 public function getSum($dates)
 {
     $percent = new Percent();
     $summa = 0;
     $summaP = 0;
     $curPercent = 0;
     $employee = Employee::model()->findAll();
     $stuff = new Halfstaff();
     $debt = Debt::model()->findAll('t.d_date = :dates', array(':dates' => $dates));
     $debts = array();
     foreach ($employee as $vals) {
         $summ = 0;
         if ($vals->check_percent == 1) {
             $curPercent = $percent->getPercent($dates);
         } else {
             $curPercent = 0;
         }
         $model = Yii::app()->db->CreateCommand()->select('t.expense_id')->from('expense t')->where('date(t.order_date) = :dates AND t.kind = :kind AND t.employee_id = :empId AND t.status != :status AND t.debt != :debt', array(':dates' => $dates, ':kind' => 0, ':empId' => $vals->employee_id, ':status' => 1, ':debt' => 1))->queryAll();
         /*$model = Expense::model()->with()->findAll( 'date(t.order_date) = :dates AND t.kind = :kind AND t.employee_id = :empId AND t.status != :status AND t.debt != :debt', array(
         
         				    ':dates' => $dates,
         				    ':kind'  => 0,
         			        ':empId' => $vals->employee_id,
                             ':status'=> 1,
                             ':debt' => 1
         			    ) );*/
         if (!empty($model)) {
             foreach ($model as $value) {
                 $summ = $summ + $this->getExpenseSum($value['expense_id'], $dates);
             }
         }
         $tempSumm = $summ / 100 * $curPercent + $summ;
         $summaP = round($tempSumm / 100) * 100 + $summaP;
         $summa = round(($summ + $summa) / 100) * 100;
     }
     if (!empty($debt)) {
         foreach ($debt as $value) {
             $debts = $stuff->sumArray($debts, $this->getExpenseProcSum($value->expense_id, $dates));
         }
     }
     return array(1 => $summaP + $debts[1], 2 => $summa + $debts[2]);
 }
示例#19
0
 public function actionCopyClientInfo()
 {
     if (Yii::app()->request->isPostRequest && Yii::app()->request->isAjaxRequest) {
         $param = (int) $_POST['Client']['employee_id'];
         $employee = Employee::model()->findByPk($param);
         echo CJSON::encode(array('status' => 'success', 'mobile_no' => $employee->mobile_no, 'first_name' => $employee->first_name, 'last_name' => $employee->last_name, 'address1' => $employee->adddress1, 'address2' => $employee->address2, 'notes' => $employee->notes));
     }
 }
示例#20
0
</div>
<div id="page-wrapper">
    <div class="col-xs-12">
        <div class="col-xs-3">
            <label>Стол</label>
            <?php 
echo CHtml::dropDownList('table', $table, array(1, 2, 3, 4, 5, 6, 7, 8, 9), array('class' => 'form-control'));
?>
 &nbsp; &nbsp;

        </div>
        <div class="col-xs-3">

            <label>официант</label>
            <?php 
echo CHtml::dropDownList('employee_id', $empId, CHtml::listData(Employee::model()->findAll(), 'employee_id', 'name'), array('class' => 'form-control'));
?>
        </div>
        <div class="col-xs-3">
            <label>Долг</label>
            <?php 
echo CHtml::checkBox('debt', $debt ? true : false, array('class' => 'form-control'));
?>
        </div>
        <?php 
echo CHtml::textField('comment', '', array('style' => 'display:none'));
?>
    </div>
    <div class="tab-panels" id="updata">

    </div>
示例#21
0
<div class="span8">
<div class="form">

<?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'user-form', 'type' => 'horizontal', 'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
?>

	<p class="note" id="requiredation">Fields with <span class="required">*</span> are required.</p>
	<?php 
echo $form->errorSummary($model);
?>
	<?php 
echo $form->textFieldRow($model, 'username', array('size' => 50, 'maxlength' => 50));
?>
	<?php 
echo $form->dropDownListRow($model, 'emp_id', CHtml::listData(Employee::model()->findAll(), 'emp_id', 'fullname'));
?>
	
	<?php 
echo $form->dropDownListRow($model, 'role', $model->getRoles());
?>
	<?php 
echo $form->datepickerRow($model, 'start_date', array('prepend' => '<i class="icon-calendar"></i>', 'options' => array('format' => 'yyyy-mm-dd')));
?>
                                                            	
	<?php 
echo $form->datepickerRow($model, 'exp_date', array('prepend' => '<i class="icon-calendar"></i>', 'options' => array('format' => 'yyyy-mm-dd')));
?>
                                                            	

 public function undodeleteEmployee($item_id)
 {
     Employee::model()->updateByPk((int) $item_id, array('status' => $this->employee_active));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Employee::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#24
0
        <span class="required">*</span>
        <?php 
echo Yii::t('TeamModule.team', 'обязательны.');
?>
    </div>

    <?php 
echo $form->errorSummary($model);
?>

    <div class="row-fluid control-group <?php 
echo $model->hasErrors('chief_id') ? 'error' : '';
?>
">
        <?php 
echo $form->dropDownListRow($model, 'chief_id', CHtml::listData(Employee::model()->findAll(), 'id', 'name'), array('empty' => 'Выберите руководителя'));
?>
    </div>
    <div class="row-fluid control-group <?php 
echo $model->hasErrors('title') ? 'error' : '';
?>
">
        <?php 
echo $form->textFieldRow($model, 'title', array('class' => 'span7 popover-help', 'size' => 60, 'maxlength' => 250, 'data-original-title' => $model->getAttributeLabel('title'), 'data-content' => $model->getAttributeDescription('title')));
?>
    </div>

    <?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? Yii::t('TeamModule.team', 'Создать и продолжить') : Yii::t('TeamModule.team', 'Сохранить и продолжить')));
?>
    <?php 
示例#25
0
 public function actionEmployeeFields()
 {
     $result = Proc::GenerateColModel(Employee::model(), Employee::model()->Employeecriteria());
     Proc::Fields_ChangeColModel($result, 'employee_id', ['hidden' => false, 'isid' => false]);
     echo json_encode($result);
 }
示例#26
0
 public function actionEmpList()
 {
     $model = Employee::model()->findAll('role < :numb', array(':numb' => 3));
     $this->renderPartial('empList', array('model' => $model));
 }
 public static function employeeByID($id)
 {
     $model = Employee::model()->findByPk($id);
     return isset($model) ? $model : null;
 }
示例#28
0
 protected function sessionInfo($data = array())
 {
     //$data=array();
     $data['items'] = Yii::app()->shoppingCart->getCart();
     $data['count_item'] = Yii::app()->shoppingCart->getQuantityTotal();
     $data['payments'] = Yii::app()->shoppingCart->getPayments();
     $data['count_payment'] = count(Yii::app()->shoppingCart->getPayments());
     $data['payment_received'] = Yii::app()->shoppingCart->getPaymentsTotal();
     $data['sub_total'] = Yii::app()->shoppingCart->getSubTotal();
     $data['total_b4vat'] = Yii::app()->shoppingCart->getTotalB4Vat();
     $data['total'] = Yii::app()->shoppingCart->getTotal();
     $data['total_due'] = Yii::app()->shoppingCart->getTotalDue();
     $data['qtytotal'] = Yii::app()->shoppingCart->getQuantityTotal();
     $data['amount_change'] = Yii::app()->shoppingCart->getAmountDue();
     // This is only work for current invoice
     $data['amount_change'] = Yii::app()->shoppingCart->getTotalDue();
     // Outstanding + Current Invoice / Hot Bill - Total Payment
     $data['customer_id'] = Yii::app()->shoppingCart->getCustomer();
     $data['comment'] = Yii::app()->shoppingCart->getComment();
     $data['employee_id'] = Yii::app()->session['employeeid'];
     $data['salerep_id'] = Yii::app()->shoppingCart->getSaleRep();
     $data['transaction_date'] = date('d/m/Y');
     $data['transaction_time'] = date('h:i:s');
     $data['session_sale_id'] = Yii::app()->shoppingCart->getSaleId();
     //$data['employee'] = ucwords(Yii::app()->session['emp_fullname']);
     $data['total_discount'] = Yii::app()->shoppingCart->getTotalDiscount();
     $data['total_gst'] = Yii::app()->shoppingCart->getTotalGST();
     $data['disable_editprice'] = Yii::app()->user->checkAccess('sale.editprice') ? false : true;
     $data['disable_discount'] = Yii::app()->user->checkAccess('sale.discount') ? false : true;
     $data['colspan'] = Yii::app()->settings->get('sale', 'discount') == 'hidden' ? '2' : '3';
     $data['discount_amount'] = Common::calDiscountAmount($data['total_discount'], $data['sub_total']);
     $data['gst_amount'] = $data['total_b4vat'] * $data['total_gst'] / 100;
     $discount_arr = Common::Discount($data['total_discount']);
     $data['discount_amt'] = $discount_arr[0];
     $data['discount_symbol'] = $discount_arr[1];
     /** Rounding a numbere to a nearest 10 or 100 (Floor : round down, Ceil : round up , Round : standard round 
      *  Ref: http://stackoverflow.com/questions/1619265/how-to-round-up-a-number-to-nearest-10
      *    ** http://stackoverflow.com/questions/6619377/how-to-get-whole-and-decimal-part-of-a-number
      *  Method : using Round method here 
      */
     $data['usd_2_khr'] = Yii::app()->settings->get('exchange_rate', 'USD2KHR');
     $data['total_khr'] = $data['total'] * $data['usd_2_khr'];
     $data['amount_change_khr'] = $data['amount_change'] * $data['usd_2_khr'];
     //Stupid PHP passing calculation 0.9-1 * 4000 = -3999.1 ,  (0.9-1) * 4000 = 400 correct
     /*
      * Total is to round up [Ceil] - Company In
      * Amount_Change suppose to round done [Floor] but usually this value is minus so using [Ceil] instead
      */
     $data['total_khr_round'] = ceil($data['total_khr'] / 100) * 100;
     $data['amount_change_khr_round'] = ceil($data['amount_change_khr'] / 100 - 0.1) * 100;
     // Got no idea why PHP ceil(-0.1/100)*100 = 399
     $data['amount_change_whole'] = ceil($data['amount_change']);
     // floor(1.25)=1
     $data['amount_change_fraction_khr'] = ceil(($data['amount_change'] - $data['amount_change_whole']) * $data['usd_2_khr'] / 100 - 0.1) * 100;
     //Added 0.1 to solve ceil (-0.1/100)*100=399
     /*** Customer Account Info ***/
     $account = $this->custAccountInfo($data['customer_id']);
     $customer = Client::model()->clientByID($data['customer_id']);
     $employee = Employee::model()->employeeByID($data['employee_id']);
     $sale_rep = Employee::model()->employeeByID($data['salerep_id']);
     $data['account'] = $account;
     $data['customer'] = $customer;
     $data['employee'] = $employee;
     $data['acc_balance'] = $account !== null ? $account->current_balance : '';
     $data['cust_fullname'] = $customer !== null ? $customer->first_name . ' ' . $customer->last_name : 'General';
     $data['salerep_fullname'] = $sale_rep !== null ? $sale_rep->first_name . ' ' . $sale_rep->last_name : $employee->first_name . ' ' . $employee->last_name;
     $data['salerep_tel'] = $sale_rep !== null ? $sale_rep->mobile_no : '';
     $data['cust_address1'] = $customer !== null ? $customer->address1 : '';
     $data['cust_mobile_no'] = $customer !== null ? $customer->mobile_no : '';
     $data['cust_fax'] = $customer !== null ? $customer->fax : '';
     $data['cust_notes'] = $customer !== null ? $customer->notes : '';
     $data['cust_contact_fullname'] = '';
     if ($customer !== null) {
         $data['cust_contact_fullname'] = $customer->contact !== null ? $customer->contact->first_name . ' ' . $customer->contact->last_name : '';
     }
     return $data;
 }
示例#29
0
<div class="input-prepend">
    <span class="add-on"><i class="icon-calendar"></i></span><?php 
$this->widget('bootstrap.widgets.TbDatePicker', array('value' => $dates, 'name' => 'dates', 'options' => array('language' => 'ru', 'format' => 'yyyy-mm-dd')));
?>
</div>
<?php 
echo CHtml::dropDownList('employee', '', CHtml::listData(Employee::model()->findAll(), 'employee_id', 'name'));
?>
<button type="button" id="export" class="btn ">Показать</button>
<div id="data"></div>
<script>
    $(document).ready(function(){
        var dates,
            empId;
        $('#export').click(function(){
            dates = $('#dates').val();
            empId = $('#employee').val();
            $.ajax({
                type: "POST",
                url: "<?php 
echo Yii::app()->createUrl('expense/ajaxEmpExpense');
?>
",
                data: "dates="+dates+"&empId="+empId,
                success: function(data){
                    $('#data').html(data);
                }
            });
        });
    });
</script>
示例#30
0
<!--<div ><?php 
$expense = new Expense();
$this->widget('application.extensions.print.printWidget', array('printedElement' => '#datas-' . $empId, 'htmlOptions' => array('id' => 'print')));
?>
</div>-->
<?php 
foreach ($empId as $key => $val) {
    $model = Expense::model()->with('order')->findAll('date(t.order_date) = :dates AND t.employee_id = :empId AND t.kind = :kind', array(':dates' => $dates, ':empId' => $val, ':kind' => 0));
    $counting = 1;
    $count = 0;
    ?>
    <?php 
    if (!empty($model)) {
        ?>
        <h3><?php 
        echo Employee::model()->findByPk($val)->name;
        ?>
</h3>
<table class="table table-bordered">
    <thead>
    <tr>
        <th></th>
        <th>Дата и время</th>
        <th>Стол №</th>
        <th>Сумма счета</th>
        <th></th>
    </tr>
    </thead>
    <tbody>
    <?php 
        foreach ($model as $value) {