Merge pull request #16407 from frederic34/casdesk_code_syntax

code syntax cashdesk directory
This commit is contained in:
Laurent Destailleur 2021-02-26 13:05:27 +01:00 committed by GitHub
commit 44d4fb6517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 357 additions and 365 deletions

View File

@ -27,16 +27,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
// If socid provided by ajax company selector // If socid provided by ajax company selector
if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) {
{
$_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); $_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha');
$_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); $_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha');
$_REQUEST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); $_REQUEST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha');
} }
// Security check // Security check
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "cashdesk")); $langs->loadLangs(array("admin", "cashdesk"));
@ -45,11 +45,12 @@ $langs->loadLangs(array("admin", "cashdesk"));
/* /*
* Actions * Actions
*/ */
if (GETPOST('action', 'alpha') == 'set') if (GETPOST('action', 'alpha') == 'set') {
{
$db->begin(); $db->begin();
if (GETPOST('socid', 'int') < 0) $_POST["socid"] = ''; if (GETPOST('socid', 'int') < 0) {
$_POST["socid"] = '';
}
$res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY", (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY", (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH", (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH", (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
@ -62,10 +63,11 @@ if (GETPOST('action', 'alpha') == 'set')
dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -93,8 +95,7 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="set">'; print '<input type="hidden" name="action" value="set">';
if (!empty($conf->service->enabled)) if (!empty($conf->service->enabled)) {
{
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>'; print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
@ -121,8 +122,7 @@ print '<tr class="oddeven"><td width=\"50%\">'.$langs->trans("CashDeskThirdParty
print '<td colspan="2">'; print '<td colspan="2">';
print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY, 'socid', '(s.client in (1,3) AND s.status = 1)', 1, 0, 0, array(), 0); print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY, 'socid', '(s.client in (1,3) AND s.status = 1)', 1, 0, 0, array(), 0);
print '</td></tr>'; print '</td></tr>';
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled)) {
{
print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
$form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CASH, 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", 1); $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CASH, 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", 1);
@ -141,8 +141,7 @@ if (!empty($conf->banque->enabled))
print '</td></tr>'; print '</td></tr>';
} }
if (!empty($conf->stock->enabled)) if (!empty($conf->stock->enabled)) {
{
print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDoNotDecreaseStock").'</td>'; // Force warehouse (this is not a default value) print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDoNotDecreaseStock").'</td>'; // Force warehouse (this is not a default value)
print '<td colspan="2">'; print '<td colspan="2">';
if (empty($conf->productbatch->enabled)) { if (empty($conf->productbatch->enabled)) {
@ -161,8 +160,7 @@ if (!empty($conf->stock->enabled))
print '<tr class="oddeven"><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; // Force warehouse (this is not a default value) print '<tr class="oddeven"><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; // Force warehouse (this is not a default value)
print '<td colspan="2">'; print '<td colspan="2">';
if (!$disabled) if (!$disabled) {
{
print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE, 'CASHDESK_ID_WAREHOUSE', '', 1, $disabled); print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE, 'CASHDESK_ID_WAREHOUSE', '', 1, $disabled);
print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">('.$langs->trans("Create").')</a>'; print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">('.$langs->trans("Create").')</a>';
} else { } else {
@ -172,8 +170,7 @@ if (!empty($conf->stock->enabled))
} }
// Use Dolibarr Receipt Printer // Use Dolibarr Receipt Printer
if (!empty($conf->receiptprinter->enabled)) if (!empty($conf->receiptprinter->enabled)) {
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')'; print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')';
print '<td colspan="2">'; print '<td colspan="2">';

View File

@ -25,15 +25,13 @@
require_once 'class/Facturation.class.php'; require_once 'class/Facturation.class.php';
// Si nouvelle vente, reinitialisation des donnees (destruction de l'objet et vidage de la table contenant la liste des articles) // Si nouvelle vente, reinitialisation des donnees (destruction de l'objet et vidage de la table contenant la liste des articles)
if ($_GET['id'] == 'NOUV') if ($_GET['id'] == 'NOUV') {
{
unset($_SESSION['serObjFacturation']); unset($_SESSION['serObjFacturation']);
unset($_SESSION['poscart']); unset($_SESSION['poscart']);
} }
// Recuperation, s'il existe, de l'objet contenant les infos de la vente en cours ... // Recuperation, s'il existe, de l'objet contenant les infos de la vente en cours ...
if (isset($_SESSION['serObjFacturation'])) if (isset($_SESSION['serObjFacturation'])) {
{
$obj_facturation = unserialize($_SESSION['serObjFacturation']); $obj_facturation = unserialize($_SESSION['serObjFacturation']);
unset($_SESSION['serObjFacturation']); unset($_SESSION['serObjFacturation']);
} else { } else {
@ -58,17 +56,18 @@ print '<div class="inline-block" style="vertical-align: top">';
print '<div class="principal">'; print '<div class="principal">';
$page = GETPOST('menutpl', 'alpha'); $page = GETPOST('menutpl', 'alpha');
if (empty($page)) $page = 'facturation'; if (empty($page)) {
$page = 'facturation';
}
if (in_array( if (in_array(
$page, $page,
array( array(
'deconnexion', 'deconnexion',
'index', 'index_verif', 'facturation', 'facturation_verif', 'facturation_dhtml', 'index', 'index_verif', 'facturation', 'facturation_verif', 'facturation_dhtml',
'validation', 'validation_ok', 'validation_ticket', 'validation_verif', 'validation', 'validation_ok', 'validation_ticket', 'validation_verif',
) )
)) )) {
{
include $page.'.php'; include $page.'.php';
} else { } else {
dol_print_error('', 'menu param '.$page.' is not inside allowed list'); dol_print_error('', 'menu param '.$page.' is not inside allowed list');

View File

@ -30,8 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/keypad.php';
$error = GETPOST('error'); $error = GETPOST('error');
// Test if already logged // Test if already logged
if ($_SESSION['uid'] <= 0) if ($_SESSION['uid'] <= 0) {
{
header('Location: index.php'); header('Location: index.php');
exit; exit;
} }
@ -53,8 +52,7 @@ top_htmlhead($head, $langs->trans("CashDesk"), 0, 0, $arrayofjs, $arrayofcss);
print '<body>'."\n"; print '<body>'."\n";
if (!empty($error)) if (!empty($error)) {
{
dol_htmloutput_events(); dol_htmloutput_events();
} }

View File

@ -27,8 +27,7 @@
<?php <?php
// Wrapper to show tooltips // Wrapper to show tooltips
if (!empty($conf->use_javascript_ajax) && empty($conf->dol_no_mouse_hover)) if (!empty($conf->use_javascript_ajax) && empty($conf->dol_no_mouse_hover)) {
{
print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n"; print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n";
print '<script type="text/javascript"> print '<script type="text/javascript">
jQuery(document).ready(function () { jQuery(document).ready(function () {

View File

@ -95,15 +95,18 @@ class Auth
$test = true; $test = true;
// Authentication mode // Authentication mode
if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr'; if (empty($dolibarr_main_authentication)) {
$dolibarr_main_authentication = 'http,dolibarr';
}
// Authentication mode: forceuser // Authentication mode: forceuser
if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user = 'auto'; if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) {
$dolibarr_auto_user = 'auto';
}
// Set authmode // Set authmode
$authmode = explode(',', $dolibarr_main_authentication); $authmode = explode(',', $dolibarr_main_authentication);
// No authentication mode // No authentication mode
if (!count($authmode)) if (!count($authmode)) {
{
$langs->load('main'); $langs->load('main');
dol_print_error('', $langs->trans("ErrorConfigParameterNotDefined", 'dolibarr_main_authentication')); dol_print_error('', $langs->trans("ErrorConfigParameterNotDefined", 'dolibarr_main_authentication'));
exit; exit;
@ -117,15 +120,17 @@ class Auth
// If ok, the variable will be initialized login // If ok, the variable will be initialized login
// If error, we will put error message in session under the name dol_loginmesg // If error, we will put error message in session under the name dol_loginmesg
$goontestloop = false; $goontestloop = false;
if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) $goontestloop = true; if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) {
if (isset($aLogin) || GETPOST('openid_mode', 'alpha', 1)) $goontestloop = true; $goontestloop = true;
}
if (isset($aLogin) || GETPOST('openid_mode', 'alpha', 1)) {
$goontestloop = true;
}
if ($test && $goontestloop) if ($test && $goontestloop) {
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$login = checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode); $login = checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode);
if ($login) if ($login) {
{
$this->login($aLogin); $this->login($aLogin);
$this->passwd($aPasswd); $this->passwd($aPasswd);
$ret = 0; $ret = 0;

View File

@ -116,8 +116,7 @@ class Facturation
// Clean vat code // Clean vat code
$reg = array(); $reg = array();
$vat_src_code = ''; $vat_src_code = '';
if (preg_match('/\((.*)\)/', $txtva, $reg)) if (preg_match('/\((.*)\)/', $txtva, $reg)) {
{
$vat_src_code = $reg[1]; $vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
} }
@ -133,8 +132,7 @@ class Facturation
$total_localtax2 = $resultarray[10]; $total_localtax2 = $resultarray[10];
// Calculation of the discount amount // Calculation of the discount amount
if ($this->remisePercent()) if ($this->remisePercent()) {
{
$remise_percent = $this->remisePercent(); $remise_percent = $this->remisePercent();
} else { } else {
$remise_percent = 0; $remise_percent = 0;
@ -155,10 +153,8 @@ class Facturation
$newcartarray[$i]['price'] = $product->price; $newcartarray[$i]['price'] = $product->price;
$newcartarray[$i]['price_ttc'] = $product->price_ttc; $newcartarray[$i]['price_ttc'] = $product->price_ttc;
if (!empty($conf->global->PRODUIT_MULTIPRICES)) if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
{ if (isset($product->multiprices[$societe->price_level])) {
if (isset($product->multiprices[$societe->price_level]))
{
$newcartarray[$i]['price'] = $product->multiprices[$societe->price_level]; $newcartarray[$i]['price'] = $product->multiprices[$societe->price_level];
$newcartarray[$i]['price_ttc'] = $product->multiprices_ttc[$societe->price_level]; $newcartarray[$i]['price_ttc'] = $product->multiprices_ttc[$societe->price_level];
} }
@ -191,10 +187,8 @@ class Facturation
$j = 0; $j = 0;
$newposcart = array(); $newposcart = array();
foreach ($poscart as $key => $val) foreach ($poscart as $key => $val) {
{ if ($poscart[$key]['id'] != $aArticle) {
if ($poscart[$key]['id'] != $aArticle)
{
$newposcart[$j] = $poscart[$key]; $newposcart[$j] = $poscart[$key];
$newposcart[$j]['id'] = $j; $newposcart[$j]['id'] = $j;
$j++; $j++;
@ -223,8 +217,7 @@ class Facturation
$tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array());
$tab_size = count($tab); $tab_size = count($tab);
for ($i = 0; $i < $tab_size; $i++) for ($i = 0; $i < $tab_size; $i++) {
{
// Total HT // Total HT
$remise = $tab[$i]['remise']; $remise = $tab[$i]['remise'];
$total_ht += ($tab[$i]['total_ht']); $total_ht += ($tab[$i]['total_ht']);
@ -291,11 +284,9 @@ class Facturation
public function id($aId = null) public function id($aId = null)
{ {
if (!$aId) if (!$aId) {
{
return $this->id; return $this->id;
} elseif ($aId == 'RESET') } elseif ($aId == 'RESET') {
{
$this->id = null; $this->id = null;
} else { } else {
$this->id = $aId; $this->id = $aId;
@ -311,11 +302,9 @@ class Facturation
public function ref($aRef = null) public function ref($aRef = null)
{ {
if (is_null($aRef)) if (is_null($aRef)) {
{
return $this->ref; return $this->ref;
} elseif ($aRef == 'RESET') } elseif ($aRef == 'RESET') {
{
$this->ref = null; $this->ref = null;
} else { } else {
$this->ref = $aRef; $this->ref = $aRef;
@ -330,11 +319,9 @@ class Facturation
*/ */
public function qte($aQte = null) public function qte($aQte = null)
{ {
if (is_null($aQte)) if (is_null($aQte)) {
{
return $this->qte; return $this->qte;
} elseif ($aQte == 'RESET') } elseif ($aQte == 'RESET') {
{
$this->qte = null; $this->qte = null;
} else { } else {
$this->qte = $aQte; $this->qte = $aQte;
@ -350,11 +337,9 @@ class Facturation
public function stock($aStock = null) public function stock($aStock = null)
{ {
if (is_null($aStock)) if (is_null($aStock)) {
{
return $this->stock; return $this->stock;
} elseif ($aStock == 'RESET') } elseif ($aStock == 'RESET') {
{
$this->stock = null; $this->stock = null;
} else { } else {
$this->stock = $aStock; $this->stock = $aStock;
@ -370,11 +355,9 @@ class Facturation
public function remisePercent($aRemisePercent = null) public function remisePercent($aRemisePercent = null)
{ {
if (is_null($aRemisePercent)) if (is_null($aRemisePercent)) {
{
return $this->remise_percent; return $this->remise_percent;
} elseif ($aRemisePercent == 'RESET') } elseif ($aRemisePercent == 'RESET') {
{
$this->remise_percent = null; $this->remise_percent = null;
} else { } else {
$this->remise_percent = $aRemisePercent; $this->remise_percent = $aRemisePercent;
@ -564,11 +547,9 @@ class Facturation
*/ */
public function amountWithTax($aTotalTtc = null) public function amountWithTax($aTotalTtc = null)
{ {
if (is_null($aTotalTtc)) if (is_null($aTotalTtc)) {
{
return $this->prix_total_ttc; return $this->prix_total_ttc;
} elseif ($aTotalTtc == 'RESET') } elseif ($aTotalTtc == 'RESET') {
{
$this->prix_total_ttc = null; $this->prix_total_ttc = null;
} else { } else {
$this->prix_total_ttc = $aTotalTtc; $this->prix_total_ttc = $aTotalTtc;

View File

@ -22,10 +22,18 @@
*/ */
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Uncomment creates pb to relogon after a disconnect //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Uncomment creates pb to relogon after a disconnect
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOREQUIREMENU')) {
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); }
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
require_once '../main.inc.php'; require_once '../main.inc.php';

View File

@ -40,16 +40,21 @@ if (GETPOST('filtre', 'alpha')) {
$ret = array(); $i = 0; $ret = array(); $i = 0;
$sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx, p.fk_product_type"; $sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx, p.fk_product_type";
if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= ", ps.reel"; if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
$sql .= ", ps.reel";
}
$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'"; if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'";
}
$sql .= " WHERE p.entity IN (".getEntity('product').")"; $sql .= " WHERE p.entity IN (".getEntity('product').")";
$sql .= " AND p.tosell = 1"; $sql .= " AND p.tosell = 1";
if (!$conf->global->CASHDESK_SERVICES) $sql .= " AND p.fk_product_type = 0"; if (!$conf->global->CASHDESK_SERVICES) {
$sql .= " AND p.fk_product_type = 0";
}
$sql .= " AND ("; $sql .= " AND (";
$sql .= "p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'"; $sql .= "p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'";
if (!empty($conf->barcode->enabled)) if (!empty($conf->barcode->enabled)) {
{
$filtre = GETPOST('filtre', 'alpha'); $filtre = GETPOST('filtre', 'alpha');
//If the barcode looks like an EAN13 format and the last digit is included in it, //If the barcode looks like an EAN13 format and the last digit is included in it,
@ -67,14 +72,11 @@ if (GETPOST('filtre', 'alpha')) {
dol_syslog("facturation.php", LOG_DEBUG); dol_syslog("facturation.php", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$nbr_enreg = $db->num_rows($resql); $nbr_enreg = $db->num_rows($resql);
while ($i < $conf_taille_listes && $tab = $db->fetch_array($resql)) while ($i < $conf_taille_listes && $tab = $db->fetch_array($resql)) {
{ foreach ($tab as $cle => $valeur) {
foreach ($tab as $cle => $valeur)
{
$ret[$i][$cle] = $valeur; $ret[$i][$cle] = $valeur;
} }
$i++; $i++;
@ -90,24 +92,27 @@ if (GETPOST('filtre', 'alpha')) {
$i = 0; $i = 0;
$sql = "SELECT p.rowid, ref, label, tva_tx, p.fk_product_type"; $sql = "SELECT p.rowid, ref, label, tva_tx, p.fk_product_type";
if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= ", ps.reel"; if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
$sql .= ", ps.reel";
}
$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'"; if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'";
}
$sql .= " WHERE p.entity IN (".getEntity('product').")"; $sql .= " WHERE p.entity IN (".getEntity('product').")";
$sql .= " AND p.tosell = 1"; $sql .= " AND p.tosell = 1";
if (!$conf->global->CASHDESK_SERVICES) $sql .= " AND p.fk_product_type = 0"; if (!$conf->global->CASHDESK_SERVICES) {
$sql .= " AND p.fk_product_type = 0";
}
$sql .= " ORDER BY p.label"; $sql .= " ORDER BY p.label";
dol_syslog($sql); dol_syslog($sql);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$nbr_enreg = $db->num_rows($resql); $nbr_enreg = $db->num_rows($resql);
while ($i < $conf_taille_listes && $tab = $db->fetch_array($resql)) while ($i < $conf_taille_listes && $tab = $db->fetch_array($resql)) {
{ foreach ($tab as $cle => $valeur) {
foreach ($tab as $cle => $valeur)
{
$ret[$i][$cle] = $valeur; $ret[$i][$cle] = $valeur;
} }
$i++; $i++;
@ -121,16 +126,13 @@ if (GETPOST('filtre', 'alpha')) {
//$nbr_enreg = count($tab_designations); //$nbr_enreg = count($tab_designations);
if ($nbr_enreg > 1) if ($nbr_enreg > 1) {
{ if ($nbr_enreg > $conf_taille_listes) {
if ($nbr_enreg > $conf_taille_listes)
{
$top_liste_produits = '----- '.$conf_taille_listes.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----'; $top_liste_produits = '----- '.$conf_taille_listes.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----';
} else { } else {
$top_liste_produits = '----- '.$nbr_enreg.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----'; $top_liste_produits = '----- '.$nbr_enreg.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----';
} }
} elseif ($nbr_enreg == 1) } elseif ($nbr_enreg == 1) {
{
$top_liste_produits = '----- 1 '.$langs->transnoentitiesnoconv("ProductFound").' -----'; $top_liste_produits = '----- 1 '.$langs->transnoentitiesnoconv("ProductFound").' -----';
} else { } else {
$top_liste_produits = '----- '.$langs->transnoentitiesnoconv("NoProductFound").' -----'; $top_liste_produits = '----- '.$langs->transnoentitiesnoconv("NoProductFound").' -----';

View File

@ -24,12 +24,24 @@
*/ */
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); if (!defined('NOREQUIRESOC')) {
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); define('NOREQUIRESOC', '1');
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); }
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOCSRFCHECK')) {
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); define('NOCSRFCHECK', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); }
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
// Change this following line to use the correct relative path (../, ../../, etc) // Change this following line to use the correct relative path (../, ../../, etc)
require '../main.inc.php'; require '../main.inc.php';
@ -40,24 +52,30 @@ top_httphead('text/html');
$search = GETPOST("code", "alpha"); $search = GETPOST("code", "alpha");
// Search from criteria // Search from criteria
if (dol_strlen($search) >= 0) // If search criteria is on char length at least if (dol_strlen($search) >= 0) { // If search criteria is on char length at least
{
$sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx"; $sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx";
if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= ", ps.reel"; if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
$sql .= ", ps.reel";
}
$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'"; if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'";
}
$sql .= " WHERE p.entity IN (".getEntity('product').")"; $sql .= " WHERE p.entity IN (".getEntity('product').")";
$sql .= " AND p.tosell = 1"; $sql .= " AND p.tosell = 1";
$sql .= " AND p.fk_product_type = 0"; $sql .= " AND p.fk_product_type = 0";
// Add criteria on ref/label // Add criteria on ref/label
if (!empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) if (!empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) {
{
$sql .= " AND (p.ref LIKE '".$db->escape($search)."%' OR p.label LIKE '".$db->escape($search)."%'"; $sql .= " AND (p.ref LIKE '".$db->escape($search)."%' OR p.label LIKE '".$db->escape($search)."%'";
if (!empty($conf->barcode->enabled)) $sql .= " OR p.barcode LIKE '".$db->escape($search)."%'"; if (!empty($conf->barcode->enabled)) {
$sql .= " OR p.barcode LIKE '".$db->escape($search)."%'";
}
$sql .= ")"; $sql .= ")";
} else { } else {
$sql .= " AND (p.ref LIKE '%".$db->escape($search)."%' OR p.label LIKE '%".$db->escape($search)."%'"; $sql .= " AND (p.ref LIKE '%".$db->escape($search)."%' OR p.label LIKE '%".$db->escape($search)."%'";
if (!empty($conf->barcode->enabled)) $sql .= " OR p.barcode LIKE '%".$db->escape($search)."%'"; if (!empty($conf->barcode->enabled)) {
$sql .= " OR p.barcode LIKE '%".$db->escape($search)."%'";
}
$sql .= ")"; $sql .= ")";
} }
$sql .= " ORDER BY label"; $sql .= " ORDER BY label";
@ -65,17 +83,13 @@ if (dol_strlen($search) >= 0) // If search criteria is on char length at least
dol_syslog("facturation_dhtml.php", LOG_DEBUG); dol_syslog("facturation_dhtml.php", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{ if ($nbr = $db->num_rows($result)) {
if ($nbr = $db->num_rows($result))
{
$resultat = '<ul class="dhtml_bloc">'; $resultat = '<ul class="dhtml_bloc">';
$ret = array(); $i = 0; $ret = array(); $i = 0;
while ($tab = $db->fetch_array($result)) while ($tab = $db->fetch_array($result)) {
{ foreach ($tab as $cle => $valeur) {
foreach ($tab as $cle => $valeur)
{
$ret[$i][$cle] = $valeur; $ret[$i][$cle] = $valeur;
} }
$i++; $i++;
@ -83,8 +97,7 @@ if (dol_strlen($search) >= 0) // If search criteria is on char length at least
$tab = $ret; $tab = $ret;
$tab_size = count($tab); $tab_size = count($tab);
for ($i = 0; $i < $tab_size; $i++) for ($i = 0; $i < $tab_size; $i++) {
{
$resultat .= ' $resultat .= '
<li class="dhtml_defaut" title="'.$tab[$i]['ref'].'" <li class="dhtml_defaut" title="'.$tab[$i]['ref'].'"
onMouseOver="javascript: this.className = \'dhtml_selection\';" onMouseOver="javascript: this.className = \'dhtml_selection\';"

View File

@ -35,36 +35,33 @@ $obj_facturation = unserialize($_SESSION['serObjFacturation']);
unset($_SESSION['serObjFacturation']); unset($_SESSION['serObjFacturation']);
switch ($action) switch ($action) {
{
default: default:
if ($_POST['hdnSource'] != 'NULL') if ($_POST['hdnSource'] != 'NULL') {
{
$sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx, p.default_vat_code, p.recuperableonly"; $sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx, p.default_vat_code, p.recuperableonly";
if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= ", ps.reel"; if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
$sql .= ", ps.reel";
}
$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot; if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot;
}
$sql .= " WHERE p.entity IN (".getEntity('product').")"; $sql .= " WHERE p.entity IN (".getEntity('product').")";
// Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ... // Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ...
if ($_POST['hdnSource'] == 'LISTE') if ($_POST['hdnSource'] == 'LISTE') {
{
$sql .= " AND p.rowid = ".((int) GETPOST('selProduit', 'int')); $sql .= " AND p.rowid = ".((int) GETPOST('selProduit', 'int'));
} elseif ($_POST['hdnSource'] == 'REF') } elseif ($_POST['hdnSource'] == 'REF') {
{
$sql .= " AND p.ref = '".$db->escape(GETPOST('txtRef', 'alpha'))."'"; $sql .= " AND p.ref = '".$db->escape(GETPOST('txtRef', 'alpha'))."'";
} }
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
// ... et enregistrement dans l'objet // ... et enregistrement dans l'objet
if ($db->num_rows($result)) if ($db->num_rows($result)) {
{
$ret = array(); $ret = array();
$tab = $db->fetch_array($result); $tab = $db->fetch_array($result);
foreach ($tab as $key => $value) foreach ($tab as $key => $value) {
{
$ret[$key] = $value; $ret[$key] = $value;
} }
// Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function // Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function
@ -81,7 +78,9 @@ switch ($action)
// Update if prices fields are defined // Update if prices fields are defined
$tva_tx = get_default_tva($mysoc, $societe, $product->id); $tva_tx = get_default_tva($mysoc, $societe, $product->id);
$tva_npr = get_default_npr($mysoc, $societe, $product->id); $tva_npr = get_default_npr($mysoc, $societe, $product->id);
if (empty($tva_tx)) $tva_npr = 0; if (empty($tva_tx)) {
$tva_npr = 0;
}
$pu_ht = $prod->price; $pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc; $pu_ttc = $prod->price_ttc;
@ -89,19 +88,20 @@ switch ($action)
$price_base_type = $prod->price_base_type; $price_base_type = $prod->price_base_type;
// multiprix // multiprix
if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($societe->price_level)) if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($societe->price_level)) {
{
$pu_ht = $prod->multiprices[$societe->price_level]; $pu_ht = $prod->multiprices[$societe->price_level];
$pu_ttc = $prod->multiprices_ttc[$societe->price_level]; $pu_ttc = $prod->multiprices_ttc[$societe->price_level];
$price_min = $prod->multiprices_min[$societe->price_level]; $price_min = $prod->multiprices_min[$societe->price_level];
$price_base_type = $prod->multiprices_base_type[$societe->price_level]; $price_base_type = $prod->multiprices_base_type[$societe->price_level];
if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { // using this option is a bug. kept for backward compatibility
{ if (isset($prod->multiprices_tva_tx[$societe->price_level])) {
if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx = $prod->multiprices_tva_tx[$societe->price_level]; $tva_tx = $prod->multiprices_tva_tx[$societe->price_level];
if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$societe->price_level]; }
if (isset($prod->multiprices_recuperableonly[$societe->price_level])) {
$tva_npr = $prod->multiprices_recuperableonly[$societe->price_level];
}
} }
} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
{
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
$prodcustprice = new Productcustomerprice($db); $prodcustprice = new Productcustomerprice($db);
@ -109,17 +109,19 @@ switch ($action)
$filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $societe->id); $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $societe->id);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
if ($result >= 0) if ($result >= 0) {
{ if (count($prodcustprice->lines) > 0) {
if (count($prodcustprice->lines) > 0)
{
$pu_ht = price($prodcustprice->lines[0]->price); $pu_ht = price($prodcustprice->lines[0]->price);
$pu_ttc = price($prodcustprice->lines[0]->price_ttc); $pu_ttc = price($prodcustprice->lines[0]->price_ttc);
$price_base_type = $prodcustprice->lines[0]->price_base_type; $price_base_type = $prodcustprice->lines[0]->price_base_type;
$tva_tx = $prodcustprice->lines[0]->tva_tx; $tva_tx = $prodcustprice->lines[0]->tva_tx;
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
}
$tva_npr = $prodcustprice->lines[0]->recuperableonly; $tva_npr = $prodcustprice->lines[0]->recuperableonly;
if (empty($tva_tx)) $tva_npr = 0; if (empty($tva_tx)) {
$tva_npr = 0;
}
} }
} else { } else {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
@ -133,10 +135,9 @@ switch ($action)
if (!empty($price_ht)) { if (!empty($price_ht)) {
$pu_ht = price2num($price_ht, 'MU'); $pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
} } elseif ($tmpvat != $tmpprodvat) {
// On reevalue prix selon taux tva car taux tva transaction peut etre different // On reevalue prix selon taux tva car taux tva transaction peut etre different
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
elseif ($tmpvat != $tmpprodvat) {
if ($price_base_type != 'HT') { if ($price_base_type != 'HT') {
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} else { } else {
@ -155,11 +156,9 @@ switch ($action)
$obj_facturation->vatrate = $vatrate; // Save vat rate (full text vat with code) $obj_facturation->vatrate = $vatrate; // Save vat rate (full text vat with code)
// Definition du filtre pour n'afficher que le produit concerne // Definition du filtre pour n'afficher que le produit concerne
if ($_POST['hdnSource'] == 'LISTE') if ($_POST['hdnSource'] == 'LISTE') {
{
$filtre = $ret['ref']; $filtre = $ret['ref'];
} elseif ($_POST['hdnSource'] == 'REF') } elseif ($_POST['hdnSource'] == 'REF') {
{
$filtre = $_POST['txtRef']; $filtre = $_POST['txtRef'];
} }
@ -167,8 +166,7 @@ switch ($action)
} else { } else {
$obj_facturation->raz(); $obj_facturation->raz();
if ($_POST['hdnSource'] == 'REF') if ($_POST['hdnSource'] == 'REF') {
{
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.$_POST['txtRef']; $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.$_POST['txtRef'];
} else { } else {
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation';
@ -185,18 +183,15 @@ switch ($action)
case 'change_thirdparty': // We have clicked on button "Modify" a thirdparty case 'change_thirdparty': // We have clicked on button "Modify" a thirdparty
$newthirdpartyid = GETPOST('CASHDESK_ID_THIRDPARTY', 'int'); $newthirdpartyid = GETPOST('CASHDESK_ID_THIRDPARTY', 'int');
if ($newthirdpartyid > 0) if ($newthirdpartyid > 0) {
{
$_SESSION["CASHDESK_ID_THIRDPARTY"] = $newthirdpartyid; $_SESSION["CASHDESK_ID_THIRDPARTY"] = $newthirdpartyid;
} }
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation';
break; break;
case 'ajout_article': // We have clicked on button "Add product" case 'ajout_article':
if (!empty($obj_facturation->id)) { // A product was previously selected and stored in session, so we can add it
if (!empty($obj_facturation->id)) // A product was previously selected and stored in session, so we can add it
{
dol_syslog("facturation_verif save vat ".$_POST['selTva']); dol_syslog("facturation_verif save vat ".$_POST['selTva']);
$obj_facturation->qte($_POST['txtQte']); $obj_facturation->qte($_POST['txtQte']);
$obj_facturation->tva($_POST['selTva']); // id of vat. Saved so we can use it for next product $obj_facturation->tva($_POST['selTva']); // id of vat. Saved so we can use it for next product

View File

@ -32,7 +32,9 @@ $conf_db_base = $dolibarr_main_db_name;
$conf_fksoc = (!empty($_SESSION["CASHDESK_ID_THIRDPARTY"])) ? $_SESSION["CASHDESK_ID_THIRDPARTY"] : ($conf->global->CASHDESK_ID_THIRDPARTY > 0 ? $conf->global->CASHDESK_ID_THIRDPARTY : 0); $conf_fksoc = (!empty($_SESSION["CASHDESK_ID_THIRDPARTY"])) ? $_SESSION["CASHDESK_ID_THIRDPARTY"] : ($conf->global->CASHDESK_ID_THIRDPARTY > 0 ? $conf->global->CASHDESK_ID_THIRDPARTY : 0);
// Identifiant unique correspondant a l'entrepot a utiliser // Identifiant unique correspondant a l'entrepot a utiliser
$conf_fkentrepot = (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"])) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : ($conf->global->CASHDESK_ID_WAREHOUSE > 0 ? $conf->global->CASHDESK_ID_WAREHOUSE : 0); $conf_fkentrepot = (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"])) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : ($conf->global->CASHDESK_ID_WAREHOUSE > 0 ? $conf->global->CASHDESK_ID_WAREHOUSE : 0);
if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $conf_fkentrepot = 0; // If option to disable the stock decrease is on, we set warehouse id to 0. if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) {
$conf_fkentrepot = 0; // If option to disable the stock decrease is on, we set warehouse id to 0.
}
// Identifiant unique correspondant au compte caisse / liquide // Identifiant unique correspondant au compte caisse / liquide
$conf_fkaccount_cash = (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) ? $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"] : ($conf->global->CASHDESK_ID_BANKACCOUNT_CASH > 0 ? $conf->global->CASHDESK_ID_BANKACCOUNT_CASH : 0); $conf_fkaccount_cash = (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) ? $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"] : ($conf->global->CASHDESK_ID_BANKACCOUNT_CASH > 0 ? $conf->global->CASHDESK_ID_BANKACCOUNT_CASH : 0);

View File

@ -26,7 +26,9 @@ function genkeypad($keypadname, $formname)
{ {
global $conf; global $conf;
if (empty($conf->global->CASHDESK_SHOW_KEYPAD)) return ''; if (empty($conf->global->CASHDESK_SHOW_KEYPAD)) {
return '';
}
// défine the font size of button // défine the font size of button
$btnsize = 32; $btnsize = 32;

View File

@ -32,8 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$langs->loadLangs(array("admin", "cashdesk")); $langs->loadLangs(array("admin", "cashdesk"));
// Test if user logged // Test if user logged
if ($_SESSION['uid'] > 0) if ($_SESSION['uid'] > 0) {
{
header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php'); header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php');
exit; exit;
} }
@ -72,8 +71,7 @@ if (is_array($hookmanager->resArray) && !empty($hookmanager->resArray)) {
<div class="menu_principal hideonsmartphone"> <div class="menu_principal hideonsmartphone">
<div class="logo"> <div class="logo">
<?php <?php
if (!empty($mysoc->logo_small)) if (!empty($mysoc->logo_small)) {
{
print '<img class="logopos" alt="Logo company" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">'; print '<img class="logopos" alt="Logo company" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">';
} else { } else {
print '<div class="logopos">'.$mysoc->name.'</div>'; print '<div class="logopos">'.$mysoc->name.'</div>';
@ -85,7 +83,9 @@ if (!empty($mysoc->logo_small))
<div class="contenu"> <div class="contenu">
<div class="inline-block" style="vertical-align: top"> <div class="inline-block" style="vertical-align: top">
<div class="principal_login"> <div class="principal_login">
<?php if ($err) print dol_escape_htmltag($err)."<br><br>\n"; ?> <?php if ($err) {
print dol_escape_htmltag($err)."<br><br>\n";
} ?>
<fieldset class="cadre_facturation"><legend class="titre1"><?php echo $langs->trans("Identification"); ?></legend> <fieldset class="cadre_facturation"><legend class="titre1"><?php echo $langs->trans("Identification"); ?></legend>
<form id="frmLogin" method="POST" action="index_verif.php"> <form id="frmLogin" method="POST" action="index_verif.php">
<input type="hidden" name="token" value="<?php echo newToken(); ?>" /> <input type="hidden" name="token" value="<?php echo newToken(); ?>" />
@ -104,8 +104,7 @@ if (!empty($mysoc->logo_small))
<?php <?php
if (!empty($morelogincontent)) { if (!empty($morelogincontent)) {
if (is_array($morelogincontent)) { if (is_array($morelogincontent)) {
foreach ($morelogincontent as $format => $option) foreach ($morelogincontent as $format => $option) {
{
if ($format == 'table') { if ($format == 'table') {
echo '<!-- Option by hook -->'; echo '<!-- Option by hook -->';
echo $option; echo $option;
@ -130,20 +129,23 @@ print '<td class="label1">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
print '<td>'; print '<td>';
$disabled = 0; $disabled = 0;
$langs->load("companies"); $langs->load("companies");
if (!empty($conf->global->CASHDESK_ID_THIRDPARTY)) $disabled = 1; // If a particular third party is defined, we disable choice if (!empty($conf->global->CASHDESK_ID_THIRDPARTY)) {
$disabled = 1; // If a particular third party is defined, we disable choice
}
print $form->select_company(GETPOST('socid', 'int') ?GETPOST('socid', 'int') : $conf->global->CASHDESK_ID_THIRDPARTY, 'socid', '(s.client IN (1,3) AND s.status = 1)', !$disabled, $disabled, 0, array(), 0, 'maxwidth300'); print $form->select_company(GETPOST('socid', 'int') ?GETPOST('socid', 'int') : $conf->global->CASHDESK_ID_THIRDPARTY, 'socid', '(s.client IN (1,3) AND s.status = 1)', !$disabled, $disabled, 0, array(), 0, 'maxwidth300');
//print '<input name="warehouse_id" class="texte_login" type="warehouse_id" value="" />'; //print '<input name="warehouse_id" class="texte_login" type="warehouse_id" value="" />';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) {
{
$langs->load("stocks"); $langs->load("stocks");
print "<tr>"; print "<tr>";
print '<td class="label1">'.$langs->trans("Warehouse").'</td>'; print '<td class="label1">'.$langs->trans("Warehouse").'</td>';
print '<td>'; print '<td>';
$disabled = 0; $disabled = 0;
if ($conf->global->CASHDESK_ID_WAREHOUSE > 0) $disabled = 1; // If a particular stock is defined, we disable choice if ($conf->global->CASHDESK_ID_WAREHOUSE > 0) {
$disabled = 1; // If a particular stock is defined, we disable choice
}
print $formproduct->selectWarehouses((GETPOST('warehouseid') ?GETPOST('warehouseid', 'int') : (empty($conf->global->CASHDESK_ID_WAREHOUSE) ? 'ifone' : $conf->global->CASHDESK_ID_WAREHOUSE)), 'warehouseid', '', !$disabled, $disabled); print $formproduct->selectWarehouses((GETPOST('warehouseid') ?GETPOST('warehouseid', 'int') : (empty($conf->global->CASHDESK_ID_WAREHOUSE) ? 'ifone' : $conf->global->CASHDESK_ID_WAREHOUSE)), 'warehouseid', '', !$disabled, $disabled);
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -153,7 +155,9 @@ print "<tr>";
print '<td class="label1">'.$langs->trans("CashDeskBankAccountForSell").'</td>'; print '<td class="label1">'.$langs->trans("CashDeskBankAccountForSell").'</td>';
print '<td>'; print '<td>';
$defaultknown = 0; $defaultknown = 0;
if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && $conf->global->CASHDESK_ID_BANKACCOUNT_CASH > 0) $defaultknown = 1; // If a particular stock is defined, we disable choice if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && $conf->global->CASHDESK_ID_BANKACCOUNT_CASH > 0) {
$defaultknown = 1; // If a particular stock is defined, we disable choice
}
$form->select_comptes(((GETPOST('bankid_cash') > 0) ?GETPOST('bankid_cash') : $conf->global->CASHDESK_ID_BANKACCOUNT_CASH), 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", ($defaultknown ? 0 : 2)); $form->select_comptes(((GETPOST('bankid_cash') > 0) ?GETPOST('bankid_cash') : $conf->global->CASHDESK_ID_BANKACCOUNT_CASH), 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", ($defaultknown ? 0 : 2));
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -162,7 +166,9 @@ print "<tr>";
print '<td class="label1">'.$langs->trans("CashDeskBankAccountForCheque").'</td>'; print '<td class="label1">'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
print '<td>'; print '<td>';
$defaultknown = 0; $defaultknown = 0;
if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE) && $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE > 0) $defaultknown = 1; // If a particular stock is defined, we disable choice if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE) && $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE > 0) {
$defaultknown = 1; // If a particular stock is defined, we disable choice
}
$form->select_comptes(((GETPOST('bankid_cheque') > 0) ?GETPOST('bankid_cheque') : $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE), 'CASHDESK_ID_BANKACCOUNT_CHEQUE', 0, "courant=1", ($defaultknown ? 0 : 2)); $form->select_comptes(((GETPOST('bankid_cheque') > 0) ?GETPOST('bankid_cheque') : $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE), 'CASHDESK_ID_BANKACCOUNT_CHEQUE', 0, "courant=1", ($defaultknown ? 0 : 2));
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -171,7 +177,9 @@ print "<tr>";
print '<td class="label1">'.$langs->trans("CashDeskBankAccountForCB").'</td>'; print '<td class="label1">'.$langs->trans("CashDeskBankAccountForCB").'</td>';
print '<td>'; print '<td>';
$defaultknown = 0; $defaultknown = 0;
if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CB) && $conf->global->CASHDESK_ID_BANKACCOUNT_CB > 0) $defaultknown = 1; // If a particular stock is defined, we disable choice if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CB) && $conf->global->CASHDESK_ID_BANKACCOUNT_CB > 0) {
$defaultknown = 1; // If a particular stock is defined, we disable choice
}
$form->select_comptes(((GETPOST('bankid_cb') > 0) ?GETPOST('bankid_cb') : $conf->global->CASHDESK_ID_BANKACCOUNT_CB), 'CASHDESK_ID_BANKACCOUNT_CB', 0, "courant=1", ($defaultknown ? 0 : 2)); $form->select_comptes(((GETPOST('bankid_cb') > 0) ?GETPOST('bankid_cb') : $conf->global->CASHDESK_ID_BANKACCOUNT_CB), 'CASHDESK_ID_BANKACCOUNT_CB', 0, "courant=1", ($defaultknown ? 0 : 2));
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -195,8 +203,7 @@ print "</tr>\n";
<?php <?php
if ($_GET['err'] < 0) if ($_GET['err'] < 0) {
{
echo ('<script type="text/javascript">'); echo ('<script type="text/javascript">');
echo (' document.getElementById(\'frmLogin\').pwdPassword.focus();'); echo (' document.getElementById(\'frmLogin\').pwdPassword.focus();');
echo ('</script>'); echo ('</script>');

View File

@ -42,36 +42,31 @@ $bankid_cheque = (GETPOST("CASHDESK_ID_BANKACCOUNT_CHEQUE") > 0) ?GETPOST("CASHD
$bankid_cb = (GETPOST("CASHDESK_ID_BANKACCOUNT_CB") > 0) ?GETPOST("CASHDESK_ID_BANKACCOUNT_CB", 'int') : $conf->global->CASHDESK_ID_BANKACCOUNT_CB; $bankid_cb = (GETPOST("CASHDESK_ID_BANKACCOUNT_CB") > 0) ?GETPOST("CASHDESK_ID_BANKACCOUNT_CB", 'int') : $conf->global->CASHDESK_ID_BANKACCOUNT_CB;
// Check username // Check username
if (empty($username)) if (empty($username)) {
{
$retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Login")); $retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Login"));
header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb);
exit; exit;
} }
// Check third party id // Check third party id
if (!($thirdpartyid > 0)) if (!($thirdpartyid > 0)) {
{
$retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("CashDeskThirdPartyForSell")); $retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("CashDeskThirdPartyForSell"));
header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb);
exit; exit;
} }
// If we setup stock module to ask movement on invoices, we must not allow access if required setup not finished. // If we setup stock module to ask movement on invoices, we must not allow access if required setup not finished.
if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !($warehouseid > 0)) if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !($warehouseid > 0)) {
{
$retour = $langs->trans("CashDeskYouDidNotDisableStockDecease"); $retour = $langs->trans("CashDeskYouDidNotDisableStockDecease");
header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb);
exit; exit;
} }
// If stock decrease on bill validation, check user has stock edit permissions // If stock decrease on bill validation, check user has stock edit permissions
if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !empty($username)) if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !empty($username)) {
{
$testuser = new User($db); $testuser = new User($db);
$testuser->fetch(0, $username); $testuser->fetch(0, $username);
$testuser->getrights('stock'); $testuser->getrights('stock');
if (empty($testuser->rights->stock->creer)) if (empty($testuser->rights->stock->creer)) {
{
$retour = $langs->trans("UserNeedPermissionToEditStockToUsePos"); $retour = $langs->trans("UserNeedPermissionToEditStockToUsePos");
header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb);
exit; exit;
@ -83,8 +78,7 @@ if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_S
$auth = new Auth($db); $auth = new Auth($db);
$retour = $auth->verif($username, $password); $retour = $auth->verif($username, $password);
if ($retour >= 0) if ($retour >= 0) {
{
$return = array(); $return = array();
$sql = "SELECT rowid, lastname, firstname"; $sql = "SELECT rowid, lastname, firstname";
@ -93,12 +87,10 @@ if ($retour >= 0)
$sql .= " AND entity IN (0,".$conf->entity.")"; $sql .= " AND entity IN (0,".$conf->entity.")";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$tab = $db->fetch_array($res); $tab = $db->fetch_array($res);
foreach ($tab as $key => $value) foreach ($tab as $key => $value) {
{
$return[$key] = $value; $return[$key] = $value;
} }

View File

@ -21,8 +21,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($langs) || !is_object($langs)) if (empty($langs) || !is_object($langs)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -64,10 +63,11 @@ $id = $obj_facturation->id();
// Si trop d'articles ont ete trouves, on n'affiche que les X premiers (defini dans le fichier de configuration) ... // Si trop d'articles ont ete trouves, on n'affiche que les X premiers (defini dans le fichier de configuration) ...
$nbtoshow = $nbr_enreg; $nbtoshow = $nbr_enreg;
if (!empty($conf_taille_listes) && $nbtoshow > $conf_taille_listes) $nbtoshow = $conf_taille_listes; if (!empty($conf_taille_listes) && $nbtoshow > $conf_taille_listes) {
$nbtoshow = $conf_taille_listes;
}
for ($i = 0; $i < $nbtoshow; $i++) for ($i = 0; $i < $nbtoshow; $i++) {
{
if ($id == $tab_designations[$i]['rowid']) { if ($id == $tab_designations[$i]['rowid']) {
$selected = 'selected'; $selected = 'selected';
} else { } else {
@ -96,9 +96,9 @@ for ($i = 0; $i < $nbtoshow; $i++)
<th><?php echo $langs->trans("Qty"); ?></th> <th><?php echo $langs->trans("Qty"); ?></th>
<th><?php echo $langs->trans("PriceUHT"); ?></th> <th><?php echo $langs->trans("PriceUHT"); ?></th>
<th><?php echo $langs->trans("Discount"); ?> (%)</th> <th><?php echo $langs->trans("Discount"); ?> (%)</th>
<th><?php echo $langs->trans("VATRate"); ?></th> <th><?php echo $langs->trans("VATRate"); ?></th>
<th></th> <th></th>
</tr> </tr>
<tr> <tr>
<td><input class="texte1 maxwidth50onsmartphone" type="text" id="txtQte" name="txtQte" value="1" onkeyup="javascript: modif();" onfocus="javascript: this.select();" /> <td><input class="texte1 maxwidth50onsmartphone" type="text" id="txtQte" name="txtQte" value="1" onkeyup="javascript: modif();" onfocus="javascript: this.select();" />
<?php print genkeypad("txtQte", "frmQte"); ?> <?php print genkeypad("txtQte", "frmQte"); ?>
@ -106,20 +106,22 @@ for ($i = 0; $i < $nbtoshow; $i++)
<!-- Show unit price --> <!-- Show unit price -->
<?php // TODO Remove the disabled and use this value when adding product into cart ?> <?php // TODO Remove the disabled and use this value when adding product into cart ?>
<td><input class="texte1_off maxwidth50onsmartphone" type="text" name="txtPrixUnit" value="<?php echo price2num($obj_facturation->prix(), 'MU'); ?>" onchange="javascript: modif();" disabled /></td> <td><input class="texte1_off maxwidth50onsmartphone" type="text" name="txtPrixUnit" value="<?php echo price2num($obj_facturation->prix(), 'MU'); ?>" onchange="javascript: modif();" disabled /></td>
<!-- Choix de la remise --> <!-- Choix de la remise -->
<td><input class="texte1 maxwidth50onsmartphone" type="text" id="txtRemise" name="txtRemise" value="0" onkeyup="javascript: modif();" onfocus="javascript: this.select();"/> <td><input class="texte1 maxwidth50onsmartphone" type="text" id="txtRemise" name="txtRemise" value="0" onkeyup="javascript: modif();" onfocus="javascript: this.select();"/>
<?php print genkeypad("txtRemise", "frmQte"); ?> <?php print genkeypad("txtRemise", "frmQte"); ?>
</td> </td>
<!-- Choix du taux de TVA --> <!-- Choix du taux de TVA -->
<td class="select_tva center"> <td class="select_tva center">
<?php <?php
$vatrate = $obj_facturation->vatrate; // To get vat rate we just have selected $vatrate = $obj_facturation->vatrate; // To get vat rate we just have selected
$buyer = new Societe($db); $buyer = new Societe($db);
if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) {
$buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]);
}
echo $form->load_tva('selTva', (GETPOSTISSET("selTva") ? GETPOST("selTva", 'alpha', 2) : $vatrate), $mysoc, $buyer, 0, 0, '', false, -1); echo $form->load_tva('selTva', (GETPOSTISSET("selTva") ? GETPOST("selTva", 'alpha', 2) : $vatrate), $mysoc, $buyer, 0, 0, '', false, -1);
?> ?>
</td> </td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
@ -130,8 +132,8 @@ for ($i = 0; $i < $nbtoshow; $i++)
<input class="texte1_off maxwidth50onsmartphone" type="text" name="txtStock" value="<?php echo $obj_facturation->stock() ?>" disabled /> <input class="texte1_off maxwidth50onsmartphone" type="text" name="txtStock" value="<?php echo $obj_facturation->stock() ?>" disabled />
</td> </td>
<td><?php echo $langs->trans("TotalHT"); ?></td> <td><?php echo $langs->trans("TotalHT"); ?></td>
<!-- Affichage du total HT --> <!-- Affichage du total HT -->
<td colspan="2"><input class="texte1_off maxwidth50onsmartphone" type="text" name="txtTotal" value="" disabled /></td><td></td> <td colspan="2"><input class="texte1_off maxwidth50onsmartphone" type="text" name="txtTotal" value="" disabled /></td><td></td>
</tr> </tr>
</table> </table>
@ -165,25 +167,28 @@ for ($i = 0; $i < $nbtoshow; $i++)
<div class="inline-block"> <div class="inline-block">
<?php <?php
print '<div class="inline-block" style="margin: 6px;">'; print '<div class="inline-block" style="margin: 6px;">';
if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CASH']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] < 0) if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CASH']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] < 0) {
{
$langs->load("errors"); $langs->load("errors");
print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("Cash").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />'; print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("Cash").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />';
} else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("Cash").'" onclick="javascript: verifClic(\'ESP\');" />'; } else {
print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("Cash").'" onclick="javascript: verifClic(\'ESP\');" />';
}
print '</div>'; print '</div>';
print '<div class="inline-block" style="margin: 6px;">'; print '<div class="inline-block" style="margin: 6px;">';
if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) {
{
$langs->load("errors"); $langs->load("errors");
print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />'; print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />';
} else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" onclick="javascript: verifClic(\'CB\');" />'; } else {
print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" onclick="javascript: verifClic(\'CB\');" />';
}
print '</div>'; print '</div>';
print '<div class="inline-block" style="margin: 6px;">'; print '<div class="inline-block" style="margin: 6px;">';
if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) {
{
$langs->load("errors"); $langs->load("errors");
print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete"), $langs->transnoentitiesnoconv("CashDesk")).'" />'; print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete"), $langs->transnoentitiesnoconv("CashDesk")).'" />';
} else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" onclick="javascript: verifClic(\'CHQ\');" />'; } else {
print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" onclick="javascript: verifClic(\'CHQ\');" />';
}
print '</div>'; print '</div>';
print '<div class="clearboth">'; print '<div class="clearboth">';
print '<div class="inline-block" style="margin: 6px;">'; print '<div class="inline-block" style="margin: 6px;">';

View File

@ -18,8 +18,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($langs) || !is_object($langs)) if (empty($langs) || !is_object($langs)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -48,10 +47,10 @@ $societe->fetch($thirdpartyid);
$tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array());
$tab_size = count($tab); $tab_size = count($tab);
if ($tab_size <= 0) print '<div class="center">'.$langs->trans("NoArticle").'</div><br>'; if ($tab_size <= 0) {
else { print '<div class="center">'.$langs->trans("NoArticle").'</div><br>';
for ($i = 0; $i < $tab_size; $i++) } else {
{ for ($i = 0; $i < $tab_size; $i++) {
echo ('<div class="cadre_article">'."\n"); echo ('<div class="cadre_article">'."\n");
echo ('<p><a href="facturation_verif.php?action=suppr_article&suppr_id='.$tab[$i]['id'].'" title="'.$langs->trans("DeleteArticle").'">'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'</a></p>'."\n"); echo ('<p><a href="facturation_verif.php?action=suppr_article&suppr_id='.$tab[$i]['id'].'" title="'.$langs->trans("DeleteArticle").'">'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'</a></p>'."\n");

View File

@ -20,8 +20,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($langs) || !is_object($langs)) if (empty($langs) || !is_object($langs)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -37,27 +36,23 @@ include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
$company->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); $company->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]);
$companyLink = $company->getNomUrl(1); $companyLink = $company->getNomUrl(1);
}*/ }*/
if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) {
{
$bankcash = new Account($db); $bankcash = new Account($db);
$bankcash->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]); $bankcash->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]);
$bankcash->label = $bankcash->ref; $bankcash->label = $bankcash->ref;
$bankcashLink = $bankcash->getNomUrl(1); $bankcashLink = $bankcash->getNomUrl(1);
} }
if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) {
{
$bankcb = new Account($db); $bankcb = new Account($db);
$bankcb->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]); $bankcb->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]);
$bankcbLink = $bankcb->getNomUrl(1); $bankcbLink = $bankcb->getNomUrl(1);
} }
if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) {
{
$bankcheque = new Account($db); $bankcheque = new Account($db);
$bankcheque->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]); $bankcheque->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]);
$bankchequeLink = $bankcheque->getNomUrl(1); $bankchequeLink = $bankcheque->getNomUrl(1);
} }
if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && !empty($conf->stock->enabled)) if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && !empty($conf->stock->enabled)) {
{
$warehouse = new Entrepot($db); $warehouse = new Entrepot($db);
$warehouse->fetch($_SESSION["CASHDESK_ID_WAREHOUSE"]); $warehouse->fetch($_SESSION["CASHDESK_ID_WAREHOUSE"]);
$warehouseLink = $warehouse->getNomUrl(1); $warehouseLink = $warehouse->getNomUrl(1);
@ -87,8 +82,7 @@ print '</form>';
print $langs->trans("CashDeskBankCB").': '.$bankcbLink.'<br>'; print $langs->trans("CashDeskBankCB").': '.$bankcbLink.'<br>';
print $langs->trans("CashDeskBankCheque").': '.$bankchequeLink.'<br>';*/ print $langs->trans("CashDeskBankCheque").': '.$bankchequeLink.'<br>';*/
print '<div class="clearboth">'; print '<div class="clearboth">';
if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && !empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && !empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) {
{
print $langs->trans("CashDeskWarehouse").': '.$warehouseLink; print $langs->trans("CashDeskWarehouse").': '.$warehouseLink;
} }
print '</div></li></ul>'; print '</div></li></ul>';

View File

@ -18,8 +18,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($langs) || !is_object($langs)) if (empty($langs) || !is_object($langs)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -38,82 +37,81 @@ $object->fetch($facid);
?> ?>
<html> <html>
<head> <head>
<title><?php echo $langs->trans('PrintTicket') ?></title> <title><?php echo $langs->trans('PrintTicket') ?></title>
<link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT; ?>/cashdesk/css/ticket.css"> <link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT; ?>/cashdesk/css/ticket.css">
</head> </head>
<body> <body>
<div class="entete"> <div class="entete">
<div class="logo"> <div class="logo">
<?php print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">'; ?> <?php print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">'; ?>
</div> </div>
<div class="infos"> <div class="infos">
<p class="address"><?php echo $mysoc->name; ?><br> <p class="address"><?php echo $mysoc->name; ?><br>
<?php print dol_nl2br(dol_format_address($mysoc)); ?><br> <?php print dol_nl2br(dol_format_address($mysoc)); ?><br>
</p> </p>
<p class="date_heure"><?php <p class="date_heure"><?php
// Recuperation et affichage de la date et de l'heure // Recuperation et affichage de la date et de l'heure
$now = dol_now(); $now = dol_now();
print dol_print_date($now, 'dayhourtext').'<br>'; print dol_print_date($now, 'dayhourtext').'<br>';
print $object->ref; print $object->ref;
?></p> ?></p>
</div> </div>
</div> </div>
<br> <br>
<table class="liste_articles"> <table class="liste_articles">
<thead> <thead>
<tr class="titres"> <tr class="titres">
<th><?php print $langs->trans("Code"); ?></th> <th><?php print $langs->trans("Code"); ?></th>
<th><?php print $langs->trans("Label"); ?></th> <th><?php print $langs->trans("Label"); ?></th>
<th><?php print $langs->trans("Qty"); ?></th> <th><?php print $langs->trans("Qty"); ?></th>
<th><?php print $langs->trans("Discount").' (%)'; ?></th> <th><?php print $langs->trans("Discount").' (%)'; ?></th>
<th><?php print $langs->trans("TotalHT"); ?></th> <th><?php print $langs->trans("TotalHT"); ?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
$tab = array(); $tab = array();
$tab = $_SESSION['poscart']; $tab = $_SESSION['poscart'];
$tab_size = count($tab); $tab_size = count($tab);
for ($i = 0; $i < $tab_size; $i++) for ($i = 0; $i < $tab_size; $i++) {
{
$remise = $tab[$i]['remise']; $remise = $tab[$i]['remise'];
?> ?>
<tr> <tr>
<td><?php echo $tab[$i]['ref']; ?></td> <td><?php echo $tab[$i]['ref']; ?></td>
<td><?php echo $tab[$i]['label']; ?></td> <td><?php echo $tab[$i]['label']; ?></td>
<td><?php echo $tab[$i]['qte']; ?></td> <td><?php echo $tab[$i]['qte']; ?></td>
<td><?php echo $tab[$i]['remise_percent']; ?></td> <td><?php echo $tab[$i]['remise_percent']; ?></td>
<td class="total"><?php echo price(price2num($tab[$i]['total_ht'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?></td> <td class="total"><?php echo price(price2num($tab[$i]['total_ht'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?></td>
</tr> </tr>
<?php <?php
} }
?> ?>
</tbody> </tbody>
</table> </table>
<table class="totaux"> <table class="totaux">
<tr> <tr>
<th class="nowrap"><?php echo $langs->trans("TotalHT"); ?></th> <th class="nowrap"><?php echo $langs->trans("TotalHT"); ?></th>
<td class="nowrap"><?php echo price(price2num($obj_facturation->amountWithoutTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td> <td class="nowrap"><?php echo price(price2num($obj_facturation->amountWithoutTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td>
</tr> </tr>
<tr> <tr>
<th class="nowrap"><?php echo $langs->trans("TotalVAT").'</th><td class="nowrap">'.price(price2num($obj_facturation->amountVat(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td> <th class="nowrap"><?php echo $langs->trans("TotalVAT").'</th><td class="nowrap">'.price(price2num($obj_facturation->amountVat(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td>
</tr> </tr>
<tr> <tr>
<th class="nowrap"><?php echo ''.$langs->trans("TotalTTC").'</th><td class="nowrap">'.price(price2num($obj_facturation->amountWithTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td> <th class="nowrap"><?php echo ''.$langs->trans("TotalTTC").'</th><td class="nowrap">'.price(price2num($obj_facturation->amountWithTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td>
</tr> </tr>
</table> </table>
<script type="text/javascript"> <script type="text/javascript">
window.print(); window.print();
</script> </script>
<a class="lien" href="#" onclick="javascript: window.close(); return(false);"><?php echo $langs->trans("Close"); ?></a> <a class="lien" href="#" onclick="javascript: window.close(); return(false);"><?php echo $langs->trans("Close"); ?></a>

View File

@ -17,8 +17,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($langs) || !is_object($langs)) if (empty($langs) || !is_object($langs)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -47,25 +46,27 @@ if ($obj_facturation->amountVat()) {
<tr><td class="resume_label"><?php echo $langs->trans("TotalTTC"); ?> </td><td><?php echo price(price2num($obj_facturation->amountWithTax(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?></td></tr> <tr><td class="resume_label"><?php echo $langs->trans("TotalTTC"); ?> </td><td><?php echo price(price2num($obj_facturation->amountWithTax(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?></td></tr>
<tr><td class="resume_label"><?php echo $langs->trans("PaymentMode"); ?> </td><td> <tr><td class="resume_label"><?php echo $langs->trans("PaymentMode"); ?> </td><td>
<?php <?php
switch ($obj_facturation->getSetPaymentMode()) switch ($obj_facturation->getSetPaymentMode()) {
{
case 'ESP': case 'ESP':
echo $langs->trans("Cash"); echo $langs->trans("Cash");
$filtre = 'courant=2'; $filtre = 'courant=2';
if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) {
$selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]; $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"];
}
break; break;
case 'CB': case 'CB':
echo $langs->trans("CreditCard"); echo $langs->trans("CreditCard");
$filtre = 'courant=1'; $filtre = 'courant=1';
if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) {
$selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]; $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CB"];
}
break; break;
case 'CHQ': case 'CHQ':
echo $langs->trans("Cheque"); echo $langs->trans("Cheque");
$filtre = 'courant=1'; $filtre = 'courant=1';
if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) {
$selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]; $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"];
}
break; break;
case 'DIF': case 'DIF':
echo $langs->trans("Reported"); echo $langs->trans("Reported");

View File

@ -18,8 +18,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($langs) || !is_object($langs)) if (empty($langs) || !is_object($langs)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }

View File

@ -33,8 +33,7 @@ $hookmanager->initHooks(array('cashdeskTplTicket'));
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $obj_facturation); $reshook = $hookmanager->executeHooks('doActions', $parameters, $obj_facturation);
if (empty($reshook)) if (empty($reshook)) {
{
require 'tpl/ticket.tpl.php'; require 'tpl/ticket.tpl.php';
} }

View File

@ -36,8 +36,7 @@ $obj_facturation = unserialize($_SESSION['serObjFacturation']);
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$bankaccountid = GETPOST('cashdeskbank'); $bankaccountid = GETPOST('cashdeskbank');
switch ($action) switch ($action) {
{
default: default:
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation'; $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation';
break; break;
@ -55,15 +54,18 @@ switch ($action)
// To use a specific numbering module for POS, reset $conf->global->FACTURE_ADDON and other vars here // To use a specific numbering module for POS, reset $conf->global->FACTURE_ADDON and other vars here
// and restore values just after // and restore values just after
$sav_FACTURE_ADDON = ''; $sav_FACTURE_ADDON = '';
if (!empty($conf->global->POS_ADDON)) if (!empty($conf->global->POS_ADDON)) {
{
$sav_FACTURE_ADDON = $conf->global->FACTURE_ADDON; $sav_FACTURE_ADDON = $conf->global->FACTURE_ADDON;
$conf->global->FACTURE_ADDON = $conf->global->POS_ADDON; $conf->global->FACTURE_ADDON = $conf->global->POS_ADDON;
// To force prefix only for POS with terre module // To force prefix only for POS with terre module
if (!empty($conf->global->POS_NUMBERING_TERRE_FORCE_PREFIX)) $conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX = $conf->global->POS_NUMBERING_TERRE_FORCE_PREFIX; if (!empty($conf->global->POS_NUMBERING_TERRE_FORCE_PREFIX)) {
$conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX = $conf->global->POS_NUMBERING_TERRE_FORCE_PREFIX;
}
// To force prefix only for POS with mars module // To force prefix only for POS with mars module
if (!empty($conf->global->POS_NUMBERING_MARS_FORCE_PREFIX)) $conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX = $conf->global->POS_NUMBERING_MARS_FORCE_PREFIX; if (!empty($conf->global->POS_NUMBERING_MARS_FORCE_PREFIX)) {
$conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX = $conf->global->POS_NUMBERING_MARS_FORCE_PREFIX;
}
// To force rule only for POS with mercure // To force rule only for POS with mercure
//... //...
} }
@ -71,8 +73,7 @@ switch ($action)
$num = $invoice->getNextNumRef($company); $num = $invoice->getNextNumRef($company);
// Restore save values // Restore save values
if (!empty($sav_FACTURE_ADDON)) if (!empty($sav_FACTURE_ADDON)) {
{
$conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON;
} }
@ -120,14 +121,12 @@ switch ($action)
$heure = dol_print_date($now, 'hour'); $heure = dol_print_date($now, 'hour');
$note = ''; $note = '';
if (!is_object($obj_facturation)) if (!is_object($obj_facturation)) {
{
dol_print_error('', 'Empty context'); dol_print_error('', 'Empty context');
exit; exit;
} }
switch ($obj_facturation->getSetPaymentMode()) switch ($obj_facturation->getSetPaymentMode()) {
{
case 'DIF': case 'DIF':
$mode_reglement_id = 0; $mode_reglement_id = 0;
//$cond_reglement_id = dol_getIdFromCode($db,'RECEP','cond_reglement','code','rowid') //$cond_reglement_id = dol_getIdFromCode($db,'RECEP','cond_reglement','code','rowid')
@ -151,8 +150,12 @@ switch ($action)
$cond_reglement_id = 0; $cond_reglement_id = 0;
break; break;
} }
if (empty($mode_reglement_id)) $mode_reglement_id = 0; // If mode_reglement_id not found if (empty($mode_reglement_id)) {
if (empty($cond_reglement_id)) $cond_reglement_id = 0; // If cond_reglement_id not found $mode_reglement_id = 0; // If mode_reglement_id not found
}
if (empty($cond_reglement_id)) {
$cond_reglement_id = 0; // If cond_reglement_id not found
}
$note .= $_POST['txtaNotes']; $note .= $_POST['txtaNotes'];
dol_syslog("obj_facturation->getSetPaymentMode()=".$obj_facturation->getSetPaymentMode()." mode_reglement_id=".$mode_reglement_id." cond_reglement_id=".$cond_reglement_id); dol_syslog("obj_facturation->getSetPaymentMode()=".$obj_facturation->getSetPaymentMode()." mode_reglement_id=".$mode_reglement_id." cond_reglement_id=".$cond_reglement_id);
@ -175,8 +178,7 @@ switch ($action)
// Loop on each line into cart // Loop on each line into cart
$tab_liste_size = count($tab_liste); $tab_liste_size = count($tab_liste);
for ($i = 0; $i < $tab_liste_size; $i++) for ($i = 0; $i < $tab_liste_size; $i++) {
{
$tmp = getTaxesFromId($tab_liste[$i]['fk_tva']); $tmp = getTaxesFromId($tab_liste[$i]['fk_tva']);
$vat_rate = $tmp['rate']; $vat_rate = $tmp['rate'];
$vat_npr = $tmp['npr']; $vat_npr = $tmp['npr'];
@ -218,32 +220,32 @@ switch ($action)
//print "c=".$invoice->cond_reglement_id." m=".$invoice->mode_reglement_id; exit; //print "c=".$invoice->cond_reglement_id." m=".$invoice->mode_reglement_id; exit;
// Si paiement differe ... // Si paiement differe ...
if ($obj_facturation->getSetPaymentMode() == 'DIF') if ($obj_facturation->getSetPaymentMode() == 'DIF') {
{
$resultcreate = $invoice->create($user, 0, dol_stringtotime($obj_facturation->paiementLe())); $resultcreate = $invoice->create($user, 0, dol_stringtotime($obj_facturation->paiementLe()));
if ($resultcreate > 0) if ($resultcreate > 0) {
{
$warehouseidtodecrease = (isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0); $warehouseidtodecrease = (isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0);
if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $warehouseidtodecrease = 0; // If a particular stock is defined, we disable choice if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) {
$warehouseidtodecrease = 0; // If a particular stock is defined, we disable choice
}
$resultvalid = $invoice->validate($user, $obj_facturation->numInvoice(), 0); $resultvalid = $invoice->validate($user, $obj_facturation->numInvoice(), 0);
if ($warehouseidtodecrease > 0) if ($warehouseidtodecrease > 0) {
{
// Decrease // Decrease
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
$langs->load("agenda"); $langs->load("agenda");
// Loop on each line // Loop on each line
$cpt = count($invoice->lines); $cpt = count($invoice->lines);
for ($i = 0; $i < $cpt; $i++) for ($i = 0; $i < $cpt; $i++) {
{ if ($invoice->lines[$i]->fk_product > 0) {
if ($invoice->lines[$i]->fk_product > 0)
{
$mouvP = new MouvementStock($db); $mouvP = new MouvementStock($db);
$mouvP->origin = &$invoice; $mouvP->origin = &$invoice;
// We decrease stock for product // We decrease stock for product
if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) {
else $result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); $result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref));
} else {
$result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref));
}
if ($result < 0) { if ($result < 0) {
$error++; $error++;
} }
@ -258,29 +260,30 @@ switch ($action)
$id = $invoice->id; $id = $invoice->id;
} else { } else {
$resultcreate = $invoice->create($user, 0, 0); $resultcreate = $invoice->create($user, 0, 0);
if ($resultcreate > 0) if ($resultcreate > 0) {
{
$warehouseidtodecrease = (isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0); $warehouseidtodecrease = (isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0);
if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $warehouseidtodecrease = 0; // If a particular stock is defined, we disable choice if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) {
$warehouseidtodecrease = 0; // If a particular stock is defined, we disable choice
}
$resultvalid = $invoice->validate($user, $obj_facturation->numInvoice(), 0); $resultvalid = $invoice->validate($user, $obj_facturation->numInvoice(), 0);
if ($warehouseidtodecrease > 0) if ($warehouseidtodecrease > 0) {
{
// Decrease // Decrease
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
$langs->load("agenda"); $langs->load("agenda");
// Loop on each line // Loop on each line
$cpt = count($invoice->lines); $cpt = count($invoice->lines);
for ($i = 0; $i < $cpt; $i++) for ($i = 0; $i < $cpt; $i++) {
{ if ($invoice->lines[$i]->fk_product > 0) {
if ($invoice->lines[$i]->fk_product > 0)
{
$mouvP = new MouvementStock($db); $mouvP = new MouvementStock($db);
$mouvP->origin = &$invoice; $mouvP->origin = &$invoice;
// We decrease stock for product // We decrease stock for product
if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) {
else $result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); $result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref));
} else {
$result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref));
}
if ($result < 0) { if ($result < 0) {
setEventMessages($mouvP->error, $mouvP->errors, 'errors'); setEventMessages($mouvP->error, $mouvP->errors, 'errors');
$error++; $error++;
@ -301,26 +304,21 @@ switch ($action)
$payment->num_payment = ''; $payment->num_payment = '';
$paiement_id = $payment->create($user); $paiement_id = $payment->create($user);
if ($paiement_id > 0) if ($paiement_id > 0) {
{ if (!$error) {
if (!$error)
{
$result = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccountid, '', ''); $result = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccountid, '', '');
if (!$result > 0) if (!$result > 0) {
{
$errmsg = $paiement->error; $errmsg = $paiement->error;
$error++; $error++;
} }
} }
if (!$error) if (!$error) {
{
if ($invoice->total_ttc == $obj_facturation->amountWithTax() if ($invoice->total_ttc == $obj_facturation->amountWithTax()
&& $obj_facturation->getSetPaymentMode() != 'DIFF') && $obj_facturation->getSetPaymentMode() != 'DIFF') {
{
// We set status to paid // We set status to paid
$result = $invoice->setPaid($user); $result = $invoice->setPaid($user);
//print 'set paid';exit; //print 'set paid';exit;
} }
} }
} else { } else {
@ -334,8 +332,7 @@ switch ($action)
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
$redirection = 'affIndex.php?menutpl=validation_ok&facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr $redirection = 'affIndex.php?menutpl=validation_ok&facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
} else { } else {