--- /tmp/dsg/dolibarr/htdocs/compta/cashcontrol/github_cashcontrol_card.php +++ /tmp/dsg/dolibarr/htdocs/compta/cashcontrol/client_cashcontrol_card.php @@ -28,7 +28,6 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; @@ -59,7 +58,7 @@ if ($contextpage == 'takepos') { - $_GET['optioncss'] = 'print'; + $_GET['optioncss'] = 'print'; } // Security check @@ -108,7 +107,8 @@ { if ($action == 'valid') { $action = 'view'; - } else { + } + else { $action = 'create'; } } @@ -144,7 +144,8 @@ $action = 'create'; $error++; } -} elseif ($action == "add") +} +elseif ($action == "add") { if (GETPOST('opening', 'alpha') == '') { @@ -164,8 +165,8 @@ $object->month_close = GETPOST('closemonth', 'int'); $object->year_close = GETPOST('closeyear', 'int'); - $object->opening = price2num(GETPOST('opening', 'alpha')); - $object->posmodule = GETPOST('posmodule', 'alpha'); + $object->opening = price2num(GETPOST('opening', 'alpha')); + $object->posmodule = GETPOST('posmodule', 'alpha'); $object->posnumber = GETPOST('posnumber', 'alpha'); $db->begin(); @@ -176,7 +177,9 @@ { $db->commit(); $action = "view"; - } else { + } + else + { $db->rollback; $action = "view"; } @@ -214,7 +217,9 @@ { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); - } else { + } + else + { setEventMessages($langs->trans("CashFenceDone"), null); $db->commit(); } @@ -226,32 +231,34 @@ "; exit; } - $action = "view"; + $action = "view"; } // Action to delete 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'); - } + $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'); + } } @@ -275,7 +282,8 @@ $syear = $object->year_close; $smonth = $object->month_close; $sday = $object->day_close; - } elseif (GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '-1') + } + elseif (GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '-1') { $posmodule = GETPOST('posmodule', 'alpha'); $terminalid = GETPOST('posnumber', 'alpha'); @@ -307,22 +315,25 @@ 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 { + $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 + { setEventMessages($langs->trans("SetupOfTerminalNotComplete", $terminaltouse), null, 'errors'); - $error++; + $error++; } } @@ -339,7 +350,8 @@ 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 { + else + { dol_print_error('Value for key = '.$key.' not supported'); exit; } @@ -359,7 +371,8 @@ $theoricalamountforterminal[$terminalid][$key] = price2num($theoricalamountforterminal[$terminalid][$key] + $obj->total); $theoricalnbofinvoiceforterminal[$terminalid][$key] = $obj->nb; } - } else dol_print_error($db); + } + else dol_print_error($db); } } @@ -370,50 +383,53 @@ print load_fiche_titre($langs->trans("CashControl")." - ".$langs->trans("New"), '', 'cash-register'); print '
'; - print ''; + print ''; if ($contextpage == 'takepos') print ''; - if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') - { - print ''; - } elseif ($action == 'close') - { - 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 ''; - 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"; $disabled = 0; $prefix = 'close'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; // Year print ''; @@ -551,7 +569,8 @@ { $object->fetch($id); print $object->opening; - } else print (GETPOSTISSET('opening') ?price2num(GETPOST('opening', 'alpha')) : price($initialbalanceforterminal[$terminalid]['cash'])); + } + else print (GETPOSTISSET('opening') ?price2num(GETPOST('opening', 'alpha')) : price($initialbalanceforterminal[$terminalid]['cash'])); print '">'; print ''; // Amount per payment type @@ -567,8 +586,8 @@ }*/ // Save print ''; print ''; @@ -577,36 +596,37 @@ 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'; - - 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 '
'; + $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 '
'; print '
'; 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, $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 '
'.$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 ''; $retstring = ''; @@ -453,7 +469,9 @@ if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') { print ''; - } else { + } + else + { print ''; } print ''; - print ''; - if ($action == 'start') print ''; + print ''; + if ($action == 'start') print ''; elseif ($action == 'close') print ''; print '
'; @@ -633,36 +653,36 @@ print ''; print '
'; - print '
'; - - print '
'; + print '
'; + + print '
'; print '
'; - 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 '"; + } 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 "
\n"; - print '
'; - print '
'; - print '
'; - - print dol_get_fiche_end(); - - if ($action != 'close') { + print ''; + print ''; + print '
'; + + dol_fiche_end(); + + if ($action != 'close') { print '
'; print ''; @@ -679,22 +699,25 @@ print '
'; if ($contextpage != 'takepos') print '
'; - } else { - print '
'; - 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 ''; - } - - /* + if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') + { + print ''; + } + elseif ($action == 'close') + { + print ''; + print ''; + } + else + { + print ''; + } + + /* print '
'; print ''; print ''; @@ -745,127 +768,128 @@ 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 '
'; - } - } + // 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 ''; + } + } } // End of page --- /tmp/dsg/dolibarr/htdocs/compta/cashcontrol/github_cashcontrol_list.php +++ /tmp/dsg/dolibarr/htdocs/compta/cashcontrol/client_cashcontrol_list.php @@ -63,8 +63,8 @@ // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); 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 $offset = $limit * $page; @@ -98,7 +98,7 @@ //$result = restrictedArea($user, 'monmodule', $id, ''); // Initialize array of search criterias -$search_all = GETPOST("search_all", 'alpha'); +$search_all = trim(GETPOST("search_all", 'alpha')); $search = array(); foreach ($object->fields as $key => $val) { @@ -120,8 +120,14 @@ if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields -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])); + } +} $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -253,7 +259,9 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; -} else { +} +else +{ $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); @@ -337,7 +345,7 @@ $topicmail = "SendCashControlRef"; $modelmail = "cashcontrol"; $objecttmp = new CashControl($db); -$trackid = 'cashfence'.$object->id; +$trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) @@ -384,7 +392,7 @@ if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); else print ''; print ''; } --- /tmp/dsg/dolibarr/htdocs/compta/cashcontrol/github_report.php +++ /tmp/dsg/dolibarr/htdocs/compta/cashcontrol/client_report.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2020 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2012 Vinícius Nogueira * Copyright (C) 2014 Florian Henry @@ -29,16 +29,13 @@ * \brief List of bank transactions */ -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 - require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; -$langs->loadLangs(array("bills", "banks")); +$langs->load("bills"); $id = GETPOST('id', 'int'); @@ -52,13 +49,13 @@ $sortfield = 'b.datev,b.dateo,b.rowid'; $arrayfields = array( - '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), 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), - 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), + 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), ); $syear = $cashcontrol->year_close; @@ -110,7 +107,7 @@ $sql .= " AND f.module_source = '".$db->escape($posmodule)."'"; $sql .= " AND f.pos_source = '".$db->escape($terminalid)."'"; $sql .= " AND f.paye = 1"; -$sql .= " AND p.entity = ".$conf->entity; // Never share entities for features related to accountancy +$sql .= " AND p.entity IN (".getEntity('facture').")"; /*if ($key == 'cash') $sql.=" AND cp.code = 'LIQ'"; elseif ($key == 'cheque') $sql.=" AND cp.code = 'CHQ'"; elseif ($key == 'card') $sql.=" AND cp.code = 'CB'"; @@ -125,16 +122,15 @@ else dol_print_error('', 'Year not defined'); $resql = $db->query($sql); -if ($resql) { +if ($resql) +{ $num = $db->num_rows($resql); $i = 0; - print "\n"; print "

"; - if ($cashcontrol->status != $cashcontrol::STATUS_DRAFT) print $langs->trans("CashControl")." ".$cashcontrol->id; + 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'); - print "

"; + print "
".$langs->trans("DateCreationShort").": ".dol_print_date($cashcontrol->date_creation, 'dayhour').""; $invoicetmp = new Facture($db); @@ -142,10 +138,10 @@ print $langs->trans("InitialBankBalance").' - '.$langs->trans("Cash")." : ".price($cashcontrol->opening); print ""; - print '
'; - print ''."\n"; - - $param = ''; + print '
'; + print '
'."\n"; + + $param = ''; // Fields title print ''; @@ -157,28 +153,34 @@ print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, 'right '); print "\n"; + $posconciliatecol = 0; + // Loop on each record $sign = 1; $cash = $bank = $cheque = $other = 0; - $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") + $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 ''; @@ -190,23 +192,24 @@ print ''; // Ref - print ''; - if (!$i) $totalarray['nbfield']++; - - // Date ope - print '\n"; - if (!$i) $totalarray['nbfield']++; - - // Bank account - print ''; + if (!$i) $totalarray['nbfield']++; + + // Date ope + print '\n"; + if (!$i) $totalarray['nbfield']++; + + // Bank account + print '\n"; - 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']++; + + // 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'; + $totalarray['val']['totalcredfield'] += $objp->amount; + $amountpertype[$objp->code] -= $objp->amount; + } + print "\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredfield'; print ""; @@ -262,7 +267,7 @@ print "
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").'
'; - print $invoicetmp->getNomUrl(1); - print ''; - print ''.dol_print_date($db->jdate($objp->do), "day").""; - print "'; + print ''; + 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; - } else { + } + else { $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'; } if ($objp->code == 'CHQ') { @@ -220,36 +223,38 @@ else $other += $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) { + 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 "
"; //$cash = $amountpertype['LIQ'] + $cashcontrol->opening; - $cash = price2num($cash + $cashcontrol->opening, 'MT'); + $cash = $cash + $cashcontrol->opening; print "

"; print $langs->trans("Cash").": ".price($cash); @@ -295,18 +300,20 @@ /* $sql = "UPDATE ".MAIN_DB_PREFIX."pos_cash_fence "; $sql .= "SET"; - $sql .= " cash='".$db->escape($cash)."'"; - $sql .= ", card='".$db->escape($bank)."'"; + $sql .= " cash='".$cash."'"; + $sql .= ", card='".$bank."'"; $sql .= " where rowid=".$id; $db->query($sql); */ print "

"; - print ''; + print ''; $db->free($resql); -} else { +} +else +{ dol_print_error($db); }