--- /tmp/dsg/dolibarr/htdocs/compta/cashcontrol/github_19.0.3_cashcontrol_card.php +++ /tmp/dsg/dolibarr/htdocs/compta/cashcontrol/client_cashcontrol_card.php @@ -30 +29,0 @@ -// Load Dolibarr environment @@ -32 +30,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -45,7 +43,7 @@ -$syear = (GETPOSTISSET('closeyear') ? GETPOST('closeyear', 'int') : dol_print_date($now, "%Y")); -$smonth = (GETPOSTISSET('closemonth') ? GETPOST('closemonth', 'int') : dol_print_date($now, "%m")); -$sday = (GETPOSTISSET('closeday') ? GETPOST('closeday', 'int') : dol_print_date($now, "%d")); - -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$syear = (GETPOSTISSET('closeyear') ?GETPOST('closeyear', 'int') : dol_print_date($now, "%Y")); +$smonth = (GETPOSTISSET('closemonth') ?GETPOST('closemonth', 'int') : dol_print_date($now, "%m")); +$sday = (GETPOSTISSET('closeday') ?GETPOST('closeday', 'int') : dol_print_date($now, "%d")); + +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -53,3 +51 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -59,10 +55,13 @@ -if (!$sortfield) { - $sortfield = 'rowid'; -} -if (!$sortorder) { - $sortorder = 'ASC'; -} -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'thirdpartylist'; - -if ($contextpage == 'takepos') { - $_GET['optioncss'] = 'print'; +if (!$sortfield) $sortfield = 'rowid'; +if (!$sortorder) $sortorder = 'ASC'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartylist'; + +if ($contextpage == 'takepos') +{ + $_GET['optioncss'] = 'print'; +} + +// Security check +if (!$user->rights->cashdesk->run && !$user->rights->takepos->run) +{ + accessforbidden(); @@ -74,6 +73,2 @@ -if (isModEnabled('cashdesk')) { - $arrayofposavailable['cashdesk'] = $langs->trans('CashDesk').' (cashdesk)'; -} -if (isModEnabled('takepos')) { - $arrayofposavailable['takepos'] = $langs->trans('TakePOS').' (takepos)'; -} +if (!empty($conf->cashdesk->enabled)) $arrayofposavailable['cashdesk'] = $langs->trans('CashDesk').' (cashdesk)'; +if (!empty($conf->takepos->enabled)) $arrayofposavailable['takepos'] = $langs->trans('TakePOS').' (takepos)'; @@ -93,9 +87,0 @@ - -// Security check -if ($user->socid > 0) { // Protection if external user - //$socid = $user->socid; - accessforbidden(); -} -if (!$user->hasRight("cashdesk", "run") && !$user->hasRight("takepos", "run")) { - accessforbidden(); -} @@ -108,6 +94,4 @@ -$permissiontoadd = ($user->hasRight("cashdesk", "run") || $user->hasRight("takepos", "run")); -$permissiontodelete = ($user->hasRight("cashdesk", "run") || $user->hasRight("takepos", "run")) || ($permissiontoadd && $object->status == 0); -if (empty($backtopage)) { - $backtopage = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.(!empty($id) && $id > 0 ? $id : '__ID__'); -} -$backurlforlist = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_list.php'; +$permissiontoadd = ($user->rights->cashdesk->run || $user->rights->takepos->run); +$permissiontodelete = ($user->rights->cashdesk->run || $user->rights->takepos->run) || ($permissiontoadd && $object->status == 0); +if (empty($backtopage)) $backtopage = dol_buildpath('/compta/cashcontrol/cashcontrol_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); +$backurlforlist = dol_buildpath('/compta/cashcontrol/cashcontrol_list.php', 1); @@ -116 +100,2 @@ -if (!getDolGlobalString('CASHDESK_ID_BANKACCOUNT_CASH') && !getDolGlobalString('CASHDESK_ID_BANKACCOUNT_CASH1')) { +if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH1)) +{ @@ -121 +106,2 @@ -if (GETPOST('cancel', 'alpha')) { +if (GETPOST('cancel', 'alpha')) +{ @@ -124 +110,2 @@ - } else { + } + else { @@ -129 +116,2 @@ -if ($action == "reopen") { +if ($action == "reopen") +{ @@ -132 +120 @@ - setEventMessages($object->error, $object->errors, 'errors'); + dol_print_error($db, $object->error, $object->error); @@ -138 +126,2 @@ -if ($action == "start") { +if ($action == "start") +{ @@ -140 +129,2 @@ - if (!GETPOST('posmodule', 'alpha') || GETPOST('posmodule', 'alpha') == '-1') { + if (!GETPOST('posmodule', 'alpha') || GETPOST('posmodule', 'alpha') == '-1') + { @@ -145 +135,2 @@ - if (GETPOST('posnumber', 'alpha') == '') { + if (GETPOST('posnumber', 'alpha') == '') + { @@ -150 +141,2 @@ - if (!GETPOST('closeyear', 'alpha') || GETPOST('closeyear', 'alpha') == '-1') { + if (!GETPOST('closeyear', 'alpha') || GETPOST('closeyear', 'alpha') == '-1') + { @@ -155,2 +147,5 @@ -} elseif ($action == "add") { - if (GETPOST('opening', 'alpha') == '') { +} +elseif ($action == "add") +{ + if (GETPOST('opening', 'alpha') == '') + { @@ -162 +157,2 @@ - foreach ($arrayofpaymentmode as $key => $val) { + foreach ($arrayofpaymentmode as $key=>$val) + { @@ -166 +162,2 @@ - if (!$error) { + if (!$error) + { @@ -171,2 +168,2 @@ - $object->opening = price2num(GETPOST('opening', 'alpha')); - $object->posmodule = GETPOST('posmodule', 'alpha'); + $object->opening = price2num(GETPOST('opening', 'alpha')); + $object->posmodule = GETPOST('posmodule', 'alpha'); @@ -179 +176,2 @@ - if ($id > 0) { + if ($id > 0) + { @@ -182 +180,3 @@ - } else { + } + else + { @@ -196 +196,2 @@ -if ($action == "valid") { // validate = close +if ($action == "valid") // validate = close +{ @@ -215 +216,2 @@ - if ($result <= 0) { + if ($result <= 0) + { @@ -218 +220,3 @@ - } else { + } + else + { @@ -230 +234 @@ - $action = "view"; + $action = "view"; @@ -234,22 +238,24 @@ -if ($action == 'confirm_delete' && !empty($permissiontodelete)) { - $object->fetch($id); - - if (!($object->id > 0)) { - dol_print_error('', 'Error, object must be fetched before being deleted'); - exit; - } - - $result = $object->delete($user); - //var_dump($result); - if ($result > 0) { - // Delete OK - setEventMessages("RecordDeleted", null, 'mesgs'); - header("Location: ".$backurlforlist); - exit; - } else { - if (!empty($object->errors)) { - setEventMessages(null, $object->errors, 'errors'); - } else { - setEventMessages($object->error, null, 'errors'); - } - } +if ($action == 'confirm_delete' && !empty($permissiontodelete)) +{ + $object->fetch($id); + + if (!($object->id > 0)) + { + dol_print_error('', 'Error, object must be fetched before being deleted'); + exit; + } + + $result = $object->delete($user); + //var_dump($result); + if ($result > 0) + { + // Delete OK + setEventMessages("RecordDeleted", null, 'mesgs'); + header("Location: ".$backurlforlist); + exit; + } + else + { + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + } @@ -269,5 +275,2 @@ - -llxHeader('', $langs->trans("CashControl")); - - -if ($action == "create" || $action == "start" || $action == 'close') { +if ($action == "create" || $action == "start" || $action == 'close') +{ @@ -282 +285,3 @@ - } elseif (GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '-1') { + } + elseif (GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '-1') + { @@ -287,3 +292 @@ - if ($terminaltouse == '1' && $posmodule == 'cashdesk') { - $terminaltouse = ''; - } + if ($terminaltouse == '1' && $posmodule == 'cashdesk') $terminaltouse = ''; @@ -298 +301,2 @@ - if (isset($terminalid) && $terminalid != '') { + if ($terminalid != '') + { @@ -300,2 +304,4 @@ - foreach ($arrayofpaymentmode as $key => $val) { - if ($key != 'cash') { + foreach ($arrayofpaymentmode as $key => $val) + { + if ($key != 'cash') + { @@ -308,25 +314,21 @@ - $bankid = getDolGlobalInt($vartouse); - - if ($bankid > 0) { - $sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; - $sql .= " WHERE fk_account = ".((int) $bankid); - if ($syear && !$smonth) { - $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; - } elseif ($syear && $smonth && !$sday) { - $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'"; - } elseif ($syear && $smonth && $sday) { - $sql .= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; - } else { - setEventMessages($langs->trans('YearNotDefined'), null, 'errors'); - } - - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj) { - $initialbalanceforterminal[$terminalid][$key] = $obj->total; - } - } else { - dol_print_error($db); - } - } else { + $bankid = $conf->global->$vartouse; + + if ($bankid > 0) + { + $sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; + $sql .= " WHERE fk_account = ".$bankid; + if ($syear && !$smonth) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; + elseif ($syear && $smonth && !$sday) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'"; + elseif ($syear && $smonth && $sday) $sql .= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; + else dol_print_error('', 'Year not defined'); + + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $initialbalanceforterminal[$terminalid][$key] = $obj->total; + } + else dol_print_error($db); + } + else + { @@ -334 +336 @@ - $error++; + $error++; @@ -339 +341,2 @@ - foreach ($arrayofpaymentmode as $key => $val) { + foreach ($arrayofpaymentmode as $key => $val) + { @@ -347,7 +350,5 @@ - if ($key == 'cash') { - $sql .= " AND cp.code = 'LIQ'"; - } elseif ($key == 'cheque') { - $sql .= " AND cp.code = 'CHQ'"; - } elseif ($key == 'card') { - $sql .= " AND cp.code = 'CB'"; - } else { + if ($key == 'cash') $sql .= " AND cp.code = 'LIQ'"; + elseif ($key == 'cheque') $sql .= " AND cp.code = 'CHQ'"; + elseif ($key == 'card') $sql .= " AND cp.code = 'CB'"; + else + { @@ -357,9 +358,4 @@ - if ($syear && !$smonth) { - $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; - } elseif ($syear && $smonth && !$sday) { - $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'"; - } elseif ($syear && $smonth && $sday) { - $sql .= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; - } else { - setEventMessages($langs->trans('YearNotDefined'), null, 'errors'); - } + if ($syear && !$smonth) $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; + elseif ($syear && $smonth && !$sday) $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'"; + elseif ($syear && $smonth && $sday) $sql .= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; + else dol_print_error('', 'Year not defined'); @@ -368 +364,2 @@ - if ($resql) { + if ($resql) + { @@ -372 +369,2 @@ - if ($obj) { + if ($obj) + { @@ -376,2 +373,0 @@ - } else { - dol_print_error($db); @@ -378,0 +375 @@ + else dol_print_error($db); @@ -383,0 +381,2 @@ + llxHeader(); + @@ -387,8 +386,9 @@ - print ''; - if ($contextpage == 'takepos') { - print ''; - } - if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') { - print ''; - } elseif ($action == 'close') { - print ''; + print ''; + if ($contextpage == 'takepos') print ''; + if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') + { + print ''; + } + elseif ($action == 'close') + { + print ''; @@ -396,14 +396,16 @@ - } else { - print ''; - } - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + } + else + { + print ''; + } + + print '
'; + print '
'.$langs->trans("Module").''.$langs->trans("Terminal").''.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; @@ -414,18 +416,17 @@ - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; @@ -435 +436,2 @@ - for ($year = $syear - 10; $year < $syear + 10; $year++) { + for ($year = $syear - 10; $year < $syear + 10; $year++) + { @@ -445 +447,2 @@ - for ($month = 1; $month <= 12; $month++) { + for ($month = 1; $month <= 12; $month++) + { @@ -457 +460,2 @@ - for ($day = 1; $day <= 31; $day++) { + for ($day = 1; $day <= 31; $day++) + { @@ -465 +469,2 @@ - if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') { + if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') + { @@ -467 +472,3 @@ - } else { + } + else + { @@ -475 +482,2 @@ - if (($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') || $action == 'close') { + if (($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') || $action == 'close') + { @@ -524,4 +532,4 @@ - print ''; - $i++; + print ''; + $i++; @@ -558,3 +566 @@ - if ($action == 'close') { - print 'disabled '; // To close cash user can't set opening cash - } + if ($action == 'close') print 'disabled '; // To close cash user can't set opening cash @@ -562 +568,2 @@ - if ($action == 'close') { + if ($action == 'close') + { @@ -565,2 +571,0 @@ - } else { - print(GETPOSTISSET('opening') ? price2num(GETPOST('opening', 'alpha')) : price($initialbalanceforterminal[$terminalid]['cash'])); @@ -567,0 +573 @@ + else print (GETPOSTISSET('opening') ?price2num(GETPOST('opening', 'alpha')) : price($initialbalanceforterminal[$terminalid]['cash'])); @@ -583,6 +589,3 @@ - print ''; - if ($action == 'start') { - print ''; - } elseif ($action == 'close') { - print ''; - } + print ''; + if ($action == 'start') print ''; + elseif ($action == 'close') print ''; @@ -596,27 +599,31 @@ - print ''; - } -} - -if (empty($action) || $action == "view" || $action == "close") { - $result = $object->fetch($id); - - if ($result <= 0) { - print $langs->trans("ErrorRecordNotFound"); - } else { - $head = array(); - $head[0][0] = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$object->id; - $head[0][1] = $langs->trans("CashControl"); - $head[0][2] = 'cashcontrol'; - - print dol_get_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'account'); - - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - $morehtmlref .= '
'; - - - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); - - print '
'; - print '
'; + print ''; + } +} + +if (empty($action) || $action == "view" || $action == "close") +{ + $result = $object->fetch($id); + + llxHeader('', $langs->trans("CashControl")); + + if ($result <= 0) { + print $langs->trans("ErrorRecordNotFound"); + } + else { + $head = array(); + $head[0][0] = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$object->id; + $head[0][1] = $langs->trans("CashControl"); + $head[0][2] = 'cashcontrol'; + + dol_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'account'); + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + $morehtmlref .= '
'; + + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); + + print '
'; + print '
'; @@ -644,2 +651,2 @@ - print($object->month_close ? "-" : "").$object->month_close; - print($object->day_close ? "-" : "").$object->day_close; + print ($object->month_close ? "-" : "").$object->month_close; + print ($object->day_close ? "-" : "").$object->day_close; @@ -649,3 +656,3 @@ - print '
'; - - print '
'; + print '
'; + + print '
'; @@ -653,17 +660,17 @@ - - print '
'.$langs->trans("Module").''.$langs->trans("Terminal").''.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
'.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).''; - - $array = array(); - $numterminals = max(1, getDolGlobalString('TAKEPOS_NUM_TERMINALS')); - for ($i = 1; $i <= $numterminals; $i++) { - $array[$i] = $i; - } - $selectedposnumber = 0; - $showempty = 1; - if (getDolGlobalString('TAKEPOS_NUM_TERMINALS') == '1') { - $selectedposnumber = 1; - $showempty = 0; - } - print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ? GETPOST('posnumber', 'int') : $selectedposnumber, $showempty); - //print ''; - print '
'.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).''; + + $array = array(); + $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); + for ($i = 1; $i <= $numterminals; $i++) { + $array[$i] = $i; + } + $selectedposnumber = 0; $showempty = 1; + if ($conf->global->TAKEPOS_NUM_TERMINALS == '1') + { + $selectedposnumber = 1; $showempty = 0; + } + print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty); + //print ''; + print ''; - print $theoricalnbofinvoiceforterminal[$terminalid][$key]; - print ''; + print $theoricalnbofinvoiceforterminal[$terminalid][$key]; + print '
'; - - print ''; - - print '"; - foreach ($arrayofpaymentmode as $key => $val) { - print '"; - } + print '
'; - print $langs->trans("DateCreationShort"); - print ''; - print dol_print_date($object->date_creation, 'dayhour'); - print '
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; - print ''.price($object->opening, 0, $langs, 1, -1, -1, $conf->currency).''; - print "
'.$langs->trans($val).''; - print ''.price($object->$key, 0, $langs, 1, -1, -1, $conf->currency).''; - print "
'; + + print ''; + + print '"; + foreach ($arrayofpaymentmode as $key => $val) + { + print '"; + } @@ -672,7 +679,7 @@ - - print ''; - print '
'; - - print dol_get_fiche_end(); - - if ($action != 'close') { + print ''; + print ''; + print '
'; + + dol_fiche_end(); + + if ($action != 'close') { @@ -681,6 +688,7 @@ - print '
'.$langs->trans('PrintTicket').'
'; - - if ($object->status == CashControl::STATUS_DRAFT) { - print '
'.$langs->trans('Close').'
'; - - print '
'.$langs->trans('Delete').'
'; + print '
'.$langs->trans('PrintTicket').'
'; + + if ($object->status == CashControl::STATUS_DRAFT) + { + print '
'.$langs->trans('Close').'
'; + + print '
'.$langs->trans('Delete').'
'; @@ -688 +696 @@ - print '
'.$langs->trans('ReOpen').'
'; + print '
'.$langs->trans('ReOpen').'
'; @@ -693,27 +701,65 @@ - if ($contextpage != 'takepos') { - print '
'; - } - } else { - print ''; - print ''; - if ($contextpage == 'takepos') { - print ''; - } - if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') { - print ''; - } elseif ($action == 'close') { - print ''; - print ''; - } else { - print ''; - } - - /* - print '
'; - print '
'; + print $langs->trans("DateCreationShort"); + print ''; + print dol_print_date($object->date_creation, 'dayhour'); + print '
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; + print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); + print "
'.$langs->trans($val).''; + print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency); + print "
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + if ($contextpage != 'takepos') print '
'; + } else { + print ''; + print ''; + if ($contextpage == 'takepos') print ''; + if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') + { + print ''; + } + elseif ($action == 'close') + { + print ''; + print ''; + } + else + { + print ''; + } + + /* + print '
'; + print '
'.$langs->trans("Module").''.$langs->trans("Terminal").''.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $disabled = 1; + $prefix = 'close'; + + print ''; + print ''; + print ''; + print ''; + // Year + print ''; + // Month + print ''; + // Day + print ''; + @@ -721,165 +767,126 @@ - print "\n"; - - $disabled = 1; - $prefix = 'close'; - - print ''; - print ''; - print ''; - print ''; - // Year - print ''; - // Month - print ''; - // Day - print ''; - - print ''; - print '
'.$langs->trans("Module").''.$langs->trans("Terminal").''.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
'.$form->selectarray('posmodulebis', $arrayofposavailable, $object->posmodule, (count($arrayofposavailable) > 1 ? 1 : 0), 0, 0, '', 0, 0, $disabled).''; + + $array = array(); + $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); + for($i = 1; $i <= $numterminals; $i++) { + $array[$i] = $i; + } + $selectedposnumber = $object->posnumber; $showempty = 1; + //print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty, 0, 0, '', 0, 0, $disabled); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$form->selectarray('posmodulebis', $arrayofposavailable, $object->posmodule, (count($arrayofposavailable) > 1 ? 1 : 0), 0, 0, '', 0, 0, $disabled).''; - - $array = array(); - $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); - for($i = 1; $i <= $numterminals; $i++) { - $array[$i] = $i; - } - $selectedposnumber = $object->posnumber; $showempty = 1; - //print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty, 0, 0, '', 0, 0, $disabled); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print '
'; - */ - - // Table to see/enter balance - if (($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') || $action == 'close') { - $posmodule = $object->posmodule; - $terminalid = $object->posnumber; - - print '
'; - - print '
'; - print ''; - - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) { - print ''; - $i++; - } - print ''; - print ''; - - print ''; - // Initial amount - print ''; - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) { - print ''; - $i++; - } - // Save - print ''; - print ''; - - print ''; - // Initial amount - print ''; - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) { - print ''; - $i++; - } - // Save - print ''; - print ''; - - print ''; - print ''; - // Initial amount - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) { - print ''; - $i++; - } - // Save - print ''; - print ''; - - print '
'.$langs->trans("InitialBankBalance"); - //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); - print '
'; - print $langs->trans("AmountAtEndOfPeriod"); - print '
'.$langs->trans("Cash"); - //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); - print '
'.$langs->trans($val); - //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); - print '
'.$langs->trans("NbOfInvoices").''; - print ''; - print $theoricalnbofinvoiceforterminal[$terminalid][$key]; - print '
'.$langs->trans("TheoricalAmount").''; - print price($initialbalanceforterminal[$terminalid]['cash']).'
'; - print '
'; - if ($key == 'cash') { - $deltaforcash = ($object->opening - $initialbalanceforterminal[$terminalid]['cash']); - print price($theoricalamountforterminal[$terminalid][$key] + $deltaforcash).'
'; - } else { - print price($theoricalamountforterminal[$terminalid][$key]).'
'; - } - print '
'.$langs->trans("RealAmount").''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($action == 'start') { - print ''; - } elseif ($action == 'close') { - print ''; - } - print '
'; - print '
'; - } - - print ''; - } - } + print ''; + print ''; + */ + + // Table to see/enter balance + if (($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') || $action == 'close') + { + $posmodule = $object->posmodule; + $terminalid = $object->posnumber; + + print '
'; + + print '
'; + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + print ''; + print ''; + + print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; + + print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; + + print ''; + print ''; + // Initial amount + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; + + print '
'.$langs->trans("InitialBankBalance"); + //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); + print '
'; + print $langs->trans("AmountAtEndOfPeriod"); + print '
'.$langs->trans("Cash"); + //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); + print '
'.$langs->trans($val); + //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); + print '
'.$langs->trans("NbOfInvoices").''; + print ''; + print $theoricalnbofinvoiceforterminal[$terminalid][$key]; + print '
'.$langs->trans("TheoricalAmount").''; + print price($initialbalanceforterminal[$terminalid]['cash']).'
'; + print '
'; + if ($key == 'cash') { + $deltaforcash = ($object->opening - $initialbalanceforterminal[$terminalid]['cash']); + print price($theoricalamountforterminal[$terminalid][$key] + $deltaforcash).'
'; + } else { + print price($theoricalamountforterminal[$terminalid][$key]).'
'; + } + print '
'.$langs->trans("RealAmount").''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($action == 'start') print ''; + elseif ($action == 'close') print ''; + print '
'; + print '
'; + } + + print ''; + } + } --- /tmp/dsg/dolibarr/htdocs/compta/cashcontrol/github_19.0.3_cashcontrol_list.php +++ /tmp/dsg/dolibarr/htdocs/compta/cashcontrol/client_cashcontrol_list.php @@ -20 +20 @@ - * \file htdocs/compta/cashcontrol/cashcontrol_list.php + * \file cashcontrol_list.php @@ -25 +25,18 @@ -// Load Dolibarr environment +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message + @@ -35 +52 @@ -$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... @@ -41 +58 @@ -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'cashcontrol'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'cashcontrol'; // To manage different context of search @@ -44 +61 @@ -$mode = GETPOST('mode', 'alpha'); // for mode view result + @@ -48,3 +65,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -52,4 +69 @@ -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { - // If $page is not defined, or '' or -1 or if we click on clear filters - $page = 0; -} +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action @@ -65 +79 @@ -//$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->monmodule->dir_output.'/temp/massgeneration/'.$user->id; @@ -70 +83,0 @@ -//$extrafields->fetch_name_optionals_label($object->table_element_line); @@ -75,7 +88,11 @@ -if (!$sortfield) { - reset($object->fields); // Reset is required to avoid key() to return null. - $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. -} -if (!$sortorder) { - $sortorder = "ASC"; -} +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; + +// Security check +$socid = 0; +if ($user->socid > 0) // Protection if external user +{ + //$socid = $user->socid; + accessforbidden(); +} +//$result = restrictedArea($user, 'monmodule', $id, ''); @@ -84 +101 @@ -$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); +$search_all = trim(GETPOST("search_all", 'alpha')); @@ -86,8 +103,3 @@ -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha') !== '') { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } - if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); - $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); - } +foreach ($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); @@ -98,7 +110,6 @@ -foreach ($object->fields as $key => $val) { - if (!empty($val['searchall'])) { - $fieldstosearchall['t.'.$key] = $val['label']; - } -} - -// Definition of array of fields for columns +foreach ($object->fields as $key => $val) +{ + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +} + +// Definition of fields for list @@ -106 +117,2 @@ -foreach ($object->fields as $key => $val) { +foreach ($object->fields as $key => $val) +{ @@ -108,10 +120 @@ - if (!empty($val['visible'])) { - $visible = (int) dol_eval($val['visible'], 1); - $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' - ); - } + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); @@ -120,2 +123,8 @@ -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} @@ -125,12 +133,0 @@ -$permissiontoread = (!empty($user->rights->cashdesk->run) || !empty($user->rights->takepos->run)); -$permissiontoadd = (!empty($user->rights->cashdesk->run) || !empty($user->rights->takepos->run)); -$permissiontodelete = (!empty($user->rights->cashdesk->run) || !empty($user->rights->takepos->run)); - -// Security check -if ($user->socid > 0) { // Protection if external user - //$socid = $user->socid; - accessforbidden(); -} -if (!$user->hasRight('cashdesk', 'run') && !$user->hasRight('takepos', 'run')) { - accessforbidden(); -} @@ -143,7 +140,2 @@ -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -153,5 +145,4 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ @@ -162,2 +153,4 @@ - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - foreach ($object->fields as $key => $val) { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + foreach ($object->fields as $key => $val) + { @@ -165,4 +157,0 @@ - if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - $search[$key.'_dtstart'] = ''; - $search[$key.'_dtend'] = ''; - } @@ -170 +159 @@ - $toselect = array(); + $toselect = ''; @@ -174 +163,2 @@ - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { @@ -181,2 +171,5 @@ - $uploaddir = $conf->bank->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + $permissiontoread = ($user->rights->cashdesk->run || $user->rights->takepos->run); + $permissiontodelete = ($user->rights->cashdesk->run || $user->rights->takepos->run); + + //$uploaddir = ''; + //include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -198,2 +191 @@ -$morejs = array(); -$morecss = array(); + @@ -204 +196,4 @@ -$sql .= $object->getFieldList('t'); +foreach ($object->fields as $key => $val) +{ + $sql .= 't.'.$key.', '; +} @@ -206,4 +201,3 @@ -if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } +if (!empty($extrafields->attributes[$object->table_element]['label'])) +{ + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); @@ -215,4 +209 @@ -$sql = preg_replace('/,\s*$/', '', $sql); - -$sqlfields = $sql; // $sql fields to remove for count total - +$sql = preg_replace('/, $/', '', $sql); @@ -220,45 +211,10 @@ -if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -} -// Add table from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -if ($object->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -} else { - $sql .= " WHERE 1 = 1"; -} -foreach ($search as $key => $val) { - if (array_key_exists($key, $object->fields)) { - if ($key == 'status' && $search[$key] == -1) { - continue; - } - $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) { - if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) { - $search[$key] = ''; - } - $mode_search = 2; - } - if ($search[$key] != '') { - $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search)); - } - } else { - if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { - $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key); - if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { - if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; - } - if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; - } - } - } - } -} -if ($search_all) { - $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -} -//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) +{ + if ($key == 'status' && $search[$key] == -1) continue; + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); +} +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); @@ -273,17 +229,16 @@ -$sql.= " GROUP BY "; -foreach($object->fields as $key => $val) { - $sql .= "t.".$db->escape($key).", "; -} -// Add fields from extrafields -if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); - } -} -// Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/','', $sql); -*/ - + $sql.= " GROUP BY " + foreach($object->fields as $key => $val) + { + $sql.='t.'.$key.', '; + } + // Add fields from extrafields + if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); + // Add where from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + $sql=preg_replace('/, $/','', $sql); + */ + +$sql .= $db->order($sortfield, $sortorder); @@ -293,13 +248,6 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); - $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); - $resql = $db->query($sqlforcount); - if ($resql) { - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - } else { - dol_print_error($db); - } - - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 + { @@ -309,6 +257,8 @@ - $db->free($resql); -} - -// Complete request and execute it with limit -$sql .= $db->order($sortfield, $sortorder); -if ($limit) { +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +{ + $num = $nbtotalofrecords; +} +else +{ @@ -316,10 +266,10 @@ -} - -$resql = $db->query($sql); -if (!$resql) { - dol_print_error($db); - exit; -} - -$num = $db->num_rows($resql); - + + $resql = $db->query($sql); + if (!$resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} @@ -328 +278,2 @@ -if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) { +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +{ @@ -331 +282 @@ - header("Location: ".DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$id); + header("Location: ".dol_buildpath('/compta/cashcontrol/cashcontrol_card.php', 1).'?id='.$id); @@ -339 +290,16 @@ -llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'classforhorizontalscrolloftabs'); +llxHeader('', $title, $help_url); + +// Example : Adding jquery code +print ''; @@ -344,27 +310,7 @@ -if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); -} -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); -} -foreach ($search as $key => $val) { - if (is_array($search[$key])) { - foreach ($search[$key] as $skey) { - if ($skey != '') { - $param .= '&search_'.$key.'[]='.urlencode($skey); - } - } - } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) { - $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int')); - $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int')); - $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int')); - } elseif ($search[$key] != '') { - $param .= '&search_'.$key.'='.urlencode($search[$key]); - } -} -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) +{ + $param .= '&search_'.$key.'='.urlencode($search[$key]); +} +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); @@ -373,4 +318,0 @@ -// Add $param from hooks -$parameters = array('param' => &$param); -$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook -$param .= $hookmanager->resPrint; @@ -379,4 +321,6 @@ -$arrayofmassactions = array(); -if (!empty($permissiontodelete)) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} +$arrayofmassactions = array( +//'presend'=>$langs->trans("SendByMail"), +//'builddoc'=>$langs->trans("PDFMerge"), +); +//if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -385,4 +329,2 @@ -print '
'."\n"; -if ($optioncss != '') { - print ''; -} +print ''; +if ($optioncss != '') print ''; @@ -394 +335,0 @@ -print ''; @@ -396 +336,0 @@ -print ''; @@ -400,5 +340 @@ -$newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitleSeparator(); -$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permforcashfence); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permforcashfence); @@ -412 +348 @@ -$trackid = 'cashfence'.$object->id; +$trackid = 'xxxx'.$object->id; @@ -415,8 +351,4 @@ -if ($search_all) { - $setupstring = ''; - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - $setupstring .= $key."=".$val.";"; - } - print ''."\n"; - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; +if ($sall) +{ + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; @@ -432,7 +364,5 @@ -if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; -} else { - $moreforfilter = $hookmanager->resPrint; -} - -if (!empty($moreforfilter)) { +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (!empty($moreforfilter)) +{ @@ -445 +375 @@ -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields @@ -449 +379 @@ -print ''."\n"; +print '
'."\n"; @@ -455,19 +385,9 @@ -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; -} -foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { +foreach ($object->fields as $key => $val) +{ + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) + { @@ -475,14 +395,2 @@ - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status onrightofpage' : ''), 1); - } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { - print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1); - } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - print ''; - } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - print '
'; - print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - } + if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); + else print ''; @@ -500,6 +408,4 @@ -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; -} +print ''; @@ -508,3 +413,0 @@ - -$totalarray = array(); -$totalarray['nbfield'] = 0; @@ -515,17 +418,9 @@ -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - $totalarray['nbfield']++; -} -foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { +foreach ($object->fields as $key => $val) +{ + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) + { @@ -533 +427,0 @@ - $totalarray['nbfield']++; @@ -539 +433 @@ -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -542,5 +436 @@ -// Action column -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - $totalarray['nbfield']++; -} +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; @@ -552,5 +442,5 @@ -if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (!is_null($val) && preg_match('/\$object/', $val)) { - $needToFetchEachLine++; // There is at least one compute field that use $object - } +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) + { + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object @@ -564 +453,0 @@ -$savnbfield = $totalarray['nbfield']; @@ -566,2 +455,2 @@ -$totalarray['nbfield'] = 0; -while ($i < ($limit ? min($num, $limit) : $num)) { +while ($i < min($num, $limit)) +{ @@ -569,3 +458 @@ - if (empty($obj)) { - break; // Should not happen - } + if (empty($obj)) break; // Should not happen @@ -574,21 +461,31 @@ - $object->setVarsFromFetchObj($obj); - - // show kanban result - if ($mode == 'kanban') { - if ($i == 0) { - print ''; + foreach ($object->fields as $key => $val) + { + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + + if (!empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if ($key == 'status') print $object->getLibStatut(5); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + else print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) + { + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; @@ -597,97 +494,20 @@ - print $object->getKanbanView('', array('selected' => $selected)); - if ($i == (min($num, $limit) - 1)) { - print ''; - print ''; - } - } else { - // Show here line of result - $j = 0; - print ''; - - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - - foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } - - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } - - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; - - if (!empty($arrayfields['t.'.$key]['checked'])) { - print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; - } - print '>'; - if ($key == 'status') { - print $object->getLibStatut(5); - } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; - } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); - } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $totalarray['val']['t.'.$key] += $object->$key; - } - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - - print ''."\n"; - } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if (!$i) $totalarray['nbfield']++; + + print ''; + @@ -702 +522,2 @@ -if ($num == 0) { +if ($num == 0) +{ @@ -704,6 +525,2 @@ - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; - } - } - print ''; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + print ''; @@ -715 +532 @@ -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -723,2 +540,2 @@ -/* -if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) +{ @@ -726,3 +543 @@ - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; - } + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; @@ -738,2 +553,2 @@ - $genallowed = $permissiontoread; - $delallowed = $permissiontoadd; + $genallowed = $user->rights->monmodule->read; + $delallowed = $user->rights->monmodule->create; @@ -743 +557,0 @@ -*/ --- /tmp/dsg/dolibarr/htdocs/compta/cashcontrol/github_19.0.3_report.php +++ /tmp/dsg/dolibarr/htdocs/compta/cashcontrol/client_report.php @@ -3 +3 @@ - * Copyright (C) 2004-2020 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur @@ -29 +29 @@ - * \brief List of sales from POS + * \brief List of bank transactions @@ -32,10 +31,0 @@ -if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -} -if (!defined('NOBROWSERNOTIF')) { - define('NOBROWSERNOTIF', '1'); // Disable browser notification -} - -$_GET['optioncss'] = "print"; - -// Load Dolibarr environment @@ -47,4 +37,2 @@ -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - - -$langs->loadLangs(array("bills", "banks")); + +$langs->load("bills"); @@ -54,2 +42,4 @@ -$object = new CashControl($db); -$object->fetch($id); +$_GET['optioncss'] = "print"; + +$cashcontrol = new CashControl($db); +$cashcontrol->fetch($id); @@ -62,5 +52,5 @@ - 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), - 'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1), - 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1), - 'cp.code'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), + 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), + 'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1), + 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1), + 'cp.code'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), @@ -68 +58 @@ - 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), + 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), @@ -71,15 +61,6 @@ -$syear = $object->year_close; -$smonth = $object->month_close; -$sday = $object->day_close; - -$posmodule = $object->posmodule; -$terminalid = $object->posnumber; - -// Security check -if ($user->socid > 0) { // Protection if external user - //$socid = $user->socid; - accessforbidden(); -} -if (!$user->hasRight('cashdesk', 'run') && !$user->hasRight('takepos', 'run')) { - accessforbidden(); -} +$syear = $cashcontrol->year_close; +$smonth = $cashcontrol->month_close; +$sday = $cashcontrol->day_close; + +$posmodule = $cashcontrol->posmodule; +$terminalid = $cashcontrol->posnumber; @@ -92 +72,0 @@ -$title = $langs->trans("CashControl"); @@ -95 +75 @@ -llxHeader('', $title, '', '', 0, 0, array(), array(), $param); +llxHeader('', $langs->trans("CashControl"), '', '', 0, 0, array(), array(), $param); @@ -110,2 +90,2 @@ -$sql.= " AND f.module_source = '".$db->escape($object->posmodule)."'"; -$sql.= " AND f.pos_source = '".$db->escape($object->posnumber)."'"; +$sql.= " AND f.module_source = '".$db->escape($cashcontrol->posmodule)."'"; +$sql.= " AND f.pos_source = '".$db->escape($cashcontrol->posnumber)."'"; @@ -119,3 +99,3 @@ -$sql.=" AND (b.fk_account = ".((int) $conf->global->CASHDESK_ID_BANKACCOUNT_CASH); -$sql.=" OR b.fk_account = ".((int) $conf->global->CASHDESK_ID_BANKACCOUNT_CB); -$sql.=" OR b.fk_account = ".((int) $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE); +$sql.=" AND (b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CASH; +$sql.=" OR b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CB; +$sql.=" OR b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; @@ -130 +110 @@ -$sql .= " AND p.entity = ".$conf->entity; // Never share entities for features related to accountancy +$sql .= " AND p.entity IN (".getEntity('facture').")"; @@ -139,9 +119,4 @@ -if ($syear && !$smonth) { - $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; -} elseif ($syear && $smonth && !$sday) { - $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'"; -} elseif ($syear && $smonth && $sday) { - $sql .= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; -} else { - dol_print_error('', 'Year not defined'); -} +if ($syear && !$smonth) $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; +elseif ($syear && $smonth && !$sday) $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'"; +elseif ($syear && $smonth && $sday) $sql .= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; +else dol_print_error('', 'Year not defined'); @@ -150 +125,2 @@ -if ($resql) { +if ($resql) +{ @@ -154,23 +130,4 @@ - print "\n"; - print '
'; - print '

'; - if ($object->status != $object::STATUS_DRAFT) { - print $langs->trans("CashControl")." ".$object->id; - } else { - print $langs->trans("CashControl")." - ".$langs->trans("Draft"); - } - print "

"; - print $mysoc->name; - print '
'.$langs->trans("DateCreationShort").": ".dol_print_date($object->date_creation, 'dayhour'); - $userauthor = $object->fk_user_valid; - if (empty($userauthor)) { - $userauthor = $object->fk_user_creat; - } - - $uservalid = new User($db); - if ($userauthor > 0) { - $uservalid->fetch($userauthor); - print '
'.$langs->trans("Author").': '.$uservalid->getFullName($langs); - } - print '
'.$langs->trans("Period").': '.$object->year_close.($object->month_close ? '-'.$object->month_close : '').($object->day_close ? '-'.$object->day_close : ''); - print '
'; + print "

"; + if ($cashcontrol->status == 2) print $langs->trans("CashControl")." ".$cashcontrol->id; + else print $langs->trans("CashControl")." - ".$langs->trans("Draft"); + print "
".$langs->trans("DateCreationShort").": ".dol_print_date($cashcontrol->date_creation, 'dayhour')."

"; @@ -181 +138 @@ - print $langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").' :
'.price($object->opening).'
'; + print $langs->trans("InitialBankBalance").' - '.$langs->trans("Cash")." : ".price($cashcontrol->opening); @@ -184,4 +141,4 @@ - print '
'; - print '
'; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print '
'; - print '
'; - } - - $object->posmodule = $obj->posmodule; - $object->cash = $obj->cash; - $object->opening = $obj->opening; - $object->year_close = $obj->year_close; - $object->cheque = $obj->cheque; - - // Output Kanban - $selected = -1; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; + $object->id = $obj->rowid; + foreach ($object->fields as $key => $val) + { + if (property_exists($obj, $key)) $object->$key = $obj->$key; + } + + // Show here line of result + print '
'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'."\n"; - - $param = ''; + print '
'; + print '
'."\n"; + + $param = ''; @@ -198,0 +156,2 @@ + $posconciliatecol = 0; + @@ -199,0 +159 @@ + $sign = 1; @@ -202,22 +162,49 @@ - $totalqty = 0; - $totalvat = 0; - $totalvatperrate = array(); - $totallocaltax1 = 0; - $totallocaltax2 = 0; - $cachebankaccount = array(); - $cacheinvoiceid = array(); - $transactionspertype = array(); - $amountpertype = array(); - - $totalarray = array(); - while ($i < $num) { - $objp = $db->fetch_object($resql); - - // Load bankaccount - if (empty($cachebankaccount[$objp->bankid])) { - $bankaccounttmp = new Account($db); - $bankaccounttmp->fetch($objp->bankid); - $cachebankaccount[$objp->bankid] = $bankaccounttmp; - $bankaccount = $bankaccounttmp; - } else { - $bankaccount = $cachebankaccount[$objp->bankid]; + $totalarray = array(); + $cachebankaccount = array(); + $amountpertype = array(); + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + if (empty($cachebankaccount[$objp->bankid])) + { + $bankaccounttmp = new Account($db); + $bankaccounttmp->fetch($objp->bankid); + $cachebankaccount[$objp->bankid] = $bankaccounttmp; + $bankaccount = $bankaccounttmp; + } + else + { + $bankaccount = $cachebankaccount[$objp->bankid]; + } + + $invoicetmp->fetch($objp->facid); + + /*if ($first == "yes") + { + print ''; + print ''; + print ''; + print ''; + $first = "no"; + }*/ + + print ''; + + // Ref + print ''; + if (!$i) $totalarray['nbfield']++; + + // Date ope + print '\n"; + if (!$i) $totalarray['nbfield']++; + + // Bank account + print ''; - - // Ref - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - // Date ope - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - - if ($object->posmodule == "takepos") { - $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'.$object->posnumber; - } else { + else { @@ -267,4 +214,0 @@ - - // Bank account - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - - // Debit - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totaldebfield'; - } - - // Credit - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totalcredfield'; - } + if (!$i) $totalarray['nbfield']++; + + // Type + print '\n"; + if (!$i) $totalarray['nbfield']++; + + // Debit + print '\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebfield'; + + // Credit + print '\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredfield'; @@ -355,13 +268,10 @@ - print ""; - - //$cash = $amountpertype['LIQ'] + $object->opening; - $cash = price2num($cash + $object->opening, 'MT'); - - print '
'; - print '

'; - - print $langs->trans("Cash").(!empty($transactionspertype['CASH']) ? ' ('.$transactionspertype['CASH'].')' : '').' :
'.price($cash).'
'; - if ($object->status == $object::STATUS_VALIDATED && $cash != $object->cash) { - print ' <>
'.$langs->trans("Declared").': '.price($object->cash).'
'; - } - print "
"; + + //$cash = $amountpertype['LIQ'] + $cashcontrol->opening; + $cash = $cash + $cashcontrol->opening; + + print "

"; + print $langs->trans("Cash").": ".price($cash); + if ($cashcontrol->status == $cashcontrol::STATUS_VALIDATED && $cash != $cashcontrol->cash) { + print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->cash).''; + } + print "

"; @@ -370,5 +280,5 @@ - print $langs->trans("PaymentTypeCHQ").(!empty($transactionspertype['CHQ']) ? ' ('.$transactionspertype['CHQ'].')' : '').' :
'.price($cheque).'
'; - if ($object->status == $object::STATUS_VALIDATED && $cheque != $object->cheque) { - print ' <>
'.$langs->trans("Declared").' : '.price($object->cheque).'
'; - } - print "
"; + print $langs->trans("PaymentTypeCHQ").": ".price($cheque); + if ($cashcontrol->status == $cashcontrol::STATUS_VALIDATED && $cheque != $cashcontrol->cheque) { + print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->cheque).''; + } + print "

"; @@ -377,5 +287,5 @@ - print $langs->trans("PaymentTypeCB").(!empty($transactionspertype['CB']) ? ' ('.$transactionspertype['CB'].')' : '').' :
'.price($bank).'
'; - if ($object->status == $object::STATUS_VALIDATED && $bank != $object->card) { - print ' <>
'.$langs->trans("Declared").': '.price($object->card).'
'; - } - print "
"; + print $langs->trans("PaymentTypeCB").": ".price($bank); + if ($cashcontrol->status == $cashcontrol::STATUS_VALIDATED && $bank != $cashcontrol->card) { + print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->card).''; + } + print "

"; @@ -385,26 +295,17 @@ - print ''.$langs->trans("Other").($transactionspertype['OTHER'] ? ' ('.$transactionspertype['OTHER'].')' : '').' :
'.price($other)."
"; - print '
'; - } - - print $langs->trans("Total").' ('.$totalqty.' '.$langs->trans("Articles").') :
'.price($cash + $cheque + $bank + $other).'
'; - - print '
'.$langs->trans("TotalVAT").' :
'.price($totalvat).'
'; - - if ($mysoc->useLocalTax(1)) { - print '
'.$langs->trans("TotalLT1").' :
'.price($totallocaltax1).'
'; - } - if ($mysoc->useLocalTax(1)) { - print '
'.$langs->trans("TotalLT2").' :
'.price($totallocaltax2).'
'; - } - - if (!empty($totalvatperrate) && is_array($totalvatperrate)) { - print '

'.$langs->trans("VATRate").'
'; - foreach ($totalvatperrate as $keyrate => $valuerate) { - print '
'.$langs->trans("VATRate").' '.vatrate($keyrate, 1).' :
'.price($valuerate).'
'; - } - } - - print '

'; - print '
'; - - print ''; + print '
'.$langs->trans("Other").": ".price($other)."

"; + } + print "

"; + + //save totals to DB + /* + $sql = "UPDATE ".MAIN_DB_PREFIX."pos_cash_fence "; + $sql .= "SET"; + $sql .= " cash='".$cash."'"; + $sql .= ", card='".$bank."'"; + $sql .= " where rowid=".$id; + $db->query($sql); + */ + + print ""; + + print ''; @@ -413 +314,3 @@ -} else { +} +else +{
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''.price($cashcontrol->opening).'
'; + print $invoicetmp->getNomUrl(1); + print ''; + print ''.dol_print_date($db->jdate($objp->do), "day").""; + print "'; + print $bankaccount->getNomUrl(1); + if ($cashcontrol->posmodule == "takepos") { + $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'.$cashcontrol->posnumber; @@ -225,40 +212 @@ - - $invoicetmp->fetch($objp->facid); - - if (empty($cacheinvoiceid[$objp->facid])) { - $cacheinvoiceid[$objp->facid] = $objp->facid; // First time this invoice is found into list of invoice x payments - foreach ($invoicetmp->lines as $line) { - $totalqty += $line->qty; - $totalvat += $line->total_tva; - if ($line->tva_tx) { - if (empty($totalvatperrate[$line->tva_tx])) { - $totalvatperrate[$line->tva_tx] = 0; - } - $totalvatperrate[$line->tva_tx] += $line->total_tva; - } - $totallocaltax1 += $line->total_localtax1; - $totallocaltax2 += $line->total_localtax2; - } - } - - print '
'; - print $invoicetmp->getNomUrl(1); - print ''; - print ''.dol_print_date($db->jdate($objp->do), "day").""; - print "'; - print $bankaccount->getNomUrl(1); @@ -273,4 +216,0 @@ - if (empty($transactionspertype[$objp->code])) { - $transactionspertype[$objp->code] = 0; - } - $transactionspertype[$objp->code] += 1; @@ -279,4 +218,0 @@ - if (empty($transactionspertype[$objp->code])) { - $transactionspertype[$objp->code] = 0; - } - $transactionspertype[$objp->code] += 1; @@ -284,15 +220,4 @@ - if (getDolGlobalString($var1) == $bankaccount->id) { - $cash += $objp->amount; - // } elseif (getDolGlobalString($var2) == $bankaccount->id) $bank+=$objp->amount; - //elseif (getDolGlobalString($var3) == $bankaccount->id) $cheque+=$objp->amount; - if (empty($transactionspertype['CASH'])) { - $transactionspertype['CASH'] = 0; - } - $transactionspertype['CASH'] += 1; - } else { - $other += $objp->amount; - if (empty($transactionspertype['OTHER'])) { - $transactionspertype['OTHER'] = 0; - } - $transactionspertype['OTHER'] += 1; - } + if ($conf->global->$var1 == $bankaccount->id) $cash += $objp->amount; + //elseif ($conf->global->$var2 == $bankaccount->id) $bank+=$objp->amount; + //elseif ($conf->global->$var3 == $bankaccount->id) $cheque+=$objp->amount; + else $other += $objp->amount; @@ -301,44 +226,32 @@ - if (!$i) { - $totalarray['nbfield']++; - } - - // Type - print ''; - print $objp->code; - if (empty($amountpertype[$objp->code])) { - $amountpertype[$objp->code] = 0; - } - print "'; - if ($objp->amount < 0) { - print ''.price($objp->amount * -1).''; - $totalarray['val']['totaldebfield'] += $objp->amount; - $amountpertype[$objp->code] += $objp->amount; - } - print "'; - if ($objp->amount > 0) { - print ''.price($objp->amount).''; - $totalarray['val']['totalcredfield'] += $objp->amount; - $amountpertype[$objp->code] -= $objp->amount; - } - print "'; + print $objp->code; + if (empty($amountpertype[$objp->code])) $amountpertype[$objp->code] = 0; + print "'; + if ($objp->amount < 0) + { + print price($objp->amount * -1); + $totalarray['val']['totaldebfield'] += $objp->amount; + $amountpertype[$objp->code] += $objp->amount; + } + print "'; + if ($objp->amount > 0) + { + print price($objp->amount); + $totalarray['val']['totalcredfield'] += $objp->amount; + $amountpertype[$objp->code] -= $objp->amount; + } + print "