public function __construct(\Iterator $iterator, $mapper)
 {
     Contracts::ensureCallable($mapper);
     $this->iterator = $iterator;
     $this->mapper = $mapper;
     $this->prepareCurrent();
 }
 public function __construct(\Iterator $iterator, $filter)
 {
     Contracts::ensureCallable($filter);
     $this->iterator = $iterator;
     $this->filter = $filter;
     $this->findCurrent();
 }
 public function __construct(\Iterator $iterator, $mapper)
 {
     Contracts::ensureCallable($mapper);
     $this->flattingIterator = $iterator;
     $this->mapper = $mapper;
     parent::__construct($this->prepareCurrentIterator()->orElse(new \ArrayIterator(array())), function ($element) {
         return $element;
     });
 }
Esempio n. 4
0
 /**
  * @param callback $mapper
  *
  * @return MapBuilder
  */
 public function mapElements($mapper)
 {
     Contracts::ensureCallable($mapper);
     if ($this->map instanceof \SplObjectStorage) {
         foreach ($this->map as $key) {
             $this->map[$key] = call_user_func($mapper, $this->map[$key]);
         }
     } else {
         foreach ($this->map as $key => $element) {
             $this->map[$key] = call_user_func($mapper, $element);
         }
     }
     return $this;
 }
Esempio n. 5
0
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $model = $this->loadModel($id);
         if (null == Contracts::model()->findByAttributes(array('template_id' => (int) $id))) {
             if ($model->delete()) {
                 $msg = 'Шаблон договора ' . $model->name . ' удалён';
                 Yii::app()->user->setFlash('success', $msg);
                 Yii::app()->logger->write($msg);
                 //				$this->redirect(array('admin', 'id' => $model->id));
             }
         } else {
             Yii::app()->user->setFlash('notice', 'Удаление невозможно. Шаблон договора ' . $model->name . ' используется!');
         }
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_GET['ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
Esempio n. 6
0
 /**
  *
  * @param <type> $contract_id
  */
 public function actionHtml()
 {
     if (!isset($_GET['contract_id']) or !is_numeric($_GET['contract_id'])) {
         $msg = 'Неверный ID договора';
         Yii::app()->user->setFlash('error', $msg);
         Yii::app()->logger->write($msg);
     } else {
         $model = Contracts::model()->findByPk($_GET['contract_id']);
         $this->layout = false;
         //contract/template_pdf';
         $this->render('html', array('model' => $model));
     }
 }
Esempio n. 7
0
<?php

require_once "../../../inclusionfirst_api/connect_inclusion_first.php";
require_once "../../../inclusionfirst_api/Contracts.php";
require_once "../../../inclusionfirst_api/Events.php";
#get monthly budget amount
#for each month, get schedule amounts
#ignore timesheets for now
$contract_id = $_POST['contract_id'];
$contracts = new Contracts();
$search = array('id' => $contract_id);
$parameter = Contracts::getAsParameter($search, Contracts::getFields());
$parameter = json_encode($parameter);
$contract = $contracts->find($parameter, $inclusionFirst);
$client_id = $contract[0]['client_id'];
$service_id = $contract[0]['service_id'];
$monthly_budget = $contract[0]['hoursMonthly'];
$start = (new DateTime($contract[0]['dateStart']))->modify('first day of this month');
$end = (new DateTime($contract[0]['dateEnd']))->modify('first day of this month');
$interval = DateInterval::createFromDateString('1 month');
$periods = new DatePeriod($start, $interval, $end);
foreach ($periods as $dt) {
    $labels[] = $dt->format("M Y");
}
$data['labels'] = $labels;
foreach ($labels as $period) {
    $data_budget[] = $monthly_budget;
}
$dataset_budget['fillColor'] = "rgba(220,220,220,0.5)";
$dataset_budget['strokeColor'] = "rgba(220,220,220,0.8)";
$dataset_budget['highlightFill'] = "rgba(220,220,220,0.75)";
Esempio n. 8
0
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $model = $this->loadModel($id);
         if (Payments::model()->count('order_id=' . $id) !== 0) {
             $transaction = Yii::app()->db->beginTransaction();
             try {
                 Contracts::model()->deleteAll('order_id=' . $id);
                 Acts::model()->deleteAll('order_id=' . $id);
                 Invoices::model()->deleteAll('order_id=' . $id);
                 InvoicesFkt::model()->deleteAll('order_id=' . $id);
                 Works::model()->deleteAll('order_id=' . $id);
                 $msg = 'Заказ #' . $model->id . ' - ' . $model->name . ' для ' . $model->client->name . ' и документы по нему удалёны';
                 $model->delete();
                 $transaction->commit();
                 Yii::app()->user->setFlash('success', $msg);
                 Yii::app()->logger->write($msg);
             } catch (Exception $e) {
                 $transaction->rollBack();
                 $msg = 'Заказ #' . $model->id . ' - ' . $model->name . ' для ' . $model->client->name . ' - удаление не удалось';
                 Yii::app()->user->setFlash('error', $msg);
                 Yii::app()->logger->write($msg);
             }
         } else {
             $msg = 'Заказ #' . $model->id . ' - ' . $model->name . ' для ' . $model->client->name . ' - удаление невозможно. По этому заказу уже были проведены платежи';
             Yii::app()->user->setFlash('notice', $msg);
             Yii::app()->logger->write($msg);
         }
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_GET['ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
Esempio n. 9
0
 /**
  * {@inheritDoc}
  */
 public function eachBy($processor)
 {
     Contracts::ensureCallable($processor);
     return $this;
 }
Esempio n. 10
0
	<div class="row">
		<?php 
echo $form->labelEx($model, 'sum');
?>
		<?php 
echo $form->textField($model, 'sum');
?>

	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'autoprolonged');
?>
		<?php 
echo $form->dropDownList($model, 'autoprolonged', Contracts::model()->itemAlias('autoprolonged'));
?>

	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'template_id');
?>
		<?php 
echo $form->dropDownList($model, 'template_id', CHtml::listData(ContractsTmpl::model()->findAll(), 'id', 'name'));
?>

	</div>

	<div class="row">
Esempio n. 11
0
 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;
     }
 }
Esempio n. 12
0
 /**
  * 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 = Contracts::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 13
0
 /**
  * {@inheritDoc}
  */
 public function eachBy($processor)
 {
     Contracts::ensureCallable($processor);
     call_user_func($processor, $this->data);
     return $this;
 }
Esempio n. 14
0
 public function __construct($comparator)
 {
     Contracts::ensureCallable($comparator);
     $this->comparator = $comparator;
 }