Merge pull request #16470 from frederic34/s_code_syntax

code syntax s... t..  dir
This commit is contained in:
Laurent Destailleur 2021-02-28 23:37:25 +01:00 committed by GitHub
commit f7933a6884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
91 changed files with 6657 additions and 5432 deletions

View File

@ -27,14 +27,17 @@ require '../../main.inc.php';
// Class // Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; if (!empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'salaries')); $langs->loadLangs(array('admin', 'salaries'));
// Security check // Security check
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -47,8 +50,7 @@ $list = array(
* Actions * Actions
*/ */
if ($action == 'update') if ($action == 'update') {
{
$error = 0; $error = 0;
foreach ($list as $constname) { foreach ($list as $constname) {
@ -59,8 +61,7 @@ if ($action == 'update')
} }
} }
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -74,7 +75,9 @@ if ($action == 'update')
llxHeader('', $langs->trans('SalariesSetup')); llxHeader('', $langs->trans('SalariesSetup'));
$form = new Form($db); $form = new Form($db);
if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); if (!empty($conf->accounting->enabled)) {
$formaccounting = new FormAccounting($db);
}
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans('SalariesSetup'), $linkback, 'title_setup'); print load_fiche_titre($langs->trans('SalariesSetup'), $linkback, 'title_setup');
@ -99,8 +102,7 @@ print '<td>'.$langs->trans("Parameters").'</td>';
print '<td width="60">'.$langs->trans("Value")."</td>\n"; print '<td width="60">'.$langs->trans("Value")."</td>\n";
print "</tr>\n"; print "</tr>\n";
foreach ($list as $key) foreach ($list as $key) {
{
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
// Param // Param
@ -109,8 +111,7 @@ foreach ($list as $key)
// Value // Value
print '<td>'; print '<td>';
if (!empty($conf->accounting->enabled)) if (!empty($conf->accounting->enabled)) {
{
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
} else { } else {
print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">'; print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';

View File

@ -36,13 +36,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'payment_salary'; //Must be the $table_element of the class that manage extrafield $elementtype = 'payment_salary'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -77,8 +81,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute").'</a></div>';
print "</div>"; print "</div>";
@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<div name="topofform"></div><br>'; print '<div name="topofform"></div><br>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -104,8 +106,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print '<div name="topofform"></div><br>'; print '<div name="topofform"></div><br>';
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -31,15 +31,16 @@ require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
} }
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("compta", "banks", "bills", "users", "salaries", "hrm")); $langs->loadLangs(array("compta", "banks", "bills", "users", "salaries", "hrm"));
if (!empty($conf->projet->enabled)) $langs->load("projects"); if (!empty($conf->projet->enabled)) {
$langs->load("projects");
}
$id = GETPOST("id", 'int'); $id = GETPOST("id", 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -54,7 +55,9 @@ $dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday
// Security check // Security check
$socid = GETPOST("socid", "int"); $socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'salaries', '', '', ''); $result = restrictedArea($user, 'salaries', '', '', '');
$object = new PaymentSalary($db); $object = new PaymentSalary($db);
@ -71,24 +74,23 @@ $hookmanager->initHooks(array('salarycard', 'globalcard'));
* Actions * Actions
*/ */
if ($cancel) if ($cancel) {
{
header("Location: list.php"); header("Location: list.php");
exit; exit;
} }
// Link to a project // Link to a project
if ($action == 'classin' && $user->rights->banque->modifier) if ($action == 'classin' && $user->rights->banque->modifier) {
{
$object->fetch($id); $object->fetch($id);
$object->setProject($projectid); $object->setProject($projectid);
} }
if ($action == 'add' && empty($cancel)) if ($action == 'add' && empty($cancel)) {
{
$error = 0; $error = 0;
if (empty($datev)) $datev = $datep; if (empty($datev)) {
$datev = $datep;
}
$type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement', 'code', 'id', 1); $type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement', 'code', 'id', 1);
@ -113,41 +115,36 @@ if ($action == 'add' && empty($cancel))
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++; if ($ret < 0) {
$error++;
}
if (empty($datep) || empty($datev) || empty($datesp) || empty($dateep)) if (empty($datep) || empty($datev) || empty($datesp) || empty($dateep)) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$error++; $error++;
} }
if (empty($object->fk_user) || $object->fk_user < 0) if (empty($object->fk_user) || $object->fk_user < 0) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Employee")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Employee")), null, 'errors');
$error++; $error++;
} }
if (empty($type_payment) || $type_payment < 0) if (empty($type_payment) || $type_payment < 0) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
$error++; $error++;
} }
if (empty($object->amount)) if (empty($object->amount)) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
$error++; $error++;
} }
if (!empty($conf->banque->enabled) && !$object->accountid > 0) if (!empty($conf->banque->enabled) && !$object->accountid > 0) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error) {
{
$db->begin(); $db->begin();
$ret = $object->create($user); $ret = $object->create($user);
if ($ret > 0) if ($ret > 0) {
{
$db->commit(); $db->commit();
if (GETPOST('saveandnew', 'alpha')) { if (GETPOST('saveandnew', 'alpha')) {
@ -168,26 +165,23 @@ if ($action == 'add' && empty($cancel))
$action = 'create'; $action = 'create';
} }
if ($action == 'delete') if ($action == 'delete') {
{
$result = $object->fetch($id); $result = $object->fetch($id);
if ($object->rappro == 0) if ($object->rappro == 0) {
{
$db->begin(); $db->begin();
$ret = $object->delete($user); $ret = $object->delete($user);
if ($ret > 0) if ($ret > 0) {
{ if ($object->fk_bank) {
if ($object->fk_bank)
{
$accountline = new AccountLine($db); $accountline = new AccountLine($db);
$result = $accountline->fetch($object->fk_bank); $result = $accountline->fetch($object->fk_bank);
if ($result > 0) $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) if ($result > 0) {
$result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
}
} }
if ($result >= 0) if ($result >= 0) {
{
$db->commit(); $db->commit();
header("Location: ".DOL_URL_ROOT.'/salaries/list.php'); header("Location: ".DOL_URL_ROOT.'/salaries/list.php');
exit; exit;
@ -213,27 +207,25 @@ if ($action == 'delete')
llxHeader("", $langs->trans("SalaryPayment")); llxHeader("", $langs->trans("SalaryPayment"));
$form = new Form($db); $form = new Form($db);
if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); if (!empty($conf->projet->enabled)) {
$formproject = new FormProjets($db);
}
if ($id) if ($id) {
{
$object = new PaymentSalary($db); $object = new PaymentSalary($db);
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) if ($result <= 0) {
{
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
} }
// Create // Create
if ($action == 'create') if ($action == 'create') {
{
$year_current = strftime("%Y", dol_now()); $year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1; $pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current; $pastmonthyear = $year_current;
if ($pastmonth == 0) if ($pastmonth == 0) {
{
$pastmonth = 12; $pastmonth = 12;
$pastmonthyear--; $pastmonthyear--;
} }
@ -247,8 +239,7 @@ if ($action == 'create')
$datesp = dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear); $datesp = dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
$dateep = dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear); $dateep = dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
if (empty($datesp) || empty($dateep)) // We define date_start and date_end if (empty($datesp) || empty($dateep)) { // We define date_start and date_end
{
$datesp = dol_get_first_day($pastmonthyear, $pastmonth, false); $dateep = dol_get_last_day($pastmonthyear, $pastmonth, false); $datesp = dol_get_first_day($pastmonthyear, $pastmonth, false); $dateep = dol_get_last_day($pastmonthyear, $pastmonth, false);
} }
@ -306,8 +297,7 @@ if ($action == 'create')
print '</td></tr>'; print '</td></tr>';
// Bank // Bank
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled)) {
{
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).'</td><td>'; print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).'</td><td>';
$form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant $form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant
@ -321,8 +311,7 @@ if ($action == 'create')
print '</td></tr>'; print '</td></tr>';
// Number // Number
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled)) {
{
// Number // Number
print '<tr><td><label for="num_payment">'.$langs->trans('Numero'); print '<tr><td><label for="num_payment">'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
@ -331,8 +320,7 @@ if ($action == 'create')
} }
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$formproject = new FormProjets($db); $formproject = new FormProjets($db);
print '<tr><td>'.$langs->trans("Project").'</td><td>'; print '<tr><td>'.$langs->trans("Project").'</td><td>';
@ -344,8 +332,7 @@ if ($action == 'create')
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook)) {
{
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
} }
@ -371,8 +358,7 @@ if ($action == 'create')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($id) if ($id) {
{
$head = salaries_prepare_head($object); $head = salaries_prepare_head($object);
print dol_get_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'salary'); print dol_get_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'salary');
@ -387,11 +373,9 @@ if ($id)
$morehtmlref .= $langs->trans('Employee').' : '.$userstatic->getNomUrl(1); $morehtmlref .= $langs->trans('Employee').' : '.$userstatic->getNomUrl(1);
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->salaries->write) if ($user->rights->salaries->write) {
{
if ($action != 'classify') { if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
} }
@ -450,10 +434,8 @@ if ($id)
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>'; print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled)) {
{ if ($object->fk_account > 0) {
if ($object->fk_account > 0)
{
$bankline = new AccountLine($db); $bankline = new AccountLine($db);
$bankline->fetch($object->fk_bank); $bankline->fetch($object->fk_bank);
@ -479,10 +461,8 @@ if ($id)
// Action buttons // Action buttons
print '<div class="tabsAction">'."\n"; print '<div class="tabsAction">'."\n";
if ($object->rappro == 0) if ($object->rappro == 0) {
{ if (!empty($user->rights->salaries->delete)) {
if (!empty($user->rights->salaries->delete))
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a></div>';
} else { } else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a></div>';

View File

@ -65,8 +65,11 @@ class SalariesStats extends Stats
if ($this->socid) { if ($this->socid) {
$this->where .= " AND fk_soc = ".$this->socid; $this->where .= " AND fk_soc = ".$this->socid;
} }
if (is_array($this->userid) && count($this->userid) > 0) $this->where .= ' AND fk_user IN ('.join(',', $this->userid).')'; if (is_array($this->userid) && count($this->userid) > 0) {
elseif ($this->userid > 0) $this->where .= ' AND fk_user = '.$this->userid; $this->where .= ' AND fk_user IN ('.join(',', $this->userid).')';
} elseif ($this->userid > 0) {
$this->where .= ' AND fk_user = '.$this->userid;
}
} }

View File

@ -45,7 +45,9 @@ $confirm = GETPOST('confirm', 'alpha');
// Security check // Security check
$socid = GETPOST("socid", "int"); $socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'salaries', '', '', ''); $result = restrictedArea($user, 'salaries', '', '', '');
@ -54,12 +56,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "name"; $sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$object = new PaymentSalary($db); $object = new PaymentSalary($db);
@ -84,8 +92,7 @@ $form = new Form($db);
llxHeader("", $langs->trans("SalaryPayment")); llxHeader("", $langs->trans("SalaryPayment"));
if ($object->id) if ($object->id) {
{
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$head = salaries_prepare_head($object); $head = salaries_prepare_head($object);
@ -95,8 +102,7 @@ if ($object->id)
// Build file list // Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0; $totalsize = 0;
foreach ($filearray as $key => $file) foreach ($filearray as $key => $file) {
{
$totalsize += $file['size']; $totalsize += $file['size'];
} }

View File

@ -36,7 +36,9 @@ $action = GETPOST('action', 'aZ09');
// Security check // Security check
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'salaries', '', '', ''); $result = restrictedArea($user, 'salaries', '', '', '');

View File

@ -32,13 +32,19 @@ $langs->loadLangs(array("salaries", "companies"));
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
$userid = GETPOST('userid', 'int'); if ($userid < 0) $userid = 0; $userid = GETPOST('userid', 'int'); if ($userid < 0) {
$socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0; $userid = 0;
}
$socid = GETPOST('socid', 'int'); if ($socid < 0) {
$socid = 0;
}
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
// Security check // Security check
$socid = GETPOST("socid", "int"); $socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'salaries', '', '', ''); $result = restrictedArea($user, 'salaries', '', '', '');
$nowyear = strftime("%Y", dol_now()); $nowyear = strftime("%Y", dol_now());
@ -80,12 +86,10 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=salariesstats&amp;file=sala
$px1 = new DolGraph(); $px1 = new DolGraph();
$mesg = $px1->isGraphKo(); $mesg = $px1->isGraphKo();
if (!$mesg) if (!$mesg) {
{
$px1->SetData($data); $px1->SetData($data);
$i = $startyear; $legend = array(); $i = $startyear; $legend = array();
while ($i <= $endyear) while ($i <= $endyear) {
{
$legend[] = $i; $legend[] = $i;
$i++; $i++;
} }
@ -112,12 +116,10 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=salariesstats&amp;file=
$px2 = new DolGraph(); $px2 = new DolGraph();
$mesg = $px2->isGraphKo(); $mesg = $px2->isGraphKo();
if (!$mesg) if (!$mesg) {
{
$px2->SetData($data); $px2->SetData($data);
$i = $startyear; $legend = array(); $i = $startyear; $legend = array();
while ($i <= $endyear) while ($i <= $endyear) {
{
$legend[] = $i; $legend[] = $i;
$i++; $i++;
} }
@ -143,12 +145,10 @@ $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=salariesstats&file=salari
$px3 = new DolGraph(); $px3 = new DolGraph();
$mesg = $px3->isGraphKo(); $mesg = $px3->isGraphKo();
if (!$mesg) if (!$mesg) {
{
$px3->SetData($data); $px3->SetData($data);
$i = $startyear; $legend = array(); $i = $startyear; $legend = array();
while ($i <= $endyear) while ($i <= $endyear) {
{
$legend[] = $i; $legend[] = $i;
$i++; $i++;
} }
@ -173,7 +173,9 @@ $arrayyears = array();
foreach ($data as $val) { foreach ($data as $val) {
$arrayyears[$val['year']] = $val['year']; $arrayyears[$val['year']] = $val['year'];
} }
if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; if (!count($arrayyears)) {
$arrayyears[$nowyear] = $nowyear;
}
$h = 0; $h = 0;
@ -203,7 +205,9 @@ print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0
print '</td></tr>'; print '</td></tr>';
// Year // Year
print '<tr><td>'.$langs->trans("Year").'</td><td>'; print '<tr><td>'.$langs->trans("Year").'</td><td>';
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; if (!in_array($year, $arrayyears)) {
$arrayyears[$year] = $year;
}
arsort($arrayyears); arsort($arrayyears);
print $form->selectarray('year', $arrayyears, $year, 0); print $form->selectarray('year', $arrayyears, $year, 0);
print '</td></tr>'; print '</td></tr>';
@ -222,11 +226,9 @@ print '<td class="right">'.$langs->trans("AmountAverage").'</td>';
print '</tr>'; print '</tr>';
$oldyear = 0; $oldyear = 0;
foreach ($data as $val) foreach ($data as $val) {
{
$year = $val['year']; $year = $val['year'];
while ($year && $oldyear > $year + 1) while ($year && $oldyear > $year + 1) {
{
// If we have empty year // If we have empty year
$oldyear--; $oldyear--;
@ -256,7 +258,9 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Show graphs // Show graphs
print '<table class="border centpercent"><tr class="pair nohover"><td align="center">'; print '<table class="border centpercent"><tr class="pair nohover"><td align="center">';
if ($mesg) { print $mesg; } else { if ($mesg) {
print $mesg;
} else {
print $px1->show(); print $px1->show();
print "<br>\n"; print "<br>\n";
print $px2->show(); print $px2->show();

View File

@ -36,13 +36,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'socpeople'; //Must be the $element of the class that manage extrafield $elementtype = 'socpeople'; //Must be the $element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -77,8 +81,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -104,8 +106,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -35,7 +35,9 @@ $langs->loadLangs(array("admin", "companies", "other"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
@ -47,10 +49,8 @@ $formcompany = new FormCompany($db);
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'setcodeclient') if ($action == 'setcodeclient') {
{ if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) {
if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -58,10 +58,8 @@ if ($action == 'setcodeclient')
} }
} }
if ($action == 'setcodecompta') if ($action == 'setcodecompta') {
{ if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) {
if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -69,41 +67,40 @@ if ($action == 'setcodecompta')
} }
} }
if ($action == 'updateoptions') if ($action == 'updateoptions') {
{ if (GETPOST('COMPANY_USE_SEARCH_TO_SELECT')) {
if (GETPOST('COMPANY_USE_SEARCH_TO_SELECT'))
{
$companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT', 'alpha'); $companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT', 'alpha');
$res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
if (!$error) $error++;
{ }
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
if (GETPOST('CONTACT_USE_SEARCH_TO_SELECT')) if (GETPOST('CONTACT_USE_SEARCH_TO_SELECT')) {
{
$contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT', 'alpha'); $contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT', 'alpha');
$res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
if (!$error) $error++;
{ }
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
if (GETPOST('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')) if (GETPOST('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')) {
{
$customertypedefault = GETPOST('defaultcustomertype', 'int'); $customertypedefault = GETPOST('defaultcustomertype', 'int');
$res = dolibarr_set_const($db, "THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT", $customertypedefault, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT", $customertypedefault, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
if (!$error) $error++;
{ }
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -112,8 +109,7 @@ if ($action == 'updateoptions')
} }
// Activate a document generator module // Activate a document generator module
if ($action == 'set') if ($action == 'set') {
{
$label = GETPOST('label', 'alpha'); $label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha');
@ -125,22 +121,24 @@ if ($action == 'set')
$sql .= ")"; $sql .= ")";
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) dol_print_error($db); if (!$resql) {
dol_print_error($db);
}
} }
// Disable a document generator module // Disable a document generator module
if ($action == 'del') if ($action == 'del') {
{
$type = 'company'; $type = 'company';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE nom='".$db->escape($value)."' AND type='".$db->escape($type)."' AND entity=".$conf->entity; $sql .= " WHERE nom='".$db->escape($value)."' AND type='".$db->escape($type)."' AND entity=".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) dol_print_error($db); if (!$resql) {
dol_print_error($db);
}
} }
// Define default generator // Define default generator
if ($action == 'setdoc') if ($action == 'setdoc') {
{
$label = GETPOST('label', 'alpha'); $label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha');
@ -164,8 +162,7 @@ if ($action == 'setdoc')
$sql .= ")"; $sql .= ")";
dol_syslog("societe.php", LOG_DEBUG); dol_syslog("societe.php", LOG_DEBUG);
$result2 = $db->query($sql); $result2 = $db->query($sql);
if ($result1 && $result2) if ($result1 && $result2) {
{
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
@ -176,9 +173,10 @@ if ($action == 'setdoc')
if ($action == "setaddrefinlist") { if ($action == "setaddrefinlist") {
$setaddrefinlist = GETPOST('value', 'int'); $setaddrefinlist = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist, 'yesno', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
if (!$error) $error++;
{ }
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -189,9 +187,10 @@ if ($action == "setaddrefinlist") {
if ($action == "setaddadressinlist") { if ($action == "setaddadressinlist") {
$val = GETPOST('value', 'int'); $val = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
if (!$error) $error++;
{ }
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -202,7 +201,9 @@ if ($action == "setaddadressinlist") {
if ($action == "setaddemailphonetownincontactlist") { if ($action == "setaddemailphonetownincontactlist") {
$val = GETPOST('value', 'int'); $val = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST", $val, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -214,9 +215,10 @@ if ($action == "setaddemailphonetownincontactlist") {
if ($action == "setaskforshippingmet") { if ($action == "setaskforshippingmet") {
$setaskforshippingmet = GETPOST('value', 'int'); $setaskforshippingmet = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet, 'yesno', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
if (!$error) $error++;
{ }
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -227,9 +229,10 @@ if ($action == "setaskforshippingmet") {
if ($action == "setdisableprospectcustomer") { if ($action == "setdisableprospectcustomer") {
$setdisableprospectcustomer = GETPOST('value', 'int'); $setdisableprospectcustomer = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
if (!$error) $error++;
{ }
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -237,13 +240,11 @@ if ($action == "setdisableprospectcustomer") {
} }
//Activate ProfId unique //Activate ProfId unique
if ($action == 'setprofid') if ($action == 'setprofid') {
{
$status = GETPOST('status', 'alpha'); $status = GETPOST('status', 'alpha');
$idprof = "SOCIETE_".$value."_UNIQUE"; $idprof = "SOCIETE_".$value."_UNIQUE";
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) {
{
//header("Location: ".$_SERVER["PHP_SELF"]); //header("Location: ".$_SERVER["PHP_SELF"]);
//exit; //exit;
} else { } else {
@ -252,13 +253,11 @@ if ($action == 'setprofid')
} }
//Activate ProfId mandatory //Activate ProfId mandatory
if ($action == 'setprofidmandatory') if ($action == 'setprofidmandatory') {
{
$status = GETPOST('status', 'alpha'); $status = GETPOST('status', 'alpha');
$idprof = "SOCIETE_".$value."_MANDATORY"; $idprof = "SOCIETE_".$value."_MANDATORY";
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) {
{
//header("Location: ".$_SERVER["PHP_SELF"]); //header("Location: ".$_SERVER["PHP_SELF"]);
//exit; //exit;
} else { } else {
@ -267,13 +266,11 @@ if ($action == 'setprofidmandatory')
} }
//Activate ProfId invoice mandatory //Activate ProfId invoice mandatory
if ($action == 'setprofidinvoicemandatory') if ($action == 'setprofidinvoicemandatory') {
{
$status = GETPOST('status', 'alpha'); $status = GETPOST('status', 'alpha');
$idprof = "SOCIETE_".$value."_INVOICE_MANDATORY"; $idprof = "SOCIETE_".$value."_INVOICE_MANDATORY";
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) {
{
//header("Location: ".$_SERVER["PHP_SELF"]); //header("Location: ".$_SERVER["PHP_SELF"]);
//exit; //exit;
} else { } else {
@ -282,12 +279,10 @@ if ($action == 'setprofidinvoicemandatory')
} }
//Set hide closed customer into combox or select //Set hide closed customer into combox or select
if ($action == 'sethideinactivethirdparty') if ($action == 'sethideinactivethirdparty') {
{
$status = GETPOST('status', 'alpha'); $status = GETPOST('status', 'alpha');
if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -297,9 +292,10 @@ if ($action == 'sethideinactivethirdparty')
if ($action == 'setonsearchandlistgooncustomerorsuppliercard') { if ($action == 'setonsearchandlistgooncustomerorsuppliercard') {
$setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int'); $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
if (!$error) $error++;
{ }
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -326,7 +322,9 @@ $head = societe_admin_prepare_head();
print dol_get_fiche_head($head, 'general', $langs->trans("ThirdParties"), -1, 'company'); print dol_get_fiche_head($head, 'general', $langs->trans("ThirdParties"), -1, 'company');
$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
foreach ($conf->modules_parts['models'] as $mo) $dirsociete[] = $mo.'core/modules/societe/'; //Add more models foreach ($conf->modules_parts['models'] as $mo) {
$dirsociete[] = $mo.'core/modules/societe/'; //Add more models
}
// Module to manage customer/supplier code // Module to manage customer/supplier code
@ -344,32 +342,31 @@ print "</tr>\n";
$arrayofmodules = array(); $arrayofmodules = array();
foreach ($dirsociete as $dirroot) foreach ($dirsociete as $dirroot) {
{
$dir = dol_buildpath($dirroot, 0); $dir = dol_buildpath($dirroot, 0);
$handle = @opendir($dir); $handle = @opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{
// Loop on each module find in opened directory // Loop on each module find in opened directory
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false) {
{ if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php') {
if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php')
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
try { try {
dol_include_once($dirroot.$file.'.php'); dol_include_once($dirroot.$file.'.php');
} catch (Exception $e) } catch (Exception $e) {
{
dol_syslog($e->getMessage(), LOG_ERR); dol_syslog($e->getMessage(), LOG_ERR);
} }
$modCodeTiers = new $file; $modCodeTiers = new $file;
// Show modules according to features level // Show modules according to features level
if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
$arrayofmodules[$file] = $modCodeTiers; $arrayofmodules[$file] = $modCodeTiers;
} }
@ -380,24 +377,26 @@ foreach ($dirsociete as $dirroot)
$arrayofmodules = dol_sort_array($arrayofmodules, 'position'); $arrayofmodules = dol_sort_array($arrayofmodules, 'position');
foreach ($arrayofmodules as $file => $modCodeTiers) foreach ($arrayofmodules as $file => $modCodeTiers) {
{
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";
print '<td width="140">'.$modCodeTiers->name.'</td>'."\n"; print '<td width="140">'.$modCodeTiers->name.'</td>'."\n";
print '<td>'.$modCodeTiers->info($langs).'</td>'."\n"; print '<td>'.$modCodeTiers->info($langs).'</td>'."\n";
print '<td class="nowrap">'.$modCodeTiers->getExample($langs).'</td>'."\n"; print '<td class="nowrap">'.$modCodeTiers->getExample($langs).'</td>'."\n";
if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file") if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file") {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print "</td>\n"; print "</td>\n";
} else { } else {
$disabled = (!empty($conf->multicompany->enabled) && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false); $disabled = (!empty($conf->multicompany->enabled) && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false);
print '<td class="center">'; print '<td class="center">';
if (!$disabled) print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; if (!$disabled) {
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
}
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
if (!$disabled) print '</a>'; if (!$disabled) {
print '</a>';
}
print '</td>'; print '</td>';
} }
@ -430,23 +429,18 @@ print "</tr>\n";
$arrayofmodules = array(); $arrayofmodules = array();
foreach ($dirsociete as $dirroot) foreach ($dirsociete as $dirroot) {
{
$dir = dol_buildpath($dirroot, 0); $dir = dol_buildpath($dirroot, 0);
$handle = @opendir($dir); $handle = @opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php') {
{
if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php')
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
try { try {
dol_include_once($dirroot.$file.'.php'); dol_include_once($dirroot.$file.'.php');
} catch (Exception $e) } catch (Exception $e) {
{
dol_syslog($e->getMessage(), LOG_ERR); dol_syslog($e->getMessage(), LOG_ERR);
} }
@ -462,16 +456,14 @@ foreach ($dirsociete as $dirroot)
$arrayofmodules = dol_sort_array($arrayofmodules, 'position'); $arrayofmodules = dol_sort_array($arrayofmodules, 'position');
foreach ($arrayofmodules as $file => $modCodeCompta) foreach ($arrayofmodules as $file => $modCodeCompta) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$modCodeCompta->name."</td><td>\n"; print '<td>'.$modCodeCompta->name."</td><td>\n";
print $modCodeCompta->info($langs); print $modCodeCompta->info($langs);
print '</td>'; print '</td>';
print '<td class="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n"; print '<td class="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n";
if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file") if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file") {
{
print '<td class="center">'; print '<td class="center">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</td>'; print '</td>';
@ -503,12 +495,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = 'company'"; $sql .= " WHERE type = 'company'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -527,24 +517,19 @@ print '<td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
print '<td class="center" width="60">'.$langs->trans("Preview").'</td>'; print '<td class="center" width="60">'.$langs->trans("Preview").'</td>';
print "</tr>\n"; print "</tr>\n";
foreach ($dirsociete as $dirroot) foreach ($dirsociete as $dirroot) {
{
$dir = dol_buildpath($dirroot.'doc/', 0); $dir = dol_buildpath($dirroot.'doc/', 0);
$handle = @opendir($dir); $handle = @opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (preg_match('/\.modules\.php$/i', $file)) {
{
if (preg_match('/\.modules\.php$/i', $file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
try { try {
dol_include_once($dirroot.'doc/'.$file); dol_include_once($dirroot.'doc/'.$file);
} catch (Exception $e) } catch (Exception $e) {
{
dol_syslog($e->getMessage(), LOG_ERR); dol_syslog($e->getMessage(), LOG_ERR);
} }
@ -552,22 +537,26 @@ foreach ($dirsociete as $dirroot)
$modulequalified = 1; $modulequalified = 1;
if (!empty($module->version)) { if (!empty($module->version)) {
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
elseif ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
} elseif ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
} }
if ($modulequalified) if ($modulequalified) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print $module->name; print $module->name;
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Activate / Disable // Activate / Disable
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print "<td class=\"center\">\n"; print "<td class=\"center\">\n";
//if ($conf->global->COMPANY_ADDON_PDF != "$name") //if ($conf->global->COMPANY_ADDON_PDF != "$name")
//{ //{
@ -581,8 +570,7 @@ foreach ($dirsociete as $dirroot)
//} //}
print "</td>"; print "</td>";
} else { } else {
if (versioncompare($module->phpmin, versionphparray()) > 0) if (versioncompare($module->phpmin, versionphparray()) > 0) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion", join('.', $module->phpmin))), 'switch_off'); print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion", join('.', $module->phpmin))), 'switch_off');
print "</td>"; print "</td>";
@ -596,8 +584,7 @@ foreach ($dirsociete as $dirroot)
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$htmltooltip .= '<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; $htmltooltip .= '<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur;
} }
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
@ -609,8 +596,7 @@ foreach ($dirsociete as $dirroot)
// Preview // Preview
print '<td class="center nowrap">'; print '<td class="center nowrap">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$linkspec = '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&token='.newToken().'&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>'; $linkspec = '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&token='.newToken().'&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
} else { } else {
$linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic'); $linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -659,10 +645,8 @@ $profid['EMAIL'][0] = $langs->trans("EMail");
$profid['EMAIL'][1] = $langs->trans('Email'); $profid['EMAIL'][1] = $langs->trans('Email');
$nbofloop = count($profid); $nbofloop = count($profid);
foreach ($profid as $key => $val) foreach ($profid as $key => $val) {
{ if ($profid[$key][1] != '-') {
if ($profid[$key][1] != '-')
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$profid[$key][0]."</td><td>\n"; print '<td>'.$profid[$key][0]."</td><td>\n";
print $profid[$key][1]; print $profid[$key][1];
@ -676,8 +660,7 @@ foreach ($profid as $key => $val)
$mandatory = (empty($conf->global->$idprof_mandatory) ?false:true); $mandatory = (empty($conf->global->$idprof_mandatory) ?false:true);
$invoice_mandatory = (empty($conf->global->$idprof_invoice_mandatory) ?false:true); $invoice_mandatory = (empty($conf->global->$idprof_invoice_mandatory) ?false:true);
if ($verif) if ($verif) {
{
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=0">'; print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>'; print '</a></td>';
@ -687,8 +670,7 @@ foreach ($profid as $key => $val)
print '</a></td>'; print '</a></td>';
} }
if ($mandatory) if ($mandatory) {
{
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&token='.newToken().'&value='.$key.'&status=0">'; print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&token='.newToken().'&value='.$key.'&status=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>'; print '</a></td>';
@ -698,8 +680,7 @@ foreach ($profid as $key => $val)
print '</a></td>'; print '</a></td>';
} }
if ($invoice_mandatory) if ($invoice_mandatory) {
{
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=0">'; print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>'; print '</a></td>';
@ -740,8 +721,7 @@ print '<td width="80">&nbsp;</td></tr>'."\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"), $langs->trans('UseSearchToSelectCompanyTooltip'), 1).' </td>'; print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"), $langs->trans('UseSearchToSelectCompanyTooltip'), 1).' </td>';
if (!$conf->use_javascript_ajax) if (!$conf->use_javascript_ajax) {
{
print '<td class="nowrap right" colspan="2">'; print '<td class="nowrap right" colspan="2">';
print $langs->trans("NotAvailableWhenAjaxDisabled"); print $langs->trans("NotAvailableWhenAjaxDisabled");
print "</td>"; print "</td>";
@ -762,8 +742,7 @@ print '</tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"), $langs->trans('UseSearchToSelectContactTooltip'), 1).'</td>'; print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"), $langs->trans('UseSearchToSelectContactTooltip'), 1).'</td>';
if (!$conf->use_javascript_ajax) if (!$conf->use_javascript_ajax) {
{
print '<td class="nowrap right" colspan="2">'; print '<td class="nowrap right" colspan="2">';
print $langs->trans("NotAvailableWhenAjaxDisabled"); print $langs->trans("NotAvailableWhenAjaxDisabled");
print "</td>"; print "</td>";
@ -787,8 +766,7 @@ print '<tr class="oddeven">';
print '<td width="80%">'.$langs->trans("AddRefInList").'</td>'; print '<td width="80%">'.$langs->trans("AddRefInList").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td class="center">'; print '<td class="center">';
if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) {
{
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&token='.newToken().'&value=0">'; print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&token='.newToken().'&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
@ -802,8 +780,7 @@ print '<tr class="oddeven">';
print '<td width="80%">'.$langs->trans("AddAdressInList").'</td>'; print '<td width="80%">'.$langs->trans("AddAdressInList").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td class="center">'; print '<td class="center">';
if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
{
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&token='.newToken().'&value=0">'; print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&token='.newToken().'&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
@ -833,8 +810,7 @@ if (!empty($conf->expedition->enabled)) {
print '<td width="80%">'.$langs->trans("AskForPreferredShippingMethod").'</td>'; print '<td width="80%">'.$langs->trans("AskForPreferredShippingMethod").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td class="center">'; print '<td class="center">';
if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) {
{
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&token='.newToken().'&value=0">'; print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&token='.newToken().'&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
@ -851,8 +827,7 @@ print '<tr class="oddeven">';
print '<td width="80%">'.$langs->trans("DisableProspectCustomerType").'</td>'; print '<td width="80%">'.$langs->trans("DisableProspectCustomerType").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td class="center">'; print '<td class="center">';
if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
{
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&token='.newToken().'&value=0">'; print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&token='.newToken().'&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {

View File

@ -36,13 +36,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'societe'; //Must be the $element of the class that manage extrafield $elementtype = 'societe'; //Must be the $element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -77,8 +81,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -104,8 +106,7 @@ if ($action == 'create')
/* Edition d'un champ optionnel */ /* Edition d'un champ optionnel */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print '<br><div id="editattrib"></div>'; print '<br><div id="editattrib"></div>';
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -34,10 +34,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->loadLangs(array("companies", "bills", "propal", "orders")); $langs->loadLangs(array("companies", "bills", "propal", "orders"));
if (GETPOST('actioncode', 'array')) if (GETPOST('actioncode', 'array')) {
{
$actioncode = GETPOST('actioncode', 'array', 3); $actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0'; if (!count($actioncode)) {
$actioncode = '0';
}
} else { } else {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
} }
@ -45,19 +46,27 @@ $search_agenda_label = GETPOST('search_agenda_label');
// Security check // Security check
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'societe', $socid, '&societe'); $result = restrictedArea($user, 'societe', $socid, '&societe');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) $sortfield = 'a.datep,a.id'; if (!$sortfield) {
if (!$sortorder) $sortorder = 'DESC,DESC'; $sortfield = 'a.datep,a.id';
}
if (!$sortorder) {
$sortorder = 'DESC,DESC';
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('agendathirdparty')); $hookmanager->initHooks(array('agendathirdparty'));
@ -69,20 +78,19 @@ $hookmanager->initHooks(array('agendathirdparty'));
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Cancel // Cancel
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
{
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} }
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
{
$actioncode = ''; $actioncode = '';
$search_agenda_label = ''; $search_agenda_label = '';
} }
@ -96,8 +104,7 @@ if (empty($reshook))
$form = new Form($db); $form = new Form($db);
if ($socid > 0) if ($socid > 0) {
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@ -105,10 +112,14 @@ if ($socid > 0)
$result = $object->fetch($socid); $result = $object->fetch($socid);
$title = $langs->trans("Agenda"); $title = $langs->trans("Agenda");
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name." - ".$title;
}
llxHeader('', $title); llxHeader('', $title);
if (!empty($conf->notification->enabled)) $langs->load("mails"); if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = societe_prepare_head($object); $head = societe_prepare_head($object);
print dol_get_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, 'company'); print dol_get_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, 'company');
@ -137,29 +148,31 @@ if ($socid > 0)
$out = ''; $out = '';
$permok = $user->rights->agenda->myactions->create; $permok = $user->rights->agenda->myactions->create;
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
{ if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') {
if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&amp;originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&amp;socid='.$objthirdparty->id : '').'&amp;backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : '')); $out .= '&amp;originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&amp;socid='.$objthirdparty->id : '').'&amp;backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : ''));
}
$out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;percentage=-1'; $out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;percentage=-1';
$out .= '&amp;datep='.dol_print_date(dol_now(), 'dayhourlog'); $out .= '&amp;datep='.dol_print_date(dol_now(), 'dayhourlog');
} }
$newcardbutton = ''; $newcardbutton = '';
if (!empty($conf->agenda->enabled)) if (!empty($conf->agenda->enabled)) {
{ if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create))
{
$newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
} }
} }
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
{
print '<br>'; print '<br>';
$param = '&socid='.$socid; $param = '&socid='.$socid;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; $param .= '&contextpage='.$contextpage;
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.$limit;
}
print load_fiche_titre($langs->trans("ActionsOnCompany"), $newcardbutton, ''); print load_fiche_titre($langs->trans("ActionsOnCompany"), $newcardbutton, '');
//print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1); //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1);

View File

@ -22,12 +22,24 @@
* \brief File to return Ajax response on thirdparty list request * \brief File to return Ajax response on thirdparty list request
*/ */
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); define('NOTOKENRENEWAL', 1); // Disables token renewal
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); }
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); if (!defined('NOREQUIREMENU')) {
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); define('NOREQUIREMENU', '1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); }
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '1');
}
require '../../main.inc.php'; require '../../main.inc.php';
@ -48,16 +60,14 @@ $showtype = GETPOST('showtype', 'int');
dol_syslog(join(',', $_GET)); dol_syslog(join(',', $_GET));
//print_r($_GET); //print_r($_GET);
if (!empty($action) && $action == 'fetch' && !empty($id)) if (!empty($action) && $action == 'fetch' && !empty($id)) {
{
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$outjson = array(); $outjson = array();
$object = new Societe($db); $object = new Societe($db);
$ret = $object->fetch($id); $ret = $object->fetch($id);
if ($ret > 0) if ($ret > 0) {
{
$outref = $object->ref; $outref = $object->ref;
$outname = $object->name; $outname = $object->name;
$outdesc = ''; $outdesc = '';
@ -74,7 +84,9 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
top_httphead(); top_httphead();
if (empty($htmlname)) return; if (empty($htmlname)) {
return;
}
$match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET));
sort($match); sort($match);
@ -83,12 +95,18 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
// When used from jQuery, the search term is added as GET param "term". // When used from jQuery, the search term is added as GET param "term".
$searchkey = (($id && GETPOST($id, 'alpha')) ?GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ?GETPOST($htmlname, 'alpha') : '')); $searchkey = (($id && GETPOST($id, 'alpha')) ?GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ?GETPOST($htmlname, 'alpha') : ''));
if (!$searchkey) return; if (!$searchkey) {
return;
}
if (!is_object($form)) $form = new Form($db); if (!is_object($form)) {
$form = new Form($db);
}
$arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson); $arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson);
$db->close(); $db->close();
if ($outjson) print json_encode($arrayresult); if ($outjson) {
print json_encode($arrayresult);
}
} }

View File

@ -23,12 +23,24 @@
* \brief File to return Ajax response on third parties request * \brief File to return Ajax response on third parties request
*/ */
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); define('NOTOKENRENEWAL', 1); // Disables token renewal
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); }
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); if (!defined('NOREQUIREMENU')) {
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); define('NOREQUIREMENU', '1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); }
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '1');
}
require '../main.inc.php'; require '../main.inc.php';
@ -50,24 +62,25 @@ dol_syslog(join(',', $_GET));
// Generation liste des societes // Generation liste des societes
if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) {
{
$return_arr = array(); $return_arr = array();
// Define filter on text typed // Define filter on text typed
$socid = $_GET['newcompany'] ? $_GET['newcompany'] : ''; $socid = $_GET['newcompany'] ? $_GET['newcompany'] : '';
if (!$socid) $socid = $_GET['socid'] ? $_GET['socid'] : ''; if (!$socid) {
if (!$socid) $socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : ''; $socid = $_GET['socid'] ? $_GET['socid'] : '';
}
if (!$socid) {
$socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : '';
}
$sql = "SELECT rowid, nom"; $sql = "SELECT rowid, nom";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.entity IN (".getEntity('societe').")"; $sql .= " WHERE s.entity IN (".getEntity('societe').")";
if ($socid) if ($socid) {
{
$sql .= " AND ("; $sql .= " AND (";
// Add criteria on name/code // Add criteria on name/code
if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) // Can use index if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) { // Can use index
{
$sql .= "nom LIKE '".$db->escape($socid)."%'"; $sql .= "nom LIKE '".$db->escape($socid)."%'";
$sql .= " OR code_client LIKE '".$db->escape($socid)."%'"; $sql .= " OR code_client LIKE '".$db->escape($socid)."%'";
$sql .= " OR code_fournisseur LIKE '".$db->escape($socid)."%'"; $sql .= " OR code_fournisseur LIKE '".$db->escape($socid)."%'";
@ -76,7 +89,9 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn'))
$sql .= " OR code_client LIKE '%".$db->escape($socid)."%'"; $sql .= " OR code_client LIKE '%".$db->escape($socid)."%'";
$sql .= " OR code_fournisseur LIKE '%".$db->escape($socid)."%'"; $sql .= " OR code_fournisseur LIKE '%".$db->escape($socid)."%'";
} }
if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) $sql .= " OR rowid = '".$db->escape($socid)."'"; if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) {
$sql .= " OR rowid = '".$db->escape($socid)."'";
}
$sql .= ")"; $sql .= ")";
} }
//if (GETPOST("filter")) $sql.= " AND (".GETPOST("filter", "alpha").")"; // Add other filters //if (GETPOST("filter")) $sql.= " AND (".GETPOST("filter", "alpha").")"; // Add other filters
@ -84,12 +99,12 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn'))
//dol_syslog("ajaxcompanies", LOG_DEBUG); //dol_syslog("ajaxcompanies", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{ while ($row = $db->fetch_array($resql)) {
while ($row = $db->fetch_array($resql))
{
$label = $row['nom']; $label = $row['nom'];
if ($socid) $label = preg_replace('/('.preg_quote($socid, '/').')/i', '<strong>$1</strong>', $label, 1); if ($socid) {
$label = preg_replace('/('.preg_quote($socid, '/').')/i', '<strong>$1</strong>', $label, 1);
}
$row_array['label'] = $label; $row_array['label'] = $label;
$row_array['value'] = $row['nom']; $row_array['value'] = $row['nom'];
$row_array['key'] = $row['rowid']; $row_array['key'] = $row['rowid'];

View File

@ -22,12 +22,24 @@
* \brief File to return Ajax response on country request * \brief File to return Ajax response on country request
*/ */
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); define('NOTOKENRENEWAL', 1); // Disables token renewal
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); }
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); if (!defined('NOREQUIREMENU')) {
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); define('NOREQUIREMENU', '1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); }
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '1');
}
require '../main.inc.php'; require '../main.inc.php';
@ -50,8 +62,7 @@ print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"])
dol_syslog(join(',', $_POST)); dol_syslog(join(',', $_POST));
// Generate list of countries // Generate list of countries
if (!empty($country)) if (!empty($country)) {
{
global $langs; global $langs;
$langs->load("dict"); $langs->load("dict");
@ -61,11 +72,9 @@ if (!empty($country))
$sql .= " ORDER BY label ASC"; $sql .= " ORDER BY label ASC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
print '<ul>'; print '<ul>';
while ($country = $db->fetch_object($resql)) while ($country = $db->fetch_object($resql)) {
{
print '<li>'; print '<li>';
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
print ($country->code && $langs->trans("Country".$country->code) != "Country".$country->code ? $langs->trans("Country".$country->code) : ($country->label != '-' ? $country->label : '&nbsp;')); print ($country->code && $langs->trans("Country".$country->code) != "Country".$country->code ? $langs->trans("Country".$country->code) : ($country->label != '-' ? $country->label : '&nbsp;'));

View File

@ -66,7 +66,9 @@ abstract class ActionsCardCommon
//$ret = $this->getInstanceDao(); //$ret = $this->getInstanceDao();
$object = new Societe($this->db); $object = new Societe($this->db);
if (!empty($id) || !empty($ref)) $object->fetch($id, $ref); if (!empty($id) || !empty($ref)) {
$object->fetch($id, $ref);
}
$this->object = $object; $this->object = $object;
} }
@ -85,26 +87,37 @@ abstract class ActionsCardCommon
global $conf, $langs, $db, $user, $mysoc, $canvas; global $conf, $langs, $db, $user, $mysoc, $canvas;
global $form, $formadmin, $formcompany; global $form, $formadmin, $formcompany;
if ($action == 'add' || $action == 'update') $this->assign_post($action); if ($action == 'add' || $action == 'update') {
$this->assign_post($action);
}
if ($_GET["type"] == 'f') { $this->object->fournisseur = 1; } if ($_GET["type"] == 'f') {
if ($_GET["type"] == 'c') { $this->object->client = 1; } $this->object->fournisseur = 1;
if ($_GET["type"] == 'p') { $this->object->client = 2; } }
if ($_GET["type"] == 'cp') { $this->object->client = 3; } if ($_GET["type"] == 'c') {
if ($_REQUEST["private"] == 1) { $this->object->particulier = 1; } $this->object->client = 1;
}
if ($_GET["type"] == 'p') {
$this->object->client = 2;
}
if ($_GET["type"] == 'cp') {
$this->object->client = 3;
}
if ($_REQUEST["private"] == 1) {
$this->object->particulier = 1;
}
foreach ($this->object as $key => $value) foreach ($this->object as $key => $value) {
{
$this->tpl[$key] = $value; $this->tpl[$key] = $value;
} }
$this->tpl['error'] = get_htmloutput_errors($this->object->error, $this->object->errors); $this->tpl['error'] = get_htmloutput_errors($this->object->error, $this->object->errors);
if (is_array($GLOBALS['errors'])) $this->tpl['error'] = get_htmloutput_mesg('', $GLOBALS['errors'], 'error'); if (is_array($GLOBALS['errors'])) {
$this->tpl['error'] = get_htmloutput_mesg('', $GLOBALS['errors'], 'error');
}
if ($action == 'create') if ($action == 'create') {
{ if ($conf->use_javascript_ajax) {
if ($conf->use_javascript_ajax)
{
$this->tpl['ajax_selecttype'] = "\n".'<script type="text/javascript" language="javascript"> $this->tpl['ajax_selecttype'] = "\n".'<script type="text/javascript" language="javascript">
$(document).ready(function () { $(document).ready(function () {
$("#radiocompany").click(function() { $("#radiocompany").click(function() {
@ -124,10 +137,8 @@ abstract class ActionsCardCommon
} }
} }
if ($action == 'create' || $action == 'edit') if ($action == 'create' || $action == 'edit') {
{ if ($conf->use_javascript_ajax) {
if ($conf->use_javascript_ajax)
{
$this->tpl['ajax_selectcountry'] = "\n".'<script type="text/javascript" language="javascript"> $this->tpl['ajax_selectcountry'] = "\n".'<script type="text/javascript" language="javascript">
$(document).ready(function () { $(document).ready(function () {
$("#selectcountry_id").change(function() { $("#selectcountry_id").change(function() {
@ -141,20 +152,22 @@ abstract class ActionsCardCommon
// Load object modCodeClient // Load object modCodeClient
$module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard'); $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard');
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
{
$module = substr($module, 0, dol_strlen($module) - 4); $module = substr($module, 0, dol_strlen($module) - 4);
} }
$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
foreach ($dirsociete as $dirroot) foreach ($dirsociete as $dirroot) {
{
$res = dol_include_once($dirroot.$module.'.php'); $res = dol_include_once($dirroot.$module.'.php');
if ($res) break; if ($res) {
break;
}
} }
$modCodeClient = new $module($db); $modCodeClient = new $module($db);
$this->tpl['auto_customercode'] = $modCodeClient->code_auto; $this->tpl['auto_customercode'] = $modCodeClient->code_auto;
// We verified if the tag prefix is used // We verified if the tag prefix is used
if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed(); if ($modCodeClient->code_auto) {
$this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
}
// TODO create a function // TODO create a function
$this->tpl['select_customertype'] = Form::selectarray('client', array( $this->tpl['select_customertype'] = Form::selectarray('client', array(
@ -166,36 +179,41 @@ abstract class ActionsCardCommon
// Customer // Customer
$this->tpl['customercode'] = $this->object->code_client; $this->tpl['customercode'] = $this->object->code_client;
if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) $this->tpl['customercode'] = $modCodeClient->getNextValue($this->object, 0); if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) {
$this->tpl['customercode'] = $modCodeClient->getNextValue($this->object, 0);
}
$this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable(); $this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable();
$s = $modCodeClient->getToolTip($langs, $this->object, 0); $s = $modCodeClient->getToolTip($langs, $this->object, 0);
$this->tpl['help_customercode'] = $form->textwithpicto('', $s, 1); $this->tpl['help_customercode'] = $form->textwithpicto('', $s, 1);
if (!empty($conf->fournisseur->enabled)) if (!empty($conf->fournisseur->enabled)) {
{
$this->tpl['supplier_enabled'] = 1; $this->tpl['supplier_enabled'] = 1;
// Load object modCodeFournisseur // Load object modCodeFournisseur
$module = $conf->global->SOCIETE_CODECLIENT_ADDON; $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
{
$module = substr($module, 0, dol_strlen($module) - 4); $module = substr($module, 0, dol_strlen($module) - 4);
} }
$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
foreach ($dirsociete as $dirroot) foreach ($dirsociete as $dirroot) {
{
$res = dol_include_once($dirroot.$module.'.php'); $res = dol_include_once($dirroot.$module.'.php');
if ($res) break; if ($res) {
break;
}
} }
$modCodeFournisseur = new $module; $modCodeFournisseur = new $module;
$this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto; $this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto;
// We verified if the tag prefix is used // We verified if the tag prefix is used
if ($modCodeFournisseur->code_auto) $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed(); if ($modCodeFournisseur->code_auto) {
$this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
}
// Supplier // Supplier
$this->tpl['yn_supplier'] = $form->selectyesno("fournisseur", $this->object->fournisseur, 1); $this->tpl['yn_supplier'] = $form->selectyesno("fournisseur", $this->object->fournisseur, 1);
$this->tpl['suppliercode'] = $this->object->code_fournisseur; $this->tpl['suppliercode'] = $this->object->code_fournisseur;
if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object, 1); if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) {
$this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object, 1);
}
$this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable(); $this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable();
$s = $modCodeFournisseur->getToolTip($langs, $this->object, 1); $s = $modCodeFournisseur->getToolTip($langs, $this->object, 1);
$this->tpl['help_suppliercode'] = $form->textwithpicto('', $s, 1); $this->tpl['help_suppliercode'] = $form->textwithpicto('', $s, 1);
@ -216,14 +234,21 @@ abstract class ActionsCardCommon
$this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id');
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); if ($user->admin) {
$this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
// State // State
if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); if ($this->object->country_id) {
else $this->tpl['select_state'] = $countrynotdefined; $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
} else {
$this->tpl['select_state'] = $countrynotdefined;
}
// Language // Language
if (!empty($conf->global->MAIN_MULTILANGS)) $this->tpl['select_lang'] = $formadmin->select_language(($this->object->default_lang ? $this->object->default_lang : $conf->global->MAIN_LANG_DEFAULT), 'default_lang', 0, 0, 1); if (!empty($conf->global->MAIN_MULTILANGS)) {
$this->tpl['select_lang'] = $formadmin->select_language(($this->object->default_lang ? $this->object->default_lang : $conf->global->MAIN_LANG_DEFAULT), 'default_lang', 0, 0, 1);
}
// VAT // VAT
$this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value', $this->tpl['tva_assuj'], 1); // Assujeti par defaut en creation $this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value', $this->tpl['tva_assuj'], 1); // Assujeti par defaut en creation
@ -233,24 +258,20 @@ abstract class ActionsCardCommon
// Local Tax // Local Tax
// TODO mettre dans une classe propre au pays // TODO mettre dans une classe propre au pays
if ($mysoc->country_code == 'ES') if ($mysoc->country_code == 'ES') {
{
$this->tpl['localtax'] = ''; $this->tpl['localtax'] = '';
if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
{
$this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td>'; $this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td>';
$this->tpl['localtax'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1); $this->tpl['localtax'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1);
$this->tpl['localtax'] .= '</td><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td>'; $this->tpl['localtax'] .= '</td><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td>';
$this->tpl['localtax'] .= $form->selectyesno('localtax2assuj_value', $this->object->localtax1_assuj, 1); $this->tpl['localtax'] .= $form->selectyesno('localtax2assuj_value', $this->object->localtax1_assuj, 1);
$this->tpl['localtax'] .= '</td></tr>'; $this->tpl['localtax'] .= '</td></tr>';
} elseif ($mysoc->localtax1_assuj == "1") } elseif ($mysoc->localtax1_assuj == "1") {
{
$this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">'; $this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
$this->tpl['localtax'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1); $this->tpl['localtax'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1);
$this->tpl['localtax'] .= '</td><tr>'; $this->tpl['localtax'] .= '</td><tr>';
} elseif ($mysoc->localtax2_assuj == "1") } elseif ($mysoc->localtax2_assuj == "1") {
{
$this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">'; $this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
$this->tpl['localtax'] .= $form->selectyesno('localtax2assuj_value', $this->object->localtax1_assuj, 1); $this->tpl['localtax'] .= $form->selectyesno('localtax2assuj_value', $this->object->localtax1_assuj, 1);
$this->tpl['localtax'] .= '</td><tr>'; $this->tpl['localtax'] .= '</td><tr>';
@ -269,7 +290,9 @@ abstract class ActionsCardCommon
$this->tpl['address'] = dol_nl2br($this->object->address); $this->tpl['address'] = dol_nl2br($this->object->address);
$img = picto_from_langcode($this->object->country_code); $img = picto_from_langcode($this->object->country_code);
if ($this->object->isInEEC()) $this->tpl['country'] = $form->textwithpicto(($img ? $img.' ' : '').$this->object->country, $langs->trans("CountryIsInEEC"), 1, 0); if ($this->object->isInEEC()) {
$this->tpl['country'] = $form->textwithpicto(($img ? $img.' ' : '').$this->object->country, $langs->trans("CountryIsInEEC"), 1, 0);
}
$this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country;
$this->tpl['phone'] = dol_print_phone($this->object->phone, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); $this->tpl['phone'] = dol_print_phone($this->object->phone, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
@ -283,8 +306,7 @@ abstract class ActionsCardCommon
$arr = $formcompany->typent_array(1); $arr = $formcompany->typent_array(1);
$this->tpl['typent'] = $arr[$this->object->typent_code]; $this->tpl['typent'] = $arr[$this->object->typent_code];
if (!empty($conf->global->MAIN_MULTILANGS)) if (!empty($conf->global->MAIN_MULTILANGS)) {
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
//$s=picto_from_langcode($this->default_lang); //$s=picto_from_langcode($this->default_lang);
//print ($s?$s.' ':''); //print ($s?$s.' ':'');
@ -300,31 +322,31 @@ abstract class ActionsCardCommon
$this->tpl['sales_representatives'] = ''; $this->tpl['sales_representatives'] = '';
$listsalesrepresentatives = $this->object->getSalesRepresentatives($user); $listsalesrepresentatives = $this->object->getSalesRepresentatives($user);
$nbofsalesrepresentative = count($listsalesrepresentatives); $nbofsalesrepresentative = count($listsalesrepresentatives);
if ($nbofsalesrepresentative > 3) // We print only number if ($nbofsalesrepresentative > 3) { // We print only number
{
$this->tpl['sales_representatives'] .= $nbofsalesrepresentative; $this->tpl['sales_representatives'] .= $nbofsalesrepresentative;
} elseif ($nbofsalesrepresentative > 0) { } elseif ($nbofsalesrepresentative > 0) {
$userstatic = new User($this->db); $userstatic = new User($this->db);
$i = 0; $i = 0;
foreach ($listsalesrepresentatives as $val) foreach ($listsalesrepresentatives as $val) {
{
$userstatic->id = $val['id']; $userstatic->id = $val['id'];
$userstatic->lastname = $val['name']; $userstatic->lastname = $val['name'];
$userstatic->firstname = $val['firstname']; $userstatic->firstname = $val['firstname'];
$this->tpl['sales_representatives'] .= $userstatic->getNomUrl(1); $this->tpl['sales_representatives'] .= $userstatic->getNomUrl(1);
$i++; $i++;
if ($i < $nbofsalesrepresentative) $this->tpl['sales_representatives'] .= ', '; if ($i < $nbofsalesrepresentative) {
$this->tpl['sales_representatives'] .= ', ';
}
}
} else {
$this->tpl['sales_representatives'] .= $langs->trans("NoSalesRepresentativeAffected");
} }
} else $this->tpl['sales_representatives'] .= $langs->trans("NoSalesRepresentativeAffected");
// Linked member // Linked member
if (!empty($conf->adherent->enabled)) if (!empty($conf->adherent->enabled)) {
{
$langs->load("members"); $langs->load("members");
$adh = new Adherent($this->db); $adh = new Adherent($this->db);
$result = $adh->fetch('', '', $this->object->id); $result = $adh->fetch('', '', $this->object->id);
if ($result > 0) if ($result > 0) {
{
$adh->ref = $adh->getFullName($langs); $adh->ref = $adh->getFullName($langs);
$this->tpl['linked_member'] = $adh->getNomUrl(1); $this->tpl['linked_member'] = $adh->getNomUrl(1);
} else { } else {
@ -334,22 +356,18 @@ abstract class ActionsCardCommon
// Local Tax // Local Tax
// TODO mettre dans une classe propre au pays // TODO mettre dans une classe propre au pays
if ($mysoc->country_code == 'ES') if ($mysoc->country_code == 'ES') {
{
$this->tpl['localtax'] = ''; $this->tpl['localtax'] = '';
if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
{
$this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>'; $this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>';
$this->tpl['localtax'] .= '<td>'.yn($this->object->localtax1_assuj).'</td>'; $this->tpl['localtax'] .= '<td>'.yn($this->object->localtax1_assuj).'</td>';
$this->tpl['localtax'] .= '<td>'.$langs->trans("LocalTax2IsUsedES").'</td>'; $this->tpl['localtax'] .= '<td>'.$langs->trans("LocalTax2IsUsedES").'</td>';
$this->tpl['localtax'] .= '<td>'.yn($this->object->localtax2_assuj).'</td></tr>'; $this->tpl['localtax'] .= '<td>'.yn($this->object->localtax2_assuj).'</td></tr>';
} elseif ($mysoc->localtax1_assuj == "1") } elseif ($mysoc->localtax1_assuj == "1") {
{
$this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>'; $this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>';
$this->tpl['localtax'] .= '<td colspan="3">'.yn($this->object->localtax1_assuj).'</td></tr>'; $this->tpl['localtax'] .= '<td colspan="3">'.yn($this->object->localtax1_assuj).'</td></tr>';
} elseif ($mysoc->localtax2_assuj == "1") } elseif ($mysoc->localtax2_assuj == "1") {
{
$this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td>'; $this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td>';
$this->tpl['localtax'] .= '<td colspan="3">'.yn($this->object->localtax2_assuj).'</td></tr>'; $this->tpl['localtax'] .= '<td colspan="3">'.yn($this->object->localtax2_assuj).'</td></tr>';
} }
@ -405,8 +423,7 @@ abstract class ActionsCardCommon
$this->object->localtax2_assuj = $_POST["localtax2assuj_value"]; $this->object->localtax2_assuj = $_POST["localtax2assuj_value"];
// We set country_id, and country_code label of the chosen country // We set country_id, and country_code label of the chosen country
if ($this->object->country_id) if ($this->object->country_id) {
{
$tmparray = getCountry($this->object->country_id, 'all', $this->db, $langs, 0); $tmparray = getCountry($this->object->country_id, 'all', $this->db, $langs, 0);
$this->object->country_code = $tmparray['code']; $this->object->country_code = $tmparray['code'];
$this->object->country_label = $tmparray['label']; $this->object->country_label = $tmparray['label'];

View File

@ -61,9 +61,15 @@ class ActionsCardCompany extends ActionsCardCommon
$out = ''; $out = '';
if ($action == 'view') $out .= $langs->trans("ThirdParty"); if ($action == 'view') {
if ($action == 'edit') $out .= $langs->trans("EditCompany"); $out .= $langs->trans("ThirdParty");
if ($action == 'create') $out .= $langs->trans("NewCompany"); }
if ($action == 'edit') {
$out .= $langs->trans("EditCompany");
}
if ($action == 'create') {
$out .= $langs->trans("NewCompany");
}
return $out; return $out;
} }
@ -95,8 +101,7 @@ class ActionsCardCompany extends ActionsCardCommon
$this->tpl['profid3'] = $this->object->idprof3; $this->tpl['profid3'] = $this->object->idprof3;
$this->tpl['profid4'] = $this->object->idprof4; $this->tpl['profid4'] = $this->object->idprof4;
if ($conf->use_javascript_ajax && empty($conf->global->MAIN_DISABLEVATCHECK)) if ($conf->use_javascript_ajax && empty($conf->global->MAIN_DISABLEVATCHECK)) {
{
$js = "\n"; $js = "\n";
$js .= '<script language="JavaScript" type="text/javascript">'; $js .= '<script language="JavaScript" type="text/javascript">';
$js .= "function CheckVAT(a) {\n"; $js .= "function CheckVAT(a) {\n";
@ -107,10 +112,8 @@ class ActionsCardCompany extends ActionsCardCommon
$this->tpl['js_checkVatPopup'] = $js; $this->tpl['js_checkVatPopup'] = $js;
} }
if ($action == 'create' || $action == 'edit') if ($action == 'create' || $action == 'edit') {
{ for ($i = 1; $i <= 4; $i++) {
for ($i = 1; $i <= 4; $i++)
{
$this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i, $this->object->country_code); $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i, $this->object->country_code);
$this->tpl['showprofid'.$i] = $formcompany->get_input_id_prof($i, 'idprof'.$i, $this->tpl['profid'.$i], $this->object->country_code); $this->tpl['showprofid'.$i] = $formcompany->get_input_id_prof($i, 'idprof'.$i, $this->tpl['profid'.$i], $this->object->country_code);
} }
@ -126,12 +129,10 @@ class ActionsCardCompany extends ActionsCardCommon
// VAT intra // VAT intra
$s = '<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">'; $s = '<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">';
if (empty($conf->global->MAIN_DISABLEVATCHECK)) if (empty($conf->global->MAIN_DISABLEVATCHECK)) {
{
$s .= ' '; $s .= ' ';
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
$s .= '<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>'; $s .= '<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
} else { } else {
@ -142,29 +143,24 @@ class ActionsCardCompany extends ActionsCardCommon
} }
} else { } else {
// Confirm delete third party // Confirm delete third party
if ($action == 'delete') if ($action == 'delete') {
{
$this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "1,action-delete"); $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "1,action-delete");
} }
for ($i = 1; $i <= 4; $i++) for ($i = 1; $i <= 4; $i++) {
{
$this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i, $this->object->country_code); $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i, $this->object->country_code);
$this->tpl['checkprofid'.$i] = $this->object->id_prof_check($i, $this->object); $this->tpl['checkprofid'.$i] = $this->object->id_prof_check($i, $this->object);
$this->tpl['urlprofid'.$i] = $this->object->id_prof_url($i, $this->object); $this->tpl['urlprofid'.$i] = $this->object->id_prof_url($i, $this->object);
} }
// TVA intra // TVA intra
if ($this->object->tva_intra) if ($this->object->tva_intra) {
{
$s = $this->object->tva_intra; $s = $this->object->tva_intra;
$s .= '<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">'; $s .= '<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">';
if (empty($conf->global->MAIN_DISABLEVATCHECK)) if (empty($conf->global->MAIN_DISABLEVATCHECK)) {
{
$s .= ' &nbsp; '; $s .= ' &nbsp; ';
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
$s .= '<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>'; $s .= '<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
$this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
} else { } else {
@ -178,8 +174,7 @@ class ActionsCardCompany extends ActionsCardCommon
} }
// Parent company // Parent company
if ($this->object->parent) if ($this->object->parent) {
{
$socm = new Societe($this->db); $socm = new Societe($this->db);
$socm->fetch($this->object->parent); $socm->fetch($this->object->parent);
$this->tpl['parent_company'] = $socm->getNomUrl(1).' '.($socm->code_client ? "(".$socm->code_client.")" : ""); $this->tpl['parent_company'] = $socm->getNomUrl(1).' '.($socm->code_client ? "(".$socm->code_client.")" : "");

View File

@ -17,8 +17,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) if (empty($conf) || !is_object($conf)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -43,7 +42,9 @@ if (empty($conf) || !is_object($conf))
<?php echo $this->control->tpl['ajax_selectcountry']; ?> <?php echo $this->control->tpl['ajax_selectcountry']; ?>
<?php } ?> <?php } ?>
<?php if ($this->control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?> <?php if ($this->control->tpl['js_checkVatPopup']) {
echo $this->control->tpl['js_checkVatPopup'];
} ?>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" name="formsoc"> <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" name="formsoc">
@ -155,15 +156,23 @@ if (!empty($conf->barcode->enabled)) { ?>
<?php <?php
for ($i = 1; $i <= 4; $i++) { for ($i = 1; $i <= 4; $i++) {
if ($this->control->tpl['langprofid'.$i] != '-') { if ($this->control->tpl['langprofid'.$i] != '-') {
if ($i == 1 || $i == 3) echo '<tr>'; if ($i == 1 || $i == 3) {
echo '<tr>';
}
echo '<td>'.$this->control->tpl['langprofid'.$i].'</td>'; echo '<td>'.$this->control->tpl['langprofid'.$i].'</td>';
echo '<td>'.$this->control->tpl['showprofid'.$i].'</td>'; echo '<td>'.$this->control->tpl['showprofid'.$i].'</td>';
if ($i == 2 || $i == 4) echo '</tr>'; if ($i == 2 || $i == 4) {
echo '</tr>';
}
} else { } else {
if ($i == 1 || $i == 3) echo '<tr>'; if ($i == 1 || $i == 3) {
echo '<tr>';
}
echo '<td>&nbsp;</td>'; echo '<td>&nbsp;</td>';
echo '<td>&nbsp;</td>'; echo '<td>&nbsp;</td>';
if ($i == 2 || $i == 4) echo '</tr>'; if ($i == 2 || $i == 4) {
echo '</tr>';
}
} }
} }
?> ?>
@ -194,7 +203,9 @@ for ($i = 1; $i <= 4; $i++) {
<td class="nowrap"><?php echo $this->control->tpl['tva_intra']; ?></td> <td class="nowrap"><?php echo $this->control->tpl['tva_intra']; ?></td>
</tr> </tr>
<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> <?php if (!empty($this->control->tpl['localtax'])) {
echo $this->control->tpl['localtax'];
} ?>
<?php if ($user->rights->societe->client->voir) { ?> <?php if ($user->rights->societe->client->voir) { ?>
<tr> <tr>

View File

@ -17,8 +17,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) if (empty($conf) || !is_object($conf)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -34,7 +33,9 @@ $contact = $GLOBALS['objcanvas']->control->object;
<?php echo $this->control->tpl['error']; ?> <?php echo $this->control->tpl['error']; ?>
<?php echo $this->control->tpl['ajax_selectcountry']; ?> <?php echo $this->control->tpl['ajax_selectcountry']; ?>
<?php if ($this->control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?> <?php if ($this->control->tpl['js_checkVatPopup']) {
echo $this->control->tpl['js_checkVatPopup'];
} ?>
<form action="<?php echo $_SERVER["PHP_SELF"].'?socid='.$this->control->tpl['id']; ?>" method="POST" name="formsoc"> <form action="<?php echo $_SERVER["PHP_SELF"].'?socid='.$this->control->tpl['id']; ?>" method="POST" name="formsoc">
<input type="hidden" name="canvas" value="<?php echo $canvas ?>"> <input type="hidden" name="canvas" value="<?php echo $canvas ?>">
@ -165,15 +166,23 @@ if (!empty($conf->barcode->enabled)) { ?>
<?php <?php
for ($i = 1; $i <= 4; $i++) { for ($i = 1; $i <= 4; $i++) {
if ($this->control->tpl['langprofid'.$i] != '-') { if ($this->control->tpl['langprofid'.$i] != '-') {
if ($i == 1 || $i == 3) echo '<tr>'; if ($i == 1 || $i == 3) {
echo '<tr>';
}
echo '<td>'.$this->control->tpl['langprofid'.$i].'</td>'; echo '<td>'.$this->control->tpl['langprofid'.$i].'</td>';
echo '<td>'.$this->control->tpl['showprofid'.$i].'</td>'; echo '<td>'.$this->control->tpl['showprofid'.$i].'</td>';
if ($i == 2 || $i == 4) echo '</tr>'; if ($i == 2 || $i == 4) {
echo '</tr>';
}
} else { } else {
if ($i == 1 || $i == 3) echo '<tr>'; if ($i == 1 || $i == 3) {
echo '<tr>';
}
echo '<td>&nbsp;</td>'; echo '<td>&nbsp;</td>';
echo '<td>&nbsp;</td>'; echo '<td>&nbsp;</td>';
if ($i == 2 || $i == 4) echo '</tr>'; if ($i == 2 || $i == 4) {
echo '</tr>';
}
} }
} }
?> ?>
@ -209,7 +218,9 @@ for ($i = 1; $i <= 4; $i++) {
</tr> </tr>
<?php } <?php }
if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> if (!empty($this->control->tpl['localtax'])) {
echo $this->control->tpl['localtax'];
} ?>
</table> </table>
<br> <br>

View File

@ -16,8 +16,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) if (empty($conf) || !is_object($conf)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -34,9 +33,15 @@ print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company
?> ?>
<?php if ($this->control->tpl['error']) echo $this->control->tpl['error']; ?> <?php if ($this->control->tpl['error']) {
<?php if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?> echo $this->control->tpl['error'];
<?php if ($this->control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?> } ?>
<?php if ($this->control->tpl['action_delete']) {
echo $this->control->tpl['action_delete'];
} ?>
<?php if ($this->control->tpl['js_checkVatPopup']) {
echo $this->control->tpl['js_checkVatPopup'];
} ?>
<table class="border allwidth"> <table class="border allwidth">
@ -120,20 +125,31 @@ print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company
<?php <?php
for ($i = 1; $i <= 4; $i++) { for ($i = 1; $i <= 4; $i++) {
if ($this->control->tpl['langprofid'.$i] != '-') { if ($this->control->tpl['langprofid'.$i] != '-') {
if ($i == 1 || $i == 3) echo '<tr>'; if ($i == 1 || $i == 3) {
echo '<tr>';
}
echo '<td>'.$this->control->tpl['langprofid'.$i].'</td>'; echo '<td>'.$this->control->tpl['langprofid'.$i].'</td>';
echo '<td>'.$this->control->tpl['profid'.$i]; echo '<td>'.$this->control->tpl['profid'.$i];
if ($this->control->tpl['profid'.$i]) { if ($this->control->tpl['profid'.$i]) {
if ($this->control->tpl['checkprofid'.$i] > 0) echo ' &nbsp; '.$this->control->tpl['urlprofid'.$i]; if ($this->control->tpl['checkprofid'.$i] > 0) {
else echo ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>'; echo ' &nbsp; '.$this->control->tpl['urlprofid'.$i];
} else {
echo ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';
}
} }
echo '</td>'; echo '</td>';
if ($i == 2 || $i == 4) echo '</tr>'; if ($i == 2 || $i == 4) {
echo '</tr>';
}
} else { } else {
if ($i == 1 || $i == 3) echo '<tr>'; if ($i == 1 || $i == 3) {
echo '<tr>';
}
echo '<td>&nbsp;</td>'; echo '<td>&nbsp;</td>';
echo '<td>&nbsp;</td>'; echo '<td>&nbsp;</td>';
if ($i == 2 || $i == 4) echo '</tr>'; if ($i == 2 || $i == 4) {
echo '</tr>';
}
} }
} }
?> ?>
@ -145,14 +161,19 @@ for ($i = 1; $i <= 4; $i++) {
<td><?php echo $this->control->tpl['tva_intra']; ?></td> <td><?php echo $this->control->tpl['tva_intra']; ?></td>
</tr> </tr>
<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> <?php if (!empty($this->control->tpl['localtax'])) {
echo $this->control->tpl['localtax'];
} ?>
<tr> <tr>
<td><?php echo $langs->trans('Capital'); ?></td> <td><?php echo $langs->trans('Capital'); ?></td>
<td colspan="3"> <td colspan="3">
<?php <?php
if ($this->control->tpl['capital']) echo $this->control->tpl['capital'].' '.$langs->trans("Currency".$conf->currency); if ($this->control->tpl['capital']) {
else echo '&nbsp;'; echo $this->control->tpl['capital'].' '.$langs->trans("Currency".$conf->currency);
} else {
echo '&nbsp;';
}
?> ?>
</td> </td>
</tr> </tr>

View File

@ -61,9 +61,15 @@ class ActionsCardIndividual extends ActionsCardCommon
$out = ''; $out = '';
if ($action == 'view') $out .= $langs->trans("Individual"); if ($action == 'view') {
if ($action == 'edit') $out .= $langs->trans("EditCompany"); $out .= $langs->trans("Individual");
if ($action == 'create') $out .= $langs->trans("NewCompany"); }
if ($action == 'edit') {
$out .= $langs->trans("EditCompany");
}
if ($action == 'create') {
$out .= $langs->trans("NewCompany");
}
return $out; return $out;
} }
@ -107,13 +113,11 @@ class ActionsCardIndividual extends ActionsCardCommon
$this->tpl['title'] = load_fiche_titre($this->getTitle($action)); $this->tpl['title'] = load_fiche_titre($this->getTitle($action));
if ($action == 'create' || $action == 'edit') if ($action == 'create' || $action == 'edit') {
{
$this->tpl['select_civility'] = $formcompany->select_civility(GETPOST('civility_id')); $this->tpl['select_civility'] = $formcompany->select_civility(GETPOST('civility_id'));
} else { } else {
// Confirm delete third party // Confirm delete third party
if ($action == 'delete' || $conf->use_javascript_ajax) if ($action == 'delete' || $conf->use_javascript_ajax) {
{
$this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id, $langs->trans("DeleteAnIndividual"), $langs->trans("ConfirmDeleteIndividual"), "confirm_delete", '', 0, "1,action-delete"); $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id, $langs->trans("DeleteAnIndividual"), $langs->trans("ConfirmDeleteIndividual"), "confirm_delete", '', 0, "1,action-delete");
} }
} }

View File

@ -17,8 +17,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) if (empty($conf) || !is_object($conf)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -169,7 +168,9 @@ if (!empty($conf->barcode->enabled)) { ?>
<td colspan="3"><?php echo $this->control->tpl['yn_assujtva']; ?></td> <td colspan="3"><?php echo $this->control->tpl['yn_assujtva']; ?></td>
</tr> </tr>
<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> <?php if (!empty($this->control->tpl['localtax'])) {
echo $this->control->tpl['localtax'];
} ?>
<?php if ($user->rights->societe->client->voir) { ?> <?php if ($user->rights->societe->client->voir) { ?>
<tr> <tr>

View File

@ -17,8 +17,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) if (empty($conf) || !is_object($conf)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -173,7 +172,9 @@ if ($this->control->tpl['fournisseur']) {
<td colspan="3"><?php echo $this->control->tpl['yn_assujtva']; ?></td> <td colspan="3"><?php echo $this->control->tpl['yn_assujtva']; ?></td>
</tr> </tr>
<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> <?php if (!empty($this->control->tpl['localtax'])) {
echo $this->control->tpl['localtax'];
} ?>
</table> </table>
<br> <br>

View File

@ -16,8 +16,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) if (empty($conf) || !is_object($conf)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -32,8 +31,12 @@ $head = societe_prepare_head($object);
print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company'); print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company');
if ($this->control->tpl['error']) echo $this->control->tpl['error']; if ($this->control->tpl['error']) {
if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?> echo $this->control->tpl['error'];
}
if ($this->control->tpl['action_delete']) {
echo $this->control->tpl['action_delete'];
} ?>
<table class="border allwidth"> <table class="border allwidth">
@ -119,7 +122,9 @@ if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delet
<td colspan="3"><?php echo $this->control->tpl['tva_assuj']; ?></td> <td colspan="3"><?php echo $this->control->tpl['tva_assuj']; ?></td>
</tr> </tr>
<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> <?php if (!empty($this->control->tpl['localtax'])) {
echo $this->control->tpl['localtax'];
} ?>
<tr> <tr>
<td><?php echo $langs->trans("Type"); ?></td> <td><?php echo $langs->trans("Type"); ?></td>

File diff suppressed because it is too large Load Diff

View File

@ -45,8 +45,7 @@ print load_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"), '', 'title_se
$vatNumber = GETPOST("vatNumber", 'alpha'); $vatNumber = GETPOST("vatNumber", 'alpha');
if (!$vatNumber) if (!$vatNumber) {
{
print '<br>'; print '<br>';
print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired", $langs->trans("VATIntraShort")).'</font><br>'; print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired", $langs->trans("VATIntraShort")).'</font><br>';
} else { } else {
@ -76,8 +75,7 @@ if (!$vatNumber)
// Check for an error // Check for an error
$err = $soapclient->getError(); $err = $soapclient->getError();
if ($err) if ($err) {
{
dol_syslog("Constructor error ".$WS_DOL_URL, LOG_ERR); dol_syslog("Constructor error ".$WS_DOL_URL, LOG_ERR);
} }
@ -96,42 +94,38 @@ if (!$vatNumber)
print '<b>'.$langs->trans("Response").'</b>:<br>'; print '<b>'.$langs->trans("Response").'</b>:<br>';
// Service indisponible // Service indisponible
if (!is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i', $result['faultstring'])) if (!is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i', $result['faultstring'])) {
{
print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
$messagetoshow = $soapclient->response; $messagetoshow = $soapclient->response;
} elseif (preg_match('/TIMEOUT/i', $result['faultstring'])) } elseif (preg_match('/TIMEOUT/i', $result['faultstring'])) {
{
print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
$messagetoshow = $soapclient->response; $messagetoshow = $soapclient->response;
} elseif (preg_match('/SERVER_BUSY/i', $result['faultstring'])) } elseif (preg_match('/SERVER_BUSY/i', $result['faultstring'])) {
{
print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
$messagetoshow = $soapclient->response; $messagetoshow = $soapclient->response;
} elseif ($result['faultstring']) } elseif ($result['faultstring']) {
{
print '<font class="error">'.$langs->trans("Error").'</font><br>'; print '<font class="error">'.$langs->trans("Error").'</font><br>';
$messagetoshow = $result['faultstring']; $messagetoshow = $result['faultstring'];
} } elseif (preg_match('/INVALID_INPUT/i', $result['faultstring'])
|| ($result['requestDate'] && !$result['valid'])) {
// Syntaxe ko // Syntaxe ko
elseif (preg_match('/INVALID_INPUT/i', $result['faultstring']) if ($result['requestDate']) {
|| ($result['requestDate'] && !$result['valid'])) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
{ }
if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
print $langs->trans("VATIntraSyntaxIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>'; print $langs->trans("VATIntraSyntaxIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>';
print $langs->trans("ValueIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>'; print $langs->trans("ValueIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>';
//$messagetoshow=$soapclient->response; //$messagetoshow=$soapclient->response;
} else { } else {
// Syntaxe ok // Syntaxe ok
if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>'; if ($result['requestDate']) {
print $langs->trans("Date").': '.$result['requestDate'].'<br>';
}
print $langs->trans("VATIntraSyntaxIsValid").': <font class="ok">'.$langs->trans("Yes").'</font><br>'; print $langs->trans("VATIntraSyntaxIsValid").': <font class="ok">'.$langs->trans("Yes").'</font><br>';
print $langs->trans("ValueIsValid").': '; print $langs->trans("ValueIsValid").': ';
if (preg_match('/MS_UNAVAILABLE/i', $result['faultstring'])) if (preg_match('/MS_UNAVAILABLE/i', $result['faultstring'])) {
{
print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE", $countryCode).'</font><br>'; print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE", $countryCode).'</font><br>';
} else { } else {
if (!empty($result['valid']) && ($result['valid'] == 1 || $result['valid'] == 'true')) if (!empty($result['valid']) && ($result['valid'] == 1 || $result['valid'] == 'true')) {
{
print '<font class="ok">'.$langs->trans("Yes").'</font>'; print '<font class="ok">'.$langs->trans("Yes").'</font>';
print '<br>'; print '<br>';
print $langs->trans("Name").': '.$result['name'].'<br>'; print $langs->trans("Name").': '.$result['name'].'<br>';
@ -144,10 +138,10 @@ if (!$vatNumber)
} }
// Show log data into page // Show log data into page
print "\n"; // print "\n";
print '<!-- '; // print '<!-- ';
var_dump($result); // var_dump($result);
print '-->'; // print '-->';
} }
print '<br>'; print '<br>';
@ -155,8 +149,7 @@ print $langs->trans("VATIntraManualCheck", $langs->trans("VATIntraCheckURL"), $l
print '<br>'; print '<br>';
print '<div class="center"><input type="button" class="button" value="'.$langs->trans("CloseWindow").'" onclick="javascript: window.close()"></div>'; print '<div class="center"><input type="button" class="button" value="'.$langs->trans("CloseWindow").'" onclick="javascript: window.close()"></div>';
if ($messagetoshow) if ($messagetoshow) {
{
print '<br><br>'; print '<br><br>';
print "\n".'Error returned:<br>'; print "\n".'Error returned:<br>';
print nl2br($messagetoshow); print nl2br($messagetoshow);

View File

@ -34,7 +34,7 @@ class Contacts extends DolibarrApi
* *
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( public static $FIELDS = array(
'lastname', 'lastname',
); );
@ -71,8 +71,7 @@ class Contacts extends DolibarrApi
*/ */
public function get($id, $includecount = 0, $includeroles = 0) public function get($id, $includecount = 0, $includeroles = 0)
{ {
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
{
throw new RestException(401, 'No permission to read contacts'); throw new RestException(401, 'No permission to read contacts');
} }
if ($id == 0) { if ($id == 0) {
@ -81,23 +80,19 @@ class Contacts extends DolibarrApi
$result = $this->contact->fetch($id); $result = $this->contact->fetch($id);
} }
if (!$result) if (!$result) {
{
throw new RestException(404, 'Contact not found'); throw new RestException(404, 'Contact not found');
} }
if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
{
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
if ($includecount) if ($includecount) {
{
$this->contact->load_ref_elements(); $this->contact->load_ref_elements();
} }
if ($includeroles) if ($includeroles) {
{
$this->contact->fetchRoles(); $this->contact->fetchRoles();
} }
@ -119,8 +114,7 @@ class Contacts extends DolibarrApi
*/ */
public function getByEmail($email, $includecount = 0, $includeroles = 0) public function getByEmail($email, $includecount = 0, $includeroles = 0)
{ {
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
{
throw new RestException(401, 'No permission to read contacts'); throw new RestException(401, 'No permission to read contacts');
} }
if (empty($email)) { if (empty($email)) {
@ -129,23 +123,19 @@ class Contacts extends DolibarrApi
$result = $this->contact->fetch('', '', '', $email); $result = $this->contact->fetch('', '', '', $email);
} }
if (!$result) if (!$result) {
{
throw new RestException(404, 'Contact not found'); throw new RestException(404, 'Contact not found');
} }
if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
{
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
if ($includecount) if ($includecount) {
{
$this->contact->load_ref_elements(); $this->contact->load_ref_elements();
} }
if ($includeroles) if ($includeroles) {
{
$this->contact->fetchRoles(); $this->contact->fetchRoles();
} }
@ -176,8 +166,7 @@ class Contacts extends DolibarrApi
$obj_ret = array(); $obj_ret = array();
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
{
throw new RestException(401, 'No permission to read contacts'); throw new RestException(401, 'No permission to read contacts');
} }
@ -186,8 +175,9 @@ class Contacts extends DolibarrApi
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
$search_sale = 0; $search_sale = 0;
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
$search_sale = DolibarrApiAccess::$user->id; $search_sale = DolibarrApiAccess::$user->id;
}
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
@ -201,15 +191,18 @@ class Contacts extends DolibarrApi
} }
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON t.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON t.fk_soc = s.rowid";
$sql .= ' WHERE t.entity IN ('.getEntity('socpeople').')'; $sql .= ' WHERE t.entity IN ('.getEntity('socpeople').')';
if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; if ($socids) {
$sql .= " AND t.fk_soc IN (".$socids.")";
}
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= " AND t.fk_soc = sc.fk_soc"; $sql .= " AND t.fk_soc = sc.fk_soc";
if ($search_sale > 0) }
if ($search_sale > 0) {
$sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
}
// Insert sale filter // Insert sale filter
if ($search_sale > 0) if ($search_sale > 0) {
{
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
@ -220,10 +213,8 @@ class Contacts extends DolibarrApi
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -232,10 +223,8 @@ class Contacts extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
if ($limit) if ($limit) {
{ if ($page < 0) {
if ($page < 0)
{
$page = 0; $page = 0;
} }
$offset = $limit * $page; $offset = $limit * $page;
@ -243,24 +232,19 @@ class Contacts extends DolibarrApi
$sql .= $this->db->plimit($limit + 1, $offset); $sql .= $this->db->plimit($limit + 1, $offset);
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit)); $min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0; $i = 0;
while ($i < $min) while ($i < $min) {
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$contact_static = new Contact($this->db); $contact_static = new Contact($this->db);
if ($contact_static->fetch($obj->rowid)) if ($contact_static->fetch($obj->rowid)) {
{
$contact_static->fetchRoles(); $contact_static->fetchRoles();
if ($includecount) if ($includecount) {
{
$contact_static->load_ref_elements(); $contact_static->load_ref_elements();
} }
if ($includeroles) if ($includeroles) {
{
$contact_static->fetchRoles(); $contact_static->fetchRoles();
} }
@ -272,8 +256,7 @@ class Contacts extends DolibarrApi
} else { } else {
throw new RestException(503, 'Error when retrieve contacts : '.$sql); throw new RestException(503, 'Error when retrieve contacts : '.$sql);
} }
if (!count($obj_ret)) if (!count($obj_ret)) {
{
throw new RestException(404, 'Contacts not found'); throw new RestException(404, 'Contacts not found');
} }
return $obj_ret; return $obj_ret;
@ -287,15 +270,13 @@ class Contacts extends DolibarrApi
*/ */
public function post($request_data = null) public function post($request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
{
throw new RestException(401, 'No permission to create/update contacts'); throw new RestException(401, 'No permission to create/update contacts');
} }
// Check mandatory fields // Check mandatory fields
$result = $this->_validate($request_data); $result = $this->_validate($request_data);
foreach ($request_data as $field => $value) foreach ($request_data as $field => $value) {
{
$this->contact->$field = $value; $this->contact->$field = $value;
} }
if ($this->contact->create(DolibarrApiAccess::$user) < 0) { if ($this->contact->create(DolibarrApiAccess::$user) < 0) {
@ -313,30 +294,29 @@ class Contacts extends DolibarrApi
*/ */
public function put($id, $request_data = null) public function put($id, $request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->societe->contact->creer) if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
{
throw new RestException(401, 'No permission to create/update contacts'); throw new RestException(401, 'No permission to create/update contacts');
} }
$result = $this->contact->fetch($id); $result = $this->contact->fetch($id);
if (!$result) if (!$result) {
{
throw new RestException(404, 'Contact not found'); throw new RestException(404, 'Contact not found');
} }
if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
{
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
foreach ($request_data as $field => $value) foreach ($request_data as $field => $value) {
{ if ($field == 'id') {
if ($field == 'id') continue; continue;
}
$this->contact->$field = $value; $this->contact->$field = $value;
} }
if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) {
return $this->get($id); return $this->get($id);
}
return false; return false;
} }
@ -349,18 +329,15 @@ class Contacts extends DolibarrApi
*/ */
public function delete($id) public function delete($id)
{ {
if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer) if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer) {
{
throw new RestException(401, 'No permission to delete contacts'); throw new RestException(401, 'No permission to delete contacts');
} }
$result = $this->contact->fetch($id); $result = $this->contact->fetch($id);
if (!$result) if (!$result) {
{
throw new RestException(404, 'Contact not found'); throw new RestException(404, 'Contact not found');
} }
if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
{
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$this->contact->oldcopy = clone $this->contact; $this->contact->oldcopy = clone $this->contact;
@ -382,10 +359,12 @@ class Contacts extends DolibarrApi
//throw new RestException(401); //throw new RestException(401);
//} //}
if (!isset($request_data["login"])) if (!isset($request_data["login"])) {
throw new RestException(400, "login field missing"); throw new RestException(400, "login field missing");
if (!isset($request_data["password"])) }
if (!isset($request_data["password"])) {
throw new RestException(400, "password field missing"); throw new RestException(400, "password field missing");
}
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
throw new RestException(401, 'No permission to read contacts'); throw new RestException(401, 'No permission to read contacts');

View File

@ -33,7 +33,7 @@ class Thirdparties extends DolibarrApi
* *
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( public static $FIELDS = array(
'name' 'name'
); );
@ -137,46 +137,68 @@ class Thirdparties extends DolibarrApi
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
$search_sale = 0; $search_sale = 0;
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
$search_sale = DolibarrApiAccess::$user->id;
}
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."societe as t"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as t";
if ($category > 0) { if ($category > 0) {
if ($mode != 4) $sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c"; if ($mode != 4) {
if (!in_array($mode, array(1, 2, 3))) $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as cc"; $sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c";
}
if (!in_array($mode, array(1, 2, 3))) {
$sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as cc";
}
}
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
} }
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st"; $sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st";
$sql .= " WHERE t.entity IN (".getEntity('societe').")"; $sql .= " WHERE t.entity IN (".getEntity('societe').")";
$sql .= " AND t.fk_stcomm = st.id"; $sql .= " AND t.fk_stcomm = st.id";
if ($mode == 1) $sql .= " AND t.client IN (1, 3)"; if ($mode == 1) {
elseif ($mode == 2) $sql .= " AND t.client IN (2, 3)"; $sql .= " AND t.client IN (1, 3)";
elseif ($mode == 3) $sql .= " AND t.client IN (0)"; } elseif ($mode == 2) {
elseif ($mode == 4) $sql .= " AND t.fournisseur IN (1)"; $sql .= " AND t.client IN (2, 3)";
} elseif ($mode == 3) {
$sql .= " AND t.client IN (0)";
} elseif ($mode == 4) {
$sql .= " AND t.fournisseur IN (1)";
}
// Select thirdparties of given category // Select thirdparties of given category
if ($category > 0) { if ($category > 0) {
if (!empty($mode) && $mode != 4) { $sql .= " AND c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid"; } if (!empty($mode) && $mode != 4) {
elseif (!empty($mode) && $mode == 4) { $sql .= " AND cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid"; } $sql .= " AND c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid";
else { $sql .= " AND ((c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid) OR (cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid))"; } } elseif (!empty($mode) && $mode == 4) {
$sql .= " AND cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid";
} else {
$sql .= " AND ((c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid) OR (cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid))";
}
} }
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= " AND t.rowid = sc.fk_soc";
}
//if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; //if ($email != NULL) $sql.= " AND s.email = \"".$email."\"";
if ($socids) $sql .= " AND t.rowid IN (".$socids.")"; if ($socids) {
if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale $sql .= " AND t.rowid IN (".$socids.")";
}
if ($search_sale > 0) {
$sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
}
// Insert sale filter // Insert sale filter
if ($search_sale > 0) if ($search_sale > 0) {
{
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -195,13 +217,11 @@ class Thirdparties extends DolibarrApi
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit)); $min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0; $i = 0;
while ($i < $min) while ($i < $min) {
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$soc_static = new Societe($this->db); $soc_static = new Societe($this->db);
if ($soc_static->fetch($obj->rowid)) { if ($soc_static->fetch($obj->rowid)) {
@ -235,8 +255,9 @@ class Thirdparties extends DolibarrApi
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
$this->company->$field = $value; $this->company->$field = $value;
} }
if ($this->company->create(DolibarrApiAccess::$user) < 0) if ($this->company->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error creating thirdparty', array_merge(array($this->company->error), $this->company->errors)); throw new RestException(500, 'Error creating thirdparty', array_merge(array($this->company->error), $this->company->errors));
}
return $this->company->id; return $this->company->id;
} }
@ -264,7 +285,9 @@ class Thirdparties extends DolibarrApi
} }
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
if ($field == 'id') continue; if ($field == 'id') {
continue;
}
$this->company->$field = $value; $this->company->$field = $value;
} }
@ -295,8 +318,7 @@ class Thirdparties extends DolibarrApi
$error = 0; $error = 0;
if ($id == $idtodelete) if ($id == $idtodelete) {
{
throw new RestException(400, 'Try to merge a thirdparty into itself'); throw new RestException(400, 'Try to merge a thirdparty into itself');
} }
@ -345,26 +367,26 @@ class Thirdparties extends DolibarrApi
'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur', 'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur',
'model_pdf', 'fk_projet' 'model_pdf', 'fk_projet'
); );
foreach ($listofproperties as $property) foreach ($listofproperties as $property) {
{ if (empty($object->$property)) {
if (empty($object->$property)) $object->$property = $soc_origin->$property; $object->$property = $soc_origin->$property;
}
} }
// Concat some data // Concat some data
$listofproperties = array( $listofproperties = array(
'note_public', 'note_private' 'note_public', 'note_private'
); );
foreach ($listofproperties as $property) foreach ($listofproperties as $property) {
{
$object->$property = dol_concatdesc($object->$property, $soc_origin->$property); $object->$property = dol_concatdesc($object->$property, $soc_origin->$property);
} }
// Merge extrafields // Merge extrafields
if (is_array($soc_origin->array_options)) if (is_array($soc_origin->array_options)) {
{ foreach ($soc_origin->array_options as $key => $val) {
foreach ($soc_origin->array_options as $key => $val) if (empty($object->array_options[$key])) {
{ $object->array_options[$key] = $val;
if (empty($object->array_options[$key])) $object->array_options[$key] = $val; }
} }
} }
@ -378,8 +400,7 @@ class Thirdparties extends DolibarrApi
// If thirdparty has a new code that is same than origin, we clean origin code to avoid duplicate key from database unique keys. // If thirdparty has a new code that is same than origin, we clean origin code to avoid duplicate key from database unique keys.
if ($soc_origin->code_client == $object->code_client if ($soc_origin->code_client == $object->code_client
|| $soc_origin->code_fournisseur == $object->code_fournisseur || $soc_origin->code_fournisseur == $object->code_fournisseur
|| $soc_origin->barcode == $object->barcode) || $soc_origin->barcode == $object->barcode) {
{
dol_syslog("We clean customer and supplier code so we will be able to make the update of target"); dol_syslog("We clean customer and supplier code so we will be able to make the update of target");
$soc_origin->code_client = ''; $soc_origin->code_client = '';
$soc_origin->code_fournisseur = ''; $soc_origin->code_fournisseur = '';
@ -389,8 +410,7 @@ class Thirdparties extends DolibarrApi
// Update // Update
$result = $object->update($object->id, $user, 0, 1, 1, 'merge'); $result = $object->update($object->id, $user, 0, 1, 1, 'merge');
if ($result < 0) if ($result < 0) {
{
$error++; $error++;
} }
@ -425,8 +445,7 @@ class Thirdparties extends DolibarrApi
); );
//First, all core objects must update their tables //First, all core objects must update their tables
foreach ($objects as $object_name => $object_file) foreach ($objects as $object_name => $object_file) {
{
require_once DOL_DOCUMENT_ROOT.$object_file; require_once DOL_DOCUMENT_ROOT.$object_file;
if (!$error && !$object_name::replaceThirdparty($this->db, $soc_origin->id, $object->id)) { if (!$error && !$object_name::replaceThirdparty($this->db, $soc_origin->id, $object->id)) {
@ -584,8 +603,7 @@ class Thirdparties extends DolibarrApi
} }
$result = $this->company->fetch($id); $result = $this->company->fetch($id);
if (!$result) if (!$result) {
{
throw new RestException(404, 'Thirdparty not found'); throw new RestException(404, 'Thirdparty not found');
} }
@ -593,13 +611,11 @@ class Thirdparties extends DolibarrApi
$result = $categories->getListForItem($id, 'customer', $sortfield, $sortorder, $limit, $page); $result = $categories->getListForItem($id, 'customer', $sortfield, $sortorder, $limit, $page);
if (is_numeric($result) && $result < 0) if (is_numeric($result) && $result < 0) {
{
throw new RestException(503, 'Error when retrieve category list : '.$categories->error); throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
} }
if (is_numeric($result) && $result == 0) // To fix a return of 0 instead of empty array of method getListForItem if (is_numeric($result) && $result == 0) { // To fix a return of 0 instead of empty array of method getListForItem
{
return array(); return array();
} }
@ -702,8 +718,7 @@ class Thirdparties extends DolibarrApi
} }
$result = $this->company->fetch($id); $result = $this->company->fetch($id);
if (!$result) if (!$result) {
{
throw new RestException(404, 'Thirdparty not found'); throw new RestException(404, 'Thirdparty not found');
} }
@ -711,13 +726,11 @@ class Thirdparties extends DolibarrApi
$result = $categories->getListForItem($id, 'supplier', $sortfield, $sortorder, $limit, $page); $result = $categories->getListForItem($id, 'supplier', $sortfield, $sortorder, $limit, $page);
if (is_numeric($result) && $result < 0) if (is_numeric($result) && $result < 0) {
{
throw new RestException(503, 'Error when retrieve category list : '.$categories->error); throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
} }
if (is_numeric($result) && $result == 0) // To fix a return of 0 instead of empty array of method getListForItem if (is_numeric($result) && $result == 0) { // To fix a return of 0 instead of empty array of method getListForItem
{
return array(); return array();
} }
@ -1005,8 +1018,12 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT f.ref, f.type as factype, re.fk_facture_source, re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc, re.description, re.fk_facture, re.fk_facture_line"; $sql = "SELECT f.ref, f.type as factype, re.fk_facture_source, re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc, re.description, re.fk_facture, re.fk_facture_line";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.rowid = re.fk_facture_source AND re.fk_soc = ".$id; $sql .= " WHERE f.rowid = re.fk_facture_source AND re.fk_soc = ".$id;
if ($filter == "available") $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL"; if ($filter == "available") {
if ($filter == "used") $sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)"; $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL";
}
if ($filter == "used") {
$sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)";
}
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
@ -1137,7 +1154,9 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; $sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
if ($id) $sql .= " WHERE fk_soc = ".$id." "; if ($id) {
$sql .= " WHERE fk_soc = ".$id." ";
}
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1150,11 +1169,9 @@ class Thirdparties extends DolibarrApi
$accounts = array(); $accounts = array();
if ($result) if ($result) {
{
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
while ($i < $num) while ($i < $num) {
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$account = new CompanyBankAccount($this->db); $account = new CompanyBankAccount($this->db);
if ($account->fetch($obj->rowid)) { if ($account->fetch($obj->rowid)) {
@ -1209,8 +1226,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value; $account->$field = $value;
} }
if ($account->create(DolibarrApiAccess::$user) < 0) if ($account->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error creating Company Bank account'); throw new RestException(500, 'Error creating Company Bank account');
}
if (empty($account->rum)) { if (empty($account->rum)) {
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
@ -1219,8 +1237,9 @@ class Thirdparties extends DolibarrApi
$account->date_rum = dol_now(); $account->date_rum = dol_now();
} }
if ($account->update(DolibarrApiAccess::$user) < 0) if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating values'); throw new RestException(500, 'Error updating values');
}
return $this->_cleanObjectDatas($account); return $this->_cleanObjectDatas($account);
} }
@ -1264,8 +1283,9 @@ class Thirdparties extends DolibarrApi
$account->date_rum = dol_now(); $account->date_rum = dol_now();
} }
if ($account->update(DolibarrApiAccess::$user) < 0) if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating values'); throw new RestException(500, 'Error updating values');
}
return $this->_cleanObjectDatas($account); return $this->_cleanObjectDatas($account);
} }
@ -1290,8 +1310,9 @@ class Thirdparties extends DolibarrApi
$account->fetch($bankaccount_id); $account->fetch($bankaccount_id);
if (!$account->socid == $id) if (!$account->socid == $id) {
throw new RestException(401); throw new RestException(401);
}
return $account->delete(DolibarrApiAccess::$user); return $account->delete(DolibarrApiAccess::$user);
} }
@ -1342,8 +1363,12 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
if ($id) $sql .= " WHERE fk_soc = ".$id." "; if ($id) {
if ($companybankid) $sql .= " AND rowid = ".$companybankid.""; $sql .= " WHERE fk_soc = ".$id." ";
}
if ($companybankid) {
$sql .= " AND rowid = ".$companybankid."";
}
$i = 0; $i = 0;
$accounts = array(); $accounts = array();
@ -1409,7 +1434,9 @@ class Thirdparties extends DolibarrApi
*/ */
$sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account"; $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account";
$sql .= " WHERE fk_soc = $id"; $sql .= " WHERE fk_soc = $id";
if ($site) $sql .= " AND site ='$site'"; if ($site) {
$sql .= " AND site ='$site'";
}
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1422,8 +1449,7 @@ class Thirdparties extends DolibarrApi
$accounts = array(); $accounts = array();
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
while ($i < $num) while ($i < $num) {
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$account = new SocieteAccount($this->db); $account = new SocieteAccount($this->db);
@ -1493,8 +1519,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value; $account->$field = $value;
} }
if ($account->create(DolibarrApiAccess::$user) < 0) if ($account->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error creating SocieteAccount entity. Ensure that the ID of thirdparty provided does exist!'); throw new RestException(500, 'Error creating SocieteAccount entity. Ensure that the ID of thirdparty provided does exist!');
}
$this->_cleanObjectDatas($account); $this->_cleanObjectDatas($account);
@ -1582,9 +1609,10 @@ class Thirdparties extends DolibarrApi
$account->$field = $value; $account->$field = $value;
} }
if ($account->update(DolibarrApiAccess::$user) < 0) if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating SocieteAccount entity.'); throw new RestException(500, 'Error updating SocieteAccount entity.');
} }
}
$this->_cleanObjectDatas($account); $this->_cleanObjectDatas($account);
@ -1624,9 +1652,10 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."' "; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."' ";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result && $this->db->num_rows($result) !== 0) if ($result && $this->db->num_rows($result) !== 0) {
throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key."); throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key.");
} }
}
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$account = new SocieteAccount($this->db); $account = new SocieteAccount($this->db);
@ -1636,8 +1665,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value; $account->$field = $value;
} }
if ($account->update(DolibarrApiAccess::$user) < 0) if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating SocieteAccount account'); throw new RestException(500, 'Error updating SocieteAccount account');
}
$this->_cleanObjectDatas($account); $this->_cleanObjectDatas($account);
@ -1713,8 +1743,7 @@ class Thirdparties extends DolibarrApi
$i = 0; $i = 0;
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
while ($i < $num) while ($i < $num) {
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$account = new SocieteAccount($this->db); $account = new SocieteAccount($this->db);
$account->fetch($obj->rowid); $account->fetch($obj->rowid);
@ -1781,8 +1810,9 @@ class Thirdparties extends DolibarrApi
{ {
$thirdparty = array(); $thirdparty = array();
foreach (Thirdparties::$FIELDS as $field) { foreach (Thirdparties::$FIELDS as $field) {
if (!isset($data[$field])) if (!isset($data[$field])) {
throw new RestException(400, "$field field missing"); throw new RestException(400, "$field field missing");
}
$thirdparty[$field] = $data[$field]; $thirdparty[$field] = $data[$field];
} }
return $thirdparty; return $thirdparty;

View File

@ -64,8 +64,7 @@ class Client extends Societe
$sql = "SELECT count(s.rowid) as nb, s.client"; $sql = "SELECT count(s.rowid) as nb, s.client";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$user->socid) if (!$user->rights->societe->client->voir && !$user->socid) {
{
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql .= " WHERE sc.fk_user = ".$user->id; $sql .= " WHERE sc.fk_user = ".$user->id;
$clause = "AND"; $clause = "AND";
@ -75,12 +74,14 @@ class Client extends Societe
$sql .= " GROUP BY s.client"; $sql .= " GROUP BY s.client";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{ while ($obj = $this->db->fetch_object($resql)) {
while ($obj = $this->db->fetch_object($resql)) if ($obj->client == 1 || $obj->client == 3) {
{ $this->nb["customers"] += $obj->nb;
if ($obj->client == 1 || $obj->client == 3) $this->nb["customers"] += $obj->nb; }
if ($obj->client == 2 || $obj->client == 3) $this->nb["prospects"] += $obj->nb; if ($obj->client == 2 || $obj->client == 3) {
$this->nb["prospects"] += $obj->nb;
}
} }
$this->db->free($resql); $this->db->free($resql);
return 1; return 1;
@ -102,7 +103,9 @@ class Client extends Societe
global $langs; global $langs;
$sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcomm"; $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcomm";
if ($active >= 0) $sql .= " WHERE active = ".$active; if ($active >= 0) {
$sql .= " WHERE active = ".$active;
}
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;

View File

@ -85,31 +85,32 @@ class CompanyBankAccount extends Account
// Correct default_rib to be sure to have always one default // Correct default_rib to be sure to have always one default
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$numrows = $this->db->num_rows($result); $numrows = $this->db->num_rows($result);
if ($this->default_rib && $numrows > 0) $this->default_rib = 0; if ($this->default_rib && $numrows > 0) {
if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1; $this->default_rib = 0;
}
if (empty($this->default_rib) && $numrows == 0) {
$this->default_rib = 1;
}
} }
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
$sql .= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')"; $sql .= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{ if ($this->db->affected_rows($resql)) {
if ($this->db->affected_rows($resql))
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib");
if (!$notrigger) if (!$notrigger) {
{
// Call trigger // Call trigger
$result = $this->call_trigger('COMPANY_RIB_CREATE', $user); $result = $this->call_trigger('COMPANY_RIB_CREATE', $user);
if ($result < 0) $error++; if ($result < 0) {
$error++;
}
// End call triggers // End call triggers
if (!$error) if (!$error) {
{
return 1; return 1;
} else { } else {
return 0; return 0;
@ -136,10 +137,16 @@ class CompanyBankAccount extends Account
global $conf; global $conf;
$error = 0; $error = 0;
if (!$this->id) return -1; if (!$this->id) {
return -1;
}
if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1); if (dol_strlen($this->domiciliation) > 255) {
if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1); $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
}
if (dol_strlen($this->owner_address) > 255) {
$this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
}
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
$sql .= " bank = '".$this->db->escape($this->bank)."'"; $sql .= " bank = '".$this->db->escape($this->bank)."'";
@ -153,28 +160,28 @@ class CompanyBankAccount extends Account
$sql .= ",proprio = '".$this->db->escape($this->proprio)."'"; $sql .= ",proprio = '".$this->db->escape($this->proprio)."'";
$sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'";
$sql .= ",default_rib = ".$this->default_rib; $sql .= ",default_rib = ".$this->default_rib;
if ($conf->prelevement->enabled) if ($conf->prelevement->enabled) {
{
$sql .= ",frstrecur = '".$this->db->escape($this->frstrecur)."'"; $sql .= ",frstrecur = '".$this->db->escape($this->frstrecur)."'";
$sql .= ",rum = '".$this->db->escape($this->rum)."'"; $sql .= ",rum = '".$this->db->escape($this->rum)."'";
$sql .= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null"); $sql .= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null");
} }
if (trim($this->label) != '') if (trim($this->label) != '') {
$sql .= ",label = '".$this->db->escape($this->label)."'"; $sql .= ",label = '".$this->db->escape($this->label)."'";
else $sql .= ",label = NULL"; } else {
$sql .= ",label = NULL";
}
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{ if (!$notrigger) {
if (!$notrigger)
{
// Call trigger // Call trigger
$result = $this->call_trigger('COMPANY_RIB_MODIFY', $user); $result = $this->call_trigger('COMPANY_RIB_MODIFY', $user);
if ($result < 0) $error++; if ($result < 0) {
$error++;
}
// End call triggers // End call triggers
if (!$error) if (!$error) {
{
return 1; return 1;
} else { } else {
return -1; return -1;
@ -199,24 +206,29 @@ class CompanyBankAccount extends Account
*/ */
public function fetch($id, $socid = 0, $default = 1, $type = 'ban') public function fetch($id, $socid = 0, $default = 1, $type = 'ban')
{ {
if (empty($id) && empty($socid)) return -1; if (empty($id) && empty($socid)) {
return -1;
}
$sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; $sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum"; $sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
if ($id) $sql .= " WHERE rowid = ".$id; if ($id) {
if ($socid) $sql .= " WHERE rowid = ".$id;
{ }
if ($socid) {
$sql .= " WHERE fk_soc = ".$socid; $sql .= " WHERE fk_soc = ".$socid;
if ($default > -1) $sql .= " AND default_rib = ".$this->db->escape($default); if ($default > -1) {
if ($type) $sql .= " AND type ='".$this->db->escape($type)."'"; $sql .= " AND default_rib = ".$this->db->escape($default);
}
if ($type) {
$sql .= " AND type ='".$this->db->escape($type)."'";
}
} }
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{ if ($this->db->num_rows($resql)) {
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref $this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref
@ -268,28 +280,26 @@ class CompanyBankAccount extends Account
$this->db->begin(); $this->db->begin();
if (!$error && !$notrigger) if (!$error && !$notrigger) {
{
// Call trigger // Call trigger
$result = $this->call_trigger('COMPANY_RIB_DELETE', $user); $result = $this->call_trigger('COMPANY_RIB_DELETE', $user);
if ($result < 0) $error++; if ($result < 0) {
$error++;
}
// End call triggers // End call triggers
} }
if (!$error) if (!$error) {
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib";
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
if (!$this->db->query($sql)) if (!$this->db->query($sql)) {
{
$error++; $error++;
$this->errors[] = $this->db->lasterror(); $this->errors[] = $this->db->lasterror();
} }
} }
if (!$error) if (!$error) {
{
$this->db->commit(); $this->db->commit();
return 1; return 1;
} else { } else {
@ -332,10 +342,8 @@ class CompanyBankAccount extends Account
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result1 = $this->db->query($sql1); $result1 = $this->db->query($sql1);
if ($result1) if ($result1) {
{ if ($this->db->num_rows($result1) == 0) {
if ($this->db->num_rows($result1) == 0)
{
return 0; return 0;
} else { } else {
$obj = $this->db->fetch_object($result1); $obj = $this->db->fetch_object($result1);
@ -352,8 +360,7 @@ class CompanyBankAccount extends Account
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result3 = $this->db->query($sql3); $result3 = $this->db->query($sql3);
if (!$result2 || !$result3) if (!$result2 || !$result3) {
{
dol_print_error($this->db); dol_print_error($this->db);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;

View File

@ -232,8 +232,12 @@ class CompanyPaymentMode extends CommonObject
$this->db = $db; $this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; $this->fields['rowid']['visible'] = 0;
}
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
} }
/** /**
@ -313,8 +317,12 @@ class CompanyPaymentMode extends CommonObject
*/ */
public function fetch($id, $ref = null, $socid = 0, $type = '', $morewhere = '') public function fetch($id, $ref = null, $socid = 0, $type = '', $morewhere = '')
{ {
if ($socid) $morewhere .= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1"; if ($socid) {
if ($type) $morewhere .= " AND type = '".$this->db->escape($type)."'"; $morewhere .= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1";
}
if ($type) {
$morewhere .= " AND type = '".$this->db->escape($type)."'";
}
$result = $this->fetchCommon($id, $ref, $morewhere); $result = $this->fetchCommon($id, $ref, $morewhere);
//if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); //if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
@ -375,7 +383,9 @@ class CompanyPaymentMode extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = ''; $result = '';
$companylink = ''; $companylink = '';
@ -386,33 +396,40 @@ class CompanyPaymentMode extends CommonObject
$url = dol_buildpath('/monmodule/companypaymentmode_card.php', 1).'?id='.$this->id; $url = dol_buildpath('/monmodule/companypaymentmode_card.php', 1).'?id='.$this->id;
if ($option != 'nolink') if ($option != 'nolink') {
{
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
} }
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip)) {
{ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $langs->trans("ShowCompanyPaymentMode"); $label = $langs->trans("ShowCompanyPaymentMode");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
$linkend = '</a>'; $linkend = '</a>';
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); if ($withpicto) {
if ($withpicto != 2) $result .= $this->ref; $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend; $result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@ -433,33 +450,36 @@ class CompanyPaymentMode extends CommonObject
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result1 = $this->db->query($sql1); $result1 = $this->db->query($sql1);
if ($result1) if ($result1) {
{ if ($this->db->num_rows($result1) == 0) {
if ($this->db->num_rows($result1) == 0)
{
return 0; return 0;
} else { } else {
$obj = $this->db->fetch_object($result1); $obj = $this->db->fetch_object($result1);
$type = ''; $type = '';
if (empty($alltypes)) $type = $obj->type; if (empty($alltypes)) {
$type = $obj->type;
}
$this->db->begin(); $this->db->begin();
$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0, tms = tms"; $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0, tms = tms";
$sql2 .= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc; $sql2 .= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc;
if ($type) $sql2 .= " AND type = '".$this->db->escape($type)."'"; if ($type) {
$sql2 .= " AND type = '".$this->db->escape($type)."'";
}
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result2 = $this->db->query($sql2); $result2 = $this->db->query($sql2);
$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1"; $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
$sql3 .= " WHERE rowid = ".$obj->id; $sql3 .= " WHERE rowid = ".$obj->id;
if ($type) $sql3 .= " AND type = '".$this->db->escape($type)."'"; if ($type) {
$sql3 .= " AND type = '".$this->db->escape($type)."'";
}
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result3 = $this->db->query($sql3); $result3 = $this->db->query($sql3);
if (!$result2 || !$result3) if (!$result2 || !$result3) {
{
dol_print_error($this->db); dol_print_error($this->db);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
@ -496,8 +516,7 @@ class CompanyPaymentMode extends CommonObject
public function LibStatut($status, $mode = 0) public function LibStatut($status, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort)) if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
{
global $langs; global $langs;
//$langs->load("mymodule"); //$langs->load("mymodule");
$this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled'); $this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled');
@ -507,7 +526,9 @@ class CompanyPaymentMode extends CommonObject
} }
$statusType = 'status5'; $statusType = 'status5';
if ($status == self::STATUS_ENABLED) $statusType = 'status4'; if ($status == self::STATUS_ENABLED) {
$statusType = 'status4';
}
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
} }
@ -525,28 +546,23 @@ class CompanyPaymentMode extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id; $sql .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{ if ($this->db->num_rows($result)) {
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
if ($obj->fk_user_author) if ($obj->fk_user_author) {
{
$cuser = new User($this->db); $cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author); $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser; $this->user_creation = $cuser;
} }
if ($obj->fk_user_valid) if ($obj->fk_user_valid) {
{
$vuser = new User($this->db); $vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid); $vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser; $this->user_validation = $vuser;
} }
if ($obj->fk_user_cloture) if ($obj->fk_user_cloture) {
{
$cluser = new User($this->db); $cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture); $cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser; $this->user_cloture = $cluser;

View File

@ -905,9 +905,8 @@ class Societe extends CommonObject
// Ajout du commercial affecte // Ajout du commercial affecte
if ($this->commercial_id != '' && $this->commercial_id != -1) { if ($this->commercial_id != '' && $this->commercial_id != -1) {
$this->add_commercial($user, $this->commercial_id); $this->add_commercial($user, $this->commercial_id);
} } elseif (empty($user->rights->societe->client->voir)) {
// si un commercial cree un client il lui est affecte automatiquement // si un commercial cree un client il lui est affecte automatiquement
elseif (empty($user->rights->societe->client->voir)) {
$this->add_commercial($user, $user->id); $this->add_commercial($user, $user->id);
} }
@ -2626,20 +2625,17 @@ class Societe extends CommonObject
$s = ''; $s = '';
if (empty($option) || preg_match('/prospect/', $option)) { if (empty($option) || preg_match('/prospect/', $option)) {
if (($this->client == 2 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) if (($this->client == 2 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
{
$s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>'; $s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
} }
} }
if (empty($option) || preg_match('/customer/', $option)) { if (empty($option) || preg_match('/customer/', $option)) {
if (($this->client == 1 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) if (($this->client == 1 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
{
$s .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>'; $s .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
} }
} }
if (empty($option) || preg_match('/supplier/', $option)) { if (empty($option) || preg_match('/supplier/', $option)) {
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $this->fournisseur) if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $this->fournisseur) {
{
$s .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>'; $s .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>';
} }
} }
@ -3811,8 +3807,7 @@ class Societe extends CommonObject
dol_syslog("We ask to create a contact/address too", LOG_DEBUG); dol_syslog("We ask to create a contact/address too", LOG_DEBUG);
$result = $this->create_individual($user); $result = $this->create_individual($user);
if ($result < 0) if ($result < 0) {
{
setEventMessages($this->error, $this->errors, 'errors'); setEventMessages($this->error, $this->errors, 'errors');
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
@ -4682,8 +4677,7 @@ class Societe extends CommonObject
$this->db->commit(); $this->db->commit();
return 1; return 1;
} } else {
else {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return -1; return -1;

View File

@ -172,7 +172,9 @@ class SocieteAccount extends CommonObject
$this->db = $db; $this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0; if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
$this->fields['rowid']['visible'] = 0;
}
} }
/** /**
@ -248,7 +250,9 @@ class SocieteAccount extends CommonObject
public function fetch($id, $ref = null) public function fetch($id, $ref = null)
{ {
$result = $this->fetchCommon($id, $ref); $result = $this->fetchCommon($id, $ref);
if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); if ($result > 0 && !empty($this->table_element_line)) {
$this->fetchLines();
}
return $result; return $result;
} }
@ -375,7 +379,9 @@ class SocieteAccount extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = ''; $result = '';
@ -388,33 +394,40 @@ class SocieteAccount extends CommonObject
$url = dol_buildpath('/website/websiteaccount_card.php', 1).'?id='.$this->id; $url = dol_buildpath('/website/websiteaccount_card.php', 1).'?id='.$this->id;
if ($option != 'nolink') if ($option != 'nolink') {
{
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
} }
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip)) {
{ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $langs->trans("WebsiteAccount"); $label = $langs->trans("WebsiteAccount");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
$linkend = '</a>'; $linkend = '</a>';
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); if ($withpicto) {
if ($withpicto != 2) $result .= $this->ref; $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend; $result .= $linkend;
return $result; return $result;
@ -444,35 +457,49 @@ class SocieteAccount extends CommonObject
// phpcs:enable // phpcs:enable
global $langs; global $langs;
if ($mode == 0) if ($mode == 0) {
{
$prefix = ''; $prefix = '';
if ($status == 1) return $langs->trans('Enabled'); if ($status == 1) {
elseif ($status == 0) return $langs->trans('Disabled'); return $langs->trans('Enabled');
} elseif ($mode == 1) } elseif ($status == 0) {
{ return $langs->trans('Disabled');
if ($status == 1) return $langs->trans('Enabled'); }
elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($mode == 1) {
} elseif ($mode == 2) if ($status == 1) {
{ return $langs->trans('Enabled');
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); } elseif ($status == 0) {
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); return $langs->trans('Disabled');
} elseif ($mode == 3) }
{ } elseif ($mode == 2) {
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); if ($status == 1) {
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
} elseif ($mode == 4) } elseif ($status == 0) {
{ return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); }
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 3) {
} elseif ($mode == 5) if ($status == 1) {
{ return img_picto($langs->trans('Enabled'), 'statut4');
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); } elseif ($status == 0) {
elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); return img_picto($langs->trans('Disabled'), 'statut5');
} elseif ($mode == 6) }
{ } elseif ($mode == 4) {
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); if ($status == 1) {
elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
} elseif ($status == 0) {
return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
}
} elseif ($mode == 5) {
if ($status == 1) {
return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
} elseif ($status == 0) {
return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
}
} elseif ($mode == 6) {
if ($status == 1) {
return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
} elseif ($status == 0) {
return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
}
} }
} }
@ -489,28 +516,23 @@ class SocieteAccount extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id; $sql .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{ if ($this->db->num_rows($result)) {
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
if ($obj->fk_user_author) if ($obj->fk_user_author) {
{
$cuser = new User($this->db); $cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author); $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser; $this->user_creation = $cuser;
} }
if ($obj->fk_user_valid) if ($obj->fk_user_valid) {
{
$vuser = new User($this->db); $vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid); $vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser; $this->user_validation = $vuser;
} }
if ($obj->fk_user_cloture) if ($obj->fk_user_cloture) {
{
$cluser = new User($this->db); $cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture); $cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser; $this->user_cloture = $cluser;

View File

@ -35,22 +35,32 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thi
// Security check // Security check
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'societe', $socid, '&societe'); $result = restrictedArea($user, 'societe', $socid, '&societe');
$object = new Societe($db); $object = new Societe($db);
if ($socid > 0) $object->fetch($socid); if ($socid > 0) {
$object->fetch($socid);
}
// Sort & Order fields // Sort & Order fields
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = 'DESC'; if (!$sortorder) {
if (!$sortfield) $sortfield = 'dateprint'; $sortorder = 'DESC';
}
if (!$sortfield) {
$sortfield = 'dateprint';
}
// Search fields // Search fields
$sref = GETPOST("sref"); $sref = GETPOST("sref");
@ -59,8 +69,7 @@ $month = GETPOST('month', 'int');
$year = GETPOST('year', 'int'); $year = GETPOST('year', 'int');
// Clean up on purge search criteria ? // Clean up on purge search criteria ?
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
{
$sref = ''; $sref = '';
$sprod_fulldescr = ''; $sprod_fulldescr = '';
$year = ''; $year = '';
@ -83,7 +92,9 @@ $hookmanager->initHooks(array('consumptionthirdparty'));
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
@ -96,12 +107,13 @@ $formother = new FormOther($db);
$productstatic = new Product($db); $productstatic = new Product($db);
$title = $langs->trans("Referers", $object->name); $title = $langs->trans("Referers", $object->name);
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name." - ".$title;
}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);
if (empty($socid)) if (empty($socid)) {
{
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
@ -118,15 +130,13 @@ print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
{
print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
} }
//if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events'); //if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events');
if ($object->client) if ($object->client) {
{
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">'; print $langs->trans('CustomerCode').'</td><td colspan="3">';
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
@ -137,21 +147,32 @@ if ($object->client)
print '</td></tr>'; print '</td></tr>';
$sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid;
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) dol_print_error($db); if (!$resql) {
dol_print_error($db);
}
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$nbFactsClient = $obj->nb; $nbFactsClient = $obj->nb;
$thirdTypeArray['customer'] = $langs->trans("customer"); $thirdTypeArray['customer'] = $langs->trans("customer");
if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); if ($conf->propal->enabled && $user->rights->propal->lire) {
if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals');
if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); }
if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); if ($conf->commande->enabled && $user->rights->commande->lire) {
$elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders');
}
if ($conf->facture->enabled && $user->rights->facture->lire) {
$elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices');
}
if ($conf->contrat->enabled && $user->rights->contrat->lire) {
$elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts');
}
} }
if (!empty($conf->ficheinter->enabled) && !empty($user->rights->ficheinter->lire)) $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions'); if (!empty($conf->ficheinter->enabled) && !empty($user->rights->ficheinter->lire)) {
$elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
}
if ($object->fournisseur) if ($object->fournisseur) {
{
$langs->load("supplier_proposal"); $langs->load("supplier_proposal");
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">'; print $langs->trans('SupplierCode').'</td><td colspan="3">';
@ -163,14 +184,22 @@ if ($object->fournisseur)
print '</td></tr>'; print '</td></tr>';
$sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".$socid; $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".$socid;
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) dol_print_error($db); if (!$resql) {
dol_print_error($db);
}
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$nbCmdsFourn = $obj->nb; $nbCmdsFourn = $obj->nb;
$thirdTypeArray['supplier'] = $langs->trans("supplier"); $thirdTypeArray['supplier'] = $langs->trans("supplier");
if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices'); if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) {
if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders'); $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal'] = $langs->transnoentitiesnoconv('SupplierProposals'); }
if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) {
$elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders');
}
if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) {
$elementTypeArray['supplier_proposal'] = $langs->transnoentitiesnoconv('SupplierProposals');
}
} }
print '</table>'; print '</table>';
@ -194,8 +223,7 @@ $sql_select = '';
$dateprint = 'f.datep'; $dateprint = 'f.datep';
$doc_number='f.id'; $doc_number='f.id';
}*/ }*/
if ($type_element == 'fichinter') if ($type_element == 'fichinter') { // Customer : show products from invoices
{ // Customer : show products from invoices
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
$documentstatic = new Fichinter($db); $documentstatic = new Fichinter($db);
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, '; $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, ';
@ -205,8 +233,7 @@ if ($type_element == 'fichinter')
$dateprint = 'f.datec'; $dateprint = 'f.datec';
$doc_number = 'f.ref'; $doc_number = 'f.ref';
} }
if ($type_element == 'invoice') if ($type_element == 'invoice') { // Customer : show products from invoices
{ // Customer : show products from invoices
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$documentstatic = new Facture($db); $documentstatic = new Facture($db);
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, '; $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, ';
@ -218,8 +245,7 @@ if ($type_element == 'invoice')
$doc_number = 'f.ref'; $doc_number = 'f.ref';
$thirdTypeSelect = 'customer'; $thirdTypeSelect = 'customer';
} }
if ($type_element == 'propal') if ($type_element == 'propal') {
{
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$documentstatic = new Propal($db); $documentstatic = new Propal($db);
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, '; $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, ';
@ -231,8 +257,7 @@ if ($type_element == 'propal')
$doc_number = 'c.ref'; $doc_number = 'c.ref';
$thirdTypeSelect = 'customer'; $thirdTypeSelect = 'customer';
} }
if ($type_element == 'order') if ($type_element == 'order') {
{
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$documentstatic = new Commande($db); $documentstatic = new Commande($db);
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, '; $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, ';
@ -244,8 +269,7 @@ if ($type_element == 'order')
$doc_number = 'c.ref'; $doc_number = 'c.ref';
$thirdTypeSelect = 'customer'; $thirdTypeSelect = 'customer';
} }
if ($type_element == 'supplier_invoice') if ($type_element == 'supplier_invoice') { // Supplier : Show products from invoices.
{ // Supplier : Show products from invoices.
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$documentstatic = new FactureFournisseur($db); $documentstatic = new FactureFournisseur($db);
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, '; $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, ';
@ -257,8 +281,7 @@ if ($type_element == 'supplier_invoice')
$doc_number = 'f.ref'; $doc_number = 'f.ref';
$thirdTypeSelect = 'supplier'; $thirdTypeSelect = 'supplier';
} }
if ($type_element == 'supplier_proposal') if ($type_element == 'supplier_proposal') {
{
require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
$documentstatic = new SupplierProposal($db); $documentstatic = new SupplierProposal($db);
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, ';
@ -270,8 +293,7 @@ if ($type_element == 'supplier_proposal')
$doc_number = 'c.ref'; $doc_number = 'c.ref';
$thirdTypeSelect = 'supplier'; $thirdTypeSelect = 'supplier';
} }
if ($type_element == 'supplier_order') if ($type_element == 'supplier_order') { // Supplier : Show products from orders.
{ // Supplier : Show products from orders.
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$documentstatic = new CommandeFournisseur($db); $documentstatic = new CommandeFournisseur($db);
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, ';
@ -283,8 +305,7 @@ if ($type_element == 'supplier_order')
$doc_number = 'c.ref'; $doc_number = 'c.ref';
$thirdTypeSelect = 'supplier'; $thirdTypeSelect = 'supplier';
} }
if ($type_element == 'contract') if ($type_element == 'contract') { // Order
{ // Order
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
$documentstatic = new Contrat($db); $documentstatic = new Contrat($db);
$documentstaticline = new ContratLigne($db); $documentstaticline = new ContratLigne($db);
@ -301,26 +322,42 @@ if ($type_element == 'contract')
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
if (!empty($sql_select)) if (!empty($sql_select)) {
{
$sql = $sql_select; $sql = $sql_select;
$sql .= ' d.description as description,'; $sql .= ' d.description as description,';
if ($type_element != 'fichinter' && $type_element != 'contract' && $type_element != 'supplier_proposal') $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; if ($type_element != 'fichinter' && $type_element != 'contract' && $type_element != 'supplier_proposal') {
if ($type_element == 'supplier_proposal') $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
if ($type_element == 'contract') $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; }
if ($type_element != 'fichinter') $sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity,'; if ($type_element == 'supplier_proposal') {
$sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
}
if ($type_element == 'contract') {
$sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
}
if ($type_element != 'fichinter') {
$sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity,';
}
$sql .= " s.rowid as socid "; $sql .= " s.rowid as socid ";
if ($type_element != 'fichinter') $sql .= ", p.ref as prod_ref, p.label as product_label"; if ($type_element != 'fichinter') {
$sql .= ", p.ref as prod_ref, p.label as product_label";
}
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".$tables_from; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".$tables_from;
if ($type_element != 'fichinter') $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; if ($type_element != 'fichinter') {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid ';
}
$sql .= $where; $sql .= $where;
$sql .= dolSqlDateFilter($dateprint, 0, $month, $year); $sql .= dolSqlDateFilter($dateprint, 0, $month, $year);
if ($sref) $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; if ($sref) {
if ($sprod_fulldescr) $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'";
{ }
if ($sprod_fulldescr) {
$sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'";
if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; if (GETPOST('type_element') != 'fichinter') {
if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'"; $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'";
}
if (GETPOST('type_element') != 'fichinter') {
$sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'";
}
$sql .= ")"; $sql .= ")";
} }
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
@ -334,8 +371,7 @@ if (!empty($sql_select))
$disabled = 0; $disabled = 0;
$showempty = 2; $showempty = 2;
if (empty($elementTypeArray) && !$object->client && !$object->fournisseur) if (empty($elementTypeArray) && !$object->client && !$object->fournisseur) {
{
$showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef"); $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef");
$disabled = 1; $disabled = 1;
} }
@ -354,21 +390,36 @@ $param .= "&type_element=".urlencode($type_element);
$total_qty = 0; $total_qty = 0;
if ($sql_select) if ($sql_select) {
{
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) dol_print_error($db); if (!$resql) {
dol_print_error($db);
}
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$param = "&socid=".urlencode($socid)."&type_element=".urlencode($type_element); $param = "&socid=".urlencode($socid)."&type_element=".urlencode($type_element);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
if ($sprod_fulldescr) $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); }
if ($sref) $param .= "&sref=".urlencode($sref); if ($limit > 0 && $limit != $conf->liste_limit) {
if ($month) $param .= "&month=".urlencode($month); $param .= '&limit='.urlencode($limit);
if ($year) $param .= "&year=".urlencode($year); }
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($sprod_fulldescr) {
$param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr);
}
if ($sref) {
$param .= "&sref=".urlencode($sref);
}
if ($month) {
$param .= "&month=".urlencode($month);
}
if ($year) {
$param .= "&year=".urlencode($year);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit); print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit);
@ -412,8 +463,7 @@ if ($sql_select)
$i = 0; $i = 0;
while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit)) while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit)) {
{
$documentstatic->id = $objp->doc_id; $documentstatic->id = $objp->doc_id;
$documentstatic->ref = $objp->doc_number; $documentstatic->ref = $objp->doc_number;
$documentstatic->type = $objp->doc_type; $documentstatic->type = $objp->doc_type;
@ -423,7 +473,9 @@ if ($sql_select)
$documentstatic->status = $objp->status; $documentstatic->status = $objp->status;
$documentstatic->paye = $objp->paid; $documentstatic->paye = $objp->paid;
if (is_object($documentstaticline)) $documentstaticline->statut = $objp->status; if (is_object($documentstaticline)) {
$documentstaticline->statut = $objp->status;
}
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nobordernopadding nowrap" width="100">'; print '<td class="nobordernopadding nowrap" width="100">';
@ -447,8 +499,7 @@ if ($sql_select)
$text = ''; $description = ''; $type = 0; $text = ''; $description = ''; $type = 0;
// Code to show product duplicated from commonobject->printObjectLine // Code to show product duplicated from commonobject->printObjectLine
if ($objp->fk_product > 0) if ($objp->fk_product > 0) {
{
$product_static = new Product($db); $product_static = new Product($db);
$product_static->type = $objp->fk_product_type; $product_static->type = $objp->fk_product_type;
@ -459,20 +510,21 @@ if ($sql_select)
} }
// Product // Product
if ($objp->fk_product > 0) if ($objp->fk_product > 0) {
{
// Define output language // Define output language
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
{
$prod = new Product($db); $prod = new Product($db);
$prod->fetch($objp->fk_product); $prod->fetch($objp->fk_product);
$outputlangs = $langs; $outputlangs = $langs;
$newlang = ''; $newlang = '';
if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if (empty($newlang) && GETPOST('lang_id', 'aZ09')) {
if (empty($newlang)) $newlang = $object->default_lang; $newlang = GETPOST('lang_id', 'aZ09');
if (!empty($newlang)) }
{ if (empty($newlang)) {
$newlang = $object->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
@ -491,39 +543,40 @@ if ($sql_select)
<?php <?php
$txt = ''; $txt = '';
print img_object($langs->trans("ShowReduc"), 'reduc').' '; print img_object($langs->trans("ShowReduc"), 'reduc').' ';
if ($objp->description == '(DEPOSIT)') $txt = $langs->trans("Deposit"); if ($objp->description == '(DEPOSIT)') {
elseif ($objp->description == '(EXCESS RECEIVED)') $txt = $langs->trans("ExcessReceived"); $txt = $langs->trans("Deposit");
elseif ($objp->description == '(EXCESS PAID)') $txt = $langs->trans("ExcessPaid"); } elseif ($objp->description == '(EXCESS RECEIVED)') {
$txt = $langs->trans("ExcessReceived");
} elseif ($objp->description == '(EXCESS PAID)') {
$txt = $langs->trans("ExcessPaid");
}
//else $txt=$langs->trans("Discount"); //else $txt=$langs->trans("Discount");
print $txt; print $txt;
?> ?>
</a> </a>
<?php <?php
if ($objp->description) if ($objp->description) {
{ if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) {
if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0)
{
$discount = new DiscountAbsolute($db); $discount = new DiscountAbsolute($db);
$discount->fetch($objp->fk_remise_except); $discount->fetch($objp->fk_remise_except);
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
} }
if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) {
{
$discount = new DiscountAbsolute($db); $discount = new DiscountAbsolute($db);
$discount->fetch($objp->fk_remise_except); $discount->fetch($objp->fk_remise_except);
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0));
} elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) } elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) {
{
$discount = new DiscountAbsolute($db); $discount = new DiscountAbsolute($db);
$discount->fetch($objp->fk_remise_except); $discount->fetch($objp->fk_remise_except);
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0));
} elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) } elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) {
{
$discount = new DiscountAbsolute($db); $discount = new DiscountAbsolute($db);
$discount->fetch($objp->fk_remise_except); $discount->fetch($objp->fk_remise_except);
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
// Add date of deposit // Add date of deposit
if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
echo ' ('.dol_print_date($discount->datec).')';
}
} else { } else {
echo ($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description); echo ($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description);
} }
@ -536,15 +589,16 @@ if ($sql_select)
echo get_date_range($objp->date_start, $objp->date_end); echo get_date_range($objp->date_start, $objp->date_end);
// Add description in form // Add description in form
if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
{
print (!empty($objp->description) && $objp->description != $objp->product_label) ? '<br>'.dol_htmlentitiesbr($objp->description) : ''; print (!empty($objp->description) && $objp->description != $objp->product_label) ? '<br>'.dol_htmlentitiesbr($objp->description) : '';
} }
} else { } else {
if (!empty($objp->label) || !empty($objp->description)) if (!empty($objp->label) || !empty($objp->description)) {
{ if ($type == 1) {
if ($type == 1) $text = img_object($langs->trans('Service'), 'service'); $text = img_object($langs->trans('Service'), 'service');
else $text = img_object($langs->trans('Product'), 'product'); } else {
$text = img_object($langs->trans('Product'), 'product');
}
if (!empty($objp->label)) { if (!empty($objp->label)) {
$text .= ' <strong>'.$objp->label.'</strong>'; $text .= ' <strong>'.$objp->label.'</strong>';
@ -580,7 +634,9 @@ if ($sql_select)
print '</td>'; print '</td>';
//print '<td class="left">'.$prodreftxt.'</td>'; //print '<td class="left">'.$prodreftxt.'</td>';
if ($type_element == 'invoice' && $objp->doc_type == Facture::TYPE_CREDIT_NOTE) $objp->prod_qty = -($objp->prod_qty); if ($type_element == 'invoice' && $objp->doc_type == Facture::TYPE_CREDIT_NOTE) {
$objp->prod_qty = -($objp->prod_qty);
}
print '<td class="right">'.$objp->prod_qty.'</td>'; print '<td class="right">'.$objp->prod_qty.'</td>';
$total_qty += $objp->prod_qty; $total_qty += $objp->prod_qty;
@ -606,9 +662,7 @@ if ($sql_select)
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num); print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
} }
$db->free($resql); $db->free($resql);
} } elseif (empty($type_element) || $type_element == -1) {
elseif (empty($type_element) || $type_element == -1)
{
print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', (!empty($num) ? $num : 0), '', ''); print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', (!empty($num) ? $num : 0), '', '');
print '<table class="liste centpercent">'."\n"; print '<table class="liste centpercent">'."\n";

View File

@ -42,12 +42,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; if (!empty($conf->adherent->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
}
$langs->loadLangs(array("companies", "commercial", "bills", "banks", "users")); $langs->loadLangs(array("companies", "commercial", "bills", "banks", "users"));
if (!empty($conf->categorie->enabled)) $langs->load("categories"); if (!empty($conf->categorie->enabled)) {
if (!empty($conf->incoterm->enabled)) $langs->load("incoterm"); $langs->load("categories");
if (!empty($conf->notification->enabled)) $langs->load("mails"); }
if (!empty($conf->incoterm->enabled)) {
$langs->load("incoterm");
}
if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$mesg = ''; $error = 0; $errors = array(); $mesg = ''; $error = 0; $errors = array();
@ -56,8 +64,12 @@ $cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
$confirm = GETPOST('confirm'); $confirm = GETPOST('confirm');
$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
if ($user->socid) $socid = $user->socid; if ($user->socid) {
if (empty($socid) && $action == 'view') $action = 'create'; $socid = $user->socid;
}
if (empty($socid) && $action == 'view') {
$action = 'create';
}
$object = new Societe($db); $object = new Societe($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
@ -68,8 +80,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('thirdpartycontact', 'globalcard')); $hookmanager->initHooks(array('thirdpartycontact', 'globalcard'));
if ($object->fetch($socid) <= 0 && $action == 'view') if ($object->fetch($socid) <= 0 && $action == 'view') {
{
$langs->load("errors"); $langs->load("errors");
print($langs->trans('ErrorRecordNotFound')); print($langs->trans('ErrorRecordNotFound'));
exit; exit;
@ -78,8 +89,7 @@ if ($object->fetch($socid) <= 0 && $action == 'view')
// Get object canvas (By default, this is not defined, so standard usage of dolibarr) // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$canvas = $object->canvas ? $object->canvas : GETPOST("canvas"); $canvas = $object->canvas ? $object->canvas : GETPOST("canvas");
$objcanvas = null; $objcanvas = null;
if (!empty($canvas)) if (!empty($canvas)) {
{
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
$objcanvas = new Canvas($db, $action); $objcanvas = new Canvas($db, $action);
$objcanvas->getCanvas('thirdparty', 'card', $canvas); $objcanvas->getCanvas('thirdparty', 'card', $canvas);
@ -87,7 +97,9 @@ if (!empty($canvas))
// Security check // Security check
$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0); $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0);
if (empty($user->rights->societe->contact->lire)) accessforbidden(); if (empty($user->rights->societe->contact->lire)) {
accessforbidden();
}
/* /*
@ -96,15 +108,14 @@ if (empty($user->rights->societe->contact->lire)) accessforbidden();
$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas); $parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{ if ($cancel) {
if ($cancel)
{
$action = ''; $action = '';
if (!empty($backtopage)) if (!empty($backtopage)) {
{
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} }
@ -124,21 +135,26 @@ $formfile = new FormFile($db);
$formadmin = new FormAdmin($db); $formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
if ($socid > 0 && empty($object->id)) if ($socid > 0 && empty($object->id)) {
{
$result = $object->fetch($socid); $result = $object->fetch($socid);
if ($result <= 0) dol_print_error('', $object->error); if ($result <= 0) {
dol_print_error('', $object->error);
}
} }
$title = $langs->trans("ThirdParty"); $title = $langs->trans("ThirdParty");
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$langs->trans('Card'); if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name." - ".$langs->trans('Card');
}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
if (!empty($object->id)) $res = $object->fetch_optionals(); if (!empty($object->id)) {
$res = $object->fetch_optionals();
}
//if ($res < 0) { dol_print_error($db); exit; } //if ($res < 0) { dol_print_error($db); exit; }
@ -154,11 +170,9 @@ print dol_get_fiche_end();
print '<br>'; print '<br>';
if ($action != 'presend') if ($action != 'presend') {
{
// Contacts list // Contacts list
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
{
$result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); $result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
} }
} }

View File

@ -40,8 +40,7 @@ $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'))
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
{
unset($action); unset($action);
$socid = $user->socid; $socid = $user->socid;
} }
@ -52,20 +51,29 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield = $conf->global->MAIN_DOC_SORT_FIELD; } if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) {
if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; } $sortfield = $conf->global->MAIN_DOC_SORT_FIELD;
}
if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) {
$sortorder = $conf->global->MAIN_DOC_SORT_ORDER;
}
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "position_name"; $sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "position_name";
}
$object = new Societe($db); $object = new Societe($db);
if ($id > 0 || !empty($ref)) if ($id > 0 || !empty($ref)) {
{
$result = $object->fetch($id, $ref); $result = $object->fetch($id, $ref);
$upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id; $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
@ -91,16 +99,19 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
$form = new Form($db); $form = new Form($db);
$title = $langs->trans("ThirdParty").' - '.$langs->trans("Files"); $title = $langs->trans("ThirdParty").' - '.$langs->trans("Files");
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Files"); if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name.' - '.$langs->trans("Files");
}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);
if ($object->id) if ($object->id) {
{
/* /*
* Show tabs * Show tabs
*/ */
if (!empty($conf->notification->enabled)) $langs->load("mails"); if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = societe_prepare_head($object); $head = societe_prepare_head($object);
$form = new Form($db); $form = new Form($db);
@ -111,8 +122,7 @@ if ($object->id)
// Build file list // Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0; $totalsize = 0;
foreach ($filearray as $key => $file) foreach ($filearray as $key => $file) {
{
$totalsize += $file['size']; $totalsize += $file['size'];
} }
@ -126,13 +136,11 @@ if ($object->id)
print '<table class="border tableforfield centpercent">'; print '<table class="border tableforfield centpercent">';
// Prefix // Prefix
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
{
print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
} }
if ($object->client) if ($object->client) {
{
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">'; print $langs->trans('CustomerCode').'</td><td colspan="3">';
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
@ -143,8 +151,7 @@ if ($object->id)
print '</td></tr>'; print '</td></tr>';
} }
if ($object->fournisseur) if ($object->fournisseur) {
{
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">'; print $langs->trans('SupplierCode').'</td><td colspan="3">';
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));

View File

@ -38,7 +38,9 @@ $hookmanager->initHooks(array('thirdpartiesindex'));
$langs->load("companies"); $langs->load("companies");
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
// Security check // Security check
$result = restrictedArea($user, 'societe', 0, '', '', '', ''); $result = restrictedArea($user, 'societe', 0, '', '', '', '');
@ -75,37 +77,62 @@ $total = 0;
$sql = "SELECT s.rowid, s.client, s.fournisseur"; $sql = "SELECT s.rowid, s.client, s.fournisseur";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; $sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if (!$user->rights->societe->client->voir && !$socid) {
if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible }
if ($socid) {
$sql .= " AND s.rowid = ".$socid;
}
if (!$user->rights->fournisseur->lire) {
$sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
}
//print $sql; //print $sql;
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{ while ($objp = $db->fetch_object($result)) {
while ($objp = $db->fetch_object($result))
{
$found = 0; $found = 0;
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found = 1; $third['prospect']++; } if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) {
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found = 1; $third['customer']++; } $found = 1; $third['prospect']++;
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found = 1; $third['supplier']++; }
if (!empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found = 1; $third['other']++; }
if ($found) $total++;
} }
} else dol_print_error($db); if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) {
$found = 1; $third['customer']++;
}
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) {
$found = 1; $third['supplier']++;
}
if (!empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) {
$found = 1; $third['other']++;
}
if ($found) {
$total++;
}
}
} else {
dol_print_error($db);
}
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">'."\n"; print '<table class="noborder nohover centpercent">'."\n";
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>'; print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2)) if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2)) {
{
print '<tr><td class="center" colspan="2">'; print '<tr><td class="center" colspan="2">';
$dataseries = array(); $dataseries = array();
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[] = array($langs->trans("Prospects"), round($third['prospect'])); if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[] = array($langs->trans("Customers"), round($third['customer'])); $dataseries[] = array($langs->trans("Prospects"), round($third['prospect']));
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[] = array($langs->trans("Suppliers"), round($third['supplier'])); }
if (!empty($conf->societe->enabled)) $dataseries[] = array($langs->trans("Others"), round($third['other'])); if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) {
$dataseries[] = array($langs->trans("Customers"), round($third['customer']));
}
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) {
$dataseries[] = array($langs->trans("Suppliers"), round($third['supplier']));
}
if (!empty($conf->societe->enabled)) {
$dataseries[] = array($langs->trans("Others"), round($third['other']));
}
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph(); $dolgraph = new DolGraph();
$dolgraph->SetData($dataseries); $dolgraph->SetData($dataseries);
@ -117,20 +144,17 @@ if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) +
print $dolgraph->show(); print $dolgraph->show();
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} else { } else {
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
{
$statstring = "<tr>"; $statstring = "<tr>";
$statstring .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=p">'.$langs->trans("Prospects").'</a></td><td class="right">'.round($third['prospect']).'</td>'; $statstring .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=p">'.$langs->trans("Prospects").'</a></td><td class="right">'.round($third['prospect']).'</td>';
$statstring .= "</tr>"; $statstring .= "</tr>";
} }
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) {
{
$statstring .= "<tr>"; $statstring .= "<tr>";
$statstring .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=c">'.$langs->trans("Customers").'</a></td><td class="right">'.round($third['customer']).'</td>'; $statstring .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=c">'.$langs->trans("Customers").'</a></td><td class="right">'.round($third['customer']).'</td>';
$statstring .= "</tr>"; $statstring .= "</tr>";
} }
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire) if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire) {
{
$statstring2 = "<tr>"; $statstring2 = "<tr>";
$statstring2 .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("Suppliers").'</a></td><td class="right">'.round($third['supplier']).'</td>'; $statstring2 .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("Suppliers").'</a></td><td class="right">'.round($third['supplier']).'</td>';
$statstring2 .= "</tr>"; $statstring2 .= "</tr>";
@ -144,8 +168,7 @@ print '</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) {
{
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$elementtype = 'societe'; $elementtype = 'societe';
@ -159,26 +182,24 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
$sql .= " WHERE c.type = 2"; $sql .= " WHERE c.type = 2";
if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql .= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) {
$sql .= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
}
$sql .= " AND c.entity IN (".getEntity('category').")"; $sql .= " AND c.entity IN (".getEntity('category').")";
$sql .= " GROUP BY c.label"; $sql .= " GROUP BY c.label";
$total = 0; $total = 0;
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax)) {
{
$dataseries = array(); $dataseries = array();
$rest = 0; $rest = 0;
$nbmax = 10; $nbmax = 10;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
if ($i < $nbmax) if ($i < $nbmax) {
{
$dataseries[] = array($obj->label, round($obj->nb)); $dataseries[] = array($obj->label, round($obj->nb));
} else { } else {
$rest += $obj->nb; $rest += $obj->nb;
@ -186,8 +207,7 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA
$total += $obj->nb; $total += $obj->nb;
$i++; $i++;
} }
if ($i > $nbmax) if ($i > $nbmax) {
{
$dataseries[] = array($langs->trans("Other"), round($rest)); $dataseries[] = array($langs->trans("Other"), round($rest));
} }
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@ -200,8 +220,7 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA
$dolgraph->draw('idgraphcateg'); $dolgraph->draw('idgraphcateg');
print $dolgraph->show(); print $dolgraph->show();
} else { } else {
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>'; print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
@ -234,24 +253,30 @@ $sql .= ", s.logo";
$sql .= ", s.entity"; $sql .= ", s.entity";
$sql .= ", s.canvas, s.tms as date_modification, s.status as status"; $sql .= ", s.canvas, s.tms as date_modification, s.status as status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; $sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if (!$user->rights->societe->client->voir && !$socid) {
if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur != 1 OR s.client != 0)"; }
if ($socid) {
$sql .= " AND s.rowid = ".$socid;
}
if (!$user->rights->fournisseur->lire) {
$sql .= " AND (s.fournisseur != 1 OR s.client != 0)";
}
$sql .= $db->order("s.tms", "DESC"); $sql .= $db->order("s.tms", "DESC");
$sql .= $db->plimit($max, 0); $sql .= $db->plimit($max, 0);
//print $sql; //print $sql;
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
if ($num > 0) if ($num > 0) {
{
$transRecordedType = $langs->trans("LastModifiedThirdParties", $max); $transRecordedType = $langs->trans("LastModifiedThirdParties", $max);
print "\n<!-- last thirdparties modified -->\n"; print "\n<!-- last thirdparties modified -->\n";
@ -263,8 +288,7 @@ if ($result)
print '<th class="right"><a href="'.DOL_URL_ROOT.'/societe/list.php?sortfield=s.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>'; print '<th class="right"><a href="'.DOL_URL_ROOT.'/societe/list.php?sortfield=s.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
print '</tr>'."\n"; print '</tr>'."\n";
while ($i < $num) while ($i < $num) {
{
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$thirdparty_static->id = $objp->rowid; $thirdparty_static->id = $objp->rowid;

File diff suppressed because it is too large Load Diff

View File

@ -35,11 +35,15 @@ $langs->load("companies");
// Security check // Security check
$id = GETPOST('id') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); $id = GETPOST('id') ?GETPOST('id', 'int') : GETPOST('socid', 'int');
if ($user->socid) $id = $user->socid; if ($user->socid) {
$id = $user->socid;
}
$result = restrictedArea($user, 'societe', $id, '&societe'); $result = restrictedArea($user, 'societe', $id, '&societe');
$object = new Societe($db); $object = new Societe($db);
if ($id > 0) $object->fetch($id); if ($id > 0) {
$object->fetch($id);
}
$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php $permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php
@ -61,16 +65,19 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include,
$form = new Form($db); $form = new Form($db);
$title = $langs->trans("ThirdParty").' - '.$langs->trans("Notes"); $title = $langs->trans("ThirdParty").' - '.$langs->trans("Notes");
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Notes"); if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name.' - '.$langs->trans("Notes");
}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);
if ($object->id > 0) if ($object->id > 0) {
{
/* /*
* Affichage onglets * Affichage onglets
*/ */
if (!empty($conf->notification->enabled)) $langs->load("mails"); if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = societe_prepare_head($object); $head = societe_prepare_head($object);
@ -89,8 +96,7 @@ if ($object->id > 0)
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
{
print '<tr><td class="'.$cssclass.'">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; print '<tr><td class="'.$cssclass.'">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
} }

View File

@ -39,16 +39,24 @@ $actionid = GETPOST('actionid');
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
// Security check // Security check
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'societe', '', ''); $result = restrictedArea($user, 'societe', '', '');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (!$sortorder) $sortorder = "DESC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "n.daten"; $sortorder = "DESC";
if (empty($page) || $page == -1) { $page = 0; } }
if (!$sortfield) {
$sortfield = "n.daten";
}
if (empty($page) || $page == -1) {
$page = 0;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -68,39 +76,34 @@ $hookmanager->initHooks(array('thirdpartynotification', 'globalcard'));
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
$error = 0; $error = 0;
// Add a notification // Add a notification
if ($action == 'add') if ($action == 'add') {
{ if (empty($contactid)) {
if (empty($contactid))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Contact")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Contact")), null, 'errors');
$error++; $error++;
} }
if ($actionid <= 0) if ($actionid <= 0) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error) {
{
$db->begin(); $db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
$sql .= " WHERE fk_soc=".$socid." AND fk_contact=".$contactid." AND fk_action=".$actionid; $sql .= " WHERE fk_soc=".$socid." AND fk_contact=".$contactid." AND fk_action=".$actionid;
if ($db->query($sql)) if ($db->query($sql)) {
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)";
$sql .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")"; $sql .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")";
if (!$db->query($sql)) if (!$db->query($sql)) {
{
$error++; $error++;
dol_print_error($db); dol_print_error($db);
} }
@ -108,8 +111,7 @@ if (empty($reshook))
dol_print_error($db); dol_print_error($db);
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
@ -118,8 +120,7 @@ if (empty($reshook))
} }
// Remove a notification // Remove a notification
if ($action == 'delete') if ($action == 'delete') {
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST('actid', 'int'); $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST('actid', 'int');
$db->query($sql); $db->query($sql);
} }
@ -137,14 +138,15 @@ $object = new Societe($db);
$result = $object->fetch($socid); $result = $object->fetch($socid);
$title = $langs->trans("ThirdParty").' - '.$langs->trans("Notification"); $title = $langs->trans("ThirdParty").' - '.$langs->trans("Notification");
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Notification"); if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name.' - '.$langs->trans("Notification");
}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);
if ($result > 0) if ($result > 0) {
{
$langs->load("other"); $langs->load("other");
$head = societe_prepare_head($object); $head = societe_prepare_head($object);
@ -161,8 +163,7 @@ if ($result > 0)
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
// Prefix // Prefix
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
{
print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
} }
@ -232,8 +233,7 @@ if ($result > 0)
$sql .= " AND c.fk_soc = ".$object->id; $sql .= " AND c.fk_soc = ".$object->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
} else { } else {
dol_print_error($db); dol_print_error($db);
@ -261,16 +261,14 @@ if ($result > 0)
// Line to add a new subscription // Line to add a new subscription
$listofemails = $object->thirdparty_and_contact_email_array(); $listofemails = $object->thirdparty_and_contact_email_array();
if (count($listofemails) > 0) if (count($listofemails) > 0) {
{
$actions = array(); $actions = array();
// Load array of available notifications // Load array of available notifications
$notificationtrigger = new InterfaceNotification($db); $notificationtrigger = new InterfaceNotification($db);
$listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents(); $listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents();
foreach ($listofmanagedeventfornotification as $managedeventfornotification) foreach ($listofmanagedeventfornotification as $managedeventfornotification) {
{
$label = ($langs->trans("Notify_".$managedeventfornotification['code']) != "Notify_".$managedeventfornotification['code'] ? $langs->trans("Notify_".$managedeventfornotification['code']) : $managedeventfornotification['label']); $label = ($langs->trans("Notify_".$managedeventfornotification['code']) != "Notify_".$managedeventfornotification['code'] ? $langs->trans("Notify_".$managedeventfornotification['code']) : $managedeventfornotification['label']);
$actions[$managedeventfornotification['rowid']] = $label; $actions[$managedeventfornotification['rowid']] = $label;
} }
@ -294,14 +292,12 @@ if ($result > 0)
} }
if ($num) if ($num) {
{
$i = 0; $i = 0;
$contactstatic = new Contact($db); $contactstatic = new Contact($db);
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$contactstatic->id = $obj->contact_id; $contactstatic->id = $obj->contact_id;
@ -310,10 +306,8 @@ if ($result > 0)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$contactstatic->getNomUrl(1); print '<td>'.$contactstatic->getNomUrl(1);
if ($obj->type == 'email') if ($obj->type == 'email') {
{ if (isValidEmail($obj->email)) {
if (isValidEmail($obj->email))
{
print ' &lt;'.$obj->email.'&gt;'; print ' &lt;'.$obj->email.'&gt;';
} else { } else {
$langs->load("errors"); $langs->load("errors");
@ -326,8 +320,12 @@ if ($result > 0)
print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$label; print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$label;
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if ($obj->type == 'email') print $langs->trans("Email"); if ($obj->type == 'email') {
if ($obj->type == 'sms') print $langs->trans("SMS"); print $langs->trans("Email");
}
if ($obj->type == 'sms') {
print $langs->trans("SMS");
}
print '</td>'; print '</td>';
print '<td class="right"><a href="card.php?socid='.$socid.'&action=delete&token='.newToken().'&actid='.$obj->rowid.'">'.img_delete().'</a></td>'; print '<td class="right"><a href="card.php?socid='.$socid.'&action=delete&token='.newToken().'&actid='.$obj->rowid.'">'.img_delete().'</a></td>';
print '</tr>'; print '</tr>';
@ -406,12 +404,10 @@ if ($result > 0)
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -420,19 +416,24 @@ if ($result > 0)
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$param = '&socid='.$object->id; $param = '&socid='.$object->id;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; $param .= '&contextpage='.$contextpage;
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.$limit;
}
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
@ -454,19 +455,16 @@ if ($result > 0)
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "n.daten", '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "n.daten", '', $param, '', $sortfield, $sortorder, 'right ');
print '</tr>'; print '</tr>';
if ($num > 0) if ($num > 0) {
{
$i = 0; $i = 0;
$contactstatic = new Contact($db); $contactstatic = new Contact($db);
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
if ($obj->id > 0) if ($obj->id > 0) {
{
$contactstatic->id = $obj->id; $contactstatic->id = $obj->id;
$contactstatic->lastname = $obj->lastname; $contactstatic->lastname = $obj->lastname;
$contactstatic->firstname = $obj->firstname; $contactstatic->firstname = $obj->firstname;
@ -481,8 +479,12 @@ if ($result > 0)
print $label; print $label;
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if ($obj->type == 'email') print $langs->trans("Email"); if ($obj->type == 'email') {
if ($obj->type == 'sms') print $langs->trans("Sms"); print $langs->trans("Email");
}
if ($obj->type == 'sms') {
print $langs->trans("Sms");
}
print '</td>'; print '</td>';
// TODO Add link to object here for other types // TODO Add link to object here for other types
/*print '<td>'; /*print '<td>';
@ -507,7 +509,9 @@ if ($result > 0)
print '</div>'; print '</div>';
print '</form>'; print '</form>';
} else dol_print_error('', 'RecordNotFound'); } else {
dol_print_error('', 'RecordNotFound');
}
// End of page // End of page
llxFooter(); llxFooter();

File diff suppressed because it is too large Load Diff

View File

@ -49,8 +49,9 @@ $search_price_ttc = GETPOST('search_price_ttc');
// Security check // Security check
$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
if ($user->socid) if ($user->socid) {
$socid = $user->socid; $socid = $user->socid;
}
$result = restrictedArea($user, 'societe', $socid, '&societe'); $result = restrictedArea($user, 'societe', $socid, '&societe');
$object = new Societe($db); $object = new Societe($db);
@ -67,12 +68,12 @@ $error = 0;
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
{
$search_prod = $search_label = $search_price = $search_price_ttc = ''; $search_prod = $search_label = $search_price = $search_price_ttc = '';
} }
@ -102,8 +103,7 @@ if (empty($reshook))
$npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
$localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0';
// If value contains the unique code of vat line (new recommended method), we use it to find npr and local taxes // If value contains the unique code of vat line (new recommended method), we use it to find npr and local taxes
if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) {
{
// We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price. // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price.
$vatratecode = $reg[1]; $vatratecode = $reg[1];
// Get record from code // Get record from code
@ -113,8 +113,7 @@ if (empty($reshook))
$sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1";
$sql .= " AND t.code ='".$db->escape($vatratecode)."'"; $sql .= " AND t.code ='".$db->escape($vatratecode)."'";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$npr = $obj->recuperableonly; $npr = $obj->recuperableonly;
$localtax1 = $obj->localtax1; $localtax1 = $obj->localtax1;
@ -193,8 +192,9 @@ $object = new Societe($db);
$result = $object->fetch($socid); $result = $object->fetch($socid);
llxHeader("", $langs->trans("ThirdParty").'-'.$langs->trans('PriceByCustomer')); llxHeader("", $langs->trans("ThirdParty").'-'.$langs->trans('PriceByCustomer'));
if (!empty($conf->notification->enabled)) if (!empty($conf->notification->enabled)) {
$langs->load("mails"); $langs->load("mails");
}
$head = societe_prepare_head($object); $head = societe_prepare_head($object);
print dol_get_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company'); print dol_get_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company');
@ -208,8 +208,7 @@ print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
{
print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
} }
@ -250,14 +249,18 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) if (!$sortorder) {
$sortorder = "ASC"; $sortorder = "ASC";
if (!$sortfield) }
if (!$sortfield) {
$sortfield = "soc.nom"; $sortfield = "soc.nom";
}
// Build filter to display only concerned lines // Build filter to display only concerned lines
$filter = array( $filter = array(
@ -365,8 +368,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print load_fiche_titre($langs->trans('PriceByCustomer')); print load_fiche_titre($langs->trans('PriceByCustomer'));
$result = $prodcustprice->fetch(GETPOST('lineid', 'int')); $result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
if ($result < 0) if ($result < 0) {
{
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
} }
@ -457,8 +459,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
} }
$result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); $result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) if ($result < 0) {
{
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
} }
@ -537,14 +538,12 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter); $nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
} }
$result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); $result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) if ($result < 0) {
{
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
} }
@ -575,8 +574,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
if (count($prodcustprice->lines) > 0 || $search_prod) if (count($prodcustprice->lines) > 0 || $search_prod) {
{
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="'.$search_prod.'" size="20"></td>'; print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="'.$search_prod.'" size="20"></td>';
print '<td class="liste_titre" ><input type="text" class="flat" name="search_label" value="'.$search_label.'" size="20"></td>'; print '<td class="liste_titre" ><input type="text" class="flat" name="search_label" value="'.$search_label.'" size="20"></td>';
@ -592,10 +590,8 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '</tr>'; print '</tr>';
} }
if (count($prodcustprice->lines) > 0) if (count($prodcustprice->lines) > 0) {
{ foreach ($prodcustprice->lines as $line) {
foreach ($prodcustprice->lines as $line)
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
$staticprod = new Product($db); $staticprod = new Product($db);
@ -621,8 +617,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '</td>'; print '</td>';
// Action // Action
if ($user->rights->produit->creer || $user->rights->service->creer) if ($user->rights->produit->creer || $user->rights->service->creer) {
{
print '<td class="right nowraponall">'; print '<td class="right nowraponall">';
print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=showlog_customer_price&amp;socid='.$object->id.'&amp;prodid='.$line->fk_product.'">'; print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=showlog_customer_price&amp;socid='.$object->id.'&amp;prodid='.$line->fk_product.'">';
print img_info(); print img_info();
@ -642,7 +637,9 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
} }
} else { } else {
$colspan = 10; $colspan = 10;
if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan += 1; if ($user->rights->produit->supprimer || $user->rights->service->supprimer) {
$colspan += 1;
}
print '<tr class="oddeven"><td colspan="'.$colspan.'">'.$langs->trans('None').'</td></tr>'; print '<tr class="oddeven"><td colspan="'.$colspan.'">'.$langs->trans('None').'</td></tr>';
} }

View File

@ -35,7 +35,9 @@ $langs->loadLangs(array("companies", "projects"));
// Security check // Security check
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'societe', $socid, '&societe'); $result = restrictedArea($user, 'societe', $socid, '&societe');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@ -48,7 +50,9 @@ $hookmanager->initHooks(array('projectthirdparty'));
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
@ -60,8 +64,7 @@ $contactstatic = new Contact($db);
$form = new Form($db); $form = new Form($db);
if ($socid) if ($socid) {
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@ -72,10 +75,14 @@ if ($socid)
$result = $object->fetch($socid); $result = $object->fetch($socid);
$title = $langs->trans("Projects"); $title = $langs->trans("Projects");
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name." - ".$title;
}
llxHeader('', $title); llxHeader('', $title);
if (!empty($conf->notification->enabled)) $langs->load("mails"); if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = societe_prepare_head($object); $head = societe_prepare_head($object);
print dol_get_fiche_head($head, 'project', $langs->trans("ThirdParty"), -1, 'company'); print dol_get_fiche_head($head, 'project', $langs->trans("ThirdParty"), -1, 'company');
@ -89,13 +96,11 @@ if ($socid)
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
{
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
} }
if ($object->client) if ($object->client) {
{
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">'; print $langs->trans('CustomerCode').'</td><td colspan="3">';
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
@ -106,8 +111,7 @@ if ($socid)
print '</td></tr>'; print '</td></tr>';
} }
if ($object->fournisseur) if ($object->fournisseur) {
{
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">'; print $langs->trans('SupplierCode').'</td><td colspan="3">';
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));

View File

@ -43,15 +43,23 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "s.nom"; $sortorder = "ASC";
if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } }
if (!$sortfield) {
$sortfield = "s.nom";
}
if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) {
$page = 0;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
// Security check // Security check
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'societe', $id, ''); $result = restrictedArea($user, 'societe', $id, '');
$object = new Societe($db); $object = new Societe($db);
@ -64,51 +72,39 @@ $hookmanager->initHooks(array('contactthirdparty', 'globalcard'));
* Actions * Actions
*/ */
if ($action == 'addcontact' && $user->rights->societe->creer) if ($action == 'addcontact' && $user->rights->societe->creer) {
{
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0) {
{
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0) {
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} else { } else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
{
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
} else { } else {
$mesg = '<div class="error">'.$object->error.'</div>'; $mesg = '<div class="error">'.$object->error.'</div>';
} }
} }
} } elseif ($action == 'swapstatut' && $user->rights->societe->creer) {
// bascule du statut d'un contact
// bascule du statut d'un contact if ($object->fetch($id)) {
elseif ($action == 'swapstatut' && $user->rights->societe->creer)
{
if ($object->fetch($id))
{
$result = $object->swapContactStatus(GETPOST('ligne')); $result = $object->swapContactStatus(GETPOST('ligne'));
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} } elseif ($action == 'deletecontact' && $user->rights->societe->creer) {
// Efface un contact
// Efface un contact
elseif ($action == 'deletecontact' && $user->rights->societe->creer)
{
$object->fetch($id); $object->fetch($id);
$result = $object->delete_contact($_GET["lineid"]); $result = $object->delete_contact($_GET["lineid"]);
if ($result >= 0) if ($result >= 0) {
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} else { } else {
@ -145,10 +141,8 @@ $userstatic = new User($db);
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
if ($id > 0 || !empty($ref)) if ($id > 0 || !empty($ref)) {
{ if ($object->fetch($id, $ref) > 0) {
if ($object->fetch($id, $ref) > 0)
{
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($object->socid); $soc->fetch($object->socid);
@ -177,13 +171,11 @@ if ($id > 0 || !empty($ref))
print yn($object->fournisseur); print yn($object->fournisseur);
print '</td></tr>';*/ print '</td></tr>';*/
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
{
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
} }
if ($object->client) if ($object->client) {
{
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">'; print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client; print $object->code_client;
@ -194,8 +186,7 @@ if ($id > 0 || !empty($ref))
print '</td></tr>'; print '</td></tr>';
} }
if ($object->fournisseur) if ($object->fournisseur) {
{
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">'; print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur; print $object->code_fournisseur;
@ -214,15 +205,15 @@ if ($id > 0 || !empty($ref))
// Contacts lines (modules that overwrite templates must declare this into descriptor) // Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
foreach ($dirtpls as $reldir) foreach ($dirtpls as $reldir) {
{
$res = @include dol_buildpath($reldir.'/contacts.tpl.php'); $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
if ($res) break; if ($res) {
break;
}
} }
// additionnal list with adherents of company // additionnal list with adherents of company
if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) {
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
@ -241,12 +232,10 @@ if ($id > 0 || !empty($ref))
dol_syslog("get list sql=".$sql); dol_syslog("get list sql=".$sql);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num > 0) if ($num > 0) {
{
$param = ''; $param = '';
$titre = $langs->trans("MembersListOfTiers"); $titre = $langs->trans("MembersListOfTiers");
@ -267,8 +256,7 @@ if ($id > 0 || !empty($ref))
print "</tr>\n"; print "</tr>\n";
$i = 0; $i = 0;
while ($i < $num && $i < $conf->liste_limit) while ($i < $num && $i < $conf->liste_limit) {
{
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$datefin = $db->jdate($objp->datefin); $datefin = $db->jdate($objp->datefin);
@ -319,8 +307,7 @@ if ($id > 0 || !empty($ref))
print "</td>"; print "</td>";
// End of subscription date // End of subscription date
if ($datefin) if ($datefin) {
{
print '<td class="center nowrap">'; print '<td class="center nowrap">';
print dol_print_date($datefin, 'day'); print dol_print_date($datefin, 'day');
if ($memberstatic->hasDelay()) { if ($memberstatic->hasDelay()) {
@ -329,10 +316,11 @@ if ($id > 0 || !empty($ref))
print '</td>'; print '</td>';
} else { } else {
print '<td class="left nowrap">'; print '<td class="left nowrap">';
if ($objp->subscription == 'yes') if ($objp->subscription == 'yes') {
{
print $langs->trans("SubscriptionNotReceived"); print $langs->trans("SubscriptionNotReceived");
if ($objp->statut > 0) print " ".img_warning(); if ($objp->statut > 0) {
print " ".img_warning();
}
} else { } else {
print '&nbsp;'; print '&nbsp;';
} }

View File

@ -67,6 +67,8 @@ if ($action == 'editsalesrepresentatives') {
print $userstatic->getNomUrl(-1); print $userstatic->getNomUrl(-1);
print ' '; print ' ';
} }
} else print '<span class="opacitymedium">'.$langs->trans("NoSalesRepresentativeAffected").'</span>'; } else {
print '<span class="opacitymedium">'.$langs->trans("NoSalesRepresentativeAffected").'</span>';
}
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -47,19 +47,27 @@ $search_status = GETPOST('search_status');
// Security check // Security check
$id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); $id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'societe', $socid, '&societe'); $result = restrictedArea($user, 'societe', $socid, '&societe');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) $sortfield = 't.login'; if (!$sortfield) {
if (!$sortorder) $sortorder = 'ASC'; $sortfield = 't.login';
}
if (!$sortorder) {
$sortorder = 'ASC';
}
// Initialize technical objects // Initialize technical objects
$object = new Societe($db); $object = new Societe($db);
@ -78,24 +86,27 @@ unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are alr
// Initialize array of search criterias // Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha'); $search_all = GETPOST("search_all", 'alpha');
$search = array(); $search = array();
foreach ($objectwebsiteaccount->fields as $key => $val) foreach ($objectwebsiteaccount->fields as $key => $val) {
{ if (GETPOST('search_'.$key, 'alpha')) {
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); $search[$key] = GETPOST('search_'.$key, 'alpha');
}
} }
// List of fields to search into when doing a "search in all" // List of fields to search into when doing a "search in all"
$fieldstosearchall = array(); $fieldstosearchall = array();
foreach ($objectwebsiteaccount->fields as $key => $val) foreach ($objectwebsiteaccount->fields as $key => $val) {
{ if ($val['searchall']) {
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; $fieldstosearchall['t.'.$key] = $val['label'];
}
} }
// Definition of fields for list // Definition of fields for list
$arrayfields = array(); $arrayfields = array();
foreach ($objectwebsiteaccount->fields as $key => $val) foreach ($objectwebsiteaccount->fields as $key => $val) {
{
// If $val['visible']==0, then we never show the field // If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled']); if (!empty($val['visible'])) {
$arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled']);
}
} }
// Extra fields // Extra fields
@ -105,8 +116,7 @@ $object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position');
if ($id > 0) if ($id > 0) {
{
$result = $object->fetch($id); $result = $object->fetch($id);
} }
@ -117,13 +127,13 @@ if ($id > 0)
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Cancel // Cancel
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
{
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} }
@ -132,18 +142,15 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
{ foreach ($objectwebsiteaccount->fields as $key => $val) {
foreach ($objectwebsiteaccount->fields as $key => $val)
{
$search[$key] = ''; $search[$key] = '';
} }
$toselect = ''; $toselect = '';
$search_array_options = array(); $search_array_options = array();
} }
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
{
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
} }
@ -172,14 +179,21 @@ $title = $langs->trans("WebsiteAccounts");
llxHeader('', $title); llxHeader('', $title);
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($id > 0) $param .= '&id='.urlencode($id); $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); }
foreach ($search as $key => $val) if ($id > 0) {
{ $param .= '&id='.urlencode($id);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
foreach ($search as $key => $val) {
$param .= '&search_'.$key.'='.urlencode($search[$key]); $param .= '&search_'.$key.'='.urlencode($search[$key]);
} }
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
// Add $param from extra fields // Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -198,8 +212,7 @@ print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Prefix // Prefix
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
{
print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
} }
@ -247,29 +260,39 @@ print '<br>';
// Build and execute select // Build and execute select
// -------------------------------------------------------------------- // --------------------------------------------------------------------
$sql = 'SELECT '; $sql = 'SELECT ';
foreach ($objectwebsiteaccount->fields as $key => $val) foreach ($objectwebsiteaccount->fields as $key => $val) {
{
$sql .= 't.'.$key.', '; $sql .= 't.'.$key.', ';
} }
// Add fields from extrafields // Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
}
}
// Add fields from hooks // Add fields from hooks
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
$sql = preg_replace('/, $/', '', $sql); $sql = preg_replace('/, $/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX."societe_account as t"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as t";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
if ($objectwebsiteaccount->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity('societeaccount').")"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
else $sql .= " WHERE 1 = 1"; }
$sql .= " AND fk_soc = ".$object->id; if ($objectwebsiteaccount->ismultientitymanaged == 1) {
foreach ($search as $key => $val) $sql .= " WHERE t.entity IN (".getEntity('societeaccount').")";
{ } else {
$mode_search = (($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key])) ? 1 : 0); $sql .= " WHERE 1 = 1";
if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); }
$sql .= " AND fk_soc = ".$object->id;
foreach ($search as $key => $val) {
$mode_search = (($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key])) ? 1 : 0);
if ($search[$key] != '') {
$sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
}
}
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
} }
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
// Add where from extra fields // Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks // Add where from hooks
@ -296,12 +319,10 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -310,8 +331,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) if (!$resql) {
{
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
@ -325,12 +345,18 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->mymodule->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); if ($user->rights->mymodule->delete) {
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
}
if (in_array($massaction, array('presend', 'predelete'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions); $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
@ -361,11 +387,13 @@ $moreforfilter.= '</div>';*/
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; if (empty($reshook)) {
else $moreforfilter = $hookmanager->resPrint; $moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
if (!empty($moreforfilter)) if (!empty($moreforfilter)) {
{
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter; print $moreforfilter;
print '</div>'; print '</div>';
@ -382,13 +410,20 @@ print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" :
// Fields title search // Fields title search
// -------------------------------------------------------------------- // --------------------------------------------------------------------
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($objectwebsiteaccount->fields as $key => $val) foreach ($objectwebsiteaccount->fields as $key => $val) {
{
$align = ''; $align = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
if (in_array($val['type'], array('timestamp'))) $align .= ' nowrap'; $align = 'center';
if ($key == 'status') $align .= ($align ? ' ' : '').'center'; }
if (!empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; if (in_array($val['type'], array('timestamp'))) {
$align .= ' nowrap';
}
if ($key == 'status') {
$align .= ($align ? ' ' : '').'center';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
}
} }
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@ -407,13 +442,20 @@ print '</tr>'."\n";
// Fields title label // Fields title label
// -------------------------------------------------------------------- // --------------------------------------------------------------------
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($objectwebsiteaccount->fields as $key => $val) foreach ($objectwebsiteaccount->fields as $key => $val) {
{
$align = ''; $align = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
if (in_array($val['type'], array('timestamp'))) $align .= 'nowrap'; $align = 'center';
if ($key == 'status') $align .= ($align ? ' ' : '').'center'; }
if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; if (in_array($val['type'], array('timestamp'))) {
$align .= 'nowrap';
}
if ($key == 'status') {
$align .= ($align ? ' ' : '').'center';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n";
}
} }
// Extra fields // Extra fields
// Extra fields // Extra fields
@ -428,11 +470,11 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line // Detect if we need a fetch on each output line
$needToFetchEachLine = 0; $needToFetchEachLine = 0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
{ foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) if (preg_match('/\$object/', $val)) {
{ $needToFetchEachLine++; // There is at least one compute field that use $object
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object }
} }
} }
@ -440,40 +482,54 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
// -------------------------------------------------------------------- // --------------------------------------------------------------------
$i = 0; $i = 0;
$totalarray = array(); $totalarray = array();
while ($i < min($num, $limit)) while ($i < min($num, $limit)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen if (empty($obj)) {
break; // Should not happen
}
// Store properties in $object // Store properties in $object
$objectwebsiteaccount->id = $obj->rowid; $objectwebsiteaccount->id = $obj->rowid;
$objectwebsiteaccount->login = $obj->login; $objectwebsiteaccount->login = $obj->login;
$objectwebsiteaccount->ref = $obj->login; $objectwebsiteaccount->ref = $obj->login;
foreach ($objectwebsiteaccount->fields as $key => $val) foreach ($objectwebsiteaccount->fields as $key => $val) {
{ if (property_exists($obj, $key)) {
if (property_exists($obj, $key)) $object->$key = $obj->$key; $object->$key = $obj->$key;
}
} }
// Show here line of result // Show here line of result
print '<tr class="oddeven">'; print '<tr class="oddeven">';
foreach ($objectwebsiteaccount->fields as $key => $val) foreach ($objectwebsiteaccount->fields as $key => $val) {
{
$align = ''; $align = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
if (in_array($val['type'], array('timestamp'))) $align .= 'nowrap'; $align = 'center';
if ($key == 'status') $align .= ($align ? ' ' : '').'center'; }
if (!empty($arrayfields['t.'.$key]['checked'])) if (in_array($val['type'], array('timestamp'))) {
{ $align .= 'nowrap';
}
if ($key == 'status') {
$align .= ($align ? ' ' : '').'center';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'; print '<td';
if ($align) print ' class="'.$align.'"'; if ($align) {
print ' class="'.$align.'"';
}
print '>'; print '>';
if ($key == 'login') print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1); if ($key == 'login') {
else print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, ''); print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1);
} else {
print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, '');
}
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
if (!empty($val['isameasure'])) $totalarray['nbfield']++;
{ }
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; if (!empty($val['isameasure'])) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
$totalarray['val']['t.'.$key] += $obj->$key; $totalarray['val']['t.'.$key] += $obj->$key;
} }
} }
@ -486,14 +542,17 @@ while ($i < min($num, $limit))
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Action column // Action column
print '<td class="nowrap center">'; print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0; $selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1; if (in_array($obj->rowid, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'; print '</tr>';
@ -505,10 +564,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found // If no record found
if ($num == 0) if ($num == 0) {
{
$colspan = 1; $colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
} }
@ -524,10 +586,11 @@ print '</div>'."\n";
print '</form>'."\n"; print '</form>'."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
{
$hidegeneratedfilelistifempty = 1; $hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
$hidegeneratedfilelistifempty = 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db); $formfile = new FormFile($db);

View File

@ -37,7 +37,9 @@ $servicename = 'Stripe';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'paypal', 'paybox', 'stripe')); $langs->loadLangs(array('admin', 'other', 'paypal', 'paybox', 'stripe'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -46,64 +48,79 @@ $action = GETPOST('action', 'aZ09');
* Actions * Actions
*/ */
if ($action == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin) {
{
$db->begin(); $db->begin();
if (empty($conf->stripeconnect->enabled)) { if (empty($conf->stripeconnect->enabled)) {
$result = dolibarr_set_const($db, "STRIPE_TEST_PUBLISHABLE_KEY", GETPOST('STRIPE_TEST_PUBLISHABLE_KEY', 'alpha'), 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, "STRIPE_TEST_PUBLISHABLE_KEY", GETPOST('STRIPE_TEST_PUBLISHABLE_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) if (!$result > 0) {
$error++;
$result = dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY", GETPOST('STRIPE_TEST_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0)
$error++;
$result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_ID", GETPOST('STRIPE_TEST_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0)
$error++;
$result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_KEY", GETPOST('STRIPE_TEST_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0)
$error++;
$result = dolibarr_set_const($db, "STRIPE_LIVE_PUBLISHABLE_KEY", GETPOST('STRIPE_LIVE_PUBLISHABLE_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0)
$error++;
$result = dolibarr_set_const($db, "STRIPE_LIVE_SECRET_KEY", GETPOST('STRIPE_LIVE_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0)
$error++;
$result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_ID", GETPOST('STRIPE_LIVE_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0)
$error++;
$result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_KEY", GETPOST('STRIPE_LIVE_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0)
$error++; $error++;
} }
$result = dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY", GETPOST('STRIPE_TEST_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) {
$error++;
}
$result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_ID", GETPOST('STRIPE_TEST_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) {
$error++;
}
$result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_KEY", GETPOST('STRIPE_TEST_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) {
$error++;
}
$result = dolibarr_set_const($db, "STRIPE_LIVE_PUBLISHABLE_KEY", GETPOST('STRIPE_LIVE_PUBLISHABLE_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) {
$error++;
}
$result = dolibarr_set_const($db, "STRIPE_LIVE_SECRET_KEY", GETPOST('STRIPE_LIVE_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) {
$error++;
}
$result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_ID", GETPOST('STRIPE_LIVE_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) {
$error++;
}
$result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_KEY", GETPOST('STRIPE_LIVE_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) {
$error++;
}
}
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR", GETPOST('ONLINE_PAYMENT_CREDITOR', 'alpha'), 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR", GETPOST('ONLINE_PAYMENT_CREDITOR', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) if (!$result > 0) {
$error++; $error++;
}
$result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_PAYMENTS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 'int'), 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_PAYMENTS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 'int'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) if (!$result > 0) {
$error++; $error++;
}
$result = dolibarr_set_const($db, "STRIPE_USER_ACCOUNT_FOR_ACTIONS", GETPOST('STRIPE_USER_ACCOUNT_FOR_ACTIONS', 'int'), 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, "STRIPE_USER_ACCOUNT_FOR_ACTIONS", GETPOST('STRIPE_USER_ACCOUNT_FOR_ACTIONS', 'int'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) { if (!$result > 0) {
$error++; $error++;
} }
$result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 'int'), 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 'int'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) if (!$result > 0) {
$error++; $error++;
}
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) if (!$result > 0) {
$error++; $error++;
}
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM", GETPOST('ONLINE_PAYMENT_MESSAGE_FORM', 'alpha'), 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM", GETPOST('ONLINE_PAYMENT_MESSAGE_FORM', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) if (!$result > 0) {
$error++; $error++;
}
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_OK", GETPOST('ONLINE_PAYMENT_MESSAGE_OK', 'alpha'), 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_OK", GETPOST('ONLINE_PAYMENT_MESSAGE_OK', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) if (!$result > 0) {
$error++; $error++;
}
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_KO", GETPOST('ONLINE_PAYMENT_MESSAGE_KO', 'alpha'), 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_KO", GETPOST('ONLINE_PAYMENT_MESSAGE_KO', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) if (!$result > 0) {
$error++; $error++;
}
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL", GETPOST('ONLINE_PAYMENT_SENDEMAIL'), 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL", GETPOST('ONLINE_PAYMENT_SENDEMAIL'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) if (!$result > 0) {
$error++; $error++;
}
// Stock decrement // Stock decrement
//$result = dolibarr_set_const($db, "ONLINE_PAYMENT_WAREHOUSE", (GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') > 0 ? GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') : ''), 'chaine', 0, '', $conf->entity); //$result = dolibarr_set_const($db, "ONLINE_PAYMENT_WAREHOUSE", (GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') > 0 ? GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
//if (! $result > 0) //if (! $result > 0)
@ -130,8 +147,7 @@ if ($action == 'setvalue' && $user->admin)
} }
} }
if ($action == "setlive") if ($action == "setlive") {
{
$liveenable = GETPOST('value', 'int'); $liveenable = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "STRIPE_LIVE", $liveenable, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "STRIPE_LIVE", $liveenable, 'yesno', 0, '', $conf->entity);
if ($res > 0) { if ($res > 0) {
@ -188,8 +204,7 @@ if ($conf->use_javascript_ajax) {
} }
print '</td><td></td></tr>'; print '</td><td></td></tr>';
if (empty($conf->stripeconnect->enabled)) if (empty($conf->stripeconnect->enabled)) {
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print '<span class="fieldrequired">'.$langs->trans("STRIPE_TEST_PUBLISHABLE_KEY").'</span></td><td>'; print '<span class="fieldrequired">'.$langs->trans("STRIPE_TEST_PUBLISHABLE_KEY").'</span></td><td>';
print '<input class="minwidth300" type="text" name="STRIPE_TEST_PUBLISHABLE_KEY" value="'.$conf->global->STRIPE_TEST_PUBLISHABLE_KEY.'">'; print '<input class="minwidth300" type="text" name="STRIPE_TEST_PUBLISHABLE_KEY" value="'.$conf->global->STRIPE_TEST_PUBLISHABLE_KEY.'">';
@ -216,10 +231,8 @@ if (empty($conf->stripeconnect->enabled))
$out .= ajax_autoselect("onlinetestwebhookurl", 0); $out .= ajax_autoselect("onlinetestwebhookurl", 0);
print '<br>'.$out; print '<br>'.$out;
print '</td><td>'; print '</td><td>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
{ if (!empty($conf->global->STRIPE_TEST_WEBHOOK_KEY) && !empty($conf->global->STRIPE_TEST_SECRET_KEY) && !empty($conf->global->STRIPE_TEST_WEBHOOK_ID)) {
if (!empty($conf->global->STRIPE_TEST_WEBHOOK_KEY) && !empty($conf->global->STRIPE_TEST_SECRET_KEY) && !empty($conf->global->STRIPE_TEST_WEBHOOK_ID))
{
\Stripe\Stripe::setApiKey($conf->global->STRIPE_TEST_SECRET_KEY); \Stripe\Stripe::setApiKey($conf->global->STRIPE_TEST_SECRET_KEY);
$endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID); $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID);
$endpoint->enabled_events = $stripearrayofwebhookevents; $endpoint->enabled_events = $stripearrayofwebhookevents;
@ -232,8 +245,7 @@ if (empty($conf->stripeconnect->enabled))
} }
$endpoint->url = dol_buildpath('/public/stripe/ipn.php?test', 3); $endpoint->url = dol_buildpath('/public/stripe/ipn.php?test', 3);
$endpoint->save(); $endpoint->save();
if ($endpoint->status == 'enabled') if ($endpoint->status == 'enabled') {
{
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">'; print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
@ -257,8 +269,7 @@ if (empty($conf->stripeconnect->enabled))
print '</td><td></td></tr>'; print '</td><td></td></tr>';
} }
if (empty($conf->stripeconnect->enabled)) if (empty($conf->stripeconnect->enabled)) {
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print '<span class="fieldrequired">'.$langs->trans("STRIPE_LIVE_PUBLISHABLE_KEY").'</span></td><td>'; print '<span class="fieldrequired">'.$langs->trans("STRIPE_LIVE_PUBLISHABLE_KEY").'</span></td><td>';
print '<input class="minwidth300" type="text" name="STRIPE_LIVE_PUBLISHABLE_KEY" value="'.$conf->global->STRIPE_LIVE_PUBLISHABLE_KEY.'">'; print '<input class="minwidth300" type="text" name="STRIPE_LIVE_PUBLISHABLE_KEY" value="'.$conf->global->STRIPE_LIVE_PUBLISHABLE_KEY.'">';
@ -285,10 +296,8 @@ if (empty($conf->stripeconnect->enabled))
$out .= ajax_autoselect("onlinelivewebhookurl", 0); $out .= ajax_autoselect("onlinelivewebhookurl", 0);
print '<br>'.$out; print '<br>'.$out;
print '</td><td>'; print '</td><td>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
{ if (!empty($conf->global->STRIPE_LIVE_WEBHOOK_KEY) && !empty($conf->global->STRIPE_LIVE_SECRET_KEY) && !empty($conf->global->STRIPE_LIVE_WEBHOOK_ID)) {
if (!empty($conf->global->STRIPE_LIVE_WEBHOOK_KEY) && !empty($conf->global->STRIPE_LIVE_SECRET_KEY) && !empty($conf->global->STRIPE_LIVE_WEBHOOK_ID))
{
\Stripe\Stripe::setApiKey($conf->global->STRIPE_LIVE_SECRET_KEY); \Stripe\Stripe::setApiKey($conf->global->STRIPE_LIVE_SECRET_KEY);
$endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_LIVE_WEBHOOK_ID); $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_LIVE_WEBHOOK_ID);
$endpoint->enabled_events = $stripearrayofwebhookevents; $endpoint->enabled_events = $stripearrayofwebhookevents;
@ -301,8 +310,7 @@ if (empty($conf->stripeconnect->enabled))
} }
$endpoint->url = dol_buildpath('/public/stripe/ipn.php', 3); $endpoint->url = dol_buildpath('/public/stripe/ipn.php', 3);
$endpoint->save(); $endpoint->save();
if ($endpoint->status == 'enabled') if ($endpoint->status == 'enabled') {
{
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">'; print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
@ -351,8 +359,7 @@ print img_picto('', 'bank_account').' ';
$form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS, 'STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); $form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS, 'STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1);
print '</td></tr>'; print '</td></tr>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is this for ? if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // What is this for ?
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("BankAccountForBankTransfer").'</td><td>'; print $langs->trans("BankAccountForBankTransfer").'</td><td>';
$form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS, 'STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 0, '', 1); $form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS, 'STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 0, '', 1);
@ -360,8 +367,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is this for ?
} }
// Activate Payment Request API // Activate Payment Request API
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("STRIPE_PAYMENT_REQUEST_API").'</td><td>'; print $langs->trans("STRIPE_PAYMENT_REQUEST_API").'</td><td>';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
@ -374,8 +380,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
} }
// Activate SEPA DIRECT_DEBIT // Activate SEPA DIRECT_DEBIT
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").'</td><td>'; print $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").'</td><td>';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
@ -388,8 +393,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
} }
// Activate Bancontact // Activate Bancontact
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("STRIPE_BANCONTACT").'</td><td>'; print $langs->trans("STRIPE_BANCONTACT").'</td><td>';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
@ -403,8 +407,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
} }
// Activate iDEAL // Activate iDEAL
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("STRIPE_IDEAL").'</td><td>'; print $langs->trans("STRIPE_IDEAL").'</td><td>';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
@ -418,8 +421,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
} }
// Activate Giropay // Activate Giropay
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("STRIPE_GIROPAY").'</td><td>'; print $langs->trans("STRIPE_GIROPAY").'</td><td>';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
@ -433,8 +435,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
} }
// Activate Sofort // Activate Sofort
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("STRIPE_SOFORT").'</td><td>'; print $langs->trans("STRIPE_SOFORT").'</td><td>';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
@ -540,8 +541,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php';
print info_admin($langs->trans("ExampleOfTestCreditCard", '4242424242424242 (no 3DSecure) or 4000000000003063 (3DSecure required) or 4000002760003184 (3DSecure2 required on all transaction) or 4000003800000446 (3DSecure2 required, the off-session allowed)', '4000000000000101', '4000000000000069', '4000000000000341')); print info_admin($langs->trans("ExampleOfTestCreditCard", '4242424242424242 (no 3DSecure) or 4000000000003063 (3DSecure required) or 4000002760003184 (3DSecure2 required on all transaction) or 4000003800000446 (3DSecure2 required, the off-session allowed)', '4000000000000101', '4000000000000069', '4000000000000341'));
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax)) {
{
print "\n".'<script type="text/javascript">'; print "\n".'<script type="text/javascript">';
print '$(document).ready(function () { print '$(document).ready(function () {
$("#apidoc").hide(); $("#apidoc").hide();

View File

@ -26,14 +26,18 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; if (!empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe')); $langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe'));
// Security check // Security check
$socid = GETPOST("socid", "int"); $socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
//$result = restrictedArea($user, 'salaries', '', '', ''); //$result = restrictedArea($user, 'salaries', '', '', '');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
@ -41,7 +45,9 @@ $rowid = GETPOST("rowid", 'alpha');
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -60,8 +66,7 @@ $stripe = new Stripe($db);
llxHeader('', $langs->trans("StripeChargeList")); llxHeader('', $langs->trans("StripeChargeList"));
if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
{
$service = 'StripeTest'; $service = 'StripeTest';
$servicestatus = '0'; $servicestatus = '0';
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
@ -80,11 +85,12 @@ if (!$rowid) {
$option = array('limit' => $limit + 1); $option = array('limit' => $limit + 1);
$num = 0; $num = 0;
if (GETPOSTISSET('starting_after_'.$page)) $option['starting_after'] = GETPOST('starting_after_'.$page, 'alphanohtml'); if (GETPOSTISSET('starting_after_'.$page)) {
$option['starting_after'] = GETPOST('starting_after_'.$page, 'alphanohtml');
}
try { try {
if ($stripeacc) if ($stripeacc) {
{
$list = \Stripe\Charge::all($option, array("stripe_account" => $stripeacc)); $list = \Stripe\Charge::all($option, array("stripe_account" => $stripeacc));
} else { } else {
$list = \Stripe\Charge::all($option); $list = \Stripe\Charge::all($option);
@ -96,7 +102,9 @@ if (!$rowid) {
$param = ''; $param = '';
//if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); //if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
$param .= '&starting_after_'.($page + 1).'='.$list->data[($limit - 1)]->id; $param .= '&starting_after_'.($page + 1).'='.$list->data[($limit - 1)]->id;
//$param.='&ending_before_'.($page+1).'='.$list->data[($limit-1)]->id; //$param.='&ending_before_'.($page+1).'='.$list->data[($limit-1)]->id;
@ -106,7 +114,9 @@ if (!$rowid) {
} }
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
@ -135,8 +145,7 @@ if (!$rowid) {
//print $list; //print $list;
$i = 0; $i = 0;
foreach ($list->data as $charge) foreach ($list->data as $charge) {
{
if ($i >= $limit) { if ($i >= $limit) {
break; break;
} }
@ -179,17 +188,14 @@ if (!$rowid) {
// Save into $tmparray all metadata // Save into $tmparray all metadata
$tmparray = dolExplodeIntoArray($FULLTAG, '.', '='); $tmparray = dolExplodeIntoArray($FULLTAG, '.', '=');
// Load origin object according to metadata // Load origin object according to metadata
if (!empty($tmparray['CUS']) && $tmparray['CUS'] > 0) if (!empty($tmparray['CUS']) && $tmparray['CUS'] > 0) {
{
$societestatic->fetch($tmparray['CUS']); $societestatic->fetch($tmparray['CUS']);
} elseif (!empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0) } elseif (!empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0) {
{
$societestatic->fetch($charge->metadata->dol_thirdparty_id); $societestatic->fetch($charge->metadata->dol_thirdparty_id);
} else { } else {
$societestatic->id = 0; $societestatic->id = 0;
} }
if (!empty($tmparray['MEM']) && $tmparray['MEM'] > 0) if (!empty($tmparray['MEM']) && $tmparray['MEM'] > 0) {
{
$memberstatic->fetch($tmparray['MEM']); $memberstatic->fetch($tmparray['MEM']);
} else { } else {
$memberstatic->id = 0; $memberstatic->id = 0;
@ -197,40 +203,41 @@ if (!$rowid) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if (!empty($stripeacc)) $connect = $stripeacc.'/'; if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
}
// Ref // Ref
$url = 'https://dashboard.stripe.com/'.$connect.'test/payments/'.$charge->id; $url = 'https://dashboard.stripe.com/'.$connect.'test/payments/'.$charge->id;
if ($servicestatus) if ($servicestatus) {
{
$url = 'https://dashboard.stripe.com/'.$connect.'payments/'.$charge->id; $url = 'https://dashboard.stripe.com/'.$connect.'payments/'.$charge->id;
} }
print "<td>"; print "<td>";
print "<a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$charge->id."</a>"; print "<a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$charge->id."</a>";
if ($charge->payment_intent) print '<br><span class="opacitymedium">'.$charge->payment_intent.'</span>'; if ($charge->payment_intent) {
print '<br><span class="opacitymedium">'.$charge->payment_intent.'</span>';
}
print "</td>\n"; print "</td>\n";
// Stripe customer // Stripe customer
print "<td>"; print "<td>";
if (!empty($conf->stripe->enabled) && !empty($stripeacc)) $connect = $stripeacc.'/'; if (!empty($conf->stripe->enabled) && !empty($stripeacc)) {
$connect = $stripeacc.'/';
}
$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$charge->customer; $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$charge->customer;
if ($servicestatus) if ($servicestatus) {
{
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$charge->customer; $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$charge->customer;
} }
if (!empty($charge->customer)) if (!empty($charge->customer)) {
{
print '<a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').' '.$charge->customer.'</a>'; print '<a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').' '.$charge->customer.'</a>';
} }
print "</td>\n"; print "</td>\n";
// Link // Link
print "<td>"; print "<td>";
if ($societestatic->id > 0) if ($societestatic->id > 0) {
{
print $societestatic->getNomUrl(1); print $societestatic->getNomUrl(1);
} elseif ($memberstatic->id > 0) } elseif ($memberstatic->id > 0) {
{
print $memberstatic->getNomUrl(1); print $memberstatic->getNomUrl(1);
} }
print "</td>\n"; print "</td>\n";

View File

@ -71,25 +71,21 @@ class ActionsStripeconnect
{ {
global $db, $conf, $user, $langs, $form; global $db, $conf, $user, $langs, $form;
if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
{
$service = 'StripeTest'; $service = 'StripeTest';
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
} else { } else {
$service = 'StripeLive'; $service = 'StripeLive';
} }
if (is_array($parameters) && !empty($parameters)) if (is_array($parameters) && !empty($parameters)) {
{ foreach ($parameters as $key => $value) {
foreach ($parameters as $key=>$value)
{
$key = $value; $key = $value;
} }
} }
if (is_object($object) && $object->element == 'societe') if (is_object($object) && $object->element == 'societe') {
{
$this->resprints .= '<tr><td>'; $this->resprints .= '<tr><td>';
$this->resprints .= '<table width="100%" class="nobordernopadding"><tr><td>'; $this->resprints .= '<table width="100%" class="nobordernopadding"><tr><td>';
$this->resprints .= $langs->trans('StripeCustomer'); $this->resprints .= $langs->trans('StripeCustomer');
@ -195,20 +191,16 @@ class ActionsStripeconnect
$resteapayer = $object->total_ttc - $totalpaye; $resteapayer = $object->total_ttc - $totalpaye;
// Request a direct debit order // Request a direct debit order
if ($object->statut > Facture::STATUS_DRAFT && $object->statut < Facture::STATUS_ABANDONED && $object->paye == 0) if ($object->statut > Facture::STATUS_DRAFT && $object->statut < Facture::STATUS_ABANDONED && $object->paye == 0) {
{
$stripe = new Stripe($this->db); $stripe = new Stripe($this->db);
if ($resteapayer > 0) if ($resteapayer > 0) {
{ if ($stripe->getStripeAccount($conf->entity)) { // a modifier avec droit stripe
if ($stripe->getStripeAccount($conf->entity)) // a modifier avec droit stripe
{
$langs->load("withdrawals"); $langs->load("withdrawals");
print '<a class="butActionDelete" href="'.dol_buildpath('/stripeconnect/payment.php?facid='.$object->id.'&action=create', 1).'" title="'.dol_escape_htmltag($langs->trans("StripeConnectPay")).'">'.$langs->trans("StripeConnectPay").'</a>'; print '<a class="butActionDelete" href="'.dol_buildpath('/stripeconnect/payment.php?facid='.$object->id.'&action=create', 1).'" title="'.dol_escape_htmltag($langs->trans("StripeConnectPay")).'">'.$langs->trans("StripeConnectPay").'</a>';
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("StripeConnectPay").'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("StripeConnectPay").'</a>';
} }
} elseif ($resteapayer == 0) } elseif ($resteapayer == 0) {
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("StripeConnectPay").'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("StripeConnectPay").'</a>';
} }
} else { } else {

View File

@ -91,7 +91,9 @@ class Stripe extends CommonObject
global $conf; global $conf;
$key = ''; $key = '';
if ($entity < 0) $entity = $conf->entity; if ($entity < 0) {
$entity = $conf->entity;
}
$sql = "SELECT tokenstring"; $sql = "SELECT tokenstring";
$sql .= " FROM ".MAIN_DB_PREFIX."oauth_token"; $sql .= " FROM ".MAIN_DB_PREFIX."oauth_token";
@ -155,8 +157,7 @@ class Stripe extends CommonObject
{ {
global $conf, $user; global $conf, $user;
if (empty($object->id)) if (empty($object->id)) {
{
dol_syslog("customerStripe is called with the parameter object that is not loaded"); dol_syslog("customerStripe is called with the parameter object that is not loaded");
return null; return null;
} }
@ -193,8 +194,7 @@ class Stripe extends CommonObject
//$customer = \Stripe\Customer::retrieve("$tiers", array("stripe_account" => $key)); //$customer = \Stripe\Customer::retrieve("$tiers", array("stripe_account" => $key));
$customer = \Stripe\Customer::retrieve(array('id'=>"$tiers", 'expand[]'=>'sources'), array("stripe_account" => $key)); $customer = \Stripe\Customer::retrieve(array('id'=>"$tiers", 'expand[]'=>'sources'), array("stripe_account" => $key));
} }
} catch (Exception $e) } catch (Exception $e) {
{
// For exemple, we may have error: 'No such customer: cus_XXXXX; a similar object exists in live mode, but a test mode key was used to make this request.' // For exemple, we may have error: 'No such customer: cus_XXXXX; a similar object exists in live mode, but a test mode key was used to make this request.'
$this->error = $e->getMessage(); $this->error = $e->getMessage();
} }
@ -234,13 +234,10 @@ class Stripe extends CommonObject
} }
// Create the VAT record in Stripe // Create the VAT record in Stripe
if (!empty($conf->global->STRIPE_SAVE_TAX_IDS)) // We setup to save Tax info on Stripe side. Warning: This may result in error when saving customer if (!empty($conf->global->STRIPE_SAVE_TAX_IDS)) { // We setup to save Tax info on Stripe side. Warning: This may result in error when saving customer
{ if (!empty($vatcleaned)) {
if (!empty($vatcleaned))
{
$isineec = isInEEC($object); $isineec = isInEEC($object);
if ($object->country_code && $isineec) if ($object->country_code && $isineec) {
{
//$taxids = $customer->allTaxIds($customer->id); //$taxids = $customer->allTaxIds($customer->id);
$customer->createTaxId($customer->id, array('type'=>'eu_vat', 'value'=>$vatcleaned)); $customer->createTaxId($customer->id, array('type'=>'eu_vat', 'value'=>$vatcleaned));
} }
@ -251,12 +248,10 @@ class Stripe extends CommonObject
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
$sql .= " VALUES (".$object->id.", '', '".$this->db->escape($customer->id)."', 'stripe', '".$this->db->escape($stripearrayofkeysbyenv[$status]['publishable_key'])."', ".$status.", ".$conf->entity.", '".$this->db->idate(dol_now())."', ".$user->id.")"; $sql .= " VALUES (".$object->id.", '', '".$this->db->escape($customer->id)."', 'stripe', '".$this->db->escape($stripearrayofkeysbyenv[$status]['publishable_key'])."', ".$status.", ".$conf->entity.", '".$this->db->idate(dol_now())."', ".$user->id.")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) if (!$resql) {
{
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
} }
} catch (Exception $e) } catch (Exception $e) {
{
$this->error = $e->getMessage(); $this->error = $e->getMessage();
} }
} }
@ -288,8 +283,7 @@ class Stripe extends CommonObject
} else { } else {
$stripepaymentmethod = \Stripe\PaymentMethod::retrieve(''.$paymentmethod->id.'', array("stripe_account" => $key)); $stripepaymentmethod = \Stripe\PaymentMethod::retrieve(''.$paymentmethod->id.'', array("stripe_account" => $key));
} }
} catch (Exception $e) } catch (Exception $e) {
{
$this->error = $e->getMessage(); $this->error = $e->getMessage();
} }
@ -329,12 +323,18 @@ class Stripe extends CommonObject
$error = 0; $error = 0;
if (empty($status)) $service = 'StripeTest'; if (empty($status)) {
else $service = 'StripeLive'; $service = 'StripeTest';
} else {
$service = 'StripeLive';
}
$arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
if (!in_array($currency_code, $arrayzerounitcurrency)) $stripeamount = $amount * 100; if (!in_array($currency_code, $arrayzerounitcurrency)) {
else $stripeamount = $amount; $stripeamount = $amount * 100;
} else {
$stripeamount = $amount;
}
$fee = $amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE; $fee = $amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE;
if ($fee >= $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL > $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { if ($fee >= $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL > $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) {
@ -350,8 +350,7 @@ class Stripe extends CommonObject
$paymentintent = null; $paymentintent = null;
if (is_object($object) && !empty($conf->global->STRIPE_REUSE_EXISTING_INTENT_IF_FOUND)) if (is_object($object) && !empty($conf->global->STRIPE_REUSE_EXISTING_INTENT_IF_FOUND)) {
{
// Warning. If a payment was tried and failed, a payment intent was created. // Warning. If a payment was tried and failed, a payment intent was created.
// But if we change something on object to pay (amount or other that does not change the idempotency key), reusing same payment intent is not allowed by Stripe. // But if we change something on object to pay (amount or other that does not change the idempotency key), reusing same payment intent is not allowed by Stripe.
// Recommended solution is to recreate a new payment intent each time we need one (old one will be automatically closed by Stripe after a delay), Stripe will // Recommended solution is to recreate a new payment intent each time we need one (old one will be automatically closed by Stripe after a delay), Stripe will
@ -369,8 +368,7 @@ class Stripe extends CommonObject
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) if ($num) {
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$intent = $obj->ext_payment_id; $intent = $obj->ext_payment_id;
@ -386,8 +384,7 @@ class Stripe extends CommonObject
} else { } else {
$paymentintent = \Stripe\PaymentIntent::retrieve($intent, array("stripe_account" => $key)); $paymentintent = \Stripe\PaymentIntent::retrieve($intent, array("stripe_account" => $key));
} }
} } catch (Exception $e) {
catch (Exception $e) {
$error++; $error++;
$this->error = $e->getMessage(); $this->error = $e->getMessage();
} }
@ -395,25 +392,35 @@ class Stripe extends CommonObject
} }
} }
if (empty($paymentintent)) if (empty($paymentintent)) {
{
// Try to create intent. See https://stripe.com/docs/api/payment_intents/create // Try to create intent. See https://stripe.com/docs/api/payment_intents/create
$ipaddress = getUserRemoteIP(); $ipaddress = getUserRemoteIP();
$metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress); $metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress);
if (is_object($object)) if (is_object($object)) {
{
$metadata['dol_type'] = $object->element; $metadata['dol_type'] = $object->element;
$metadata['dol_id'] = $object->id; $metadata['dol_id'] = $object->id;
if (is_object($object->thirdparty) && $object->thirdparty->id > 0) $metadata['dol_thirdparty_id'] = $object->thirdparty->id; if (is_object($object->thirdparty) && $object->thirdparty->id > 0) {
$metadata['dol_thirdparty_id'] = $object->thirdparty->id;
}
} }
// list of payment method types // list of payment method types
$paymentmethodtypes = array("card"); $paymentmethodtypes = array("card");
if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) {
if (!empty($conf->global->STRIPE_BANCONTACT)) $paymentmethodtypes[] = "bancontact"; $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC())
if (!empty($conf->global->STRIPE_IDEAL)) $paymentmethodtypes[] = "ideal"; }
if (!empty($conf->global->STRIPE_GIROPAY)) $paymentmethodtypes[] = "giropay"; if (!empty($conf->global->STRIPE_BANCONTACT)) {
if (!empty($conf->global->STRIPE_SOFORT)) $paymentmethodtypes[] = "sofort"; $paymentmethodtypes[] = "bancontact";
}
if (!empty($conf->global->STRIPE_IDEAL)) {
$paymentmethodtypes[] = "ideal";
}
if (!empty($conf->global->STRIPE_GIROPAY)) {
$paymentmethodtypes[] = "giropay";
}
if (!empty($conf->global->STRIPE_SOFORT)) {
$paymentmethodtypes[] = "sofort";
}
$dataforintent = array( $dataforintent = array(
"confirm" => $confirmnow, // Do not confirm immediatly during creation of intent "confirm" => $confirmnow, // Do not confirm immediatly during creation of intent
@ -427,32 +434,32 @@ class Stripe extends CommonObject
"setup_future_usage" => "on_session", "setup_future_usage" => "on_session",
"metadata" => $metadata "metadata" => $metadata
); );
if (!is_null($customer)) $dataforintent["customer"] = $customer; if (!is_null($customer)) {
$dataforintent["customer"] = $customer;
}
// payment_method = // payment_method =
// payment_method_types = array('card') // payment_method_types = array('card')
//var_dump($dataforintent); //var_dump($dataforintent);
if ($off_session) if ($off_session) {
{
unset($dataforintent['setup_future_usage']); unset($dataforintent['setup_future_usage']);
// We can't use both "setup_future_usage" = "off_session" and "off_session" = true. // We can't use both "setup_future_usage" = "off_session" and "off_session" = true.
// Because $off_session parameter is dedicated to create paymentintent off_line (and not future payment), we need to use "off_session" = true. // Because $off_session parameter is dedicated to create paymentintent off_line (and not future payment), we need to use "off_session" = true.
//$dataforintent["setup_future_usage"] = "off_session"; //$dataforintent["setup_future_usage"] = "off_session";
$dataforintent["off_session"] = true; $dataforintent["off_session"] = true;
} }
if (!empty($conf->global->STRIPE_GIROPAY)) unset($dataforintent['setup_future_usage']); if (!empty($conf->global->STRIPE_GIROPAY)) {
unset($dataforintent['setup_future_usage']);
}
if (!is_null($payment_method)) if (!is_null($payment_method)) {
{
$dataforintent["payment_method"] = $payment_method; $dataforintent["payment_method"] = $payment_method;
$description .= ' - '.$payment_method; $description .= ' - '.$payment_method;
} }
if ($conf->entity != $conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) if ($conf->entity != $conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) {
{
$dataforintent["application_fee_amount"] = $stripefee; $dataforintent["application_fee_amount"] = $stripefee;
} }
if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email) if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email) {
{
$dataforintent["receipt_email"] = $object->thirdparty->email; $dataforintent["receipt_email"] = $object->thirdparty->email;
} }
@ -475,8 +482,7 @@ class Stripe extends CommonObject
$paymentintent = \Stripe\PaymentIntent::create($dataforintent, $arrayofoptions); $paymentintent = \Stripe\PaymentIntent::create($dataforintent, $arrayofoptions);
// Store the payment intent // Store the payment intent
if (is_object($object)) if (is_object($object)) {
{
$paymentintentalreadyexists = 0; $paymentintentalreadyexists = 0;
// Check that payment intent $paymentintent->id is not already recorded. // Check that payment intent $paymentintent->id is not already recorded.
$sql = "SELECT pi.rowid"; $sql = "SELECT pi.rowid";
@ -489,22 +495,23 @@ class Stripe extends CommonObject
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) if ($num) {
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($obj) $paymentintentalreadyexists++; if ($obj) {
$paymentintentalreadyexists++;
}
}
} else {
dol_print_error($this->db);
} }
} else dol_print_error($this->db);
// If not, we create it. // If not, we create it.
if (!$paymentintentalreadyexists) if (!$paymentintentalreadyexists) {
{
$now = dol_now(); $now = dol_now();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_facture_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site, amount)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_facture_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site, amount)";
$sql .= " VALUES ('".$this->db->idate($now)."', ".$user->id.", '".$this->db->escape($paymentintent->id)."', ".$object->id.", '".$this->db->escape($object->element)."', ".$conf->entity.", '".$this->db->escape($service)."', ".$amount.")"; $sql .= " VALUES ('".$this->db->idate($now)."', ".$user->id.", '".$this->db->escape($paymentintent->id)."', ".$object->id.", '".$this->db->escape($object->element)."', ".$conf->entity.", '".$this->db->escape($service)."', ".$amount.")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) if (!$resql) {
{
$error++; $error++;
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
dol_syslog(get_class($this)."::PaymentIntent failed to insert paymentintent with id=".$paymentintent->id." into database."); dol_syslog(get_class($this)."::PaymentIntent failed to insert paymentintent with id=".$paymentintent->id." into database.");
@ -513,14 +520,12 @@ class Stripe extends CommonObject
} else { } else {
$_SESSION["stripe_payment_intent"] = $paymentintent; $_SESSION["stripe_payment_intent"] = $paymentintent;
} }
} catch (Stripe\Error\Card $e) } catch (Stripe\Error\Card $e) {
{
$error++; $error++;
$this->error = $e->getMessage(); $this->error = $e->getMessage();
$this->code = $e->getStripeCode(); $this->code = $e->getStripeCode();
$this->declinecode = $e->getDeclineCode(); $this->declinecode = $e->getDeclineCode();
} catch (Exception $e) } catch (Exception $e) {
{
/*var_dump($dataforintent); /*var_dump($dataforintent);
var_dump($description); var_dump($description);
var_dump($key); var_dump($key);
@ -570,29 +575,40 @@ class Stripe extends CommonObject
$error = 0; $error = 0;
if (empty($status)) $service = 'StripeTest'; if (empty($status)) {
else $service = 'StripeLive'; $service = 'StripeTest';
} else {
$service = 'StripeLive';
}
$setupintent = null; $setupintent = null;
if (empty($setupintent)) if (empty($setupintent)) {
{
$ipaddress = getUserRemoteIP(); $ipaddress = getUserRemoteIP();
$metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress); $metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress);
if (is_object($object)) if (is_object($object)) {
{
$metadata['dol_type'] = $object->element; $metadata['dol_type'] = $object->element;
$metadata['dol_id'] = $object->id; $metadata['dol_id'] = $object->id;
if (is_object($object->thirdparty) && $object->thirdparty->id > 0) $metadata['dol_thirdparty_id'] = $object->thirdparty->id; if (is_object($object->thirdparty) && $object->thirdparty->id > 0) {
$metadata['dol_thirdparty_id'] = $object->thirdparty->id;
}
} }
// list of payment method types // list of payment method types
$paymentmethodtypes = array("card"); $paymentmethodtypes = array("card");
if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) {
if (!empty($conf->global->STRIPE_BANCONTACT)) $paymentmethodtypes[] = "bancontact"; $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC())
if (!empty($conf->global->STRIPE_IDEAL)) $paymentmethodtypes[] = "ideal"; }
if (!empty($conf->global->STRIPE_BANCONTACT)) {
$paymentmethodtypes[] = "bancontact";
}
if (!empty($conf->global->STRIPE_IDEAL)) {
$paymentmethodtypes[] = "ideal";
}
// Giropay not possible for setup intent // Giropay not possible for setup intent
if (!empty($conf->global->STRIPE_SOFORT)) $paymentmethodtypes[] = "sofort"; if (!empty($conf->global->STRIPE_SOFORT)) {
$paymentmethodtypes[] = "sofort";
}
$dataforintent = array( $dataforintent = array(
"confirm" => $confirmnow, // Do not confirm immediatly during creation of intent "confirm" => $confirmnow, // Do not confirm immediatly during creation of intent
@ -600,14 +616,17 @@ class Stripe extends CommonObject
"usage" => "off_session", "usage" => "off_session",
"metadata" => $metadata "metadata" => $metadata
); );
if (!is_null($customer)) $dataforintent["customer"] = $customer; if (!is_null($customer)) {
if (!is_null($description)) $dataforintent["description"] = $description; $dataforintent["customer"] = $customer;
}
if (!is_null($description)) {
$dataforintent["description"] = $description;
}
// payment_method = // payment_method =
// payment_method_types = array('card') // payment_method_types = array('card')
//var_dump($dataforintent); //var_dump($dataforintent);
if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email) if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email) {
{
$dataforintent["receipt_email"] = $object->thirdparty->email; $dataforintent["receipt_email"] = $object->thirdparty->email;
} }
@ -670,8 +689,7 @@ class Stripe extends CommonObject
{ {
$_SESSION["stripe_setup_intent"] = $setupintent; $_SESSION["stripe_setup_intent"] = $setupintent;
}*/ }*/
} catch (Exception $e) } catch (Exception $e) {
{
/*var_dump($dataforintent); /*var_dump($dataforintent);
var_dump($description); var_dump($description);
var_dump($key); var_dump($key);
@ -682,8 +700,7 @@ class Stripe extends CommonObject
} }
} }
if (!$error) if (!$error) {
{
dol_syslog("getSetupIntent ".(is_object($setupintent) ? $setupintent->id : ''), LOG_INFO, -1); dol_syslog("getSetupIntent ".(is_object($setupintent) ? $setupintent->id : ''), LOG_INFO, -1);
return $setupintent; return $setupintent;
} else { } else {
@ -718,24 +735,20 @@ class Stripe extends CommonObject
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) if ($num) {
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$cardref = $obj->stripe_card_ref; $cardref = $obj->stripe_card_ref;
dol_syslog(get_class($this)."::cardStripe cardref=".$cardref); dol_syslog(get_class($this)."::cardStripe cardref=".$cardref);
if ($cardref) if ($cardref) {
{
try { try {
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
if (!preg_match('/^pm_/', $cardref) && !empty($cu->sources)) if (!preg_match('/^pm_/', $cardref) && !empty($cu->sources)) {
{
$card = $cu->sources->retrieve($cardref); $card = $cu->sources->retrieve($cardref);
} else { } else {
$card = \Stripe\PaymentMethod::retrieve($cardref); $card = \Stripe\PaymentMethod::retrieve($cardref);
} }
} else { } else {
if (!preg_match('/^pm_/', $cardref) && !empty($cu->sources)) if (!preg_match('/^pm_/', $cardref) && !empty($cu->sources)) {
{
//$card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided //$card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided
$card = $cu->sources->retrieve($cardref); $card = $cu->sources->retrieve($cardref);
} else { } else {
@ -743,13 +756,11 @@ class Stripe extends CommonObject
$card = \Stripe\PaymentMethod::retrieve($cardref); $card = \Stripe\PaymentMethod::retrieve($cardref);
} }
} }
} catch (Exception $e) } catch (Exception $e) {
{
$this->error = $e->getMessage(); $this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING); dol_syslog($this->error, LOG_WARNING);
} }
} elseif ($createifnotlinkedtostripe) } elseif ($createifnotlinkedtostripe) {
{
$exp_date_month = $obj->exp_date_month; $exp_date_month = $obj->exp_date_month;
$exp_date_year = $obj->exp_date_year; $exp_date_year = $obj->exp_date_year;
$number = $obj->number; $number = $obj->number;
@ -767,20 +778,19 @@ class Stripe extends CommonObject
//var_dump($a);var_dump($stripeacc);exit; //var_dump($a);var_dump($stripeacc);exit;
try { try {
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
{
dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard)); dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard));
$card = $cu->sources->create($dataforcard); $card = $cu->sources->create($dataforcard);
if (!$card) if (!$card) {
{
$this->error = 'Creation of card on Stripe has failed'; $this->error = 'Creation of card on Stripe has failed';
} }
} else { } else {
$connect = ''; $connect = '';
if (!empty($stripeacc)) $connect = $stripeacc.'/'; if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
}
$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$cu->id; $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$cu->id;
if ($status) if ($status) {
{
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id; $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id;
} }
$urtoswitchonstripe = ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').'</a>'; $urtoswitchonstripe = ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').'</a>';
@ -789,20 +799,19 @@ class Stripe extends CommonObject
$this->error = $langs->trans('CreationOfPaymentModeMustBeDoneFromStripeInterface', $urtoswitchonstripe); $this->error = $langs->trans('CreationOfPaymentModeMustBeDoneFromStripeInterface', $urtoswitchonstripe);
} }
} else { } else {
if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
{
dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard)); dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard));
$card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc)); $card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc));
if (!$card) if (!$card) {
{
$this->error = 'Creation of card on Stripe has failed'; $this->error = 'Creation of card on Stripe has failed';
} }
} else { } else {
$connect = ''; $connect = '';
if (!empty($stripeacc)) $connect = $stripeacc.'/'; if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
}
$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$cu->id; $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$cu->id;
if ($status) if ($status) {
{
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id; $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id;
} }
$urtoswitchonstripe = ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').'</a>'; $urtoswitchonstripe = ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').'</a>';
@ -812,8 +821,7 @@ class Stripe extends CommonObject
} }
} }
if ($card) if ($card) {
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib"; $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib";
$sql .= " SET stripe_card_ref = '".$this->db->escape($card->id)."', card_type = '".$this->db->escape($card->brand)."',"; $sql .= " SET stripe_card_ref = '".$this->db->escape($card->id)."', card_type = '".$this->db->escape($card->brand)."',";
$sql .= " country_code = '".$this->db->escape($card->country)."',"; $sql .= " country_code = '".$this->db->escape($card->country)."',";
@ -821,13 +829,11 @@ class Stripe extends CommonObject
$sql .= " WHERE rowid = ".$object->id; $sql .= " WHERE rowid = ".$object->id;
$sql .= " AND type = 'card'"; $sql .= " AND type = 'card'";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) if (!$resql) {
{
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
} }
} }
} catch (Exception $e) } catch (Exception $e) {
{
$this->error = $e->getMessage(); $this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING); dol_syslog($this->error, LOG_WARNING);
} }
@ -862,8 +868,11 @@ class Stripe extends CommonObject
$error = 0; $error = 0;
if (empty($status)) $service = 'StripeTest'; if (empty($status)) {
else $service = 'StripeLive'; $service = 'StripeTest';
} else {
$service = 'StripeLive';
}
$sql = "SELECT sa.key_account as key_account, sa.fk_soc, sa.entity"; $sql = "SELECT sa.key_account as key_account, sa.fk_soc, sa.entity";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_account as sa"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as sa";
@ -885,11 +894,16 @@ class Stripe extends CommonObject
} }
$arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
if (!in_array($currency, $arrayzerounitcurrency)) $stripeamount = $amount * 100; if (!in_array($currency, $arrayzerounitcurrency)) {
else $stripeamount = $amount; $stripeamount = $amount * 100;
} else {
$stripeamount = $amount;
}
$societe = new Societe($this->db); $societe = new Societe($this->db);
if ($key > 0) $societe->fetch($key); if ($key > 0) {
$societe->fetch($key);
}
$description = ""; $description = "";
$ref = ""; $ref = "";
@ -922,10 +936,8 @@ class Stripe extends CommonObject
global $stripearrayofkeysbyenv; global $stripearrayofkeysbyenv;
\Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']);
if (empty($conf->stripeconnect->enabled)) // With a common Stripe account if (empty($conf->stripeconnect->enabled)) { // With a common Stripe account
{ if (preg_match('/pm_/i', $source)) {
if (preg_match('/pm_/i', $source))
{
$stripecard = $source; $stripecard = $source;
$amountstripe = $stripeamount; $amountstripe = $stripeamount;
$FULLTAG = 'PFBO'; // Payment From Back Office $FULLTAG = 'PFBO'; // Payment From Back Office
@ -942,8 +954,7 @@ class Stripe extends CommonObject
$paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $invoice, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1); $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $invoice, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1);
$charge = new stdClass(); $charge = new stdClass();
if ($paymentintent->status == 'succeeded') if ($paymentintent->status == 'succeeded') {
{
$charge->status = 'ok'; $charge->status = 'ok';
} else { } else {
$charge->status = 'failed'; $charge->status = 'failed';
@ -954,8 +965,7 @@ class Stripe extends CommonObject
$stripefailuremessage = $stripe->error; $stripefailuremessage = $stripe->error;
$stripefailuredeclinecode = $stripe->declinecode; $stripefailuredeclinecode = $stripe->declinecode;
} }
} elseif (preg_match('/acct_/i', $source)) } elseif (preg_match('/acct_/i', $source)) {
{
$charge = \Stripe\Charge::create(array( $charge = \Stripe\Charge::create(array(
"amount" => "$stripeamount", "amount" => "$stripeamount",
"currency" => "$currency", "currency" => "$currency",
@ -977,8 +987,7 @@ class Stripe extends CommonObject
"customer" => "$customer" "customer" => "$customer"
); );
if ($societe->email && $usethirdpartyemailforreceiptemail) if ($societe->email && $usethirdpartyemailforreceiptemail) {
{
$paymentarray["receipt_email"] = $societe->email; $paymentarray["receipt_email"] = $societe->email;
} }
@ -993,8 +1002,11 @@ class Stripe extends CommonObject
$fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL;
} }
if (!in_array($currency, $arrayzerounitcurrency)) $stripefee = round($fee * 100); if (!in_array($currency, $arrayzerounitcurrency)) {
else $stripefee = round($fee); $stripefee = round($fee * 100);
} else {
$stripefee = round($fee);
}
$paymentarray = array( $paymentarray = array(
"amount" => "$stripeamount", "amount" => "$stripeamount",
@ -1006,17 +1018,14 @@ class Stripe extends CommonObject
"source" => "$source", "source" => "$source",
"customer" => "$customer" "customer" => "$customer"
); );
if ($conf->entity != $conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) if ($conf->entity != $conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) {
{
$paymentarray["application_fee_amount"] = $stripefee; $paymentarray["application_fee_amount"] = $stripefee;
} }
if ($societe->email && $usethirdpartyemailforreceiptemail) if ($societe->email && $usethirdpartyemailforreceiptemail) {
{
$paymentarray["receipt_email"] = $societe->email; $paymentarray["receipt_email"] = $societe->email;
} }
if (preg_match('/pm_/i', $source)) if (preg_match('/pm_/i', $source)) {
{
$stripecard = $source; $stripecard = $source;
$amountstripe = $stripeamount; $amountstripe = $stripeamount;
$FULLTAG = 'PFBO'; // Payment From Back Office $FULLTAG = 'PFBO'; // Payment From Back Office
@ -1033,8 +1042,7 @@ class Stripe extends CommonObject
$paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $invoice, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1); $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $invoice, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1);
$charge = new stdClass(); $charge = new stdClass();
if ($paymentintent->status == 'succeeded') if ($paymentintent->status == 'succeeded') {
{
$charge->status = 'ok'; $charge->status = 'ok';
$charge->id = $paymentintent->id; $charge->id = $paymentintent->id;
} else { } else {
@ -1047,13 +1055,13 @@ class Stripe extends CommonObject
$charge = \Stripe\Charge::create($paymentarray, array("idempotency_key" => "$description", "stripe_account" => "$account")); $charge = \Stripe\Charge::create($paymentarray, array("idempotency_key" => "$description", "stripe_account" => "$account"));
} }
} }
if (isset($charge->id)) {} if (isset($charge->id)) {
}
$return->statut = 'success'; $return->statut = 'success';
$return->id = $charge->id; $return->id = $charge->id;
if (preg_match('/pm_/i', $source)) if (preg_match('/pm_/i', $source)) {
{
$return->message = 'Payment retrieved by card status = '.$charge->status; $return->message = 'Payment retrieved by card status = '.$charge->status;
} else { } else {
if ($charge->source->type == 'card') { if ($charge->source->type == 'card') {

View File

@ -44,8 +44,7 @@ $stripearrayofkeysbyenv = array(
); );
$stripearrayofkeys = array(); $stripearrayofkeys = array();
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) {
{
$stripearrayofkeys = $stripearrayofkeysbyenv[0]; // Test $stripearrayofkeys = $stripearrayofkeysbyenv[0]; // Test
} else { } else {
$stripearrayofkeys = $stripearrayofkeysbyenv[1]; // Live $stripearrayofkeys = $stripearrayofkeysbyenv[1]; // Live

View File

@ -67,52 +67,53 @@ function html_print_stripe_footer($fromcompany, $langs)
// Juridical status // Juridical status
$line1 = ""; $line1 = "";
if ($fromcompany->forme_juridique_code) if ($fromcompany->forme_juridique_code) {
{
$line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); $line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code);
} }
// Capital // Capital
if ($fromcompany->capital) if ($fromcompany->capital) {
{
$line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); $line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency);
} }
$reg = array(); $reg = array();
// Prof Id 1 // Prof Id 1
if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) {
{
$field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code); $field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code);
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; if (preg_match('/\((.*)\)/i', $field, $reg)) {
$field = $reg[1];
}
$line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1; $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1;
} }
// Prof Id 2 // Prof Id 2
if ($fromcompany->idprof2) if ($fromcompany->idprof2) {
{
$field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code); $field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code);
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; if (preg_match('/\((.*)\)/i', $field, $reg)) {
$field = $reg[1];
}
$line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2; $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2;
} }
// Second line of company infos // Second line of company infos
$line2 = ""; $line2 = "";
// Prof Id 3 // Prof Id 3
if ($fromcompany->idprof3) if ($fromcompany->idprof3) {
{
$field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code); $field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code);
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; if (preg_match('/\((.*)\)/i', $field, $reg)) {
$field = $reg[1];
}
$line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3; $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3;
} }
// Prof Id 4 // Prof Id 4
if ($fromcompany->idprof4) if ($fromcompany->idprof4) {
{
$field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code); $field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code);
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; if (preg_match('/\((.*)\)/i', $field, $reg)) {
$field = $reg[1];
}
$line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4; $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4;
} }
// IntraCommunautary VAT // IntraCommunautary VAT
if ($fromcompany->tva_intra != '') if ($fromcompany->tva_intra != '') {
{
$line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; $line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra;
} }

View File

@ -26,14 +26,18 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; if (!empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe')); $langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe'));
// Security check // Security check
$socid = GETPOST("socid", "int"); $socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
//$result = restrictedArea($user, 'salaries', '', '', ''); //$result = restrictedArea($user, 'salaries', '', '', '');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
@ -41,7 +45,9 @@ $rowid = GETPOST("rowid", 'alpha');
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -110,15 +116,13 @@ if (!$rowid) {
print "</tr>\n"; print "</tr>\n";
try { try {
if ($stripeacc) if ($stripeacc) {
{
$payout = \Stripe\Payout::all(array("limit" => $limit), array("stripe_account" => $stripeacc)); $payout = \Stripe\Payout::all(array("limit" => $limit), array("stripe_account" => $stripeacc));
} else { } else {
$payout = \Stripe\Payout::all(array("limit" => $limit)); $payout = \Stripe\Payout::all(array("limit" => $limit));
} }
foreach ($payout->data as $payout) foreach ($payout->data as $payout) {
{
//$charge = $payout; //$charge = $payout;
//var_dump($payout); //var_dump($payout);
@ -157,7 +161,9 @@ if (!$rowid) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Ref // Ref
if (!empty($stripeacc)) $connect = $stripeacc.'/'; if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
}
$url = 'https://dashboard.stripe.com/'.$connect.'test/payouts/'.$payout->id; $url = 'https://dashboard.stripe.com/'.$connect.'test/payouts/'.$payout->id;
if ($servicestatus) { if ($servicestatus) {

View File

@ -26,14 +26,18 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; if (!empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe')); $langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe'));
// Security check // Security check
$socid = GETPOST("socid", "int"); $socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
//$result = restrictedArea($user, 'salaries', '', '', ''); //$result = restrictedArea($user, 'salaries', '', '', '');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
@ -41,7 +45,9 @@ $rowid = GETPOST("rowid", 'alpha');
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -60,8 +66,7 @@ $stripe = new Stripe($db);
llxHeader('', $langs->trans("StripeTransactionList")); llxHeader('', $langs->trans("StripeTransactionList"));
if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
{
$service = 'StripeTest'; $service = 'StripeTest';
$servicestatus = '0'; $servicestatus = '0';
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
@ -77,7 +82,9 @@ $stripeacc = $stripe->getStripeAccount($service);
if (!$rowid) { if (!$rowid) {
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
@ -106,15 +113,13 @@ if (!$rowid) {
print "</tr>\n"; print "</tr>\n";
try { try {
if ($stripeacc) if ($stripeacc) {
{
$txn = \Stripe\BalanceTransaction::all(array("limit" => $limit), array("stripe_account" => $stripeacc)); $txn = \Stripe\BalanceTransaction::all(array("limit" => $limit), array("stripe_account" => $stripeacc));
} else { } else {
$txn = \Stripe\BalanceTransaction::all(array("limit" => $limit)); $txn = \Stripe\BalanceTransaction::all(array("limit" => $limit));
} }
foreach ($txn->data as $txn) foreach ($txn->data as $txn) {
{
//$charge = $txn; //$charge = $txn;
//var_dump($txn); //var_dump($txn);
@ -153,7 +158,9 @@ if (!$rowid) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Ref // Ref
if (!empty($stripeacc)) $connect = $stripeacc.'/'; if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
}
// Ref // Ref
if (preg_match('/po_/i', $txn->source)) { if (preg_match('/po_/i', $txn->source)) {

View File

@ -31,13 +31,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'supplier_proposal'; //Must be the $table_element of the class that manage extrafield $elementtype = 'supplier_proposal'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -72,8 +76,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a></div>';
print "</div>"; print "</div>";
@ -86,8 +89,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -99,8 +101,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -26,8 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/supplier_proposal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
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', 'other', 'supplier_proposal')); $langs->loadLangs(array('admin', 'other', 'supplier_proposal'));
@ -38,14 +39,18 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'supplier_proposaldet'; //Must be the $table_element of the class that manage extrafield $elementtype = 'supplier_proposaldet'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -77,8 +82,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -91,8 +95,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -104,8 +107,7 @@ if ($action == 'create')
/* Edition d'un champ optionnel */ /* Edition d'un champ optionnel */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ class Supplierproposals extends DolibarrApi
/** /**
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( public static $FIELDS = array(
'socid' 'socid'
); );
@ -105,28 +105,37 @@ class Supplierproposals extends DolibarrApi
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
$search_sale = 0; $search_sale = 0;
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
$search_sale = DolibarrApiAccess::$user->id;
}
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as t"; $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as t";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
}
$sql .= ' WHERE t.entity IN ('.getEntity('propal').')'; $sql .= ' WHERE t.entity IN ('.getEntity('propal').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; $sql .= " AND t.fk_soc = sc.fk_soc";
if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale }
if ($socids) {
$sql .= " AND t.fk_soc IN (".$socids.")";
}
if ($search_sale > 0) {
$sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
}
// Insert sale filter // Insert sale filter
if ($search_sale > 0) if ($search_sale > 0) {
{
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -135,8 +144,7 @@ class Supplierproposals extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) if ($page < 0) {
{
$page = 0; $page = 0;
} }
$offset = $limit * $page; $offset = $limit * $page;
@ -146,13 +154,11 @@ class Supplierproposals extends DolibarrApi
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit)); $min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0; $i = 0;
while ($i < $min) while ($i < $min) {
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$propal_static = new SupplierProposal($this->db); $propal_static = new SupplierProposal($this->db);
if ($propal_static->fetch($obj->rowid)) { if ($propal_static->fetch($obj->rowid)) {
@ -181,8 +187,9 @@ class Supplierproposals extends DolibarrApi
{ {
$propal = array(); $propal = array();
foreach (SupplierProposals::$FIELDS as $field) { foreach (SupplierProposals::$FIELDS as $field) {
if (!isset($data[$field])) if (!isset($data[$field])) {
throw new RestException(400, "$field field missing"); throw new RestException(400, "$field field missing");
}
$propal[$field] = $data[$field]; $propal[$field] = $data[$field];
} }
return $propal; return $propal;

File diff suppressed because it is too large Load Diff

View File

@ -39,7 +39,9 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
// Security check // Security check
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal', ''); $result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal', '');
$object = new SupplierProposal($db); $object = new SupplierProposal($db);
@ -51,50 +53,38 @@ $permissiontoedit = $user->rights->supplier_proposal->creer;
* Add a new contact * Add a new contact
*/ */
if ($action == 'addcontact' && $permissiontoedit) if ($action == 'addcontact' && $permissiontoedit) {
{
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0) {
{
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
} }
if ($result >= 0) if ($result >= 0) {
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} else { } else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
{
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} } elseif ($action == 'swapstatut' && $permissiontoedit) {
// Toggle the status of a contact
// Toggle the status of a contact if ($object->fetch($id)) {
elseif ($action == 'swapstatut' && $permissiontoedit)
{
if ($object->fetch($id))
{
$result = $object->swapContactStatus(GETPOST('ligne')); $result = $object->swapContactStatus(GETPOST('ligne'));
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} } elseif ($action == 'deletecontact' && $permissiontoedit) {
// Deleting a contact
// Deleting a contact
elseif ($action == 'deletecontact' && $permissiontoedit)
{
$object->fetch($id); $object->fetch($id);
$result = $object->delete_contact(GETPOST("lineid", 'int')); $result = $object->delete_contact(GETPOST("lineid", 'int'));
if ($result >= 0) if ($result >= 0) {
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} else { } else {
@ -123,12 +113,10 @@ $userstatic = new User($db);
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
if ($id > 0 || !empty($ref)) if ($id > 0 || !empty($ref)) {
{
$langs->trans("SupplierProposal"); $langs->trans("SupplierProposal");
if ($object->fetch($id, $ref) > 0) if ($object->fetch($id, $ref) > 0) {
{
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$head = supplier_proposal_prepare_head($object); $head = supplier_proposal_prepare_head($object);
@ -145,12 +133,10 @@ if ($id > 0 || !empty($ref))
// Thirdparty // Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($permissiontoedit) if ($permissiontoedit) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';

View File

@ -45,8 +45,7 @@ $ref = GETPOST('ref', 'alpha');
// Security check // Security check
$socid = ''; $socid = '';
if (!empty($user->socid)) if (!empty($user->socid)) {
{
$socid = $user->socid; $socid = $user->socid;
} }
$result = restrictedArea($user, 'supplier_proposal', $id); $result = restrictedArea($user, 'supplier_proposal', $id);
@ -56,17 +55,22 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "name"; $sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$object = new SupplierProposal($db); $object = new SupplierProposal($db);
$object->fetch($id, $ref); $object->fetch($id, $ref);
if ($object->id > 0) if ($object->id > 0) {
{
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$upload_dir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($object->ref); $upload_dir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($object->ref);
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
@ -81,8 +85,7 @@ llxHeader('', $langs->trans('CommRequest'), 'EN:Ask_Price_Supplier|FR:Demande_de
$form = new Form($db); $form = new Form($db);
if ($object->id > 0) if ($object->id > 0) {
{
$upload_dir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($object->ref); $upload_dir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($object->ref);
$head = supplier_proposal_prepare_head($object); $head = supplier_proposal_prepare_head($object);
@ -91,8 +94,7 @@ if ($object->id > 0)
// Build file list // Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0; $totalsize = 0;
foreach ($filearray as $key => $file) foreach ($filearray as $key => $file) {
{
$totalsize += $file['size']; $totalsize += $file['size'];
} }
@ -108,12 +110,10 @@ if ($object->id > 0)
// Thirdparty // Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->supplier_proposal->creer) if ($user->rights->supplier_proposal->creer) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';

View File

@ -38,8 +38,7 @@ $langs->loadLangs(array('supplier_proposal', 'companies'));
// Security check // Security check
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
if (isset($user->socid) && $user->socid > 0) if (isset($user->socid) && $user->socid > 0) {
{
$action = ''; $action = '';
$socid = $user->socid; $socid = $user->socid;
} }
@ -65,8 +64,7 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
// Search form // Search form
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo
{
print '<form method="post" action="'.DOL_URL_ROOT.'/supplier_proposal/list.php">'; print '<form method="post" action="'.DOL_URL_ROOT.'/supplier_proposal/list.php">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
@ -84,16 +82,21 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles
$sql = "SELECT count(p.rowid), p.fk_statut"; $sql = "SELECT count(p.rowid), p.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."supplier_proposal as p"; $sql .= ", ".MAIN_DB_PREFIX."supplier_proposal as p";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " WHERE p.fk_soc = s.rowid";
$sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
if ($user->socid) $sql .= ' AND p.fk_soc = '.$user->socid; if ($user->socid) {
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $sql .= ' AND p.fk_soc = '.$user->socid;
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
$sql .= " AND p.fk_statut IN (0,1,2,3,4)"; $sql .= " AND p.fk_statut IN (0,1,2,3,4)";
$sql .= " GROUP BY p.fk_statut"; $sql .= " GROUP BY p.fk_statut";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
@ -103,11 +106,9 @@ if ($resql)
$colorseries = array(); $colorseries = array();
$vals = array(); $vals = array();
// -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not)
while ($i < $num) while ($i < $num) {
{
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
if ($row) if ($row) {
{
//if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1))
{ {
$vals[$row[1]] = $row[0]; $vals[$row[1]] = $row[0];
@ -125,25 +126,32 @@ if ($resql)
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("CommRequests").'</th></tr>'."\n"; print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("CommRequests").'</th></tr>'."\n";
$listofstatus = array(0, 1, 2, 3, 4); $listofstatus = array(0, 1, 2, 3, 4);
foreach ($listofstatus as $status) foreach ($listofstatus as $status) {
{
$dataseries[] = array($supplier_proposalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); $dataseries[] = array($supplier_proposalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
if ($status == SupplierProposal::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; if ($status == SupplierProposal::STATUS_DRAFT) {
if ($status == SupplierProposal::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; $colorseries[$status] = '-'.$badgeStatus0;
if ($status == SupplierProposal::STATUS_SIGNED) $colorseries[$status] = $badgeStatus4; }
if ($status == SupplierProposal::STATUS_NOTSIGNED) $colorseries[$status] = $badgeStatus9; if ($status == SupplierProposal::STATUS_VALIDATED) {
if ($status == SupplierProposal::STATUS_CLOSE) $colorseries[$status] = $badgeStatus6; $colorseries[$status] = $badgeStatus1;
}
if ($status == SupplierProposal::STATUS_SIGNED) {
$colorseries[$status] = $badgeStatus4;
}
if ($status == SupplierProposal::STATUS_NOTSIGNED) {
$colorseries[$status] = $badgeStatus9;
}
if ($status == SupplierProposal::STATUS_CLOSE) {
$colorseries[$status] = $badgeStatus6;
}
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax)) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$supplier_proposalstatic->LibStatut($status, 0).'</td>'; print '<td>'.$supplier_proposalstatic->LibStatut($status, 0).'</td>';
print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>'; print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
print '<tr><td class="center" colspan="2">'; print '<tr><td class="center" colspan="2">';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@ -170,32 +178,34 @@ if ($resql)
/* /*
* Draft askprice * Draft askprice
*/ */
if (!empty($conf->supplier_proposal->enabled)) if (!empty($conf->supplier_proposal->enabled)) {
{
$sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client"; $sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client";
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as c"; $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity = ".$conf->entity; $sql .= " AND c.entity = ".$conf->entity;
$sql .= " AND c.fk_statut = 0"; $sql .= " AND c.fk_statut = 0";
if ($socid) $sql .= " AND c.fk_soc = ".$socid; if ($socid) {
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $sql .= " AND c.fk_soc = ".$socid;
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th colspan="2">'.$langs->trans("DraftRequests").'</th></tr>'; print '<th colspan="2">'.$langs->trans("DraftRequests").'</th></tr>';
$langs->load("supplier_proposal"); $langs->load("supplier_proposal");
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num) if ($num) {
{
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -230,29 +240,32 @@ $sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid,
$sql .= " date_cloture as datec"; $sql .= " date_cloture as datec";
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as c"; $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity = ".$conf->entity; $sql .= " AND c.entity = ".$conf->entity;
//$sql.= " AND c.fk_statut > 2"; //$sql.= " AND c.fk_statut > 2";
if ($socid) $sql .= " AND c.fk_soc = ".$socid; if ($socid) {
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $sql .= " AND c.fk_soc = ".$socid;
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
$sql .= " ORDER BY c.tms DESC"; $sql .= " ORDER BY c.tms DESC";
$sql .= $db->plimit($max, 0); $sql .= $db->plimit($max, 0);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th colspan="4">'.$langs->trans("LastModifiedRequests", $max).'</th></tr>'; print '<th colspan="4">'.$langs->trans("LastModifiedRequests", $max).'</th></tr>';
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num) if ($num) {
{
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -292,14 +305,15 @@ if ($resql)
} }
} }
print "</table></div><br>"; print "</table></div><br>";
} else dol_print_error($db); } else {
dol_print_error($db);
}
/* /*
* Opened askprice * Opened askprice
*/ */
if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) {
{
$langs->load("supplier_proposal"); $langs->load("supplier_proposal");
$now = dol_now(); $now = dol_now();
@ -307,29 +321,32 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
$sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as supplier_proposalid, p.total_ttc, p.total_tva, p.total_ht, p.ref, p.fk_statut, p.datec as dp"; $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as supplier_proposalid, p.total_ttc, p.total_tva, p.total_ht, p.ref, p.fk_statut, p.datec as dp";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."supplier_proposal as p"; $sql .= ", ".MAIN_DB_PREFIX."supplier_proposal as p";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " WHERE p.fk_soc = s.rowid";
$sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
$sql .= " AND p.fk_statut = 1"; $sql .= " AND p.fk_statut = 1";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if (!$user->rights->societe->client->voir && !$socid) {
if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid) {
$sql .= " AND s.rowid = ".$socid;
}
$sql .= " ORDER BY p.rowid DESC"; $sql .= " ORDER BY p.rowid DESC";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$total = 0; $total = 0;
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
if ($num > 0) if ($num > 0) {
{
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><th colspan="5">'.$langs->trans("RequestsOpened").' <a href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?search_status=1"><span class="badge">'.$num.'</span></a></th></tr>'; print '<tr class="liste_titre"><th colspan="5">'.$langs->trans("RequestsOpened").' <a href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?search_status=1"><span class="badge">'.$num.'</span></a></th></tr>';
$nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
while ($i < $nbofloop) while ($i < $nbofloop) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -345,7 +362,9 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
print $supplier_proposalstatic->getNomUrl(1); print $supplier_proposalstatic->getNomUrl(1);
print '</td>'; print '</td>';
print '<td width="18" class="nobordernopadding nowrap">'; print '<td width="18" class="nobordernopadding nowrap">';
if ($db->jdate($obj->dfv) < ($now - $conf->supplier_proposal->cloture->warning_delay)) print img_warning($langs->trans("Late")); if ($db->jdate($obj->dfv) < ($now - $conf->supplier_proposal->cloture->warning_delay)) {
print img_warning($langs->trans("Late"));
}
print '</td>'; print '</td>';
print '<td width="16" class="center nobordernopadding">'; print '<td width="16" class="center nobordernopadding">';
$filename = dol_sanitizeFileName($obj->ref); $filename = dol_sanitizeFileName($obj->ref);
@ -370,11 +389,9 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
$i++; $i++;
$total += $obj->total_ttc; $total += $obj->total_ttc;
} }
if ($num > $nbofloop) if ($num > $nbofloop) {
{
print '<tr class="liste_total"><td colspan="5">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>"; print '<tr class="liste_total"><td colspan="5">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
} elseif ($total > 0) } elseif ($total > 0) {
{
print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total").'</td><td class="right">'.price($total)."</td><td>&nbsp;</td></tr>"; print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total").'</td><td class="right">'.price($total)."</td><td>&nbsp;</td></tr>";
} }
print "</table></div><br>"; print "</table></div><br>";

View File

@ -39,7 +39,9 @@ $id = GETPOST('id', 'int');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
// Security check // Security check
if (!empty($user->socid)) $socid = $user->socid; if (!empty($user->socid)) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'supplier_proposal', $id); $result = restrictedArea($user, 'supplier_proposal', $id);
@ -72,12 +74,10 @@ $morehtmlref = '<div class="refidno">';
// Thirdparty // Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->supplier_proposal->creer) if ($user->rights->supplier_proposal->creer) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,9 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
// Security check // Security check
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal'); $result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal');
$object = new SupplierProposal($db); $object = new SupplierProposal($db);
@ -64,19 +66,18 @@ llxHeader('', $langs->trans('CommRequest'), 'EN:Ask_Price_Supplier|FR:Demande_de
$form = new Form($db); $form = new Form($db);
if ($id > 0 || !empty($ref)) if ($id > 0 || !empty($ref)) {
{ if ($mesg) {
if ($mesg) print $mesg; print $mesg;
}
$now = dol_now(); $now = dol_now();
if ($object->fetch($id, $ref)) if ($object->fetch($id, $ref)) {
{
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$societe = new Societe($db); $societe = new Societe($db);
if ($societe->fetch($object->socid)) if ($societe->fetch($object->socid)) {
{
$head = supplier_proposal_prepare_head($object); $head = supplier_proposal_prepare_head($object);
print dol_get_fiche_head($head, 'note', $langs->trans('CommRequest'), -1, 'supplier_proposal'); print dol_get_fiche_head($head, 'note', $langs->trans('CommRequest'), -1, 'supplier_proposal');
@ -92,12 +93,10 @@ if ($id > 0 || !empty($ref))
// Thirdparty // Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->supplier_proposal->creer) if ($user->rights->supplier_proposal->creer) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';

View File

@ -18,8 +18,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) if (empty($conf) || !is_object($conf)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -35,12 +34,13 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$total = 0; $total = 0;
$ilink = 0; $ilink = 0;
foreach ($linkedObjectBlock as $key => $objectlink) foreach ($linkedObjectBlock as $key => $objectlink) {
{
$ilink++; $ilink++;
$trclass = 'oddeven'; $trclass = 'oddeven';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
$trclass .= ' liste_sub_total';
}
?> ?>
<tr class="<?php echo $trclass; ?>"> <tr class="<?php echo $trclass; ?>">
<td><?php echo $langs->trans("SupplierProposal"); ?></td> <td><?php echo $langs->trans("SupplierProposal"); ?></td>
@ -57,8 +57,7 @@ foreach ($linkedObjectBlock as $key => $objectlink)
</tr> </tr>
<?php <?php
} }
if (count($linkedObjectBlock) > 1) if (count($linkedObjectBlock) > 1) {
{
?> ?>
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>"> <tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>">
<td><?php echo $langs->trans("Total"); ?></td> <td><?php echo $langs->trans("Total"); ?></td>

View File

@ -25,7 +25,9 @@
*/ */
// Define DOL_DOCUMENT_ROOT // Define DOL_DOCUMENT_ROOT
if (!defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..'); if (!defined('DOL_DOCUMENT_ROOT')) {
define('DOL_DOCUMENT_ROOT', '..');
}
require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
@ -44,8 +46,7 @@ $_REQUEST["logtohtml"] = 1;
// Correction PHP_SELF (ex pour apache via caudium) car PHP_SELF doit valoir URL relative // Correction PHP_SELF (ex pour apache via caudium) car PHP_SELF doit valoir URL relative
// et non path absolu. // et non path absolu.
if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"]) if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"]) {
{
$_SERVER["PHP_SELF"] = $_SERVER["DOCUMENT_URI"]; $_SERVER["PHP_SELF"] = $_SERVER["DOCUMENT_URI"];
} }
@ -58,27 +59,28 @@ $conffiletoshowshort = "conf.php";
$conffile = "../conf/conf.php"; $conffile = "../conf/conf.php";
$conffiletoshow = "htdocs/conf/conf.php"; $conffiletoshow = "htdocs/conf/conf.php";
// For debian/redhat like systems // For debian/redhat like systems
if (!file_exists($conffile)) if (!file_exists($conffile)) {
{
$conffile = "/etc/dolibarr/conf.php"; $conffile = "/etc/dolibarr/conf.php";
$conffiletoshow = "/etc/dolibarr/conf.php"; $conffiletoshow = "/etc/dolibarr/conf.php";
} }
// Load conf file if it is already defined // Load conf file if it is already defined
if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8) // Test on filesize is to ensure that conf file is more that an empty template with just <?php in first line if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8) { // Test on filesize is to ensure that conf file is more that an empty template with just <?php in first line
{
$result = include_once $conffile; // Load conf file $result = include_once $conffile; // Load conf file
if ($result) if ($result) {
{ if (empty($dolibarr_main_db_type)) {
if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type = 'mysql'; // For backward compatibility $dolibarr_main_db_type = 'mysql'; // For backward compatibility
}
//Mysql driver support has been removed in favor of mysqli //Mysql driver support has been removed in favor of mysqli
if ($dolibarr_main_db_type == 'mysql') { if ($dolibarr_main_db_type == 'mysql') {
$dolibarr_main_db_type = 'mysqli'; $dolibarr_main_db_type = 'mysqli';
} }
if (empty($dolibarr_main_db_port) && ($dolibarr_main_db_type == 'mysqli')) $dolibarr_main_db_port = '3306'; // For backward compatibility if (empty($dolibarr_main_db_port) && ($dolibarr_main_db_type == 'mysqli')) {
$dolibarr_main_db_port = '3306'; // For backward compatibility
}
// Clean parameters // Clean parameters
$dolibarr_main_data_root = isset($dolibarr_main_data_root) ?trim($dolibarr_main_data_root) : ''; $dolibarr_main_data_root = isset($dolibarr_main_data_root) ?trim($dolibarr_main_data_root) : '';
@ -88,25 +90,31 @@ if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) >
$dolibarr_main_document_root_alt = isset($dolibarr_main_document_root_alt) ?trim($dolibarr_main_document_root_alt) : ''; $dolibarr_main_document_root_alt = isset($dolibarr_main_document_root_alt) ?trim($dolibarr_main_document_root_alt) : '';
// Remove last / or \ on directories or url value // Remove last / or \ on directories or url value
if (!empty($dolibarr_main_document_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root)) $dolibarr_main_document_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root); if (!empty($dolibarr_main_document_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root)) {
if (!empty($dolibarr_main_url_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root)) $dolibarr_main_url_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root); $dolibarr_main_document_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root);
if (!empty($dolibarr_main_data_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_data_root)) $dolibarr_main_data_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_data_root); }
if (!empty($dolibarr_main_document_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root_alt)) $dolibarr_main_document_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root_alt); if (!empty($dolibarr_main_url_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root)) {
if (!empty($dolibarr_main_url_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root_alt)) $dolibarr_main_url_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root_alt); $dolibarr_main_url_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root);
}
if (!empty($dolibarr_main_data_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_data_root)) {
$dolibarr_main_data_root = preg_replace('/[\\/]+$/', '', $dolibarr_main_data_root);
}
if (!empty($dolibarr_main_document_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_document_root_alt)) {
$dolibarr_main_document_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_document_root_alt);
}
if (!empty($dolibarr_main_url_root_alt) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root_alt)) {
$dolibarr_main_url_root_alt = preg_replace('/[\\/]+$/', '', $dolibarr_main_url_root_alt);
}
// Create conf object // Create conf object
if (!empty($dolibarr_main_document_root)) if (!empty($dolibarr_main_document_root)) {
{
$result = conf($dolibarr_main_document_root); $result = conf($dolibarr_main_document_root);
} }
// Load database driver // Load database driver
if ($result) if ($result) {
{ if (!empty($dolibarr_main_document_root) && !empty($dolibarr_main_db_type)) {
if (!empty($dolibarr_main_document_root) && !empty($dolibarr_main_db_type))
{
$result = include_once $dolibarr_main_document_root."/core/db/".$dolibarr_main_db_type.'.class.php'; $result = include_once $dolibarr_main_document_root."/core/db/".$dolibarr_main_db_type.'.class.php';
if (!$result) if (!$result) {
{
$includeconferror = 'ErrorBadValueForDolibarrMainDBType'; $includeconferror = 'ErrorBadValueForDolibarrMainDBType';
} }
} }
@ -120,7 +128,9 @@ if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) >
$conf->global->MAIN_LOGTOHTML = 1; $conf->global->MAIN_LOGTOHTML = 1;
// Define prefix // Define prefix
if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) $dolibarr_main_db_prefix = 'llx_'; if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) {
$dolibarr_main_db_prefix = 'llx_';
}
define('MAIN_DB_PREFIX', (isset($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : '')); define('MAIN_DB_PREFIX', (isset($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : ''));
define('DOL_CLASS_PATH', 'class/'); // Filsystem path to class dir define('DOL_CLASS_PATH', 'class/'); // Filsystem path to class dir
@ -128,27 +138,44 @@ define('DOL_DATA_ROOT', (isset($dolibarr_main_data_root) ? $dolibarr_main_data_r
define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root) ? $dolibarr_main_url_root : '')); // URL relative root define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root) ? $dolibarr_main_url_root : '')); // URL relative root
$uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http* $uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
$suburi = strstr($uri, '/'); // $suburi contains url without domain $suburi = strstr($uri, '/'); // $suburi contains url without domain
if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now '' if ($suburi == '/') {
$suburi = ''; // If $suburi is /, it is now ''
}
define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...) define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)
if (empty($character_set_client)) $character_set_client = "UTF-8"; if (empty($character_set_client)) {
$character_set_client = "UTF-8";
}
$conf->file->character_set_client = strtoupper($character_set_client); $conf->file->character_set_client = strtoupper($character_set_client);
if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : ''); // Old installation if (empty($dolibarr_main_db_character_set)) {
$dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : ''); // Old installation
}
$conf->db->character_set = $dolibarr_main_db_character_set; $conf->db->character_set = $dolibarr_main_db_character_set;
if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : ''); // Old installation if (empty($dolibarr_main_db_collation)) {
$dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : ''); // Old installation
}
$conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation; $conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation;
if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; if (empty($dolibarr_main_db_encryption)) {
$dolibarr_main_db_encryption = 0;
}
$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; if (empty($dolibarr_main_db_cryptkey)) {
$dolibarr_main_db_cryptkey = '';
}
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
if (empty($conf->db->user)) $conf->db->user = ''; if (empty($conf->db->user)) {
$conf->db->user = '';
}
// Defini objet langs // Defini objet langs
$langs = new Translate('..', $conf); $langs = new Translate('..', $conf);
if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); if (GETPOST('lang', 'aZ09')) {
else $langs->setDefaultLang('auto'); $langs->setDefaultLang(GETPOST('lang', 'aZ09'));
} else {
$langs->setDefaultLang('auto');
}
$bc[false] = ' class="bg1"'; $bc[false] = ' class="bg1"';
$bc[true] = ' class="bg2"'; $bc[true] = ' class="bg2"';
@ -172,7 +199,9 @@ function conf($dolibarr_main_document_root)
global $character_set_client; global $character_set_client;
$return = include_once $dolibarr_main_document_root.'/core/class/conf.class.php'; $return = include_once $dolibarr_main_document_root.'/core/class/conf.class.php';
if (!$return) return -1; if (!$return) {
return -1;
}
$conf = new Conf(); $conf = new Conf();
$conf->db->type = trim($dolibarr_main_db_type); $conf->db->type = trim($dolibarr_main_db_type);
@ -182,7 +211,9 @@ function conf($dolibarr_main_document_root)
$conf->db->user = trim($dolibarr_main_db_user); $conf->db->user = trim($dolibarr_main_db_user);
$conf->db->pass = trim($dolibarr_main_db_pass); $conf->db->pass = trim($dolibarr_main_db_pass);
if (empty($conf->db->dolibarr_main_db_collation)) $conf->db->dolibarr_main_db_collation = 'utf8_unicode_ci'; if (empty($conf->db->dolibarr_main_db_collation)) {
$conf->db->dolibarr_main_db_collation = 'utf8_unicode_ci';
}
return 1; return 1;
} }

View File

@ -31,9 +31,12 @@
include_once 'inc.php'; include_once 'inc.php';
$uri = preg_replace('/^http(s?):\/\//i', '', $dolibarr_main_url_root); $uri = preg_replace('/^http(s?):\/\//i', '', $dolibarr_main_url_root);
$pos = strstr($uri, '/'); // $pos contient alors url sans nom domaine $pos = strstr($uri, '/'); // $pos contient alors url sans nom domaine
if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a '' if ($pos == '/') {
if (!defined('DOL_URL_ROOT')) $pos = ''; // si $pos vaut /, on le met a ''
}
if (!defined('DOL_URL_ROOT')) {
define('DOL_URL_ROOT', $pos); // URL racine relative define('DOL_URL_ROOT', $pos); // URL racine relative
}
$langs->loadLangs(array("other", $langs->load("help"))); $langs->loadLangs(array("other", $langs->load("help")));
@ -49,10 +52,18 @@ print $langs->trans("HelpCenterDesc2")."<br>\n";
print '<br>'; print '<br>';
$homeurl = DOL_URL_ROOT.'/'; $homeurl = DOL_URL_ROOT.'/';
if (GETPOST('dol_hide_toptmenu')) $homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_hide_toptmenu=1'; if (GETPOST('dol_hide_toptmenu')) {
if (GETPOST('dol_hide_leftmenu')) $homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_hide_leftmenu=1'; $homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_hide_toptmenu=1';
if (GETPOST('dol_no_mouse_hover')) $homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_no_mouse_hover=1'; }
if (GETPOST('dol_use_jmobile')) $homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_use_jmobile=1'; if (GETPOST('dol_hide_leftmenu')) {
$homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_hide_leftmenu=1';
}
if (GETPOST('dol_no_mouse_hover')) {
$homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_no_mouse_hover=1';
}
if (GETPOST('dol_use_jmobile')) {
$homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_use_jmobile=1';
}
print $langs->trans("ToGoBackToDolibarr", $homeurl); print $langs->trans("ToGoBackToDolibarr", $homeurl);
print '<br><br>'; print '<br><br>';
@ -86,20 +97,38 @@ print '<td align="center" valign="middle">';
print '<table class="nocellnopadd">'; print '<table class="nocellnopadd">';
print '<tr><td align="center">'; print '<tr><td align="center">';
$urlwiki = 'https://wiki.dolibarr.org'; $urlwiki = 'https://wiki.dolibarr.org';
if (preg_match('/fr/i', $langs->defaultlang)) $urlwiki = 'https://wiki.dolibarr.org/index.php/Accueil'; if (preg_match('/fr/i', $langs->defaultlang)) {
if (preg_match('/es/i', $langs->defaultlang)) $urlwiki = 'https://wiki.dolibarr.org/index.php/Portada'; $urlwiki = 'https://wiki.dolibarr.org/index.php/Accueil';
if (preg_match('/de/i', $langs->defaultlang)) $urlwiki = 'https://wiki.dolibarr.org/index.php/Hauptseite'; }
if (preg_match('/es/i', $langs->defaultlang)) {
$urlwiki = 'https://wiki.dolibarr.org/index.php/Portada';
}
if (preg_match('/de/i', $langs->defaultlang)) {
$urlwiki = 'https://wiki.dolibarr.org/index.php/Hauptseite';
}
print '<br>'.$langs->trans("ForDocumentationSeeWiki", $urlwiki, $urlwiki); print '<br>'.$langs->trans("ForDocumentationSeeWiki", $urlwiki, $urlwiki);
print '<br>'; print '<br>';
$urlforum = 'https://www.dolibarr.org/forum/'; $urlforum = 'https://www.dolibarr.org/forum/';
$urlforumlocal = 'https://www.dolibarr.org/forum/'; $urlforumlocal = 'https://www.dolibarr.org/forum/';
if (preg_match('/fr/i', $langs->defaultlang)) $urlforumlocal = 'https://www.dolibarr.fr/forum/'; if (preg_match('/fr/i', $langs->defaultlang)) {
if (preg_match('/es/i', $langs->defaultlang)) $urlforumlocal = 'https://www.dolibarr.es/foro/'; $urlforumlocal = 'https://www.dolibarr.fr/forum/';
if (preg_match('/it/i', $langs->defaultlang)) $urlforumlocal = 'http://www.dolibarr.it/forum/'; }
if (preg_match('/gr/i', $langs->defaultlang)) $urlforumlocal = 'https://www.dolibarr.gr/forum/'; if (preg_match('/es/i', $langs->defaultlang)) {
if (preg_match('/de/i', $langs->defaultlang)) $urlforumlocal = 'https://www.dolibarr.de/forum/'; $urlforumlocal = 'https://www.dolibarr.es/foro/';
}
if (preg_match('/it/i', $langs->defaultlang)) {
$urlforumlocal = 'http://www.dolibarr.it/forum/';
}
if (preg_match('/gr/i', $langs->defaultlang)) {
$urlforumlocal = 'https://www.dolibarr.gr/forum/';
}
if (preg_match('/de/i', $langs->defaultlang)) {
$urlforumlocal = 'https://www.dolibarr.de/forum/';
}
print '<br>'.$langs->trans("ForAnswersSeeForum", $urlforumlocal, $urlforumlocal).'<br>'; print '<br>'.$langs->trans("ForAnswersSeeForum", $urlforumlocal, $urlforumlocal).'<br>';
if ($urlforumlocal != $urlforum) print '<b><a href="'.$urlforum.'">'.$urlforum.'</a></b>'; if ($urlforumlocal != $urlforum) {
print '<b><a href="'.$urlforum.'">'.$urlforum.'</a></b>';
}
print '</td></tr></table>'; print '</td></tr></table>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';

View File

@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
// Security check // Security check
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$langs->loadLangs(array("admin", "cashdesk", "commercial")); $langs->loadLangs(array("admin", "cashdesk", "commercial"));
@ -38,8 +40,7 @@ $langs->loadLangs(array("admin", "cashdesk", "commercial"));
* Actions * Actions
*/ */
if (GETPOST('action', 'alpha') == 'set') if (GETPOST('action', 'alpha') == 'set') {
{
$db->begin(); $db->begin();
$res = dolibarr_set_const($db, "TAKEPOS_COLOR_THEME", GETPOST('TAKEPOS_COLOR_THEME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_COLOR_THEME", GETPOST('TAKEPOS_COLOR_THEME', 'alpha'), 'chaine', 0, '', $conf->entity);
@ -47,18 +48,18 @@ 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 {
$db->rollback(); $db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif (GETPOST('action', 'alpha') == 'setmethod') } elseif (GETPOST('action', 'alpha') == 'setmethod') {
{
dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity);
} }

View File

@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
// Security check // Security check
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$langs->loadLangs(array("admin", "cashdesk", "printing")); $langs->loadLangs(array("admin", "cashdesk", "printing"));
@ -41,22 +43,22 @@ $res = 0;
* Actions * Actions
*/ */
if (GETPOST('action', 'alpha') == 'set') if (GETPOST('action', 'alpha') == 'set') {
{
$db->begin(); $db->begin();
dol_syslog("admin/bar"); dol_syslog("admin/bar");
$suplement_category = GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha'); $suplement_category = GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha');
if ($suplement_category < 0) $suplement_category = 0; if ($suplement_category < 0) {
$suplement_category = 0;
}
$res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", $suplement_category, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", $suplement_category, 'chaine', 0, '', $conf->entity);
if ($res <= 0) { if ($res <= 0) {
$error++; $error++;
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -153,8 +155,7 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) {
print ajax_constantonoff("TAKEPOS_SUPPLEMENTS", array(), $conf->entity, 0, 0, 1, 0); print ajax_constantonoff("TAKEPOS_SUPPLEMENTS", array(), $conf->entity, 0, 0, 1, 0);
print '</td></tr>'; print '</td></tr>';
if ($conf->global->TAKEPOS_SUPPLEMENTS) if ($conf->global->TAKEPOS_SUPPLEMENTS) {
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("SupplementCategory"); print $langs->trans("SupplementCategory");
print '</td>'; print '</td>';
@ -187,8 +188,7 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) {
} }
if ($conf->global->TAKEPOS_BAR_RESTAURANT) { if ($conf->global->TAKEPOS_BAR_RESTAURANT) {
if ($conf->global->TAKEPOS_QR_MENU) if ($conf->global->TAKEPOS_QR_MENU) {
{
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
print '<br>'; print '<br>';
@ -205,8 +205,7 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) {
print '</table>'; print '</table>';
} }
if ($conf->global->TAKEPOS_AUTO_ORDER) if ($conf->global->TAKEPOS_AUTO_ORDER) {
{
print '<br>'; print '<br>';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';

View File

@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
$langs->loadLangs(array("main"), "categories", "takepos", "printing"); $langs->loadLangs(array("main"), "categories", "takepos", "printing");
if (!$user->rights->categorie->lire) accessforbidden(); if (!$user->rights->categorie->lire) {
accessforbidden();
}
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT); $type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT);
@ -44,32 +46,40 @@ $printer1 = GETPOST('printer1', 'alpha');
$printer2 = GETPOST('printer2', 'alpha'); $printer2 = GETPOST('printer2', 'alpha');
$printer3 = GETPOST('printer3', 'alpha'); $printer3 = GETPOST('printer3', 'alpha');
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility if (is_numeric($type)) {
$type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
}
/* /*
* Actions * Actions
*/ */
if ($action == "SavePrinter1") { if ($action == "SavePrinter1") {
$printedcategories = ";"; $printedcategories = ";";
if (is_array($printer1)) foreach ($printer1 as $cat) { if (is_array($printer1)) {
foreach ($printer1 as $cat) {
$printedcategories = $printedcategories.$cat.";"; $printedcategories = $printedcategories.$cat.";";
} }
}
dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_1", $printedcategories, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_1", $printedcategories, 'chaine', 0, '', $conf->entity);
} }
if ($action == "SavePrinter2") { if ($action == "SavePrinter2") {
$printedcategories = ";"; $printedcategories = ";";
if (is_array($printer2)) foreach ($printer2 as $cat) { if (is_array($printer2)) {
foreach ($printer2 as $cat) {
$printedcategories = $printedcategories.$cat.";"; $printedcategories = $printedcategories.$cat.";";
} }
}
dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_2", $printedcategories, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_2", $printedcategories, 'chaine', 0, '', $conf->entity);
} }
if ($action == "SavePrinter3") { if ($action == "SavePrinter3") {
$printedcategories = ";"; $printedcategories = ";";
if (is_array($printer3)) foreach ($printer3 as $cat) { if (is_array($printer3)) {
foreach ($printer3 as $cat) {
$printedcategories = $printedcategories.$cat.";"; $printedcategories = $printedcategories.$cat.";";
} }
}
dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_3", $printedcategories, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_3", $printedcategories, 'chaine', 0, '', $conf->entity);
} }
@ -145,8 +155,7 @@ $fulltree = $cate_arbo;
// Define data (format for treeview) // Define data (format for treeview)
$data = array(); $data = array();
$data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); $data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>'');
foreach ($fulltree as $key => $val) foreach ($fulltree as $key => $val) {
{
$categstatic->id = $val['id']; $categstatic->id = $val['id'];
$categstatic->ref = $val['label']; $categstatic->ref = $val['label'];
$categstatic->color = $val['color']; $categstatic->color = $val['color'];
@ -168,13 +177,18 @@ print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 1</td><td></td><
print '</td></tr>'; print '</td></tr>';
$nbofentries = (count($data) - 1); $nbofentries = (count($data) - 1);
print '<form action="orderprinters.php">'; print '<form action="orderprinters.php">';
if ($nbofentries > 0) if ($nbofentries > 0) {
{
print '<tr class="pair"><td colspan="3">'; print '<tr class="pair"><td colspan="3">';
print '<input type="hidden" name="action" value="SavePrinter1">'; print '<input type="hidden" name="action" value="SavePrinter1">';
foreach ($data as $row) { foreach ($data as $row) {
if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_1, ';'.$row["rowid"].';') !== false) $checked = 'checked'; else $checked = ''; if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_1, ';'.$row["rowid"].';') !== false) {
if ($row["fk_menu"] == 0) print '<input type="checkbox" name="printer1[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>'; $checked = 'checked';
} else {
$checked = '';
}
if ($row["fk_menu"] == 0) {
print '<input type="checkbox" name="printer1[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
}
} }
print '</td></tr>'; print '</td></tr>';
} else { } else {
@ -196,13 +210,18 @@ print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 2</td><td></td><
print '</td></tr>'; print '</td></tr>';
$nbofentries = (count($data) - 1); $nbofentries = (count($data) - 1);
print '<form action="orderprinters.php">'; print '<form action="orderprinters.php">';
if ($nbofentries > 0) if ($nbofentries > 0) {
{
print '<tr class="pair"><td colspan="3">'; print '<tr class="pair"><td colspan="3">';
print '<input type="hidden" name="action" value="SavePrinter2">'; print '<input type="hidden" name="action" value="SavePrinter2">';
foreach ($data as $row) { foreach ($data as $row) {
if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_2, ';'.$row["rowid"].';') !== false) $checked = 'checked'; else $checked = ''; if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_2, ';'.$row["rowid"].';') !== false) {
if ($row["fk_menu"] == 0) print '<input type="checkbox" name="printer2[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>'; $checked = 'checked';
} else {
$checked = '';
}
if ($row["fk_menu"] == 0) {
print '<input type="checkbox" name="printer2[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
}
} }
print '</td></tr>'; print '</td></tr>';
} else { } else {
@ -224,13 +243,18 @@ print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 3</td><td></td><
print '</td></tr>'; print '</td></tr>';
$nbofentries = (count($data) - 1); $nbofentries = (count($data) - 1);
print '<form action="orderprinters.php">'; print '<form action="orderprinters.php">';
if ($nbofentries > 0) if ($nbofentries > 0) {
{
print '<tr class="pair"><td colspan="3">'; print '<tr class="pair"><td colspan="3">';
print '<input type="hidden" name="action" value="SavePrinter3">'; print '<input type="hidden" name="action" value="SavePrinter3">';
foreach ($data as $row) { foreach ($data as $row) {
if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_3, ';'.$row["rowid"].';') !== false) $checked = 'checked'; else $checked = ''; if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_3, ';'.$row["rowid"].';') !== false) {
if ($row["fk_menu"] == 0) print '<input type="checkbox" name="printer3[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>'; $checked = 'checked';
} else {
$checked = '';
}
if ($row["fk_menu"] == 0) {
print '<input type="checkbox" name="printer3[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
}
} }
print '</td></tr>'; print '</td></tr>';
} else { } else {

View File

@ -36,7 +36,9 @@ if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) {
} }
// Security check // Security check
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$langs->loadLangs(array("admin", "cashdesk")); $langs->loadLangs(array("admin", "cashdesk"));
@ -61,7 +63,9 @@ if ($resql) {
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_SERVICES", GETPOST('CASHDESK_SERVICES', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_SERVICES", GETPOST('CASHDESK_SERVICES', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_ROOT_CATEGORY_ID", GETPOST('TAKEPOS_ROOT_CATEGORY_ID', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ROOT_CATEGORY_ID", GETPOST('TAKEPOS_ROOT_CATEGORY_ID', 'alpha'), 'chaine', 0, '', $conf->entity);
@ -86,7 +90,9 @@ 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();

View File

@ -24,7 +24,9 @@
require '../../main.inc.php'; require '../../main.inc.php';
// Security check // Security check
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$langs->load("cashdesk"); $langs->load("cashdesk");
@ -37,8 +39,7 @@ print '<center>';
if (GETPOSTISSET("id")) { if (GETPOSTISSET("id")) {
print '<h1><b>'.$langs->trans("ScanToOrder").'</b></h1>'; print '<h1><b>'.$langs->trans("ScanToOrder").'</b></h1>';
print "<img src='".DOL_URL_ROOT."/takepos/genimg/qr.php?key=".dol_encode($id)."' width='30%'>"; print "<img src='".DOL_URL_ROOT."/takepos/genimg/qr.php?key=".dol_encode($id)."' width='30%'>";
} } else {
else {
print '<h1><b>'.$langs->trans("ScanToMenu").'</b></h1>'; print '<h1><b>'.$langs->trans("ScanToMenu").'</b></h1>';
print "<img src='".DOL_URL_ROOT."/takepos/genimg/qr.php' width='30%'>"; print "<img src='".DOL_URL_ROOT."/takepos/genimg/qr.php' width='30%'>";
} }

View File

@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
// Security check // Security check
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$langs->loadLangs(array("admin", "cashdesk", "commercial")); $langs->loadLangs(array("admin", "cashdesk", "commercial"));
@ -39,8 +41,7 @@ $langs->loadLangs(array("admin", "cashdesk", "commercial"));
* Actions * Actions
*/ */
if (GETPOST('action', 'alpha') == 'set') if (GETPOST('action', 'alpha') == 'set') {
{
$db->begin(); $db->begin();
$res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'alpha'), 'chaine', 0, '', $conf->entity);
@ -53,21 +54,23 @@ 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 {
$db->rollback(); $db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif (GETPOST('action', 'alpha') == 'setmethod') } elseif (GETPOST('action', 'alpha') == 'setmethod') {
{
dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity);
// TakePOS connector require ReceiptPrinter module // TakePOS connector require ReceiptPrinter module
if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector" && !$conf->receiptprinter->enabled) activateModule("modReceiptPrinter"); if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector" && !$conf->receiptprinter->enabled) {
activateModule("modReceiptPrinter");
}
} }
@ -103,8 +106,7 @@ print $langs->trans('Browser');
print '<td>'; print '<td>';
print $langs->trans('BrowserMethodDescription'); print $langs->trans('BrowserMethodDescription');
print '</td><td class="right">'; print '</td><td class="right">';
if ($conf->global->TAKEPOS_PRINT_METHOD == "browser") if ($conf->global->TAKEPOS_PRINT_METHOD == "browser") {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmethod&token='.newToken().'&value=browser">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmethod&token='.newToken().'&value=browser">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
@ -138,8 +140,7 @@ print "TakePOS Connector";
print '<td>'; print '<td>';
print $langs->trans('TakeposConnectorMethodDescription'); print $langs->trans('TakeposConnectorMethodDescription');
print '</td><td class="right">'; print '</td><td class="right">';
if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmethod&token='.newToken().'&value=takeposconnector">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmethod&token='.newToken().'&value=takeposconnector">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
@ -177,15 +178,16 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "browser" || $conf->global->TAKEPOS_P
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Header"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Header"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
print '</td><td>'; print '</td><td>';
$variablename = 'TAKEPOS_HEADER'; $variablename = 'TAKEPOS_HEADER';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
@ -198,8 +200,7 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "browser" || $conf->global->TAKEPOS_P
print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Footer"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Footer"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
print '</td><td>'; print '</td><td>';
$variablename = 'TAKEPOS_FOOTER'; $variablename = 'TAKEPOS_FOOTER';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -32,15 +32,16 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.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) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$langs->loadLangs(array("admin", "cashdesk")); $langs->loadLangs(array("admin", "cashdesk"));
@ -67,10 +68,11 @@ $action = GETPOST('action', 'aZ09');
$error = 0; $error = 0;
if ($action == 'set') if ($action == 'set') {
{
$db->begin(); $db->begin();
if (GETPOST('socid', 'int') < 0) $_POST["socid"] = ''; if (GETPOST('socid', 'int') < 0) {
$_POST["socid"] = '';
}
$res = dolibarr_set_const($db, "TAKEPOS_ROOT_CATEGORY_ID", GETPOST('TAKEPOS_ROOT_CATEGORY_ID', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ROOT_CATEGORY_ID", GETPOST('TAKEPOS_ROOT_CATEGORY_ID', 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha'), 'chaine', 0, '', $conf->entity);
@ -86,10 +88,11 @@ if ($action == '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();
} else { } else {
$db->rollback(); $db->rollback();
@ -97,7 +100,9 @@ if ($action == 'set')
} elseif ($action == 'updateMask') { } elseif ($action == 'updateMask') {
$maskconst = GETPOST('maskconst', 'alpha'); $maskconst = GETPOST('maskconst', 'alpha');
$maskvalue = GETPOST('maskvalue', 'alpha'); $maskvalue = GETPOST('maskvalue', 'alpha');
if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if ($maskconst) {
$res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) { if (!($res > 0)) {
$error++; $error++;
} }
@ -146,21 +151,16 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/takepos/"); $dir = dol_buildpath($reldir."core/modules/takepos/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{
$var = true; $var = true;
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false) {
{ if (substr($file, 0, 16) == 'mod_takepos_ref_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
if (substr($file, 0, 16) == 'mod_takepos_ref_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php'; require_once $dir.$file.'.php';
@ -168,11 +168,14 @@ foreach ($dirmodels as $reldir)
$module = new $file; $module = new $file;
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
@ -183,13 +186,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td align="center">'; print '<td align="center">';
if ($conf->global->TAKEPOS_REF_ADDON == "$file") if ($conf->global->TAKEPOS_REF_ADDON == "$file") {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setrefmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setrefmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
@ -211,8 +216,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -256,8 +262,7 @@ print $form->selectarray('TAKEPOS_NUM_TERMINALS', $array, (empty($conf->global->
print "</td></tr>\n"; print "</td></tr>\n";
// Services // Services
if (!empty($conf->service->enabled)) if (!empty($conf->service->enabled)) {
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("CashdeskShowServices"); print $langs->trans("CashdeskShowServices");
print '<td colspan="2">'; print '<td colspan="2">';
@ -292,7 +297,9 @@ print "</td></tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
// Payment numpad // Payment numpad

View File

@ -31,15 +31,16 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
$terminal = GETPOST('terminal', 'int'); $terminal = GETPOST('terminal', 'int');
// If socid provided by ajax company selector // If socid provided by ajax company selector
if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal.'_id'])) if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal.'_id'])) {
{
$_GET['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha'); $_GET['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
$_POST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha'); $_POST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
$_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha'); $_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
} }
// Security check // Security check
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$langs->loadLangs(array("admin", "cashdesk", "printing", "receiptprinter")); $langs->loadLangs(array("admin", "cashdesk", "printing", "receiptprinter"));
@ -64,10 +65,11 @@ $terminaltouse = $terminal;
* 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".$terminaltouse, (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY".$terminaltouse, (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity);
@ -78,7 +80,9 @@ if (GETPOST('action', 'alpha') == 'set')
$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_SUMUP".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_SUMUP".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
} }
foreach ($paiements as $modep) { foreach ($paiements as $modep) {
if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) continue; if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) {
continue;
}
$name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse; $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
$res = dolibarr_set_const($db, $name, (GETPOST($name, 'alpha') > 0 ? GETPOST($name, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, $name, (GETPOST($name, 'alpha') > 0 ? GETPOST($name, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
} }
@ -101,10 +105,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 {
@ -147,45 +152,55 @@ print $form->select_company($conf->global->{'CASHDESK_ID_THIRDPARTY'.$terminalto
print '</td></tr>'; print '</td></tr>';
$atleastonefound = 0; $atleastonefound = 0;
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>'; print '<td>';
$form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 0, "courant=2", 1); $form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 0, "courant=2", 1);
if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse})) $atleastonefound++; if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse})) {
$atleastonefound++;
}
print '</td></tr>'; print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
print '<td>'; print '<td>';
$form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 0, "courant=1", 1); $form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 0, "courant=1", 1);
if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse})) $atleastonefound++; if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse})) {
$atleastonefound++;
}
print '</td></tr>'; print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
print '<td>'; print '<td>';
$form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 0, "courant=1", 1); $form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 0, "courant=1", 1);
if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse})) $atleastonefound++; if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse})) {
$atleastonefound++;
}
print '</td></tr>'; print '</td></tr>';
if ($conf->global->TAKEPOS_ENABLE_SUMUP) { if ($conf->global->TAKEPOS_ENABLE_SUMUP) {
print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSumup").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSumup").'</td>';
print '<td>'; print '<td>';
$form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 0, "courant=1", 1); $form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 0, "courant=1", 1);
if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse})) $atleastonefound++; if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse})) {
$atleastonefound++;
}
print '</td></tr>'; print '</td></tr>';
} }
foreach ($paiements as $modep) { foreach ($paiements as $modep) {
if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) continue; // Already managed before if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) {
continue; // Already managed before
}
$name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse; $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->label).'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->label).'</td>';
print '<td>'; print '<td>';
if (!empty($conf->global->$name)) $atleastonefound++; if (!empty($conf->global->$name)) {
$atleastonefound++;
}
$cour = preg_match('/^LIQ.*/', $modep->code) ? 2 : 1; $cour = preg_match('/^LIQ.*/', $modep->code) ? 2 : 1;
$form->select_comptes($conf->global->$name, $name, 0, "courant=".$cour, 1); $form->select_comptes($conf->global->$name, $name, 0, "courant=".$cour, 1);
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>'; print '<td>';
if (empty($conf->productbatch->enabled) || !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { if (empty($conf->productbatch->enabled) || !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
@ -204,8 +219,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 class="minwidth300">'; print '<td class="minwidth300">';
if (!$disabled) if (!$disabled) {
{
print $formproduct->selectWarehouses($conf->global->{'CASHDESK_ID_WAREHOUSE'.$terminal}, 'CASHDESK_ID_WAREHOUSE'.$terminal, '', 1, $disabled, 0, '', 0, 0, array(), 'maxwidth250'); print $formproduct->selectWarehouses($conf->global->{'CASHDESK_ID_WAREHOUSE'.$terminal}, 'CASHDESK_ID_WAREHOUSE'.$terminal, '', 1, $disabled, 0, '', 0, 0, array(), 'maxwidth250');
print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?&terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle"></span></a>'; print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?&terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
} else { } else {
@ -279,44 +293,42 @@ if ($conf->global->TAKEPOS_ADDON == "terminal") {
print '<td colspan="2">'; print '<td colspan="2">';
$array = array(0=>$langs->trans("Default")); $array = array(0=>$langs->trans("Default"));
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/facture/"); $dir = dol_buildpath($reldir."core/modules/facture/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) {
{
if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
{
$filebis = $file; $filebis = $file;
$classname = preg_replace('/\.php$/', '', $file); $classname = preg_replace('/\.php$/', '', $file);
// For compatibility // For compatibility
if (!is_file($dir.$filebis)) if (!is_file($dir.$filebis)) {
{
$filebis = $file."/".$file.".modules.php"; $filebis = $file."/".$file.".modules.php";
$classname = "mod_facture_".$file; $classname = "mod_facture_".$file;
} }
// Check if there is a filter on country // Check if there is a filter on country
preg_match('/\-(.*)_(.*)$/', $classname, $reg); preg_match('/\-(.*)_(.*)$/', $classname, $reg);
if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
continue;
}
$classname = preg_replace('/\-.*$/', '', $classname); $classname = preg_replace('/\-.*$/', '', $classname);
if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
{
// Charging the numbering class // Charging the numbering class
require_once $dir.$filebis; require_once $dir.$filebis;
$module = new $classname($db); $module = new $classname($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
$array[preg_replace('/\-.*$/', '', preg_replace('/\.php$/', '', $file))] = preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); $array[preg_replace('/\-.*$/', '', preg_replace('/\.php$/', '', $file))] = preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
} }
} }
@ -339,7 +351,9 @@ print '</div>';
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans('Translation'); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans('Translation');
$htmltext = '<i>'.$langs->trans('AvailableVariables').':<br>'; $htmltext = '<i>'.$langs->trans('AvailableVariables').':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<br>'; print '<br>';
@ -386,8 +400,7 @@ print '</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
if ($atleastonefound == 0 && !empty($conf->banque->enabled)) if ($atleastonefound == 0 && !empty($conf->banque->enabled)) {
{
print info_admin($langs->trans("AtLeastOneDefaultBankAccountMandatory"), 0, 0, 'error'); print info_admin($langs->trans("AtLeastOneDefaultBankAccountMandatory"), 0, 0, 'error');
} }

View File

@ -25,12 +25,24 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOCSRFCHECK')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); define('NOCSRFCHECK', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); define('NOTOKENRENEWAL', '1');
if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); }
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOBROWSERNOTIF')) {
define('NOBROWSERNOTIF', '1');
}
require '../../main.inc.php'; // Load $user and permissions require '../../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
@ -51,16 +63,15 @@ if (empty($user->rights->takepos->run)) {
if ($action == 'getProducts') { if ($action == 'getProducts') {
$object = new Categorie($db); $object = new Categorie($db);
if ($category == "supplements") $category = $conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY; if ($category == "supplements") {
$category = $conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY;
}
$result = $object->fetch($category); $result = $object->fetch($category);
if ($result > 0) if ($result > 0) {
{
$prods = $object->getObjectsInCateg("product", 0, 0, 0, $conf->global->TAKEPOS_SORTPRODUCTFIELD, 'ASC'); $prods = $object->getObjectsInCateg("product", 0, 0, 0, $conf->global->TAKEPOS_SORTPRODUCTFIELD, 'ASC');
// Removed properties we don't need // Removed properties we don't need
if (is_array($prods) && count($prods) > 0) if (is_array($prods) && count($prods) > 0) {
{ foreach ($prods as $prod) {
foreach ($prods as $prod)
{
unset($prod->fields); unset($prod->fields);
unset($prod->db); unset($prod->db);
} }
@ -95,8 +106,7 @@ if ($action == 'getProducts') {
//$result = $object->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID); //$result = $object->fetch($conf->global->TAKEPOS_ROOT_CATEGORY_ID);
$arrayofcateg = $object->get_full_arbo('product', $conf->global->TAKEPOS_ROOT_CATEGORY_ID, 1); $arrayofcateg = $object->get_full_arbo('product', $conf->global->TAKEPOS_ROOT_CATEGORY_ID, 1);
if (is_array($arrayofcateg) && count($arrayofcateg) > 0) { if (is_array($arrayofcateg) && count($arrayofcateg) > 0) {
foreach ($arrayofcateg as $val) foreach ($arrayofcateg as $val) {
{
$filteroncategids .= ($filteroncategids ? ', ' : '').$val['id']; $filteroncategids .= ($filteroncategids ? ', ' : '').$val['id'];
} }
} }
@ -110,8 +120,7 @@ if ($action == 'getProducts') {
$sql .= ' AND tosell = 1'; $sql .= ' AND tosell = 1';
$sql .= natural_search(array('ref', 'label', 'barcode'), $term); $sql .= natural_search(array('ref', 'label', 'barcode'), $term);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$rows = array(); $rows = array();
while ($obj = $db->fetch_object($resql)) { while ($obj = $db->fetch_object($resql)) {
$rows[] = array( $rows[] = array(

View File

@ -27,14 +27,26 @@
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled because need to load personalized language //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled because need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled to increase speed. Language code is found on url. //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled to increase speed. Language code is found on url.
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); if (!defined('NOCSRFCHECK')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); define('NOCSRFCHECK', 1);
if (!defined('NOLOGIN')) define('NOLOGIN', 1); // File must be accessed by logon page so without login }
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1);
}
if (!defined('NOLOGIN')) {
define('NOLOGIN', 1); // File must be accessed by logon page so without login
}
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We need top menu content //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We need top menu content
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); if (!defined('NOREQUIREHTML')) {
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); define('NOREQUIREHTML', 1);
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
define('ISLOADEDBYSTEELSHEET', '1'); define('ISLOADEDBYSTEELSHEET', '1');
@ -48,12 +60,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Define css type // Define css type
top_httphead('text/css'); top_httphead('text/css');
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate'); if (empty($dolibarr_nocache)) {
else header('Cache-Control: no-cache'); header('Cache-Control: max-age=10800, public, must-revalidate');
} else {
header('Cache-Control: no-cache');
}
require DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; require DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
if (defined('THEME_ONLY_CONSTANT')) return; if (defined('THEME_ONLY_CONSTANT')) {
return;
}
?> ?>

View File

@ -25,11 +25,21 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOCSRFCHECK')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); define('NOCSRFCHECK', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
require '../main.inc.php'; // Load $user and permissions require '../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@ -37,7 +47,9 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$langs->loadLangs(array("bills", "orders", "commercial", "cashdesk")); $langs->loadLangs(array("bills", "orders", "commercial", "cashdesk"));
$floor = GETPOST('floor', 'int'); $floor = GETPOST('floor', 'int');
if ($floor == "") $floor = 1; if ($floor == "") {
$floor = 1;
}
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$left = GETPOST('left', 'alpha'); $left = GETPOST('left', 'alpha');
@ -57,38 +69,45 @@ if (empty($user->rights->takepos->run)) {
* Actions * Actions
*/ */
if ($action == "getTables") if ($action == "getTables") {
{
$sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables where floor=".$floor; $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables where floor=".$floor;
$resql = $db->query($sql); $resql = $db->query($sql);
$rows = array(); $rows = array();
while ($row = $db->fetch_array($resql)) { while ($row = $db->fetch_array($resql)) {
$invoice = new Facture($db); $invoice = new Facture($db);
$result = $invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$row['rowid'].')'); $result = $invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$row['rowid'].')');
if ($result > 0) $row['occupied'] = "red"; if ($result > 0) {
$row['occupied'] = "red";
}
$rows[] = $row; $rows[] = $row;
} }
echo json_encode($rows); echo json_encode($rows);
exit; exit;
} }
if ($action == "update") if ($action == "update") {
{ if ($left > 95) {
if ($left > 95) $left = 95; $left = 95;
if ($top > 95) $top = 95; }
if ($left > 3 or $top > 4) $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set leftpos=".$left.", toppos=".$top." WHERE rowid='".$place."'"); if ($top > 95) {
else $db->query("DELETE from ".MAIN_DB_PREFIX."takepos_floor_tables where rowid='".$place."'"); $top = 95;
}
if ($left > 3 or $top > 4) {
$db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set leftpos=".$left.", toppos=".$top." WHERE rowid='".$place."'");
} else {
$db->query("DELETE from ".MAIN_DB_PREFIX."takepos_floor_tables where rowid='".$place."'");
}
} }
if ($action == "updatename") if ($action == "updatename") {
{
$newname = preg_replace("/[^a-zA-Z0-9\s]/", "", $newname); // Only English chars $newname = preg_replace("/[^a-zA-Z0-9\s]/", "", $newname); // Only English chars
if (strlen($newname) > 3) $newname = substr($newname, 0, 3); // Only 3 chars if (strlen($newname) > 3) {
$newname = substr($newname, 0, 3); // Only 3 chars
}
$db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set label='".$db->escape($newname)."' WHERE rowid='".$place."'"); $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set label='".$db->escape($newname)."' WHERE rowid='".$place."'");
} }
if ($action == "add") if ($action == "add") {
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."takepos_floor_tables(entity, label, leftpos, toppos, floor) VALUES (".$conf->entity.", '', '45', '45', ".$floor.")"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."takepos_floor_tables(entity, label, leftpos, toppos, floor) VALUES (".$conf->entity.", '', '45', '45', ".$floor.")";
$asdf = $db->query($sql); $asdf = $db->query($sql);
$db->query("update ".MAIN_DB_PREFIX."takepos_floor_tables set label=rowid where label=''"); // No empty table names $db->query("update ".MAIN_DB_PREFIX."takepos_floor_tables set label=rowid where label=''"); // No empty table names
@ -101,7 +120,9 @@ if ($action == "add")
// Title // Title
$title = 'TakePOS - Dolibarr '.DOL_VERSION; $title = 'TakePOS - Dolibarr '.DOL_VERSION;
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
$title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
}
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
?> ?>
<link rel="stylesheet" href="css/pos.css.php?a=xxx"> <link rel="stylesheet" href="css/pos.css.php?a=xxx">
@ -203,7 +224,11 @@ $( document ).ready(function() {
<center> <center>
<h1> <h1>
<?php if ($floor > 1) { ?> <?php if ($floor > 1) { ?>
<img class="valignmiddle" src="./img/arrow-prev.png" width="5%" onclick="location.href='floors.php?floor=<?php if ($floor > 1) { $floor--; echo $floor; $floor++; } else echo "1"; ?>';"> <img class="valignmiddle" src="./img/arrow-prev.png" width="5%" onclick="location.href='floors.php?floor=<?php if ($floor > 1) {
$floor--; echo $floor; $floor++;
} else {
echo "1";
} ?>';">
<?php } ?> <?php } ?>
<span class="valignmiddle"><?php echo $langs->trans("Floor")." ".$floor; ?></span> <span class="valignmiddle"><?php echo $langs->trans("Floor")." ".$floor; ?></span>
<img src="./img/arrow-next.png" class="valignmiddle" width="5%" onclick="location.href='floors.php?floor=<?php $floor++; echo $floor; ?>';"> <img src="./img/arrow-next.png" class="valignmiddle" width="5%" onclick="location.href='floors.php?floor=<?php $floor++; echo $floor; ?>';">

View File

@ -26,11 +26,21 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOCSRFCHECK')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); define('NOCSRFCHECK', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
require '../main.inc.php'; // Load $user and permissions require '../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
@ -61,8 +71,11 @@ if ($place > 0) {
// get default vat rate // get default vat rate
$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION['takeposterminal']; $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION['takeposterminal'];
$soc = new Societe($db); $soc = new Societe($db);
if ($invoice->socid > 0) $soc->fetch($invoice->socid); if ($invoice->socid > 0) {
else $soc->fetch($conf->global->$constforcompanyid); $soc->fetch($invoice->socid);
} else {
$soc->fetch($conf->global->$constforcompanyid);
}
$vatRateDefault = get_default_tva($mysoc, $soc); $vatRateDefault = get_default_tva($mysoc, $soc);
/* /*
@ -109,8 +122,12 @@ top_htmlhead($head, '', 0, 0, $arrayofjs, $arrayofcss);
<center> <center>
<input type="text" id="desc" name="desc" class="takepospay" style="width:40%;" placeholder="<?php echo $langs->trans('Description'); ?>"> <input type="text" id="desc" name="desc" class="takepospay" style="width:40%;" placeholder="<?php echo $langs->trans('Description'); ?>">
<?php <?php
if ($action == "freezone") echo '<input type="text" id="number" name="number" class="takepospay" style="width:15%;" placeholder="'.$langs->trans('Price').'">'; if ($action == "freezone") {
if ($action == "addnote") echo '<input type="hidden" id="number" name="number" value="'.$idline.'">'; echo '<input type="text" id="number" name="number" class="takepospay" style="width:15%;" placeholder="'.$langs->trans('Price').'">';
}
if ($action == "addnote") {
echo '<input type="hidden" id="number" name="number" value="'.$idline.'">';
}
?> ?>
<input type="hidden" name="place" class="takepospay" value="<?php echo $place; ?>"> <input type="hidden" name="place" class="takepospay" value="<?php echo $place; ?>">
<input type="button" class="button takepospay clearboth" value="OK" onclick="Save();"> <input type="button" class="button takepospay clearboth" value="OK" onclick="Save();">

View File

@ -17,15 +17,29 @@
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOCSRFCHECK')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); define('NOCSRFCHECK', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) require '../../main.inc.php'; // Load $user and permissions if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
require '../../main.inc.php'; // Load $user and permissions
}
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$w = GETPOST('w', 'int'); $w = GETPOST('w', 'int');
@ -38,8 +52,7 @@ $query = GETPOST('query', 'alpha');
* View * View
*/ */
if ($query == "cat") if ($query == "cat") {
{
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
@ -50,10 +63,8 @@ if ($query == "cat")
$pdir = get_exdir($object->id, 2, 0, 0, $object, 'category').$object->id."/photos/"; $pdir = get_exdir($object->id, 2, 0, 0, $object, 'category').$object->id."/photos/";
$dir = $upload_dir.'/'.$pdir; $dir = $upload_dir.'/'.$pdir;
foreach ($object->liste_photos($dir) as $key => $obj) foreach ($object->liste_photos($dir) as $key => $obj) {
{ if ($obj['photo_vignette']) {
if ($obj['photo_vignette'])
{
$filename = $obj['photo_vignette']; $filename = $obj['photo_vignette'];
} else { } else {
$filename = $obj['photo']; $filename = $obj['photo'];
@ -63,8 +74,7 @@ if ($query == "cat")
exit; exit;
} }
header('Location: ../../public/theme/common/nophoto.png'); header('Location: ../../public/theme/common/nophoto.png');
} elseif ($query == "pro") } elseif ($query == "pro") {
{
require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
$objProd = new Product($db); $objProd = new Product($db);

View File

@ -15,14 +15,30 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) if (!defined("NOLOGIN")) {
if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); }
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOIPCHECK')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOREQUIRESOC')) {
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); define('NOREQUIRESOC', '1');
}
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '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');
}
require '../../main.inc.php'; // Load $user and permissions require '../../main.inc.php'; // Load $user and permissions
require '../../core/modules/barcode/doc/tcpdfbarcode.modules.php'; require '../../core/modules/barcode/doc/tcpdfbarcode.modules.php';
@ -34,8 +50,7 @@ if (GETPOSTISSET("key")) {
$key = GETPOST('key'); $key = GETPOST('key');
$module = new modTcpdfbarcode(); $module = new modTcpdfbarcode();
$result = $module->buildBarCode($urlwithroot."/takepos/public/auto_order.php?key=".$key, 'QRCODE', 'Y'); $result = $module->buildBarCode($urlwithroot."/takepos/public/auto_order.php?key=".$key, 'QRCODE', 'Y');
} } else {
else {
$module = new modTcpdfbarcode(); $module = new modTcpdfbarcode();
$result = $module->buildBarCode($urlwithroot."/takepos/public/menu.php", 'QRCODE', 'Y'); $result = $module->buildBarCode($urlwithroot."/takepos/public/menu.php", 'QRCODE', 'Y');
} }

View File

@ -27,11 +27,21 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOCSRFCHECK')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); define('NOCSRFCHECK', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
require '../main.inc.php'; // Load $user and permissions require '../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
@ -47,20 +57,20 @@ $action = GETPOST('action', 'aZ09');
$setterminal = GETPOST('setterminal', 'int'); $setterminal = GETPOST('setterminal', 'int');
$setcurrency = GETPOST('setcurrency', 'aZ09'); $setcurrency = GETPOST('setcurrency', 'aZ09');
if ($_SESSION["takeposterminal"] == "") if ($_SESSION["takeposterminal"] == "") {
{ if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") {
if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") $_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal $_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal
elseif (!empty($_COOKIE["takeposterminal"])) $_SESSION["takeposterminal"] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE["takeposterminal"]); // Restore takeposterminal from previous session } elseif (!empty($_COOKIE["takeposterminal"])) {
$_SESSION["takeposterminal"] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE["takeposterminal"]); // Restore takeposterminal from previous session
}
} }
if ($setterminal > 0) if ($setterminal > 0) {
{
$_SESSION["takeposterminal"] = $setterminal; $_SESSION["takeposterminal"] = $setterminal;
setcookie("takeposterminal", $setterminal, (time() + (86400 * 354)), '/', null, false, true); // Permanent takeposterminal var in a cookie setcookie("takeposterminal", $setterminal, (time() + (86400 * 354)), '/', null, false, true); // Permanent takeposterminal var in a cookie
} }
if ($setcurrency != "") if ($setcurrency != "") {
{
$_SESSION["takeposcustomercurrency"] = $setcurrency; $_SESSION["takeposcustomercurrency"] = $setcurrency;
} }
@ -72,13 +82,11 @@ $categorie = new Categorie($db);
$maxcategbydefaultforthisdevice = 12; $maxcategbydefaultforthisdevice = 12;
$maxproductbydefaultforthisdevice = 24; $maxproductbydefaultforthisdevice = 24;
if ($conf->browser->layout == 'phone') if ($conf->browser->layout == 'phone') {
{
$maxcategbydefaultforthisdevice = 8; $maxcategbydefaultforthisdevice = 8;
$maxproductbydefaultforthisdevice = 16; $maxproductbydefaultforthisdevice = 16;
//REDIRECT TO BASIC LAYOUT IF TERMINAL SELECTED AND BASIC MOBILE LAYOUT ENABLED //REDIRECT TO BASIC LAYOUT IF TERMINAL SELECTED AND BASIC MOBILE LAYOUT ENABLED
if ($_SESSION["takeposterminal"] != "" && $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1) if ($_SESSION["takeposterminal"] != "" && $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1) {
{
$_SESSION["basiclayout"] = 1; $_SESSION["basiclayout"] = 1;
header("Location: phone.php?mobilepage=invoice"); header("Location: phone.php?mobilepage=invoice");
exit; exit;
@ -107,7 +115,9 @@ $form = new Form($db);
// Title // Title
$title = 'TakePOS - Dolibarr '.DOL_VERSION; $title = 'TakePOS - Dolibarr '.DOL_VERSION;
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
$title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
}
$head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/> $head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/>
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
@ -118,7 +128,9 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
<link rel="stylesheet" href="css/pos.css.php"> <link rel="stylesheet" href="css/pos.css.php">
<link rel="stylesheet" href="css/colorbox.css" type="text/css" media="screen" /> <link rel="stylesheet" href="css/colorbox.css" type="text/css" media="screen" />
<?php <?php
if ($conf->global->TAKEPOS_COLOR_THEME == 1) print '<link rel="stylesheet" href="css/colorful.css">'; if ($conf->global->TAKEPOS_COLOR_THEME == 1) {
print '<link rel="stylesheet" href="css/colorful.css">';
}
?> ?>
<script type="text/javascript" src="js/jquery.colorbox-min.js"></script> <!-- TODO It seems we don't need this --> <script type="text/javascript" src="js/jquery.colorbox-min.js"></script> <!-- TODO It seems we don't need this -->
<script language="javascript"> <script language="javascript">
@ -129,12 +141,9 @@ $categories = $categorie->get_full_arbo('product', (($conf->global->TAKEPOS_ROOT
// Search root category to know its level // Search root category to know its level
//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0; //$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
$levelofrootcategory = 0; $levelofrootcategory = 0;
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
{ foreach ($categories as $key => $categorycursor) {
foreach ($categories as $key => $categorycursor) if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID) {
{
if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID)
{
$levelofrootcategory = $categorycursor['level']; $levelofrootcategory = $categorycursor['level'];
break; break;
} }
@ -145,10 +154,8 @@ $levelofmaincategories = $levelofrootcategory + 1;
$maincategories = array(); $maincategories = array();
$subcategories = array(); $subcategories = array();
foreach ($categories as $key => $categorycursor) foreach ($categories as $key => $categorycursor) {
{ if ($categorycursor['level'] == $levelofmaincategories) {
if ($categorycursor['level'] == $levelofmaincategories)
{
$maincategories[$key] = $categorycursor; $maincategories[$key] = $categorycursor;
} else { } else {
$subcategories[$key] = $categorycursor; $subcategories[$key] = $categorycursor;
@ -300,8 +307,7 @@ function LoadProducts(position, issubcat) {
//console.log("ishow"+ishow+" idata="+idata); //console.log("ishow"+ishow+" idata="+idata);
console.log(data[idata]); console.log(data[idata]);
if (typeof (data[idata]) == "undefined") { if (typeof (data[idata]) == "undefined") {
<?php if (!$conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) <?php if (!$conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) {
{
echo '$("#prodivdesc"+ishow).hide();'; echo '$("#prodivdesc"+ishow).hide();';
echo '$("#prodesc"+ishow).text("");'; echo '$("#prodesc"+ishow).text("");';
echo '$("#proimg"+ishow).attr("title","");'; echo '$("#proimg"+ishow).attr("title","");';
@ -323,14 +329,12 @@ function LoadProducts(position, issubcat) {
$titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[idata]['barcode']"; $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[idata]['barcode']";
?> ?>
var titlestring = <?php echo $titlestring; ?>; var titlestring = <?php echo $titlestring; ?>;
<?php if (!$conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) <?php if (!$conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) {
{
echo '$("#prodivdesc"+ishow).show();'; echo '$("#prodivdesc"+ishow).show();';
echo '$("#prodesc"+ishow).text(data[parseInt(idata)][\'label\']);'; echo '$("#prodesc"+ishow).text(data[parseInt(idata)][\'label\']);';
echo '$("#proimg"+ishow).attr("title", titlestring);'; echo '$("#proimg"+ishow).attr("title", titlestring);';
echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);'; echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
} } else {
else {
echo '$("#probutton"+ishow).show();'; echo '$("#probutton"+ishow).show();';
echo '$("#probutton"+ishow).text(data[parseInt(idata)][\'label\']);'; echo '$("#probutton"+ishow).text(data[parseInt(idata)][\'label\']);';
} }
@ -691,8 +695,11 @@ function OpenDrawer(){
$.ajax({ $.ajax({
type: "POST", type: "POST",
<?php <?php
if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) echo "url: '".$conf->global->TAKEPOS_PRINT_SERVER."/printer/drawer.php',"; if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
else echo "url: 'http://".$conf->global->TAKEPOS_PRINT_SERVER.":8111/print',"; echo "url: '".$conf->global->TAKEPOS_PRINT_SERVER."/printer/drawer.php',";
} else {
echo "url: 'http://".$conf->global->TAKEPOS_PRINT_SERVER.":8111/print',";
}
?> ?>
data: "opendrawer" data: "opendrawer"
}); });
@ -774,8 +781,7 @@ $( document ).ready(function() {
Refresh(); Refresh();
<?php <?php
//IF NO TERMINAL SELECTED //IF NO TERMINAL SELECTED
if ($_SESSION["takeposterminal"] == "") if ($_SESSION["takeposterminal"] == "") {
{
print "ModalBox('ModalTerminal');"; print "ModalBox('ModalTerminal');";
} }
if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) { if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) {
@ -786,7 +792,9 @@ $( document ).ready(function() {
if ($resql) { if ($resql) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
// If there is no cash control from today open it // If there is no cash control from today open it
if ($obj->rowid == null) print "ControlCashOpening();"; if ($obj->rowid == null) {
print "ControlCashOpening();";
}
} }
} }
?> ?>
@ -812,8 +820,11 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
<?php echo $langs->trans("Terminal"); ?> <?php echo $langs->trans("Terminal"); ?>
</span> </span>
<?php echo " "; <?php echo " ";
if ($_SESSION["takeposterminal"] == "") echo "1"; if ($_SESSION["takeposterminal"] == "") {
else echo $_SESSION["takeposterminal"]; echo "1";
} else {
echo $_SESSION["takeposterminal"];
}
echo '<span class="hideonsmartphone"> - '.dol_print_date(dol_now(), "day").'</span>'; echo '<span class="hideonsmartphone"> - '.dol_print_date(dol_now(), "day").'</span>';
?> ?>
</a> </a>
@ -863,8 +874,7 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
<div class="modal-body"> <div class="modal-body">
<button type="button" class="block" onclick="location.href='index.php?setterminal=1'"><?php print $langs->trans("Terminal"); ?> 1</button> <button type="button" class="block" onclick="location.href='index.php?setterminal=1'"><?php print $langs->trans("Terminal"); ?> 1</button>
<?php <?php
for ($i = 2; $i <= $conf->global->TAKEPOS_NUM_TERMINALS; $i++) for ($i = 2; $i <= $conf->global->TAKEPOS_NUM_TERMINALS; $i++) {
{
print '<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.'\'">'.$langs->trans("Terminal").' '.$i.'</button>'; print '<button type="button" class="block" onclick="location.href=\'index.php?setterminal='.$i.'\'">'.$langs->trans("Terminal").' '.$i.'</button>';
} }
?> ?>
@ -885,11 +895,11 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency'; $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
$sql .= " WHERE entity IN ('".getEntity('multicurrency')."')"; $sql .= " WHERE entity IN ('".getEntity('multicurrency')."')";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{ while ($obj = $db->fetch_object($resql)) {
while ($obj = $db->fetch_object($resql))
print '<button type="button" class="block" onclick="location.href=\'index.php?setcurrency='.$obj->code.'\'">'.$obj->code.'</button>'; print '<button type="button" class="block" onclick="location.href=\'index.php?setcurrency='.$obj->code.'\'">'.$obj->code.'</button>';
} }
}
?> ?>
</div> </div>
</div> </div>
@ -910,7 +920,9 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
</div> </div>
</div> </div>
<div class="row1<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) print 'withhead'; ?>"> <div class="row1<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
print 'withhead';
} ?>">
<div id="poslines" class="div1"> <div id="poslines" class="div1">
</div> </div>
@ -947,12 +959,18 @@ $paiementsModes = array();
if ($resql) { if ($resql) {
while ($obj = $db->fetch_object($resql)) { while ($obj = $db->fetch_object($resql)) {
$paycode = $obj->code; $paycode = $obj->code;
if ($paycode == 'LIQ') $paycode = 'CASH'; if ($paycode == 'LIQ') {
if ($paycode == 'CHQ') $paycode = 'CHEQUE'; $paycode = 'CASH';
}
if ($paycode == 'CHQ') {
$paycode = 'CHEQUE';
}
$constantforkey = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"]; $constantforkey = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"];
//var_dump($constantforkey.' '.$conf->global->$constantforkey); //var_dump($constantforkey.' '.$conf->global->$constantforkey);
if (!empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) array_push($paiementsModes, $obj); if (!empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) {
array_push($paiementsModes, $obj);
}
} }
} }
@ -974,8 +992,7 @@ if (count($maincategories) == 0) {
$menus = array(); $menus = array();
$r = 0; $r = 0;
if (empty($conf->global->TAKEPOS_BAR_RESTAURANT)) if (empty($conf->global->TAKEPOS_BAR_RESTAURANT)) {
{
$menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("New").'</div>', 'action'=>'New();'); $menus[$r++] = array('title'=>'<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("New").'</div>', 'action'=>'New();');
} else { } else {
// BAR RESTAURANT specific menu // BAR RESTAURANT specific menu
@ -995,30 +1012,28 @@ if ($conf->global->TAKEPOS_DIRECT_PAYMENT) {
} }
// BAR RESTAURANT specific menu // BAR RESTAURANT specific menu
if ($conf->global->TAKEPOS_BAR_RESTAURANT) if ($conf->global->TAKEPOS_BAR_RESTAURANT) {
{ if ($conf->global->TAKEPOS_ORDER_PRINTERS) {
if ($conf->global->TAKEPOS_ORDER_PRINTERS)
{
$menus[$r++] = array('title'=>$langs->trans("Order"), 'action'=>'TakeposPrintingOrder();'); $menus[$r++] = array('title'=>$langs->trans("Order"), 'action'=>'TakeposPrintingOrder();');
} }
//Button to print receipt before payment //Button to print receipt before payment
if ($conf->global->TAKEPOS_BAR_RESTAURANT) if ($conf->global->TAKEPOS_BAR_RESTAURANT) {
{
if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") {
if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposConnector(placeid);'); if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
else $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposPrinting(placeid);'); $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposConnector(placeid);');
} else {
$menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposPrinting(placeid);');
}
} elseif ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { } elseif ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") {
$menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);'); $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);');
} else { } else {
$menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'Print(placeid);'); $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'Print(placeid);');
} }
} }
if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector" && $conf->global->TAKEPOS_ORDER_NOTES == 1) if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector" && $conf->global->TAKEPOS_ORDER_NOTES == 1) {
{
$menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("OrderNotes").'</div>', 'action'=>'TakeposOrderNotes();'); $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("OrderNotes").'</div>', 'action'=>'TakeposOrderNotes();');
} }
if ($conf->global->TAKEPOS_SUPPLEMENTS) if ($conf->global->TAKEPOS_SUPPLEMENTS) {
{
$menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("ProductSupplements").'</div>', 'action'=>'LoadProducts(\'supplements\');'); $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("ProductSupplements").'</div>', 'action'=>'LoadProducts(\'supplements\');');
} }
} }
@ -1037,14 +1052,14 @@ $sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE
$sql .= " entity = ".$conf->entity." AND "; $sql .= " entity = ".$conf->entity." AND ";
$sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'"; $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num) if ($num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$menus[$r++] = array('title'=>'<span class="fas fa-file-invoice-dollar paddingrightonly"></span><div class="trunc">'.$langs->trans("CashReport").'</div>', 'action'=>'CashReport('.$obj->rowid.');'); $menus[$r++] = array('title'=>'<span class="fas fa-file-invoice-dollar paddingrightonly"></span><div class="trunc">'.$langs->trans("CashReport").'</div>', 'action'=>'CashReport('.$obj->rowid.');');
if ($obj->status == 0) $menus[$r++] = array('title'=>'<span class="fas fa-cash-register paddingrightonly"></span><div class="trunc">'.$langs->trans("CloseCashFence").'</div>', 'action'=>'CloseCashFence('.$obj->rowid.');'); if ($obj->status == 0) {
$menus[$r++] = array('title'=>'<span class="fas fa-cash-register paddingrightonly"></span><div class="trunc">'.$langs->trans("CloseCashFence").'</div>', 'action'=>'CloseCashFence('.$obj->rowid.');');
}
} }
} }
@ -1060,14 +1075,15 @@ if (!empty($reshook)) {
} }
} }
if ($r % 3 == 2) $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;'); if ($r % 3 == 2) {
$menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;');
}
if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
$menus[$r++] = array('title'=>'<span class="fa fa-sign-out-alt paddingrightonly"></span><div class="trunc">'.$langs->trans("Logout").'</div>', 'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php\';'); $menus[$r++] = array('title'=>'<span class="fa fa-sign-out-alt paddingrightonly"></span><div class="trunc">'.$langs->trans("Logout").'</div>', 'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php\';');
} }
if ($conf->global->TAKEPOS_WEIGHING_SCALE) if ($conf->global->TAKEPOS_WEIGHING_SCALE) {
{
$menus[$r++] = array('title'=>'<span class="fa fa-balance-scale paddingrightonly"></span><div class="trunc">'.$langs->trans("WeighingScale").'</div>', 'action'=>'WeighingScale();'); $menus[$r++] = array('title'=>'<span class="fa fa-balance-scale paddingrightonly"></span><div class="trunc">'.$langs->trans("WeighingScale").'</div>', 'action'=>'WeighingScale();');
} }
@ -1076,15 +1092,16 @@ if ($conf->global->TAKEPOS_WEIGHING_SCALE)
<div class="div3"> <div class="div3">
<?php <?php
$i = 0; $i = 0;
foreach ($menus as $menu) foreach ($menus as $menu) {
{
$i++; $i++;
if (count($menus) > 12 and $i == 12) if (count($menus) > 12 and $i == 12) {
{
echo '<button style="'.$menu['style'].'" type="button" id="actionnext" class="actionbutton" onclick="MoreActions('.count($menus).');">'.$langs->trans("Next").'</button>'; echo '<button style="'.$menu['style'].'" type="button" id="actionnext" class="actionbutton" onclick="MoreActions('.count($menus).');">'.$langs->trans("Next").'</button>';
echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.$menu['action'].'">'.$menu['title'].'</button>'; echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.$menu['action'].'">'.$menu['title'].'</button>';
} elseif ($i > 12) echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.$menu['action'].'">'.$menu['title'].'</button>'; } elseif ($i > 12) {
else echo '<button style="'.$menu['style'].'" type="button" id="action'.$i.'" class="actionbutton" onclick="'.$menu['action'].'">'.$menu['title'].'</button>'; echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.$menu['action'].'">'.$menu['title'].'</button>';
} else {
echo '<button style="'.$menu['style'].'" type="button" id="action'.$i.'" class="actionbutton" onclick="'.$menu['action'].'">'.$menu['title'].'</button>';
}
} }
if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
@ -1098,16 +1115,23 @@ if ($conf->global->TAKEPOS_WEIGHING_SCALE)
</div> </div>
</div> </div>
<div class="row2<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) print 'withhead'; ?>"> <div class="row2<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
print 'withhead';
} ?>">
<!-- Show categories --> <!-- Show categories -->
<div class="div4"> <div class="div4">
<?php <?php
$count = 0; $count = 0;
while ($count < $MAXCATEG) while ($count < $MAXCATEG) {
{
?> ?>
<div class="wrapper" <?php if ($count == ($MAXCATEG - 2)) echo 'onclick="MoreCategories(\'less\');"'; elseif ($count == ($MAXCATEG - 1)) echo 'onclick="MoreCategories(\'more\');"'; else echo 'onclick="LoadProducts('.$count.');"'; ?> id="catdiv<?php echo $count; ?>"> <div class="wrapper" <?php if ($count == ($MAXCATEG - 2)) {
echo 'onclick="MoreCategories(\'less\');"';
} elseif ($count == ($MAXCATEG - 1)) {
echo 'onclick="MoreCategories(\'more\');"';
} else {
echo 'onclick="LoadProducts('.$count.');"';
} ?> id="catdiv<?php echo $count; ?>">
<?php <?php
if ($count == ($MAXCATEG - 2)) { if ($count == ($MAXCATEG - 2)) {
//echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="catimg'.$count.'" />'; //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="catimg'.$count.'" />';
@ -1116,7 +1140,9 @@ if ($conf->global->TAKEPOS_WEIGHING_SCALE)
//echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="catimg'.$count.'" />'; //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="catimg'.$count.'" />';
echo '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em;"></span>'; echo '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em;"></span>';
} else { } else {
if (!$conf->global->TAKEPOS_HIDE_CATEGORY_IMAGES) echo '<img class="imgwrapper" height="100%" id="catimg'.$count.'" />'; if (!$conf->global->TAKEPOS_HIDE_CATEGORY_IMAGES) {
echo '<img class="imgwrapper" height="100%" id="catimg'.$count.'" />';
}
} }
?> ?>
<?php if ($count != ($MAXCATEG - 2) && $count != ($MAXCATEG - 1)) { ?> <?php if ($count != ($MAXCATEG - 2) && $count != ($MAXCATEG - 1)) { ?>
@ -1136,10 +1162,15 @@ if ($conf->global->TAKEPOS_WEIGHING_SCALE)
<div class="div5"> <div class="div5">
<?php <?php
$count = 0; $count = 0;
while ($count < $MAXPRODUCT) while ($count < $MAXPRODUCT) {
{
?> ?>
<div class="wrapper2" id='prodiv<?php echo $count; ?>' <?php if ($count == ($MAXPRODUCT - 2)) {?> onclick="MoreProducts('less');" <?php } if ($count == ($MAXPRODUCT - 1)) {?> onclick="MoreProducts('more');" <?php } else echo 'onclick="ClickProduct('.$count.');"'; ?>> <div class="wrapper2" id='prodiv<?php echo $count; ?>' <?php if ($count == ($MAXPRODUCT - 2)) {
?> onclick="MoreProducts('less');" <?php
} if ($count == ($MAXPRODUCT - 1)) {
?> onclick="MoreProducts('more');" <?php
} else {
echo 'onclick="ClickProduct('.$count.');"';
} ?>>
<?php <?php
if ($count == ($MAXPRODUCT - 2)) { if ($count == ($MAXPRODUCT - 2)) {
//echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="proimg'.$count.'" />'; //echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="proimg'.$count.'" />';
@ -1148,8 +1179,9 @@ if ($conf->global->TAKEPOS_WEIGHING_SCALE)
//echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="proimg'.$count.'" />'; //echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="proimg'.$count.'" />';
print '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em;"></span>'; print '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em;"></span>';
} else { } else {
if ($conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) echo '<button type="button" id="probutton'.$count.'" class="productbutton" style="display: none;"></button>'; if ($conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) {
else { echo '<button type="button" id="probutton'.$count.'" class="productbutton" style="display: none;"></button>';
} else {
print '<div class="" id="proprice'.$count.'"></div>'; print '<div class="" id="proprice'.$count.'"></div>';
print '<img class="imgwrapper" height="100%" title="" id="proimg'.$count.'">'; print '<img class="imgwrapper" height="100%" title="" id="proimg'.$count.'">';
} }

View File

@ -27,13 +27,25 @@
// if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language // if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
// if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
// if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (!defined('NOCSRFCHECK')) { define('NOCSRFCHECK', '1'); } if (!defined('NOCSRFCHECK')) {
if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } define('NOCSRFCHECK', '1');
if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } }
if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); } if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) require '../main.inc.php'; if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
require '../main.inc.php';
}
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
@ -58,20 +70,21 @@ if (empty($user->rights->takepos->run) && !defined('INCLUDE_PHONEPAGE_FROM_PUBLI
* View * View
*/ */
if (($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1 && $conf->browser->layout == 'phone') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) if (($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1 && $conf->browser->layout == 'phone') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
{
// DIRECT LINK TO THIS PAGE FROM MOBILE AND NO TERMINAL SELECTED // DIRECT LINK TO THIS PAGE FROM MOBILE AND NO TERMINAL SELECTED
if ($_SESSION["takeposterminal"] == "") if ($_SESSION["takeposterminal"] == "") {
{ if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") {
if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") $_SESSION["takeposterminal"] = 1; $_SESSION["takeposterminal"] = 1;
else { } else {
header("Location: ".DOL_URL_ROOT."/takepos/index.php"); header("Location: ".DOL_URL_ROOT."/takepos/index.php");
exit; exit;
} }
} }
$mobilepage = GETPOST('mobilepage', 'alpha'); $mobilepage = GETPOST('mobilepage', 'alpha');
$title = 'TakePOS - Dolibarr '.DOL_VERSION; $title = 'TakePOS - Dolibarr '.DOL_VERSION;
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
$title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
}
$head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/> $head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/>
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
@ -108,9 +121,15 @@ $amountofpayment = price2num(GETPOST('amount', 'alpha'));
$invoiceid = GETPOST('invoiceid', 'int'); $invoiceid = GETPOST('invoiceid', 'int');
$paycode = $pay; $paycode = $pay;
if ($pay == 'cash') $paycode = 'LIQ'; // For backward compatibility if ($pay == 'cash') {
if ($pay == 'card') $paycode = 'CB'; // For backward compatibility $paycode = 'LIQ'; // For backward compatibility
if ($pay == 'cheque') $paycode = 'CHQ'; // For backward compatibility }
if ($pay == 'card') {
$paycode = 'CB'; // For backward compatibility
}
if ($pay == 'cheque') {
$paycode = 'CHQ'; // For backward compatibility
}
// Retrieve paiementid // Retrieve paiementid
$sql = "SELECT id FROM ".MAIN_DB_PREFIX."c_paiement"; $sql = "SELECT id FROM ".MAIN_DB_PREFIX."c_paiement";
@ -121,22 +140,23 @@ $obj = $db->fetch_object($resql);
$paiementid = $obj->id; $paiementid = $obj->id;
$invoice = new Facture($db); $invoice = new Facture($db);
if ($invoiceid > 0) if ($invoiceid > 0) {
{
$ret = $invoice->fetch($invoiceid); $ret = $invoice->fetch($invoiceid);
} else { } else {
$ret = $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); $ret = $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')');
} }
if ($ret > 0) if ($ret > 0) {
{
$placeid = $invoice->id; $placeid = $invoice->id;
} }
$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
$soc = new Societe($db); $soc = new Societe($db);
if ($invoice->socid > 0) $soc->fetch($invoice->socid); if ($invoice->socid > 0) {
else $soc->fetch($conf->global->$constforcompanyid); $soc->fetch($invoice->socid);
} else {
$soc->fetch($conf->global->$constforcompanyid);
}
/* /*
@ -144,18 +164,20 @@ else $soc->fetch($conf->global->$constforcompanyid);
*/ */
// Action to record a payment on a TakePOS invoice // Action to record a payment on a TakePOS invoice
if ($action == 'valid' && $user->rights->facture->creer) if ($action == 'valid' && $user->rights->facture->creer) {
{
$bankaccount = 0; $bankaccount = 0;
$error = 0; $error = 0;
if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) { if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) {
$bankaccount = GETPOST('accountid', 'int'); $bankaccount = GETPOST('accountid', 'int');
} else { } else {
if ($pay == "cash") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]}; // For backward compatibility if ($pay == "cash") {
elseif ($pay == "card") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$_SESSION["takeposterminal"]}; // For backward compatibility $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]}; // For backward compatibility
elseif ($pay == "cheque") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]}; // For backward compatibility } elseif ($pay == "card") {
else { $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$_SESSION["takeposterminal"]}; // For backward compatibility
} elseif ($pay == "cheque") {
$bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]}; // For backward compatibility
} else {
$accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"]; $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"];
$bankaccount = $conf->global->$accountname; $bankaccount = $conf->global->$accountname;
} }
@ -253,11 +275,15 @@ if ($action == 'valid' && $user->rights->facture->creer)
$payment->datepaye = $now; $payment->datepaye = $now;
$payment->fk_account = $bankaccount; $payment->fk_account = $bankaccount;
$payment->amounts[$invoice->id] = $amountofpayment; $payment->amounts[$invoice->id] = $amountofpayment;
if ($pay == 'cash') $payment->pos_change = price2num(GETPOST('excess', 'alpha')); if ($pay == 'cash') {
$payment->pos_change = price2num(GETPOST('excess', 'alpha'));
}
// If user has not used change control, add total invoice payment // If user has not used change control, add total invoice payment
// Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay
if ($amountofpayment == 0 || $amountofpayment > $remaintopay) $payment->amounts[$invoice->id] = $remaintopay; if ($amountofpayment == 0 || $amountofpayment > $remaintopay) {
$payment->amounts[$invoice->id] = $remaintopay;
}
$payment->paiementid = $paiementid; $payment->paiementid = $paiementid;
$payment->num_payment = $invoice->ref; $payment->num_payment = $invoice->ref;
@ -272,7 +298,9 @@ if ($action == 'valid' && $user->rights->facture->creer)
if ($remaintopay == 0) { if ($remaintopay == 0) {
dol_syslog("Invoice is paid, so we set it to status Paid"); dol_syslog("Invoice is paid, so we set it to status Paid");
$result = $invoice->setPaid($user); $result = $invoice->setPaid($user);
if ($result > 0) $invoice->paye = 1; if ($result > 0) {
$invoice->paye = 1;
}
// set payment method // set payment method
$invoice->setPaymentMethods($paiementid); $invoice->setPaymentMethods($paiementid);
} else { } else {
@ -283,8 +311,7 @@ if ($action == 'valid' && $user->rights->facture->creer)
} }
} }
if ($action == 'creditnote') if ($action == 'creditnote') {
{
$creditnote = new Facture($db); $creditnote = new Facture($db);
$creditnote->socid = $invoice->socid; $creditnote->socid = $invoice->socid;
$creditnote->date = dol_now(); $creditnote->date = dol_now();
@ -294,8 +321,7 @@ if ($action == 'creditnote')
$creditnote->remise_percent = $invoice->remise_percent; $creditnote->remise_percent = $invoice->remise_percent;
$creditnote->create($user); $creditnote->create($user);
foreach ($invoice->lines as $line) foreach ($invoice->lines as $line) {
{
// Extrafields // Extrafields
if (method_exists($line, 'fetch_optionals')) { if (method_exists($line, 'fetch_optionals')) {
// load extrafields // load extrafields
@ -305,21 +331,17 @@ if ($action == 'creditnote')
if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
$fk_parent_line = 0; $fk_parent_line = 0;
} }
if ($invoice->type == Facture::TYPE_SITUATION) if ($invoice->type == Facture::TYPE_SITUATION) {
{
$source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id
$line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from
if (!empty($invoice->tab_previous_situation_invoice)) if (!empty($invoice->tab_previous_situation_invoice)) {
{
// search the last standard invoice in cycle and the possible credit note between this last and invoice // search the last standard invoice in cycle and the possible credit note between this last and invoice
// TODO Move this out of loop of $invoice->lines // TODO Move this out of loop of $invoice->lines
$tab_jumped_credit_notes = array(); $tab_jumped_credit_notes = array();
$lineIndex = count($invoice->tab_previous_situation_invoice) - 1; $lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
$searchPreviousInvoice = true; $searchPreviousInvoice = true;
while ($searchPreviousInvoice) while ($searchPreviousInvoice) {
{ if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) {
if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1)
{
$searchPreviousInvoice = false; // find, exit; $searchPreviousInvoice = false; // find, exit;
break; break;
} else { } else {
@ -331,10 +353,8 @@ if ($action == 'creditnote')
} }
$maxPrevSituationPercent = 0; $maxPrevSituationPercent = 0;
foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) {
{ if ($prevLine->id == $source_fk_prev_id) {
if ($prevLine->id == $source_fk_prev_id)
{
$maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
//$line->subprice = $line->subprice - $prevLine->subprice; //$line->subprice = $line->subprice - $prevLine->subprice;
@ -359,10 +379,8 @@ if ($action == 'creditnote')
// If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta)
$maxPrevSituationPercent = 0; $maxPrevSituationPercent = 0;
foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) {
{ if ($prevLine->fk_prev_id == $source_fk_prev_id) {
if ($prevLine->fk_prev_id == $source_fk_prev_id)
{
$maxPrevSituationPercent = $prevLine->situation_percent; $maxPrevSituationPercent = $prevLine->situation_percent;
$line->total_ht -= $prevLine->total_ht; $line->total_ht -= $prevLine->total_ht;
@ -431,10 +449,12 @@ if ($action == 'creditnote')
} }
} }
if ($action == 'history' || $action == 'creditnote') if ($action == 'history' || $action == 'creditnote') {
{ if ($action == 'creditnote') {
if ($action == 'creditnote') $placeid = $creditnote->id; $placeid = $creditnote->id;
else $placeid = (int) GETPOST('placeid', 'int'); } else {
$placeid = (int) GETPOST('placeid', 'int');
}
$invoice = new Facture($db); $invoice = new Facture($db);
$invoice->fetch($placeid); $invoice->fetch($placeid);
} }
@ -443,22 +463,19 @@ if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"
$invoice->setMulticurrencyCode($_SESSION["takeposcustomercurrency"]); $invoice->setMulticurrencyCode($_SESSION["takeposcustomercurrency"]);
} }
if (($action == "addline" || $action == "freezone") && $placeid == 0) if (($action == "addline" || $action == "freezone") && $placeid == 0) {
{
$invoice->socid = $conf->global->$constforcompanyid; $invoice->socid = $conf->global->$constforcompanyid;
$invoice->date = dol_now(); $invoice->date = dol_now();
$invoice->module_source = 'takepos'; $invoice->module_source = 'takepos';
$invoice->pos_source = $_SESSION["takeposterminal"]; $invoice->pos_source = $_SESSION["takeposterminal"];
$invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity; $invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity;
if ($invoice->socid <= 0) if ($invoice->socid <= 0) {
{
$langs->load('errors'); $langs->load('errors');
dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1); dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1);
} else { } else {
$placeid = $invoice->create($user); $placeid = $invoice->create($user);
if ($placeid < 0) if ($placeid < 0) {
{
dol_htmloutput_errors($invoice->error, $invoice->errors, 1); dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
} }
$sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid; $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid;
@ -466,8 +483,7 @@ if (($action == "addline" || $action == "freezone") && $placeid == 0)
} }
} }
if ($action == "addline") if ($action == "addline") {
{
$prod = new Product($db); $prod = new Product($db);
$prod->fetch($idproduct); $prod->fetch($idproduct);
@ -487,19 +503,20 @@ if ($action == "addline")
$localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr);
if (!empty($conf->global->TAKEPOS_SUPPLEMENTS)) if (!empty($conf->global->TAKEPOS_SUPPLEMENTS)) {
{
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$cat = new Categorie($db); $cat = new Categorie($db);
$categories = $cat->containing($idproduct, 'product'); $categories = $cat->containing($idproduct, 'product');
$found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories, 'id'))); $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories, 'id')));
if ($found !== false) // If this product is a supplement if ($found !== false) { // If this product is a supplement
{
$sql = "SELECT fk_parent_line FROM ".MAIN_DB_PREFIX."facturedet where rowid=$selectedline"; $sql = "SELECT fk_parent_line FROM ".MAIN_DB_PREFIX."facturedet where rowid=$selectedline";
$resql = $db->query($sql); $resql = $db->query($sql);
$row = $db->fetch_array($resql); $row = $db->fetch_array($resql);
if ($row[0] == null) $parent_line = $selectedline; if ($row[0] == null) {
else $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product $parent_line = $selectedline;
} else {
$parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product
}
} }
} }
@ -547,10 +564,8 @@ if ($action == "freezone") {
} }
if ($action == "addnote") { if ($action == "addnote") {
foreach ($invoice->lines as $line) foreach ($invoice->lines as $line) {
{ if ($line->id == $number) {
if ($line->id == $number)
{
$line->array_options['order_notes'] = $desc; $line->array_options['order_notes'] = $desc;
$result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
} }
@ -583,8 +598,7 @@ if ($action == "delete") {
if ($placeid > 0) { if ($placeid > 0) {
$result = $invoice->fetch($placeid); $result = $invoice->fetch($placeid);
if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) {
{
$db->begin(); $db->begin();
// We delete the lines // We delete the lines
@ -614,12 +628,9 @@ if ($action == "delete") {
} }
} }
if ($action == "updateqty") if ($action == "updateqty") {
{ foreach ($invoice->lines as $line) {
foreach ($invoice->lines as $line) if ($line->id == $idline) {
{
if ($line->id == $idline)
{
$result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
} }
} }
@ -627,12 +638,9 @@ if ($action == "updateqty")
$invoice->fetch($placeid); $invoice->fetch($placeid);
} }
if ($action == "updateprice") if ($action == "updateprice") {
{ foreach ($invoice->lines as $line) {
foreach ($invoice->lines as $line) if ($line->id == $idline) {
{
if ($line->id == $idline)
{
$prod = new Product($db); $prod = new Product($db);
$prod->fetch($line->fk_product); $prod->fetch($line->fk_product);
$customer = new Societe($db); $customer = new Societe($db);
@ -642,21 +650,19 @@ if ($action == "updateprice")
$usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
$pu_ht = price2num($number / (1 + ($line->tva_tx / 100)), 'MU'); $pu_ht = price2num($number / (1 + ($line->tva_tx / 100)), 'MU');
//Check min price //Check min price
if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) {
{
echo $langs->trans("CantBeLessThanMinPrice"); echo $langs->trans("CantBeLessThanMinPrice");
} else $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } else {
$result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
}
} }
} }
$invoice->fetch($placeid); $invoice->fetch($placeid);
} }
if ($action == "updatereduction") if ($action == "updatereduction") {
{ foreach ($invoice->lines as $line) {
foreach ($invoice->lines as $line) if ($line->id == $idline) {
{
if ($line->id == $idline)
{
$prod = new Product($db); $prod = new Product($db);
$prod->fetch($line->fk_product); $prod->fetch($line->fk_product);
$customer = new Societe($db); $customer = new Societe($db);
@ -666,10 +672,11 @@ if ($action == "updatereduction")
$usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
$pu_ht = price2num($line->multicurrency_subprice / (1 + ($line->tva_tx / 100)), 'MU'); $pu_ht = price2num($line->multicurrency_subprice / (1 + ($line->tva_tx / 100)), 'MU');
//Check min price //Check min price
if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($line->multicurrency_subprice) * (1 - price2num($number) / 100) < price2num($price_min)))) if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($line->multicurrency_subprice) * (1 - price2num($number) / 100) < price2num($price_min)))) {
{
echo $langs->trans("CantBeLessThanMinPrice"); echo $langs->trans("CantBeLessThanMinPrice");
} else $result = $invoice->updateline($line->id, $line->desc, $line->multicurrency_subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } else {
$result = $invoice->updateline($line->id, $line->desc, $line->multicurrency_subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
}
} }
} }
$invoice->fetch($placeid); $invoice->fetch($placeid);
@ -681,8 +688,7 @@ if ($action == "updatereduction")
$invoice->fetch($placeid); $invoice->fetch($placeid);
} }
if ($action == "order" and $placeid != 0) if ($action == "order" and $placeid != 0) {
{
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") {
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
@ -700,8 +706,7 @@ if ($action == "order" and $placeid != 0)
$catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
$catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2);
$catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3); $catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3);
foreach ($invoice->lines as $line) foreach ($invoice->lines as $line) {
{
if ($line->special_code == "4") { if ($line->special_code == "4") {
continue; continue;
} }
@ -709,16 +714,23 @@ if ($action == "order" and $placeid != 0)
$existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
$result = array_intersect($catsprinter1, $existing); $result = array_intersect($catsprinter1, $existing);
$count = count($result); $count = count($result);
if (!$line->fk_product) $count++; // Print Free-text item (Unassigned printer) to Printer 1 if (!$line->fk_product) {
$count++; // Print Free-text item (Unassigned printer) to Printer 1
}
if ($count > 0) { if ($count > 0) {
$linestoprint++; $linestoprint++;
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1 $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1
$db->query($sql); $db->query($sql);
$order_receipt_printer1 .= '<tr><td class="left">'; $order_receipt_printer1 .= '<tr><td class="left">';
if ($line->fk_product) $order_receipt_printer1 .= $line->product_label; if ($line->fk_product) {
else $order_receipt_printer1 .= $line->description; $order_receipt_printer1 .= $line->product_label;
} else {
$order_receipt_printer1 .= $line->description;
}
$order_receipt_printer1 .= '</td><td class="right">'.$line->qty; $order_receipt_printer1 .= '</td><td class="right">'.$line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer1 .= "<br>(".$line->array_options['options_order_notes'].")"; if (!empty($line->array_options['options_order_notes'])) {
$order_receipt_printer1 .= "<br>(".$line->array_options['options_order_notes'].")";
}
$order_receipt_printer1 .= '</td></tr>'; $order_receipt_printer1 .= '</td></tr>';
} }
} }
@ -735,8 +747,7 @@ if ($action == "order" and $placeid != 0)
$invoice->fetch($placeid); //Reload object after set lines as printed $invoice->fetch($placeid); //Reload object after set lines as printed
$linestoprint = 0; $linestoprint = 0;
foreach ($invoice->lines as $line) foreach ($invoice->lines as $line) {
{
if ($line->special_code == "4") { if ($line->special_code == "4") {
continue; continue;
} }
@ -749,7 +760,9 @@ if ($action == "order" and $placeid != 0)
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2 $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2
$db->query($sql); $db->query($sql);
$order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty; $order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer2 .= "<br>(".$line->array_options['options_order_notes'].")"; if (!empty($line->array_options['options_order_notes'])) {
$order_receipt_printer2 .= "<br>(".$line->array_options['options_order_notes'].")";
}
$order_receipt_printer2 .= '</td></tr>'; $order_receipt_printer2 .= '</td></tr>';
} }
} }
@ -766,8 +779,7 @@ if ($action == "order" and $placeid != 0)
$invoice->fetch($placeid); //Reload object after set lines as printed $invoice->fetch($placeid); //Reload object after set lines as printed
$linestoprint = 0; $linestoprint = 0;
foreach ($invoice->lines as $line) foreach ($invoice->lines as $line) {
{
if ($line->special_code == "4") { if ($line->special_code == "4") {
continue; continue;
} }
@ -780,7 +792,9 @@ if ($action == "order" and $placeid != 0)
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3 $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3
$db->query($sql); $db->query($sql);
$order_receipt_printer3 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty; $order_receipt_printer3 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer3 .= "<br>(".$line->array_options['options_order_notes'].")"; if (!empty($line->array_options['options_order_notes'])) {
$order_receipt_printer3 .= "<br>(".$line->array_options['options_order_notes'].")";
}
$order_receipt_printer3 .= '</td></tr>'; $order_receipt_printer3 .= '</td></tr>';
} }
} }
@ -798,23 +812,27 @@ if ($action == "order" and $placeid != 0)
} }
$sectionwithinvoicelink = ''; $sectionwithinvoicelink = '';
if ($action == "valid" || $action == "history" || $action == 'creditnote') if ($action == "valid" || $action == "history" || $action == 'creditnote') {
{
$sectionwithinvoicelink .= '<!-- Section with invoice link -->'."\n"; $sectionwithinvoicelink .= '<!-- Section with invoice link -->'."\n";
$sectionwithinvoicelink .= '<span style="font-size:120%;" class="center">'; $sectionwithinvoicelink .= '<span style="font-size:120%;" class="center">';
$sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - "; $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - ";
$remaintopay = $invoice->getRemainToPay(); $remaintopay = $invoice->getRemainToPay();
if ($remaintopay > 0) if ($remaintopay > 0) {
{
$sectionwithinvoicelink .= $langs->trans('RemainToPay').': <span class="amountremaintopay" style="font-size: unset">'.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).'</span>'; $sectionwithinvoicelink .= $langs->trans('RemainToPay').': <span class="amountremaintopay" style="font-size: unset">'.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
} else { } else {
if ($invoice->paye) $sectionwithinvoicelink .= '<span class="amountpaymentcomplete" style="font-size: unset">'.$langs->trans("Paid").'</span>'; if ($invoice->paye) {
else $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated'); $sectionwithinvoicelink .= '<span class="amountpaymentcomplete" style="font-size: unset">'.$langs->trans("Paid").'</span>';
} else {
$sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated');
}
} }
$sectionwithinvoicelink .= '</span><br>'; $sectionwithinvoicelink .= '</span><br>';
if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") {
if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="TakeposConnector('.$placeid.');">'.$langs->trans('PrintTicket').'</button>'; if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
else $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="TakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button>'; $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="TakeposConnector('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
} else {
$sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="TakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
}
} elseif ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { } elseif ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") {
$sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="DolibarrTakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button>'; $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="DolibarrTakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
} else { } else {
@ -823,12 +841,13 @@ if ($action == "valid" || $action == "history" || $action == 'creditnote')
$sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="Print('.$placeid.', 1);">'.$langs->trans('GiftReceipt').'</button>'; $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="Print('.$placeid.', 1);">'.$langs->trans('GiftReceipt').'</button>';
} }
} }
if ($conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) if ($conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) {
{
$sectionwithinvoicelink .= ' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.');">'.$langs->trans('SendTicket').'</button>'; $sectionwithinvoicelink .= ' <button id="buttonsend" type="button" onclick="SendTicket('.$placeid.');">'.$langs->trans('SendTicket').'</button>';
} }
if ($remaintopay <= 0 && $conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink .= '<script language="javascript">$("#buttonprint").click();</script>'; if ($remaintopay <= 0 && $conf->global->TAKEPOS_AUTO_PRINT_TICKETS) {
$sectionwithinvoicelink .= '<script language="javascript">$("#buttonprint").click();</script>';
}
} }
/* /*
@ -877,8 +896,7 @@ if ($action == "order" and $order_receipt_printer1 != "") {
data: 'invoice='+orderprinter1esc data: 'invoice='+orderprinter1esc
}); });
<?php <?php
} } else {
else {
?> ?>
$.ajax({ $.ajax({
type: "POST", type: "POST",
@ -899,8 +917,7 @@ if ($action == "order" and $order_receipt_printer2 != "") {
data: 'invoice='+orderprinter2esc data: 'invoice='+orderprinter2esc
}); });
<?php <?php
} } else {
else {
?> ?>
$.ajax({ $.ajax({
type: "POST", type: "POST",
@ -1036,13 +1053,19 @@ $( document ).ready(function() {
echo '<a class="valignmiddle" title="'.dol_escape_js($langs->trans("SaleStartedAt", dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser'))).'" onclick="place=\\\''; echo '<a class="valignmiddle" title="'.dol_escape_js($langs->trans("SaleStartedAt", dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser'))).'" onclick="place=\\\'';
$num_sale = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref)); $num_sale = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
echo $num_sale; echo $num_sale;
if (str_replace("-", "", $num_sale) > $max_sale) $max_sale = str_replace("-", "", $num_sale); if (str_replace("-", "", $num_sale) > $max_sale) {
$max_sale = str_replace("-", "", $num_sale);
}
echo '\\\'; invoiceid=\\\''; echo '\\\'; invoiceid=\\\'';
echo $obj->rowid; echo $obj->rowid;
echo '\\\'; Refresh();">'; echo '\\\'; Refresh();">';
if ($placeid == $obj->rowid) echo "<b>"; if ($placeid == $obj->rowid) {
echo "<b>";
}
echo dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser'); echo dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser');
if ($placeid == $obj->rowid) echo "</b>"; if ($placeid == $obj->rowid) {
echo "</b>";
}
echo '</a>\');'; echo '</a>\');';
} }
echo '$("#customerandsales").append(\'<a onclick="place=\\\'0-'; echo '$("#customerandsales").append(\'<a onclick="place=\\\'0-';
@ -1055,8 +1078,7 @@ $( document ).ready(function() {
$s = ''; $s = '';
$constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"];
if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") {
{
$s = '<span class="small">'; $s = '<span class="small">';
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
$warehouse = new Entrepot($db); $warehouse = new Entrepot($db);
@ -1071,31 +1093,34 @@ $( document ).ready(function() {
<?php <?php
// Module Adherent // Module Adherent
$s = ''; $s = '';
if (!empty($conf->adherent->enabled) && $invoice->socid > 0 && $invoice->socid != $conf->global->$constforcompanyid) if (!empty($conf->adherent->enabled) && $invoice->socid > 0 && $invoice->socid != $conf->global->$constforcompanyid) {
{
$s = '<span class="small">'; $s = '<span class="small">';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$langs->load("members"); $langs->load("members");
$s .= $langs->trans("Member").': '; $s .= $langs->trans("Member").': ';
$adh = new Adherent($db); $adh = new Adherent($db);
$result = $adh->fetch('', '', $invoice->socid); $result = $adh->fetch('', '', $invoice->socid);
if ($result > 0) if ($result > 0) {
{
$adh->ref = $adh->getFullName($langs); $adh->ref = $adh->getFullName($langs);
if (empty($adh->statut)) { $s .= "<s>"; } if (empty($adh->statut)) {
$s .= "<s>";
}
$s .= $adh->getFullName($langs); $s .= $adh->getFullName($langs);
$s .= ' - '.$adh->type; $s .= ' - '.$adh->type;
if ($adh->datefin) if ($adh->datefin) {
{
$s .= '<br>'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); $s .= '<br>'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day');
if ($adh->hasDelay()) { if ($adh->hasDelay()) {
$s .= " ".img_warning($langs->trans("Late")); $s .= " ".img_warning($langs->trans("Late"));
} }
} else { } else {
$s .= '<br>'.$langs->trans("SubscriptionNotReceived"); $s .= '<br>'.$langs->trans("SubscriptionNotReceived");
if ($adh->statut > 0) $s .= " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated if ($adh->statut > 0) {
$s .= " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
}
}
if (empty($adh->statut)) {
$s .= "</s>";
} }
if (empty($adh->statut)) { $s .= "</s>"; }
} else { } else {
$s .= '<br>'.$langs->trans("ThirdpartyNotLinkedToMember"); $s .= '<br>'.$langs->trans("ThirdpartyNotLinkedToMember");
} }
@ -1111,8 +1136,7 @@ $( document ).ready(function() {
<?php <?php
// Add again js for footer because this content is injected into index.php page so all init // Add again js for footer because this content is injected into index.php page so all init
// for tooltip and other js beautifiers must be reexecuted too. // for tooltip and other js beautifiers must be reexecuted too.
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax)) {
{
print "\n".'<!-- Includes JS Footer of Dolibarr -->'."\n"; print "\n".'<!-- Includes JS Footer of Dolibarr -->'."\n";
print '<script src="'.DOL_URL_ROOT.'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.($ext ? '&'.$ext : '').'"></script>'."\n"; print '<script src="'.DOL_URL_ROOT.'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.($ext ? '&'.$ext : '').'"></script>'."\n";
} }
@ -1121,8 +1145,9 @@ print '<!-- invoice.php place='.(int) $place.' invoice='.$invoice->ref.' mobilep
print '<div class="div-table-responsive-no-min invoice">'; print '<div class="div-table-responsive-no-min invoice">';
print '<table id="tablelines" class="noborder noshadow postablelines" width="100%">'; print '<table id="tablelines" class="noborder noshadow postablelines" width="100%">';
if ($sectionwithinvoicelink && ($mobilepage == "invoice" || $mobilepage == "")) { if ($sectionwithinvoicelink && ($mobilepage == "invoice" || $mobilepage == "")) {
if (!empty($conf->global->TAKEPOS_SHOW_HT)) { print '<tr><td colspan="5">'.$sectionwithinvoicelink.'</td></tr>'; } if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
else { print '<tr><td colspan="5">'.$sectionwithinvoicelink.'</td></tr>';
} else {
print '<tr><td colspan="4">'.$sectionwithinvoicelink.'</td></tr>'; print '<tr><td colspan="4">'.$sectionwithinvoicelink.'</td></tr>';
} }
} }
@ -1132,13 +1157,11 @@ print '<td class="linecoldescription">';
if ($mobilepage == "invoice" || $mobilepage == "") { if ($mobilepage == "invoice" || $mobilepage == "") {
print '<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.'">'; print '<input type="hidden" name="invoiceid" id="invoiceid" value="'.$invoice->id.'">';
} }
if ($conf->global->TAKEPOS_BAR_RESTAURANT) if ($conf->global->TAKEPOS_BAR_RESTAURANT) {
{
$sql = "SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); $sql = "SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place);
$resql = $db->query($sql); $resql = $db->query($sql);
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) if ($obj) {
{
$label = $obj->label; $label = $obj->label;
$floor = $obj->floor; $floor = $obj->floor;
} }
@ -1146,16 +1169,18 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT)
if ($mobilepage == "invoice" || $mobilepage == "") { if ($mobilepage == "invoice" || $mobilepage == "") {
print '<span class="opacitymedium">'.$langs->trans('Place')."</span> <b>".$label."</b><br>"; print '<span class="opacitymedium">'.$langs->trans('Place')."</span> <b>".$label."</b><br>";
print '<span class="opacitymedium">'.$langs->trans('Floor')."</span> <b>".$floor."</b>"; print '<span class="opacitymedium">'.$langs->trans('Floor')."</span> <b>".$floor."</b>";
} elseif (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
print $mysoc->name;
} elseif ($mobilepage == "cats") {
print $langs->trans('Category');
} elseif ($mobilepage == "products") {
print $langs->trans('Label');
} }
elseif (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) print $mysoc->name;
elseif ($mobilepage == "cats") print $langs->trans('Category');
elseif ($mobilepage == "products") print $langs->trans('Label');
} else { } else {
print $langs->trans("Products"); print $langs->trans("Products");
} }
print '</td>'; print '</td>';
if ($_SESSION["basiclayout"] != 1) if ($_SESSION["basiclayout"] != 1) {
{
print '<td class="linecolqty right">'.$langs->trans('ReductionShort').'</td>'; print '<td class="linecolqty right">'.$langs->trans('ReductionShort').'</td>';
print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>'; print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
if ($conf->global->TAKEPOS_SHOW_HT) { if ($conf->global->TAKEPOS_SHOW_HT) {
@ -1190,36 +1215,43 @@ if ($_SESSION["basiclayout"] != 1)
print '</td>'; print '</td>';
} }
print '</td>'; print '</td>';
} elseif ($mobilepage == "invoice") {
print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
} }
elseif ($mobilepage == "invoice") print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
print "</tr>\n"; print "</tr>\n";
if ($_SESSION["basiclayout"] == 1) if ($_SESSION["basiclayout"] == 1) {
{ if ($mobilepage == "cats") {
if ($mobilepage == "cats")
{
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$categorie = new Categorie($db); $categorie = new Categorie($db);
$categories = $categorie->get_full_arbo('product'); $categories = $categorie->get_full_arbo('product');
$htmlforlines = ''; $htmlforlines = '';
foreach ($categories as $row) { foreach ($categories as $row) {
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) $htmlforlines .= '<div class="leftcat'; if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
else $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline'; $htmlforlines .= '<div class="leftcat';
} else {
$htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
}
$htmlforlines .= '" onclick="LoadProducts('.$row['id'].');">'; $htmlforlines .= '" onclick="LoadProducts('.$row['id'].');">';
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) $htmlforlines .= '<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row['id'].'"><br>'; if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
else $htmlforlines .= '<td class="left">'; $htmlforlines .= '<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.'/takepos/public/auto_order.php?genimg=cat&query=cat&id='.$row['id'].'"><br>';
} else {
$htmlforlines .= '<td class="left">';
}
$htmlforlines .= $row['label']; $htmlforlines .= $row['label'];
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) $htmlforlines .= '</div>'."\n"; if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
else $htmlforlines .= '</td></tr>'."\n"; $htmlforlines .= '</div>'."\n";
} else {
$htmlforlines .= '</td></tr>'."\n";
}
} }
$htmlforlines .= '</table>'; $htmlforlines .= '</table>';
$htmlforlines .= '</table>'; $htmlforlines .= '</table>';
print $htmlforlines; print $htmlforlines;
} }
if ($mobilepage == "products") if ($mobilepage == "products") {
{
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$object = new Categorie($db); $object = new Categorie($db);
$catid = GETPOST('catid', 'int'); $catid = GETPOST('catid', 'int');
@ -1227,15 +1259,17 @@ if ($_SESSION["basiclayout"] == 1)
$prods = $object->getObjectsInCateg("product"); $prods = $object->getObjectsInCateg("product");
$htmlforlines = ''; $htmlforlines = '';
foreach ($prods as $row) { foreach ($prods as $row) {
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) $htmlforlines .= '<div class="leftcat'; if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
else $htmlforlines .= '<tr class="drag drop oddeven posinvoiceline'; $htmlforlines .= '<div class="leftcat';
} else {
$htmlforlines .= '<tr class="drag drop oddeven posinvoiceline';
}
$htmlforlines .= '" onclick="AddProduct(\''.$place.'\', '.$row->id.')">'; $htmlforlines .= '" onclick="AddProduct(\''.$place.'\', '.$row->id.')">';
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
$htmlforlines .= '<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.'/takepos/public/auto_order.php?genimg=pro&query=pro&id='.$row->id.'"><br>'; $htmlforlines .= '<img class="imgwrapper" width="33%" src="'.DOL_URL_ROOT.'/takepos/public/auto_order.php?genimg=pro&query=pro&id='.$row->id.'"><br>';
$htmlforlines .= $row->label.''.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency); $htmlforlines .= $row->label.''.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency);
$htmlforlines .= '</div>'."\n"; $htmlforlines .= '</div>'."\n";
} } else {
else {
$htmlforlines .= '<td class="left">'; $htmlforlines .= '<td class="left">';
$htmlforlines .= $row->label; $htmlforlines .= $row->label;
$htmlforlines .= '<div class="right">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>'; $htmlforlines .= '<div class="right">'.price($row->price_ttc, 1, $langs, 1, -1, -1, $conf->currency).'</div>';
@ -1246,8 +1280,7 @@ if ($_SESSION["basiclayout"] == 1)
print $htmlforlines; print $htmlforlines;
} }
if ($mobilepage == "places") if ($mobilepage == "places") {
{
$sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables"; $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables";
$resql = $db->query($sql); $resql = $db->query($sql);
$rows = array(); $rows = array();
@ -1266,39 +1299,40 @@ if ($_SESSION["basiclayout"] == 1)
} }
} }
if ($placeid > 0) if ($placeid > 0) {
{
//In Phone basic layout hide some content depends situation //In Phone basic layout hide some content depends situation
if ($_SESSION["basiclayout"] == 1 && $mobilepage != "invoice" && $action != "order") return; if ($_SESSION["basiclayout"] == 1 && $mobilepage != "invoice" && $action != "order") {
return;
}
if (is_array($invoice->lines) && count($invoice->lines)) if (is_array($invoice->lines) && count($invoice->lines)) {
{
print '<!-- invoice.php show lines of invoices -->'."\n"; print '<!-- invoice.php show lines of invoices -->'."\n";
$tmplines = array_reverse($invoice->lines); $tmplines = array_reverse($invoice->lines);
foreach ($tmplines as $line) foreach ($tmplines as $line) {
{ if ($line->fk_parent_line != false) {
if ($line->fk_parent_line != false)
{
$htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline'; $htmlsupplements[$line->fk_parent_line] .= '<tr class="drag drop oddeven posinvoiceline';
if ($line->special_code == "4") $htmlsupplements[$line->fk_parent_line] .= ' order'; if ($line->special_code == "4") {
$htmlsupplements[$line->fk_parent_line] .= ' order';
}
$htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'">'; $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'">';
$htmlsupplements[$line->fk_parent_line] .= '<td class="left">'; $htmlsupplements[$line->fk_parent_line] .= '<td class="left">';
$htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow'); $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow');
if ($line->product_label) $htmlsupplements[$line->fk_parent_line] .= $line->product_label; if ($line->product_label) {
if ($line->product_label && $line->desc) $htmlsupplements[$line->fk_parent_line] .= '<br>'; $htmlsupplements[$line->fk_parent_line] .= $line->product_label;
if ($line->product_label != $line->desc) }
{ if ($line->product_label && $line->desc) {
$htmlsupplements[$line->fk_parent_line] .= '<br>';
}
if ($line->product_label != $line->desc) {
$firstline = dolGetFirstLineOfText($line->desc); $firstline = dolGetFirstLineOfText($line->desc);
if ($firstline != $line->desc) if ($firstline != $line->desc) {
{
$htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
} else { } else {
$htmlsupplements[$line->fk_parent_line] .= $line->desc; $htmlsupplements[$line->fk_parent_line] .= $line->desc;
} }
} }
$htmlsupplements[$line->fk_parent_line] .= '</td>'; $htmlsupplements[$line->fk_parent_line] .= '</td>';
if ($_SESSION["basiclayout"] != 1) if ($_SESSION["basiclayout"] != 1) {
{
$htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.vatrate($line->remise_percent, true).'</td>'; $htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.vatrate($line->remise_percent, true).'</td>';
$htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.$line->qty.'</td>'; $htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.$line->qty.'</td>';
$htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.price($line->total_ttc).'</td>'; $htmlsupplements[$line->fk_parent_line] .= '<td class="right">'.price($line->total_ttc).'</td>';
@ -1314,11 +1348,15 @@ if ($placeid > 0)
} }
$htmlforlines .= '" id="'.$line->id.'">'; $htmlforlines .= '" id="'.$line->id.'">';
$htmlforlines .= '<td class="left">'; $htmlforlines .= '<td class="left">';
if ($_SESSION["basiclayout"] == 1) $htmlforlines .= '<span class="phoneqty">'.$line->qty."</span> x "; if ($_SESSION["basiclayout"] == 1) {
if (isset($line->product_type)) $htmlforlines .= '<span class="phoneqty">'.$line->qty."</span> x ";
{ }
if (empty($line->product_type)) $htmlforlines .= img_object('', 'product').' '; if (isset($line->product_type)) {
else $htmlforlines .= img_object('', 'service').' '; if (empty($line->product_type)) {
$htmlforlines .= img_object('', 'product').' ';
} else {
$htmlforlines .= img_object('', 'service').' ';
}
} }
if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) { if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) {
$tooltiptext = ''; $tooltiptext = '';
@ -1326,45 +1364,53 @@ if ($placeid > 0)
$tooltiptext .= '<b>'.$langs->trans("Ref").'</b> : '.$line->product_ref.'<br>'; $tooltiptext .= '<b>'.$langs->trans("Ref").'</b> : '.$line->product_ref.'<br>';
$tooltiptext .= '<b>'.$langs->trans("Label").'</b> : '.$line->product_label.'<br>'; $tooltiptext .= '<b>'.$langs->trans("Label").'</b> : '.$line->product_label.'<br>';
if ($line->product_label != $line->desc) { if ($line->product_label != $line->desc) {
if ($line->desc) $tooltiptext .= '<br>'; if ($line->desc) {
$tooltiptext .= '<br>';
}
$tooltiptext .= $line->desc; $tooltiptext .= $line->desc;
} }
} }
$htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext); $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
} else { } else {
if ($line->product_label) $htmlforlines .= $line->product_label; if ($line->product_label) {
if ($line->product_label != $line->desc) $htmlforlines .= $line->product_label;
{ }
if ($line->product_label && $line->desc) $htmlforlines .= '<br>'; if ($line->product_label != $line->desc) {
if ($line->product_label && $line->desc) {
$htmlforlines .= '<br>';
}
$firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES); $firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES);
if ($firstline != $line->desc) if ($firstline != $line->desc) {
{
$htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc);
} else { } else {
$htmlforlines .= $line->desc; $htmlforlines .= $line->desc;
} }
} }
} }
if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "<br>(".$line->array_options['options_order_notes'].")"; if (!empty($line->array_options['options_order_notes'])) {
$htmlforlines .= "<br>(".$line->array_options['options_order_notes'].")";
}
if ($_SESSION["basiclayout"] == 1) { if ($_SESSION["basiclayout"] == 1) {
$htmlforlines .= '</td><td class="right phonetable"><button type="button" onclick="SetQty(place, '.$line->rowid.', '.($line->qty - 1).');" class="publicphonebutton2 phonered">-</button>&nbsp;&nbsp;<button type="button" onclick="SetQty(place, '.$line->rowid.', '.($line->qty + 1).');" class="publicphonebutton2 phonegreen">+</button>'; $htmlforlines .= '</td><td class="right phonetable"><button type="button" onclick="SetQty(place, '.$line->rowid.', '.($line->qty - 1).');" class="publicphonebutton2 phonered">-</button>&nbsp;&nbsp;<button type="button" onclick="SetQty(place, '.$line->rowid.', '.($line->qty + 1).');" class="publicphonebutton2 phonegreen">+</button>';
} }
if ($_SESSION["basiclayout"] != 1) if ($_SESSION["basiclayout"] != 1) {
{
$moreinfo = ''; $moreinfo = '';
$moreinfo .= $langs->transcountry("TotalHT", $mysoc->country_code).': '.price($line->total_ht); $moreinfo .= $langs->transcountry("TotalHT", $mysoc->country_code).': '.price($line->total_ht);
if ($line->vat_src_code) $moreinfo .= '<br>'.$langs->trans("VATCode").': '.$line->vat_src_code; if ($line->vat_src_code) {
$moreinfo .= '<br>'.$langs->trans("VATCode").': '.$line->vat_src_code;
}
$moreinfo .= '<br>'.$langs->transcountry("TotalVAT", $mysoc->country_code).': '.price($line->total_tva); $moreinfo .= '<br>'.$langs->transcountry("TotalVAT", $mysoc->country_code).': '.price($line->total_tva);
$moreinfo .= '<br>'.$langs->transcountry("TotalLT1", $mysoc->country_code).': '.price($line->total_localtax1); $moreinfo .= '<br>'.$langs->transcountry("TotalLT1", $mysoc->country_code).': '.price($line->total_localtax1);
$moreinfo .= '<br>'.$langs->transcountry("TotalLT2", $mysoc->country_code).': '.price($line->total_localtax2); $moreinfo .= '<br>'.$langs->transcountry("TotalLT2", $mysoc->country_code).': '.price($line->total_localtax2);
$moreinfo .= '<br>'.$langs->transcountry("TotalTTC", $mysoc->country_code).': '.price($line->total_ttc); $moreinfo .= '<br>'.$langs->transcountry("TotalTTC", $mysoc->country_code).': '.price($line->total_ttc);
//$moreinfo .= $langs->trans("TotalHT").': '.$line->total_ht; //$moreinfo .= $langs->trans("TotalHT").': '.$line->total_ht;
if ($line->date_start || $line->date_end) $htmlforlines .= '<br><div class="clearboth nowraponall">'.get_date_range($line->date_start, $line->date_end).'</div>'; if ($line->date_start || $line->date_end) {
$htmlforlines .= '<br><div class="clearboth nowraponall">'.get_date_range($line->date_start, $line->date_end).'</div>';
}
$htmlforlines .= '</td>'; $htmlforlines .= '</td>';
$htmlforlines .= '<td class="right">'.vatrate($line->remise_percent, true).'</td>'; $htmlforlines .= '<td class="right">'.vatrate($line->remise_percent, true).'</td>';
$htmlforlines .= '<td class="right">'; $htmlforlines .= '<td class="right">';
if (!empty($conf->stock->enabled) && !empty($user->rights->stock->mouvement->lire)) if (!empty($conf->stock->enabled) && !empty($user->rights->stock->mouvement->lire)) {
{
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
if (!empty($conf->global->$constantforkey) && $line->fk_product > 0) { if (!empty($conf->global->$constantforkey) && $line->fk_product > 0) {
$sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp"; $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp";
@ -1380,9 +1426,13 @@ if ($placeid > 0)
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$stock_real = price2num($obj->reel, 'MS'); $stock_real = price2num($obj->reel, 'MS');
$htmlforlines .= $line->qty; $htmlforlines .= $line->qty;
if ($line->qty && $line->qty > $stock_real) $htmlforlines .= '<span style="color: var(--amountremaintopaycolor)">'; if ($line->qty && $line->qty > $stock_real) {
$htmlforlines .= '<span style="color: var(--amountremaintopaycolor)">';
}
$htmlforlines .= ' <span class="posstocktoolow">('.$langs->trans("Stock").' '.$stock_real.')</span>'; $htmlforlines .= ' <span class="posstocktoolow">('.$langs->trans("Stock").' '.$stock_real.')</span>';
if ($line->qty && $line->qty > $stock_real) $htmlforlines .= "</span>"; if ($line->qty && $line->qty > $stock_real) {
$htmlforlines .= "</span>";
}
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
@ -1424,13 +1474,17 @@ if ($placeid > 0)
} }
} else { } else {
print '<tr class="drag drop oddeven"><td class="left"><span class="opacitymedium">'.$langs->trans("Empty").'</span></td><td></td><td></td><td></td>'; print '<tr class="drag drop oddeven"><td class="left"><span class="opacitymedium">'.$langs->trans("Empty").'</span></td><td></td><td></td><td></td>';
if (!empty($conf->global->TAKEPOS_SHOW_HT)){ print '<td></td>'; } if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
print '<td></td>';
}
print '</tr>'; print '</tr>';
} }
} else { // No invoice generated yet } else { // No invoice generated yet
print '<tr class="drag drop oddeven"><td class="left"><span class="opacitymedium">'.$langs->trans("Empty").'</span></td><td></td><td></td><td></td>'; print '<tr class="drag drop oddeven"><td class="left"><span class="opacitymedium">'.$langs->trans("Empty").'</span></td><td></td><td></td><td></td>';
if (!empty($conf->global->TAKEPOS_SHOW_HT)){ print '<td></td>'; } if (!empty($conf->global->TAKEPOS_SHOW_HT)) {
print '<td></td>';
}
print '</tr>'; print '</tr>';
} }
@ -1441,8 +1495,7 @@ if (($action == "valid" || $action == "history") && $invoice->type != Facture::T
} }
if ($action == "search") if ($action == "search") {
{
print '<center> print '<center>
<input type="text" id="search" name="search" onkeyup="Search2();" name="search" style="width:80%;font-size: 150%;" placeholder=' . $langs->trans('Search').' <input type="text" id="search" name="search" onkeyup="Search2();" name="search" style="width:80%;font-size: 150%;" placeholder=' . $langs->trans('Search').'
</center>'; </center>';

View File

@ -25,11 +25,21 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOCSRFCHECK')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); define('NOCSRFCHECK', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
require '../main.inc.php'; // Load $user and permissions require '../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@ -50,19 +60,16 @@ if (empty($user->rights->takepos->run)) {
*/ */
$invoice = new Facture($db); $invoice = new Facture($db);
if ($invoiceid > 0) if ($invoiceid > 0) {
{
$invoice->fetch($invoiceid); $invoice->fetch($invoiceid);
} else { } else {
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
$resql = $db->query($sql); $resql = $db->query($sql);
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) if ($obj) {
{
$invoiceid = $obj->rowid; $invoiceid = $obj->rowid;
} }
if (!$invoiceid) if (!$invoiceid) {
{
$invoiceid = 0; // Invoice does not exist yet $invoiceid = 0; // Invoice does not exist yet
} else { } else {
$invoice->fetch($invoiceid); $invoice->fetch($invoiceid);
@ -92,9 +99,15 @@ $resql = $db->query($sql);
if ($resql) { if ($resql) {
while ($obj = $db->fetch_object($resql)) { while ($obj = $db->fetch_object($resql)) {
$paycode = $obj->code; $paycode = $obj->code;
if ($paycode == 'LIQ') $paycode = 'CASH'; if ($paycode == 'LIQ') {
if ($paycode == 'CB') $paycode = 'CB'; $paycode = 'CASH';
if ($paycode == 'CHQ') $paycode = 'CHEQUE'; }
if ($paycode == 'CB') {
$paycode = 'CB';
}
if ($paycode == 'CHQ') {
$paycode = 'CHEQUE';
}
$accountname = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"]; $accountname = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"];
if (!empty($conf->global->$accountname) && $conf->global->$accountname > 0) { if (!empty($conf->global->$accountname) && $conf->global->$accountname > 0) {
@ -106,7 +119,9 @@ if ($resql) {
?> ?>
<link rel="stylesheet" href="css/pos.css.php"> <link rel="stylesheet" href="css/pos.css.php">
<?php <?php
if ($conf->global->TAKEPOS_COLOR_THEME == 1) print '<link rel="stylesheet" href="css/colorful.css">'; if ($conf->global->TAKEPOS_COLOR_THEME == 1) {
print '<link rel="stylesheet" href="css/colorful.css">';
}
?> ?>
</head> </head>
<body> <body>
@ -114,14 +129,16 @@ if ($conf->global->TAKEPOS_COLOR_THEME == 1) print '<link rel="stylesheet" href=
<script> <script>
<?php <?php
$remaintopay = 0; $remaintopay = 0;
if ($invoice->id > 0) if ($invoice->id > 0) {
{
$remaintopay = $invoice->getRemainToPay(); $remaintopay = $invoice->getRemainToPay();
} }
$alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0); $alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0);
if ($conf->global->TAKEPOS_NUMPAD == 0) print "var received='';"; if ($conf->global->TAKEPOS_NUMPAD == 0) {
else print "var received=0;"; print "var received='';";
} else {
print "var received=0;";
}
?> ?>
var alreadypayed = <?php echo $alreadypayed ?>; var alreadypayed = <?php echo $alreadypayed ?>;
@ -129,8 +146,11 @@ else print "var received=0;";
function addreceived(price) function addreceived(price)
{ {
<?php <?php
if (empty($conf->global->TAKEPOS_NUMPAD)) print 'received+=String(price);'."\n"; if (empty($conf->global->TAKEPOS_NUMPAD)) {
else print 'received+=parseFloat(price);'."\n"; print 'received+=String(price);'."\n";
} else {
print 'received+=parseFloat(price);'."\n";
}
?> ?>
$('.change1').html(pricejs(parseFloat(received), 'MT')); $('.change1').html(pricejs(parseFloat(received), 'MT'));
$('.change1').val(parseFloat(received)); $('.change1').val(parseFloat(received));
@ -294,13 +314,19 @@ print '<button type="button" class="calcbutton" onclick="addreceived('.($numpad
$payIcon = ''; $payIcon = '';
if ($paycode == 'LIQ') { if ($paycode == 'LIQ') {
$paycode = 'cash'; $paycode = 'cash';
if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins'; if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
$payIcon = 'coins';
}
} elseif ($paycode == 'CB') { } elseif ($paycode == 'CB') {
$paycode = 'card'; $paycode = 'card';
if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card'; if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
$payIcon = 'credit-card';
}
} elseif ($paycode == 'CHQ') { } elseif ($paycode == 'CHQ') {
$paycode = 'cheque'; $paycode = 'cheque';
if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check'; if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
$payIcon = 'money-check';
}
} }
print '<button type="button" class="calcbutton2" onclick="Validate(\''.$langs->trans($paycode).'\');">'.(!empty($payIcon) ? '<span class="fa fa-2x fa-'.$payIcon.' iconwithlabel"></span><span class="hideonsmartphone"><br>'. $langs->trans("PaymentTypeShort".$arrayOfValidPaymentModes[0]->code) : $langs->trans("PaymentTypeShort".$arrayOfValidPaymentModes[0]->code)).'</span></button>'; print '<button type="button" class="calcbutton2" onclick="Validate(\''.$langs->trans($paycode).'\');">'.(!empty($payIcon) ? '<span class="fa fa-2x fa-'.$payIcon.' iconwithlabel"></span><span class="hideonsmartphone"><br>'. $langs->trans("PaymentTypeShort".$arrayOfValidPaymentModes[0]->code) : $langs->trans("PaymentTypeShort".$arrayOfValidPaymentModes[0]->code)).'</span></button>';
@ -317,13 +343,19 @@ print '<button type="button" class="calcbutton" onclick="addreceived('.($numpad
$payIcon = ''; $payIcon = '';
if ($paycode == 'LIQ') { if ($paycode == 'LIQ') {
$paycode = 'cash'; $paycode = 'cash';
if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins'; if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
$payIcon = 'coins';
}
} elseif ($paycode == 'CB') { } elseif ($paycode == 'CB') {
$paycode = 'card'; $paycode = 'card';
if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card'; if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
$payIcon = 'credit-card';
}
} elseif ($paycode == 'CHQ') { } elseif ($paycode == 'CHQ') {
$paycode = 'cheque'; $paycode = 'cheque';
if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check'; if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
$payIcon = 'money-check';
}
} }
print '<button type="button" class="calcbutton2" onclick="Validate(\''.$langs->trans($paycode).'\');">'.(!empty($payIcon) ? '<span class="fa fa-2x fa-'.$payIcon.' iconwithlabel"></span><br> '. $langs->trans("PaymentTypeShort".$arrayOfValidPaymentModes[1]->code) : $langs->trans("PaymentTypeShort".$arrayOfValidPaymentModes[1]->code)).'</button>'; print '<button type="button" class="calcbutton2" onclick="Validate(\''.$langs->trans($paycode).'\');">'.(!empty($payIcon) ? '<span class="fa fa-2x fa-'.$payIcon.' iconwithlabel"></span><br> '. $langs->trans("PaymentTypeShort".$arrayOfValidPaymentModes[1]->code) : $langs->trans("PaymentTypeShort".$arrayOfValidPaymentModes[1]->code)).'</button>';
@ -341,13 +373,19 @@ print '<button type="button" class="calcbutton" onclick="addreceived('.($numpad
$payIcon = ''; $payIcon = '';
if ($paycode == 'LIQ') { if ($paycode == 'LIQ') {
$paycode = 'cash'; $paycode = 'cash';
if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins'; if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
$payIcon = 'coins';
}
} elseif ($paycode == 'CB') { } elseif ($paycode == 'CB') {
$paycode = 'card'; $paycode = 'card';
if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card'; if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
$payIcon = 'credit-card';
}
} elseif ($paycode == 'CHQ') { } elseif ($paycode == 'CHQ') {
$paycode = 'cheque'; $paycode = 'cheque';
if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check'; if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
$payIcon = 'money-check';
}
} }
print '<button type="button" class="calcbutton2" onclick="Validate(\''.$langs->trans($paycode).'\');">'.(!empty($payIcon) ? '<span class="fa fa-2x fa-'.$payIcon.' iconwithlabel"></span>'.(!empty($conf->global->TAKEPOS_NUMPAD_FORCE_PAYMENT_ICONS_LABELS) ? '<br> '. $langs->trans("PaymentTypeShort".$arrayOfValidPaymentModes[2]->code) : '') : $langs->trans("PaymentTypeShort".$arrayOfValidPaymentModes[2]->code)).'</button>'; print '<button type="button" class="calcbutton2" onclick="Validate(\''.$langs->trans($paycode).'\');">'.(!empty($payIcon) ? '<span class="fa fa-2x fa-'.$payIcon.' iconwithlabel"></span>'.(!empty($conf->global->TAKEPOS_NUMPAD_FORCE_PAYMENT_ICONS_LABELS) ? '<br> '. $langs->trans("PaymentTypeShort".$arrayOfValidPaymentModes[2]->code) : '') : $langs->trans("PaymentTypeShort".$arrayOfValidPaymentModes[2]->code)).'</button>';

View File

@ -25,13 +25,25 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOCSRFCHECK')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); define('NOCSRFCHECK', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) require '../main.inc.php'; if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
require '../main.inc.php';
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@ -47,8 +59,7 @@ $action = GETPOST('action', 'aZ09');
$setterminal = GETPOST('setterminal', 'int'); $setterminal = GETPOST('setterminal', 'int');
$idproduct = GETPOST('idproduct', 'int'); $idproduct = GETPOST('idproduct', 'int');
if ($setterminal > 0) if ($setterminal > 0) {
{
$_SESSION["takeposterminal"] = $setterminal; $_SESSION["takeposterminal"] = $setterminal;
} }
@ -83,8 +94,7 @@ if ($action == "productinfo") {
print '<h1>'.$langs->trans('StatusOrderDelivered').'</h1>'; print '<h1>'.$langs->trans('StatusOrderDelivered').'</h1>';
print '<button type="button" class="publicphonebutton2 phoneblue total" onclick="CheckPlease();">'.$langs->trans('Payment').'</button>'; print '<button type="button" class="publicphonebutton2 phoneblue total" onclick="CheckPlease();">'.$langs->trans('Payment').'</button>';
print '<br>'; print '<br>';
} } elseif ($action == "checkplease") {
elseif ($action == "checkplease") {
if (GETPOSTISSET("payment")) { if (GETPOSTISSET("payment")) {
print '<h1>'.$langs->trans('StatusOrderDelivered').'</h1>'; print '<h1>'.$langs->trans('StatusOrderDelivered').'</h1>';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
@ -114,10 +124,8 @@ elseif ($action == "checkplease") {
$selectedline = GETPOST('selectedline', 'int'); $selectedline = GETPOST('selectedline', 'int');
$invoice = new Facture($db); $invoice = new Facture($db);
$invoice->fetch($placeid); $invoice->fetch($placeid);
foreach ($invoice->lines as $line) foreach ($invoice->lines as $line) {
{ if ($line->id == $selectedline) {
if ($line->id == $selectedline)
{
$prod = new Product($db); $prod = new Product($db);
$prod->fetch($line->fk_product); $prod->fetch($line->fk_product);
print "<b>".$prod->label."</b><br>"; print "<b>".$prod->label."</b><br>";
@ -133,7 +141,9 @@ elseif ($action == "checkplease") {
} else { } else {
// Title // Title
$title = 'TakePOS - Dolibarr '.DOL_VERSION; $title = 'TakePOS - Dolibarr '.DOL_VERSION;
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
$title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
}
$head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/> $head = '<meta name="apple-mobile-web-app-title" content="TakePOS"/>
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
@ -149,12 +159,9 @@ elseif ($action == "checkplease") {
// Search root category to know its level // Search root category to know its level
//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0; //$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
$levelofrootcategory = 0; $levelofrootcategory = 0;
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
{ foreach ($categories as $key => $categorycursor) {
foreach ($categories as $key => $categorycursor) if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID) {
{
if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID)
{
$levelofrootcategory = $categorycursor['level']; $levelofrootcategory = $categorycursor['level'];
break; break;
} }
@ -164,10 +171,8 @@ elseif ($action == "checkplease") {
$maincategories = array(); $maincategories = array();
$subcategories = array(); $subcategories = array();
foreach ($categories as $key => $categorycursor) foreach ($categories as $key => $categorycursor) {
{ if ($categorycursor['level'] == $levelofmaincategories) {
if ($categorycursor['level'] == $levelofmaincategories)
{
$maincategories[$key] = $categorycursor; $maincategories[$key] = $categorycursor;
} else { } else {
$subcategories[$key] = $categorycursor; $subcategories[$key] = $categorycursor;
@ -203,8 +208,7 @@ function LoadPlace(placeid){
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
echo '$("#phonediv2").load("auto_order.php?mobilepage=invoice&place="+place, function() { echo '$("#phonediv2").load("auto_order.php?mobilepage=invoice&place="+place, function() {
});'; });';
} } else {
else {
echo '$("#phonediv2").load("invoice.php?mobilepage=invoice&place="+place, function() { echo '$("#phonediv2").load("invoice.php?mobilepage=invoice&place="+place, function() {
});'; });';
} }
@ -219,8 +223,7 @@ function AddProduct(placeid, productid){
print 'place=placeid; print 'place=placeid;
$("#phonediv1").load("auto_order.php?action=productinfo&place="+place+"&idproduct="+productid, function() { $("#phonediv1").load("auto_order.php?action=productinfo&place="+place+"&idproduct="+productid, function() {
});'; });';
} } else {
else {
print 'AddProductConfirm(placeid, productid);'; print 'AddProductConfirm(placeid, productid);';
} }
?> ?>
@ -237,8 +240,7 @@ function AddProductConfirm(placeid, productid){
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
echo '$("#phonediv2").load("auto_order.php?mobilepage=invoice&action=addline&place="+place+"&idproduct="+productid, function() { echo '$("#phonediv2").load("auto_order.php?mobilepage=invoice&action=addline&place="+place+"&idproduct="+productid, function() {
});'; });';
} } else {
else {
echo '$("#phonediv2").load("invoice.php?mobilepage=invoice&action=addline&place="+place+"&idproduct="+productid, function() { echo '$("#phonediv2").load("invoice.php?mobilepage=invoice&action=addline&place="+place+"&idproduct="+productid, function() {
});'; });';
} }
@ -258,8 +260,7 @@ function SetQty(place, selectedline, qty){
}); });
} }
<?php <?php
} } else {
else {
?> ?>
if (qty==0){ if (qty==0){
$("#phonediv2").load("invoice.php?mobilepage=invoice&action=deleteline&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline, function() { $("#phonediv2").load("invoice.php?mobilepage=invoice&action=deleteline&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline, function() {
@ -287,8 +288,7 @@ function LoadCats(){
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
echo '$("#phonediv1").load("auto_order.php?mobilepage=cats&place="+place, function() { echo '$("#phonediv1").load("auto_order.php?mobilepage=cats&place="+place, function() {
});'; });';
} } else {
else {
echo '$("#phonediv1").load("invoice.php?mobilepage=cats&place="+place, function() { echo '$("#phonediv1").load("invoice.php?mobilepage=cats&place="+place, function() {
});'; });';
} }
@ -301,8 +301,7 @@ function LoadProducts(idcat){
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
echo '$("#phonediv1").load("auto_order.php?mobilepage=products&catid="+idcat+"&place="+place, function() { echo '$("#phonediv1").load("auto_order.php?mobilepage=products&catid="+idcat+"&place="+place, function() {
});'; });';
} } else {
else {
echo '$("#phonediv1").load("invoice.php?mobilepage=products&catid="+idcat+"&place="+place, function() { echo '$("#phonediv1").load("invoice.php?mobilepage=products&catid="+idcat+"&place="+place, function() {
});'; });';
} }
@ -322,8 +321,7 @@ function TakeposPrintingOrder(){
});'; });';
echo '$("#phonediv1").load("auto_order.php?action=publicpayment&place="+place, function() { echo '$("#phonediv1").load("auto_order.php?action=publicpayment&place="+place, function() {
});'; });';
} } else {
else {
echo '$("#phonediv2").load("invoice.php?action=order&place="+place, function() { echo '$("#phonediv2").load("invoice.php?action=order&place="+place, function() {
});'; });';
} }
@ -350,7 +348,9 @@ function CheckPlease(payment){
<body style="background-color:#D1D1D1;"> <body style="background-color:#D1D1D1;">
<?php <?php
if ($conf->global->TAKEPOS_NUM_TERMINALS != "1" && $_SESSION["takeposterminal"] == "") print '<div class="dialog-info-takepos-terminal" id="dialog-info" title="TakePOS">'.$langs->trans('TerminalSelect').'</div>'; if ($conf->global->TAKEPOS_NUM_TERMINALS != "1" && $_SESSION["takeposterminal"] == "") {
print '<div class="dialog-info-takepos-terminal" id="dialog-info" title="TakePOS">'.$langs->trans('TerminalSelect').'</div>';
}
?> ?>
<div class="container"> <div class="container">
<div class="phonebuttonsrow"> <div class="phonebuttonsrow">
@ -360,8 +360,7 @@ function CheckPlease(payment){
print '<button type="button" class="phonebutton" onclick="LoadCats();">'.strtoupper(substr($langs->trans('Categories'), 0, 3)).'</button>'; print '<button type="button" class="phonebutton" onclick="LoadCats();">'.strtoupper(substr($langs->trans('Categories'), 0, 3)).'</button>';
print '<button type="button" class="phonebutton" onclick="TakeposPrintingOrder();">'.strtoupper(substr($langs->trans('Order'), 0, 3)).'</button>'; print '<button type="button" class="phonebutton" onclick="TakeposPrintingOrder();">'.strtoupper(substr($langs->trans('Order'), 0, 3)).'</button>';
print '<button type="button" class="phonebutton" onclick="Exit();">'.strtoupper(substr($langs->trans('Logout'), 0, 3)).'</button>'; print '<button type="button" class="phonebutton" onclick="Exit();">'.strtoupper(substr($langs->trans('Logout'), 0, 3)).'</button>';
} } else {
else {
print '<button type="button" class="publicphonebutton phoneblue" onclick="LoadCats();">'.strtoupper(substr($langs->trans('Categories'), 0, 5)).'</button>'; print '<button type="button" class="publicphonebutton phoneblue" onclick="LoadCats();">'.strtoupper(substr($langs->trans('Categories'), 0, 5)).'</button>';
print '<button type="button" class="publicphonebutton phoneorange" onclick="PublicPreOrder();">'.strtoupper(substr($langs->trans('Order'), 0, 5)).'</button>'; print '<button type="button" class="publicphonebutton phoneorange" onclick="PublicPreOrder();">'.strtoupper(substr($langs->trans('Order'), 0, 5)).'</button>';
print '<button type="button" class="publicphonebutton phonegreen" onclick="CheckPlease();">'.strtoupper(substr($langs->trans('Payment'), 0, 5)).'</button>'; print '<button type="button" class="publicphonebutton phonegreen" onclick="CheckPlease();">'.strtoupper(substr($langs->trans('Payment'), 0, 5)).'</button>';

View File

@ -21,18 +21,30 @@
* \brief Public orders for customers * \brief Public orders for customers
*/ */
if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) if (!defined("NOLOGIN")) {
if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); }
if (!defined('NOIPCHECK')) {
define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
if (!defined('NOBROWSERNOTIF')) {
define('NOBROWSERNOTIF', '1');
}
require '../../main.inc.php'; require '../../main.inc.php';
if (!$conf->global->TAKEPOS_AUTO_ORDER) accessforbidden(); // If Auto Order is disabled never allow NO LOGIN access if (!$conf->global->TAKEPOS_AUTO_ORDER) {
accessforbidden(); // If Auto Order is disabled never allow NO LOGIN access
}
$_SESSION["basiclayout"] = 1; $_SESSION["basiclayout"] = 1;
$_SESSION["takeposterminal"] = 1; $_SESSION["takeposterminal"] = 1;
define('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE', 1); define('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE', 1);
if (GETPOSTISSET("mobilepage")) require '../invoice.php'; if (GETPOSTISSET("mobilepage")) {
elseif (GETPOSTISSET("genimg")) require DOL_DOCUMENT_ROOT.'/takepos/genimg/index.php'; require '../invoice.php';
else require '../phone.php'; } elseif (GETPOSTISSET("genimg")) {
require DOL_DOCUMENT_ROOT.'/takepos/genimg/index.php';
} else {
require '../phone.php';
}

View File

@ -21,15 +21,23 @@
* \brief Public menu for customers * \brief Public menu for customers
*/ */
if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) if (!defined("NOLOGIN")) {
if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); }
if (!defined('NOIPCHECK')) {
define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
if (!defined('NOBROWSERNOTIF')) {
define('NOBROWSERNOTIF', '1');
}
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
if (!$conf->global->TAKEPOS_QR_MENU) accessforbidden(); // If Restaurant Menu is disabled never allow NO LOGIN access if (!$conf->global->TAKEPOS_QR_MENU) {
accessforbidden(); // If Restaurant Menu is disabled never allow NO LOGIN access
}
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
@ -52,12 +60,9 @@ if (!$conf->global->TAKEPOS_QR_MENU) accessforbidden(); // If Restaurant Menu is
$categorie = new Categorie($db); $categorie = new Categorie($db);
$categories = $categorie->get_full_arbo('product', (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) ? $conf->global->TAKEPOS_ROOT_CATEGORY_ID : 0), 1); $categories = $categorie->get_full_arbo('product', (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) ? $conf->global->TAKEPOS_ROOT_CATEGORY_ID : 0), 1);
$levelofrootcategory = 0; $levelofrootcategory = 0;
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
{ foreach ($categories as $key => $categorycursor) {
foreach ($categories as $key => $categorycursor) if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID) {
{
if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID)
{
$levelofrootcategory = $categorycursor['level']; $levelofrootcategory = $categorycursor['level'];
break; break;
} }
@ -67,10 +72,8 @@ $levelofmaincategories = $levelofrootcategory + 1;
$maincategories = array(); $maincategories = array();
$subcategories = array(); $subcategories = array();
foreach ($categories as $key => $categorycursor) foreach ($categories as $key => $categorycursor) {
{ if ($categorycursor['level'] == $levelofmaincategories) {
if ($categorycursor['level'] == $levelofmaincategories)
{
$maincategories[$key] = $categorycursor; $maincategories[$key] = $categorycursor;
} else { } else {
$subcategories[$key] = $categorycursor; $subcategories[$key] = $categorycursor;

View File

@ -31,10 +31,18 @@ if (!isset($action)) {
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); define('NOTOKENRENEWAL', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); }
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
require '../main.inc.php'; // If this file is called from send.php avoid load again require '../main.inc.php'; // If this file is called from send.php avoid load again
} }
@ -59,13 +67,11 @@ if (empty($user->rights->takepos->run)) {
top_httphead('text/html'); top_httphead('text/html');
if ($place > 0) if ($place > 0) {
{
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
$resql = $db->query($sql); $resql = $db->query($sql);
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) if ($obj) {
{
$facid = $obj->rowid; $facid = $obj->rowid;
} }
} }
@ -104,12 +110,15 @@ if (!empty($hookmanager->resPrint)) {
<p class="left"> <p class="left">
<?php <?php
$constFreeText = 'TAKEPOS_HEADER'.$_SESSION['takeposterminal']; $constFreeText = 'TAKEPOS_HEADER'.$_SESSION['takeposterminal'];
if (!empty($conf->global->TAKEPOS_HEADER) || !empty($conf->global->{$constFreeText})) if (!empty($conf->global->TAKEPOS_HEADER) || !empty($conf->global->{$constFreeText})) {
{
$newfreetext = ''; $newfreetext = '';
$substitutionarray = getCommonSubstitutionArray($langs); $substitutionarray = getCommonSubstitutionArray($langs);
if (!empty($conf->global->TAKEPOS_HEADER)) $newfreetext .= make_substitutions($conf->global->TAKEPOS_HEADER, $substitutionarray); if (!empty($conf->global->TAKEPOS_HEADER)) {
if (!empty($conf->global->{$constFreeText})) $newfreetext .= make_substitutions($conf->global->{$constFreeText}, $substitutionarray); $newfreetext .= make_substitutions($conf->global->TAKEPOS_HEADER, $substitutionarray);
}
if (!empty($conf->global->{$constFreeText})) {
$newfreetext .= make_substitutions($conf->global->{$constFreeText}, $substitutionarray);
}
print $newfreetext; print $newfreetext;
} }
?> ?>
@ -117,16 +126,22 @@ if (!empty($conf->global->TAKEPOS_HEADER) || !empty($conf->global->{$constFreeTe
<p class="right"> <p class="right">
<?php <?php
print $langs->trans('Date')." ".dol_print_date($object->date, 'day').'<br>'; print $langs->trans('Date')." ".dol_print_date($object->date, 'day').'<br>';
if (!empty($conf->global->TAKEPOS_RECEIPT_NAME)) print $conf->global->TAKEPOS_RECEIPT_NAME." "; if (!empty($conf->global->TAKEPOS_RECEIPT_NAME)) {
if ($object->statut == Facture::STATUS_DRAFT) print str_replace(")", "", str_replace("-", " ".$langs->trans('Place')." ", str_replace("(PROV-POS", $langs->trans("Terminal")." ", $object->ref))); print $conf->global->TAKEPOS_RECEIPT_NAME." ";
else print $object->ref; }
if ($conf->global->TAKEPOS_SHOW_CUSTOMER) if ($object->statut == Facture::STATUS_DRAFT) {
{ print str_replace(")", "", str_replace("-", " ".$langs->trans('Place')." ", str_replace("(PROV-POS", $langs->trans("Terminal")." ", $object->ref)));
if ($object->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}) } else {
{ print $object->ref;
}
if ($conf->global->TAKEPOS_SHOW_CUSTOMER) {
if ($object->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}) {
$soc = new Societe($db); $soc = new Societe($db);
if ($object->socid > 0) $soc->fetch($object->socid); if ($object->socid > 0) {
else $soc->fetch($conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}); $soc->fetch($object->socid);
} else {
$soc->fetch($conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]});
}
print "<br>".$langs->trans("Customer").': '.$soc->name; print "<br>".$langs->trans("Customer").': '.$soc->name;
} }
} }
@ -139,32 +154,46 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
<tr> <tr>
<th class="center"><?php print $langs->trans("Label"); ?></th> <th class="center"><?php print $langs->trans("Label"); ?></th>
<th class="right"><?php print $langs->trans("Qty"); ?></th> <th class="right"><?php print $langs->trans("Qty"); ?></th>
<th class="right"><?php if ($gift != 1) print $langs->trans("Price"); ?></th> <th class="right"><?php if ($gift != 1) {
print $langs->trans("Price");
} ?></th>
<?php if (!empty($conf->global->TAKEPOS_SHOW_HT_RECEIPT)) { ?> <?php if (!empty($conf->global->TAKEPOS_SHOW_HT_RECEIPT)) { ?>
<th class="right"><?php if ($gift != 1) print $langs->trans("TotalHT"); ?></th> <th class="right"><?php if ($gift != 1) {
print $langs->trans("TotalHT");
} ?></th>
<?php } ?> <?php } ?>
<th class="right"><?php if ($gift != 1) print $langs->trans("TotalTTC"); ?></th> <th class="right"><?php if ($gift != 1) {
print $langs->trans("TotalTTC");
} ?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
foreach ($object->lines as $line) foreach ($object->lines as $line) {
{
?> ?>
<tr> <tr>
<td> <td>
<?php if (!empty($line->product_label)) echo $line->product_label; <?php if (!empty($line->product_label)) {
else echo $line->description; ?> echo $line->product_label;
} else {
echo $line->description;
} ?>
</td> </td>
<td class="right"><?php echo $line->qty; ?></td> <td class="right"><?php echo $line->qty; ?></td>
<td class="right"><?php if ($gift != 1) echo price(price2num($line->total_ttc / $line->qty, 'MT'), 1); ?></td> <td class="right"><?php if ($gift != 1) {
echo price(price2num($line->total_ttc / $line->qty, 'MT'), 1);
} ?></td>
<?php <?php
if (!empty($conf->global->TAKEPOS_SHOW_HT_RECEIPT)) { ?> if (!empty($conf->global->TAKEPOS_SHOW_HT_RECEIPT)) { ?>
<td class="right"><?php if ($gift != 1) echo price($line->total_ht, 1); ?></td> <td class="right"><?php if ($gift != 1) {
echo price($line->total_ht, 1);
} ?></td>
<?php <?php
} }
?> ?>
<td class="right"><?php if ($gift != 1) echo price($line->total_ttc, 1); ?></td> <td class="right"><?php if ($gift != 1) {
echo price($line->total_ttc, 1);
} ?></td>
</tr> </tr>
<?php <?php
} }
@ -174,13 +203,16 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
<br> <br>
<table class="right"> <table class="right">
<tr> <tr>
<th class="right"><?php if ($gift != 1) echo $langs->trans("TotalHT"); ?></th> <th class="right"><?php if ($gift != 1) {
<td class="right"><?php if ($gift != 1) echo price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td> echo $langs->trans("TotalHT");
} ?></th>
<td class="right"><?php if ($gift != 1) {
echo price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n";
} ?></td>
</tr> </tr>
<?php if ($conf->global->TAKEPOS_TICKET_VAT_GROUPPED) { <?php if ($conf->global->TAKEPOS_TICKET_VAT_GROUPPED) {
$vat_groups = array(); $vat_groups = array();
foreach ($object->lines as $line) foreach ($object->lines as $line) {
{
if (!array_key_exists($line->tva_tx, $vat_groups)) { if (!array_key_exists($line->tva_tx, $vat_groups)) {
$vat_groups[$line->tva_tx] = 0; $vat_groups[$line->tva_tx] = 0;
} }
@ -189,18 +221,26 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
foreach ($vat_groups as $key => $val) { foreach ($vat_groups as $key => $val) {
?> ?>
<tr> <tr>
<th align="right"><?php if ($gift != 1) echo $langs->trans("VAT").' '.vatrate($key, 1); ?></th> <th align="right"><?php if ($gift != 1) {
<td align="right"><?php if ($gift != 1) echo price($val, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td> echo $langs->trans("VAT").' '.vatrate($key, 1);
} ?></th>
<td align="right"><?php if ($gift != 1) {
echo price($val, 1, '', 1, - 1, - 1, $conf->currency)."\n";
} ?></td>
</tr> </tr>
<?php <?php
} }
} else { ?> } else { ?>
<tr> <tr>
<th class="right"><?php if ($gift != 1) echo $langs->trans("TotalVAT").'</th><td class="right">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td> <th class="right"><?php if ($gift != 1) {
echo $langs->trans("TotalVAT").'</th><td class="right">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n";
} ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
<tr> <tr>
<th class="right"><?php if ($gift != 1) echo ''.$langs->trans("TotalTTC").'</th><td class="right">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td> <th class="right"><?php if ($gift != 1) {
echo ''.$langs->trans("TotalTTC").'</th><td class="right">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n";
} ?></td>
</tr> </tr>
<?php <?php
if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency"]) { if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
@ -209,7 +249,9 @@ if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"
$multicurrency = new MultiCurrency($db); $multicurrency = new MultiCurrency($db);
$multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]); $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]);
echo '<tr><th class="right">'; echo '<tr><th class="right">';
if ($gift != 1) echo ''.$langs->trans("TotalTTC").' '.$_SESSION["takeposcustomercurrency"].'</th><td class="right">'.price($object->total_ttc * $multicurrency->rate->rate, 1, '', 1, - 1, - 1, $_SESSION["takeposcustomercurrency"])."\n"; if ($gift != 1) {
echo ''.$langs->trans("TotalTTC").' '.$_SESSION["takeposcustomercurrency"].'</th><td class="right">'.price($object->total_ttc * $multicurrency->rate->rate, 1, '', 1, - 1, - 1, $_SESSION["takeposcustomercurrency"])."\n";
}
echo '</td></tr>'; echo '</td></tr>';
} }
@ -221,8 +263,7 @@ if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) {
$sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$facid; $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$facid;
$sql .= " ORDER BY p.datep"; $sql .= " ORDER BY p.datep";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {
@ -233,12 +274,13 @@ if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) {
echo '</td>'; echo '</td>';
echo '<td class="right">'; echo '<td class="right">';
$amount_payment = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount; $amount_payment = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount;
if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment if ($row->code == "LIQ") {
$amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment
}
echo price($amount_payment, 1, '', 1, - 1, - 1, $conf->currency); echo price($amount_payment, 1, '', 1, - 1, - 1, $conf->currency);
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
if ($row->code == "LIQ" && $row->pos_change > 0) // Print change only in cash payments if ($row->code == "LIQ" && $row->pos_change > 0) { // Print change only in cash payments
{
echo '<tr>'; echo '<tr>';
echo '<td class="right">'; echo '<td class="right">';
echo $langs->trans("Change"); echo $langs->trans("Change");
@ -260,12 +302,15 @@ if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) {
<br> <br>
<?php <?php
$constFreeText = 'TAKEPOS_FOOTER'.$_SESSION['takeposterminal']; $constFreeText = 'TAKEPOS_FOOTER'.$_SESSION['takeposterminal'];
if (!empty($conf->global->TAKEPOS_FOOTER) || !empty($conf->global->{$constFreeText})) if (!empty($conf->global->TAKEPOS_FOOTER) || !empty($conf->global->{$constFreeText})) {
{
$newfreetext = ''; $newfreetext = '';
$substitutionarray = getCommonSubstitutionArray($langs); $substitutionarray = getCommonSubstitutionArray($langs);
if (!empty($conf->global->{$constFreeText})) $newfreetext .= make_substitutions($conf->global->{$constFreeText}, $substitutionarray); if (!empty($conf->global->{$constFreeText})) {
if (!empty($conf->global->TAKEPOS_FOOTER)) $newfreetext .= make_substitutions($conf->global->TAKEPOS_FOOTER, $substitutionarray); $newfreetext .= make_substitutions($conf->global->{$constFreeText}, $substitutionarray);
}
if (!empty($conf->global->TAKEPOS_FOOTER)) {
$newfreetext .= make_substitutions($conf->global->TAKEPOS_FOOTER, $substitutionarray);
}
print $newfreetext; print $newfreetext;
} }
?> ?>

View File

@ -25,11 +25,21 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOCSRFCHECK')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); define('NOCSRFCHECK', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
require '../main.inc.php'; // Load $user and permissions require '../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@ -48,19 +58,16 @@ if (empty($user->rights->takepos->run)) {
*/ */
$invoice = new Facture($db); $invoice = new Facture($db);
if ($invoiceid > 0) if ($invoiceid > 0) {
{
$invoice->fetch($invoiceid); $invoice->fetch($invoiceid);
} else { } else {
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
$resql = $db->query($sql); $resql = $db->query($sql);
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) if ($obj) {
{
$invoiceid = $obj->rowid; $invoiceid = $obj->rowid;
} }
if (!$invoiceid) if (!$invoiceid) {
{
$invoiceid = 0; // Invoice does not exist yet $invoiceid = 0; // Invoice does not exist yet
} else { } else {
$invoice->fetch($invoiceid); $invoice->fetch($invoiceid);

View File

@ -26,11 +26,21 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOCSRFCHECK')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); define('NOCSRFCHECK', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
require '../main.inc.php'; // Load $user and permissions require '../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
@ -51,8 +61,7 @@ $invoice->fetch($facid);
$customer = new Societe($db); $customer = new Societe($db);
$customer->fetch($invoice->socid); $customer->fetch($invoice->socid);
if ($action == "send") if ($action == "send") {
{
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db); $formmail = new FormMail($db);

View File

@ -21,11 +21,21 @@
* \brief Page with the content for smpcb payment * \brief Page with the content for smpcb payment
*/ */
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); if (!defined('NOCSRFCHECK')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); define('NOCSRFCHECK', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); }
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOTOKENRENEWAL')) {
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
require '../main.inc.php'; require '../main.inc.php';