Beispiel #1
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 == Acts::model()->findByAttributes(array('template_id' => (int) $id))) {
             if ($model->delete()) {
                 $msg = 'Шаблон акта #' . $model->id . ' - ' . $model->name . ' удалён';
                 Yii::app()->user->setFlash('success', $msg);
                 Yii::app()->logger->write($msg);
             }
         } else {
             Yii::app()->user->setFlash('notice', 'Удаление невозможно. Шаблон акта #' . $model->id . ' - ' . $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.');
     }
 }
Beispiel #2
0
<?php

$this->breadcrumbs = array('Акты' => array('index'), $model->id => array('view', 'id' => $model->id), 'Изменить');
$this->menu = array(array('label' => 'Просмотреть акт', 'url' => array('view', 'id' => $model->id)), array('label' => 'Управление актами', 'url' => array('admin')));
?>

<h1>Изменить акт для Заказа #<?php 
echo $model->order_id;
?>
 &mdash; <?php 
echo $model->order->name;
?>
</h1>

<?php 
$works = $this->renderPartial('grid-works', array('model' => $model, 'mdlWorks' => Acts::model()->mdlWorks($model->order_id, $model->id)), true);
//$works .= "\n";
//$works .= $this->renderPartial('grid-works_act', array('model' => $model, 'mdlWorksAct' => Acts::model()->mdlWorks($model->order_id,$model->id)), true);
echo $this->renderPartial('_form', array('model' => $model, 'works' => $works));
Beispiel #3
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.');
     }
 }
Beispiel #4
0
<?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>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</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'))));
Beispiel #5
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 $id the ID of the model to be loaded
  * @return Acts the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Acts::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Beispiel #6
0
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'challan-form', 'enableAjaxValidation' => false));
?>

    <p class="help-block">Fields with <span class="required">*</span> are required.</p>

    <?php 
echo $form->errorSummary($model);
?>
   
            <div class="row" style="margin-bottom:10px;margin-top:10px;clear:both;">
            <div style="float:left;width:200px;" >
                <?php 
echo $form->labelEx($model, 'acts_id');
?>
                <?php 
echo $form->dropDownList($model, 'acts_id', CHtml::listData(Acts::model()->findAll(array('order' => 'id ASC')), 'id', 'name'), array('span' => 5));
?>
 
            </div> 
            <div style="float: left;" class="rad">

                <?php 
echo $form->radioButtonListControlGroup($model, 'challan_type', array('1' => 'Challan at Site', '2' => 'Challan through Sticker', '3' => 'Challan through TVI Slip'));
?>
                <div style="clear:both" ></div>
            </div> 
            <div style="clear:both;"></div>
           <h4 style="background-color: #49afcd;
    background-image: linear-gradient(to bottom, #5bc0de, #2f96b4);color:#E7FDD6 !important;padding: 6px;background-image: linear-gradient(to bottom, #3AE8EB, #0e8eff) repeat-x scroll 0 0 #335a84; background-repeat: repeat-x;

    border-radius: 4px;
 public function actionChangeAct()
 {
     $return_msg = '';
     //		Dumper::d($_POST['order_id']);die;
     if (Yii::app()->request->isAjaxRequest) {
         if (is_numeric($_POST['act_id'])) {
             $q = Acts::model()->findByPk((int) $_POST['act_id'], array('select' => 'sum'));
             if (null !== $q) {
                 $return_msg = $q->sum;
             } else {
                 $return_msg = 'null';
             }
         } else {
             $return_msg = 'Некорректный формат запроса';
         }
     } else {
         $return_msg = 'Некорректный формат запроса';
     }
     echo $return_msg;
 }
Beispiel #8
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;
     }
 }
Beispiel #9
0
		<?php 
    echo $form->dropDownList($model, 'act_id', array(), array('empty' => 'Выберите заказ'));
    ?>
		<span class="note" style="display: block" id="ajax_mess_act"></span>
	</div>

	<?php 
} else {
    ?>

	<div class="row">
		<?php 
    echo $form->labelEx($model, 'act_id');
    ?>
		<?php 
    echo $form->dropDownList($model, 'act_id', Acts::model()->listData($model->order_id));
    ?>
	</div>

	<?php 
}
?>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'template_id');
?>
		<?php 
echo $form->dropDownList($model, 'template_id', CHtml::listData(InvoicesTmpl::model()->findAll(), 'id', 'name'));
?>
	</div>
Beispiel #10
0
?>
		<?php 
echo $form->dropDownList($model, 'order_id', $orders, array('encode' => false, 'empty' => ''));
?>
		<span class="note" style="display: block" id="ajax_order_mess"></span>
	</div>
	
	<?php 
if (!$model->isNewRecord) {
    ?>
		<div class="row">
			<?php 
    echo $form->labelEx($model, 'act_id');
    ?>
			<?php 
    echo $form->dropDownList($model, 'act_id', Acts::model()->listData($model->order_id), array('encode' => false, 'empty' => ''));
    ?>
		</div>
	<?php 
}
?>
	<div class="row">
		<?php 
echo $form->labelEx($model, 'name');
?>
		<?php 
echo $form->textField($model, 'name', array('size' => 60, 'maxlength' => 255));
?>
	</div>

	<div class="row">
Beispiel #11
0
 public function actionChangeOrder()
 {
     $return_msg = '';
     //		Dumper::d($_POST['order_id']);die;
     if (Yii::app()->request->isAjaxRequest) {
         if (is_numeric($_POST['order_id'])) {
             $q = Acts::model()->listData((int) $_POST['order_id']);
             if (count($q) > 0) {
                 foreach ($q as $key => $value) {
                     $haOptions[] = array('value' => $key, 'text' => $value);
                 }
                 $return_msg = json_encode($haOptions);
             } else {
                 $return_msg = json_encode('no');
             }
         } else {
             $return_msg = '[{"value":"","text":"Некорректный формат запроса"}]';
         }
     } else {
         $return_msg = '[{"value":"",text:"Некорректный формат запроса"}]';
     }
     echo $return_msg;
 }