function createDayView($mday, $month, $year, $view_diary) { // generate the previous day link data (for _GET) if ($mday == 1) { if ($month == 1) { $tmpmonth = 12; $tmpyear = $year - 1; } else { $tmpmonth = $month - 1; $tmpyear = $year; } $tmpday = getDaysInMonth($tmpmonth, $tmpyear); } else { $tmpday = $mday - 1; $tmpmonth = $month; $tmpyear = $year; } $prevlink = "mday={$tmpday}&month={$tmpmonth}&year={$tmpyear}"; // generate the next day link data (for _GET) if ($mday == getDaysInMonth($month, $year)) { if ($month == 12) { $tmpmonth = 1; $tmpyear++; } else { $tmpmonth = $month + 1; $tmpyear = $year; } $tmpday = 1; } else { $tmpday = $mday + 1; $tmpmonth = $month; $tmpyear = $year; } $nextlink = "mday={$tmpday}&month={$tmpmonth}&year={$tmpyear}"; // create the output of the header (with date, and previous and next buttons $OUTPUT = "\r\n\t\t<table width='550' cellspacing=0 cellpadding=0>\r\n\t\t\t<tr><td align=center valign=top " . TMPL_calTimeStyle2 . ">\r\n\t\t\t\t<table width='100%' cellspacing=0 cellpadding=0>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td valign=middle align=center width='30%'>\r\n\t\t\t\t\t\t\t<a href='" . SELF . "?{$prevlink}'><img border=0 src='left_day.gif' align=right></a>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t<td nowrap valign=middle align=center " . TMPL_calTimeStyleHeader . " width='40%'>\r\n\t\t\t\t\t\t\t" . GetWeekday($mday, $month, $year) . ", " . GetMonthText($month) . " {$mday}\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t<td valign=middle align=center width='30%'>\r\n\t\t\t\t\t\t\t<a href='" . SELF . "?{$nextlink}'><img border=0 src='right_day.gif' align=left></a>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table>\r\n\t\t\t\t<table width='100%' cellspacing=0 cellpadding=0 border=0>"; // create the scedule layout $ds =& new clsDaySchedule(); $ds->addDiary($view_diary); $ds->generateScheduleMatrix(); $OUTPUT .= $ds->generateScheduleData(); $OUTPUT .= "\r\n\t\t\t</table>\r\n\t\t</td></tr>\r\n\t</table>\r\n\t"; return $OUTPUT; }
$Title = _('Inventory Planning') . ' - ' . _('Problem Report') . '....'; include 'includes/header.inc'; prnMsg(_('The inventory quantities could not be retrieved by the SQL because') . ' - ' . DB_error_msg(), 'error'); 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;
//because we're using comma as a delimiter return str_replace(',', '', str_replace(';', '', $str)); } /*Now figure out the inventory data to report for the category range under review need QOH, QOO, QDem, Sales Mth -1, Sales Mth -2, Sales Mth -3, Sales Mth -4*/ if ($_POST['Location'] == 'All') { $SQL = "SELECT stockmaster.categoryid,\n\t\t\t\t\t\tstockmaster.description,\n\t\t\t\t\t\tstockcategory.categorydescription,\n\t\t\t\t\t\tlocstock.stockid,\n\t\t\t\t\t\tSUM(locstock.quantity) AS qoh\n\t\t\t\t\tFROM locstock\n\t\t\t\t\tINNER JOIN locationusers ON locationusers.loccode=locstock.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1,\n\t\t\t\t\t\tstockmaster,\n\t\t\t\t\t\tstockcategory\n\t\t\t\t\tWHERE locstock.stockid=stockmaster.stockid\n\t\t\t\t\tAND stockmaster.discontinued = 0\n\t\t\t\t\tAND stockmaster.categoryid=stockcategory.categoryid\n\t\t\t\t\tAND (stockmaster.mbflag='B' OR stockmaster.mbflag='M')\n\t\t\t\t\tAND stockmaster.categoryid IN ('" . implode("','", $_POST['Categories']) . "')\n\t\t\t\t\tGROUP BY stockmaster.categoryid,\n\t\t\t\t\t\tstockmaster.description,\n\t\t\t\t\t\tstockcategory.categorydescription,\n\t\t\t\t\t\tlocstock.stockid,\n\t\t\t\t\t\tstockmaster.stockid\n\t\t\t\t\tORDER BY stockmaster.categoryid,\n\t\t\t\t\t\tstockmaster.stockid"; } else { $SQL = "SELECT stockmaster.categoryid,\n\t\t\t\t\tlocstock.stockid,\n\t\t\t\t\tstockmaster.description,\n\t\t\t\t\tstockcategory.categorydescription,\n\t\t\t\t\tlocstock.quantity AS qoh\n\t\t\t\tFROM locstock\n\t\t\t\tINNER JOIN locationusers ON locationusers.loccode=locstock.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1,\n\t\t\t\t\tstockmaster,\n\t\t\t\t\tstockcategory\n\t\t\t\tWHERE locstock.stockid=stockmaster.stockid\n\t\t\t\tAND stockmaster.discontinued = 0\n\t\t\t\tAND stockmaster.categoryid IN ('" . implode("','", $_POST['Categories']) . "')\n\t\t\t\tAND stockmaster.categoryid=stockcategory.categoryid\n\t\t\t\tAND (stockmaster.mbflag='B' OR stockmaster.mbflag='M')\n\t\t\t\tAND locstock.loccode = '" . $_POST['Location'] . "'\n\t\t\t\tORDER BY stockmaster.categoryid,\n\t\t\t\t\tstockmaster.stockid"; } $InventoryResult = DB_query($SQL); $CurrentPeriod = GetPeriod(Date($_SESSION['DefaultDateFormat']), $db); $Periods = array(); for ($i = 0; $i < 24; $i++) { $Periods[$i]['Period'] = $CurrentPeriod - $i; $Periods[$i]['Month'] = GetMonthText(Date('m', mktime(0, 0, 0, Date('m') - $i, Date('d'), Date('Y')))) . ' ' . Date('Y', mktime(0, 0, 0, Date('m') - $i, Date('d'), Date('Y'))); } $SQLStarter = "SELECT stockmoves.stockid,"; for ($i = 0; $i < 24; $i++) { $SQLStarter .= "SUM(CASE WHEN prd='" . $Periods[$i]['Period'] . "' THEN -qty ELSE 0 END) AS prd" . $i . ' '; if ($i < 23) { $SQLStarter .= ', '; } } $SQLStarter .= "FROM stockmoves\n\t\t\t\t\tINNER JOIN locationusers ON locationusers.loccode=stockmoves.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1\n\t\t\t\t\tWHERE (type=10 OR type=11)\n\t\t\t\t\tAND stockmoves.hidemovt=0"; if ($_POST['Location'] != 'All') { $SQLStarter .= " AND stockmoves.loccode ='" . $_POST['Location'] . "'"; } $CSVListing = _('Category ID') . ',' . _('Category Description') . ',' . _('Stock ID') . ',' . _('Description') . ',' . _('QOH') . ','; for ($i = 0; $i < 24; $i++) { $CSVListing .= $Periods[$i]['Month'] . ',';