Example #1
0
 public function save()
 {
     //print_r($this->Deposit);
     $num = 0;
     $linenum = 1;
     $tranType = Settings::model()->findByPk('transactionType.chequedeposit')->value;
     if ($this->refnum == '' || $this->date == '' || !is_array($this->Deposit)) {
         return false;
     }
     $valuedate = date("Y-m-d H:m:s", CDateTimeParser::parse($this->date, Yii::app()->locale->getDateFormat('yiishort')));
     foreach ($this->Deposit as $line => $val) {
         list($a, $b) = explode(',', $line);
         $cheq = Doccheques::model()->findByPk(array("doc_id" => $a, "line" => $b));
         $oppt_acc = PaymentType::model()->findByPk($cheq->type)->oppt_account_id;
         //print_r($cheq);
         $accout = new Transactions();
         $accout->num = $num;
         $accout->account_id = $this->account_id;
         $accout->type = $tranType;
         $accout->refnum1 = $this->refnum;
         $accout->valuedate = $valuedate;
         //$accout->details=$this->company;
         $accout->currency_id = $cheq->currency_id;
         $accout->owner_id = Yii::app()->user->id;
         $accout->linenum = $linenum;
         $accout->sum = $cheq->sum * -1;
         $linenum++;
         $num = $accout->save();
         $oppt = new Transactions();
         $oppt->num = $num;
         $oppt->account_id = $oppt_acc;
         $oppt->type = $tranType;
         $oppt->refnum1 = $this->refnum;
         $oppt->valuedate = $valuedate;
         //$oppt->details=$this->company;
         $oppt->currency_id = $cheq->currency_id;
         $oppt->owner_id = Yii::app()->user->id;
         $oppt->linenum = $linenum;
         $oppt->sum = $cheq->sum * 1;
         $linenum++;
         $num = $oppt->save();
         $cheq->bank_refnum = $num;
         $cheq->save();
     }
     //Yii::app()->end();
     return $num;
 }
Example #2
0
 public function printDetailes()
 {
     $model = PaymentType::model()->findByPk($this->type);
     //echo CJSON::encode("echo ".$model->value);
     if ($model->value == '') {
         echo CJSON::encode(array($_POST['bill']['line'], false));
         Yii::app()->end();
     }
     $form = new $model->value();
     //$form->type=$id;
     //$form->sum=$_POST['bill']['sum'];
     //$form->line=$_POST['bill']['line'];
     $text = '';
     foreach ($form->printDetailes() as $field => $type) {
         $text .= $field . ':' . "value" . ", ";
     }
     return $text;
 }
Example #3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionAjax($id)
 {
     $model = new Doccheques();
     $type = PaymentType::model()->findByPk($id);
     if ($type !== null) {
         //$this->renderPartial('ajax', array(
         $this->render('ajax', array('model' => $model, 'type' => $type));
         Yii::app()->end();
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Doccheques'])) {
         $model->attributes = $_POST['Doccheques'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->renderPartial('create', array('model' => $model));
 }
Example #4
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 = PaymentType::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #5
0
 public function docCheqVal($attribute, $params)
 {
     $line = 0;
     $sum = 0;
     if (!is_null($this->docCheq)) {
         foreach ($this->docCheq as $key => $rcpt) {
             $line++;
             if (!is_array($rcpt)) {
                 return $this->addError($attribute, Yii::t('app', 'Not a valid doc Cheq array'));
             }
             $submodel = new Doccheques();
             //go throw attr if no save new
             foreach ($rcpt as $key1 => $value) {
                 if ($submodel->hasAttribute($key1)) {
                     $submodel->{$key1} = $value;
                 }
             }
             $submodel->doc_id = 0;
             if (PaymentType::model()->findByPk((int) $rcpt["type"]) !== null) {
                 if ($submodel->validate()) {
                     $sum += $submodel->sum;
                 } else {
                     $this->addError($attribute, Yii::t('app', 'Not a valid doc Cheq'));
                 }
             } else {
                 $this->addError($attribute, Yii::t('app', 'Not a valid paymenet type'));
             }
         }
     }
     if ($line) {
         //if (!Linet3Helper::numDiff($sum, (double) $this->rcptsum))
         if (abs($sum - $this->total) > 0.0001) {
             echo Yii::t('app', 'Total and recipt does not mach') . " " . $sum . " " . $this->total . " " . abs($sum - $this->total);
             exit;
             $this->addError($attribute, Yii::t('app', 'Total and recipt does not mach') . " " . $sum . " " . $this->total);
         }
     }
 }
Example #6
0
 public function penalty($occurence, $penalty, $app_id, $payment_type_id)
 {
     $payment_type = PaymentType::model()->findByPk($payment_type_id);
     $due_date = DueDate::model()->find('applicant_id=:aid AND payment_type_id=:pid', array(':aid' => $app_id, ':pid' => $payment_type_id));
     $date_now = DateTime::createFromFormat(Yii::app()->user->getDateFormat(false), date(Yii::app()->user->getDateFormat(false)));
     $due_date = DateTime::createFromFormat(Yii::app()->user->getDateFormat(false), $due_date->date);
     $date_diff = date_diff($date_now, $due_date);
     if ($occurence == 'permonth') {
         return $payment_type->amount * $penalty / 100 / 30 * $date_diff->d;
     } else {
         return $payment_type->amount * $penalty / 100 / 12 / 30 * $date_diff->d;
     }
     return false;
 }
Example #7
0
?>
		<?php 
$this->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => 'date_hour', 'options' => array('dateFormat' => 'yy-mm-dd', 'timeFormat' => 'hh:mm:ss', 'pickerTimeFormat' => 'hh:mm:ss', 'showSecond' => true)));
?>
		<?php 
echo $form->error($model, 'date_hour');
?>
		
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'payment_type_id');
?>
		<?php 
echo $form->dropDownList($model, 'payment_type_id', CHtml::listData(PaymentType::model()->findAll(array('condition' => 'active=1', 'order' => 'name')), 'id', 'name'), array('prompt' => 'Seleccionar', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('order/advancePaymentFromPaymentType'), 'data' => array('Order[payment_type_id]' => 'js:this.value'), 'success' => 'js:function(dataType){
						jsonObject = JSON.parse(dataType);
						
						$("#Order_advance_payment").children().remove();
						$("#Order_advance_payment").val(jsonObject.advance_payment);
					}', 'error' => 'js:function(dataType){
//						$("#Order_contact_id").children().remove();
//						$("#Order_contact_id").append( new Option("Seleccionar"));
//						$("#Order_payment_type_id > option[value=]").attr("selected","selected");
					}')));
?>
		<?php 
echo $form->error($model, 'payment_type_id');
?>
	</div>
	
Example #8
0
?>
        <?php 
echo $form->hiddenField($model, "[{$i}]line", array('class' => 'rcptline'));
?>
        <?php 
//echo $form->hiddenField($model, "[$i]dep_date");
?>
        <b><?php 
echo $form->labelEx($model, 'type');
?>
</b>
            
            
            <?php 
//Doctype::model()->getList()
$temp = PaymentType::model()->getList();
$temp[0] = Yii::t('app', 'None');
echo $form->dropDownList($model, "[{$i}]type", $temp);
?>
    </td>
    <td id="Doccheques_<?php 
echo $i;
?>
_text"></td>


    <td><b><?php 
echo $form->labelEx($model, 'currency_id');
?>
</b><?php 
echo $form->dropDownList($model, "[{$i}]currency_id", CHtml::listData(Currates::model()->GetRateList(), 'currency_id', 'name'), array('class' => 'currSelect'));
Example #9
0
 public static function getPaymentTypesByText()
 {
     $result = array();
     $criteria = new CDbCriteria();
     $criteria->select = 'id, payment_type';
     $criteria->distinct = true;
     $criteria->order = 'id';
     $paymenttypes = PaymentType::model()->findAll($criteria);
     foreach ($paymenttypes as $paymenttype) {
         $result = $result + array($paymenttype->payment_type => $paymenttype->payment_type);
     }
     return $result;
 }
Example #10
0
 public function printDetails()
 {
     $model = PaymentType::model()->findByPk($this->type);
     $form = new $model->value();
     $attrs = DocchequesEav::model()->findAllByAttributes(array("doc_id" => $this->doc_id, "line" => $this->line));
     //$text='';
     return $form->line($attrs);
 }
Example #11
0
 public function actionAdvancePaymentFromPaymentType()
 {
     if (isset($_POST['Order']['payment_type_id'])) {
         $advance_payment = PaymentType::model()->findByPK($_POST['Order']['payment_type_id']);
         $this->renderPartial('advancePaymentFromPaymentType', array('advance_payment' => $advance_payment));
     }
 }
Example #12
0
 public function getTipoPago()
 {
     return $ModelDependencias = PaymentType::model()->findAll('active = 1');
 }