public function TransferringCredit($indvCredited) { $creditRemainingOfThisModel = $indvCredited->amount - $indvCredited->credit_assigned; foreach (PurchasesInvoices::model()->findAll(array('condition' => 'supplier_id=:supplier', 'params' => array(':supplier' => $indvCredited->supplier_id))) as $indvPurchasesInvoice) { if ($creditRemainingOfThisModel > 0) { //echo $creditRemainingOfThisModel; $amountToGetBalanced = $indvPurchasesInvoice->balance - $indvPurchasesInvoice->credited; //echo $amountToGetBalanced; if ($amountToGetBalanced > 0) { if ($creditRemainingOfThisModel > $amountToGetBalanced) { $amountCredited = $amountToGetBalanced; } else { $amountCredited = $creditRemainingOfThisModel; } $indvPurchasesInvoice->credited += $amountCredited; $indvCredited->credit_assigned += $amountCredited; $creditRemainingOfThisModel -= $amountCredited; $transaction = new AutomatedTransactionSuppliers(); $transaction->paid_date = $indvCredited->credited_date; $transaction->supplier_id = $indvCredited->supplier_id; $transaction->from_purchases_invoice_id = $indvCredited->credited_from; $transaction->to_purchases_invoice_id = $indvPurchasesInvoice->id; $transaction->amount = $amountCredited; $indvPurchasesInvoice->save(); $indvCredited->save(); $transaction->save(); } } else { } } }
<table class="table table-bordered"> <tr> <th>Edit</th> <th>View</th> <th>Date</th> <th>Transacation</th> <th>#</th> <th>Description</th> <th>Contact</th> <th>Amount</th> <th>Balance</th> </tr> <?php $balance = 0; $PurchasesInvoices = PurchasesInvoices::model()->findAll(array('order' => 'issue_date', 'condition' => 'supplier_id=:supplier', 'params' => array(':supplier' => $id))); foreach ($PurchasesInvoices as $PurchasesInvoice) { ?> <tr> <td><?php echo CHtml::link('<button class="btn btn-default btn-sm"><span class="btn-label-style">Edit</span></button>', $this->createAbsoluteUrl('PurchasesInvoices/update', array('id' => $PurchasesInvoice->id))); ?> </td> <td><?php echo CHtml::link('<button class="btn btn-default btn-sm"><span class="btn-label-style">View</span></button>', $this->createAbsoluteUrl('purchasesInvoices/view', array('id' => $PurchasesInvoice->id))); ?> </td> <td> <?php echo $PurchasesInvoice->issue_date; ?> </td>
<h2>Create MoneyReceived</h2> <div style="border: 1px inset gold;padding: 3%;"> <span><b>Supplier: </b><?php echo Suppliers::model()->findByPk(PurchasesInvoices::model()->findByPk($id)->supplier_id)->supplierName; ?> </span> <br> <br> <span><b>Purchase Invoice: </b><?php echo $id; ?> </span> <br> <br> <?php $this->renderPartial('_form', array('model' => $model, 'id' => $id)); ?> </div>
$supplierCredits = SuppliersCredit::model()->findAll(array('condition' => 'supplier_id=:supplier', 'params' => array(':supplier' => $model->id))); $credits = 0; foreach ($supplierCredits as $supplierCredit) { $credits += $supplierCredit->amount - $supplierCredit->credit_assigned; } if ($credits < 0) { echo '-'; } else { echo CHtml::link($credits, $this->createAbsoluteUrl('suppliers/viewTransactionCreditType', array('id' => $model->id))); } ?> </td> <td> <?php $Invoices = PurchasesInvoices::model()->findAll(array('condition' => 'supplier_id=:supplier', 'params' => array(':supplier' => $model->id))); $payables = 0; foreach ($Invoices as $invoice) { $payables += $invoice->balance - $invoice->credited; } if ($payables < 0) { echo '-'; } else { echo CHtml::link($payables, $this->createAbsoluteUrl('suppliers/viewTransaction', array('id' => $model->id))); } ?> </td> <td> <?php $contacts = $model->suppliersContacts; if (count($contacts) > 0) {
</th> <th><?php echo $total_credit_invoice; ?> </th> </tr> <tr><td colspan="10"></td></tr> <!-------------------------------------------inventory on hand end-------------------------> <!------------------------------------------accounts payable start-------------------------> <tr> <th colspan="10">Accounts Payables</th> </tr> <?php $total_credit_payables = 0; foreach (PurchasesInvoices::model()->findAll(array('order' => 'issue_date', 'condition' => 'issue_date>=:start_date AND issue_date<=:end_date', 'params' => array(':start_date' => $model->from_date, ':end_date' => $model->to_date))) as $purchasesInv) { ?> <tr> <td colspan="8"><?php echo $purchasesInv->issue_date . '- ' . $purchasesInv->supplier->supplierName . '-PurchasesInvoice #' . $purchasesInv->id; ?> </td> <td></td> <td><?php $total_credit_payables += $purchasesInv->total_amount; echo $purchasesInv->total_amount; ?> </td> </tr> <?php
/** * 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 SalesInvoices the loaded model * @throws CHttpException */ public function loadModel($id) { $model = PurchasesInvoices::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<table class="table table-bordered"> <tr> <th>Edit</th> <th>View</th> <th>Date</th> <th>Transacation</th> <th>#</th> <th>Description</th> <th>Contact</th> <th>Amount</th> <th>Balance</th> </tr> <tr> <?php $balance = 0; $PurchasesInvoice = PurchasesInvoices::model()->findByPk($id); ?> <td><?php echo CHtml::link('<button class="btn btn-default btn-sm"><span class="btn-label-style">Edit</span></button>', $this->createAbsoluteUrl('purchasesInvoices/update', array('id' => $id))); ?> </td> <td><?php echo CHtml::link('<button class="btn btn-default btn-sm"><span class="btn-label-style">View</span></button>', $this->createAbsoluteUrl('purchasesInvoices/view', array('id' => $id))); ?> </td> <td> <?php echo $PurchasesInvoice->issue_date; ?> </td> <td>