Example #1
0
 public function PostBatch($uid, $date, $systemname, $batch_name, $description, $totaltransactionamt, $documentnoarray, $accountsarray, $amtarray, $currencyarray, $conversionarray, $originalamtarray, $bpartnerarray, $transtypearray, $linetypearray, $chequenoarray, $linedesc = "", $isreadonly = 0, $batchno = "", $orgarray, $track1array, $track2array, $track3array)
 {
     include_once "../simbiz/class/Batch.php";
     include_once "../simbiz/class/Accounts.php";
     include_once "../simbiz/class/Transaction.php";
     include_once "../simbiz/class/FinancialYearLine.php";
     include_once "../simantz/class/Period.inc.php";
     //		include_once "system.php";
     global $xoopsDB, $log, $defaultorganization_id, $tableprefix;
     $tablebatch = $tableprefix . "simbiz_batch";
     $tabletransaction = $tableprefix . "simbiz_transaction";
     $batch = new Batch();
     $acc = new Accounts();
     $trans = new Transaction();
     $fyl = new FinancialYearLine();
     $period = new Period();
     $year = $this->left($date, 4);
     $month = $this->right($this->left($date, 7), 2);
     $period_id = $period->getPeriodID($year, $month);
     $allowtrans = $fyl->allowAccountTransactionInDate($defaultorganization_id, $date);
     if (!$allowtrans) {
         $log->showLog(1, "Can't post data due to period in financial year is closed. You can fix this problem on re-opened this period at Financial Year window(under simbiz module)");
         return false;
     }
     $totaltransactionamt = abs($totaltransactionamt);
     //1.get next batch no
     if ($batchno == "") {
         $batchno = getNewCode($xoopsDB, "batchno", $tablebatch);
     }
     $timestamp = date("y/m/d H:i:s", time());
     //2. Create new batch
     $sqlinsertbatch = "INSERT INTO {$tablebatch} (organization_id, batchno,batch_name,description,created,createdby,\r\n\t\t\tupdated,updatedby,totaldebit,totalcredit,fromsys,batchdate,iscomplete,isreadonly,period_id) values(\r\n\t\t\t{$defaultorganization_id}, '{$batchno}','{$batch_name}','{$description}','{$timestamp}',{$uid},\r\n\t\t\t'{$timestamp}',{$uid},{$totaltransactionamt},{$totaltransactionamt},'{$systemname}','{$date}',1,{$isreadonly},{$period_id})";
     $rsinsertbatch = $xoopsDB->query($sqlinsertbatch);
     if (!$rsinsertbatch) {
         $log->showLog(1, __LINE__ . "PostBatch Create batch failed with sqlinsertbatch: {$sqlinsertbatch} ");
         return false;
     } else {
         $log->showLog(4, "Create batch successfully with sqlinsertbatch: {$sqlinsertbatch} ");
         $newbatch_id = $batch->getLatestBatchID();
         $i = 0;
         $reference_id = 0;
         foreach ($accountsarray as $accounts_id) {
             //3. Loop to create transaction
             if ($i != 0 && ($i == 1 || $linetypearray[$i - 1] == 0)) {
                 $reference_id = $this->latestTransactionId();
             } elseif ($linetypearray[$i] == 0 && $i > 0) {
                 $reference_id = 0;
             }
             if ($orgarray[$i] == "") {
                 $orgarray[$i] == $defaultorganization_id;
             }
             if ($track1array[$i] == "") {
                 $track1array[$i] = 0;
             }
             if ($track2array[$i] == "") {
                 $track2array[$i] = 0;
             }
             if ($track3array[$i] == "") {
                 $track3array[$i] = 0;
             }
             $sqlinserttransaction = "INSERT INTO {$tabletransaction} (\r\n\t\t\t\t\tdocument_no,batch_id,amt,currency_id,originalamt,\r\n\t\t\t\t\ttranstype,accounts_id,multiplyconversion,\r\n\t\t\t\t\tseqno,reference_id,bpartner_id,document_no2,linedesc,branch_id,track_id1,track_id2,track_id3)\r\n\t\t\t\t\tVALUES (\r\n\t\t\t\t\t'{$documentnoarray[$i]}',{$newbatch_id},{$amtarray[$i]},{$currencyarray[$i]},{$originalamtarray[$i]},\r\n\t\t\t\t\t'{$transtypearray[$i]}',{$accounts_id},{$conversionarray[$i]},'{$i}',{$reference_id},{$bpartnerarray[$i]},\r\n\t\t\t\t\t'{$chequenoarray[$i]}','{$linedesc[$i]}', {$orgarray[$i]},{$track1array[$i]},{$track2array[$i]},{$track3array[$i]})";
             $rsinserttransaction = $xoopsDB->query($sqlinserttransaction);
             if (!$rsinserttransaction) {
                 echo mysql_error();
                 $log->showLog(1, __LINE__ . "PostBatch Create transaction line failed with\r\n\t\t\t\t\t\t\t sqlinserttransaction: {$sqlinserttransaction},<br>deleteing batch: {$newbatch_id}");
                 $batch->deleteBatch($newbatch_id);
                 return false;
             } else {
                 $log->showLog(4, __LINE__ . "PostBatch Create transaction line successfully with\r\n\t\t\t\t\t\t\t sqlinserttransaction: {$sqlinserttransaction} ");
             }
             $i++;
         }
         //4. update lastbalance for accounts, and parent accounts
         $trans->compileSummary($newbatch_id);
         //5. Update transaction summary
         //6. update last balance for bpartner
         $trans->insertTransactionSummary($newbatch_id, $defaultorganization_id, 1);
         //7. put batch id, batch no at resultbatch_id,$resultbatch_no
         $this->resultbatch_id = $newbatch_id;
         $this->resultbatch_no = $batchno;
         //return true or false
         //$acc->repairAccounts();
         return true;
     }
     return false;
 }
Example #2
0
     $o->showcalendarto = $dp->show("batchdateto");
     $o->batchdatefrom = $_POST['batchdatefrom'];
     $o->batchdateto = $_POST['batchdateto'];
     $o->batchno = $_POST['batchno'];
     $o->batch_name = $_POST['batch_name'];
     $o->reuse = $_POST['reusesearch'];
     $o->iscomplete = $_POST['iscompletesearch'];
     $o->showSearchForm();
     $wherestring = " WHERE b.batch_id>0 and b.organization_id={$defaultorganization_id} ";
     $wherestring .= $o->genWhereString($o->batchdatefrom, $o->batchdateto, $o->batchno, $o->batch_name, $o->reuse, $o->iscomplete);
     $o->showHistoryTable($wherestring, "ORDER BY b.batchdate DESC,b.batchno DESC");
     break;
 case "checkclosing":
     //echo $o->batchdate;
     include_once "class/FinancialYearLine.php";
     $fyl = new FinancialYearLine();
     $allowtrans = $fyl->allowAccountTransactionInDate($defaultorganization_id, $o->batchdate);
     $newperiod_id = $fyl->period_id;
     //	$retval = $o->checkClosing();
     if ($allowtrans == true) {
         echo "<script type='text/javascript'>\r\n\r\n\t\tself.parent.document.frmBatch.period_id.value={$newperiod_id};\r\n\t\tself.parent.document.frmBatch.submit();\r\n\t\t</script>";
     } else {
         echo "<script type='text/javascript'>\r\n\t\t\talert('Date already closed.');\r\n\t\t</script>";
     }
     break;
 case "refreshbpartner":
     //on create new batch, 1st account bpartner
     include_once "class/Accounts.php";
     $acc = new Accounts();
     $accounts_id = $_POST['accounts_id'];
     $acc->fetchAccounts($accounts_id);
Example #3
0
<?php

include "system.php";
include "menu.php";
include_once 'class/Log.php';
include_once 'class/FinancialYear.php';
include_once 'class/FinancialYearLine.php';
include_once 'class/SelectCtrl.php';
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
$log = new Log();
$o = new FinancialYear();
$l = new FinancialYearLine();
$s = new XoopsSecurity();
$ctrl = new SelectCtrl();
$orgctrl = "";
//marhan add here --> ajax
echo "<iframe src='financialyear.php' name='nameValidate' id='idValidate' style='display:none' width='100%' height='260px'></iframe>";
echo "<div id='simit'><form name='frmValidate' target='nameValidate' method='POST'></form></div>";
////////////////////
$action = "";
echo <<<EOF
<script type="text/javascript">
function autofocus(){
document.forms['frmFinancialYear'].financialyear_name.focus();
}

\tfunction validateFinancialYear(){
\t\t
\t\tvar name=document.forms['frmFinancialYear'].financialyear_name.value;
\t\tvar description=document.forms['frmFinancialYear'].description.value;