public function getClient($id) { if (empty($id)) { return NULL; } $dept_id = Clients::model()->getScaler('client_name', '`id`=:t1', array(':t1' => $id)); return !empty($dept_id) ? $dept_id : NULL; }
/** * Check Auth_Code rule */ public function check_auth() { $client = Clients::model()->findByPk($this->Client_ID); if($client) { $company = Companies::model()->findByPk($client->Company_ID); if ($company->Auth_Code != $this->Auth_Code) { $this->addError('Auth_Code','Invalid Authorization Code'); } } else { $this->addError('Auth_Code',"Company with this Authorization Code doesn't exists"); } }
function Header() { $client = Clients::model()->with('company')->findByPk(Yii::app()->user->clientID); $project = Projects::model()->findByPk(Yii::app()->user->projectID); $projectId = Yii::app()->user->projectID; //Logo //$this->Image('logo_pb.png',10,8,33); //Arial bold 15 $this->SetFont('Arial','',12); $this->SetXY(5,5); //$this->Cell(20,10,$client->company->Company_Name.' - '.$project->Project_Name ,0,0,'L'); $this->SetXY(5,5); $this->SetFont('Arial','B',12); $this->Cell(0,0, Helper::shortenString($client->company->Company_Name,30).' - '.Helper::shortenString($project->Project_Name,20),0,1,'L'); $this->SetFont('Arial','',12); $this->SetXY(5,10); $this->Cell(0,0,"Export Summary:",0,1,'L'); // $this->Text(0,10,"AP Batch Summary Report: "); $this->SetFont('Arial','B',12); $this->SetXY(140,5); if($this->doc_type == 'AP') { $this->Cell(0,0,"AP Batch Summary Report:",0,1,'R'); } else { $this->Cell(0,0,"PO Batch Summary Report:",0,1,'R'); } $this->SetFont('Arial','',12); $this->SetXY(140,10); $this->Cell(0,0,"Batch ".$this->batch_id,0,1,'R'); //$this->SetXY(120,5); //$this->Cell(0,0,"AP Batch Summary Report: ",0,0,'R'); $this->Line(5,14,205,14); $this->Ln(5); }
public function appendCompany($client_id){ $client = Clients::model()->with('company.adreses')->findByPk($client_id); $company = $client->company; $xml_company = $this->xml->createElement("company"); $xml_row = $this->xml->createElement("row"); foreach ($company->attributes as $key => $value) { $xml_field = $this->xml->createElement("field",htmlentities($value,ENT_QUOTES | 'ENT_XML1')); $xml_field->setAttribute('name', $key); $xml_row->appendChild($xml_field); } $xml_company->appendChild($xml_row); $xml_adreses = $this->xml->createElement("addresses"); foreach ($company->adreses as $address) { $xml_address = $this->xml->createElement("address"); $xml_row = $this->xml->createElement("row"); foreach ($address->attributes as $key=>$value) { $xml_field = $this->xml->createElement("field",htmlentities($value,ENT_QUOTES | 'ENT_XML1')); $xml_field->setAttribute('name', $key); $xml_row->appendChild($xml_field); } $xml_address->appendChild($xml_row); } $xml_adreses->appendChild($xml_address); $xml_company->appendChild($xml_adreses); $this->wrapper->appendChild($xml_company); }
<?php $this->breadcrumbs = array('Работы' => array('index'), 'Управление'); $this->menu = array(array('label' => 'Создать работу', 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('works-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>Управление работами/услугами</h1> <?php $this->widget('application.extensions.yii-flash.Flash', array('keys' => array('success', 'error', 'notice'), 'htmlOptions' => array('class' => 'flash'))); ?> <!-- flashes --> <p> Можно использовать (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b> или <b>=</b>). </p> <?php echo CHtml::link('Advanced Search', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'works-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'date', array('name' => 'client_id', 'value' => '$data->client->name', 'filter' => CHtml::listData(Clients::model()->findAll(array('order' => 'name')), 'id', 'name')), array('name' => 'order_id', 'value' => '$data->order->name', 'filter' => CHtml::listData(Orders::model()->findAll(array('order' => 'name')), 'id', 'name')), array('name' => 'act_id', 'value' => '!is_null($data->act_id)?$data->act->num:null', 'filter' => CHtml::listData(Acts::model()->findAll(array('order' => 'num')), 'id', 'num')), 'name', 'unit', 'cost', 'quantity', 'sum', 'location', array('class' => 'MyButtonColumn'))));
/** * This method is invoked right before an action is to be executed (after all possible filters.) * @param CAction $action the action to be executed. * @return boolean whether the action should be executed */ public function beforeAction($action) { $response = false; //if (Yii::app()->user->getState('project_selected') != null) //{ if (in_array($action->id, array('view', 'update'))) { $response = Clients::model()->countClientsByAccount((int) $_GET['id'], Yii::app()->user->Accountid) > 0 ? true : false; } else { $response = true; } //} //else // return false; if (!$response) { throw new CHttpException(403, Yii::t('site', '403_Error')); } else { return $response; } }
/** * Lists all models. */ public function actionIndex() { if (isset($_POST['oper']) && $_POST['oper'] == 'edit') { $id = intval($_POST["id"]); $video = Videos::model()->findByPk($id); if ($video) { $error_string= ''; $video->Video_Title =$_POST['Video_Title'] ? $_POST["Video_Title"] : null; $video->Video_Log_Line =$_POST['Video_Log_Line'] ? $_POST["Video_Log_Line"] : null; $video->Video_Desc =$_POST['Video_Desc'] ? $_POST["Video_Desc"] : null; $video->Link_Title =$_POST['Link_Title'] ? $_POST["Link_Title"] : null; $video->Sort_Order =$_POST['Sort_Order'] ? $_POST["Sort_Order"] : null; $video->Video_URL =$_POST['Video_URL'] ? addslashes($_POST['Video_URL']) : null; $video->Video_Password =$_POST['Video_Password'] ? $_POST["Video_Password"] : null; $video->Visibility =$_POST['Visibility'] ? $_POST["Visibility"] : null; if (intval($_POST['Visibility'])==4) { $client_id = intval($_POST['Clients_Client_ID']); $client = Clients::model()->findByPk($client_id); if (!$client) { $error_string = 'Client_ID should be real'; } } if (intval($_POST['Visibility'])==5) { $client_id = intval($_POST['Clients_Client_ID']); $project_id = intval($_POST['Clients_Client_ID']); $project = Projects::model()->findByAttributes(array( 'Project_ID'=>$project_id, 'Client_ID'=>$client_id )); if (!$project) { $error_string = 'There is no project for such Client_ID and Project_ID'; } } $video->Clients_Client_ID =$_POST['Clients_Client_ID'] ? $_POST["Clients_Client_ID"] : null; $video->Project_ID =$_POST['Project_ID'] ? $_POST["Project_ID"] : null; if ($video->validate() && $error_string == '') { $video->save(); echo "video\n"; } else { die($error_string); } } die; } if (isset($_POST['oper']) && $_POST['oper'] == 'add') { // var_dump($_POST);die; $error_string= ''; $video = new Videos(); $video->Video_Title =$_POST['Video_Title']; $video->Video_Log_Line =$_POST['Video_Log_Line']; $video->Video_Desc =$_POST['Video_Desc']; $video->Link_Title =$_POST['Link_Title']; $video->Video_URL =addslashes($_POST['Video_URL']); $video->Video_Password =$_POST['Video_Password']; $video->Sort_Order =$_POST['Sort_Order'] ? $_POST["Sort_Order"] : 1; if (intval($_POST['Visibility'])==4) { $client_id = intval($_POST['Clients_Client_ID']); $client = Clients::model()->findByPk($client_id); if (!$client) { $error_string = 'Client_ID should be real'; } } if (intval($_POST['Visibility'])==5) { $client_id = intval($_POST['Clients_Client_ID']); $project_id = intval($_POST['Clients_Client_ID']); $project = Projects::model()->findByAttributes(array( 'Project_ID'=>$project_id, 'Client_ID'=>$client_id )); if (!$project) { $error_string = 'There is no project for such Client_ID and Project_ID'; } } $video->Visibility =$_POST['Visibility']; $video->Clients_Client_ID =$_POST['Clients_Client_ID']; $video->Project_ID =$_POST['Project_ID']; if ($error_string == '') { $video->save(); } else { die($error_string); } } if (isset($_POST['oper']) && $_POST['oper'] == 'del') { $video_id = intval($_POST["id"]); $video =Videos::model()->findByPk($video_id); if ($video) { $video->delete(); } die; } $conn = mysql_connect(Yii::app()->params->dbhost, Yii::app()->params->dbuser, Yii::app()->params->dbpassword); mysql_select_db(Yii::app()->params->dbname); mysql_query("SET NAMES 'utf8'"); Yii::import('ext.phpgrid.inc.jqgrid'); // set columns $col = array(); $col["title"] = "Video_ID"; // caption of column $col["name"] = "Video_ID"; $col["dbname"] = "Video_ID"; // grid column name, same as db field or alias from sql $col["resizable"] = false; $col["editable"] = false; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = false; $col["sortable"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "Video_Title"; // caption of column $col["name"] = "Video_Title"; $col["dbname"] = "Video_Title"; // grid column name, same as db field or alias from sql $col["resizable"] = false; $col["editable"] = true; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = true; $col["sortable"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "Video_Log_Line"; // caption of column $col["name"] = "Video_Log_Line"; $col["dbname"] = "Video_Log_Line"; // grid column name, same as db field or alias from sql $col["resizable"] = true; $col["editable"] = true; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = true; $col["sortable"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "Video_Desc"; // caption of column $col["name"] = "Video_Desc"; $col["dbname"] = "Video_Desc"; // grid column name, same as db field or alias from sql $col["resizable"] = true; $col["editable"] = true; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = true; $col["sortable"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "Link_Title"; // caption of column $col["name"] = "Link_Title"; $col["dbname"] = "Link_Title"; // grid column name, same as db field or alias from sql $col["resizable"] = true; $col["editable"] = true; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = true; $col["sortable"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "Video_URL"; // caption of column $col["name"] = "Video_URL"; $col["dbname"] = "Video_URL"; // grid column name, same as db field or alias from sql $col["resizable"] = true; $col["editable"] = true; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = true; $col["sortable"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "Video_Password"; // caption of column $col["name"] = "Video_Password"; $col["dbname"] = "Video_Password"; // grid column name, same as db field or alias from sql $col["resizable"] = true; $col["editable"] = true; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = true; $col["sortable"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "Sort_Order"; // caption of column $col["name"] = "Sort_Order"; $col["dbname"] = "Sort_Order"; // grid column name, same as db field or alias from sql $col["resizable"] = true; $col["editable"] = true; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = true; $col["sortable"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "Visibility"; // caption of column $col["name"] = "Visibility"; $col["dbname"] = "Visibility"; // grid column name, same as db field or alias from sql $col["resizable"] = true; $col["editable"] = true; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = true; $col["sortable"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "Clients_Client_ID"; // caption of column $col["name"] = "Clients_Client_ID"; $col["dbname"] = "Clients_Client_ID"; // grid column name, same as db field or alias from sql $col["resizable"] = true; $col["editable"] = true; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = true; $col["sortable"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "Project_ID"; // caption of column $col["name"] = "Project_ID"; $col["dbname"] = "Project_ID"; // grid column name, same as db field or alias from sql $col["resizable"] = true; $col["editable"] = true; // this column is editable $col["hidden"] = false; $col["viewable"] = true; $col["search"] = true; $col["sortable"] = true; $cols[] = $col; $g = new jqgrid(); $grid["caption"] = "Videos"; // $grid["multiselect"] = true; $grid["autowidth"] = true; $grid["resizable"] = true; //$grid["toppager"] = true; $grid["sortname"] = 'Video_ID'; $grid["sortorder"] = "ASC"; $grid["add_options"] = array( 'width'=>'420', "closeAfterEdit"=>true, // close dialog after add/edit "top"=>"200", // absolute top position of dialog "left"=>"200" // absolute left position of dialog ); $g->set_options($grid); $g->set_actions(array( "add"=>true, // allow/disallow add "edit"=>true, // allow/disallow edit "delete"=>true, // allow/disallow delete "rowactions"=>true, // show/hide row wise edit/del/save option "export"=>true, // show/hide export to excel option "autofilter" => true, // show/hide autofilter for search "search" => "advance" // show single/multi field search condition (e.g. simple or advance) ) ); $g->select_command = "SELECT Videos.* FROM Videos"; // set database table for CRUD operations $g->table = "Videos"; $g->set_columns($cols); // group columns header $g->set_group_header( array( "useColSpanStyle"=>true, "groupHeaders"=>array( array( "startColumnName"=>'Video_ID', // group starts from this column "numberOfColumns"=>4, // group span to next 2 columns "titleText"=>'Videos' // caption of group header ), ) ) ); // render grid and get html/js output $out = $g->render("Videos"); $this->render('index',array( 'out'=>$out, )); }
/** * Get vendors to approve to session * @return array */ public static function getVendorsToApproveToSession() { $vendorsList = array(); $client = Clients::model()->with('vendors_list')->findByPk(Yii::app()->user->clientID); if (isset($client->vendors_list)) { $vendors = $client->vendors_list; } else { $vendors = array(); } $i = 1; foreach($vendors as $vendor) { $vendorsList[$i] = $vendor->Vendor_ID; $i++; } return $vendorsList; }
public function loadModel($id) { $model = Clients::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
private function _prepare_body($mdl = null) { $return_msg = ''; if (is_null($mdl)) { if (!isset($_POST['act_id']) and !isset($_POST['order_id']) and empty($_POST['works']) and !isset($_POST['client_id']) and !isset($_POST['template_id']) and !isset($_POST['date']) and !isset($_POST['sum']) and !isset($_POST['num'])) { die("Необходимых данных недостаточно </br>"); } $date = $_POST['date']; $sum = $_POST['sum']; $num = (int) $_POST['num']; $act_id = (int) $_POST['act_id']; $order_id = (int) $_POST['order_id']; $works = $_POST['works']; $client_id = (int) $_POST['client_id']; $template_id = (int) $_POST['template_id']; } else { $date = $mdl->date; $sum = $mdl->sum; $num = $mdl->num; $act_id = $mdl->id; $order_id = $mdl->order_id; $works = false; $client_id = $mdl->client_id; $template_id = $mdl->template_id; } $data['act']['date'] = $date; $data['act']['sum'] = $sum; $data['act']['num'] = $num; if (!is_array($order_pos = Works::model()->worksByOrder($order_id, $act_id, $works))) { $return_msg .= "Невозможно получить список работ </br>"; } $data['works'] = $order_pos; // parse_str($_POST['works']); // Dumper::d($Works);die; $data['contract'] = Contracts::model()->findByPk($order_id, array('select' => 'date, num')); // if (is_null($data['contract'] = Contracts::model()->findByPk((int) $_POST['order_id'], array('select' => 'date, num')))) { // $return_msg .= "Невозможно получить данные договора \n"; // } if (is_null($data['client'] = Clients::model()->findByPk($client_id))) { $return_msg .= "Невозможно получить данные клиента \n"; } if (!is_array($data['settings'] = Config::model()->get_settings())) { $return_msg .= "Невозможно получить основные параметры \n"; } $body = $this->_tmpl_body($data, Acts::model()->get_act_tmpl($template_id)); if ($body == '') { $return_msg .= "Невозможно сформировать шаблон \n"; } if ($return_msg == '') { echo $body; } else { echo $return_msg; } }
<div class="row"> <?php echo $form->labelEx($model, 'name'); ?> <?php echo $form->textField($model, 'name', array('size' => 60, 'maxlength' => 255)); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'client_id'); ?> <?php echo $form->dropDownList($model, 'client_id', CHtml::listData(Clients::model()->findAll(), 'id', 'name')); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'status'); ?> <?php echo $form->dropDownList($model, 'status', Orders::model()->itemAlias('status')); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'date');
/** * Return a value indicating whether the user is or not client * By default user_id as unique param * @return boolean value indicating wheter is or not client */ public function getisClient() { $Users = Clients::model()->with("Users")->count(array('select' => 't.user_id', 'condition' => 'Users.user_id = :user_id', 'params' => array(':user_id' => Yii::app()->user->id))); return (bool) $Users; }
padding: 8px 11px; text-align:left; font-size: 11px; color: #222; line-height: 12px;'), 'value' => function ($data) { return '<span class="square ' . $data->dealPriority->color . '">square</span>' . CHtml::submitButton($data->text, array("class" => "button_to_link", 'onClick' => 'ActionEdit(' . $data->id . ',"deal", "dealings_page")')); }), array('name' => 'client_id', 'header' => 'Клиент', 'headerHtmlOptions' => array('class' => 'w56_5', 'style' => ' height: 12px; border-right: 1px solid #d9d9d9; border-bottom: 1px solid #d9d9d9; padding: 8px 11px; text-align:left; font-size: 11px; color: #222; line-height: 12px;'), 'type' => 'raw', 'value' => function ($data) { $role = UsersRoles::model()->find('user_id=' . Yii::app()->user->id)->itemname; $client_info = Clients::model()->findByPk($data->client_id); $responsible = Users::model()->findByPk($client_info->responsable_id); if ($client_info->responsable_id == Yii::app()->user->id || $responsible->parent_id == Yii::app()->user->id || $role == 'admin') { return CHtml::link($data->client->name, Yii::app()->createUrl("page/client_profile", array("id" => $data->client->id))); } else { return $data->client->name; } }), array('name' => 'paid', 'header' => 'Уплачено / Остаток', 'headerHtmlOptions' => array('class' => 'w57_5', 'style' => ' height: 12px; border-right: 1px solid #d9d9d9; border-bottom: 1px solid #d9d9d9; padding: 8px 11px; text-align:left; font-size: 11px; color: #222; line-height: 12px;'), 'type' => 'raw', 'value' => function ($data) { return round($data->paid) . ' / ' . round($data->balance);
<?php $this->breadcrumbs = array('Contacts' => array('index'), 'Manage'); $this->menu = array(array('label' => 'Создать', 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('contacts-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>Управление контактами</h1> <p>Можно использовать (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b> или <b>=</b>). </p> <?php echo CHtml::link('Advanced Search', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'contacts-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', array('name' => 'client_id', 'value' => '$data->client->name', 'filter' => CHtml::listData(Clients::model()->findAll(), 'id', 'name')), 'name', 'post', 'birthday', 'address', 'phone', 'email', 'icq', array('class' => 'MyButtonColumn'))));
public function actionDelete_user($id) { if ($user = Users::model()->findByPk($id)) { $admin = new Users(); $admin_id = $admin->getAdminId(); $new_responsible = $user->parent_id != null ? $user->parent_id : $admin_id; Clients::model()->updateAll(array('responsable_id' => $new_responsible, 'creator_id' => $new_responsible), 'responsable_id=' . $id); Deals::model()->updateAll(array('responsable_id' => $new_responsible), 'responsable_id=' . $id); Actions::model()->updateAll(array('responsable_id' => $new_responsible), 'responsable_id=' . $id); $user->delete(); $this->redirect(array('user_info')); } }
<div class="row"> <?php echo $form->label($model, 'name'); ?> <?php echo $form->textField($model, 'name', array('size' => 60, 'maxlength' => 255)); ?> </div> <div class="row"> <?php echo $form->label($model, 'client_id'); ?> <?php echo $form->dropDownList($model, 'client_id', CHtml::listData(Clients::model()->findAll(), 'id', 'name'), array('empty' => '(Все)')); ?> </div> <div class="row"> <?php echo $form->label($model, 'status'); ?> <?php echo $form->dropDownList($model, 'status', Orders::model()->itemAlias('fstatus'), array('empty' => '[Все]')); ?> </div> <div class="row"> <?php echo $form->label($model, 'date');
?> <?php if ($model->getIsNewRecord() || $can_update) { ?> <div class="form-group"> <?php echo CHtml::activeLabelEx($model, 'client_id', array('class' => $label_class, 'label' => Lang::t('Client / Partner'))); ?> <div class="<?php echo $input_class; ?> "> <?php echo CHtml::activeDropDownList($model, 'client_id', Clients::model()->getListData('id', 'client_name', '', '', array(), 'client_name'), array('class' => 'form-control')); ?> </div> </div> <div class="form-group"> <?php echo CHtml::activeLabelEx($model, 'user_level', array('class' => $label_class)); ?> <div class="<?php echo $input_class; ?> "> <?php echo CHtml::activeDropDownList($model, 'user_level', Users::model()->getUserLevels($this), array('class' => 'form-control', 'data-show-role' => UserLevels::LEVEL_ADMIN)); ?> </div>
public function countClientsByAccount($client_id, $account_id) { return Clients::model()->count(array('condition' => 't.client_id = :client_id AND Users.account_id = :account_id', 'params' => array(':account_id' => $account_id, ':client_id' => $client_id), 'with' => array('Users'))); }
border-bottom: 1px solid #d9d9d9; padding: 8px 11px; text-align:left; font-size: 11px; color: #222; line-height: 12px;'), 'value' => function ($data) { return '<span class="circle ' . $data->color . '">circle</span>' . $data->name; }), array('name' => 'id', 'header' => 'Количество клиентов', 'headerHtmlOptions' => array('style' => ' height: 12px; border-right: 1px solid #d9d9d9; border-bottom: 1px solid #d9d9d9; padding: 8px 11px; text-align:left; font-size: 11px; color: #222; line-height: 12px;'), 'type' => 'raw', 'value' => function ($data) { return count(Clients::model()->findAll('priority_id=' . $data->id . ' and company_id=' . Users::model()->findByPk(Yii::app()->user->id)->company_id)); })))); ?> <div class="settings-footer"> <div class="help-dropdown open"> <dl> <dt class="dt simple"><i class="icon-help">help</i>Справка</dt> <dd class="dd"> <ul> <li> <strong>Приоритет клиента</strong> определяет важность клиента для компании.<br> Изменять или удалять приоритеты на данный момент невозможно. Сейчас доступно три приоритета: важный, средний и низки. Важный приоритет - это наиболее платежеспособные клиенты, на которых необходимо обратить внимание в первую очередь. Средний приоритет - это перспективные клиенты, с которыми нужно развивать взаимоотношения. Низкий приоритет - это клиенты, у которых нет или мало интереса к товарам или услугам компании. </li> </ul>
/** * * @param <type> $id */ public function actionHtml($id) { if (!is_numeric($id)) { throw new CHttpException(400, 'Неверный идентификатор счёта.'); } $data['invoice_fkt'] = $this->loadModel($id); if (!is_array($works_pos = Works::model()->worksByOrder($data['invoice_fkt']->order_id, $data['invoice_fkt']->act_id))) { Yii::app()->user->setFlash('error', 'Список работ для счёта #' . $data['invoice_fkt']->id . ' пуст'); $this->redirect(array('view', 'id' => $data['invoice_fkt']->id)); } else { $data['works'] = $works_pos; } if (is_null($data['client'] = Clients::model()->findByPk($data['invoice_fkt']->client_id))) { Yii::app()->user->setFlash('error', 'Данные клиента для счёта #' . $data['invoice_fkt']->id . ' пусты'); $this->redirect(array('view', 'id' => $data['invoice_fkt']->id)); } if (!is_array($data['settings'] = Config::model()->get_settings())) { Yii::app()->user->setFlash('error', 'Основные параметры для счёта #' . $data['invoice_fkt']->id . ' пусты'); $this->redirect(array('view', 'id' => $data['invoice_fkt']->id)); } $data['body'] = $this->_tmpl_body($data, InvoicesFktTmpl::model()->findByPk($data['invoice_fkt']->template_id)); $this->layout = false; $this->render('html', array('data' => $data)); }
border-right: 1px solid #d9d9d9; padding: 8px 11px; text-align:left; font-size: 11px; color: #222; line-height: 12px;'), 'value' => function ($data) { return $data->status == 'active' ? 'Активен' : 'Не активен'; }), array('name' => 'clients_count', 'header' => 'Клиенты', 'headerHtmlOptions' => array('class' => 'w8', 'style' => ' height: 12px; border-bottom: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; padding: 8px 11px; text-align:left; font-size: 11px; color: #222; line-height: 12px;'), 'value' => function ($data) { return count(Clients::model()->findAll('responsable_id=' . $data->id)); }), array('name' => 'reg_date', 'header' => 'Дата создания', 'headerHtmlOptions' => array('class' => 'w8', 'style' => ' height: 12px; border-bottom: 1px solid #d9d9d9; padding: 8px 11px; text-align:left; font-size: 11px; color: #222; line-height: 12px;'), 'value' => function ($data) { return date('d.m.y', strtotime($data->reg_date)) . ' в ' . date('H:i', strtotime($data->reg_date)); })))); ?> </div> </div> </main><!--.content--> </div><!--.container--> <aside class="left-sidebar">
public static function getApproversArray ($clientId) { $client = Clients::model()->with('company', 'users')->findByPk($clientId); $client_users = $client->users; $admins_array = array(); $approvalValue = array(); $approvers_array = array(); if ($client_users) { //$_SESSION['tabs_to_auto_load']['client_users_list_appr_value'] = array('client_id'=> $client->Client_ID); //$_SESSION['admin_active_tab']='us_appr_value'; foreach ($client_users as $key => $cuser) { $uClRow = UsersClientList::model()->findByAttributes(array( 'User_ID'=>$cuser->User_ID, 'Client_ID'=>$clientId, )); self::$approversIdValueArray[$cuser->User_ID] = $uClRow->User_Approval_Value; $state_appr = $uClRow->hasApproverPrivileges(); if($state_appr) { $approvers_array[] = array( 'user' =>$cuser, 'approval_value' =>$uClRow->User_Approval_Value ); } } self::$approversArray = $approvers_array; usort(self::$approversArray, 'self::sortClientUsersByApprovalValue'); $approvers_array = self::$approversArray; } return $approvers_array; }
function getClientname($vid) { return Clients::model()->findByPk($vid)->FirstName; }
?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model, 'client_id'); ?> <?php $val = ""; if (isset($model->client_id)) { $c = Clients::model()->findByPk($model->client_id); $val = $c->FirstName . " " . $c->LastName; } $this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => 'client_id', 'value' => $val, 'source' => Yii::app()->request->baseUrl . '/site/getNames', 'options' => array('minLength' => '1', 'select' => 'js:function(event, ui) { $("#setclientval").val(ui.item.id); console.log(ui.item.id +":"+ui.item.value); }'), 'htmlOptions' => array('id' => 'person', 'rel' => 'val', 'class' => 'form-control'))); ?> <input type="hidden" name="Session[client_id]" id="setclientval" value="<?php echo $model->client_id; ?> "> <?php echo $form->error($model, 'client_id'); ?> </div>
<?php $this->breadcrumbs = array('Invoices Fkts' => array('index'), 'Manage'); $this->menu = array(array('label' => 'Создать', 'url' => array('create')), array('label' => 'Шаблоны', 'url' => array('invoicesFktTmpl/admin'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('invoices-fkt-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>Управление счетами-фактурами</h1> <?php $this->widget('application.extensions.yii-flash.Flash', array('keys' => array('success', 'error', 'notice'), 'htmlOptions' => array('class' => 'flash'))); ?> <!-- flashes --> <p> Можно использовать (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b> или <b>=</b>). </p> <?php echo CHtml::link('Продвинутый поиск', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'invoices-fkt-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'num', array('name' => 'order_id', 'value' => '$data->order->name', 'filter' => Orders::model()->listData()), array('name' => 'client_id', 'value' => '$data->client->name', 'filter' => CHtml::listData(Clients::model()->findAll(), 'id', 'name')), 'date', 'sum', array('name' => 'is_sign', 'value' => 'InvoicesFkt::model()->itemAlias("is_sign",$data->is_sign)'), array('class' => 'MyButtonColumn'))));
<?php $this->breadcrumbs = array('Payments' => array('index'), 'Manage'); $this->menu = array(array('label' => 'Создать платёж', 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('payments-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>Управление платежами</h1> <?php $this->widget('application.extensions.yii-flash.Flash', array('keys' => array('success', 'error', 'notice'), 'htmlOptions' => array('class' => 'flash'))); ?> <!-- flashes --> <p> Можно использовать (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b> или <b>=</b>). </p> <?php echo CHtml::link('Advanced Search', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'payments-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'date', 'sum', array('name' => 'client_id', 'value' => '$data->client->name', 'filter' => CHtml::listData(Clients::model()->findAll(array('order' => 'name')), 'id', 'name')), array('name' => 'order_id', 'value' => '$data->order->name', 'filter' => CHtml::listData(Orders::model()->findAll(array('order' => 'name')), 'id', 'name')), 'invoice_id', 'note', array('class' => 'MyButtonColumn'))));
/** * получить данные о договоре для редактора */ public function actionChangeBody() { if (Yii::app()->request->isAjaxRequest) { //printvar($_POST); $return_msg = ''; $order_id = intval($_POST['order_id']); if (!is_array($order_pos = Works::model()->worksByOrder($order_id))) { $return_msg .= 'Невозможно получить список работ'; } $data['works'] = "<ul>\n"; foreach ($order_pos as $o_p) { $data['works'] .= '<li>' . $o_p->name . ', ' . $o_p->quantity . $o_p->unit . "</li>\n"; } $data['works'] .= "</ul>\n"; // echo ($data['works']);die; $data['contract']['date'] = $_POST['date']; $data['contract']['duedate'] = $_POST['duedate']; $data['contract']['name'] = $_POST['name']; $data['contract']['num'] = $_POST['num']; $data['contract']['sum'] = $_POST['sum']; // echo json_encode(CVarDumper::dump($data));die;//Yii::app()->end; if (!is_array($data['client'] = Clients::model()->clientByOrder($order_id))) { $return_msg .= 'Невозможно получить данные клиента'; } // echo CVarDumper::dump($data['client']);die; if (!is_array($data['settings'] = Config::model()->get_settings())) { $return_msg .= 'Невозможно получить основные параметры'; } // echo CVarDumper::dump($data['settings']['org.fullname']['value'],10,true);die; $body = $this->_tmpl_body($data, Contracts::model()->get_contract_tmpl($_POST['template_id'])); // echo $body;die; if ($body == '') { $return_msg .= 'Невозможно сформировать шаблон'; } if ($return_msg == '') { echo $body; } else { echo $return_msg; } } else { echo 'Некорректный формат запроса'; } }
echo $form->labelEx($model, 'client_id'); ?> <?php $val = ""; if (isset($model->client_id)) { $c = Clients::model()->findByPk($model->client_id); $val = $c->FirstName . " " . $c->LastName; } ?> <select class="form-control mysetect" name="Session[client_id]" > <option value=''>Select Clients</option> <?php $Criteria = new CDbCriteria(); $theClients = Clients::model()->findAll($Criteria); foreach ($theClients as $client) { $selected = ''; if ($client->id == $model->client_id) { $selected = 'selected'; } echo "<option value='{$client->id}' {$selected}> {$client->FirstName}</option>"; } ?> </select> <?php echo $form->error($model, 'client_id'); ?> </div>
public static function notifyNextUsers($nextUsers,$userToClient){ if ($nextUsers) { $project = Projects::model()->findByPk(Yii::app()->user->projectID); foreach ($nextUsers as $nextUser) { $nextUserId = $nextUser->User_ID; $nextUserApprovalValue = $nextUser->User_Approval_Value; $user = Users::model()->with('settings','person')->findByPk($nextUserId); // send notification // get aps to approve to next users $condition = new CDbCriteria(); $condition->join = "LEFT JOIN documents ON documents.Document_ID=t.Document_ID"; $condition->condition = "documents.Client_ID='" . Yii::app()->user->clientID . "'"; $condition->addCondition("documents.Project_ID = '" . Yii::app()->user->projectID . "'"); $condition->addCondition("t.AP_Approval_Value < '" . $nextUserApprovalValue . "'"); $condition->addCondition("t.AP_Approval_Value >= '" . $userToClient->User_Approval_Value . "'"); $condition->addCondition("t.AP_Approval_Value != '0'"); $aps = Aps::model()->find($condition); if ($aps) { $client = Clients::model()->findByPk(Yii::app()->user->clientID); $clientsToApprove = array($client->company->Company_Name.' - '.$project->Project_Name); Mail::sendPendingApprovalDocumentsNotification(!$user->settings->Notification,$user, $clientsToApprove, Documents::AP,$client,$project); } } } }
/** * Get user's clients list except current client * @return array */ public static function getOtherUserClients() { $userClients = array(); $condition = new CDbCriteria(); $condition->join = "LEFT JOIN users_client_list ON users_client_list.Client_ID = t.Client_ID"; $condition->condition = "users_client_list.User_ID = '" . Yii::app()->user->userID . "'"; $condition->addCondition("t.Client_ID != '" . Yii::app()->user->clientID . "'"); $condition->addCondition("t.Client_Status = '" . self::ACTIVE . "'"); $clients = Clients::model()->with('company')->findAll($condition); foreach ($clients as $client) { $userClients[$client->Client_ID] = CHtml::encode($client->company->Company_Name); } return $userClients; }