function pRequestR2($id) { $this->myheader4($id); $criteria = new CDbCriteria(); $criteria->compare('parent_id', $id); $criteria->compare('tcredit>', 0); $criteria->order = 'periode_date, id'; $models = aBudgetDetail::model()->findAll($criteria); $_counter = 1; $_countert = 1; $_totalc = 0; $_totals = 0; $w = array(8, 25, 50, 30, 30, 30, 40, 50); //Saldo Awal $criteria1 = new CDbCriteria(); $criteria1->compare('parent_id', $id); $criteria1->compare('tdebt>', 0); $criteria1->order = 'periode_date, id'; $modelt = aBudgetDetail::model()->find($criteria1); $this->SetFont('Arial', '', 8); $this->Cell($w[0], 6, $_counter, 'LB', 0, 'R'); $this->Cell($w[1], 6, $modelt->input_date, 'LB'); $this->Cell($w[2], 6, $modelt->no_ref, 'LB'); $this->Cell($w[3], 6, $modelt->periode_date, 'LB'); $this->Cell($w[4], 6, '', 'LB', 0, 'R'); $this->SetFont('Arial', 'B', 8); $this->Cell($w[5], 6, number_format($modelt->tdebt, 0, ',', '.'), 'LB', 0, 'R'); $this->Cell($w[6], 6, '', 'LB'); $this->SetFont('Arial', '', 8); $this->Cell($w[7], 6, $modelt->remark, 'LBR'); $this->Ln(); //End of Saldo Awal $_counter++; foreach ($models as $mod) { $this->SetFont('Arial', '', 8); $this->Cell($w[0], 6, $_counter, 'LB', 0, 'R'); $this->Cell($w[1], 6, $mod->input_date, 'LB'); $this->Cell($w[2], 6, $mod->no_ref, 'LB'); $this->Cell($w[3], 6, sParameter::BulanTahun1($mod->periode_date), 'LB'); $this->Cell($w[4], 6, number_format($mod->tcredit, 0, ',', '.'), 'LB', 0, 'R'); $this->Cell($w[4], 6, number_format($mod->balance, 0, ',', '.'), 'LB', 0, 'R'); $this->Cell($w[6], 6, aPorder::model()->issuerBy((int) $mod->prequest_id), 'LB'); $this->Cell($w[7], 6, $mod->remark, 'LBR'); $this->Ln(); $_totalc = $_totalc + $mod->tcredit; $_counter++; $_countert++; //if ($_counter==34) { // $this->AddPage(); // $this->myheader4($id); // $_counter = 1; //} } //Closure line $this->Cell(array_sum($w), 0, '', 'T'); $this->Ln(2); $w = array(8, 25, 50, 30, 30, 30, 40, 50); $this->SetFont('Arial', 'B', 8); $this->Cell($w[0], 6, '', 1); $this->Cell($w[1], 6, '', 1, 0, 'C'); $this->Cell($w[2], 6, '', 1, 0, 'C'); $this->Cell($w[3], 6, '', 1, 0, 'C'); $this->Cell($w[4], 6, number_format($_totalc, 0, ',', '.'), 1, 0, 'R'); $this->Cell($w[5], 6, number_format($mod->balance, 0, ',', '.'), 1, 0, 'R'); $this->Cell($w[6], 6, '', 1, 0, 'C'); $this->Cell($w[7], 6, '', 1, 0, 'C'); $this->Ln(); /* $this->SetFont('Arial','',8); $this->Cell(30,6,'Keterangan'); $this->Ln(); $this->Cell(0,6,aBudgetDetail::model()->findByPk($mod->parent_id)->remark); $this->Ln(10); $this->SetFont('Arial','',10); $this->Cell($w[0],6,'','LT'); $this->Cell($w[1],6,'Requested By','TR',0,'C'); $this->Cell($w[2],6,'','T',0,'C'); $this->Cell($w[3],6,'','T',0,'C'); $this->Cell($w[4],6,'','T',0,'C'); $this->Cell($w[5],6,'','T',0,'C'); $this->Cell($w[6],6,'','T',0,'C'); $this->Cell($w[7],6,'Acknowledge By:','T',0,'C'); $this->Cell($w[8],6,'','T',0,'C'); $this->Cell($w[9],6,'','T',0,'C'); $this->Cell($w[10],6,'','T',0,'C'); $this->Cell($w[11],6,'','T',0,'C'); $this->Cell($w[12],6,'','T',0,'C'); $this->Cell($w[13],6,'','TR',0,'C'); $this->Ln(); $this->Cell($w[0],18,'','L'); $this->Cell($w[1],18,'','R'); $this->Cell($w[2],18); $this->Cell($w[3],18); $this->Cell($w[4],18); $this->Cell($w[5],18); $this->Cell($w[6],18); $this->Cell($w[7],18); $this->Cell($w[8],18); $this->Cell($w[9],18); $this->Cell($w[10],18); $this->Cell($w[11],18); $this->Cell($w[12],18); $this->Cell($w[13],18,'','R'); $this->Ln(); $this->Cell($w[0],6,'','L'); $this->Cell($w[1],6,'Silvia Theresia','R',0,'C'); $this->Cell($w[2],6,'',0,0,'C'); $this->Cell($w[3],6,'',0,0,'C'); $this->Cell($w[4]+$w[5],6,'Hadi Sutanto',0,0,'C'); $this->Cell($w[6],6,'',0,0,'C'); $this->Cell($w[7],6,'',0,0,'C'); $this->Cell($w[8],6,'',0,0,'C'); $this->Cell($w[9]+$w[10]+$w[11],6,'Indra W. Antono',0,0,'C'); $this->Cell($w[12],6,'',0,0,'C'); $this->Cell($w[13],6,'','R','C'); $this->Ln(3); $this->SetFont('Arial','',8); $this->Cell($w[0],6,'','LB'); $this->Cell($w[1],6,'Office Support Manager','BR',0,'C'); $this->Cell($w[2],6,'','B',0,'C'); $this->Cell($w[3],6,'','B',0,'C'); $this->Cell($w[4]+$w[5],6,'Fin & Acc Deputy Director','B',0,'C'); $this->Cell($w[6],6,'','B',0,'C'); $this->Cell($w[7],6,'','B',0,'C'); $this->Cell($w[8],6,'','B',0,'C'); $this->Cell($w[9]+$w[10]+$w[11],6,'Marketing Director','B',0,'C'); $this->Cell($w[12],6,'','B',0,'C'); $this->Cell($w[13],6,'','BR','C'); $this->Ln(); $this->SetFont('Arial','BI',8); $this->Cell(0,6,aBudgetDetail::model()->findByPk($mod->parent_id)->no_ref . " ",0,0,'R'); $this->Ln(); */ }
public function actionUpdateApproved($id) { $model = $this->loadModel($id); if ($model->approved_date == null) { #---------------------------------------- #Budget Detail $modelbd = aBudgetDetail::model()->find(array('condition' => 'parent_id = :parent', 'params' => array(':parent' => $model->budgetcomp_id))); if ($modelbd == null) { //Step 1. null berarti saldo baru berjalan, jadi cek saldo awal $modelbd1 = new aBudgetDetail(); $modelbd1->parent_id = $model->budgetcomp_id; $modelbd1->input_date = new CDbExpression("now()"); $modelbd1->periode_date = 0; $modelbd1->no_ref = 'temp'; $modelbd1->prequest_id = 0; $modelbd1->tdebt = $model->budgetcomp->amount; $modelbd1->balance = $model->budgetcomp->amount; $modelbd1->created_by = 'admin'; $modelbd1->created_date = time(); $modelbd1->save(); } //Step 2. Get Saldo $bd_balance = aBudgetDetail::model()->getSaldo($model->budgetcomp_id); $command = Yii::app()->db->createCommand('INSERT INTO a_budget_detail (parent_id, input_date, periode_date, no_ref, prequest_id, tdebt, tcredit, balance, remark, created_date, created_by) SELECT a.budgetcomp_id, a.input_date, a.periode_date, a.no_ref, a.id, 0, Sum(b.qty*b.amount), :balance - Sum(b.qty*b.amount), \'Automatic Posting\', ' . time() . ',\'' . Yii::app()->user->name . '\' FROM a_porder a INNER JOIN a_porder_detail b ON a.id = b.parent_id WHERE a.id = :id GROUP BY a.budgetcomp_id, a.input_date, a.no_ref, a.id'); $command->bindParam(":id", $id, PDO::PARAM_STR); $command->bindParam(":balance", $bd_balance, PDO::PARAM_STR); $command->execute(); #------------------------------------ #Budget Department /* foreach ($model->po_detail_group as $mod) { $criteria=new CDbCriteria; $criteria->compare('parent_id',$mod->budget_id); $criteria->compare('department_id',$mod->department_id); $cekDeptBudget=aBudget::model()->find($criteria); //Cek Budget Besar Apakah ada budget dept dari component ini if ($cekDeptBudget != null) { //Jika tidak ada ignore $modelbd=aBudgetDepartment::model()->find($criteria); if($modelbd==null) { //Step 1. Cek Existing Data. Jika belom pernah diisi, maka diisi $modelbd1=new aBudgetDepartment; $modelbd1->parent_id=$mod->budget_id; $modelbd1->input_date = new CDbExpression("now()"); $modelbd1->periode_date=0; $modelbd1->no_ref='temp'; $modelbd1->department_id =$mod->department_id; $modelbd1->tdebt=$cekDeptBudget->amount; //karena budget-nya ada, amountnya diambil $modelbd1->tcredit=0; $modelbd1->balance=$cekDeptBudget->amount; //karena budget-nya ada, amountnya diambil $modelbd1->created_by='admin'; $modelbd1->created_date=time(); $modelbd1->save(); } //Step 2. Get Saldo, baik diproses dari saldo diatas maupun existing Saldo $bd_balanceDept = aBudgetDepartment::model()->getSaldo($mod->budget_id,$mod->department_id); } else { //Step 2. Get Saldo, baik diproses dari saldo diatas maupun existing Saldo $bd_balanceDept = $mod->sub_total; } $command=Yii::app()->db->createCommand(); $command->insert('a_budget_department',array( 'parent_id'=>$mod->budget_id, 'input_date'=>$model->input_date, 'periode_date'=>$model->periode_date, 'no_ref'=>$model->no_ref, 'department_id'=>$mod->department_id, 'tdebt'=>0, 'tcredit'=>$mod->sub_total, 'balance'=>$bd_balanceDept-$mod->sub_total, 'remark'=>"Automatic Posting", 'created_date'=>time(), 'created_by'=>Yii::app()->user->id, )); } */ $_date = Yii::app()->dateFormatter->format("yyyy-MM-dd", time()); aPorder::model()->updateByPk((int) $model->id, array('approved_date' => $_date)); } }
public function getTotalComponentR($id = null) { $criteria = new CDbCriteria(); $criteria->compare('parent_id', $id); $models = aBudgetDetail::model()->findAll($criteria); $_total = 0; foreach ($models as $model) { $_total = $_total + $model->tcredit; } $_total = Yii::app()->numberFormatter->format("#,##0.00", $_total); return $_total; }