public function createliquidacionAction() { try { $request = $this->getRequest(); if ($this->getRequest()->isPost()) { $liqDataId = 0; $liqId = (int) $request->id; //if there's an empty string it defaults to 0 $liqDate = $request->date; $variableDate = false; $lMapper = new Gyuser_Model_LiquidacionesDataMapper(); $liq = new Gyuser_Model_Liquidaciones(); $liq->setProvider_id($request->provider_id); $liq->setCommitted((int) $request->committed); $pMapper = new Gyuser_Model_ProvidersDataMapper(); $prov = $pMapper->GetProviderById($liq->getProvider_id()); $cMapper = new Gyuser_Model_ChequesDataMapper(); $oMapper = new Gyuser_Model_OperationsDataMapper(); //if liq has already been submitted then cleanup previous //selected cheques, rejected cheques and operations if ($liqId) { $chequesList = $cMapper->UpdateLiquidacionDeleted($liqId); $opertationsList = $oMapper->UpdateLiquidacionDeleted($liqId); } else { $liqId = $lMapper->createNewLiq(); } //check liq id has been created. if ($liqId) { $liq->setId($liqId); //depending on the status of the liquidacion //set the appropriate dates and/or liq data if ($liq->getCommitted() == 0) { //set current date and current prov values list($Day, $Month, $Year) = explode('/', $liqDate); $liqDate = mktime(12, 0, 0, $Month, $Day, $Year); $liqDate = date("Y-m-d", $liqDate); $today = date("Y-m-d"); if ($liqDate != $today) { $liq->setDate($liqDate); $variableDate = true; } else { $liq->setDate($today); } //even if this date won't be stored in db, we needed to calculate checks today value $provData = $prov; //set the current provider values as prov data } elseif ($liq->getCommitted() == 2) { //status is en camino. save date and prov values $liqData = $lMapper->GetLiquidacionesById($liq); //set date as today or as date selected by user if ($liqData['variable_date']) { $liq->setDate($liqData['date']); $variableDate = true; } else { $liq->setDate(date('Y-m-d')); } //set current prov values into liq for db save $liq->setTasa_anual($prov->getTasa_anual()); $liq->setImpuesto_al_cheque($prov->getImpuesto_al_cheque()); $liq->setAcreditacion_capital($prov->getAcreditacion_capital()); $liq->setAcreditacion_interior($prov->getAcreditacion_interior()); $liq->setGastos_general($prov->getGastos_general()); $liq->setGastos_interior($prov->getGastos_interior()); $liq->setGastos_cheque_a_1($prov->getGastos_cheque_a_1()); $liq->setGastos_cheque_menor_a_1($prov->getGastos_cheque_menor_a_1()); $liq->setGastos_cheque_a_2($prov->getGastos_cheque_a_2()); $liq->setGastos_cheque_menor_a_2($prov->getGastos_cheque_menor_a_2()); $liq->setDate_delivered(date("Y-m-d")); $provData = $prov; //set the current provider values as prov data } elseif ($liq->getCommitted() == 1) { //to be consolidated get the prov values stored in liq $liqData = $lMapper->GetLiquidacionesById($liq); //set date as date saved on step 2 $liq->setDate($liqData['date']); $provData = $lMapper->getProvData($liqId); //set the saved prov data on liq to calculate checks values } /* update Liquidacion id in cheques */ $checksJson = json_decode($request->cheques_json); $checkObj = new Gyuser_Model_Cheques(); $checkObj->setLiquidacion_id($liqId); $checkObj->setProvider_id($liq->getProvider_id()); foreach ($checksJson as $check) { $checkObj->setId($check->cheque_id); if ($check->acreditacion_hrs) { $checkObj->setAcreditacion_hrs($check->acreditacion_hrs); } $cMapper->UpdateLiquidacion($checkObj); } /* update Liquidacion id in rejected cheques */ $rejected_cheques_json = json_decode($request->rejected_cheques_json); $rejCheckTotal = 0; foreach ($rejected_cheques_json as $check) { $checkDetails = $cMapper->getCheckDetails($check->rejected_cheque_id); $gastos_type = $checkDetails->getRejected_type(); if ($gastos_type == "Denuncia") { $checkDetails->setRejected_cost_prov($prov->getGastos_denuncia()); } elseif ($gastos_type == "Sin Fondos") { $checkDetails->setRejected_cost_prov($prov->getGastos_rechazo()); } //set the current liq id as the liq id where the rejected check was payed $checkDetails->setRejected_liq_id($liqId); //add the check total to the rej checks total $rejCheckTotal += $checkDetails->getAmount() + $checkDetails->getRejected_cost_prov(); $cMapper->UpdateRejectedCheques($checkDetails); } $opsTotal = 0; /* update Liquidacion id in operations */ $operations_json = json_decode($request->operations_json); $opDetails = new Gyuser_Model_Operations(); $opDetails->setLiquidacion_id($liqId); $commissionRate = $prov->getComisionRate(); foreach ($operations_json as $operation) { $opDetails->setId($operation->operation_id); $oMapper->UpdateLiquidacion($opDetails); $amount = (double) $oMapper->GetAmount($operation->operation_id); $commissionAmt = (double) $pMapper->calculateComisionAmt($amount, $commissionRate); $opsTotal += (double) $pMapper->calculateProvPayment($amount, $commissionAmt); } $checksTotals = $cMapper->GetChequesTotalsJson($liq->getProvider_id(), $checksJson, $provData, $liq->getDate()); $acreditacion = floatval($request->acreditacion); $amountDebt = $rejCheckTotal + $opsTotal - $acreditacion; $accountBalance = $checksTotals['payingAmount'] - $amountDebt; $liq->setId($liqId); $liq->setAcreditacion($acreditacion); $liq->setAmount_debt($amountDebt); $liq->setAmount_payed($checksTotals['payingAmount']); $liq->setPrevious_account_balance($prov->getBalance()); $liq->setCurrent_account_balance($accountBalance); $liq->setChecks_qty($checksTotals['chequeChkCount']); $liq->setAverage_days($checksTotals['dayAvg']); $liq->setTotal_bruto($checksTotals['bruto']); $liq->setImpuesto_al_cheque_amt($checksTotals['impuestoAlCheque']); //the amount for impuesto al cheque $liq->setIntereses($checksTotals['intereses']); //also called descuento $liq->setGastos_interior_fee($checksTotals['gastosInterior']); //the amount for interior gastos $liq->setGastos_general_fee($checksTotals['gastosGeneral']); //the amount for general gastos $liq->setGastos_varios($checksTotals['gastosOtros']); $liq->setTotal_neto($checksTotals['payingAmount']); $lMapper->createLiq($liq, $variableDate); //update current balance $prov->setBalance($accountBalance); $pMapper->UpdateBalance($prov); } else { throw new Exception('error inserting new liquidacion'); } $this->_helper->redirector('providers', 'liquidaciones', 'gyuser', array('provider_id' => $request->provider_id)); } } catch (Exception $e) { echo $e; } }
public function getProviders() { $table = $this->getDbTable(); $select = $table->select(); $select->setIntegrityCheck(false); $select->from('providers', array('id', 'name', 'email', 'balance', 'tasa_anual', 'impuesto_al_cheque', 'gastos_general', 'gastos_interior', 'gastos_denuncia', 'gastos_rechazo', 'acreditacion_capital', 'acreditacion_interior', 'gastos_menor_a_monto_1', 'gastos_menor_a_1', 'gastos_menor_a_monto_2', 'gastos_menor_a_2')); $select->joinLeft(array('cqu' => 'cheques'), 'cqu.provider_id = providers.id and cqu.status = 3 and cqu.rejected_liquidacion_id IS NULL', array('sum(amount) as rej_amount', 'sum(rejected_cost) as rej_cost')); //$select->where('cqu.status = ?', 3); //$select->where('cqu.rejected_liquidacion_id IS NULL'); $select->where('providers.status = ?', true); $select->group('providers.id'); $select->order('id ASC'); $resultset = $table->fetchAll($select); $entires = array(); foreach ($resultset as $row) { //$entry = new Gyuser_Model_SupplierOperations(); $entry = new Gyuser_Model_Providers(); $entry->setId($row->id); $entry->setName($row->name); $entry->setEmail($row->email); $entry->setBalance($row->balance); $entry->setTasa_anual($row->tasa_anual); $entry->setImpuesto_al_cheque($row->impuesto_al_cheque); $entry->setGastos_general($row->gastos_general); $entry->setGastos_interior($row->gastos_interior); $entry->setGastos_denuncia($row->gastos_denuncia); $entry->setGastos_rechazo($row->gastos_rechazo); $entry->setAcreditacion_capital($row->acreditacion_capital); $entry->setAcreditacion_interior($row->acreditacion_interior); $entry->setGastos_cheque_menor_a_1($row->gastos_menor_a_monto_1); $entry->setGastos_cheque_a_1($row->gastos_menor_a_1); $entry->setGastos_cheque_menor_a_2($row->gastos_menor_a_monto_2); $entry->setGastos_cheque_a_2($row->gastos_menor_a_2); $entry->setRej_check_amount(floatval($row->rej_amount) + floatval($row->rej_cost)); $cMapper = new Gyuser_Model_ChequesDataMapper(); $cObj = new Gyuser_Model_Cheques(); $cObj->setStatus(4); $cObj->setProvider_id($row->id); $cAmount = $cMapper->GetTotalAmountByStats($cObj); $entry->setPassed_amount($cAmount); $entires[] = $entry; } return $entires; }
private function displayLiqTable($liqId, &$filename = null, &$provEmail = null, &$provName = null) { $pre_val = 0; $liqId = (int) $liqId; if ($liqId) { $lMapper = new Gyuser_Model_LiquidacionesDataMapper(); $lObj = new Gyuser_Model_Liquidaciones(); $lObj->setId($liqId); $lqList = $lMapper->GetLiquidacionesById($lObj); $provId = $lqList['provider_id']; $liqDate = $lqList['date']; $html = ' <table cellpadding="0" cellspacing="0" border="1" class="liq-table"> <thead> <tr> <td colspan="6" class="liq-header">OPERACIONES COMPARTIDAS</td> </tr> <tr class="liq-header2"> <th>FECHA OP.</th> <th>NOMBRE</th> <th>TOTAL</th> <th>GY</th> <th>COMISIONES</th> <th>SALDO</th> </tr> </thead> <tbody class="gridtbody">'; $oMapper = new Gyuser_Model_OperationsDataMapper(); $oObj = new Gyuser_Model_Operations(); $oObj->setLiquidacion_id($liqId); $opertationsList = $oMapper->GetOperationsByLiquidacionIdJson($oObj); $pArr = $opertationsList; $strBld = ''; $pay_final_amount = 0; if (count($pArr)) { foreach ($pArr as $pRow) { $pay_final_amount += $pRow['prov_payment']; $halfAmt = number_format($pRow['amount'] / 2, 2, '.', ''); $html .= "<tr >\n <td>{$pRow['date']}</td>\n <td>{$pRow['first_name']} {$pRow['last_name']}</td>\n <td>{$this->formatMoney($pRow['amount'])}</td>\n <td>{$this->formatMoney($halfAmt)}</td>\n <td>{$this->formatMoney($pRow['comision_amt'])}</td>\n <td>{$this->formatMoney($pRow['prov_payment'])}</td>\n </tr>"; } } $html .= '</tbody> <tfoot> <tr class="liq-footer"><td colspan="4"> </td><td>TOTAL</td><td><span class="operationsTotal_span">' . $this->formatMoney($pay_final_amount) . '</span></td></tr> </tfoot> </table><br />'; $html .= '<table cellpadding="0" cellspacing="0" border="1" class="liq-table"> <thead> <tr> <td colspan="6" class="liq-header">CHEQUES RECHAZADOS</td> </tr> <tr class="liq-header2"> <th>TITULAR</th> <th>FECHA</th> <th>N. CHEQUE</th> <th>RECHAZOS</th> <th>GASTOS</th> <th>SALDO</th> </tr> </thead> <tbody class="gridtbody">'; $cMapper = new Gyuser_Model_ChequesDataMapper(); $cObj = new Gyuser_Model_Cheques(); $cObj->setLiquidacion_id($liqId); $cObj->setProvider_id($provId); $pArr = $cMapper->RejectedChequeByLiquidacionesIdForProv($cObj); $strBld = ''; $sName = ''; $rejectedTotal = 0; //$rejectedChequesFee = number_format($rejectedChequesFee,2,'.',''); if (count($pArr)) { foreach ($pArr as $pRow) { $cObj->setRejected_type($pRow['rejected_type']); $cMapper = new Gyuser_Model_ChequesDataMapper(); $rejectedChequesFee = (int) $cMapper->GetRejectionCostForProv($cObj); $amount = $pRow['amount']; $rChequeWithFee = $amount + $rejectedChequesFee; $rChequeWithFee = number_format($rChequeWithFee, 2, '.', ''); $rejectedTotal += $rChequeWithFee; $pay_final_amount += $rChequeWithFee; $rejectedChequesFee = number_format($rejectedChequesFee, 2, '.', ''); $strBld .= <<<EOT <tr id="RejectedCheque_{$pRow['id']}"> <td class="user_operation_id">{$pRow['first_name']} {$pRow['last_name']}</td> <td class="user_check_n">{$pRow['date']}</td> <td class="user_bank_name">{$pRow['check_n']}</td> <td class="user_amount">{$this->formatMoney($amount)}</td> <td class="user_rejected_cheque_fee">{$this->formatMoney($rejectedChequesFee)}</td> <td class="pay_amount_cls">{$this->formatMoney($rChequeWithFee)}</td> </tr> EOT; } } $pay_final_amountInv = $pay_final_amount * -1; $pre_val = $pre_val * -1; $html .= $strBld; $html .= ' </tbody> <tfoot> <tr class="liq-footer"><td colspan="4"> </td><td>TOTAL</td><td>' . $this->formatMoney($rejectedTotal) . '</td></tr> </tfoot> </table><br />'; $html .= ' <table cellpadding="0" cellspacing="0" border="1" class="liq-table"> <thead> <tr> <td colspan="9" class="liq-header">CALCULO DE DESCUENTO</td> </tr> <tr class="liq-header2"> <th>TITULAR</th> <th>EMPRESA</th> <th>FECHA</th> <th>NUMERO</th> <th>IMPORTE</th> <th>CANT DIAS</th> <th>IMP. AL CHEQUE</th> <th>DESCUENTO</th> <th>SALDO A HOY</th> </tr> </thead> <tbody class="gridtbody">'; if ($lqList['committed'] == 1 || $lqList['committed'] == 2) { $provData = $lMapper->getProvData($lqList['id']); } else { //not committed. Get values from provider today values $pMapper = new Gyuser_Model_ProvidersDataMapper(); $provData = $pMapper->GetProviderByIdSimple($provId); } $checksList = $cMapper->GetChequeDetailsByLiquidacionIdJson($liqId, $provData, $liqDate); $totalFinalAmount = 0; foreach ($checksList as $item) { $html .= "<tr>\n <td>{$item['first_name']} {$item['last_name']}</td>\n <td>{$item['business']}</td>\n <td>{$item['date']}</td>\n <td>{$item['check_n']}</td>\n <td>{$this->formatMoney($item['amount'])}</td>\n <td>{$item['days']}</td>\n <td>{$this->formatMoney($item['imp_al_cheque'])}</td>\n <td>{$this->formatMoney($item['descuento'])}</td>\n <td>{$this->formatMoney($item['today_value'])}</td>\n </tr>"; } $html .= "</tbody>"; $cTotals = $cMapper->GetChequesTotalsJson($provId, $checksList, $provData, $liqDate); $html .= "<tfoot>\n <tr class='liq-header3'><th>N. CHEQUES</th><th>DIAS PROM.</th><th>BRUTO</th><th>IMP. AL CHEQUE</th><th>INTERESES</th><th>GASTOS INT.</th><th>GASTOS CAP.</th><th>GASTOS OTROS</th><th>SUBTOTAL</th></tr>\n <tr>\n <td>{$cTotals['chequeChkCount']}</td>\n <td>{$cTotals['dayAvg']}</td>\n <td>{$this->formatMoney($cTotals['bruto'])}</td>\n <td>{$this->formatMoney($cTotals['impuestoAlCheque'])}</td>\n <td>{$this->formatMoney($cTotals['intereses'])}</td>\n <td>{$this->formatMoney($cTotals['gastosInterior'])}</td>\n <td>{$this->formatMoney($cTotals['gastosGeneral'])}</td>\n <td>{$this->formatMoney($cTotals['gastosOtros'])}</td>\n <td>{$this->formatMoney($cTotals['payingAmount'])}</td>\n </tr>\n </tfoot></table>"; $html_style = <<<EOT <style type="text/css"> .liq-table { border:1px solid #777; } .liq-table td, .liq-table th { border-top: 0px; border-right: 1px solid #e5e5e5; border-bottom: 1px solid #e5e5e5; border-left: 0px; border:1px solid #ccc; padding:3px 7px; font:12px Geneva, sans-serif; background-color:#fff; white-space:nowrap; } td.liq-header { background-color:#777; text-align:center; color:#fff; font:bold 13px Geneva, sans-serif; text-transform:uppercase; border-width:0; white-space:nowrap; } .liq-header2 td, .liq-header2 th{ background-color:#f7f7f7; } .liq-header3 td, .liq-header3 th{ background-color:#e3e3e3; } .liq-header2 td, .liq-header2 th, .liq-header3 td, .liq-header3 th{ font:bold 12px Geneva, arial, sans-serif; text-transform: uppercase white-space:nowrap; } .liq-footer td{ background-color:#e3e3e3; font-weight:bold; border-top:1px solid #333; white-space:nowrap; } </style> EOT; $html_header = "<h1 style='font:bold 26px georgia, geneva'>Liquidacion {$lqList['id']}</h1>\n <table cellpadding='0' cellspacing='0' border='1' class='liq-table'>\n <tr><th style='text-align:right'>PROVEEDOR:</th><td>{$provData->getName()}</td></tr>\n <tr><th style='text-align:right'>FECHA:</th><td>{$lqList['date']}</td></tr>\n <tr><th style='text-align:right'>ACREDITACIONES:</th><td>{$this->formatMoney($lqList['acreditacion'])}</td></tr>\n <tr><th style='text-align:right'>TOTAL A LIQUIDAR</th><td>{$this->formatMoney($lqList['amount_debt'])}</td></tr>\n <tr><th style='text-align:right'>IMPORTE PAGADO:</th><td>{$this->formatMoney($lqList['amount_payed'])}</td></tr>\n <tr><th style='text-align:right'>SALDO:</th><td>{$this->formatMoney($lqList['current_account_balance'])}</td></tr>\n </table><br /><br />"; $provEmail = $provData->getEmail(); $provName = str_replace(' ', '-', $provData->getName()); $liqDate = str_replace('/', '-', $liqDate); $filename = 'Liq' . $liqId . '_' . $provName . '_' . $liqDate; return $html_style . $html_header . $html; } else { throw new Exception('liqId missing in display pdf generator -> displayTable function'); } }
public function RejectedChequeByProviderId($provider_id) { $table = $this->getDbTable(); $select = $table->select(); $select->setIntegrityCheck(false); $select->from(array('cqu' => 'cheques'), array('id as cheque_id', 'operation_id', 'date as cheque_date', 'check_n', 'amount', 'local', 'liquidacion_id', 'status as cheque_status', 'provider_id', 'rejected_cost', 'rejected_type')); $select->joinLeft(array('lqs' => 'liquidaciones'), 'lqs.id = cqu.liquidacion_id'); $select->joinLeft(array('ops' => 'operations'), 'cqu.operation_id = ops.id', array('client_id', 'bank_account_id')); $select->joinLeft(array('bas' => 'bank_accounts'), 'ops.bank_account_id = bas.id', array('bank_name')); $select->joinLeft(array('cls' => 'clients'), 'ops.client_id = cls.id', array('first_name', 'last_name')); $select->joinLeft(array('chqs' => 'cheques_status'), 'cqu.status = chqs.id', array('id as cheque_state_id', 'status_list')); $select->where('lqs.provider_id = ?', $provider_id); $select->where('cqu.status = ?', 3); $select->where('cqu.rejected_liquidacion_id IS NULL'); $select->order('cqu.id ASC'); $resultSet = $table->fetchAll($select); $entries = array(); foreach ($resultSet as $row) { $entry = new Gyuser_Model_Cheques(); $entry->setId($row->cheque_id); $entry->setOperation_id($row->operation_id); $entry->setDate(date("d/m/Y", strtotime($row->date))); $entry->setCheck_n($row->check_n); $entry->setAmount($row->amount); $entry->setStatus($row->cheque_status); $entry->setRejected_gastos($row->rejected_cost); $entry->setRejected_type($row->rejected_type); $entry->setLiquidacion_id($row->liquidacion_id); $entry->setProvider_id($row->provider_id); $clientObj = new Gyuser_Model_User(); $clientObj->setFirst_name($row->first_name); $clientObj->setLast_name($row->last_name); $entry->setClients_obj($clientObj); $cheques_state_obj = new Gyuser_Model_ChequesStatus(); $cheques_state_obj->setId($row->cheque_state_id); $cheques_state_obj->setStatus_list($row->status_list); $entry->setCheques_status_obj($cheques_state_obj); $_bank_accounts_obj = new Gyuser_Model_BankAccounts(); $_bank_accounts_obj->setBank_name($row->bank_name); $entry->setBank_accounts_obj($_bank_accounts_obj); $entries[] = $entry; } return $entries; }
public function getLiquidacionesForPrint($liqId) { if ($liqId) { $lMapper = new Gyuser_Model_LiquidacionesDataMapper(); $lObj = new Gyuser_Model_Liquidaciones(); $lObj->setId($liqId); $lqList = $lMapper->GetLiquidacionesById($lObj); $html = ''; $html .= '<h1>Liquidacion ' . $lqList['id'] . '</h1> <table cellpadding="0" cellspacing="0" border="1"> <thead> <tr> <th>Id</th> <th>FECHA</th> <th>DEBE</th> <th>ACREDITACIONES</th> <th>IMPORTE PAGADO</th> <th>SALDO</th> </tr> </thead> <tbody>'; $html .= "<tr>\n <td>{$lqList['id']}</td>\n <td>{$lqList['date']}</td>\n <td>{$lqList['amount_debt']}</td>\n <td>{$lqList['acreditacion']}</td>\n <td>{$lqList['amount_payed']}</td>\n <td>{$lqList['current_account_balance']}</td>\n </tr>"; $html .= '</tbody></table><br/>'; $html .= ' <table cellpadding="0" cellspacing="0" border="1" > <thead> <tr> <td colspan="6" style="text-align:center">OPERACIONES COMPARTIDAS</td> </tr> <tr> <th>FECHA OP.</th> <th>NOMBRE</th> <th>TOTAL</th> <th>GY</th> <th>COMISIONES</th> <th>SALDO</th> </tr> </thead> <tbody class="gridtbody">'; $oMapper = new Gyuser_Model_OperationsDataMapper(); $cObj = new Gyuser_Model_Operations(); $cObj->setLiquidacion_id($liqId); $opertationsList = $oMapper->GetOperationsByLiquidacionIdJson($cObj); $pArr = $opertationsList; $strBld = ''; $pay_final_amount = 0; if (count($pArr)) { foreach ($pArr as $pRow) { $pay_final_amount += $pRow['prov_payment']; $halfAmt = number_format($pRow['amount'] / 2, 2, '.', ''); $html .= "<tr >\n <td>{$pRow['date']}</td>\n <td>{$pRow['first_name']} {$pRow['last_name']}</td>\n <td>{$pRow['amount']}</td>\n <td>{$halfAmt}</td> \n <td>{$pRow['comision_amt']}</td>\n <td>{$pRow['prov_payment']}</td>\n </tr>"; } } $html .= '</tbody> <tfoot> <tr style="font-weight:bold"><td colspan="4"> </td><td>TOTAL</td><td><span class="operationsTotal_span">' . $pay_final_amount . '/span></td></tr> </tfoot> </table><br />'; $html .= '<table cellpadding="0" cellspacing="0" border="1" > <thead> <tr> <td colspan="6" style="text-align:center">CHEQUES RECHAZADOS</td> </tr> <tr> <th>TITULAR</th> <th>FECHA</th> <th>N. CHEQUE</th> <th>RECHAZOS</th> <th>GASTOS</th> <th>SALDO</th> </tr> </thead> <tbody class="gridtbody">'; $cMapper = new Gyuser_Model_ChequesDataMapper(); $cObj = new Gyuser_Model_Cheques(); $cObj->setLiquidacion_id($liqId); $cObj->setProvider_id($lqList['provider_id']); $pArr = $cMapper->RejectedChequeByLiquidacionesIdForProv($cObj); $strBld = ''; $sName = ''; $rejectedTotal = 0; //$rejectedChequesFee = number_format($rejectedChequesFee,2,'.',''); if (count($pArr)) { foreach ($pArr as $pRow) { $cObj->setRejected_type($pRow['rejected_type']); $rejectedChequesFee = (int) $cMapper->GetRejectionCostForProv($cObj); $amount = $pRow['amount']; $rChequeWithFee = $amount + $rejectedChequesFee; $rChequeWithFee = number_format($rChequeWithFee, 2, '.', ''); $rejectedTotal += $rChequeWithFee; $pay_final_amount += $rChequeWithFee; $rejectedChequesFee = number_format($rejectedChequesFee, 2, '.', ''); $strBld .= <<<EOT <tr id="RejectedCheque_{$pRow['id']}" style="background:#E3E3E3;"> <td class="user_operation_id">{$pRow['first_name']} {$pRow['last_name']}</td> <td class="user_check_n">{$pRow['date']}</td> <td class="user_bank_name">{$pRow['check_n']}</td> <td class="user_amount">{$amount}</td> <td class="user_rejected_cheque_fee">{$rejectedChequesFee}</td> <td class="pay_amount_cls">{$rChequeWithFee}</td> </tr> EOT; } } $pay_final_amountInv = $pay_final_amount * -1; $pre_val = $pre_val * -1; $html .= $strBld; $html .= ' </tbody> <tfoot> <tr style="font-weight:bold"><td colspan="4"> </td><td>TOTAL</td><td><span class="rejectedTotal_span">' . $rejectedTotal . '</span></td></tr> </tfoot> </table><br />'; $html .= '<table id="operationGridADDst" class="totals-table"> <tr id="Acreditacion"> <td>Acreditaciones:</td> <td> $ <input type="text" name="acreditacion" class="pay_amount_cls" value="" size="5" style="height:11px" /> </td> </tr> <tr id="operationGridADDend"> <td>Importe a Liquidar:</td> <td> <span class="pay_final_amount_span">' . $pay_final_amount . '</span> <input type="hidden" id="pay_final_amount" value="' . $pay_final_amountInv . '" /> </td> </tr> </table><br />'; /* $rejectedCheques = $cMapper->RejectedChequeByLiquidacionesIdForProv($cObj); $pArr = $rejectedCheques; $rejectedChequesFee = 60.00; $rejectedChequesFee = number_format($rejectedChequesFee, 2, '.', ''); if (count($pArr)) { $html .= '<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>-</td></tr>'; foreach ($pArr as $pRow) { //$pRow = new Gyuser_Model_Cheques(); $amount = $pRow['amount']; $rChequeWithFee = $amount + $rejectedChequesFee; $rChequeWithFee = number_format($rChequeWithFee, 2, '.', ''); $pay_final_amount += $rChequeWithFee; $html .= "<tr style='background:#E3E3E3;'> <td class='user_operation_id'>{$pRow['first_name']}<input type='hidden' value='}' name='operation_id'/></td> <td class='user_date'></td> <td class='user_check_n'></td> <td class='user_bank_name'></td> <td class='user_amount'>{$amount}</td> <td class='user_rejected_cheque_fee'>{$rejectedChequesFee}</td> <td class='user_bank_name'></td> <td class='user_bank_name'>$rChequeWithFee</td> </tr>"; } if (count($pArr)) { $html .= '<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>-</td></tr>'; $html .= '<tr><td style="height:20px"></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>'; $pay_final_amount = number_format($pay_final_amount, 2, '.', ''); $html .= "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td style='background:#E3E3E3;'>SALDO EN CHEQUES</td><td style='background:#CCCCCC;'><b>$pay_final_amount</b><input type='hidden' id='pay_final_amount' value='$pay_final_amount' /></td></tr>"; $html .= "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td><input type='button' class='chooseChequesBtn jqButton' value='Choose Cheques'/></td><td></td></tr>"; } } $html .= '</tbody></table>'; * * */ $html .= '<br /><br /> <h1>CALCULO DE DESCUENTO - <span class="currentDate"></span></h1> <table cellpadding="0" cellspacing="0" border="1" > <thead> <tr> <th>TITULAR</th> <th>EMPRESA</th> <th>FECHA</th> <th>N. CHEQUE</th> <th>IMPORTE</th> <th>CANT. DIAS</th> <th>IMP. AL CHEQUE</th> <th>DESCUENTO</th> <th>SALDO A HOY</th> </tr> </thead> <tbody class="gridtbody">'; $cMapper = new Gyuser_Model_ChequesDataMapper(); $cObj = new Gyuser_Model_Cheques(); $cObj->setLiquidacion_id($liqId); $chequesList = $cMapper->GetChequeDetailsByLiquidacionIdJson($liqId, $provData, $liqDate); $totalFinalAmount = 0; foreach ($chequesList as $cheques) { $item = $cheques; $cave_name = $item['first_name']; $amount = floatval($item['amount']); $check_n = $item['check_n']; $bank_name = $item['bank_name']; $date = $item['date']; $l_date = $item['liquidacion_date']; $acreditacion_hr = (int) $item['acreditacion_hrs']; $date = $item['date']; $date_arc = add_days_by_hr($date, $acreditacion_hr); $date_diff = dateDiff($l_date, $date_arc); $chqPer = $amount * 2.1 / 100; $discount = $amount * 0.17 / 100 * $date_diff; $finalAmount = $amount - $chqPer - $discount; $finalAmount = number_format($finalAmount, 2, '.', ''); $amount = number_format($amount, 2, '.', ''); $chqPer = number_format($chqPer, 2, '.', ''); $discount = number_format($discount, 2, '.', ''); $commision = number_format($commision, 2, '.', ''); $totalFinalAmount += $finalAmount; $html .= "<tr> \n <td>{$cave_name}</td>\n <td>{$date}</td>\n <td>{$amount}</td>\n <td>{$check_n}</td>\n <td>{$bank_name}</td>\n <td>{$date_diff}</td>\n <td>{$chqPer}</td>\n <td>{$discount}</td>\n <td>{$finalAmount}</td>\n </tr>"; } $html .= '<tr><td style="height:20px"></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>'; $html .= "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td style='background:#E3E3E3;'>SALDO A LIQUIDAR</td><td style='background:#CCCCCC;'><b>{$totalFinalAmount}</b><input type='hidden' id='pay_final_amount' value='{$totalFinalAmount}' /></td></tr>"; $html .= "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><input type='button' class='chooseChequesBtn jqButton' value='Choose Cheques'/></td><td></td></tr>"; $html .= '</tbody></table>'; echo $html; } }