Ejemplo n.º 1
0
 public function save($runValidation = true, $attributes = NULL)
 {
     $this->owner = Yii::app()->user->id;
     if ($this->total == 0) {
         $this->total = $this->rcptsum;
     }
     $a = parent::save($runValidation, $attributes);
     if (!$a) {
         return $a;
     }
     if (!is_null($attributes)) {
         return $a;
     }
     //if ($a) { //if switch no save
     $this->saveRef();
     //load docs and re-save them
     if (!$this->action) {
         if ($this->status === null) {
             throw new CHttpException(500, Yii::t('app', 'No status recived'));
         }
         $this->docStatus = Docstatus::model()->findByPk(array('num' => $this->status, 'doc_type' => $this->doctype));
         if ($this->docStatus === null) {
             throw new CHttpException(500, Yii::t('app', 'Status is Invalid'));
         }
         $this->saveDet();
         $this->saveCheq();
         $this->calc();
         $this->validate();
         if (count($this->getErrors()) != 0) {
             return false;
         }
         if (isset($this->docStatus)) {
             if ($this->docStatus->action != 0) {
                 $this->docnum = $this->newNum();
                 //get num
                 $this->action = 1;
                 $a = parent::save($runValidation, $attributes);
                 $this->transaction((int) $this->docStatus->action);
                 if (is_null($this->docType->transactionType_id)) {
                     //only if !transaction stock
                     foreach ($this->docDetailes as $docdetail) {
                         $this->stock($docdetail->item_id, $docdetail->qty);
                     }
                 }
             }
         }
     }
     //} //else {
     // throw new CHttpException(500, Yii::t('app', 'Uneable to save document'));
     //}
     return $a;
 }
Ejemplo n.º 2
0
	
		<?php 
//echo $form->checkboxRow($model,'iscontract');
?>
	

		<?php 
echo $form->checkboxRow($model, 'stockAction');
?>
	
		<?php 
echo $form->dropDownListRow($model, 'account_type', CHtml::listData(Acctype::model()->findAll(), 'id', 'name'));
?>
                <br />
		<?php 
echo $form->dropDownListRow($model, 'docStatus_id', CHtml::listData(Docstatus::model()->findAllByAttributes(array('doc_type' => $model->id)), 'num', 'name'));
?>
	<br />
		<?php 
echo $form->textFieldRow($model, 'last_docnum');
?>
	
        <?php 
echo $form->labelEx($model, 'header');
?>
        <?php 
$this->widget('ext.tinymce.TinyMce', array('model' => $model, 'attribute' => 'header'));
?>
        
        <?php 
echo $form->labelEx($model, 'footer');
Ejemplo n.º 3
0
<?php

/* * *********************************************************************************
 * The contents of this file are subject to the Mozilla Public License Version 2.0
 * ("License"); You may not use this file except in compliance with the Mozilla Public License Version 2.0
 * The Original Code is:  Linet 3.0 Open Source
 * The Initial Developer of the Original Code is Adam Ben Hur.
 * All portions are Copyright (C) Adam Ben Hur.
 * All Rights Reserved.
 * ********************************************************************************** */
// this is the date picker
$dateisOn = $this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => 'Docs[issue_from]', 'language' => substr(Yii::app()->language, 0, 2), 'value' => $model->issue_from, 'options' => array('showAnim' => 'fold', 'dateFormat' => Yii::app()->locale->getDateFormat('short'), 'changeMonth' => 'true', 'changeYear' => 'true', 'constrainInput' => 'false'), 'htmlOptions' => array('placeholder' => Yii::t('app', 'From Date'))), true) . $this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => 'Docs[issue_to]', 'language' => substr(Yii::app()->language, 0, 2), 'value' => $model->issue_to, 'options' => array('showAnim' => 'fold', 'dateFormat' => Yii::app()->locale->getDateFormat('short'), 'changeMonth' => 'true', 'changeYear' => 'true', 'constrainInput' => 'false'), 'htmlOptions' => array('placeholder' => Yii::t('app', 'To Date'))), true);
?>



<?php 
$filter = '';
if ($model->doctype != null) {
    $filter = CHtml::listData(Docstatus::model()->findAllByAttributes(array('doc_type' => $model->doctype)), 'num', 'name');
} else {
    $model->status = null;
}
//print_r(Yii::app()->locale);
$this->widget('EExcelView', array('id' => 'Docs', 'dataProvider' => $model->search(), 'filter' => $model, 'ajaxUpdate' => true, 'ajaxType' => 'POST', 'afterAjaxUpdate' => "function() {\n\t\t\t\t\t\tjQuery('#Docs_issue_from').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['" . substr(Yii::app()->language, 0, 2) . "'], {'showAnim':'fold','dateFormat':'" . Yii::app()->locale->getDateFormat('short') . "','changeMonth':'true','showButtonPanel':'true','changeYear':'true','constrainInput':'false'}));\n\t\t\t\t\t\tjQuery('#Docs_issue_to').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['" . substr(Yii::app()->language, 0, 2) . "'], {'showAnim':'fold','dateFormat':'" . Yii::app()->locale->getDateFormat('short') . "','changeMonth':'true','showButtonPanel':'true','changeYear':'true','constrainInput':'false'}));\n                                }", 'columns' => array(array('name' => 'doctype', 'filter' => Doctype::model()->getList(), 'value' => '$data->getTypeName()', 'htmlOptions' => array('style' => 'width:20%;')), array('name' => 'status', 'filter' => $filter, 'value' => '$data->getStatus()'), array('name' => 'refstatus', 'filter' => CHtml::listData(Docs::model()->getRefStatuses(), 'id', 'name'), 'value' => '$data->getRefStatus()'), array('name' => 'docnum', 'htmlOptions' => array('style' => 'width:8%;')), array('name' => 'account_id', 'htmlOptions' => array('style' => 'width:8%;')), 'company', array('name' => 'issue_date', 'filter' => $dateisOn, 'value' => '$data->issue_date', 'htmlOptions' => array('style' => 'width:15%;')), array('name' => 'total', 'htmlOptions' => array('style' => 'width:8%;')), array('class' => 'bootstrap.widgets.TbButtonColumn', 'htmlOptions' => array('style' => 'width:80px'), 'template' => '{duplicate}{print}{edit}{delete}{display}', 'buttons' => array('duplicate' => array('label' => '<i class="glyphicon glyphicon-plus-sign"></i>', 'url' => 'Yii::app()->createUrl("docs/duplicate/". $data->id)'), 'edit' => array('label' => '<i class="glyphicon glyphicon-edit"></i>', 'url' => 'Yii::app()->createUrl("docs/update", array("id"=>$data->id))'), 'delete' => array('label' => '<i class="glyphicon glyphicon-remove"></i>', 'deleteConfirmation' => true, 'imageUrl' => false, 'url' => 'Yii::app()->createUrl("docs/delete", array("id"=>$data->id))'), 'print' => array('label' => '<i class="glyphicon glyphicon-print"></i>', 'url' => 'Yii::app()->createUrl("docs/print", array("id"=>$data->id))', 'options' => array("target" => "_blank")), 'display' => array('label' => '<i class="glyphicon glyphicon-search"></i>', 'url' => 'Yii::app()->createUrl("docs/view", array("id"=>$data->id))'))))));