diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 15483f80c2a..0d66cc546d7 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -55,6 +55,10 @@ $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contactlist'; $mode = GETPOST('mode', 'alpha'); +if ($contextpage == 'poslist') { + $_GET['optioncss'] = 'print'; +} + // Security check $id = GETPOST('id', 'int'); $contactid = GETPOST('id', 'int'); @@ -118,6 +122,7 @@ if ($search_no_email === '') { $optioncss = GETPOST('optioncss', 'alpha'); +$place = GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'; // $place is string id of table for Bar or Restaurant $type = GETPOST("type", 'aZ'); $view = GETPOST("view", 'alpha'); @@ -279,6 +284,54 @@ if (!$permissiontoread) accessforbidden(); * Actions */ +if ($action == "change" && $user->hasRight('takepos', 'run')) { // Change customer for TakePOS + $idcustomer = GETPOST('idcustomer', 'int'); + $idcontact = GETPOST('idcontact', 'int'); + + // Check if draft invoice already exists, if not create it + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' AND entity IN (".getEntity('invoice').")"; + $result = $db->query($sql); + $num_lines = $db->num_rows($result); + if ($num_lines == 0) { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $invoice = new Facture($db); + $constforthirdpartyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; + $invoice->socid = $conf->global->$constforthirdpartyid; + $invoice->date = dol_now(); + $invoice->module_source = 'takepos'; + $invoice->pos_source = $_SESSION["takeposterminal"]; + $placeid = $invoice->create($user); + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid); + $db->query($sql); + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".((int) $idcustomer)." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $resql = $db->query($sql); + + // set contact on invoice + if (!isset($invoice)) { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $invoice = new Facture($db); + $invoice->fetch(null, "(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")"); + $invoice->delete_linked_contact('external', 'BILLING'); + } + $invoice->add_contact($idcontact, 'BILLING'); + ?> + + hasRight('societe', 'creer')) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } -if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) { $arrayofmassactions = array(); } -$massactionbutton = $form->selectMassAction('', $arrayofmassactions); +if ($contextpage != 'poslist') $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '