Example #1
0
function _makeExtra($value, $title = '')
{
    global $THIS_RET;
    if ($THIS_RET['WITH_TEACHER_ID']) {
        $return .= Localize('colon', _('With')) . '&nbsp;' . GetTeacher($THIS_RET['WITH_TEACHER_ID']) . '<BR>';
    }
    if ($THIS_RET['NOT_TEACHER_ID']) {
        $return .= Localize('colon', _('Not With')) . '&nbsp;' . GetTeacher($THIS_RET['NOT_TEACHER_ID']) . '<BR>';
    }
    if ($THIS_RET['WITH_PERIOD_ID']) {
        $return .= Localize('colon', _('On')) . '&nbsp;' . GetPeriod($THIS_RET['WITH_PERIOD_ID']) . '<BR>';
    }
    if ($THIS_RET['NOT_PERIOD_ID']) {
        $return .= Localize('colon', _('Not On')) . '&nbsp;' . GetPeriod($THIS_RET['NOT_PERIOD_ID']) . '<BR>';
    }
    if ($THIS_RET['PRIORITY']) {
        $return .= Localize('colon', _('Priority')) . '&nbsp;' . $THIS_RET['PRIORITY'] . '<BR>';
    }
    if ($THIS_RET['MARKING_PERIOD_ID']) {
        $return .= Localize('colon', _('Marking Period')) . '&nbsp;' . GetMP($THIS_RET['MARKING_PERIOD_ID']) . '<BR>';
    }
    return $return;
}
 $ProcessResult = DB_query($SQL, $db, '', '', false, false);
 if (DB_error_no($db) != 0) {
     $title = _('Payment Processing - Problem Report');
     include 'header.inc';
     prnMsg(_('None of the payments will be processed because the bank account payment record for') . ' ' . $SupplierName . ' ' . _('could not be inserted because') . ' - ' . DB_error_msg($db), 'error');
     echo '<br /><a href="' . $rootpath . '/index.php">' . _('Back to the menu') . '</a>';
     if ($debug == 1) {
         prnMsg(_('The SQL that failed was') . ' ' . $SQL, 'error');
     }
     $ProcessResult = DB_Txn_Rollback($db);
     include 'footer.inc';
     exit;
 }
 /*If the General Ledger Link is activated */
 if ($_SESSION['CompanyRecord']['gllink_creditors'] == 1) {
     $PeriodNo = GetPeriod($_POST['AmountsDueBy'], $db);
     /*Do the GL trans for the payment CR bank */
     $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\taccount,\n\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\tamount )\n\t\t\t\tVALUES (22,\n\t\t\t\t\t'" . $SuppPaymentNo . "',\n\t\t\t\t\t'" . FormatDateForSQL($_POST['AmountsDueBy']) . "',\n\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t'" . $_POST['BankAccount'] . "',\n\t\t\t\t\t'" . $SupplierID . " - " . $SupplierName . ' ' . _('payment run on') . ' ' . Date($_SESSION['DefaultDateFormat']) . ' - ' . $PaytReference . "',\n\t\t\t\t\t'" . -$AccumBalance / $_POST['ExRate'] . "')";
     $ProcessResult = DB_query($SQL, $db, '', '', false, false);
     if (DB_error_no($db) != 0) {
         $title = _('Payment Processing') . ' - ' . _('Problem Report') . '.... ';
         include 'header.inc';
         prnMsg(_('None of the payments will be processed since the general ledger posting for the payment to') . ' ' . $SupplierName . ' ' . _('could not be inserted because') . ' - ' . DB_error_msg($db), 'error');
         echo '<br /><a href="' . $rootpath . '/index.php">' . _('Back to the menu') . '</a>';
         if ($debug == 1) {
             prnMsg(_('The SQL that failed was') . ':<br />' . $SQL, 'error');
         }
         $ProcessResult = DB_Txn_Rollback($db);
         include 'footer.inc';
         exit;
     }
 $Department = $_POST[$RequestID . 'Department' . $LineID];
 $Tag = $_POST[$RequestID . 'Tag' . $LineID];
 $RequestedQuantity = filter_number_format($_POST[$RequestID . 'RequestedQuantity' . $LineID]);
 if (isset($_POST[$RequestID . 'Completed' . $LineID])) {
     $Completed = True;
 } else {
     $Completed = False;
 }
 $sql = "SELECT materialcost, labourcost, overheadcost, decimalplaces FROM stockmaster WHERE stockid='" . $StockID . "'";
 $result = DB_query($sql, $db);
 $myrow = DB_fetch_array($result);
 $StandardCost = $myrow['materialcost'] + $myrow['labourcost'] + $myrow['overheadcost'];
 $DecimalPlaces = $myrow['decimalplaces'];
 $Narrative = _('Issue') . ' ' . $Quantity . ' ' . _('of') . ' ' . $StockID . ' ' . _('to department') . ' ' . $Department . ' ' . _('from') . ' ' . $Location;
 $AdjustmentNumber = GetNextTransNo(17, $db);
 $PeriodNo = GetPeriod(Date($_SESSION['DefaultDateFormat']), $db);
 $SQLAdjustmentDate = FormatDateForSQL(Date($_SESSION['DefaultDateFormat']));
 $Result = DB_Txn_Begin($db);
 // Need to get the current location quantity will need it later for the stock movement
 $SQL = "SELECT locstock.quantity\n\t\t\t\t\tFROM locstock\n\t\t\t\t\tWHERE locstock.stockid='" . $StockID . "'\n\t\t\t\t\t\tAND loccode= '" . $Location . "'";
 $Result = DB_query($SQL, $db);
 if (DB_num_rows($Result) == 1) {
     $LocQtyRow = DB_fetch_row($Result);
     $QtyOnHandPrior = $LocQtyRow[0];
 } else {
     // There must actually be some error this should never happen
     $QtyOnHandPrior = 0;
 }
 if ($_SESSION['ProhibitNegativeStock'] == 0 or $_SESSION['ProhibitNegativeStock'] == 1 and $QtyOnHandPrior >= $Quantity) {
     $SQL = "INSERT INTO stockmoves (\n\t\t\t\t\t\t\t\t\tstockid,\n\t\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t\ttransno,\n\t\t\t\t\t\t\t\t\tloccode,\n\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\tprd,\n\t\t\t\t\t\t\t\t\treference,\n\t\t\t\t\t\t\t\t\tqty,\n\t\t\t\t\t\t\t\t\tnewqoh)\n\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t'" . $StockID . "',\n\t\t\t\t\t\t\t\t\t17,\n\t\t\t\t\t\t\t\t\t'" . $AdjustmentNumber . "',\n\t\t\t\t\t\t\t\t\t'" . $Location . "',\n\t\t\t\t\t\t\t\t\t'" . $SQLAdjustmentDate . "',\n\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t'" . $Narrative . "',\n\t\t\t\t\t\t\t\t\t'" . -$Quantity . "',\n\t\t\t\t\t\t\t\t\t'" . ($QtyOnHandPrior - $Quantity) . "'\n\t\t\t\t\t\t\t\t)";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The stock movement record cannot be inserted because');
     echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>';
     if ($debug == 1) {
         echo '<br />' . $SQL;
     }
     include 'includes/footer.inc';
     exit;
 }
 $Period_0_Name = GetMonthText(mktime(0, 0, 0, Date('m'), Date('d'), Date('Y')));
 $Period_1_Name = GetMonthText(mktime(0, 0, 0, Date('m') - 1, Date('d'), Date('Y')));
 $Period_2_Name = GetMonthText(mktime(0, 0, 0, Date('m') - 2, Date('d'), Date('Y')));
 $Period_3_Name = GetMonthText(mktime(0, 0, 0, Date('m') - 3, Date('d'), Date('Y')));
 $Period_4_Name = GetMonthText(mktime(0, 0, 0, Date('m') - 4, Date('d'), Date('Y')));
 $Period_5_Name = GetMonthText(mktime(0, 0, 0, Date('m') - 5, Date('d'), Date('Y')));
 include 'includes/PDFInventoryPlanPageHeader.inc';
 $Category = '';
 $CurrentPeriod = GetPeriod(Date($_SESSION['DefaultDateFormat']), $db);
 $Period_1 = $CurrentPeriod - 1;
 $Period_2 = $CurrentPeriod - 2;
 $Period_3 = $CurrentPeriod - 3;
 $Period_4 = $CurrentPeriod - 4;
 $Period_5 = $CurrentPeriod - 5;
 while ($InventoryPlan = DB_fetch_array($InventoryResult)) {
     if ($Category != $InventoryPlan['categoryid']) {
         $FontSize = 10;
         if ($Category != '') {
             /*Then it's NOT the first time round */
             /*draw a line under the CATEGORY TOTAL*/
             $YPos -= $line_height;
             $pdf->line($Left_Margin, $YPos, $Page_Width - $Right_Margin, $YPos);
             $YPos -= 2 * $line_height;
         }
Example #5
0
                echo '<option selected="selected" value="' . $myrow['periodno'] . '">' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']) . '</option>';
            } else {
                echo '<option value="' . $myrow['periodno'] . '">' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']) . '</option>';
            }
        } else {
            if ($myrow['lastdate_in_period'] == $DefaultFromDate) {
                echo '<option selected="selected" value="' . $myrow['periodno'] . '">' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']) . '</option>';
            } else {
                echo '<option value="' . $myrow['periodno'] . '">' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']) . '</option>';
            }
        }
    }
    echo '</select></td>
		</tr>';
    if (!isset($_POST['ToPeriod']) or $_POST['ToPeriod'] == '') {
        $DefaultToPeriod = GetPeriod(date($_SESSION['DefaultDateFormat'], mktime(0, 0, 0, Date('m') + 1, 0, Date('Y'))), $db);
    } else {
        $DefaultToPeriod = $_POST['ToPeriod'];
    }
    echo '<tr>
			<td>' . _('Select Period To:') . '</td>
			<td><select name="ToPeriod">';
    $RetResult = DB_data_seek($Periods, 0);
    while ($myrow = DB_fetch_array($Periods, $db)) {
        if ($myrow['periodno'] == $DefaultToPeriod) {
            echo '<option selected="selected" value="' . $myrow['periodno'] . '">' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']) . '</option>';
        } else {
            echo '<option value ="' . $myrow['periodno'] . '">' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']) . '</option>';
        }
    }
    echo '</select></td>
            unset($_openSIS['DrawHeader']);
            //DrawHeader(Config('TITLE').' Class List');
            //DrawHeader($course_period['TEACHER'],$course_period['COURSE_TITLE'].' '.GetPeriod($course_period['PERIOD_ID']).($course_period['MARKING_PERIOD_ID']!="$fy_id"?' - '.GetMP($course_period['MARKING_PERIOD_ID']):'').(strlen($course_period['DAYS'])<5?' - '.$course_period['DAYS']:''));
            //DrawHeader(GetSchool(UserSchool()),ProperDate(DBDate()));
            $_openSIS['User'] = array(1 => array('STAFF_ID' => $course_period['TEACHER_ID'], 'NAME' => 'name', 'PROFILE' => 'teacher', 'SCHOOLS' => ',' . UserSchool() . ',', 'SYEAR' => UserSyear()));
            $_SESSION['UserCoursePeriod'] = $course_period['COURSE_PERIOD_ID'];
            echo "<table width=100%  style=\" font-family:Arial; font-size:12px;\" >";
            echo "<tr><td  style=\"font-size:15px; font-weight:bold; padding-top:20px;\">" . GetSchool(UserSchool()) . "<div style=\"font-size:12px;\">Teacher Class List</div></td><td align=right style=\"padding-top:20px;\">" . ProperDate(DBDate()) . "<br />Powered by openSIS</td></tr><tr><td colspan=2 style=\"border-top:1px solid #333;\">&nbsp;</td></tr></table>";
            echo "<table >";
            echo '<table border=0>';
            echo '<tr><td>Teacher Name:</td>';
            echo '<td>' . $course_period['TEACHER'] . '</td></tr>';
            echo '<tr><td>Course Program Name:</td>';
            echo '<td>' . $course_period['COURSE_TITLE'] . '</td></tr>';
            echo '<tr><td>Course Period Name:</td>';
            echo '<td>' . GetPeriod($course_period['PERIOD_ID']) . '</td></tr>';
            echo '<tr><td>Marking Period:</td>';
            echo '<td>' . GetMP($course_period['MARKING_PERIOD_ID']) . '</td></tr>';
            echo '</table>';
            $extra = $first_extra;
            $extra['MP'] = $course_period['MARKING_PERIOD_ID'];
            include 'modules/misc/Export.php';
            echo "<div style=\"page-break-before: always;\"></div>";
        }
        $_SESSION['UserCoursePeriod'] = $PCL_UserCoursePeriod;
        PDFStop($handle);
    } else {
        BackPrompt('You must choose at least one course period.');
    }
}
if (!$_REQUEST['modfunc']) {
Example #7
0
    echo '<tr><td>' . _('Tax Authority To Report On:') . ':</td>
			<td><select name="TaxAuthority">';
    $result = DB_query("SELECT taxid, description FROM taxauthorities", $db);
    while ($myrow = DB_fetch_array($result)) {
        echo '<option value="' . $myrow['taxid'] . '">' . $myrow['description'] . '</option>';
    }
    echo '</select></td></tr>';
    echo '<tr>
			<td>' . _('Return Covering') . ':</td>
			<td><select name="NoOfPeriods">
			<option value="1">' . _('One Month') . '</option>' . '<option selected="selected" value="2">' . _('Two Months') . '</option>' . '<option value="3">' . _('Quarter') . '</option>' . '<option value="6">' . _('Six Months') . '</option>' . '</select></td>
		</tr>';
    echo '<tr>
			<td>' . _('Return To') . ':</td>
			<td><select name="ToPeriod">';
    $DefaultPeriod = GetPeriod(Date($_SESSION['DefaultDateFormat'], Mktime(0, 0, 0, Date('m'), 0, Date('Y'))), $db);
    $sql = "SELECT periodno,\n\t\t\tlastdate_in_period\n\t\tFROM periods";
    $ErrMsg = _('Could not retrieve the period data because');
    $Periods = DB_query($sql, $db, $ErrMsg);
    while ($myrow = DB_fetch_array($Periods, $db)) {
        if ($myrow['periodno'] == $DefaultPeriod) {
            echo '<option selected="selected" value="' . $myrow['periodno'] . '">' . ConvertSQLDate($myrow['lastdate_in_period']) . '</option>';
        } else {
            echo '<option value="' . $myrow['periodno'] . '">' . ConvertSQLDate($myrow['lastdate_in_period']) . '</option>';
        }
    }
    echo '</select></td>
		</tr>';
    echo '<tr>
			<td>' . _('Detail Or Summary Only') . ':</td>
			<td><select name="DetailOrSummary">
Example #8
0
 function get_period($bln)
 {
     echo GetPeriod(urldecode($bln));
 }
Example #9
0
    }
    if ($_POST['BankAccount'] == '') {
        prnMsg(_('No bank account has been selected so this payment cannot be processed'), 'warn');
        include 'includes/footer.inc';
        exit;
    }
    /*Make an array of the defined bank accounts */
    $SQL = "SELECT bankaccounts.accountcode\n\t\t\tFROM bankaccounts,\n\t\t\t\tchartmaster\n\t\t\tWHERE bankaccounts.accountcode=chartmaster.accountcode";
    $result = DB_query($SQL, $db);
    $BankAccounts = array();
    $i = 0;
    while ($Act = DB_fetch_row($result)) {
        $BankAccounts[$i] = $Act[0];
        $i++;
    }
    $PeriodNo = GetPeriod($_SESSION['PaymentDetail' . $identifier]->DatePaid, $db);
    $sql = "SELECT usepreprintedstationery\n\t\t\tFROM paymentmethods\n\t\t\tWHERE paymentname='" . $_SESSION['PaymentDetail' . $identifier]->Paymenttype . "'";
    $result = DB_query($sql, $db);
    $myrow = DB_fetch_row($result);
    // first time through commit if supplier cheque then print it first
    if (!isset($_POST['ChequePrinted']) and !isset($_POST['PaymentCancelled']) and $myrow[0] == 1) {
        // it is a supplier payment by cheque and haven't printed yet so print cheque
        echo '<br />
			<a href="' . $rootpath . '/PrintCheque.php?ChequeNum=' . $_POST['ChequeNum'] . '&amp;identifier=' . $identifier . '">' . _('Print Cheque using pre-printed stationery') . '</a>
			<br />
			<br />';
        echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'] . '?identifier=' . $identifier) . '">';
        echo '<div>';
        echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
        echo _('Has the cheque been printed') . '?
			<br />
<?php

/* $Id: DailySalesInquiry.php 6944 2014-10-27 07:15:34Z daintree $*/
include 'includes/session.inc';
$Title = _('Daily Sales Inquiry');
include 'includes/header.inc';
echo '<p class="page_title_text"><img src="' . $RootPath . '/css/' . $Theme . '/images/transactions.png" title="' . _('Daily Sales') . '" alt="" />' . ' ' . _('Daily Sales') . '</p>';
echo '<div class="page_help_text">' . _('Select the month to show daily sales for') . '</div>
	<br />';
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">';
echo '<div>';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
if (!isset($_POST['MonthToShow'])) {
    $_POST['MonthToShow'] = GetPeriod(Date($_SESSION['DefaultDateFormat']), $db);
    $Result = DB_query("SELECT lastdate_in_period FROM periods WHERE periodno='" . $_POST['MonthToShow'] . "'");
    $myrow = DB_fetch_array($Result);
    $EndDateSQL = $myrow['lastdate_in_period'];
}
echo '<table class="selection">
	<tr>
		<td>' . _('Month to Show') . ':</td>
		<td><select tabindex="1" name="MonthToShow">';
$PeriodsResult = DB_query("SELECT periodno, lastdate_in_period FROM periods");
while ($PeriodRow = DB_fetch_array($PeriodsResult)) {
    if ($_POST['MonthToShow'] == $PeriodRow['periodno']) {
        echo '<option selected="selected" value="' . $PeriodRow['periodno'] . '">' . MonthAndYearFromSQLDate($PeriodRow['lastdate_in_period']) . '</option>';
        $EndDateSQL = $PeriodRow['lastdate_in_period'];
    } else {
        echo '<option value="' . $PeriodRow['periodno'] . '">' . MonthAndYearFromSQLDate($PeriodRow['lastdate_in_period']) . '</option>';
    }
}
Example #11
0
 /* end of the costing specific updates */
 if ($_SESSION['CompanyRecord']['gllink_stock'] == 1) {
     /*we always need to reverse entries relating to the GRN suspense during delivery and entry of shipment charges */
     $sql = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\tamount)\n\t\t\t\tVALUES (31,\n\t\t\t\t\t" . $_GET['SelectedShipment'] . ",\n\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t" . $PeriodNo . ",\n\t\t\t\t\t" . $_SESSION['CompanyRecord']['grnact'] . ",\n\t\t\t\t\t'" . $myrow['itemcode'] . ' ' . _('shipt cost') . ' ' . number_format($ItemShipmentCost, 2) . ' x ' . _('Qty invoiced') . ' ' . $myrow['totqtyinvoiced'] . "',\n                                        " . $Variance * $myrow['totqtyinvoiced'] . ")";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The credit GL entry for the shipment variance posting for') . ' ' . $myrow['itemcode'] . ' ' . _('could not be inserted because');
     $result = DB_query($sql, $db, $ErrMsg, '', TRUE);
 }
 if ($_POST['UpdateCost'] == 'Yes') {
     /*Only ever a standard costing option
       Weighted average costing implies cost updates taking place automatically */
     $QOHResult = DB_query("SELECT SUM(quantity) FROM locstock WHERE stockid ='" . $myrow['itemcode'] . "'", $db);
     $QOHRow = DB_fetch_row($QOHResult);
     $QOH = $QOHRow[0];
     if ($_SESSION['CompanyRecord']['gllink_stock'] == 1) {
         $CostUpdateNo = GetNextTransNo(35, $db);
         $PeriodNo = GetPeriod(Date("d/m/Y"), $db);
         $ValueOfChange = $QOH * ($ItemShipmentCost - $StdCostUnit);
         $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\tVALUES (35,\n\t\t\t\t\t\t\t" . $CostUpdateNo . ",\n\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t" . $PeriodNo . ",\n\t\t\t\t\t\t\t" . $StockGLCodes['adjglact'] . ",\n\t\t\t\t\t\t\t'" . _('Shipment of') . ' ' . $myrow['itemcode'] . " " . _('cost was') . ' ' . $StdCostUnit . ' ' . _('changed to') . ' ' . number_format($ItemShipmentCost, 2) . ' x ' . _('QOH of') . ' ' . $QOH . "', " . -$ValueOfChange . ")";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GL credit for the shipment stock cost adjustment posting could not be inserted because') . ' ' . DB_error_msg($db);
         $Result = DB_query($SQL, $db, $ErrMsg, '', TRUE);
         $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\tVALUES (35,\n\t\t\t\t\t\t\t" . $CostUpdateNo . ",\n\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t" . $PeriodNo . ",\n\t\t\t\t\t\t\t" . $StockGLCodes['stockact'] . ",\n\t\t\t\t\t\t\t'" . _('Shipment of') . ' ' . $myrow['itemcode'] . ' ' . _('cost was') . ' ' . $StdCostUnit . ' ' . _('changed to') . ' ' . number_format($ItemShipmentCost, 2) . ' x ' . _('QOH of') . ' ' . $QOH . "',\n                                                        " . $ValueOfChange . ")";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GL debit for stock cost adjustment posting could not be inserted because') . ' ' . DB_error_msg($db);
         $Result = DB_query($SQL, $db, $ErrMsg, '', TRUE);
     }
     /*end of GL entries for a standard cost update */
     /* Only the material cost is important for imported items */
     $sql = "UPDATE stockmaster SET materialcost=" . $ItemShipmentCost . ",\n\t\t\t\t\t\t\t\tlabourcost=0,\n\t\t\t\t\t\t\t\toverheadcost=0,\n\t\t\t\t\t\t\t\tlastcost=" . $StdCostUnit . "\n\t\t\t\t\t\tWHERE stockid='" . $myrow['itemcode'] . "'";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The shipment cost details for the stock item could not be updated because') . ': ' . DB_error_msg($db);
     $result = DB_query($sql, $db, $ErrMsg, '', TRUE);
 }
 // end of update cost code
Example #12
0
											<td><input id="phone" class="idle" style="width: 200px;" ' . $other_disabled . ' type="text" value="' . $res[phone] . '" /></td>
											<td><input id="phone1" class="idle" style="width: 200px;" ' . $other_disabled . ' type="text" value="' . $res[phone1] . '" /></td>
											<td><input id="addres" class="idle" style="width: 200px;" ' . $other_disabled . ' type="text" value="' . $res[address] . '" /></td>
										</tr>
									</table>
								</fieldset >
									<fieldset style="margin-top: 5px;">
							    		<legend>დავალების ტიპი</legend>
											<table class="dialog-form-table" >
											<tr>
												<td style="width: 280px;"><label for="period">პერიოდი</label></td>
												<td colspan="2" style="width: 280px;"><label for="book">გამოცემა</label></td>
											</tr>
								    		<tr>
												<td>
											    <select style="width: 200px;"  id="period" class="idls object">' . GetPeriod($res['period_id']) . '</select>
												</td>
												<td colspan="2"><input style="width: 444px;" id="book" 		value="' . $res[books] . '" 	class="idls object" ' . $other_disabled . '></td>
											</tr>
											<tr>
												<td style="width: 280px;"><label for="date">ქოლ-ცენტრის დარეკვის თარიღი</label></td>
												<td style="width: 280px;"><label for="op_id">ოპერატორი</label></td>
											</tr>
								    		<tr>
												<td><input style="width: 200px;" id="date" 		value="' . $res[call_date] . '" 		class="idls object" ' . $other_disabled . '></td>
												<td><input style="width: 200px;" id="op_id" 	value="' . $res[operator_id] . '" 		class="idls object" disabled></td>
											</tr>
											</table>
											<table class="dialog-form-table" >
											<tr>
												<td style="width: 270px;"><label> გადასახდელი თანხა  </label></td>
         if ($OldWIPAccount != $NewWIPAct and $_SESSION['CompanyRecord']['gllink_stock'] == 1) {
             /*Then we need to make a journal to transfer the cost  of WIP to the new WIP account */
             /*First get the total cost of WIP for this category */
             $WOCostsResult = DB_query("SELECT workorders.costissued,\n\t\t\t\t\t\t\t\t\t\t\t\t\tSUM(woitems.qtyreqd * woitems.stdcost) AS costrecd\n\t\t\t\t\t\t\t\t\t\t\t\tFROM woitems INNER JOIN workorders\n\t\t\t\t\t\t\t\t\t\t\t\tON woitems.wo = workorders.wo\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN stockmaster\n\t\t\t\t\t\t\t\t\t\t\t\tON woitems.stockid=stockmaster.stockid\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE stockmaster.stockid='" . $StockID . "'\n\t\t\t\t\t\t\t\t\t\t\t\tAND workorders.closed=0\n\t\t\t\t\t\t\t\t\t\t\t\tGROUP BY workorders.costissued", _('Error retrieving value of finished goods received and cost issued against work orders for this item'));
             $WIPValue = 0;
             while ($WIPRow = DB_fetch_array($WOCostsResult)) {
                 $WIPValue += $WIPRow['costissued'] - $WIPRow['costrecd'];
             }
             if ($WIPValue != 0) {
                 $JournalNo = GetNextTransNo(0, $db);
                 //enter as a journal
                 $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\t\t\tVALUES ( 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $JournalNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . GetPeriod(Date($_SESSION['DefaultDateFormat']), $db, true) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $NewWIPAct . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $StockID . ' ' . _('Change stock category') . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $WIPValue . "')";
                 $ErrMsg = _('The WIP cost journal could not be inserted because');
                 $DbgMsg = _('The SQL that was used to create the WIP cost journal and failed was');
                 $result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
                 $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\t\t\tVALUES ( 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $JournalNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . GetPeriod(Date($_SESSION['DefaultDateFormat']), $db, true) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $OldWIPAccount . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $StockID . ' ' . _('Change stock category') . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . -$WIPValue . "')";
                 $result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
             }
         }
         /* end if the stock category changed and forced a change in WIP account */
         DB_Txn_Commit();
         prnMsg(_('Stock Item') . ' ' . $StockID . ' ' . _('has been updated'), 'success');
         echo '<br />';
     }
 } else {
     //it is a NEW part
     //but lets be really sure here
     $result = DB_query("SELECT stockid\n\t\t\t\t\t\t\t\tFROM stockmaster\n\t\t\t\t\t\t\t\tWHERE stockid='" . $StockID . "'");
     if (DB_num_rows($result) == 1) {
         prnMsg(_('The stock code entered is actually already in the database - duplicate stock codes are prohibited by the system. Try choosing an alternative stock code'), 'error');
         $InputError = 1;
 /* end of the costing specific updates */
 if ($_SESSION['CompanyRecord']['gllink_stock'] == 1) {
     /*we always need to reverse entries relating to the GRN suspense during delivery and entry of shipment charges */
     $sql = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\t\tVALUES (31,\n\t\t\t\t\t\t\t\t\t\t\t'" . $_GET['SelectedShipment'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['CompanyRecord']['grnact'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['DefaulTag'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . $Variance * $myrow['totqtyinvoiced'] . ")";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The credit GL entry for the shipment variance posting for') . ' ' . $myrow['itemcode'] . ' ' . _('could not be inserted because');
     $result = DB_query($sql, $db, $ErrMsg, '', TRUE);
 }
 if ($_POST['UpdateCost'] == 'Yes') {
     /*Only ever a standard costing option
       Weighted average costing implies cost updates taking place automatically */
     $QOHResult = DB_query("SELECT SUM(quantity) AS totalquantity FROM locstock WHERE stockid ='" . $myrow['itemcode'] . "'", $db);
     $QOHRow = DB_fetch_array($QOHResult);
     $QOH = $QOHRow['totalquantity'];
     if ($_SESSION['CompanyRecord']['gllink_stock'] == 1) {
         $CostUpdateNo = GetNextTransNo(35, $db);
         $PeriodNo = GetPeriod(Date('d/m/Y'), $db);
         $ValueOfChange = $QOH * ($ItemShipmentCost - $StdCostUnit);
         $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\t\t\tVALUES (35,\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $CostUpdateNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $StockGLCodes['adjglact'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['DefaulTag'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . _('Shipment of') . ' ' . $myrow['itemcode'] . " " . _('cost was') . ' ' . $StdCostUnit . ' ' . _('changed to') . ' ' . locale_money_format($ItemShipmentCost, $ShipmentCurrency) . ' x ' . _('QOH of') . ' ' . $QOH . "', " . -$ValueOfChange . ")";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GL credit for the shipment stock cost adjustment posting could not be inserted because') . ' ' . DB_error_msg($db);
         $Result = DB_query($SQL, $db, $ErrMsg, '', TRUE);
         $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\t\tdefaulttag'\n\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\t\t\tVALUES (35,\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $CostUpdateNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $StockGLCodes['stockact'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['DefaulTag'] . "',\n\t\t\t\t\t\t\t\t\t'" . _('Shipment of') . ' ' . $myrow['itemcode'] . ' ' . _('cost was') . ' ' . $StdCostUnit . ' ' . _('changed to') . ' ' . locale_money_format($ItemShipmentCost, $ShipmentCurrency) . ' x ' . _('QOH of') . ' ' . $QOH . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $ValueOfChange . ")";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GL debit for stock cost adjustment posting could not be inserted because') . ' ' . DB_error_msg($db);
         $Result = DB_query($SQL, $db, $ErrMsg, '', TRUE);
     }
     /*end of GL entries for a standard cost update */
     /* Only the material cost is important for imported items */
     $sql = "UPDATE stockmaster SET materialcost=" . $ItemShipmentCost . ",\n\t\t\t\t\t\t\t\t\t\t\t\tlabourcost=0,\n\t\t\t\t\t\t\t\t\t\t\t\toverheadcost=0,\n\t\t\t\t\t\t\t\t\t\t\t\tlastcost='" . $StdCostUnit . "'\n\t\t\t\t\t\t\t\t\t\tWHERE stockid='" . $myrow['itemcode'] . "'";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The shipment cost details for the stock item could not be updated because') . ': ' . DB_error_msg($db);
     $result = DB_query($sql, $db, $ErrMsg, '', TRUE);
 }
 // end of update cost code
 }
 if (abs($TotalAllocated + $_SESSION['Alloc']->TransAmt) < 0.01) {
     $Settled = 1;
 } else {
     $Settled = 0;
 }
 // Update the receipt or credit note
 $SQL = "UPDATE debtortrans\n\t\t\t\tSET alloc = '" . -$AllAllocations . "',\n\t\t\t\tdiffonexch = '" . -$TotalDiffOnExch . "',\n\t\t\t\tsettled='" . $Settled . "'\n\t\t\t\tWHERE id = '" . $_POST['AllocTrans'] . "'";
 if (!($Result = DB_query($SQL, $db))) {
     $Error = _('Could not update receipt or credit note');
 }
 // If GLLink to debtors active post diff on exchange to GL
 $MovtInDiffOnExch = -$_SESSION['Alloc']->PrevDiffOnExch - $TotalDiffOnExch;
 if ($MovtInDiffOnExch != 0) {
     if ($_SESSION['CompanyRecord']['gllink_debtors'] == 1) {
         $PeriodNo = GetPeriod($_SESSION['Alloc']->TransDate, $db);
         $_SESSION['Alloc']->TransDate = FormatDateForSQL($_SESSION['Alloc']->TransDate);
         $SQL = "INSERT INTO gltrans (\n\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\tamount\n\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\t'" . $_SESSION['Alloc']->TransType . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['Alloc']->TransNo . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['Alloc']->TransDate . "',\n\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['CompanyRecord']['exchangediffact'] . "',\n\t\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t\t'" . $MovtInDiffOnExch . "'\n\t\t\t\t\t\t\t)";
         if (!($Result = DB_query($SQL, $db))) {
             $Error = _('Could not update exchange difference in General Ledger');
         }
         $SQL = "INSERT INTO gltrans (\n\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\tamount\n\t\t  \t\t\t\t) VALUES (\n\t\t\t\t\t\t\t'" . $_SESSION['Alloc']->TransType . "',\n\t\t\t\t\t\t\t'" . $_SESSION['Alloc']->TransNo . "',\n\t\t\t\t\t\t\t'" . $_SESSION['Alloc']->TransDate . "',\n\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t'" . $_SESSION['CompanyRecord']['debtorsact'] . "',\n\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t'" . -$MovtInDiffOnExch . "'\n\t\t\t\t\t\t)";
         if (!($Result = DB_query($SQL, $db))) {
             $Error = _('Could not update debtors control in General Ledger');
         }
     }
 }
 //
 //========[ COMMIT TRANSACTION ]===========
 //
 if (empty($Error)) {
Example #16
0
 echo "</td><td><td><input  type=submit name='cancelInvoice' VALUE='" . _('Cancel Fee Structure') . "' onclick=\"return confirm('" . _('Are you sure you want to cancel this Fee Structure') . "');\"></td></tr>";
 echo '</table>';
 if (isset($_POST['cancelInvoice'])) {
     unset($_SESSION['form_already_loaded']);
     unset($_SESSION['invoiceItems']);
     unset($_SESSION['feeStructure']);
     unset($_SESSION['InvoiceItems']->LineItems);
     unset($_SESSION['InvoiceItems']->LineCounter);
     unset($_SESSION['period']);
     unset($_SESSION['classSession']);
     $_SESSION['InvoiceItems'] = new Cart();
     echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . "/FeeStructure.php" . "'>";
 }
 if (isset($_POST['submitInvoice'])) {
     $PostingDate = Date($_SESSION['DefaultDateFormat'], mktime(0, 0, 0, Date('m'), 0, Date('Y')));
     $PeriodNo = GetPeriod($PostingDate, $db);
     if (isset($_SESSION['feeStructure'])) {
         $sql = "DELETE FROM autobilling_items WHERE autobilling_id='" . $_SESSION['feeStructure'] . "'";
         $result = DB_query($sql, $db);
         $i = 0;
         foreach ($_POST['id'] as $value) {
             $sql = "SELECT id FROM autobilling_items\n\t\t\t\tWHERE autobilling_id='" . $lastID . "'\n\t\t\t\tAND product_id='" . $_POST['stockID' . $value] . "'";
             $result = DB_query($sql, $db);
             if (DB_fetch_row($result) > 0) {
                 prnMsg(_($value . _(' ') . 'has already been invoiced for this period'), 'warn');
             } else {
                 $sql = "INSERT INTO autobilling_items (autobilling_id,product_id,amount,priority) \n\t\t\t\t\tVALUES ('" . $_SESSION['feeStructure'] . "','" . $_POST['id'][$i] . "','" . $_POST['Price'][$i] . "','" . $_POST['priority'][$i] . "') ";
                 $result = DB_query($sql, $db);
             }
             $i++;
         }
Example #17
0
function submit(&$db, $TabToShow)
{
    //initialise no input errors
    $InputError = 0;
    //first off validate inputs sensible
    if ($InputError == 0) {
        // Creation of beginning of SQL query
        $SQL = "SELECT pcexpenses.codeexpense,";
        // Creation of periods SQL query
        $period_today = GetPeriod(Date($_SESSION['DefaultDateFormat']), $db);
        $sqlPeriods = "SELECT periodno,\r\n\t\t\t\t\t\tlastdate_in_period\r\n\t\t\t\tFROM periods\r\n\t\t\t\tWHERE periodno <= " . $period_today . "\r\n\t\t\t\tORDER BY periodno DESC\r\n\t\t\t\tLIMIT 24";
        $Periods = DB_query($sqlPeriods);
        $numPeriod = 0;
        $LabelsArray = array();
        while ($myrow = DB_fetch_array($Periods, $db)) {
            $numPeriod++;
            $LabelsArray[$numPeriod] = MonthAndYearFromSQLDate($myrow['lastdate_in_period']);
            $SQL = $SQL . "(SELECT SUM(pcashdetails.amount)\r\n\t\t\t\t\t\t\tFROM pcashdetails\r\n\t\t\t\t\t\t\tWHERE pcashdetails.codeexpense = pcexpenses.codeexpense";
            if ($TabToShow != 'All') {
                $SQL = $SQL . " \tAND pcashdetails.tabcode = '" . $TabToShow . "'";
            }
            $SQL = $SQL . "\t\tAND date >= '" . beginning_of_month($myrow['lastdate_in_period']) . "'\r\n\t\t\t\t\t\t\t\tAND date <= '" . $myrow['lastdate_in_period'] . "') AS expense_period" . $numPeriod . ", ";
        }
        // Creation of final part of SQL
        $SQL = $SQL . " pcexpenses.description\r\n\t\t\t\tFROM  pcexpenses\r\n\t\t\t\tORDER BY pcexpenses.codeexpense";
        $result = DB_query($SQL);
        if (DB_num_rows($result) != 0) {
            // Create new PHPExcel object
            $objPHPExcel = new PHPExcel();
            // Set document properties
            $objPHPExcel->getProperties()->setCreator("webERP")->setLastModifiedBy("webERP")->setTitle("Petty Cash Expenses Analysis")->setSubject("Petty Cash Expenses Analysis")->setDescription("Petty Cash Expenses Analysis")->setKeywords("")->setCategory("");
            $objPHPExcel->getActiveSheet()->getStyle('1')->getAlignment()->setWrapText(true);
            $objPHPExcel->getActiveSheet()->getStyle('C:AB')->getNumberFormat()->setFormatCode('#,###');
            // Add title data
            $objPHPExcel->setActiveSheetIndex(0);
            $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Code');
            $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Description');
            $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Total 12 Months');
            $objPHPExcel->getActiveSheet()->setCellValue('D1', 'Average 12 Months');
            $objPHPExcel->getActiveSheet()->setCellValue('E1', $LabelsArray[24]);
            $objPHPExcel->getActiveSheet()->setCellValue('F1', $LabelsArray[23]);
            $objPHPExcel->getActiveSheet()->setCellValue('G1', $LabelsArray[22]);
            $objPHPExcel->getActiveSheet()->setCellValue('H1', $LabelsArray[21]);
            $objPHPExcel->getActiveSheet()->setCellValue('I1', $LabelsArray[20]);
            $objPHPExcel->getActiveSheet()->setCellValue('J1', $LabelsArray[19]);
            $objPHPExcel->getActiveSheet()->setCellValue('K1', $LabelsArray[18]);
            $objPHPExcel->getActiveSheet()->setCellValue('L1', $LabelsArray[17]);
            $objPHPExcel->getActiveSheet()->setCellValue('M1', $LabelsArray[16]);
            $objPHPExcel->getActiveSheet()->setCellValue('N1', $LabelsArray[15]);
            $objPHPExcel->getActiveSheet()->setCellValue('O1', $LabelsArray[14]);
            $objPHPExcel->getActiveSheet()->setCellValue('P1', $LabelsArray[13]);
            $objPHPExcel->getActiveSheet()->setCellValue('Q1', $LabelsArray[12]);
            $objPHPExcel->getActiveSheet()->setCellValue('R1', $LabelsArray[11]);
            $objPHPExcel->getActiveSheet()->setCellValue('S1', $LabelsArray[10]);
            $objPHPExcel->getActiveSheet()->setCellValue('T1', $LabelsArray[9]);
            $objPHPExcel->getActiveSheet()->setCellValue('U1', $LabelsArray[8]);
            $objPHPExcel->getActiveSheet()->setCellValue('V1', $LabelsArray[7]);
            $objPHPExcel->getActiveSheet()->setCellValue('W1', $LabelsArray[6]);
            $objPHPExcel->getActiveSheet()->setCellValue('X1', $LabelsArray[5]);
            $objPHPExcel->getActiveSheet()->setCellValue('Y1', $LabelsArray[4]);
            $objPHPExcel->getActiveSheet()->setCellValue('Z1', $LabelsArray[3]);
            $objPHPExcel->getActiveSheet()->setCellValue('AA1', $LabelsArray[2]);
            $objPHPExcel->getActiveSheet()->setCellValue('AB1', $LabelsArray[1]);
            // Add data
            $i = 2;
            while ($myrow = DB_fetch_array($result)) {
                $objPHPExcel->setActiveSheetIndex(0);
                $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $myrow['codeexpense']);
                $objPHPExcel->getActiveSheet()->setCellValue('B' . $i, $myrow['description']);
                $objPHPExcel->getActiveSheet()->setCellValue('C' . $i, '=SUM(Q' . $i . ':AB' . $i . ')');
                $objPHPExcel->getActiveSheet()->setCellValue('D' . $i, '=AVERAGE(Q' . $i . ':AB' . $i . ')');
                $objPHPExcel->getActiveSheet()->setCellValue('E' . $i, -$myrow['expense_period24']);
                $objPHPExcel->getActiveSheet()->setCellValue('F' . $i, -$myrow['expense_period23']);
                $objPHPExcel->getActiveSheet()->setCellValue('G' . $i, -$myrow['expense_period22']);
                $objPHPExcel->getActiveSheet()->setCellValue('H' . $i, -$myrow['expense_period21']);
                $objPHPExcel->getActiveSheet()->setCellValue('I' . $i, -$myrow['expense_period20']);
                $objPHPExcel->getActiveSheet()->setCellValue('J' . $i, -$myrow['expense_period19']);
                $objPHPExcel->getActiveSheet()->setCellValue('K' . $i, -$myrow['expense_period18']);
                $objPHPExcel->getActiveSheet()->setCellValue('L' . $i, -$myrow['expense_period17']);
                $objPHPExcel->getActiveSheet()->setCellValue('M' . $i, -$myrow['expense_period16']);
                $objPHPExcel->getActiveSheet()->setCellValue('N' . $i, -$myrow['expense_period15']);
                $objPHPExcel->getActiveSheet()->setCellValue('O' . $i, -$myrow['expense_period14']);
                $objPHPExcel->getActiveSheet()->setCellValue('P' . $i, -$myrow['expense_period13']);
                $objPHPExcel->getActiveSheet()->setCellValue('Q' . $i, -$myrow['expense_period12']);
                $objPHPExcel->getActiveSheet()->setCellValue('R' . $i, -$myrow['expense_period11']);
                $objPHPExcel->getActiveSheet()->setCellValue('S' . $i, -$myrow['expense_period10']);
                $objPHPExcel->getActiveSheet()->setCellValue('T' . $i, -$myrow['expense_period9']);
                $objPHPExcel->getActiveSheet()->setCellValue('U' . $i, -$myrow['expense_period8']);
                $objPHPExcel->getActiveSheet()->setCellValue('V' . $i, -$myrow['expense_period7']);
                $objPHPExcel->getActiveSheet()->setCellValue('W' . $i, -$myrow['expense_period6']);
                $objPHPExcel->getActiveSheet()->setCellValue('X' . $i, -$myrow['expense_period5']);
                $objPHPExcel->getActiveSheet()->setCellValue('Y' . $i, -$myrow['expense_period4']);
                $objPHPExcel->getActiveSheet()->setCellValue('Z' . $i, -$myrow['expense_period3']);
                $objPHPExcel->getActiveSheet()->setCellValue('AA' . $i, -$myrow['expense_period2']);
                $objPHPExcel->getActiveSheet()->setCellValue('AB' . $i, -$myrow['expense_period1']);
                $i++;
            }
            // Freeze panes
            $objPHPExcel->getActiveSheet()->freezePane('E2');
            // Auto Size columns
            foreach (range('A', 'AB') as $columnID) {
                $objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
            }
            // Rename worksheet
            if ($TabToShow == 'All') {
                $objPHPExcel->getActiveSheet()->setTitle('All Accounts');
            } else {
                $objPHPExcel->getActiveSheet()->setTitle($TabToShow);
            }
            // Set active sheet index to the first sheet, so Excel opens this as the first sheet
            $objPHPExcel->setActiveSheetIndex(0);
            // Redirect output to a client’s web browser (Excel2007)
            header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
            $File = 'PCExpensesAnalysis-' . Date('Y-m-d') . '.xlsx';
            header('Content-Disposition: attachment;filename="' . $File . '"');
            header('Cache-Control: max-age=0');
            // If you're serving to IE 9, then the following may be needed
            header('Cache-Control: max-age=1');
            // If you're serving to IE over SSL, then the following may be needed
            header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
            // Date in the past
            header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
            // always modified
            header('Cache-Control: cache, must-revalidate');
            // HTTP/1.1
            header('Pragma: public');
            // HTTP/1.0
            $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
            $objWriter->save('php://output');
        } else {
            $Title = _('Excel file for petty Cash Expenses Analysis');
            include 'includes/header.inc';
            prnMsg('No data to analyse');
            include 'includes/footer.inc';
        }
    }
}
Example #18
0
             if (count($course_weights_RET[$value['COURSE_ID']])) {
                 foreach ($course_weights_RET[$value['COURSE_ID']] as $weight) {
                     $select_html[$key] .= "<OPTION value='" . $weight['COURSE_WEIGHT'] . "'" . ($value['COURSE_WEIGHT'] == $weight['COURSE_WEIGHT'] ? ' SELECTED' : '') . ">" . $weight['COURSE_WEIGHT'] . "</OPTION>";
                 }
             }
             $select_html[$key] .= "</SELECT></TD>";
             $with_teachers = $with_periods = $without_teachers = $without_periods = '';
             $teachers_done = $periods_done = array();
             foreach ($periods_RET[$value['COURSE_ID']][$value['COURSE_WEIGHT']] as $period) {
                 if (!$teachers_done[$period['TEACHER_ID']]) {
                     $with_teachers .= "<OPTION value=" . $period['TEACHER_ID'] . " " . ($value['WITH_TEACHER_ID'] == $period['TEACHER_ID'] ? ' SELECTED' : '') . ">" . GetTeacher($period['TEACHER_ID']) . "</OPTION>";
                     $without_teachers .= "<OPTION value=" . $period['TEACHER_ID'] . " " . ($value['NOT_TEACHER_ID'] == $period['TEACHER_ID'] ? ' SELECTED' : '') . ">" . GetTeacher($period['TEACHER_ID']) . "</OPTION>";
                 }
                 if (!$periods_done[$period['PERIOD_ID']]) {
                     $with_periods .= "<OPTION value=" . $period['PERIOD_ID'] . " " . ($value['WITH_PERIOD_ID'] == $period['PERIOD_ID'] ? ' SELECTED' : '') . ">" . GetPeriod($period['PERIOD_ID']) . '</OPTION>';
                     $without_periods .= "<OPTION value=" . $period['PERIOD_ID'] . " " . ($value['NOT_PERIOD_ID'] == $period['PERIOD_ID'] ? ' SELECTED' : '') . ">" . GetPeriod($period['PERIOD_ID']) . '</OPTION>';
                 }
                 $periods_done[$period['PERIOD_ID']] = true;
                 $teachers_done[$period['TEACHER_ID']] = true;
             }
             $select_html[$key] .= "<TD><TABLE><TR><TD>With</TD><TD><SELECT name=with_teacher[{$key}][]><OPTION value=''>Not Specified</OPTION>" . $with_teachers . "</SELECT></TD><TD><SELECT name=with_period[{$key}][]><OPTION value=''>Not Specified</OPTION>" . $with_periods . "</TD></TR><TR><TR><TD>Without</TD><TD><SELECT name=without_teacher[{$key}][]><OPTION value=''>Not Specified</OPTION>" . $without_teachers . "</SELECT></TD><TD><SELECT name=without_period[{$key}][]><OPTION value=''>Not Specified</OPTION>" . $without_periods . "</TD></TR></TABLE></TD>";
             $select_html[$key] .= "</TR></TABLE>";
         }
     }
 }
 echo "<BR><TABLE>";
 if (count($subjects_RET)) {
     foreach ($subjects_RET as $key => $value) {
         echo "<TR><TD>" . button('add', '', "# onclick='javascript:addHTML(html_{$key},{$key}); return false;'") . "<TD><b>" . $value[1][TITLE] . "</b></TD></TR>";
         echo "<TR><TD></TD><TD>";
         if ($select_html[$key]) {
Example #19
0
     echo '<br />' . _('Row:') . $Row . ' - ' . _('Invalid asset location code:') . ' ' . $AssetLocationCode;
 }
 if (!Is_Date($DatePurchased)) {
     $InputError = true;
     prnMsg(_('The date purchased must be entered in the format:') . ' ' . $_SESSION['DefaultDateFormat'], 'error');
     echo '<br />' . _('Row:') . $Row . ' - ' . _('Invalid date format:') . ' ' . $DatePurchased;
 }
 if ($DepnType == 'DV') {
     $DepnType = 1;
 } else {
     $DepnType = 0;
 }
 if ($InputError == false) {
     //no errors
     $TransNo = GetNextTransNo(49, $db);
     $PeriodNo = GetPeriod(ConvertSQLDate($_POST['DateToEnter']), $db);
     //attempt to insert the stock item
     $sql = "INSERT INTO fixedassets (description,\n\t\t\t\t\t\t\t\t\t\t\tlongdescription,\n\t\t\t\t\t\t\t\t\t\t\tassetcategoryid,\n\t\t\t\t\t\t\t\t\t\t\tserialno,\n\t\t\t\t\t\t\t\t\t\t\tbarcode,\n\t\t\t\t\t\t\t\t\t\t\tassetlocation,\n\t\t\t\t\t\t\t\t\t\t\tcost,\n\t\t\t\t\t\t\t\t\t\t\taccumdepn,\n\t\t\t\t\t\t\t\t\t\t\tdepntype,\n\t\t\t\t\t\t\t\t\t\t\tdepnrate,\n\t\t\t\t\t\t\t\t\t\t\tdatepurchased)\n\t\t\t\t\t\t\tVALUES ('" . $Description . "',\n\t\t\t\t\t\t\t\t\t'" . $LongDescription . "',\n\t\t\t\t\t\t\t\t\t'" . $AssetCategoryID . "',\n\t\t\t\t\t\t\t\t\t'" . $SerialNo . "',\n\t\t\t\t\t\t\t\t\t'" . $BarCode . "',\n\t\t\t\t\t\t\t\t\t'" . $AssetLocationCode . "',\n\t\t\t\t\t\t\t\t\t'" . $Cost . "',\n\t\t\t\t\t\t\t\t\t'" . $AccumDepn . "',\n\t\t\t\t\t\t\t\t\t'" . $DepnType . "',\n\t\t\t\t\t\t\t\t\t'" . $DepnRate . "',\n\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($DatePurchased) . "')";
     $ErrMsg = _('The asset could not be added because');
     $DbgMsg = _('The SQL that was used to add the asset and failed was');
     $result = DB_query($sql, $db, $ErrMsg, $DbgMsg);
     if (DB_error_no($db) == 0) {
         //the insert of the new code worked so bang in the fixedassettrans records too
         $AssetID = DB_Last_Insert_ID($db, 'fixedassets', 'assetid');
         $sql = "INSERT INTO fixedassettrans ( assetid,\n\t\t\t\t\t\t\t\t\t\t\t\ttranstype,\n\t\t\t\t\t\t\t\t\t\t\t\ttransno,\n\t\t\t\t\t\t\t\t\t\t\t\ttransdate,\n\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\tinputdate,\n\t\t\t\t\t\t\t\t\t\t\t\tfixedassettranstype,\n\t\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\tVALUES ( '" . $AssetID . "',\n\t\t\t\t\t\t\t\t\t\t\t'49',\n\t\t\t\t\t\t\t\t\t\t\t'" . $TransNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['DateToEnter'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t\t\t\t\t'cost',\n\t\t\t\t\t\t\t\t\t\t\t'" . $Cost . "')";
         $ErrMsg = _('The transaction for the cost of the asset could not be added because');
         $DbgMsg = _('The SQL that was used to add the fixedasset trans record that failed was');
         $InsResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
         $sql = "INSERT INTO fixedassettrans ( assetid,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttranstype,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttransno,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttransdate,\n\t\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\t\tinputdate,\n\t\t\t\t\t\t\t\t\t\t\t\t\tfixedassettranstype,\n\t\t\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\tVALUES ( '" . $AssetID . "',\n\t\t\t\t\t\t\t\t\t\t\t'49',\n\t\t\t\t\t\t\t\t\t\t\t'" . $TransNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['DateToEnter'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t\t\t\t\t'depn',\n\t\t\t\t\t\t\t\t\t\t\t'" . $AccumDepn . "')";
         $ErrMsg = _('The transaction for the cost of the asset could not be added because');
         $DbgMsg = _('The SQL that was used to add the fixedasset trans record that failed was');
         if ($_SESSION['Care2xDatabase'] != 'None') {
             $SQL = "UPDATE " . $_SESSION['Care2xDatabase'] . ".care_encounter_prescription SET bill_number='" . $OrderNo . "'\n\t\t\t\t\t\t\t\tWHERE nr='" . $_SESSION['Items'][$i]['Care2x'] . "'";
             $DbgMsg = _('Trouble inserting a line of a sales order. The SQL that failed was');
             $UpdateCare2xResult = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
         }
     }
 }
 if (isset($_POST['Doctor'])) {
     $SuppInvoiceNumber = GetNextTransNo(20, $db);
     $DoctorsInvoiceSQL = "INSERT INTO supptrans (transno,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsupplierno,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsuppreference,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tduedate,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinputdate,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsettled,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\trate,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tovamount,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tovgst,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdiffonexch,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\talloc,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttranstext,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\thold,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid)\n\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $SuppInvoiceNumber . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'20',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['Doctor'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'1',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['DoctorsFee'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['Doctor'] . ' ' . _('fee') . ' ' . _('for patient') . ' ' . $_POST['PatientNo'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t''\n\t\t\t\t\t\t\t\t\t\t\t\t\t)";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The doctors transaction record could not be inserted because');
     $DbgMsg = _('The following SQL to insert the doctors transaction record was used');
     $Result = DB_query($DoctorsInvoiceSQL, $db, $ErrMsg, $DbgMsg, true);
 }
 $InvoiceNo = GetNextTransNo(10, $db);
 $PeriodNo = GetPeriod($_POST['AdmissionDate'], $db);
 if (isset($_POST['SubmitInsurance'])) {
     $_POST['Received'] = 0;
 } else {
     $_POST['InsuranceRef'] = '';
 }
 $sql = "INSERT INTO debtortrans (\n\t\t\t\ttransno,\n\t\t\t\ttype,\n\t\t\t\tdebtorno,\n\t\t\t\tbranchcode,\n\t\t\t\ttrandate,\n\t\t\t\tinputdate,\n\t\t\t\tprd,\n\t\t\t\torder_,\n\t\t\t\tovamount,\n\t\t\t\tovgst,\n\t\t\t\trate,\n\t\t\t\tinvtext,\n\t\t\t\treference,\n\t\t\t\tshipvia,\n\t\t\t\talloc )\n\t\t\tVALUES (\n\t\t\t\t'" . $InvoiceNo . "',\n\t\t\t\t10,\n\t\t\t\t'" . $_POST['PatientNo'] . "',\n\t\t\t\t'" . $_POST['BranchNo'] . "',\n\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t'" . $OrderNo . "',\n\t\t\t\t'" . $_SESSION['Items']['Value'] . "',\n\t\t\t\t'0',\n\t\t\t\t'1',\n\t\t\t\t'" . _('Invoice for radiology test of Patient number') . ' ' . $_POST['PatientNo'] . "',\n\t\t\t\t'" . $_POST['InsuranceRef'] . "',\n\t\t\t\t'1',\n\t\t\t\t'" . filter_currency_input($_POST['Received']) . "')";
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The debtor transaction record could not be inserted because');
 $DbgMsg = _('The following SQL to insert the debtor transaction record was used');
 $Result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true);
 for ($i = 0; $i < $_SESSION['Items']['Lines']; $i++) {
     if (isset($_SESSION['Items'][$i]['StockID'])) {
         $SQL = "INSERT INTO stockmoves (\n\t\t\t\t\t\tstockid,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\ttransno,\n\t\t\t\t\t\tloccode,\n\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\tdebtorno,\n\t\t\t\t\t\tbranchcode,\n\t\t\t\t\t\tprd,\n\t\t\t\t\t\treference,\n\t\t\t\t\t\tqty,\n\t\t\t\t\t\tprice,\n\t\t\t\t\t\tshow_on_inv_crds,\n\t\t\t\t\t\tnewqoh\n\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t'" . $_SESSION['Items'][$i]['StockID'] . "',\n\t\t\t\t\t\t 10,\n\t\t\t\t\t\t'" . $InvoiceNo . "',\n\t\t\t\t\t\t'" . $_SESSION['UserStockLocation'] . "',\n\t\t\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t\t\t'" . $_POST['PatientNo'] . "',\n\t\t\t\t\t\t'" . $_POST['BranchNo'] . "',\n\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t'" . _('Invoice for radiology test of Patient number') . ' ' . $_POST['PatientNo'] . "',\n\t\t\t\t\t\t-1,\n\t\t\t\t\t\t'" . $_SESSION['Items'][$i]['Price'] . "',\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t0\n\t\t\t\t\t)";
         $BaseStockID = $_SESSION['Items'][$i]['StockID'];
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Stock movement records for') . ' ' . $_POST['StockID'] . ' ' . _('could not be inserted because');
         $DbgMsg = _('The following SQL to insert the stock movement records was used');
Example #21
0
         if ($GetQOH[0] < $SerialStockMoves['moveqty']) {
             /*Then some of the original goods received must have been sold
             		or transfered so cannot reverse the GRN */
             prnMsg(_('Unfortunately, of the original number') . ' (' . $SerialStockMoves['moveqty'] . ') ' . _('that were received on serial number') . ' ' . $SerialStockMoves['serialno'] . ' ' . _('only') . ' ' . $GetQOH[0] . ' ' . _('remain') . '. ' . _('The GRN can only be reversed if all the original serial number items are still in stock in the location they were received into'), 'error');
             include 'includes/footer.inc';
             exit;
         }
     }
     /*reset the pointer on this resultset ... will need it later */
     DB_data_seek($GetStockMoveResult, 0);
 } else {
     $Controlled = false;
 }
 /*Start an SQL transaction */
 $Result = DB_Txn_Begin($db);
 $PeriodNo = GetPeriod(ConvertSQLDate($GRN['deliverydate']), $db);
 /*Now the SQL to do the update to the PurchOrderDetails */
 $SQL = "UPDATE purchorderdetails\n\t\t\t\t\t\tSET quantityrecd = quantityrecd - '" . $QtyToReverse . "',\n\t\t\t\t\t\tcompleted=0\n\t\t\t\t\t\tWHERE purchorderdetails.podetailitem = '" . $GRN['podetailitem'] . "'";
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The purchase order detail record could not be updated with the quantity reversed because');
 $DbgMsg = _('The following SQL to update the purchase order detail record was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 /*Now the purchorder header status in case it was completed  - now incomplete - just printed */
 $SQL = "UPDATE purchorders\n\t\t\t\t\tSET status = 'Printed',\n\t\t\t\t\t\t\tstat_comment = CONCAT('" . Date($_SESSION['DefaultDateFormat']) . ' ' . _('GRN Reversed for') . ' ' . $GRN['itemdescription'] . ' ' . _('by') . ' ' . $_SESSION['UsersRealName'] . "<br />', stat_comment )\n\t\t\t\t\tWHERE  orderno = '" . $GRN['orderno'] . "'";
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The purchase order statusand status comment could not be changed because');
 $DbgMsg = _('The following SQL to update the purchase order header record was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 /*Need to update or delete the existing GRN item */
 if ($QtyToReverse == $GRN['qtyrecd']) {
     //then ok to delete the whole thing
     /* if this is not deleted then the purchorderdetail line cannot be deleted subsequentely */
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GRN record could not be deleted because');
Example #22
0
        include 'includes/footer.inc';
        exit;
    }
    /*Make an array of the defined bank accounts */
    $SQL = 'SELECT bankaccounts.accountcode
			FROM bankaccounts,
				chartmaster
		WHERE bankaccounts.accountcode=chartmaster.accountcode';
    $result = DB_query($SQL, $db);
    $BankAccounts = array();
    $i = 0;
    while ($Act = DB_fetch_row($result)) {
        $BankAccounts[$i] = $Act[0];
        $i++;
    }
    $PeriodNo = GetPeriod($_SESSION['PaymentDetail']->DatePaid, $db);
    // first time through commit if supplier cheque then print it first
    if (!isset($_POST['ChequePrinted']) and !isset($_POST['PaymentCancelled']) and $_SESSION['PaymentDetail']->Paymenttype == 'Cheque') {
        // it is a supplier payment by cheque and haven't printed yet so print cheque
        echo '<br><a href="' . $rootpath . '/PrintCheque.php?' . SID . '&ChequeNum=' . $_POST['ChequeNum'] . '">' . _('Print Cheque using pre-printed stationery') . '</a><br><br>';
        echo '<form method=post action="' . $_SERVER['PHP_SELF'] . '">';
        echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
        echo _('Has the cheque been printed') . '?<br><br>';
        echo '<input type="hidden" name="CommitBatch" VALUE="' . $_POST['CommitBatch'] . '">';
        echo '<input type="submit" name="ChequePrinted" VALUE="' . _('Yes / Continue') . '">&nbsp;&nbsp;';
        echo '<input type="submit" name="PaymentCancelled" VALUE="' . _('No / Cancel Payment') . '">';
    } else {
        //Start a transaction to do the whole lot inside
        $SQL = 'BEGIN';
        $result = DB_query($SQL, $db);
        if ($_SESSION['PaymentDetail']->SupplierID == '') {
    $_POST['SelectADifferentPeriod'] = _('Select A Different Period');
}
if (!isset($_POST['FromPeriod']) and !isset($_POST['ToPeriod']) or isset($_POST['SelectADifferentPeriod'])) {
    include 'includes/header.inc';
    echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Trial Balance') . '" alt="" />' . ' ' . $title . '</p>';
    echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">';
    echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
    if (Date('m') > $_SESSION['YearEnd']) {
        /*Dates in SQL format */
        $DefaultFromDate = Date('Y-m-d', Mktime(0, 0, 0, $_SESSION['YearEnd'] + 2, 0, Date('Y')));
        $FromDate = Date($_SESSION['DefaultDateFormat'], Mktime(0, 0, 0, $_SESSION['YearEnd'] + 2, 0, Date('Y')));
    } else {
        $DefaultFromDate = Date('Y-m-d', Mktime(0, 0, 0, $_SESSION['YearEnd'] + 2, 0, Date('Y') - 1));
        $FromDate = Date($_SESSION['DefaultDateFormat'], Mktime(0, 0, 0, $_SESSION['YearEnd'] + 2, 0, Date('Y') - 1));
    }
    $period = GetPeriod($FromDate, $db);
    /*Show a form to allow input of criteria for TB to show */
    echo '<table class="selection"><tr><td>' . _('Select Period From:') . '</td><td><select name="FromPeriod">';
    $nextYear = date('Y-m-d', strtotime('+1 Year'));
    $sql = "SELECT periodno,\n\t\t\t\t\tlastdate_in_period\n\t\t\t\tFROM periods\n\t\t\t\tWHERE lastdate_in_period < '" . $nextYear . "'\n\t\t\t\tORDER BY periodno DESC";
    $Periods = DB_query($sql, $db);
    while ($myrow = DB_fetch_array($Periods, $db)) {
        if (isset($_POST['FromPeriod']) and $_POST['FromPeriod'] != '') {
            if ($_POST['FromPeriod'] == $myrow['periodno']) {
                echo '<option selected="True" value="' . $myrow['periodno'] . '">' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']) . '</option>';
            } else {
                echo '<option value="' . $myrow['periodno'] . '">' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']) . '</option>';
            }
        } else {
            if ($myrow['lastdate_in_period'] == $DefaultFromDate) {
                echo '<option selected="True" value="' . $myrow['periodno'] . '">' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']) . '</option>';
    echo '<tr>
		<th>' . _('Date') . '</th>
		<th>' . _('Expense Code') . '</th>
		<th>' . _('Amount') . '</th>
		<th>' . _('Posted') . '</th>
		<th>' . _('Notes') . '</th>
		<th>' . _('Receipt') . '</th>
		<th>' . _('Authorised') . '</th>
	</tr>';
    $k = 0;
    //row colour counter
    while ($myrow = DB_fetch_array($result)) {
        $CurrDecimalPlaces = $myrow['decimalplaces'];
        //update database if update pressed
        if (isset($_POST['Submit']) and $_POST['Submit'] == _('Update') and isset($_POST[$myrow['counterindex']])) {
            $PeriodNo = GetPeriod(ConvertSQLDate($myrow['date']), $db);
            if ($myrow['rate'] == 1) {
                // functional currency
                $Amount = $myrow['amount'];
            } else {
                // other currencies
                $Amount = $myrow['amount'] / $myrow['rate'];
            }
            if ($myrow['codeexpense'] == 'ASSIGNCASH') {
                $type = 2;
                $AccountFrom = $myrow['glaccountassignment'];
                $AccountTo = $myrow['glaccountpcash'];
                $TagTo = 0;
            } else {
                $type = 1;
                $Amount = -$Amount;
/* $Id$*/
include 'includes/DefineSerialItems.php';
include 'includes/DefineStockTransfers.php';
include 'includes/session.inc';
$title = _('Inventory Transfer') . ' - ' . _('Receiving');
include 'includes/header.inc';
include 'includes/SQL_CommonFunctions.inc';
if (isset($_GET['NewTransfer'])) {
    unset($_SESSION['Transfer']);
}
if (isset($_SESSION['Transfer']) and $_SESSION['Transfer']->TrfID == '') {
    unset($_SESSION['Transfer']);
}
if (isset($_POST['ProcessTransfer'])) {
    /*Ok Time To Post transactions to Inventory Transfers, and Update Posted variable & received Qty's  to LocTransfers */
    $PeriodNo = GetPeriod($_SESSION['Transfer']->TranDate, $db);
    $SQLTransferDate = FormatDateForSQL($_SESSION['Transfer']->TranDate);
    $InputError = False;
    /*Start off hoping for the best */
    $i = 0;
    $TotalQuantity = 0;
    foreach ($_SESSION['Transfer']->TransferItem as $TrfLine) {
        $_POST['Qty' . $i] = filter_number_input($_POST['Qty' . $i]);
        if (is_numeric($_POST['Qty' . $i])) {
            /*Update the quantity received from the inputs */
            $_SESSION['Transfer']->TransferItem[$i]->Quantity = $_POST['Qty' . $i];
        } else {
            prnMsg(_('The quantity entered for') . ' ' . $TrfLine->StockID . ' ' . _('is not numeric') . '. ' . _('All quantities must be numeric'), 'error');
            $InputError = True;
        }
        if ($_POST['Qty' . $i] < 0) {
    $AllowUserEnteredProcessDate = false;
    $_POST['ProcessDate'] = LastDayOfMonth(DateAdd(ConvertSQLDate($LastDepnRun[0]), 'd', 28));
}
/* Get list of assets for journal */
$sql = "SELECT fixedassets.assetid,\n\t\t\tfixedassets.description,\n\t\t\tfixedassets.depntype,\n\t\t\tfixedassets.depnrate,\n\t\t\tfixedassets.datepurchased,\n\t\t\tfixedassetcategories.accumdepnact,\n\t\t\tfixedassetcategories.depnact,\n\t\t\tfixedassetcategories.categorydescription,\n\t\t\tSUM(CASE WHEN fixedassettrans.fixedassettranstype='cost' THEN fixedassettrans.amount ELSE 0 END) AS costtotal,\n\t\t\tSUM(CASE WHEN fixedassettrans.fixedassettranstype='depn' THEN fixedassettrans.amount ELSE 0 END) AS depnbfwd\n\t\tFROM fixedassets\n\t\tINNER JOIN fixedassetcategories\n\t\t\tON fixedassets.assetcategoryid=fixedassetcategories.categoryid\n\t\tINNER JOIN fixedassettrans\n\t\t\tON fixedassets.assetid=fixedassettrans.assetid\n\t\tWHERE fixedassettrans.transdate<='" . FormatDateForSQL($_POST['ProcessDate']) . "'\n\t\tGROUP BY fixedassets.assetid,\n\t\t\tfixedassets.description,\n\t\t\tfixedassets.depntype,\n\t\t\tfixedassets.depnrate,\n\t\t\tfixedassets.datepurchased,\n\t\t\tfixedassetcategories.accumdepnact,\n\t\t\tfixedassetcategories.depnact,\n\t\t\tfixedassetcategories.categorydescription\n\t\tORDER BY assetcategoryid, assetid";
$AssetsResult = DB_query($sql, $db);
$InputError = false;
//always hope for the best
if (Date1GreaterThanDate2($_POST['ProcessDate'], Date($_SESSION['DefaultDateFormat']))) {
    prnMsg(_('No depreciation will be committed as the processing date is beyond the current date. The depreciation run can only be run for periods prior to today'), 'warn');
    $InputError = true;
}
if (isset($_POST['CommitDepreciation']) and $InputError == false) {
    $result = DB_Txn_Begin($db);
    $TransNo = GetNextTransNo(44, $db);
    $PeriodNo = GetPeriod($_POST['ProcessDate'], $db);
}
echo '<br /><table>';
$Heading = '<tr>
				<th>' . _('Asset ID') . '</th>
				<th>' . _('Description') . '</th>
				<th>' . _('Date Purchased') . '</th>
				<th>' . _('Cost') . '</th>
				<th>' . _('Accum Depn') . '</th>
				<th>' . _('B/fwd Book Value') . '</th>
				<th>' . _('Depn Type') . '</th>
				<th>' . _('Depn Rate') . '</th>
				<th>' . _('New Depn') . '</th>
			</tr>';
echo $Heading;
$AssetCategoryDescription = '0';
 } elseif (DateDiff(Date($_SESSION['DefaultDateFormat']), $_SESSION['SuppTrans']->TranDate, 'd') < 0) {
     $InputError = True;
     prnMsg(_('The credit note as entered cannot be processed because the date is after today') . '. ' . _('Purchase credit notes are expected to have a date prior to or today'), 'error');
 } elseif ($_SESSION['SuppTrans']->ExRate <= 0) {
     $InputError = True;
     prnMsg(_('The credit note as entered cannot be processed because the exchange rate for the credit note has been entered as a negative or zero number') . '. ' . _('The exchange rate is expected to show how many of the suppliers currency there are in 1 of the local currency'), 'warn');
 } elseif ($_SESSION['SuppTrans']->OvAmount < round($TotalShiptValue + $TotalGLValue + $TotalAssetValue + $TotalGRNValue, $_SESSION['SuppTrans']->CurrDecimalPlaces)) {
     prnMsg(_('The credit note total as entered is less than the sum of the shipment charges') . ', ' . _('the general ledger entries (if any) and the charges for goods received') . '. ' . _('There must be a mistake somewhere') . ', ' . _('the credit note as entered will not be processed'), 'error');
     $InputError = True;
 } else {
     /* SQL to process the postings for purchase credit note */
     /*Start an SQL transaction */
     DB_Txn_Begin($db);
     /*Get the next transaction number for internal purposes and the period to post GL transactions in based on the credit note date*/
     $CreditNoteNo = GetNextTransNo(21, $db);
     $PeriodNo = GetPeriod($_SESSION['SuppTrans']->TranDate, $db);
     $SQLCreditNoteDate = FormatDateForSQL($_SESSION['SuppTrans']->TranDate);
     if ($_SESSION['SuppTrans']->GLLink_Creditors == 1) {
         /*Loop through the GL Entries and create a debit posting for each of the accounts entered */
         $LocalTotal = 0;
         /*the postings here are a little tricky, the logic goes like this:
         
         			> if its a shipment entry then the cost must go against the GRN suspense account defined in the company record
         
         			> if its a general ledger amount it goes straight to the account specified
         
         			> if its a GRN amount credited then there are two possibilities:
         
         			1 The PO line is on a shipment.
         			The whole charge goes to the GRN suspense account pending the closure of the
         			shipment where the variance is calculated on the shipment as a whole and the clearing entry to the GRN suspense
Example #28
0
function _makeExtra($value, $title = '')
{
    global $THIS_RET;
    if ($THIS_RET['WITH_TEACHER_ID']) {
        $return .= 'With:&nbsp;' . GetTeacher($THIS_RET['WITH_TEACHER_ID']) . '<BR>';
    }
    if ($THIS_RET['NOT_TEACHER_ID']) {
        $return .= 'Not With:&nbsp;' . GetTeacher($THIS_RET['NOT_TEACHER_ID']) . '<BR>';
    }
    if ($THIS_RET['WITH_PERIOD_ID']) {
        $return .= 'On:&nbsp;' . GetPeriod($THIS_RET['WITH_PERIOD_ID']) . '<BR>';
    }
    if ($THIS_RET['NOT_PERIOD_ID']) {
        $return .= 'Not On:&nbsp;' . GetPeriod($THIS_RET['NOT_PERIOD_ID']) . '<BR>';
    }
    if ($THIS_RET['PRIORITY']) {
        $return .= 'Priority:&nbsp;' . $THIS_RET['PRIORITY'] . '<BR>';
    }
    if ($THIS_RET['MARKING_PERIOD_ID']) {
        $return .= 'Marking Period:&nbsp;' . GetMP($THIS_RET['MARKING_PERIOD_ID']) . '<BR>';
    }
    return $return;
}
         echo '<br>' . _('Orig order for') . ' ' . $myrow['orderlineno'] . ' ' . _('has a quantity of') . ' ' . $myrow['quantity'] . ' ' . _('and an invoiced qty of') . ' ' . $myrow['qtyinvoiced'] . ' ' . _('the session shows quantity of') . ' ' . $_SESSION['Items']->LineItems[$myrow['orderlineno']]->Quantity . ' ' . _('and quantity invoice of') . ' ' . $_SESSION['Items']->LineItems[$myrow['orderlineno']]->QtyInv;
         prnMsg(_('This order has been changed or invoiced since this delivery was started to be confirmed') . ' ' . _('Processing halted.') . ' ' . _('To enter and confirm this dispatch, it must be re-selected and re-read again to update the changes made by the other user'), 'error');
         echo '<br>';
         echo '<div class="centre"><a href="' . $rootpath . '/SelectSalesOrder.php?' . SID . '">' . _('Select a sales order for confirming deliveries and invoicing') . '</a></div>';
         unset($_SESSION['Items']->LineItems);
         unset($_SESSION['Items']);
         unset($_SESSION['ProcessingOrder']);
         include 'includes/footer.inc';
         exit;
     }
 }
 /*loop through all line items of the order to ensure none have been invoiced since started looking at this order*/
 DB_free_result($Result);
 /*Now Get the next invoice number - function in SQL_CommonFunctions*/
 $InvoiceNo = GetNextTransNo(10, $db);
 $PeriodNo = GetPeriod($DefaultDispatchDate, $db);
 /*Start an SQL transaction */
 DB_Txn_Begin($db);
 if ($DefaultShipVia != $_SESSION['Items']->ShipVia) {
     $SQL = "UPDATE custbranch SET defaultshipvia ='" . $_SESSION['Items']->ShipVia . "' WHERE debtorno='" . $_SESSION['Items']->DebtorNo . "' AND branchcode='" . $_SESSION['Items']->Branch . "'";
     $ErrMsg = _('Could not update the default shipping carrier for this branch because');
     $DbgMsg = _('The SQL used to update the branch default carrier was');
     $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 }
 $DefaultDispatchDate = FormatDateForSQL($DefaultDispatchDate);
 /*Update order header for invoice charged on */
 $SQL = "UPDATE salesorders SET comments = CONCAT(comments,' Inv ','" . $InvoiceNo . "') WHERE orderno= " . $_SESSION['ProcessingOrder'];
 $ErrMsg = _('CRITICAL ERROR') . ' ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales order header could not be updated with the invoice number');
 $DbgMsg = _('The following SQL to update the sales order was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 /*Now insert the DebtorTrans */
Example #30
0
     $InputError = 1;
     prnMsg(_('approved By field cannot be empty'), 'error');
     $Errors[$i] = 'approver';
     $i++;
 }
 if ($_POST['entryDate'] == "") {
     $InputError = 1;
     prnMsg(_('entryDate field cannot be empty'), 'error');
     $Errors[$i] = 'dateEntered';
     $i++;
 }
 if ($InputError != 1) {
     if (!Is_Date($_SESSION['DateBanked'])) {
         $_SESSION['DateBanked'] = Date($_SESSION['DefaultDateFormat']);
     }
     $PeriodNo = GetPeriod($_SESSION['DateBanked'], $db);
     $TransNo = GetNextTransNo(0, $db);
     $SQL_entryDate = FormatDateForSQL($_POST['entryDate']);
     if (!isset($_POST['New'])) {
         $sql = "SELECT amount,transaction_type FROM  banking WHERE banking_id='{$bankingID}'";
         $result = DB_query($sql, $db);
         $myrow = DB_fetch_row($result);
         $initialAmountPaid = $myrow[0];
         $previousTransactionType = $myrow[1];
         $sql = "UPDATE banking SET\t\t\t\n\t\t\tentryDate='{$SQL_entryDate}',\n\t\t\tbank_account_code='" . DB_escape_string($_POST['bankAccountCode']) . "',\n\t\t\tamount='" . DB_escape_string($_POST['amount']) . "',\n\t\t\tpayment_mode='" . DB_escape_string($_POST['paymentMode']) . "',\n\t\t\tapproved_by='" . DB_escape_string($_POST['approvedBy']) . "',\n\t\t\tcomment='" . DB_escape_string($_POST['comment']) . "'\n            WHERE banking_id = '{$bankingID}'";
         $ErrMsg = _('The record could not be updated because');
         $DbgMsg = _('The SQL that was used to update the member saving but failed was');
         $result = DB_query($sql, $db, $ErrMsg, $DbgMsg);
         prnMsg(_('The record for') . ' ' . $bankingID . ' ' . _('has been updated'), 'success');
         $difference = $initialAmountPaid - $_POST['amount'];
         if ($previousTransactionType == 1) {