code syntax s... t.. dir

This commit is contained in:
Frédéric FRANCE 2021-02-26 21:17:52 +01:00
parent 0d4acc53e2
commit ebfba19778
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
91 changed files with 6658 additions and 5434 deletions

View File

@ -27,14 +27,17 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.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
$langs->loadLangs(array('admin', 'salaries'));
// Security check
if (!$user->admin)
if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09');
@ -47,8 +50,7 @@ $list = array(
* Actions
*/
if ($action == 'update')
{
if ($action == 'update') {
$error = 0;
foreach ($list as $constname) {
@ -59,8 +61,7 @@ if ($action == 'update')
}
}
if (!$error)
{
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
@ -74,7 +75,9 @@ if ($action == 'update')
llxHeader('', $langs->trans('SalariesSetup'));
$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>';
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 "</tr>\n";
foreach ($list as $key)
{
foreach ($list as $key) {
print '<tr class="oddeven value">';
// Param
@ -109,8 +111,7 @@ foreach ($list as $key)
// Value
print '<td>';
if (!empty($conf->accounting->enabled))
{
if (!empty($conf->accounting->enabled)) {
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
} else {
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
$tmptype2label = ExtraFields::$type2label;
$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');
$attrname = GETPOST('attrname', 'alpha');
$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
if ($action != 'create' && $action != 'edit')
{
if ($action != 'create' && $action != 'edit') {
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>";
@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit')
/* */
/* ************************************************************************** */
if ($action == 'create')
{
if ($action == 'create') {
print '<div name="topofform"></div><br>';
print load_fiche_titre($langs->trans('NewAttribute'));
@ -104,8 +106,7 @@ if ($action == 'create')
/* Edition of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'edit' && !empty($attrname))
{
if ($action == 'edit' && !empty($attrname)) {
print '<div name="topofform"></div><br>';
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.'/core/lib/salaries.lib.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.'/core/class/html.formprojet.class.php';
}
// Load translation files required by the page
$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');
$action = GETPOST('action', 'aZ09');
@ -54,7 +55,9 @@ $dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday
// Security check
$socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'salaries', '', '', '');
$object = new PaymentSalary($db);
@ -71,24 +74,23 @@ $hookmanager->initHooks(array('salarycard', 'globalcard'));
* Actions
*/
if ($cancel)
{
if ($cancel) {
header("Location: list.php");
exit;
}
// Link to a project
if ($action == 'classin' && $user->rights->banque->modifier)
{
if ($action == 'classin' && $user->rights->banque->modifier) {
$object->fetch($id);
$object->setProject($projectid);
}
if ($action == 'add' && empty($cancel))
{
if ($action == 'add' && empty($cancel)) {
$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);
@ -113,41 +115,36 @@ if ($action == 'add' && empty($cancel))
// Fill array 'array_options' with data from add form
$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');
$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');
$error++;
}
if (empty($type_payment) || $type_payment < 0)
{
if (empty($type_payment) || $type_payment < 0) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
$error++;
}
if (empty($object->amount))
{
if (empty($object->amount)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
$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');
$error++;
}
if (!$error)
{
if (!$error) {
$db->begin();
$ret = $object->create($user);
if ($ret > 0)
{
if ($ret > 0) {
$db->commit();
if (GETPOST('saveandnew', 'alpha')) {
@ -168,26 +165,23 @@ if ($action == 'add' && empty($cancel))
$action = 'create';
}
if ($action == 'delete')
{
if ($action == 'delete') {
$result = $object->fetch($id);
if ($object->rappro == 0)
{
if ($object->rappro == 0) {
$db->begin();
$ret = $object->delete($user);
if ($ret > 0)
{
if ($object->fk_bank)
{
if ($ret > 0) {
if ($object->fk_bank) {
$accountline = new AccountLine($db);
$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();
header("Location: ".DOL_URL_ROOT.'/salaries/list.php');
exit;
@ -213,27 +207,25 @@ if ($action == 'delete')
llxHeader("", $langs->trans("SalaryPayment"));
$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);
$result = $object->fetch($id);
if ($result <= 0)
{
if ($result <= 0) {
dol_print_error($db);
exit;
}
}
// Create
if ($action == 'create')
{
if ($action == 'create') {
$year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0)
{
if ($pastmonth == 0) {
$pastmonth = 12;
$pastmonthyear--;
}
@ -247,8 +239,7 @@ if ($action == 'create')
$datesp = dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
$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);
}
@ -306,8 +297,7 @@ if ($action == 'create')
print '</td></tr>';
// Bank
if (!empty($conf->banque->enabled))
{
if (!empty($conf->banque->enabled)) {
print '<tr><td>';
print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).'</td><td>';
$form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant
@ -321,8 +311,7 @@ if ($action == 'create')
print '</td></tr>';
// Number
if (!empty($conf->banque->enabled))
{
if (!empty($conf->banque->enabled)) {
// Number
print '<tr><td><label for="num_payment">'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
@ -331,21 +320,19 @@ if ($action == 'create')
}
// Project
if (!empty($conf->projet->enabled))
{
$formproject = new FormProjets($db);
if (!empty($conf->projet->enabled)) {
$formproject = new FormProjets($db);
print '<tr><td>'.$langs->trans("Project").'</td><td>';
$formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Project").'</td><td>';
$formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1);
print '</td></tr>';
}
// Other attributes
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
if (empty($reshook)) {
print $object->showOptionals($extrafields, 'edit');
}
@ -371,8 +358,7 @@ if ($action == 'create')
/* */
/* ************************************************************************** */
if ($id)
{
if ($id) {
$head = salaries_prepare_head($object);
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);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->salaries->write)
{
if ($user->rights->salaries->write) {
if ($action != 'classify') {
$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>';
if (!empty($conf->banque->enabled))
{
if ($object->fk_account > 0)
{
if (!empty($conf->banque->enabled)) {
if ($object->fk_account > 0) {
$bankline = new AccountLine($db);
$bankline->fetch($object->fk_bank);
@ -479,10 +461,8 @@ if ($id)
// Action buttons
print '<div class="tabsAction">'."\n";
if ($object->rappro == 0)
{
if (!empty($user->rights->salaries->delete))
{
if ($object->rappro == 0) {
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>';
} else {
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) {
$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).')';
elseif ($this->userid > 0) $this->where .= ' AND fk_user = '.$this->userid;
if (is_array($this->userid) && count($this->userid) > 0) {
$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
$socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'salaries', '', '', '');
@ -54,12 +56,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$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;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "name";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$object = new PaymentSalary($db);
@ -84,8 +92,7 @@ $form = new Form($db);
llxHeader("", $langs->trans("SalaryPayment"));
if ($object->id)
{
if ($object->id) {
$object->fetch_thirdparty();
$head = salaries_prepare_head($object);
@ -95,8 +102,7 @@ if ($object->id)
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
foreach ($filearray as $key => $file)
{
foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
}

View File

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

View File

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

View File

@ -36,13 +36,17 @@ $form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$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');
$attrname = GETPOST('attrname', 'alpha');
$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
if ($action != 'create' && $action != 'edit')
{
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit')
/* */
/* ************************************************************************** */
if ($action == 'create')
{
if ($action == 'create') {
print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
@ -104,8 +106,7 @@ if ($action == 'create')
/* Edition of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'edit' && !empty($attrname))
{
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

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

View File

@ -36,13 +36,17 @@ $form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$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');
$attrname = GETPOST('attrname', 'alpha');
$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
if ($action != 'create' && $action != 'edit')
{
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit')
/* */
/* ************************************************************************** */
if ($action == 'create')
{
if ($action == 'create') {
print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
@ -104,8 +106,7 @@ if ($action == 'create')
/* Edition d'un champ optionnel */
/* */
/* ************************************************************************** */
if ($action == 'edit' && !empty($attrname))
{
if ($action == 'edit' && !empty($attrname)) {
print '<br><div id="editattrib"></div>';
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"));
if (GETPOST('actioncode', 'array'))
{
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0';
if (!count($actioncode)) {
$actioncode = '0';
}
} 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));
}
@ -45,19 +46,27 @@ $search_agenda_label = GETPOST('search_agenda_label');
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'societe', $socid, '&societe');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$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;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = 'a.datep,a.id';
if (!$sortorder) $sortorder = 'DESC,DESC';
if (!$sortfield) {
$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
$hookmanager->initHooks(array('agendathirdparty'));
@ -69,20 +78,19 @@ $hookmanager->initHooks(array('agendathirdparty'));
$parameters = array('id'=>$socid);
$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
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
{
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
// 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 = '';
$search_agenda_label = '';
}
@ -96,8 +104,7 @@ if (empty($reshook))
$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.'/societe/class/societe.class.php';
@ -105,10 +112,14 @@ if ($socid > 0)
$result = $object->fetch($socid);
$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);
if (!empty($conf->notification->enabled)) $langs->load("mails");
if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = societe_prepare_head($object);
print dol_get_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, 'company');
@ -137,29 +148,31 @@ if ($socid > 0)
$out = '';
$permok = $user->rights->agenda->myactions->create;
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok)
{
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 : ''));
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
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 .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;percentage=-1';
$out .= '&amp;datep='.dol_print_date(dol_now(), 'dayhourlog');
}
$newcardbutton = '';
if (!empty($conf->agenda->enabled))
{
if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create))
{
if (!empty($conf->agenda->enabled)) {
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);
}
}
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>';
$param = '&socid='.$socid;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.$contextpage;
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.$limit;
}
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);

View File

@ -22,12 +22,24 @@
* \brief File to return Ajax response on thirdparty list request
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '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');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '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';
@ -48,16 +60,14 @@ $showtype = GETPOST('showtype', 'int');
dol_syslog(join(',', $_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';
$outjson = array();
$object = new Societe($db);
$ret = $object->fetch($id);
if ($ret > 0)
{
if ($ret > 0) {
$outref = $object->ref;
$outname = $object->name;
$outdesc = '';
@ -74,7 +84,9 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
top_httphead();
if (empty($htmlname)) return;
if (empty($htmlname)) {
return;
}
$match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET));
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".
$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);
$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
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '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');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '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';
@ -50,24 +62,25 @@ dol_syslog(join(',', $_GET));
// 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();
// Define filter on text typed
$socid = $_GET['newcompany'] ? $_GET['newcompany'] : '';
if (!$socid) $socid = $_GET['socid'] ? $_GET['socid'] : '';
if (!$socid) $socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : '';
if (!$socid) {
$socid = $_GET['socid'] ? $_GET['socid'] : '';
}
if (!$socid) {
$socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : '';
}
$sql = "SELECT rowid, nom";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.entity IN (".getEntity('societe').")";
if ($socid)
{
if ($socid) {
$sql .= " AND (";
// 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 .= " OR code_client 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_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 .= ")";
}
//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);
$resql = $db->query($sql);
if ($resql)
{
while ($row = $db->fetch_array($resql))
{
if ($resql) {
while ($row = $db->fetch_array($resql)) {
$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['value'] = $row['nom'];
$row_array['key'] = $row['rowid'];

View File

@ -22,12 +22,24 @@
* \brief File to return Ajax response on country request
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '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');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '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';
@ -50,8 +62,7 @@ print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"])
dol_syslog(join(',', $_POST));
// Generate list of countries
if (!empty($country))
{
if (!empty($country)) {
global $langs;
$langs->load("dict");
@ -61,11 +72,9 @@ if (!empty($country))
$sql .= " ORDER BY label ASC";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
print '<ul>';
while ($country = $db->fetch_object($resql))
{
while ($country = $db->fetch_object($resql)) {
print '<li>';
// 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;'));

View File

@ -66,7 +66,9 @@ abstract class ActionsCardCommon
//$ret = $this->getInstanceDao();
$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;
}
@ -85,26 +87,37 @@ abstract class ActionsCardCommon
global $conf, $langs, $db, $user, $mysoc, $canvas;
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"] == 'c') { $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; }
if ($_GET["type"] == 'f') {
$this->object->fournisseur = 1;
}
if ($_GET["type"] == 'c') {
$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['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 ($conf->use_javascript_ajax)
{
if ($action == 'create') {
if ($conf->use_javascript_ajax) {
$this->tpl['ajax_selecttype'] = "\n".'<script type="text/javascript" language="javascript">
$(document).ready(function () {
$("#radiocompany").click(function() {
@ -124,10 +137,8 @@ abstract class ActionsCardCommon
}
}
if ($action == 'create' || $action == 'edit')
{
if ($conf->use_javascript_ajax)
{
if ($action == 'create' || $action == 'edit') {
if ($conf->use_javascript_ajax) {
$this->tpl['ajax_selectcountry'] = "\n".'<script type="text/javascript" language="javascript">
$(document).ready(function () {
$("#selectcountry_id").change(function() {
@ -141,20 +152,22 @@ abstract class ActionsCardCommon
// Load object modCodeClient
$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);
}
$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');
if ($res) break;
if ($res) {
break;
}
}
$modCodeClient = new $module($db);
$this->tpl['auto_customercode'] = $modCodeClient->code_auto;
// 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
$this->tpl['select_customertype'] = Form::selectarray('client', array(
@ -166,36 +179,41 @@ abstract class ActionsCardCommon
// Customer
$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();
$s = $modCodeClient->getToolTip($langs, $this->object, 0);
$this->tpl['help_customercode'] = $form->textwithpicto('', $s, 1);
if (!empty($conf->fournisseur->enabled))
{
if (!empty($conf->fournisseur->enabled)) {
$this->tpl['supplier_enabled'] = 1;
// Load object modCodeFournisseur
$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);
}
$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');
if ($res) break;
if ($res) {
break;
}
}
$modCodeFournisseur = new $module;
$this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto;
// 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
$this->tpl['yn_supplier'] = $form->selectyesno("fournisseur", $this->object->fournisseur, 1);
$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();
$s = $modCodeFournisseur->getToolTip($langs, $this->object, 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');
$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
if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
else $this->tpl['select_state'] = $countrynotdefined;
if ($this->object->country_id) {
$this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
} else {
$this->tpl['select_state'] = $countrynotdefined;
}
// 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
$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
// TODO mettre dans une classe propre au pays
if ($mysoc->country_code == 'ES')
{
if ($mysoc->country_code == 'ES') {
$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'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1);
$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'] .= '</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'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1);
$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'] .= $form->selectyesno('localtax2assuj_value', $this->object->localtax1_assuj, 1);
$this->tpl['localtax'] .= '</td><tr>';
@ -269,7 +290,9 @@ abstract class ActionsCardCommon
$this->tpl['address'] = dol_nl2br($this->object->address);
$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['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);
$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';
//$s=picto_from_langcode($this->default_lang);
//print ($s?$s.' ':'');
@ -300,31 +322,31 @@ abstract class ActionsCardCommon
$this->tpl['sales_representatives'] = '';
$listsalesrepresentatives = $this->object->getSalesRepresentatives($user);
$nbofsalesrepresentative = count($listsalesrepresentatives);
if ($nbofsalesrepresentative > 3) // We print only number
{
if ($nbofsalesrepresentative > 3) { // We print only number
$this->tpl['sales_representatives'] .= $nbofsalesrepresentative;
} elseif ($nbofsalesrepresentative > 0) {
$userstatic = new User($this->db);
$i = 0;
foreach ($listsalesrepresentatives as $val)
{
foreach ($listsalesrepresentatives as $val) {
$userstatic->id = $val['id'];
$userstatic->lastname = $val['name'];
$userstatic->firstname = $val['firstname'];
$this->tpl['sales_representatives'] .= $userstatic->getNomUrl(1);
$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
if (!empty($conf->adherent->enabled))
{
if (!empty($conf->adherent->enabled)) {
$langs->load("members");
$adh = new Adherent($this->db);
$result = $adh->fetch('', '', $this->object->id);
if ($result > 0)
{
if ($result > 0) {
$adh->ref = $adh->getFullName($langs);
$this->tpl['linked_member'] = $adh->getNomUrl(1);
} else {
@ -334,22 +356,18 @@ abstract class ActionsCardCommon
// Local Tax
// TODO mettre dans une classe propre au pays
if ($mysoc->country_code == 'ES')
{
if ($mysoc->country_code == 'ES') {
$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'] .= '<td>'.yn($this->object->localtax1_assuj).'</td>';
$this->tpl['localtax'] .= '<td>'.$langs->trans("LocalTax2IsUsedES").'</td>';
$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'] .= '<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'] .= '<td colspan="3">'.yn($this->object->localtax2_assuj).'</td></tr>';
}
@ -405,8 +423,7 @@ abstract class ActionsCardCommon
$this->object->localtax2_assuj = $_POST["localtax2assuj_value"];
// 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);
$this->object->country_code = $tmparray['code'];
$this->object->country_label = $tmparray['label'];

View File

@ -61,9 +61,15 @@ class ActionsCardCompany extends ActionsCardCommon
$out = '';
if ($action == 'view') $out .= $langs->trans("ThirdParty");
if ($action == 'edit') $out .= $langs->trans("EditCompany");
if ($action == 'create') $out .= $langs->trans("NewCompany");
if ($action == 'view') {
$out .= $langs->trans("ThirdParty");
}
if ($action == 'edit') {
$out .= $langs->trans("EditCompany");
}
if ($action == 'create') {
$out .= $langs->trans("NewCompany");
}
return $out;
}
@ -95,8 +101,7 @@ class ActionsCardCompany extends ActionsCardCommon
$this->tpl['profid3'] = $this->object->idprof3;
$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 .= '<script language="JavaScript" type="text/javascript">';
$js .= "function CheckVAT(a) {\n";
@ -107,10 +112,8 @@ class ActionsCardCompany extends ActionsCardCommon
$this->tpl['js_checkVatPopup'] = $js;
}
if ($action == 'create' || $action == 'edit')
{
for ($i = 1; $i <= 4; $i++)
{
if ($action == 'create' || $action == 'edit') {
for ($i = 1; $i <= 4; $i++) {
$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);
}
@ -126,12 +129,10 @@ class ActionsCardCompany extends ActionsCardCommon
// VAT 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 .= ' ';
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>';
$this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
} else {
@ -142,29 +143,24 @@ class ActionsCardCompany extends ActionsCardCommon
}
} else {
// 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");
}
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['checkprofid'.$i] = $this->object->id_prof_check($i, $this->object);
$this->tpl['urlprofid'.$i] = $this->object->id_prof_url($i, $this->object);
}
// TVA intra
if ($this->object->tva_intra)
{
if ($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.'">';
if (empty($conf->global->MAIN_DISABLEVATCHECK))
{
if (empty($conf->global->MAIN_DISABLEVATCHECK)) {
$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>';
$this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
} else {
@ -178,8 +174,7 @@ class ActionsCardCompany extends ActionsCardCommon
}
// Parent company
if ($this->object->parent)
{
if ($this->object->parent) {
$socm = new Societe($this->db);
$socm->fetch($this->object->parent);
$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
if (empty($conf) || !is_object($conf))
{
if (empty($conf) || !is_object($conf)) {
print "Error, template page can't be called as URL";
exit;
}
@ -43,7 +42,9 @@ if (empty($conf) || !is_object($conf))
<?php echo $this->control->tpl['ajax_selectcountry']; ?>
<?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">
@ -61,17 +62,17 @@ if (empty($conf) || !is_object($conf))
<td><span class="fieldrequired"><?php echo $langs->trans('ThirdPartyName'); ?></span></td>
<td><input type="text" size="30" maxlength="60" name="nom" value="<?php echo $this->control->tpl['nom']; ?>"></td>
<?php if (!empty($conf->global->SOCIETE_USEPREFIX)) { ?>
<td><?php echo $langs->trans('Prefix'); ?></td>
<td><input type="text" size="5" maxlength="5" name="prefix_comm" value="<?php echo $this->control->tpl['prefix_comm']; ?>"></td>
<?php } ?>
<td><?php echo $langs->trans('Prefix'); ?></td>
<td><input type="text" size="5" maxlength="5" name="prefix_comm" value="<?php echo $this->control->tpl['prefix_comm']; ?>"></td>
<?php } ?>
</tr>
<tr>
<td width="25%"><span class="fieldrequired"><?php echo $langs->trans('ProspectCustomer'); ?></span></td>
<td width="25%"><?php echo $this->control->tpl['select_customertype']; ?></td>
<td width="25%"><?php echo $langs->trans('CustomerCode'); ?></td>
<td width="25%">
<td width="25%"><?php echo $langs->trans('CustomerCode'); ?></td>
<td width="25%">
<table class="nobordernopadding">
<tr>
<td><input type="text" name="code_client" size="16" value="<?php echo $this->control->tpl['customercode']; ?>" maxlength="15"></td>
@ -85,14 +86,14 @@ if (empty($conf) || !is_object($conf))
<tr>
<td><span class="fieldrequired"><?php echo $langs->trans('Supplier'); ?></span></td>
<td><?php echo $this->control->tpl['yn_supplier']; ?></td>
<td><?php echo $langs->trans('SupplierCode'); ?></td>
<td>
<table class="nobordernopadding">
<tr>
<td><input type="text" name="code_fournisseur" size="16" value="<?php echo $this->control->tpl['suppliercode']; ?>" maxlength="15"></td>
<td><?php echo $this->control->tpl['help_suppliercode']; ?></td>
</tr>
</table>
<td><?php echo $langs->trans('SupplierCode'); ?></td>
<td>
<table class="nobordernopadding">
<tr>
<td><input type="text" name="code_fournisseur" size="16" value="<?php echo $this->control->tpl['suppliercode']; ?>" maxlength="15"></td>
<td><?php echo $this->control->tpl['help_suppliercode']; ?></td>
</tr>
</table>
</td>
</tr>
@ -155,15 +156,23 @@ if (!empty($conf->barcode->enabled)) { ?>
<?php
for ($i = 1; $i <= 4; $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['showprofid'.$i].'</td>';
if ($i == 2 || $i == 4) echo '</tr>';
if ($i == 2 || $i == 4) {
echo '</tr>';
}
} else {
if ($i == 1 || $i == 3) echo '<tr>';
if ($i == 1 || $i == 3) {
echo '<tr>';
}
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>
</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) { ?>
<tr>

View File

@ -17,8 +17,7 @@
*/
// 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";
exit;
}
@ -34,7 +33,9 @@ $contact = $GLOBALS['objcanvas']->control->object;
<?php echo $this->control->tpl['error']; ?>
<?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">
<input type="hidden" name="canvas" value="<?php echo $canvas ?>">
@ -165,15 +166,23 @@ if (!empty($conf->barcode->enabled)) { ?>
<?php
for ($i = 1; $i <= 4; $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['showprofid'.$i].'</td>';
if ($i == 2 || $i == 4) echo '</tr>';
if ($i == 2 || $i == 4) {
echo '</tr>';
}
} else {
if ($i == 1 || $i == 3) echo '<tr>';
if ($i == 1 || $i == 3) {
echo '<tr>';
}
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>
<?php }
if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
if (!empty($this->control->tpl['localtax'])) {
echo $this->control->tpl['localtax'];
} ?>
</table>
<br>

View File

@ -16,8 +16,7 @@
*/
// 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";
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['action_delete']) echo $this->control->tpl['action_delete']; ?>
<?php if ($this->control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?>
<?php if ($this->control->tpl['error']) {
echo $this->control->tpl['error'];
} ?>
<?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">
@ -120,20 +125,31 @@ print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company
<?php
for ($i = 1; $i <= 4; $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['profid'.$i];
if ($this->control->tpl['profid'.$i]) {
if ($this->control->tpl['checkprofid'.$i] > 0) echo ' &nbsp; '.$this->control->tpl['urlprofid'.$i];
else echo ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';
if ($this->control->tpl['checkprofid'.$i] > 0) {
echo ' &nbsp; '.$this->control->tpl['urlprofid'.$i];
} else {
echo ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';
}
}
echo '</td>';
if ($i == 2 || $i == 4) echo '</tr>';
if ($i == 2 || $i == 4) {
echo '</tr>';
}
} else {
if ($i == 1 || $i == 3) echo '<tr>';
if ($i == 1 || $i == 3) {
echo '<tr>';
}
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>
</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>
<td><?php echo $langs->trans('Capital'); ?></td>
<td colspan="3">
<?php
if ($this->control->tpl['capital']) echo $this->control->tpl['capital'].' '.$langs->trans("Currency".$conf->currency);
else echo '&nbsp;';
if ($this->control->tpl['capital']) {
echo $this->control->tpl['capital'].' '.$langs->trans("Currency".$conf->currency);
} else {
echo '&nbsp;';
}
?>
</td>
</tr>

View File

@ -61,9 +61,15 @@ class ActionsCardIndividual extends ActionsCardCommon
$out = '';
if ($action == 'view') $out .= $langs->trans("Individual");
if ($action == 'edit') $out .= $langs->trans("EditCompany");
if ($action == 'create') $out .= $langs->trans("NewCompany");
if ($action == 'view') {
$out .= $langs->trans("Individual");
}
if ($action == 'edit') {
$out .= $langs->trans("EditCompany");
}
if ($action == 'create') {
$out .= $langs->trans("NewCompany");
}
return $out;
}
@ -107,13 +113,11 @@ class ActionsCardIndividual extends ActionsCardCommon
$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'));
} else {
// 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");
}
}

View File

@ -17,8 +17,7 @@
*/
// 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";
exit;
}
@ -32,15 +31,15 @@ if (empty($conf) || !is_object($conf))
<?php echo $this->control->tpl['error']; ?>
<?php if ($conf->use_javascript_ajax) { ?>
<?php echo $this->control->tpl['ajax_selecttype']; ?>
<?php echo $this->control->tpl['ajax_selecttype']; ?>
<br>
<?php echo $langs->trans("ThirdPartyType") ?>: &nbsp;
<?php echo $langs->trans("ThirdPartyType") ?>: &nbsp;
<input type="radio" id="radiocompany" class="flat" name="private" value="0">
<?php echo $langs->trans("CompanyFoundation"); ?> &nbsp; &nbsp;
<?php echo $langs->trans("CompanyFoundation"); ?> &nbsp; &nbsp;
<input type="radio" id="radioprivate" class="flat" name="private" value="1" checked> <?php echo $langs->trans("Individual"); ?> (<?php echo $langs->trans("ToCreateContactWithSameName") ?>)
<br>
<br>
<?php echo $this->control->tpl['ajax_selectcountry']; ?>
<?php echo $this->control->tpl['ajax_selectcountry']; ?>
<?php } ?>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" name="formsoc">
@ -80,8 +79,8 @@ if (empty($conf) || !is_object($conf))
<td width="25%"><span class="fieldrequired"><?php echo $langs->trans('ProspectCustomer'); ?></span></td>
<td width="25%"><?php echo $this->control->tpl['select_customertype']; ?></td>
<td width="25%"><?php echo $langs->trans('CustomerCode'); ?></td>
<td width="25%">
<td width="25%"><?php echo $langs->trans('CustomerCode'); ?></td>
<td width="25%">
<table class="nobordernopadding">
<tr>
<td><input type="text" name="code_client" size="16" value="<?php echo $this->control->tpl['customercode']; ?>" maxlength="15"></td>
@ -95,23 +94,23 @@ if (empty($conf) || !is_object($conf))
<tr>
<td><span class="fieldrequired"><?php echo $langs->trans('Supplier'); ?></span></td>
<td><?php echo $this->control->tpl['yn_supplier']; ?></td>
<td><?php echo $langs->trans('SupplierCode'); ?></td>
<td>
<table class="nobordernopadding">
<tr>
<td><input type="text" name="code_fournisseur" size="16" value="<?php echo $this->control->tpl['suppliercode']; ?>" maxlength="15"></td>
<td><?php echo $this->control->tpl['help_suppliercode']; ?></td>
</tr>
</table>
<td><?php echo $langs->trans('SupplierCode'); ?></td>
<td>
<table class="nobordernopadding">
<tr>
<td><input type="text" name="code_fournisseur" size="16" value="<?php echo $this->control->tpl['suppliercode']; ?>" maxlength="15"></td>
<td><?php echo $this->control->tpl['help_suppliercode']; ?></td>
</tr>
</table>
</td>
</tr>
<?php if (count($this->control->tpl['suppliercategory']) > 0) { ?>
<?php if (count($this->control->tpl['suppliercategory']) > 0) { ?>
<tr>
<td><?php echo $langs->trans('SupplierCategory'); ?></td>
<td colspan="3"><?php echo $this->control->tpl['select_suppliercategory']; ?></td>
</tr>
<?php }
<?php }
}
if (!empty($conf->barcode->enabled)) { ?>
@ -169,7 +168,9 @@ if (!empty($conf->barcode->enabled)) { ?>
<td colspan="3"><?php echo $this->control->tpl['yn_assujtva']; ?></td>
</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) { ?>
<tr>

View File

@ -17,8 +17,7 @@
*/
// 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";
exit;
}
@ -173,7 +172,9 @@ if ($this->control->tpl['fournisseur']) {
<td colspan="3"><?php echo $this->control->tpl['yn_assujtva']; ?></td>
</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>
<br>

View File

@ -16,8 +16,7 @@
*/
// 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";
exit;
}
@ -32,8 +31,12 @@ $head = societe_prepare_head($object);
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['action_delete']) echo $this->control->tpl['action_delete']; ?>
if ($this->control->tpl['error']) {
echo $this->control->tpl['error'];
}
if ($this->control->tpl['action_delete']) {
echo $this->control->tpl['action_delete'];
} ?>
<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>
</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>
<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');
if (!$vatNumber)
{
if (!$vatNumber) {
print '<br>';
print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired", $langs->trans("VATIntraShort")).'</font><br>';
} else {
@ -76,8 +75,7 @@ if (!$vatNumber)
// Check for an error
$err = $soapclient->getError();
if ($err)
{
if ($err) {
dol_syslog("Constructor error ".$WS_DOL_URL, LOG_ERR);
}
@ -96,42 +94,38 @@ if (!$vatNumber)
print '<b>'.$langs->trans("Response").'</b>:<br>';
// 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>';
$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>';
$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>';
$messagetoshow = $soapclient->response;
} elseif ($result['faultstring'])
{
} elseif ($result['faultstring']) {
print '<font class="error">'.$langs->trans("Error").'</font><br>';
$messagetoshow = $result['faultstring'];
}
// Syntaxe ko
elseif (preg_match('/INVALID_INPUT/i', $result['faultstring'])
|| ($result['requestDate'] && !$result['valid']))
{
if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
} elseif (preg_match('/INVALID_INPUT/i', $result['faultstring'])
|| ($result['requestDate'] && !$result['valid'])) {
// Syntaxe ko
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("ValueIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>';
//$messagetoshow=$soapclient->response;
} else {
// 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("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>';
} 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 '<br>';
print $langs->trans("Name").': '.$result['name'].'<br>';
@ -144,10 +138,10 @@ if (!$vatNumber)
}
// Show log data into page
print "\n";
print '<!-- ';
var_dump($result);
print '-->';
// print "\n";
// print '<!-- ';
// var_dump($result);
// print '-->';
}
print '<br>';
@ -155,8 +149,7 @@ print $langs->trans("VATIntraManualCheck", $langs->trans("VATIntraCheckURL"), $l
print '<br>';
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 "\n".'Error returned:<br>';
print nl2br($messagetoshow);

View File

@ -34,7 +34,7 @@ class Contacts extends DolibarrApi
*
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
public static $FIELDS = array(
'lastname',
);
@ -71,8 +71,7 @@ class Contacts extends DolibarrApi
*/
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');
}
if ($id == 0) {
@ -81,23 +80,19 @@ class Contacts extends DolibarrApi
$result = $this->contact->fetch($id);
}
if (!$result)
{
if (!$result) {
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);
}
if ($includecount)
{
if ($includecount) {
$this->contact->load_ref_elements();
}
if ($includeroles)
{
if ($includeroles) {
$this->contact->fetchRoles();
}
@ -119,8 +114,7 @@ class Contacts extends DolibarrApi
*/
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');
}
if (empty($email)) {
@ -129,23 +123,19 @@ class Contacts extends DolibarrApi
$result = $this->contact->fetch('', '', '', $email);
}
if (!$result)
{
if (!$result) {
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);
}
if ($includecount)
{
if ($includecount) {
$this->contact->load_ref_elements();
}
if ($includeroles)
{
if ($includeroles) {
$this->contact->fetchRoles();
}
@ -176,8 +166,7 @@ class Contacts extends DolibarrApi
$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');
}
@ -186,8 +175,9 @@ class Contacts extends DolibarrApi
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
$search_sale = DolibarrApiAccess::$user->id;
}
$sql = "SELECT t.rowid";
$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 .= ' 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";
if ($search_sale > 0)
}
if ($search_sale > 0) {
$sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
}
// Insert sale filter
if ($search_sale > 0)
{
if ($search_sale > 0) {
$sql .= " AND sc.fk_user = ".$search_sale;
}
@ -220,10 +213,8 @@ class Contacts extends DolibarrApi
}
// Add sql filters
if ($sqlfilters)
{
if (!DolibarrApi::_checkFilters($sqlfilters))
{
if ($sqlfilters) {
if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -232,10 +223,8 @@ class Contacts extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit)
{
if ($page < 0)
{
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
@ -243,24 +232,19 @@ class Contacts extends DolibarrApi
$sql .= $this->db->plimit($limit + 1, $offset);
}
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0;
while ($i < $min)
{
while ($i < $min) {
$obj = $this->db->fetch_object($result);
$contact_static = new Contact($this->db);
if ($contact_static->fetch($obj->rowid))
{
if ($contact_static->fetch($obj->rowid)) {
$contact_static->fetchRoles();
if ($includecount)
{
if ($includecount) {
$contact_static->load_ref_elements();
}
if ($includeroles)
{
if ($includeroles) {
$contact_static->fetchRoles();
}
@ -272,8 +256,7 @@ class Contacts extends DolibarrApi
} else {
throw new RestException(503, 'Error when retrieve contacts : '.$sql);
}
if (!count($obj_ret))
{
if (!count($obj_ret)) {
throw new RestException(404, 'Contacts not found');
}
return $obj_ret;
@ -287,15 +270,13 @@ class Contacts extends DolibarrApi
*/
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');
}
// Check mandatory fields
$result = $this->_validate($request_data);
foreach ($request_data as $field => $value)
{
foreach ($request_data as $field => $value) {
$this->contact->$field = $value;
}
if ($this->contact->create(DolibarrApiAccess::$user) < 0) {
@ -313,30 +294,29 @@ class Contacts extends DolibarrApi
*/
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');
}
$result = $this->contact->fetch($id);
if (!$result)
{
if (!$result) {
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);
}
foreach ($request_data as $field => $value)
{
if ($field == 'id') continue;
foreach ($request_data as $field => $value) {
if ($field == 'id') {
continue;
}
$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 false;
}
@ -349,18 +329,15 @@ class Contacts extends DolibarrApi
*/
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');
}
$result = $this->contact->fetch($id);
if (!$result)
{
if (!$result) {
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);
}
$this->contact->oldcopy = clone $this->contact;
@ -382,10 +359,12 @@ class Contacts extends DolibarrApi
//throw new RestException(401);
//}
if (!isset($request_data["login"]))
if (!isset($request_data["login"])) {
throw new RestException(400, "login field missing");
if (!isset($request_data["password"]))
}
if (!isset($request_data["password"])) {
throw new RestException(400, "password field missing");
}
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
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
*/
static $FIELDS = array(
public static $FIELDS = array(
'name'
);
@ -137,46 +137,68 @@ class Thirdparties extends DolibarrApi
// If the internal user must only see his customers, force searching by him
$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";
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";
if ($category > 0) {
if ($mode != 4) $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 ($mode != 4) {
$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 .= " WHERE t.entity IN (".getEntity('societe').")";
$sql .= " AND t.fk_stcomm = st.id";
if ($mode == 1) $sql .= " AND t.client IN (1, 3)";
elseif ($mode == 2) $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)";
if ($mode == 1) {
$sql .= " AND t.client IN (1, 3)";
} elseif ($mode == 2) {
$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
if ($category > 0) {
if (!empty($mode) && $mode != 4) { $sql .= " AND c.fk_categorie = ".$this->db->escape($category)." AND c.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 (!empty($mode) && $mode != 4) {
$sql .= " AND c.fk_categorie = ".$this->db->escape($category)." AND c.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 ($socids) $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
if ($socids) {
$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
if ($search_sale > 0)
{
if ($search_sale > 0) {
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
{
if (!DolibarrApi::_checkFilters($sqlfilters))
{
if ($sqlfilters) {
if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -195,13 +217,11 @@ class Thirdparties extends DolibarrApi
}
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0;
while ($i < $min)
{
while ($i < $min) {
$obj = $this->db->fetch_object($result);
$soc_static = new Societe($this->db);
if ($soc_static->fetch($obj->rowid)) {
@ -235,8 +255,9 @@ class Thirdparties extends DolibarrApi
foreach ($request_data as $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));
}
return $this->company->id;
}
@ -264,7 +285,9 @@ class Thirdparties extends DolibarrApi
}
foreach ($request_data as $field => $value) {
if ($field == 'id') continue;
if ($field == 'id') {
continue;
}
$this->company->$field = $value;
}
@ -295,8 +318,7 @@ class Thirdparties extends DolibarrApi
$error = 0;
if ($id == $idtodelete)
{
if ($id == $idtodelete) {
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',
'model_pdf', 'fk_projet'
);
foreach ($listofproperties as $property)
{
if (empty($object->$property)) $object->$property = $soc_origin->$property;
foreach ($listofproperties as $property) {
if (empty($object->$property)) {
$object->$property = $soc_origin->$property;
}
}
// Concat some data
$listofproperties = array(
'note_public', 'note_private'
);
foreach ($listofproperties as $property)
{
foreach ($listofproperties as $property) {
$object->$property = dol_concatdesc($object->$property, $soc_origin->$property);
}
// Merge extrafields
if (is_array($soc_origin->array_options))
{
foreach ($soc_origin->array_options as $key => $val)
{
if (empty($object->array_options[$key])) $object->array_options[$key] = $val;
if (is_array($soc_origin->array_options)) {
foreach ($soc_origin->array_options as $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 ($soc_origin->code_client == $object->code_client
|| $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");
$soc_origin->code_client = '';
$soc_origin->code_fournisseur = '';
@ -389,8 +410,7 @@ class Thirdparties extends DolibarrApi
// Update
$result = $object->update($object->id, $user, 0, 1, 1, 'merge');
if ($result < 0)
{
if ($result < 0) {
$error++;
}
@ -425,8 +445,7 @@ class Thirdparties extends DolibarrApi
);
//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;
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);
if (!$result)
{
if (!$result) {
throw new RestException(404, 'Thirdparty not found');
}
@ -593,13 +611,11 @@ class Thirdparties extends DolibarrApi
$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);
}
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();
}
@ -702,8 +718,7 @@ class Thirdparties extends DolibarrApi
}
$result = $this->company->fetch($id);
if (!$result)
{
if (!$result) {
throw new RestException(404, 'Thirdparty not found');
}
@ -711,13 +726,11 @@ class Thirdparties extends DolibarrApi
$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);
}
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();
}
@ -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 .= " 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;
if ($filter == "available") $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)";
if ($filter == "available") {
$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);
@ -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 .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
$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);
@ -1150,11 +1169,9 @@ class Thirdparties extends DolibarrApi
$accounts = array();
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
while ($i < $num)
{
while ($i < $num) {
$obj = $this->db->fetch_object($result);
$account = new CompanyBankAccount($this->db);
if ($account->fetch($obj->rowid)) {
@ -1209,8 +1226,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value;
}
if ($account->create(DolibarrApiAccess::$user) < 0)
if ($account->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error creating Company Bank account');
}
if (empty($account->rum)) {
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
@ -1219,8 +1237,9 @@ class Thirdparties extends DolibarrApi
$account->date_rum = dol_now();
}
if ($account->update(DolibarrApiAccess::$user) < 0)
if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating values');
}
return $this->_cleanObjectDatas($account);
}
@ -1264,8 +1283,9 @@ class Thirdparties extends DolibarrApi
$account->date_rum = dol_now();
}
if ($account->update(DolibarrApiAccess::$user) < 0)
if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating values');
}
return $this->_cleanObjectDatas($account);
}
@ -1290,8 +1310,9 @@ class Thirdparties extends DolibarrApi
$account->fetch($bankaccount_id);
if (!$account->socid == $id)
if (!$account->socid == $id) {
throw new RestException(401);
}
return $account->delete(DolibarrApiAccess::$user);
}
@ -1342,8 +1363,12 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
if ($id) $sql .= " WHERE fk_soc = ".$id." ";
if ($companybankid) $sql .= " AND rowid = ".$companybankid."";
if ($id) {
$sql .= " WHERE fk_soc = ".$id." ";
}
if ($companybankid) {
$sql .= " AND rowid = ".$companybankid."";
}
$i = 0;
$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 .= " WHERE fk_soc = $id";
if ($site) $sql .= " AND site ='$site'";
if ($site) {
$sql .= " AND site ='$site'";
}
$result = $this->db->query($sql);
@ -1422,8 +1449,7 @@ class Thirdparties extends DolibarrApi
$accounts = array();
$num = $this->db->num_rows($result);
while ($i < $num)
{
while ($i < $num) {
$obj = $this->db->fetch_object($result);
$account = new SocieteAccount($this->db);
@ -1493,8 +1519,9 @@ class Thirdparties extends DolibarrApi
$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!');
}
$this->_cleanObjectDatas($account);
@ -1582,8 +1609,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value;
}
if ($account->update(DolibarrApiAccess::$user) < 0)
if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating SocieteAccount entity.');
}
}
$this->_cleanObjectDatas($account);
@ -1624,8 +1652,9 @@ 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'])."' ";
$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.");
}
}
$obj = $this->db->fetch_object($result);
@ -1636,8 +1665,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value;
}
if ($account->update(DolibarrApiAccess::$user) < 0)
if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating SocieteAccount account');
}
$this->_cleanObjectDatas($account);
@ -1713,8 +1743,7 @@ class Thirdparties extends DolibarrApi
$i = 0;
$num = $this->db->num_rows($result);
while ($i < $num)
{
while ($i < $num) {
$obj = $this->db->fetch_object($result);
$account = new SocieteAccount($this->db);
$account->fetch($obj->rowid);
@ -1781,8 +1810,9 @@ class Thirdparties extends DolibarrApi
{
$thirdparty = array();
foreach (Thirdparties::$FIELDS as $field) {
if (!isset($data[$field]))
if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
}
$thirdparty[$field] = $data[$field];
}
return $thirdparty;

View File

@ -64,8 +64,7 @@ class Client extends Societe
$sql = "SELECT count(s.rowid) as nb, s.client";
$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 .= " WHERE sc.fk_user = ".$user->id;
$clause = "AND";
@ -75,12 +74,14 @@ class Client extends Societe
$sql .= " GROUP BY s.client";
$resql = $this->db->query($sql);
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
{
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 ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if ($obj->client == 1 || $obj->client == 3) {
$this->nb["customers"] += $obj->nb;
}
if ($obj->client == 2 || $obj->client == 3) {
$this->nb["prospects"] += $obj->nb;
}
}
$this->db->free($resql);
return 1;
@ -101,8 +102,10 @@ class Client extends Societe
{
global $langs;
$sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcomm";
if ($active >= 0) $sql .= " WHERE active = ".$active;
$sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcomm";
if ($active >= 0) {
$sql .= " WHERE active = ".$active;
}
$resql = $this->db->query($sql);
$num = $this->db->num_rows($resql);
$i = 0;

View File

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

View File

@ -232,8 +232,12 @@ class CompanyPaymentMode extends CommonObject
$this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0;
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$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 = '')
{
if ($socid) $morewhere .= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1";
if ($type) $morewhere .= " AND type = '".$this->db->escape($type)."'";
if ($socid) {
$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);
//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 $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 = '';
$companylink = '';
@ -386,33 +396,40 @@ class CompanyPaymentMode extends CommonObject
$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_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 ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
}
$linkclose = '';
if (empty($notooltip))
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowCompanyPaymentMode");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>';
$linkend = '</a>';
$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 != 2) $result .= $this->ref;
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 != 2) {
$result .= $this->ref;
}
$result .= $linkend;
//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);
$result1 = $this->db->query($sql1);
if ($result1)
{
if ($this->db->num_rows($result1) == 0)
{
if ($result1) {
if ($this->db->num_rows($result1) == 0) {
return 0;
} else {
$obj = $this->db->fetch_object($result1);
$type = '';
if (empty($alltypes)) $type = $obj->type;
if (empty($alltypes)) {
$type = $obj->type;
}
$this->db->begin();
$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0, tms = tms";
$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);
$result2 = $this->db->query($sql2);
$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
$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);
$result3 = $this->db->query($sql3);
if (!$result2 || !$result3)
{
if (!$result2 || !$result3) {
dol_print_error($this->db);
$this->db->rollback();
return -1;
@ -496,8 +516,7 @@ class CompanyPaymentMode extends CommonObject
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort))
{
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
//$langs->load("mymodule");
$this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled');
@ -507,7 +526,9 @@ class CompanyPaymentMode extends CommonObject
}
$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);
}
@ -525,28 +546,23 @@ class CompanyPaymentMode extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
if ($result) {
if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
if ($obj->fk_user_author)
{
if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_valid)
{
if ($obj->fk_user_valid) {
$vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
if ($obj->fk_user_cloture)
{
if ($obj->fk_user_cloture) {
$cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser;

View File

@ -905,9 +905,8 @@ class Societe extends CommonObject
// Ajout du commercial affecte
if ($this->commercial_id != '' && $this->commercial_id != -1) {
$this->add_commercial($user, $this->commercial_id);
}
// si un commercial cree un client il lui est affecte automatiquement
elseif (empty($user->rights->societe->client->voir)) {
} elseif (empty($user->rights->societe->client->voir)) {
// si un commercial cree un client il lui est affecte automatiquement
$this->add_commercial($user, $user->id);
}
@ -2626,20 +2625,17 @@ class Societe extends CommonObject
$s = '';
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>';
}
}
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>';
}
}
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>';
}
}
@ -3811,8 +3807,7 @@ class Societe extends CommonObject
dol_syslog("We ask to create a contact/address too", LOG_DEBUG);
$result = $this->create_individual($user);
if ($result < 0)
{
if ($result < 0) {
setEventMessages($this->error, $this->errors, 'errors');
$this->db->rollback();
return -1;
@ -4682,8 +4677,7 @@ class Societe extends CommonObject
$this->db->commit();
return 1;
}
else {
} else {
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1;

View File

@ -172,7 +172,9 @@ class SocieteAccount extends CommonObject
$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)
{
$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;
}
@ -375,7 +379,9 @@ class SocieteAccount extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo;
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 = '';
@ -388,33 +394,40 @@ class SocieteAccount extends CommonObject
$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_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 ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
}
$linkclose = '';
if (empty($notooltip))
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("WebsiteAccount");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>';
$linkend = '</a>';
$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 != 2) $result .= $this->ref;
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 != 2) {
$result .= $this->ref;
}
$result .= $linkend;
return $result;
@ -444,35 +457,49 @@ class SocieteAccount extends CommonObject
// phpcs:enable
global $langs;
if ($mode == 0)
{
if ($mode == 0) {
$prefix = '';
if ($status == 1) return $langs->trans('Enabled');
elseif ($status == 0) return $langs->trans('Disabled');
} elseif ($mode == 1)
{
if ($status == 1) return $langs->trans('Enabled');
elseif ($status == 0) return $langs->trans('Disabled');
} elseif ($mode == 2)
{
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)
{
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
} elseif ($mode == 4)
{
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 == 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');
if ($status == 1) {
return $langs->trans('Enabled');
} elseif ($status == 0) {
return $langs->trans('Disabled');
}
} elseif ($mode == 1) {
if ($status == 1) {
return $langs->trans('Enabled');
} elseif ($status == 0) {
return $langs->trans('Disabled');
}
} elseif ($mode == 2) {
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) {
if ($status == 1) {
return img_picto($langs->trans('Enabled'), 'statut4');
} elseif ($status == 0) {
return img_picto($langs->trans('Disabled'), 'statut5');
}
} elseif ($mode == 4) {
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 == 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 .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
if ($result) {
if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
if ($obj->fk_user_author)
{
if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_valid)
{
if ($obj->fk_user_valid) {
$vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
if ($obj->fk_user_cloture)
{
if ($obj->fk_user_cloture) {
$cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser;

View File

@ -35,22 +35,32 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thi
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'societe', $socid, '&societe');
$object = new Societe($db);
if ($socid > 0) $object->fetch($socid);
if ($socid > 0) {
$object->fetch($socid);
}
// Sort & Order fields
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$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;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = 'DESC';
if (!$sortfield) $sortfield = 'dateprint';
if (!$sortorder) {
$sortorder = 'DESC';
}
if (!$sortfield) {
$sortfield = 'dateprint';
}
// Search fields
$sref = GETPOST("sref");
@ -59,8 +69,7 @@ $month = GETPOST('month', 'int');
$year = GETPOST('year', 'int');
// 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 = '';
$sprod_fulldescr = '';
$year = '';
@ -83,7 +92,9 @@ $hookmanager->initHooks(array('consumptionthirdparty'));
$parameters = array('id'=>$socid);
$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);
$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';
llxHeader('', $title, $help_url);
if (empty($socid))
{
if (empty($socid)) {
dol_print_error($db);
exit;
}
@ -118,15 +130,13 @@ print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
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>';
}
//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 $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client;
@ -137,21 +147,32 @@ if ($object->client)
print '</td></tr>';
$sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid;
$resql = $db->query($sql);
if (!$resql) dol_print_error($db);
if (!$resql) {
dol_print_error($db);
}
$obj = $db->fetch_object($resql);
$nbFactsClient = $obj->nb;
$thirdTypeArray['customer'] = $langs->trans("customer");
if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals');
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 ($conf->propal->enabled && $user->rights->propal->lire) {
$elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals');
}
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");
print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
@ -163,14 +184,22 @@ if ($object->fournisseur)
print '</td></tr>';
$sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".$socid;
$resql = $db->query($sql);
if (!$resql) dol_print_error($db);
if (!$resql) {
dol_print_error($db);
}
$obj = $db->fetch_object($resql);
$nbCmdsFourn = $obj->nb;
$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->commande->lire) $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders');
if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal'] = $langs->transnoentitiesnoconv('SupplierProposals');
if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) {
$elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
}
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>';
@ -194,8 +223,7 @@ $sql_select = '';
$dateprint = 'f.datep';
$doc_number='f.id';
}*/
if ($type_element == 'fichinter')
{ // Customer : show products from invoices
if ($type_element == 'fichinter') { // Customer : show products from invoices
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
$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, ';
@ -205,8 +233,7 @@ if ($type_element == 'fichinter')
$dateprint = 'f.datec';
$doc_number = 'f.ref';
}
if ($type_element == 'invoice')
{ // Customer : show products from invoices
if ($type_element == 'invoice') { // Customer : show products from invoices
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$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, ';
@ -218,8 +245,7 @@ if ($type_element == 'invoice')
$doc_number = 'f.ref';
$thirdTypeSelect = 'customer';
}
if ($type_element == 'propal')
{
if ($type_element == 'propal') {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$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, ';
@ -231,8 +257,7 @@ if ($type_element == 'propal')
$doc_number = 'c.ref';
$thirdTypeSelect = 'customer';
}
if ($type_element == 'order')
{
if ($type_element == 'order') {
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$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, ';
@ -244,8 +269,7 @@ if ($type_element == 'order')
$doc_number = 'c.ref';
$thirdTypeSelect = 'customer';
}
if ($type_element == 'supplier_invoice')
{ // Supplier : Show products from invoices.
if ($type_element == 'supplier_invoice') { // Supplier : Show products from invoices.
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$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, ';
@ -257,8 +281,7 @@ if ($type_element == 'supplier_invoice')
$doc_number = 'f.ref';
$thirdTypeSelect = 'supplier';
}
if ($type_element == 'supplier_proposal')
{
if ($type_element == 'supplier_proposal') {
require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
$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, ';
@ -270,8 +293,7 @@ if ($type_element == 'supplier_proposal')
$doc_number = 'c.ref';
$thirdTypeSelect = 'supplier';
}
if ($type_element == 'supplier_order')
{ // Supplier : Show products from orders.
if ($type_element == 'supplier_order') { // Supplier : Show products from orders.
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$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, ';
@ -283,8 +305,7 @@ if ($type_element == 'supplier_order')
$doc_number = 'c.ref';
$thirdTypeSelect = 'supplier';
}
if ($type_element == 'contract')
{ // Order
if ($type_element == 'contract') { // Order
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
$documentstatic = new Contrat($db);
$documentstaticline = new ContratLigne($db);
@ -301,26 +322,42 @@ if ($type_element == 'contract')
$parameters = array();
$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 .= ' 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 == '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,';
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 == '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 ";
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;
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 .= dolSqlDateFilter($dateprint, 0, $month, $year);
if ($sref) $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'";
if ($sprod_fulldescr)
{
if ($sref) {
$sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'";
}
if ($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') $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'";
if (GETPOST('type_element') != 'fichinter') {
$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 .= $db->order($sortfield, $sortorder);
@ -334,8 +371,7 @@ if (!empty($sql_select))
$disabled = 0;
$showempty = 2;
if (empty($elementTypeArray) && !$object->client && !$object->fournisseur)
{
if (empty($elementTypeArray) && !$object->client && !$object->fournisseur) {
$showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef");
$disabled = 1;
}
@ -354,21 +390,36 @@ $param .= "&type_element=".urlencode($type_element);
$total_qty = 0;
if ($sql_select)
{
if ($sql_select) {
$resql = $db->query($sql);
if (!$resql) dol_print_error($db);
if (!$resql) {
dol_print_error($db);
}
$num = $db->num_rows($resql);
$param = "&socid=".urlencode($socid)."&type_element=".urlencode($type_element);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
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);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
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);
@ -412,8 +463,7 @@ if ($sql_select)
$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->ref = $objp->doc_number;
$documentstatic->type = $objp->doc_type;
@ -423,7 +473,9 @@ if ($sql_select)
$documentstatic->status = $objp->status;
$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 '<td class="nobordernopadding nowrap" width="100">';
@ -447,8 +499,7 @@ if ($sql_select)
$text = ''; $description = ''; $type = 0;
// 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->type = $objp->fk_product_type;
@ -459,20 +510,21 @@ if ($sql_select)
}
// Product
if ($objp->fk_product > 0)
{
if ($objp->fk_product > 0) {
// 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->fetch($objp->fk_product);
$outputlangs = $langs;
$newlang = '';
if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if (empty($newlang)) $newlang = $object->default_lang;
if (!empty($newlang))
{
if (empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (empty($newlang)) {
$newlang = $object->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
@ -491,39 +543,40 @@ if ($sql_select)
<?php
$txt = '';
print img_object($langs->trans("ShowReduc"), 'reduc').' ';
if ($objp->description == '(DEPOSIT)') $txt = $langs->trans("Deposit");
elseif ($objp->description == '(EXCESS RECEIVED)') $txt = $langs->trans("ExcessReceived");
elseif ($objp->description == '(EXCESS PAID)') $txt = $langs->trans("ExcessPaid");
if ($objp->description == '(DEPOSIT)') {
$txt = $langs->trans("Deposit");
} elseif ($objp->description == '(EXCESS RECEIVED)') {
$txt = $langs->trans("ExcessReceived");
} elseif ($objp->description == '(EXCESS PAID)') {
$txt = $langs->trans("ExcessPaid");
}
//else $txt=$langs->trans("Discount");
print $txt;
?>
</a>
<?php
if ($objp->description)
{
if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0)
{
if ($objp->description) {
if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) {
$discount = new DiscountAbsolute($db);
$discount->fetch($objp->fk_remise_except);
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->fetch($objp->fk_remise_except);
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->fetch($objp->fk_remise_except);
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->fetch($objp->fk_remise_except);
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
// 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 {
echo ($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description);
}
@ -536,15 +589,16 @@ if ($sql_select)
echo get_date_range($objp->date_start, $objp->date_end);
// 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) : '';
}
} else {
if (!empty($objp->label) || !empty($objp->description))
{
if ($type == 1) $text = img_object($langs->trans('Service'), 'service');
else $text = img_object($langs->trans('Product'), 'product');
if (!empty($objp->label) || !empty($objp->description)) {
if ($type == 1) {
$text = img_object($langs->trans('Service'), 'service');
} else {
$text = img_object($langs->trans('Product'), 'product');
}
if (!empty($objp->label)) {
$text .= ' <strong>'.$objp->label.'</strong>';
@ -580,7 +634,9 @@ if ($sql_select)
print '</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>';
$total_qty += $objp->prod_qty;
@ -606,9 +662,7 @@ if ($sql_select)
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
}
$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 '<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.'/contact/class/contact.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"));
if (!empty($conf->categorie->enabled)) $langs->load("categories");
if (!empty($conf->incoterm->enabled)) $langs->load("incoterm");
if (!empty($conf->notification->enabled)) $langs->load("mails");
if (!empty($conf->categorie->enabled)) {
$langs->load("categories");
}
if (!empty($conf->incoterm->enabled)) {
$langs->load("incoterm");
}
if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$mesg = ''; $error = 0; $errors = array();
@ -56,8 +64,12 @@ $cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$confirm = GETPOST('confirm');
$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
if ($user->socid) $socid = $user->socid;
if (empty($socid) && $action == 'view') $action = 'create';
if ($user->socid) {
$socid = $user->socid;
}
if (empty($socid) && $action == 'view') {
$action = 'create';
}
$object = new Societe($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
$hookmanager->initHooks(array('thirdpartycontact', 'globalcard'));
if ($object->fetch($socid) <= 0 && $action == 'view')
{
if ($object->fetch($socid) <= 0 && $action == 'view') {
$langs->load("errors");
print($langs->trans('ErrorRecordNotFound'));
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)
$canvas = $object->canvas ? $object->canvas : GETPOST("canvas");
$objcanvas = null;
if (!empty($canvas))
{
if (!empty($canvas)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
$objcanvas = new Canvas($db, $action);
$objcanvas->getCanvas('thirdparty', 'card', $canvas);
@ -87,7 +97,9 @@ if (!empty($canvas))
// Security check
$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);
$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 ($cancel)
{
if (empty($reshook)) {
if ($cancel) {
$action = '';
if (!empty($backtopage))
{
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
@ -124,21 +135,26 @@ $formfile = new FormFile($db);
$formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db);
if ($socid > 0 && empty($object->id))
{
if ($socid > 0 && empty($object->id)) {
$result = $object->fetch($socid);
if ($result <= 0) dol_print_error('', $object->error);
if ($result <= 0) {
dol_print_error('', $object->error);
}
}
$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';
llxHeader('', $title, $help_url);
$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; }
@ -154,11 +170,9 @@ print dol_get_fiche_end();
print '<br>';
if ($action != 'presend')
{
if ($action != 'presend') {
// 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);
}
}

View File

@ -40,8 +40,7 @@ $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'))
$ref = GETPOST('ref', 'alpha');
// Security check
if ($user->socid > 0)
{
if ($user->socid > 0) {
unset($action);
$socid = $user->socid;
}
@ -52,20 +51,29 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$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;
$pageprev = $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_ORDER)) { $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; }
if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) {
$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 (!$sortfield) $sortfield = "position_name";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "position_name";
}
$object = new Societe($db);
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref);
$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);
$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';
llxHeader('', $title, $help_url);
if ($object->id)
{
if ($object->id) {
/*
* Show tabs
*/
if (!empty($conf->notification->enabled)) $langs->load("mails");
if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = societe_prepare_head($object);
$form = new Form($db);
@ -111,8 +122,7 @@ if ($object->id)
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
foreach ($filearray as $key => $file)
{
foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
}
@ -126,13 +136,11 @@ if ($object->id)
print '<table class="border tableforfield centpercent">';
// 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>';
}
if ($object->client)
{
if ($object->client) {
print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client;
@ -143,8 +151,7 @@ if ($object->id)
print '</td></tr>';
}
if ($object->fournisseur)
{
if ($object->fournisseur) {
print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur;

View File

@ -38,7 +38,9 @@ $hookmanager->initHooks(array('thirdpartiesindex'));
$langs->load("companies");
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
// Security check
$result = restrictedArea($user, 'societe', 0, '', '', '', '');
@ -75,37 +77,62 @@ $total = 0;
$sql = "SELECT s.rowid, s.client, s.fournisseur";
$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').')';
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
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
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
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;
$result = $db->query($sql);
if ($result)
{
while ($objp = $db->fetch_object($result))
{
if ($result) {
while ($objp = $db->fetch_object($result)) {
$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_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++;
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_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);
} else {
dol_print_error($db);
}
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">'."\n";
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">';
$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_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']));
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_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';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
@ -117,20 +144,17 @@ if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) +
print $dolgraph->show();
print '</td></tr>'."\n";
} 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 .= '<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>";
}
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 .= '<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>";
}
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 .= '<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>";
@ -144,8 +168,7 @@ print '</td></tr>';
print '</table>';
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';
$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 .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
$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 .= " GROUP BY c.label";
$total = 0;
$result = $db->query($sql);
if ($result)
{
if ($result) {
$num = $db->num_rows($result);
$i = 0;
if (!empty($conf->use_javascript_ajax))
{
if (!empty($conf->use_javascript_ajax)) {
$dataseries = array();
$rest = 0;
$nbmax = 10;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($result);
if ($i < $nbmax)
{
if ($i < $nbmax) {
$dataseries[] = array($obj->label, round($obj->nb));
} else {
$rest += $obj->nb;
@ -186,8 +207,7 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA
$total += $obj->nb;
$i++;
}
if ($i > $nbmax)
{
if ($i > $nbmax) {
$dataseries[] = array($langs->trans("Other"), round($rest));
}
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');
print $dolgraph->show();
} else {
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($result);
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.canvas, s.tms as date_modification, s.status as status";
$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').')';
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur != 1 OR s.client != 0)";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
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->plimit($max, 0);
//print $sql;
$result = $db->query($sql);
if ($result)
{
if ($result) {
$num = $db->num_rows($result);
$i = 0;
if ($num > 0)
{
if ($num > 0) {
$transRecordedType = $langs->trans("LastModifiedThirdParties", $max);
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 '</tr>'."\n";
while ($i < $num)
{
while ($i < $num) {
$objp = $db->fetch_object($result);
$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
$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');
$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
@ -61,16 +65,19 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include,
$form = new Form($db);
$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';
llxHeader('', $title, $help_url);
if ($object->id > 0)
{
if ($object->id > 0) {
/*
* Affichage onglets
*/
if (!empty($conf->notification->enabled)) $langs->load("mails");
* Affichage onglets
*/
if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = societe_prepare_head($object);
@ -89,32 +96,31 @@ if ($object->id > 0)
print '<div class="underbanner clearboth"></div>';
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>';
}
if ($object->client) {
print '<tr><td class="'.$cssclass.'">';
print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client;
$tmpcheck = $object->check_codeclient();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
}
print '</td></tr>';
}
if ($object->client) {
print '<tr><td class="'.$cssclass.'">';
print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client;
$tmpcheck = $object->check_codeclient();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
}
print '</td></tr>';
}
if ($object->fournisseur) {
print '<tr><td class="'.$cssclass.'">';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur;
$tmpcheck = $object->check_codefournisseur();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
}
print '</td></tr>';
}
if ($object->fournisseur) {
print '<tr><td class="'.$cssclass.'">';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur;
$tmpcheck = $object->check_codefournisseur();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
}
print '</td></tr>';
}
print "</table>";

View File

@ -39,16 +39,24 @@ $actionid = GETPOST('actionid');
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'societe', '', '');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "n.daten";
if (empty($page) || $page == -1) { $page = 0; }
if (!$sortorder) {
$sortorder = "DESC";
}
if (!$sortfield) {
$sortfield = "n.daten";
}
if (empty($page) || $page == -1) {
$page = 0;
}
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -68,39 +76,34 @@ $hookmanager->initHooks(array('thirdpartynotification', 'globalcard'));
$parameters = array('id'=>$socid);
$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;
// Add a notification
if ($action == 'add')
{
if (empty($contactid))
{
if ($action == 'add') {
if (empty($contactid)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Contact")), null, 'errors');
$error++;
}
if ($actionid <= 0)
{
if ($actionid <= 0) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors');
$error++;
}
if (!$error)
{
if (!$error) {
$db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
$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 .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")";
if (!$db->query($sql))
{
if (!$db->query($sql)) {
$error++;
dol_print_error($db);
}
@ -108,8 +111,7 @@ if (empty($reshook))
dol_print_error($db);
}
if (!$error)
{
if (!$error) {
$db->commit();
} else {
$db->rollback();
@ -118,8 +120,7 @@ if (empty($reshook))
}
// Remove a notification
if ($action == 'delete')
{
if ($action == 'delete') {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST('actid', 'int');
$db->query($sql);
}
@ -137,14 +138,15 @@ $object = new Societe($db);
$result = $object->fetch($socid);
$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';
llxHeader('', $title, $help_url);
if ($result > 0)
{
if ($result > 0) {
$langs->load("other");
$head = societe_prepare_head($object);
@ -161,44 +163,43 @@ if ($result > 0)
print '<table class="border centpercent tableforfield">';
// 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>';
}
if ($object->client) {
print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client;
$tmpcheck = $object->check_codeclient();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
}
print '</td></tr>';
}
if ($object->client) {
print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client;
$tmpcheck = $object->check_codeclient();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
}
print '</td></tr>';
}
if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) {
print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur;
$tmpcheck = $object->check_codefournisseur();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
}
print '</td></tr>';
}
if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) {
print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur;
$tmpcheck = $object->check_codefournisseur();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
}
print '</td></tr>';
}
/*print '<tr><td class="titlefield">'.$langs->trans("NbOfActiveNotifications").'</td>'; // Notification for this thirdparty
print '<td colspan="3">';
$nbofrecipientemails=0;
$notify=new Notify($db);
$tmparray = $notify->getNotificationsArray('', $object->id, null, 0, array('thirdparty'));
foreach($tmparray as $tmpkey => $tmpval)
{
if (! empty($tmpkey)) $nbofrecipientemails++;
}
print $nbofrecipientemails;
print '</td></tr>';*/
print '<td colspan="3">';
$nbofrecipientemails=0;
$notify=new Notify($db);
$tmparray = $notify->getNotificationsArray('', $object->id, null, 0, array('thirdparty'));
foreach($tmparray as $tmpkey => $tmpval)
{
if (! empty($tmpkey)) $nbofrecipientemails++;
}
print $nbofrecipientemails;
print '</td></tr>';*/
print '</table>';
@ -232,8 +233,7 @@ if ($result > 0)
$sql .= " AND c.fk_soc = ".$object->id;
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
} else {
dol_print_error($db);
@ -261,17 +261,15 @@ if ($result > 0)
// Line to add a new subscription
$listofemails = $object->thirdparty_and_contact_email_array();
if (count($listofemails) > 0)
{
if (count($listofemails) > 0) {
$actions = array();
// Load array of available notifications
$notificationtrigger = new InterfaceNotification($db);
$listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents();
foreach ($listofmanagedeventfornotification as $managedeventfornotification)
{
$label = ($langs->trans("Notify_".$managedeventfornotification['code']) != "Notify_".$managedeventfornotification['code'] ? $langs->trans("Notify_".$managedeventfornotification['code']) : $managedeventfornotification['label']);
foreach ($listofmanagedeventfornotification as $managedeventfornotification) {
$label = ($langs->trans("Notify_".$managedeventfornotification['code']) != "Notify_".$managedeventfornotification['code'] ? $langs->trans("Notify_".$managedeventfornotification['code']) : $managedeventfornotification['label']);
$actions[$managedeventfornotification['rowid']] = $label;
}
print '<tr class="oddeven nohover">';
@ -294,14 +292,12 @@ if ($result > 0)
}
if ($num)
{
if ($num) {
$i = 0;
$contactstatic = new Contact($db);
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
$contactstatic->id = $obj->contact_id;
@ -310,10 +306,8 @@ if ($result > 0)
print '<tr class="oddeven">';
print '<td>'.$contactstatic->getNomUrl(1);
if ($obj->type == 'email')
{
if (isValidEmail($obj->email))
{
if ($obj->type == 'email') {
if (isValidEmail($obj->email)) {
print ' &lt;'.$obj->email.'&gt;';
} else {
$langs->load("errors");
@ -326,8 +320,12 @@ if ($result > 0)
print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$label;
print '</td>';
print '<td>';
if ($obj->type == 'email') print $langs->trans("Email");
if ($obj->type == 'sms') print $langs->trans("SMS");
if ($obj->type == 'email') {
print $langs->trans("Email");
}
if ($obj->type == 'sms') {
print $langs->trans("SMS");
}
print '</td>';
print '<td class="right"><a href="card.php?socid='.$socid.'&action=delete&token='.newToken().'&actid='.$obj->rowid.'">'.img_delete().'</a></td>';
print '</tr>';
@ -338,9 +336,9 @@ if ($result > 0)
// List of notifications enabled for fixed email
/*
foreach($conf->global as $key => $val)
{
if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue;
foreach($conf->global as $key => $val)
{
if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue;
print '<tr class="oddeven"><td>';
$listtmp=explode(',',$val);
$first=1;
@ -349,7 +347,7 @@ if ($result > 0)
if (! $first) print ', ';
$first=0;
$valemail=trim($valemail);
//print $keyemail.' - '.$valemail.' - '.$reg[1].'<br>';
//print $keyemail.' - '.$valemail.' - '.$reg[1].'<br>';
if (isValidEmail($valemail, 1))
{
if ($valemail == '__SUPERVISOREMAIL__') print $valemail;
@ -377,14 +375,14 @@ if ($result > 0)
print '</td>';
print '<td class="right">'.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'</td>';
print '</tr>';
}*/
}*/
/*if ($user->admin)
{
{
print '<tr class="oddeven"><td colspan="4">';
print '+ <a href="'.DOL_URL_ROOT.'/admin/notification.php">'.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'</a>';
print '</td></tr>';
}*/
}*/
print '</table>';
print '</div>';
@ -406,12 +404,10 @@ if ($result > 0)
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $db->query($sql);
$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;
$offset = 0;
}
@ -420,19 +416,24 @@ if ($result > 0)
$sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
} else {
dol_print_error($db);
}
$param = '&socid='.$object->id;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.$contextpage;
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.$limit;
}
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="formfilteraction" id="formfilteraction" value="list">';
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 '</tr>';
if ($num > 0)
{
if ($num > 0) {
$i = 0;
$contactstatic = new Contact($db);
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td>';
if ($obj->id > 0)
{
if ($obj->id > 0) {
$contactstatic->id = $obj->id;
$contactstatic->lastname = $obj->lastname;
$contactstatic->firstname = $obj->firstname;
@ -481,18 +479,22 @@ if ($result > 0)
print $label;
print '</td>';
print '<td>';
if ($obj->type == 'email') print $langs->trans("Email");
if ($obj->type == 'sms') print $langs->trans("Sms");
if ($obj->type == 'email') {
print $langs->trans("Email");
}
if ($obj->type == 'sms') {
print $langs->trans("Sms");
}
print '</td>';
// TODO Add link to object here for other types
/*print '<td>';
if ($obj->object_type == 'order')
{
if ($obj->object_type == 'order')
{
$orderstatic->id=$obj->object_id;
$orderstatic->ref=...
print $orderstatic->getNomUrl(1);
}
print '</td>';*/
}
print '</td>';*/
// print
print'<td class="right">'.dol_print_date($db->jdate($obj->daten), 'dayhour').'</td>';
print '</tr>';
@ -507,7 +509,9 @@ if ($result > 0)
print '</div>';
print '</form>';
} else dol_print_error('', 'RecordNotFound');
} else {
dol_print_error('', 'RecordNotFound');
}
// End of page
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
$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
if ($user->socid)
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'societe', $socid, '&societe');
$object = new Societe($db);
@ -67,12 +68,12 @@ $error = 0;
$parameters = array('id'=>$socid);
$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 (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 (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
$search_prod = $search_label = $search_price = $search_price_ttc = '';
}
@ -102,8 +103,7 @@ if (empty($reshook))
$npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 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 (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.
$vatratecode = $reg[1];
// 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.code ='".$db->escape($vatratecode)."'";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $db->fetch_object($resql);
$npr = $obj->recuperableonly;
$localtax1 = $obj->localtax1;
@ -193,8 +192,9 @@ $object = new Societe($db);
$result = $object->fetch($socid);
llxHeader("", $langs->trans("ThirdParty").'-'.$langs->trans('PriceByCustomer'));
if (!empty($conf->notification->enabled))
if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = societe_prepare_head($object);
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 '<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>';
}
@ -250,14 +249,18 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$sortorder = GETPOST("sortorder", 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$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;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder)
if (!$sortorder) {
$sortorder = "ASC";
if (!$sortfield)
}
if (!$sortfield) {
$sortfield = "soc.nom";
}
// Build filter to display only concerned lines
$filter = array(
@ -365,8 +368,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print load_fiche_titre($langs->trans('PriceByCustomer'));
$result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
if ($result < 0)
{
if ($result < 0) {
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);
if ($result < 0)
{
if ($result < 0) {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
@ -537,14 +538,12 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
}
$result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0)
{
if ($result < 0) {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
@ -575,8 +574,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<td>&nbsp;</td>';
print '</tr>';
if (count($prodcustprice->lines) > 0 || $search_prod)
{
if (count($prodcustprice->lines) > 0 || $search_prod) {
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_label" value="'.$search_label.'" size="20"></td>';
@ -592,10 +590,8 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '</tr>';
}
if (count($prodcustprice->lines) > 0)
{
foreach ($prodcustprice->lines as $line)
{
if (count($prodcustprice->lines) > 0) {
foreach ($prodcustprice->lines as $line) {
print '<tr class="oddeven">';
$staticprod = new Product($db);
@ -621,8 +617,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '</td>';
// 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 '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=showlog_customer_price&amp;socid='.$object->id.'&amp;prodid='.$line->fk_product.'">';
print img_info();
@ -642,7 +637,9 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
}
} else {
$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>';
}

View File

@ -35,7 +35,9 @@ $langs->loadLangs(array("companies", "projects"));
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'societe', $socid, '&societe');
// 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);
$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);
if ($socid)
{
if ($socid) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@ -72,10 +75,14 @@ if ($socid)
$result = $object->fetch($socid);
$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);
if (!empty($conf->notification->enabled)) $langs->load("mails");
if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = societe_prepare_head($object);
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 '<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>';
}
if ($object->client)
{
if ($object->client) {
print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client;
@ -106,8 +111,7 @@ if ($socid)
print '</td></tr>';
}
if ($object->fournisseur)
{
if ($object->fournisseur) {
print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur;

View File

@ -43,15 +43,23 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "s.nom";
if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; }
if (!$sortorder) {
$sortorder = "ASC";
}
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;
$pageprev = $page - 1;
$pagenext = $page + 1;
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'societe', $id, '');
$object = new Societe($db);
@ -64,51 +72,39 @@ $hookmanager->initHooks(array('contactthirdparty', 'globalcard'));
* Actions
*/
if ($action == 'addcontact' && $user->rights->societe->creer)
{
if ($action == 'addcontact' && $user->rights->societe->creer) {
$result = $object->fetch($id);
if ($result > 0 && $id > 0)
{
if ($result > 0 && $id > 0) {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
}
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
} else {
$mesg = '<div class="error">'.$object->error.'</div>';
}
}
}
// bascule du statut d'un contact
elseif ($action == 'swapstatut' && $user->rights->societe->creer)
{
if ($object->fetch($id))
{
} elseif ($action == 'swapstatut' && $user->rights->societe->creer) {
// bascule du statut d'un contact
if ($object->fetch($id)) {
$result = $object->swapContactStatus(GETPOST('ligne'));
} else {
dol_print_error($db);
}
}
// Efface un contact
elseif ($action == 'deletecontact' && $user->rights->societe->creer)
{
} elseif ($action == 'deletecontact' && $user->rights->societe->creer) {
// Efface un contact
$object->fetch($id);
$result = $object->delete_contact($_GET["lineid"]);
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@ -145,10 +141,8 @@ $userstatic = new User($db);
/* */
/* *************************************************************************** */
if ($id > 0 || !empty($ref))
{
if ($object->fetch($id, $ref) > 0)
{
if ($id > 0 || !empty($ref)) {
if ($object->fetch($id, $ref) > 0) {
$soc = new Societe($db);
$soc->fetch($object->socid);
@ -169,41 +163,38 @@ if ($id > 0 || !empty($ref))
// Prospect/Customer
/*print '<tr><td class="titlefield">'.$langs->trans('ProspectCustomer').'</td><td>';
print $object->getLibCustProspStatut();
print '</td></tr>';
print $object->getLibCustProspStatut();
print '</td></tr>';
// Supplier
print '<tr><td>'.$langs->trans('Supplier').'</td><td>';
print yn($object->fournisseur);
print '</td></tr>';*/
// Supplier
print '<tr><td>'.$langs->trans('Supplier').'</td><td>';
print yn($object->fournisseur);
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>';
}
if ($object->client)
{
print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client;
$tmpcheck = $object->check_codeclient();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
}
print '</td></tr>';
if ($object->client) {
print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client;
$tmpcheck = $object->check_codeclient();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
}
print '</td></tr>';
}
if ($object->fournisseur)
{
print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur;
$tmpcheck = $object->check_codefournisseur();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
}
print '</td></tr>';
if ($object->fournisseur) {
print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur;
$tmpcheck = $object->check_codefournisseur();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
}
print '</td></tr>';
}
print '</table>';
@ -214,15 +205,15 @@ if ($id > 0 || !empty($ref))
// Contacts lines (modules that overwrite templates must declare this into descriptor)
$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');
if ($res) break;
if ($res) {
break;
}
}
// 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_type.class.php';
@ -241,12 +232,10 @@ if ($id > 0 || !empty($ref))
dol_syslog("get list sql=".$sql);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
if ($num > 0)
{
if ($num > 0) {
$param = '';
$titre = $langs->trans("MembersListOfTiers");
@ -267,8 +256,7 @@ if ($id > 0 || !empty($ref))
print "</tr>\n";
$i = 0;
while ($i < $num && $i < $conf->liste_limit)
{
while ($i < $num && $i < $conf->liste_limit) {
$objp = $db->fetch_object($resql);
$datefin = $db->jdate($objp->datefin);
@ -319,8 +307,7 @@ if ($id > 0 || !empty($ref))
print "</td>";
// End of subscription date
if ($datefin)
{
if ($datefin) {
print '<td class="center nowrap">';
print dol_print_date($datefin, 'day');
if ($memberstatic->hasDelay()) {
@ -329,10 +316,11 @@ if ($id > 0 || !empty($ref))
print '</td>';
} else {
print '<td class="left nowrap">';
if ($objp->subscription == 'yes')
{
if ($objp->subscription == 'yes') {
print $langs->trans("SubscriptionNotReceived");
if ($objp->statut > 0) print " ".img_warning();
if ($objp->statut > 0) {
print " ".img_warning();
}
} else {
print '&nbsp;';
}

View File

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

View File

@ -47,19 +47,27 @@ $search_status = GETPOST('search_status');
// Security check
$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');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$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;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = 't.login';
if (!$sortorder) $sortorder = 'ASC';
if (!$sortfield) {
$sortfield = 't.login';
}
if (!$sortorder) {
$sortorder = 'ASC';
}
// Initialize technical objects
$object = new Societe($db);
@ -78,24 +86,27 @@ unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are alr
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha');
$search = array();
foreach ($objectwebsiteaccount->fields as $key => $val)
{
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
foreach ($objectwebsiteaccount->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha')) {
$search[$key] = GETPOST('search_'.$key, 'alpha');
}
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array();
foreach ($objectwebsiteaccount->fields as $key => $val)
{
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
foreach ($objectwebsiteaccount->fields as $key => $val) {
if ($val['searchall']) {
$fieldstosearchall['t.'.$key] = $val['label'];
}
}
// Definition of fields for list
$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 (!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
@ -105,8 +116,7 @@ $object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
if ($id > 0)
{
if ($id > 0) {
$result = $object->fetch($id);
}
@ -117,13 +127,13 @@ if ($id > 0)
$parameters = array('id'=>$socid);
$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
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
{
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
@ -132,18 +142,15 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// 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
{
foreach ($objectwebsiteaccount->fields as $key => $val)
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
foreach ($objectwebsiteaccount->fields as $key => $val) {
$search[$key] = '';
}
$toselect = '';
$search_array_options = array();
}
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
}
@ -172,14 +179,21 @@ $title = $langs->trans("WebsiteAccounts");
llxHeader('', $title);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($id > 0) $param .= '&id='.urlencode($id);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
foreach ($search as $key => $val)
{
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
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]);
}
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
// Add $param from extra fields
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">';
// 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>';
}
@ -247,29 +260,39 @@ print '<br>';
// Build and execute select
// --------------------------------------------------------------------
$sql = 'SELECT ';
foreach ($objectwebsiteaccount->fields as $key => $val)
{
foreach ($objectwebsiteaccount->fields as $key => $val) {
$sql .= 't.'.$key.', ';
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label']))
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
}
}
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql = preg_replace('/, $/', '', $sql);
$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 ($objectwebsiteaccount->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity('societeaccount').")";
else $sql .= " WHERE 1 = 1";
$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 (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 ($objectwebsiteaccount->ismultientitymanaged == 1) {
$sql .= " WHERE t.entity IN (".getEntity('societeaccount').")";
} else {
$sql .= " WHERE 1 = 1";
}
$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
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
@ -296,12 +319,10 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $db->query($sql);
$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;
$offset = 0;
}
@ -310,8 +331,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if (!$resql)
{
if (!$resql) {
dol_print_error($db);
exit;
}
@ -325,12 +345,18 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
if ($user->rights->mymodule->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if ($user->rights->mymodule->delete) {
$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);
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="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -361,11 +387,13 @@ $moreforfilter.= '</div>';*/
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
if (empty($reshook)) {
$moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
if (!empty($moreforfilter))
{
if (!empty($moreforfilter)) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
@ -382,13 +410,20 @@ print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" :
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
foreach ($objectwebsiteaccount->fields as $key => $val)
{
foreach ($objectwebsiteaccount->fields as $key => $val) {
$align = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center';
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>';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$align = 'center';
}
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
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@ -407,13 +442,20 @@ print '</tr>'."\n";
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
foreach ($objectwebsiteaccount->fields as $key => $val)
{
foreach ($objectwebsiteaccount->fields as $key => $val) {
$align = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center';
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";
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$align = 'center';
}
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
@ -428,11 +470,11 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine = 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)
{
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
if (preg_match('/\$object/', $val)) {
$needToFetchEachLine++; // There is at least one compute field that use $object
}
}
}
@ -440,40 +482,54 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
if (empty($obj)) {
break; // Should not happen
}
// Store properties in $object
$objectwebsiteaccount->id = $obj->rowid;
$objectwebsiteaccount->login = $obj->login;
$objectwebsiteaccount->ref = $obj->login;
foreach ($objectwebsiteaccount->fields as $key => $val)
{
if (property_exists($obj, $key)) $object->$key = $obj->$key;
foreach ($objectwebsiteaccount->fields as $key => $val) {
if (property_exists($obj, $key)) {
$object->$key = $obj->$key;
}
}
// Show here line of result
print '<tr class="oddeven">';
foreach ($objectwebsiteaccount->fields as $key => $val)
{
foreach ($objectwebsiteaccount->fields as $key => $val) {
$align = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center';
if (in_array($val['type'], array('timestamp'))) $align .= 'nowrap';
if ($key == 'status') $align .= ($align ? ' ' : '').'center';
if (!empty($arrayfields['t.'.$key]['checked']))
{
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
$align = 'center';
}
if (in_array($val['type'], array('timestamp'))) {
$align .= 'nowrap';
}
if ($key == 'status') {
$align .= ($align ? ' ' : '').'center';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td';
if ($align) print ' class="'.$align.'"';
if ($align) {
print ' class="'.$align.'"';
}
print '>';
if ($key == 'login') print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1);
else print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, '');
if ($key == 'login') {
print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1);
} else {
print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, '');
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!empty($val['isameasure']))
{
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
if (!$i) {
$totalarray['nbfield']++;
}
if (!empty($val['isameasure'])) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
$totalarray['val']['t.'.$key] += $obj->$key;
}
}
@ -486,14 +542,17 @@ while ($i < min($num, $limit))
print $hookmanager->resPrint;
// Action column
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;
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 '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>';
@ -505,10 +564,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
if ($num == 0)
{
if ($num == 0) {
$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>';
}
@ -524,10 +586,11 @@ print '</div>'."\n";
print '</form>'."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
{
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
$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';
$formfile = new FormFile($db);

View File

@ -37,7 +37,9 @@ $servicename = 'Stripe';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'paypal', 'paybox', 'stripe'));
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09');
@ -46,64 +48,79 @@ $action = GETPOST('action', 'aZ09');
* Actions
*/
if ($action == 'setvalue' && $user->admin)
{
if ($action == 'setvalue' && $user->admin) {
$db->begin();
if (empty($conf->stripeconnect->enabled)) {
$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)
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)
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)
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)
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)
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)
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)
if (!$result > 0) {
$error++;
}
}
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR", GETPOST('ONLINE_PAYMENT_CREDITOR', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!$result > 0)
if (!$result > 0) {
$error++;
}
$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++;
}
$result = dolibarr_set_const($db, "STRIPE_USER_ACCOUNT_FOR_ACTIONS", GETPOST('STRIPE_USER_ACCOUNT_FOR_ACTIONS', 'int'), 'chaine', 0, '', $conf->entity);
if (!$result > 0) {
$error++;
}
$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++;
}
$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++;
}
$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++;
}
$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++;
}
$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++;
}
$result = dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL", GETPOST('ONLINE_PAYMENT_SENDEMAIL'), 'chaine', 0, '', $conf->entity);
if (!$result > 0)
if (!$result > 0) {
$error++;
}
// 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);
//if (! $result > 0)
@ -130,8 +147,7 @@ if ($action == 'setvalue' && $user->admin)
}
}
if ($action == "setlive")
{
if ($action == "setlive") {
$liveenable = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "STRIPE_LIVE", $liveenable, 'yesno', 0, '', $conf->entity);
if ($res > 0) {
@ -188,8 +204,7 @@ if ($conf->use_javascript_ajax) {
}
print '</td><td></td></tr>';
if (empty($conf->stripeconnect->enabled))
{
if (empty($conf->stripeconnect->enabled)) {
print '<tr class="oddeven"><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.'">';
@ -216,10 +231,8 @@ if (empty($conf->stripeconnect->enabled))
$out .= ajax_autoselect("onlinetestwebhookurl", 0);
print '<br>'.$out;
print '</td><td>';
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 ($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)) {
\Stripe\Stripe::setApiKey($conf->global->STRIPE_TEST_SECRET_KEY);
$endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID);
$endpoint->enabled_events = $stripearrayofwebhookevents;
@ -232,8 +245,7 @@ if (empty($conf->stripeconnect->enabled))
}
$endpoint->url = dol_buildpath('/public/stripe/ipn.php?test', 3);
$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 img_picto($langs->trans("Activated"), 'switch_on');
} else {
@ -257,8 +269,7 @@ if (empty($conf->stripeconnect->enabled))
print '</td><td></td></tr>';
}
if (empty($conf->stripeconnect->enabled))
{
if (empty($conf->stripeconnect->enabled)) {
print '<tr class="oddeven"><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.'">';
@ -285,10 +296,8 @@ if (empty($conf->stripeconnect->enabled))
$out .= ajax_autoselect("onlinelivewebhookurl", 0);
print '<br>'.$out;
print '</td><td>';
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 ($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)) {
\Stripe\Stripe::setApiKey($conf->global->STRIPE_LIVE_SECRET_KEY);
$endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_LIVE_WEBHOOK_ID);
$endpoint->enabled_events = $stripearrayofwebhookevents;
@ -301,8 +310,7 @@ if (empty($conf->stripeconnect->enabled))
}
$endpoint->url = dol_buildpath('/public/stripe/ipn.php', 3);
$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 img_picto($langs->trans("Activated"), 'switch_on');
} 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);
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 $langs->trans("BankAccountForBankTransfer").'</td><td>';
$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
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 $langs->trans("STRIPE_PAYMENT_REQUEST_API").'</td><td>';
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
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 $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").'</td><td>';
if ($conf->use_javascript_ajax) {
@ -388,8 +393,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
}
// 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 $langs->trans("STRIPE_BANCONTACT").'</td><td>';
if ($conf->use_javascript_ajax) {
@ -403,8 +407,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
}
// 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 $langs->trans("STRIPE_IDEAL").'</td><td>';
if ($conf->use_javascript_ajax) {
@ -418,8 +421,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
}
// 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 $langs->trans("STRIPE_GIROPAY").'</td><td>';
if ($conf->use_javascript_ajax) {
@ -433,8 +435,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code
}
// 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 $langs->trans("STRIPE_SOFORT").'</td><td>';
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'));
if (!empty($conf->use_javascript_ajax))
{
if (!empty($conf->use_javascript_ajax)) {
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#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.'/commande/class/commande.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
$langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe'));
// Security check
$socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
//$result = restrictedArea($user, 'salaries', '', '', '');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
@ -41,7 +45,9 @@ $rowid = GETPOST("rowid", 'alpha');
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$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;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -60,8 +66,7 @@ $stripe = new Stripe($db);
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';
$servicestatus = '0';
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
@ -80,11 +85,12 @@ if (!$rowid) {
$option = array('limit' => $limit + 1);
$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 {
if ($stripeacc)
{
if ($stripeacc) {
$list = \Stripe\Charge::all($option, array("stripe_account" => $stripeacc));
} else {
$list = \Stripe\Charge::all($option);
@ -96,7 +102,9 @@ if (!$rowid) {
$param = '';
//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.='&ending_before_'.($page+1).'='.$list->data[($limit-1)]->id;
@ -106,7 +114,9 @@ if (!$rowid) {
}
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="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -135,8 +145,7 @@ if (!$rowid) {
//print $list;
$i = 0;
foreach ($list->data as $charge)
{
foreach ($list->data as $charge) {
if ($i >= $limit) {
break;
}
@ -179,17 +188,14 @@ if (!$rowid) {
// Save into $tmparray all metadata
$tmparray = dolExplodeIntoArray($FULLTAG, '.', '=');
// Load origin object according to metadata
if (!empty($tmparray['CUS']) && $tmparray['CUS'] > 0)
{
if (!empty($tmparray['CUS']) && $tmparray['CUS'] > 0) {
$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);
} else {
$societestatic->id = 0;
}
if (!empty($tmparray['MEM']) && $tmparray['MEM'] > 0)
{
if (!empty($tmparray['MEM']) && $tmparray['MEM'] > 0) {
$memberstatic->fetch($tmparray['MEM']);
} else {
$memberstatic->id = 0;
@ -197,40 +203,41 @@ if (!$rowid) {
print '<tr class="oddeven">';
if (!empty($stripeacc)) $connect = $stripeacc.'/';
if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
}
// Ref
$url = 'https://dashboard.stripe.com/'.$connect.'test/payments/'.$charge->id;
if ($servicestatus)
{
if ($servicestatus) {
$url = 'https://dashboard.stripe.com/'.$connect.'payments/'.$charge->id;
}
print "<td>";
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";
// Stripe customer
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;
if ($servicestatus)
{
if ($servicestatus) {
$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 "</td>\n";
// Link
print "<td>";
if ($societestatic->id > 0)
{
if ($societestatic->id > 0) {
print $societestatic->getNomUrl(1);
} elseif ($memberstatic->id > 0)
{
} elseif ($memberstatic->id > 0) {
print $memberstatic->getNomUrl(1);
}
print "</td>\n";

View File

@ -71,25 +71,21 @@ class ActionsStripeconnect
{
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';
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
} else {
$service = 'StripeLive';
}
if (is_array($parameters) && !empty($parameters))
{
foreach ($parameters as $key=>$value)
{
if (is_array($parameters) && !empty($parameters)) {
foreach ($parameters as $key => $value) {
$key = $value;
}
}
if (is_object($object) && $object->element == 'societe')
{
if (is_object($object) && $object->element == 'societe') {
$this->resprints .= '<tr><td>';
$this->resprints .= '<table width="100%" class="nobordernopadding"><tr><td>';
$this->resprints .= $langs->trans('StripeCustomer');
@ -195,20 +191,16 @@ class ActionsStripeconnect
$resteapayer = $object->total_ttc - $totalpaye;
// 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);
if ($resteapayer > 0)
{
if ($stripe->getStripeAccount($conf->entity)) // a modifier avec droit stripe
{
if ($resteapayer > 0) {
if ($stripe->getStripeAccount($conf->entity)) { // a modifier avec droit stripe
$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>';
} else {
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>';
}
} else {

View File

@ -91,7 +91,9 @@ class Stripe extends CommonObject
global $conf;
$key = '';
if ($entity < 0) $entity = $conf->entity;
if ($entity < 0) {
$entity = $conf->entity;
}
$sql = "SELECT tokenstring";
$sql .= " FROM ".MAIN_DB_PREFIX."oauth_token";
@ -155,8 +157,7 @@ class Stripe extends CommonObject
{
global $conf, $user;
if (empty($object->id))
{
if (empty($object->id)) {
dol_syslog("customerStripe is called with the parameter object that is not loaded");
return null;
}
@ -193,8 +194,7 @@ class Stripe extends CommonObject
//$customer = \Stripe\Customer::retrieve("$tiers", 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.'
$this->error = $e->getMessage();
}
@ -234,13 +234,10 @@ class Stripe extends CommonObject
}
// 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($vatcleaned))
{
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)) {
$isineec = isInEEC($object);
if ($object->country_code && $isineec)
{
if ($object->country_code && $isineec) {
//$taxids = $customer->allTaxIds($customer->id);
$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 .= " 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);
if (!$resql)
{
if (!$resql) {
$this->error = $this->db->lasterror();
}
} catch (Exception $e)
{
} catch (Exception $e) {
$this->error = $e->getMessage();
}
}
@ -288,8 +283,7 @@ class Stripe extends CommonObject
} else {
$stripepaymentmethod = \Stripe\PaymentMethod::retrieve(''.$paymentmethod->id.'', array("stripe_account" => $key));
}
} catch (Exception $e)
{
} catch (Exception $e) {
$this->error = $e->getMessage();
}
@ -329,12 +323,18 @@ class Stripe extends CommonObject
$error = 0;
if (empty($status)) $service = 'StripeTest';
else $service = 'StripeLive';
if (empty($status)) {
$service = 'StripeTest';
} else {
$service = 'StripeLive';
}
$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;
else $stripeamount = $amount;
if (!in_array($currency_code, $arrayzerounitcurrency)) {
$stripeamount = $amount * 100;
} else {
$stripeamount = $amount;
}
$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) {
@ -350,8 +350,7 @@ class Stripe extends CommonObject
$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.
// 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
@ -369,8 +368,7 @@ class Stripe extends CommonObject
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
if ($num)
{
if ($num) {
$obj = $this->db->fetch_object($resql);
$intent = $obj->ext_payment_id;
@ -386,8 +384,7 @@ class Stripe extends CommonObject
} else {
$paymentintent = \Stripe\PaymentIntent::retrieve($intent, array("stripe_account" => $key));
}
}
catch (Exception $e) {
} catch (Exception $e) {
$error++;
$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
$ipaddress = getUserRemoteIP();
$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_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
$paymentmethodtypes = array("card");
if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC())
if (!empty($conf->global->STRIPE_BANCONTACT)) $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";
if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) {
$paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC())
}
if (!empty($conf->global->STRIPE_BANCONTACT)) {
$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(
"confirm" => $confirmnow, // Do not confirm immediatly during creation of intent
@ -427,32 +434,32 @@ class Stripe extends CommonObject
"setup_future_usage" => "on_session",
"metadata" => $metadata
);
if (!is_null($customer)) $dataforintent["customer"] = $customer;
if (!is_null($customer)) {
$dataforintent["customer"] = $customer;
}
// payment_method =
// payment_method_types = array('card')
//var_dump($dataforintent);
if ($off_session)
{
if ($off_session) {
unset($dataforintent['setup_future_usage']);
// 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.
//$dataforintent["setup_future_usage"] = "off_session";
$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;
$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;
}
if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email)
{
if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email) {
$dataforintent["receipt_email"] = $object->thirdparty->email;
}
@ -475,8 +482,7 @@ class Stripe extends CommonObject
$paymentintent = \Stripe\PaymentIntent::create($dataforintent, $arrayofoptions);
// Store the payment intent
if (is_object($object))
{
if (is_object($object)) {
$paymentintentalreadyexists = 0;
// Check that payment intent $paymentintent->id is not already recorded.
$sql = "SELECT pi.rowid";
@ -489,22 +495,23 @@ class Stripe extends CommonObject
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
if ($num)
{
if ($num) {
$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 (!$paymentintentalreadyexists)
{
if (!$paymentintentalreadyexists) {
$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 .= " 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);
if (!$resql)
{
if (!$resql) {
$error++;
$this->error = $this->db->lasterror();
dol_syslog(get_class($this)."::PaymentIntent failed to insert paymentintent with id=".$paymentintent->id." into database.");
@ -513,20 +520,18 @@ class Stripe extends CommonObject
} else {
$_SESSION["stripe_payment_intent"] = $paymentintent;
}
} catch (Stripe\Error\Card $e)
{
} catch (Stripe\Error\Card $e) {
$error++;
$this->error = $e->getMessage();
$this->code = $e->getStripeCode();
$this->declinecode = $e->getDeclineCode();
} catch (Exception $e)
{
} catch (Exception $e) {
/*var_dump($dataforintent);
var_dump($description);
var_dump($key);
var_dump($paymentintent);
var_dump($e->getMessage());
var_dump($e);*/
var_dump($description);
var_dump($key);
var_dump($paymentintent);
var_dump($e->getMessage());
var_dump($e);*/
$error++;
$this->error = $e->getMessage();
$this->code = '';
@ -570,29 +575,40 @@ class Stripe extends CommonObject
$error = 0;
if (empty($status)) $service = 'StripeTest';
else $service = 'StripeLive';
if (empty($status)) {
$service = 'StripeTest';
} else {
$service = 'StripeLive';
}
$setupintent = null;
if (empty($setupintent))
{
if (empty($setupintent)) {
$ipaddress = getUserRemoteIP();
$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_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
$paymentmethodtypes = array("card");
if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC())
if (!empty($conf->global->STRIPE_BANCONTACT)) $paymentmethodtypes[] = "bancontact";
if (!empty($conf->global->STRIPE_IDEAL)) $paymentmethodtypes[] = "ideal";
if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) {
$paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC())
}
if (!empty($conf->global->STRIPE_BANCONTACT)) {
$paymentmethodtypes[] = "bancontact";
}
if (!empty($conf->global->STRIPE_IDEAL)) {
$paymentmethodtypes[] = "ideal";
}
// Giropay not possible for setup intent
if (!empty($conf->global->STRIPE_SOFORT)) $paymentmethodtypes[] = "sofort";
if (!empty($conf->global->STRIPE_SOFORT)) {
$paymentmethodtypes[] = "sofort";
}
$dataforintent = array(
"confirm" => $confirmnow, // Do not confirm immediatly during creation of intent
@ -600,14 +616,17 @@ class Stripe extends CommonObject
"usage" => "off_session",
"metadata" => $metadata
);
if (!is_null($customer)) $dataforintent["customer"] = $customer;
if (!is_null($description)) $dataforintent["description"] = $description;
if (!is_null($customer)) {
$dataforintent["customer"] = $customer;
}
if (!is_null($description)) {
$dataforintent["description"] = $description;
}
// payment_method =
// payment_method_types = array('card')
//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;
}
@ -670,8 +689,7 @@ class Stripe extends CommonObject
{
$_SESSION["stripe_setup_intent"] = $setupintent;
}*/
} catch (Exception $e)
{
} catch (Exception $e) {
/*var_dump($dataforintent);
var_dump($description);
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);
return $setupintent;
} else {
@ -718,24 +735,20 @@ class Stripe extends CommonObject
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
if ($num)
{
if ($num) {
$obj = $this->db->fetch_object($resql);
$cardref = $obj->stripe_card_ref;
dol_syslog(get_class($this)."::cardStripe cardref=".$cardref);
if ($cardref)
{
if ($cardref) {
try {
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);
} else {
$card = \Stripe\PaymentMethod::retrieve($cardref);
}
} 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);
} else {
@ -743,13 +756,11 @@ class Stripe extends CommonObject
$card = \Stripe\PaymentMethod::retrieve($cardref);
}
}
} catch (Exception $e)
{
} catch (Exception $e) {
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
}
} elseif ($createifnotlinkedtostripe)
{
} elseif ($createifnotlinkedtostripe) {
$exp_date_month = $obj->exp_date_month;
$exp_date_year = $obj->exp_date_year;
$number = $obj->number;
@ -767,20 +778,19 @@ class Stripe extends CommonObject
//var_dump($a);var_dump($stripeacc);exit;
try {
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));
$card = $cu->sources->create($dataforcard);
if (!$card)
{
if (!$card) {
$this->error = 'Creation of card on Stripe has failed';
}
} else {
$connect = '';
if (!empty($stripeacc)) $connect = $stripeacc.'/';
if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
}
$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$cu->id;
if ($status)
{
if ($status) {
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id;
}
$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);
}
} 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));
$card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc));
if (!$card)
{
if (!$card) {
$this->error = 'Creation of card on Stripe has failed';
}
} else {
$connect = '';
if (!empty($stripeacc)) $connect = $stripeacc.'/';
if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
}
$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$cu->id;
if ($status)
{
if ($status) {
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id;
}
$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 .= " SET stripe_card_ref = '".$this->db->escape($card->id)."', card_type = '".$this->db->escape($card->brand)."',";
$sql .= " country_code = '".$this->db->escape($card->country)."',";
@ -821,13 +829,11 @@ class Stripe extends CommonObject
$sql .= " WHERE rowid = ".$object->id;
$sql .= " AND type = 'card'";
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$this->error = $this->db->lasterror();
}
}
} catch (Exception $e)
{
} catch (Exception $e) {
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
}
@ -862,8 +868,11 @@ class Stripe extends CommonObject
$error = 0;
if (empty($status)) $service = 'StripeTest';
else $service = 'StripeLive';
if (empty($status)) {
$service = 'StripeTest';
} else {
$service = 'StripeLive';
}
$sql = "SELECT sa.key_account as key_account, sa.fk_soc, sa.entity";
$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');
if (!in_array($currency, $arrayzerounitcurrency)) $stripeamount = $amount * 100;
else $stripeamount = $amount;
if (!in_array($currency, $arrayzerounitcurrency)) {
$stripeamount = $amount * 100;
} else {
$stripeamount = $amount;
}
$societe = new Societe($this->db);
if ($key > 0) $societe->fetch($key);
if ($key > 0) {
$societe->fetch($key);
}
$description = "";
$ref = "";
@ -922,10 +936,8 @@ class Stripe extends CommonObject
global $stripearrayofkeysbyenv;
\Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']);
if (empty($conf->stripeconnect->enabled)) // With a common Stripe account
{
if (preg_match('/pm_/i', $source))
{
if (empty($conf->stripeconnect->enabled)) { // With a common Stripe account
if (preg_match('/pm_/i', $source)) {
$stripecard = $source;
$amountstripe = $stripeamount;
$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);
$charge = new stdClass();
if ($paymentintent->status == 'succeeded')
{
if ($paymentintent->status == 'succeeded') {
$charge->status = 'ok';
} else {
$charge->status = 'failed';
@ -954,8 +965,7 @@ class Stripe extends CommonObject
$stripefailuremessage = $stripe->error;
$stripefailuredeclinecode = $stripe->declinecode;
}
} elseif (preg_match('/acct_/i', $source))
{
} elseif (preg_match('/acct_/i', $source)) {
$charge = \Stripe\Charge::create(array(
"amount" => "$stripeamount",
"currency" => "$currency",
@ -977,8 +987,7 @@ class Stripe extends CommonObject
"customer" => "$customer"
);
if ($societe->email && $usethirdpartyemailforreceiptemail)
{
if ($societe->email && $usethirdpartyemailforreceiptemail) {
$paymentarray["receipt_email"] = $societe->email;
}
@ -993,8 +1002,11 @@ class Stripe extends CommonObject
$fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL;
}
if (!in_array($currency, $arrayzerounitcurrency)) $stripefee = round($fee * 100);
else $stripefee = round($fee);
if (!in_array($currency, $arrayzerounitcurrency)) {
$stripefee = round($fee * 100);
} else {
$stripefee = round($fee);
}
$paymentarray = array(
"amount" => "$stripeamount",
@ -1006,17 +1018,14 @@ class Stripe extends CommonObject
"source" => "$source",
"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;
}
if ($societe->email && $usethirdpartyemailforreceiptemail)
{
if ($societe->email && $usethirdpartyemailforreceiptemail) {
$paymentarray["receipt_email"] = $societe->email;
}
if (preg_match('/pm_/i', $source))
{
if (preg_match('/pm_/i', $source)) {
$stripecard = $source;
$amountstripe = $stripeamount;
$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);
$charge = new stdClass();
if ($paymentintent->status == 'succeeded')
{
if ($paymentintent->status == 'succeeded') {
$charge->status = 'ok';
$charge->id = $paymentintent->id;
} else {
@ -1047,13 +1055,13 @@ class Stripe extends CommonObject
$charge = \Stripe\Charge::create($paymentarray, array("idempotency_key" => "$description", "stripe_account" => "$account"));
}
}
if (isset($charge->id)) {}
if (isset($charge->id)) {
}
$return->statut = 'success';
$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;
} else {
if ($charge->source->type == 'card') {

View File

@ -44,8 +44,7 @@ $stripearrayofkeysbyenv = 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
} else {
$stripearrayofkeys = $stripearrayofkeysbyenv[1]; // Live

View File

@ -67,52 +67,53 @@ function html_print_stripe_footer($fromcompany, $langs)
// Juridical status
$line1 = "";
if ($fromcompany->forme_juridique_code)
{
if ($fromcompany->forme_juridique_code) {
$line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code);
}
// Capital
if ($fromcompany->capital)
{
if ($fromcompany->capital) {
$line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency);
}
$reg = array();
// 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);
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
if (preg_match('/\((.*)\)/i', $field, $reg)) {
$field = $reg[1];
}
$line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1;
}
// Prof Id 2
if ($fromcompany->idprof2)
{
if ($fromcompany->idprof2) {
$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;
}
// Second line of company infos
$line2 = "";
// Prof Id 3
if ($fromcompany->idprof3)
{
if ($fromcompany->idprof3) {
$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;
}
// Prof Id 4
if ($fromcompany->idprof4)
{
if ($fromcompany->idprof4) {
$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;
}
// IntraCommunautary VAT
if ($fromcompany->tva_intra != '')
{
if ($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.'/commande/class/commande.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
$langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe'));
// Security check
$socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
//$result = restrictedArea($user, 'salaries', '', '', '');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
@ -41,7 +45,9 @@ $rowid = GETPOST("rowid", 'alpha');
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$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;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -110,15 +116,13 @@ if (!$rowid) {
print "</tr>\n";
try {
if ($stripeacc)
{
if ($stripeacc) {
$payout = \Stripe\Payout::all(array("limit" => $limit), array("stripe_account" => $stripeacc));
} else {
$payout = \Stripe\Payout::all(array("limit" => $limit));
}
foreach ($payout->data as $payout)
{
foreach ($payout->data as $payout) {
//$charge = $payout;
//var_dump($payout);
@ -157,7 +161,9 @@ if (!$rowid) {
print '<tr class="oddeven">';
// Ref
if (!empty($stripeacc)) $connect = $stripeacc.'/';
if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
}
$url = 'https://dashboard.stripe.com/'.$connect.'test/payouts/'.$payout->id;
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.'/commande/class/commande.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
$langs->loadLangs(array('compta', 'salaries', 'bills', 'hrm', 'stripe'));
// Security check
$socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
//$result = restrictedArea($user, 'salaries', '', '', '');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
@ -41,7 +45,9 @@ $rowid = GETPOST("rowid", 'alpha');
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$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;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -60,8 +66,7 @@ $stripe = new Stripe($db);
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';
$servicestatus = '0';
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
@ -77,7 +82,9 @@ $stripeacc = $stripe->getStripeAccount($service);
if (!$rowid) {
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="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -106,15 +113,13 @@ if (!$rowid) {
print "</tr>\n";
try {
if ($stripeacc)
{
if ($stripeacc) {
$txn = \Stripe\BalanceTransaction::all(array("limit" => $limit), array("stripe_account" => $stripeacc));
} else {
$txn = \Stripe\BalanceTransaction::all(array("limit" => $limit));
}
foreach ($txn->data as $txn)
{
foreach ($txn->data as $txn) {
//$charge = $txn;
//var_dump($txn);
@ -153,7 +158,9 @@ if (!$rowid) {
print '<tr class="oddeven">';
// Ref
if (!empty($stripeacc)) $connect = $stripeacc.'/';
if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
}
// Ref
if (preg_match('/po_/i', $txn->source)) {

View File

@ -31,13 +31,17 @@ $form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$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');
$attrname = GETPOST('attrname', 'alpha');
$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
if ($action != 'create' && $action != 'edit')
{
if ($action != 'create' && $action != 'edit') {
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>";
@ -86,8 +89,7 @@ if ($action != 'create' && $action != 'edit')
/* */
/* ************************************************************************** */
if ($action == 'create')
{
if ($action == 'create') {
print "<br>";
print load_fiche_titre($langs->trans('NewAttribute'));
@ -99,8 +101,7 @@ if ($action == 'create')
/* Edition of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'edit' && !empty($attrname))
{
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
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';
if (!$user->admin)
if (!$user->admin) {
accessforbidden();
}
// Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'supplier_proposal'));
@ -38,14 +39,18 @@ $form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$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');
$attrname = GETPOST('attrname', 'alpha');
$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
if ($action != 'create' && $action != 'edit')
{
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
@ -91,8 +95,7 @@ if ($action != 'create' && $action != 'edit')
/* */
/* ************************************************************************** */
if ($action == 'create')
{
if ($action == 'create') {
print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
@ -104,8 +107,7 @@ if ($action == 'create')
/* Edition d'un champ optionnel */
/* */
/* ************************************************************************** */
if ($action == 'edit' && !empty($attrname))
{
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
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
*/
static $FIELDS = array(
public static $FIELDS = array(
'socid'
);
@ -105,28 +105,37 @@ class Supplierproposals extends DolibarrApi
// If the internal user must only see his customers, force searching by him
$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";
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";
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').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc";
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
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= " AND t.fk_soc = sc.fk_soc";
}
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
if ($search_sale > 0)
{
if ($search_sale > 0) {
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
{
if (!DolibarrApi::_checkFilters($sqlfilters))
{
if ($sqlfilters) {
if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -135,8 +144,7 @@ class Supplierproposals extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
@ -146,13 +154,11 @@ class Supplierproposals extends DolibarrApi
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0;
while ($i < $min)
{
while ($i < $min) {
$obj = $this->db->fetch_object($result);
$propal_static = new SupplierProposal($this->db);
if ($propal_static->fetch($obj->rowid)) {
@ -181,8 +187,9 @@ class Supplierproposals extends DolibarrApi
{
$propal = array();
foreach (SupplierProposals::$FIELDS as $field) {
if (!isset($data[$field]))
if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
}
$propal[$field] = $data[$field];
}
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');
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal', '');
$object = new SupplierProposal($db);
@ -51,50 +53,38 @@ $permissiontoedit = $user->rights->supplier_proposal->creer;
* Add a new contact
*/
if ($action == 'addcontact' && $permissiontoedit)
{
if ($action == 'addcontact' && $permissiontoedit) {
$result = $object->fetch($id);
if ($result > 0 && $id > 0)
{
if ($result > 0 && $id > 0) {
$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);
exit;
} else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors");
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
// Toggle the status of a contact
elseif ($action == 'swapstatut' && $permissiontoedit)
{
if ($object->fetch($id))
{
} elseif ($action == 'swapstatut' && $permissiontoedit) {
// Toggle the status of a contact
if ($object->fetch($id)) {
$result = $object->swapContactStatus(GETPOST('ligne'));
} else {
dol_print_error($db);
}
}
// Deleting a contact
elseif ($action == 'deletecontact' && $permissiontoedit)
{
} elseif ($action == 'deletecontact' && $permissiontoedit) {
// Deleting a contact
$object->fetch($id);
$result = $object->delete_contact(GETPOST("lineid", 'int'));
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@ -123,12 +113,10 @@ $userstatic = new User($db);
/* */
/* *************************************************************************** */
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$langs->trans("SupplierProposal");
if ($object->fetch($id, $ref) > 0)
{
if ($object->fetch($id, $ref) > 0) {
$object->fetch_thirdparty();
$head = supplier_proposal_prepare_head($object);
@ -145,12 +133,10 @@ if ($id > 0 || !empty($ref))
// Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($permissiontoedit)
{
if ($permissiontoedit) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ';

View File

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

View File

@ -38,8 +38,7 @@ $langs->loadLangs(array('supplier_proposal', 'companies'));
// Security check
$socid = GETPOST('socid', 'int');
if (isset($user->socid) && $user->socid > 0)
{
if (isset($user->socid) && $user->socid > 0) {
$action = '';
$socid = $user->socid;
}
@ -65,8 +64,7 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
// 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 '<input type="hidden" name="token" value="'.newToken().'">';
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 .= " FROM ".MAIN_DB_PREFIX."societe as s";
$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 .= " AND p.entity IN (".getEntity('supplier_proposal').")";
if ($user->socid) $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;
if ($user->socid) {
$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 .= " GROUP BY p.fk_statut";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
@ -103,11 +106,9 @@ if ($resql)
$colorseries = 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)
while ($i < $num)
{
while ($i < $num) {
$row = $db->fetch_row($resql);
if ($row)
{
if ($row) {
//if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1))
{
$vals[$row[1]] = $row[0];
@ -125,25 +126,32 @@ if ($resql)
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("CommRequests").'</th></tr>'."\n";
$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));
if ($status == SupplierProposal::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
if ($status == SupplierProposal::STATUS_VALIDATED) $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 ($status == SupplierProposal::STATUS_DRAFT) {
$colorseries[$status] = '-'.$badgeStatus0;
}
if ($status == SupplierProposal::STATUS_VALIDATED) {
$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 '<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 "</tr>\n";
}
}
if ($conf->use_javascript_ajax)
{
if ($conf->use_javascript_ajax) {
print '<tr><td class="center" colspan="2">';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@ -170,32 +178,34 @@ if ($resql)
/*
* 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 .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as c";
$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 .= " AND c.entity = ".$conf->entity;
$sql .= " AND c.fk_statut = 0";
if ($socid) $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;
if ($socid) {
$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);
if ($resql)
{
if ($resql) {
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="2">'.$langs->trans("DraftRequests").'</th></tr>';
$langs->load("supplier_proposal");
$num = $db->num_rows($resql);
if ($num)
{
if ($num) {
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
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 .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as c";
$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 .= " AND c.entity = ".$conf->entity;
//$sql.= " AND c.fk_statut > 2";
if ($socid) $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;
if ($socid) {
$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 .= $db->plimit($max, 0);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="4">'.$langs->trans("LastModifiedRequests", $max).'</th></tr>';
$num = $db->num_rows($resql);
if ($num)
{
if ($num) {
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
@ -292,14 +305,15 @@ if ($resql)
}
}
print "</table></div><br>";
} else dol_print_error($db);
} else {
dol_print_error($db);
}
/*
* 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");
$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 .= " FROM ".MAIN_DB_PREFIX."societe as s";
$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 .= " AND p.entity IN (".getEntity('supplier_proposal').")";
$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 ($socid) $sql .= " AND s.rowid = ".$socid;
if (!$user->rights->societe->client->voir && !$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";
$result = $db->query($sql);
if ($result)
{
if ($result) {
$total = 0;
$num = $db->num_rows($result);
$i = 0;
if ($num > 0)
{
if ($num > 0) {
print '<div class="div-table-responsive-no-min">';
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>';
$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);
print '<tr class="oddeven">';
@ -345,7 +362,9 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
print $supplier_proposalstatic->getNomUrl(1);
print '</td>';
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 width="16" class="center nobordernopadding">';
$filename = dol_sanitizeFileName($obj->ref);
@ -370,11 +389,9 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
$i++;
$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>";
} 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 "</table></div><br>";

View File

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

View File

@ -18,8 +18,7 @@
*/
// 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";
exit;
}
@ -35,41 +34,41 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$total = 0;
$ilink = 0;
foreach ($linkedObjectBlock as $key => $objectlink)
{
foreach ($linkedObjectBlock as $key => $objectlink) {
$ilink++;
$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; ?>">
<td><?php echo $langs->trans("SupplierProposal"); ?></td>
<td><a href="<?php echo DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$objectlink->id ?>"><?php echo img_object($langs->trans("ShowSupplierProposal"), "supplier_proposal").' '.$objectlink->ref; ?></a></td>
<td></td>
<td class="center"><?php echo dol_print_date($objectlink->datec, 'day'); ?></td>
<td class="right"><?php
<tr class="<?php echo $trclass; ?>">
<td><?php echo $langs->trans("SupplierProposal"); ?></td>
<td><a href="<?php echo DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$objectlink->id ?>"><?php echo img_object($langs->trans("ShowSupplierProposal"), "supplier_proposal").' '.$objectlink->ref; ?></a></td>
<td></td>
<td class="center"><?php echo dol_print_date($objectlink->datec, 'day'); ?></td>
<td class="right"><?php
if ($user->rights->supplier_proposal->lire) {
$total = $total + $objectlink->total_ht;
echo price($objectlink->total_ht);
} ?></td>
<td class="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td class="right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr>
<?php
<td class="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td class="right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr>
<?php
}
if (count($linkedObjectBlock) > 1)
{
if (count($linkedObjectBlock) > 1) {
?>
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>">
<td><?php echo $langs->trans("Total"); ?></td>
<td></td>
<td class="center"></td>
<td class="center"></td>
<td class="right"><?php echo price($total); ?></td>
<td class="right"></td>
<td class="right"></td>
</tr>
<?php
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>">
<td><?php echo $langs->trans("Total"); ?></td>
<td></td>
<td class="center"></td>
<td class="center"></td>
<td class="right"><?php echo price($total); ?></td>
<td class="right"></td>
<td class="right"></td>
</tr>
<?php
}
print "<!-- END PHP TEMPLATE -->\n";

View File

@ -25,7 +25,9 @@
*/
// 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/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
// 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"];
}
@ -58,27 +59,28 @@ $conffiletoshowshort = "conf.php";
$conffile = "../conf/conf.php";
$conffiletoshow = "htdocs/conf/conf.php";
// For debian/redhat like systems
if (!file_exists($conffile))
{
if (!file_exists($conffile)) {
$conffile = "/etc/dolibarr/conf.php";
$conffiletoshow = "/etc/dolibarr/conf.php";
}
// 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
if ($result)
{
if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type = 'mysql'; // For backward compatibility
if ($result) {
if (empty($dolibarr_main_db_type)) {
$dolibarr_main_db_type = 'mysql'; // For backward compatibility
}
//Mysql driver support has been removed in favor of mysqli
if ($dolibarr_main_db_type == 'mysql') {
$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
$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) : '';
// 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_url_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root)) $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);
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_url_root) && !preg_match('/^[\\/]+$/', $dolibarr_main_url_root)) {
$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
if (!empty($dolibarr_main_document_root))
{
if (!empty($dolibarr_main_document_root)) {
$result = conf($dolibarr_main_document_root);
}
// Load database driver
if ($result)
{
if (!empty($dolibarr_main_document_root) && !empty($dolibarr_main_db_type))
{
if ($result) {
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';
if (!$result)
{
if (!$result) {
$includeconferror = 'ErrorBadValueForDolibarrMainDBType';
}
}
@ -120,7 +128,9 @@ if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) >
$conf->global->MAIN_LOGTOHTML = 1;
// 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('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
$uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
$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', ...)
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);
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;
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;
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;
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;
if (empty($conf->db->user)) $conf->db->user = '';
if (empty($conf->db->user)) {
$conf->db->user = '';
}
// Defini objet langs
$langs = new Translate('..', $conf);
if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09'));
else $langs->setDefaultLang('auto');
if (GETPOST('lang', 'aZ09')) {
$langs->setDefaultLang(GETPOST('lang', 'aZ09'));
} else {
$langs->setDefaultLang('auto');
}
$bc[false] = ' class="bg1"';
$bc[true] = ' class="bg2"';
@ -172,7 +199,9 @@ function conf($dolibarr_main_document_root)
global $character_set_client;
$return = include_once $dolibarr_main_document_root.'/core/class/conf.class.php';
if (!$return) return -1;
if (!$return) {
return -1;
}
$conf = new Conf();
$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->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;
}

View File

@ -31,9 +31,12 @@
include_once 'inc.php';
$uri = preg_replace('/^http(s?):\/\//i', '', $dolibarr_main_url_root);
$pos = strstr($uri, '/'); // $pos contient alors url sans nom domaine
if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a ''
if (!defined('DOL_URL_ROOT'))
if ($pos == '/') {
$pos = ''; // si $pos vaut /, on le met a ''
}
if (!defined('DOL_URL_ROOT')) {
define('DOL_URL_ROOT', $pos); // URL racine relative
}
$langs->loadLangs(array("other", $langs->load("help")));
@ -49,10 +52,18 @@ print $langs->trans("HelpCenterDesc2")."<br>\n";
print '<br>';
$homeurl = DOL_URL_ROOT.'/';
if (GETPOST('dol_hide_toptmenu')) $homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_hide_toptmenu=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';
if (GETPOST('dol_hide_toptmenu')) {
$homeurl .= (strpos($homeurl, '?') === false ? '?' : '&').'dol_hide_toptmenu=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 '<br><br>';
@ -86,20 +97,38 @@ print '<td align="center" valign="middle">';
print '<table class="nocellnopadd">';
print '<tr><td align="center">';
$urlwiki = 'https://wiki.dolibarr.org';
if (preg_match('/fr/i', $langs->defaultlang)) $urlwiki = 'https://wiki.dolibarr.org/index.php/Accueil';
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';
if (preg_match('/fr/i', $langs->defaultlang)) {
$urlwiki = 'https://wiki.dolibarr.org/index.php/Accueil';
}
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>';
$urlforum = '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('/es/i', $langs->defaultlang)) $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/';
if (preg_match('/fr/i', $langs->defaultlang)) {
$urlforumlocal = 'https://www.dolibarr.fr/forum/';
}
if (preg_match('/es/i', $langs->defaultlang)) {
$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>';
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>';
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";
// Security check
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$langs->loadLangs(array("admin", "cashdesk", "commercial"));
@ -38,8 +40,7 @@ $langs->loadLangs(array("admin", "cashdesk", "commercial"));
* Actions
*/
if (GETPOST('action', 'alpha') == 'set')
{
if (GETPOST('action', 'alpha') == 'set') {
$db->begin();
$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'));
if (!($res > 0)) $error++;
if (!($res > 0)) {
$error++;
}
if (!$error)
{
if (!$error) {
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
$db->rollback();
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);
}

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";
// Security check
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$langs->loadLangs(array("admin", "cashdesk", "printing"));
@ -41,22 +43,22 @@ $res = 0;
* Actions
*/
if (GETPOST('action', 'alpha') == 'set')
{
if (GETPOST('action', 'alpha') == 'set') {
$db->begin();
dol_syslog("admin/bar");
$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);
if ($res <= 0) {
$error++;
}
if (!$error)
{
if (!$error) {
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
@ -153,8 +155,7 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) {
print ajax_constantonoff("TAKEPOS_SUPPLEMENTS", array(), $conf->entity, 0, 0, 1, 0);
print '</td></tr>';
if ($conf->global->TAKEPOS_SUPPLEMENTS)
{
if ($conf->global->TAKEPOS_SUPPLEMENTS) {
print '<tr class="oddeven"><td>';
print $langs->trans("SupplementCategory");
print '</td>';
@ -187,8 +188,7 @@ 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));
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
print '<br>';
@ -205,8 +205,7 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) {
print '</table>';
}
if ($conf->global->TAKEPOS_AUTO_ORDER)
{
if ($conf->global->TAKEPOS_AUTO_ORDER) {
print '<br>';
print '<table class="noborder centpercent">';
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");
if (!$user->rights->categorie->lire) accessforbidden();
if (!$user->rights->categorie->lire) {
accessforbidden();
}
$id = GETPOST('id', 'int');
$type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT);
@ -44,31 +46,39 @@ $printer1 = GETPOST('printer1', 'alpha');
$printer2 = GETPOST('printer2', '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
*/
if ($action == "SavePrinter1") {
$printedcategories = ";";
if (is_array($printer1)) foreach ($printer1 as $cat) {
$printedcategories = $printedcategories.$cat.";";
if (is_array($printer1)) {
foreach ($printer1 as $cat) {
$printedcategories = $printedcategories.$cat.";";
}
}
dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_1", $printedcategories, 'chaine', 0, '', $conf->entity);
}
if ($action == "SavePrinter2") {
$printedcategories = ";";
if (is_array($printer2)) foreach ($printer2 as $cat) {
$printedcategories = $printedcategories.$cat.";";
if (is_array($printer2)) {
foreach ($printer2 as $cat) {
$printedcategories = $printedcategories.$cat.";";
}
}
dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_2", $printedcategories, 'chaine', 0, '', $conf->entity);
}
if ($action == "SavePrinter3") {
$printedcategories = ";";
if (is_array($printer3)) foreach ($printer3 as $cat) {
$printedcategories = $printedcategories.$cat.";";
if (is_array($printer3)) {
foreach ($printer3 as $cat) {
$printedcategories = $printedcategories.$cat.";";
}
}
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)
$data = array();
$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->ref = $val['label'];
$categstatic->color = $val['color'];
@ -168,13 +177,18 @@ print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 1</td><td></td><
print '</td></tr>';
$nbofentries = (count($data) - 1);
print '<form action="orderprinters.php">';
if ($nbofentries > 0)
{
if ($nbofentries > 0) {
print '<tr class="pair"><td colspan="3">';
print '<input type="hidden" name="action" value="SavePrinter1">';
foreach ($data as $row) {
if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_1, ';'.$row["rowid"].';') !== false) $checked = 'checked'; else $checked = '';
if ($row["fk_menu"] == 0) print '<input type="checkbox" name="printer1[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_1, ';'.$row["rowid"].';') !== false) {
$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>';
} else {
@ -196,13 +210,18 @@ print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 2</td><td></td><
print '</td></tr>';
$nbofentries = (count($data) - 1);
print '<form action="orderprinters.php">';
if ($nbofentries > 0)
{
if ($nbofentries > 0) {
print '<tr class="pair"><td colspan="3">';
print '<input type="hidden" name="action" value="SavePrinter2">';
foreach ($data as $row) {
if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_2, ';'.$row["rowid"].';') !== false) $checked = 'checked'; else $checked = '';
if ($row["fk_menu"] == 0) print '<input type="checkbox" name="printer2[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_2, ';'.$row["rowid"].';') !== false) {
$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>';
} else {
@ -224,13 +243,18 @@ print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 3</td><td></td><
print '</td></tr>';
$nbofentries = (count($data) - 1);
print '<form action="orderprinters.php">';
if ($nbofentries > 0)
{
if ($nbofentries > 0) {
print '<tr class="pair"><td colspan="3">';
print '<input type="hidden" name="action" value="SavePrinter3">';
foreach ($data as $row) {
if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_3, ';'.$row["rowid"].';') !== false) $checked = 'checked'; else $checked = '';
if ($row["fk_menu"] == 0) print '<input type="checkbox" name="printer3[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_3, ';'.$row["rowid"].';') !== false) {
$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>';
} else {

View File

@ -36,7 +36,9 @@ if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) {
}
// Security check
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$langs->loadLangs(array("admin", "cashdesk"));
@ -61,7 +63,9 @@ if ($resql) {
if (GETPOST('action', 'alpha') == 'set') {
$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, "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'));
if (!($res > 0)) $error++;
if (!($res > 0)) {
$error++;
}
if (!$error) {
$db->commit();

View File

@ -24,7 +24,9 @@
require '../../main.inc.php';
// Security check
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$langs->load("cashdesk");
@ -37,8 +39,7 @@ print '<center>';
if (GETPOSTISSET("id")) {
print '<h1><b>'.$langs->trans("ScanToOrder").'</b></h1>';
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 "<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";
// Security check
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$langs->loadLangs(array("admin", "cashdesk", "commercial"));
@ -39,8 +41,7 @@ $langs->loadLangs(array("admin", "cashdesk", "commercial"));
* Actions
*/
if (GETPOST('action', 'alpha') == 'set')
{
if (GETPOST('action', 'alpha') == 'set') {
$db->begin();
$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'));
if (!($res > 0)) $error++;
if (!($res > 0)) {
$error++;
}
if (!$error)
{
if (!$error) {
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
$db->rollback();
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);
// 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 $langs->trans('BrowserMethodDescription');
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');
} else {
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 $langs->trans('TakeposConnectorMethodDescription');
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');
} else {
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['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>';
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Header"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
print '</td><td>';
$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>';
} else {
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 '</td><td>';
$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>';
} else {
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';
// 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');
$_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha');
$_REQUEST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha');
}
// Security check
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$langs->loadLangs(array("admin", "cashdesk"));
@ -67,10 +68,11 @@ $action = GETPOST('action', 'aZ09');
$error = 0;
if ($action == 'set')
{
if ($action == 'set') {
$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_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'));
if (!($res > 0)) $error++;
if (!($res > 0)) {
$error++;
}
if (!$error)
{
if (!$error) {
$db->commit();
} else {
$db->rollback();
@ -97,7 +100,9 @@ if ($action == 'set')
} elseif ($action == 'updateMask') {
$maskconst = GETPOST('maskconst', '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)) {
$error++;
}
@ -146,21 +151,16 @@ print '</tr>'."\n";
clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/takepos/");
if (is_dir($dir))
{
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle))
{
if (is_resource($handle)) {
$var = true;
while (($file = readdir($handle)) !== false)
{
if (substr($file, 0, 16) == 'mod_takepos_ref_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
while (($file = readdir($handle)) !== false) {
if (substr($file, 0, 16) == 'mod_takepos_ref_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
$file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php';
@ -168,11 +168,14 @@ foreach ($dirmodels as $reldir)
$module = new $file;
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
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 $module->info();
print '</td>';
@ -183,13 +186,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
} elseif ($tmp == 'NotConfigured') {
print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n";
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');
} else {
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
$htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip .= $langs->trans($module->error).'<br>';
@ -256,8 +262,7 @@ print $form->selectarray('TAKEPOS_NUM_TERMINALS', $array, (empty($conf->global->
print "</td></tr>\n";
// Services
if (!empty($conf->service->enabled))
{
if (!empty($conf->service->enabled)) {
print '<tr class="oddeven"><td>';
print $langs->trans("CashdeskShowServices");
print '<td colspan="2">';
@ -292,7 +297,9 @@ print "</td></tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>';
// Payment numpad

View File

@ -31,15 +31,16 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
$terminal = GETPOST('terminal', 'int');
// 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');
$_POST['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
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$langs->loadLangs(array("admin", "cashdesk", "printing", "receiptprinter"));
@ -64,10 +65,11 @@ $terminaltouse = $terminal;
* Actions
*/
if (GETPOST('action', 'alpha') == 'set')
{
if (GETPOST('action', 'alpha') == 'set') {
$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);
@ -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);
}
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;
$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'));
if (!($res > 0)) $error++;
if (!($res > 0)) {
$error++;
}
if (!$error)
{
if (!$error) {
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
@ -147,45 +152,55 @@ print $form->select_company($conf->global->{'CASHDESK_ID_THIRDPARTY'.$terminalto
print '</td></tr>';
$atleastonefound = 0;
if (!empty($conf->banque->enabled))
{
if (!empty($conf->banque->enabled)) {
print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
print '<td>';
$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 '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
print '<td>';
$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 '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
print '<td>';
$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>';
if ($conf->global->TAKEPOS_ENABLE_SUMUP) {
print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSumup").'</td>';
print '<td>';
$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>';
}
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;
print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->label).'</td>';
print '<td>';
if (!empty($conf->global->$name)) $atleastonefound++;
if (!empty($conf->global->$name)) {
$atleastonefound++;
}
$cour = preg_match('/^LIQ.*/', $modep->code) ? 2 : 1;
$form->select_comptes($conf->global->$name, $name, 0, "courant=".$cour, 1);
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 '<td>';
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 '<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 ' <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 {
@ -279,44 +293,42 @@ if ($conf->global->TAKEPOS_ADDON == "terminal") {
print '<td colspan="2">';
$array = array(0=>$langs->trans("Default"));
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/facture/");
if (is_dir($dir))
{
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle)) !== false)
{
if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
{
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) {
$filebis = $file;
$classname = preg_replace('/\.php$/', '', $file);
// For compatibility
if (!is_file($dir.$filebis))
{
if (!is_file($dir.$filebis)) {
$filebis = $file."/".$file.".modules.php";
$classname = "mod_facture_".$file;
}
// Check if there is a filter on country
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);
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
require_once $dir.$filebis;
$module = new $classname($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
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)));
}
}
@ -339,7 +351,9 @@ print '</div>';
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans('Translation');
$htmltext = '<i>'.$langs->trans('AvailableVariables').':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>';
print '<br>';
@ -386,8 +400,7 @@ print '</td></tr>';
print '</table>';
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');
}

View File

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

View File

@ -27,14 +27,26 @@
//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('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('NOCSRFCHECK')) define('NOCSRFCHECK', 1);
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1);
if (!defined('NOLOGIN')) define('NOLOGIN', 1); // File must be accessed by logon page so without login
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', 1);
}
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('NOREQUIREHTML')) define('NOREQUIREHTML', 1);
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', 1);
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
define('ISLOADEDBYSTEELSHEET', '1');
@ -48,25 +60,30 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Define css type
top_httphead('text/css');
// 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');
else header('Cache-Control: no-cache');
if (empty($dolibarr_nocache)) {
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';
if (defined('THEME_ONLY_CONSTANT')) return;
if (defined('THEME_ONLY_CONSTANT')) {
return;
}
?>
html,body {
box-sizing: border-box;
box-sizing: border-box;
padding:0px;
margin:0;
height:100%;
margin:0;
height:100%;
width:100%;
}
.bodytakepos {
background-color: #EEE;
background-color: #EEE;
}
.center {
@ -74,14 +91,14 @@ html,body {
}
button.calcbutton.poscolorblue {
background-color: #0066AA;
background-color: #0066AA;
}
button.calcbutton2.poscolordelete {
background: rgb(255, 188, 185);
color: #633;
/*background-color: #884444;
color: #fff;*/
color: #633;
/*background-color: #884444;
color: #fff;*/
}
button.calcbutton {
@ -96,19 +113,19 @@ button.calcbutton {
width: calc(25% - 2px);
height: calc(25% - 2px);
font-weight: bold;
background-color: #8c907e;
color: #fff;
/* border-color: unset; */
border-width: 0;
margin: 1px;
background-color: #8c907e;
color: #fff;
/* border-color: unset; */
border-width: 0;
margin: 1px;
font-size: 14pt;
border-radius: 3px;
border-radius: 3px;
}
button.calcbutton2 {
color: #fff;
background-color: #5555AA;
border-width: 0px;
color: #fff;
background-color: #5555AA;
border-width: 0px;
display: inline-block;
position: relative;
padding: 0;
@ -122,7 +139,7 @@ button.calcbutton2 {
font-weight: bold;
font-size: 10pt;
margin: 1px;
border-radius: 3px;
border-radius: 3px;
}
button.calcbutton2 .iconwithlabel {
@ -142,7 +159,7 @@ button.calcbutton3 {
height: calc(25% - 2px);
font-size: 14pt;
margin: 1px;
border-radius: 3px;
border-radius: 3px;
}
button.productbutton {
@ -157,20 +174,20 @@ button.productbutton {
width: calc(100% - 2px);
height: calc(100% - 2px);
font-weight: bold;
background-color: #a3a6a3;
color: #fff;
/* border-color: unset; */
border-width: 0;
margin: 1px;
background-color: #a3a6a3;
color: #fff;
/* border-color: unset; */
border-width: 0;
margin: 1px;
font-size: 14pt;
border-radius: 3px;
border-radius: 3px;
}
button.actionbutton {
background: #EABCA6;
border: 2px solid #EEE;
min-height: 40px;
border-radius: 3px;
background: #EABCA6;
border: 2px solid #EEE;
min-height: 40px;
border-radius: 3px;
}
button.actionbutton {
@ -185,7 +202,7 @@ button.actionbutton {
width: calc(33.33% - 2px);
height: calc(25% - 2px);
margin: 1px;
border-width: 0;
border-width: 0;
}
button.item_value {
@ -202,10 +219,10 @@ button.item_value.selected {
}
div[aria-describedby="dialog-info"] button:before {
content: "\f788";
font-family: "Font Awesome 5 Free";
font-weight: 900;
padding-right: 5px;
content: "\f788";
font-family: "Font Awesome 5 Free";
font-weight: 900;
padding-right: 5px;
}
div[aria-describedby="dialog-info"].ui-dialog .ui-dialog-buttonpane {
border-width: 0;
@ -216,7 +233,7 @@ div[aria-describedby="dialog-info"].ui-dialog .ui-dialog-buttonpane {
}
.fa.fa-trash:before {
font-size: 1.5em;
font-size: 1.5em;
}
@ -249,11 +266,11 @@ div.wrapper2{
}
img.imgwrapper {
max-width: 100%;
max-width: 100%;
}
button:active{
background:black;
background:black;
color: white;
}
@ -270,7 +287,7 @@ div.description{
text-align:center;
padding-top: 30px;
background: -webkit-linear-gradient(top, rgba(250,250,250,0), rgba(250,250,250,0.5), rgba(250,250,250,0.95), rgba(250,250,250,1));
background: -webkit-linear-gradient(top, rgba(250,250,250,0), rgba(250,250,250,0.5), rgba(250,250,250,0.95), rgba(250,250,250,1));
}
div.catwatermark{
@ -288,17 +305,17 @@ div.catwatermark{
table.postablelines tr td {
line-height: unset;
padding-top: 3px;
padding-bottom: 3px;
padding-top: 3px;
padding-bottom: 3px;
}
.posinvoiceline td {
height: 40px !important;
background-color: var(--colorbacklineimpair1);
height: 40px !important;
background-color: var(--colorbacklineimpair1);
}
.postablelines td.linecolht {
line-height: 1.3em !important;
line-height: 1.3em !important;
}
div.paymentbordline
@ -414,11 +431,11 @@ div.paymentbordline
}
tr.selected, tr.selected td {
/* font-weight: bold; */
/* font-weight: bold; */
background-color: rgb(240,230,210) !important;
}
.order {
color: limegreen;
color: limegreen;
}
.colorwhite {
@ -442,13 +459,13 @@ tr.selected, tr.selected td {
.centerinmiddle {
transform: translate(0,-50%);
position: relative;
top: 50%;
position: relative;
top: 50%;
}
.trunc {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
p.description_content{
@ -457,11 +474,11 @@ p.description_content{
}
div.description_content {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: <?php echo $conf->global->TAKEPOS_LINES_TO_SHOW; ?>;
overflow: hidden;
padding-left: 2px;
padding-right: 2px;
-webkit-box-orient: vertical;
-webkit-line-clamp: <?php echo $conf->global->TAKEPOS_LINES_TO_SHOW; ?>;
overflow: hidden;
padding-left: 2px;
padding-right: 2px;
}
.header{
@ -488,7 +505,7 @@ div.description_content {
height: 100%;
}
.topnav .tmenu {
display: block;
display: block;
}
.topnav a{
@ -498,8 +515,8 @@ div.description_content {
}
.topnav .login_block_other a {
padding: 5px 10px;
margin-left: 4px;
font-size: 1.3em;
margin-left: 4px;
font-size: 1.3em;
}
@media screen and (max-width: 767px) {
@ -515,8 +532,8 @@ div.description_content {
.topnav-left a {
padding: 7px 4px 7px 4px;
margin: 8px;
margin-left: 4px;
margin: 8px;
margin-left: 4px;
}
.topnav-left a:hover, .topnav .login_block_other a:hover {
background-color: #ddd;
@ -534,27 +551,27 @@ div.description_content {
border-bottom: none !important;
margin-left: 6px;
font-size: 1.3em;
max-width: 250px;
border-radius: 5px;
max-width: 250px;
border-radius: 5px;
}
div#moreinfo, div#infowarehouse {
color: #aaa;
padding: 0 8px 0 8px;
color: #aaa;
padding: 0 8px 0 8px;
}
.productprice {
position: absolute;
top: 5px;
right: 5px;
background: var(--colorbackhmenu1);
color: var(--colortextbackhmenu);
font-size: 2em;
padding: 5px;
border-radius: 2px;
opacity: 0.9;
padding-left: 8px;
padding-right: 8px;
position: absolute;
top: 5px;
right: 5px;
background: var(--colorbackhmenu1);
color: var(--colortextbackhmenu);
font-size: 2em;
padding: 5px;
border-radius: 2px;
opacity: 0.9;
padding-left: 8px;
padding-right: 8px;
}
@ -604,9 +621,9 @@ div#moreinfo, div#infowarehouse {
@media screen and (max-width: 767px) {
.header {
position: sticky;
top: 0;
z-index: 10;
position: sticky;
top: 0;
z-index: 10;
}
.topnav input[type="text"] {
@ -634,7 +651,7 @@ div#moreinfo, div#infowarehouse {
}
div#moreinfo, div#infowarehouse {
padding: 0 5px 0 5px;
padding: 0 5px 0 5px;
}
div.div1 {
@ -659,7 +676,7 @@ div#moreinfo, div#infowarehouse {
}
button.calcbutton, button.calcbutton2 {
min-height: 30px;
min-height: 30px;
}
.takepospay {

View File

@ -25,11 +25,21 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','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');
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_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"));
$floor = GETPOST('floor', 'int');
if ($floor == "") $floor = 1;
if ($floor == "") {
$floor = 1;
}
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'aZ09');
$left = GETPOST('left', 'alpha');
@ -57,38 +69,45 @@ if (empty($user->rights->takepos->run)) {
* 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;
$resql = $db->query($sql);
$rows = array();
while ($row = $db->fetch_array($resql)) {
$invoice = new Facture($db);
$result = $invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$row['rowid'].')');
if ($result > 0) $row['occupied'] = "red";
if ($result > 0) {
$row['occupied'] = "red";
}
$rows[] = $row;
}
echo json_encode($rows);
exit;
}
if ($action == "update")
{
if ($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."'");
else $db->query("DELETE from ".MAIN_DB_PREFIX."takepos_floor_tables where rowid='".$place."'");
if ($action == "update") {
if ($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."'");
} 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
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."'");
}
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.")";
$asdf = $db->query($sql);
$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 = '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);
?>
<link rel="stylesheet" href="css/pos.css.php?a=xxx">
@ -159,14 +180,14 @@ function LoadPlace(place){
$( document ).ready(function() {
$.getJSON('./floors.php?action=getTables&floor=<?php echo $floor; ?>', function(data) {
$.each(data, function(key, val) {
$.each(data, function(key, val) {
<?php if ($mode == "edit") {?>
$('body').append('<div class="tablediv" contenteditable onblur="updatename('+val.rowid+');" style="position: absolute; left: '+val.leftpos+'%; top: '+val.toppos+'%;" id="tablename'+val.rowid+'">'+val.label+'</div>');
$( "#tablename"+val.rowid ).draggable(
{
start: function() {
$("#add").html("<?php echo $langs->trans("Delete"); ?>");
},
},
stop: function() {
var left=$(this).offset().left*100/$(window).width();
var top=$(this).offset().top*100/$(window).height();
@ -190,25 +211,29 @@ $( document ).ready(function() {
<body style="overflow: hidden">
<?php if ($user->admin) {?>
<div style="position: absolute; left: 0.1%; top: 0.8%; width:8%; height:11%;">
<?php if ($mode == "edit") {?>
<?php if ($mode == "edit") {?>
<a id="add" onclick="window.location.href='floors.php?mode=edit&action=add&floor=<?php echo $floor; ?>';"><?php echo $langs->trans("AddTable"); ?></a>
<?php } else { ?>
<?php } else { ?>
<a onclick="window.location.href='floors.php?mode=edit&floor=<?php echo $floor; ?>';"><?php echo $langs->trans("Edit"); ?></a>
<?php } ?>
<?php } ?>
</div>
<?php }
?>
<div style="position: absolute; left: 25%; bottom: 8%; width:50%; height:3%;">
<center>
<h1>
<?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"; ?>';">
<?php } ?>
<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; ?>';">
</h1>
</center>
<center>
<h1>
<?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";
} ?>';">
<?php } ?>
<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; ?>';">
</h1>
</center>
</div>
</body>
</html>

View File

@ -26,11 +26,21 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','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');
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_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
@ -61,8 +71,11 @@ if ($place > 0) {
// get default vat rate
$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION['takeposterminal'];
$soc = new Societe($db);
if ($invoice->socid > 0) $soc->fetch($invoice->socid);
else $soc->fetch($conf->global->$constforcompanyid);
if ($invoice->socid > 0) {
$soc->fetch($invoice->socid);
} else {
$soc->fetch($conf->global->$constforcompanyid);
}
$vatRateDefault = get_default_tva($mysoc, $soc);
/*
@ -109,8 +122,12 @@ top_htmlhead($head, '', 0, 0, $arrayofjs, $arrayofcss);
<center>
<input type="text" id="desc" name="desc" class="takepospay" style="width:40%;" placeholder="<?php echo $langs->trans('Description'); ?>">
<?php
if ($action == "freezone") 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.'">';
if ($action == "freezone") {
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="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('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('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');
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');
}
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');
$w = GETPOST('w', 'int');
@ -38,8 +52,7 @@ $query = GETPOST('query', 'alpha');
* View
*/
if ($query == "cat")
{
if ($query == "cat") {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.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/";
$dir = $upload_dir.'/'.$pdir;
foreach ($object->liste_photos($dir) as $key => $obj)
{
if ($obj['photo_vignette'])
{
foreach ($object->liste_photos($dir) as $key => $obj) {
if ($obj['photo_vignette']) {
$filename = $obj['photo_vignette'];
} else {
$filename = $obj['photo'];
@ -63,8 +74,7 @@ if ($query == "cat")
exit;
}
header('Location: ../../public/theme/common/nophoto.png');
} elseif ($query == "pro")
{
} elseif ($query == "pro") {
require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
$objProd = new Product($db);

View File

@ -15,14 +15,30 @@
* 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('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
if (!defined('NOREQUIRESOC')) 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');
if (!defined("NOLOGIN")) {
define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
}
if (!defined('NOIPCHECK')) {
define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
if (!defined('NOREQUIRESOC')) {
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 '../../core/modules/barcode/doc/tcpdfbarcode.modules.php';
@ -34,8 +50,7 @@ if (GETPOSTISSET("key")) {
$key = GETPOST('key');
$module = new modTcpdfbarcode();
$result = $module->buildBarCode($urlwithroot."/takepos/public/auto_order.php?key=".$key, 'QRCODE', 'Y');
}
else {
} else {
$module = new modTcpdfbarcode();
$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('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','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');
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_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
@ -47,20 +57,20 @@ $action = GETPOST('action', 'aZ09');
$setterminal = GETPOST('setterminal', 'int');
$setcurrency = GETPOST('setcurrency', 'aZ09');
if ($_SESSION["takeposterminal"] == "")
{
if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") $_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
if ($_SESSION["takeposterminal"] == "") {
if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") {
$_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
}
}
if ($setterminal > 0)
{
if ($setterminal > 0) {
$_SESSION["takeposterminal"] = $setterminal;
setcookie("takeposterminal", $setterminal, (time() + (86400 * 354)), '/', null, false, true); // Permanent takeposterminal var in a cookie
}
if ($setcurrency != "")
{
if ($setcurrency != "") {
$_SESSION["takeposcustomercurrency"] = $setcurrency;
}
@ -72,13 +82,11 @@ $categorie = new Categorie($db);
$maxcategbydefaultforthisdevice = 12;
$maxproductbydefaultforthisdevice = 24;
if ($conf->browser->layout == 'phone')
{
if ($conf->browser->layout == 'phone') {
$maxcategbydefaultforthisdevice = 8;
$maxproductbydefaultforthisdevice = 16;
//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;
header("Location: phone.php?mobilepage=invoice");
exit;
@ -107,7 +115,9 @@ $form = new Form($db);
// Title
$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"/>
<meta name="apple-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/colorbox.css" type="text/css" media="screen" />
<?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 language="javascript">
@ -129,12 +141,9 @@ $categories = $categorie->get_full_arbo('product', (($conf->global->TAKEPOS_ROOT
// Search root category to know its level
//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
$levelofrootcategory = 0;
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)
{
foreach ($categories as $key => $categorycursor)
{
if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID)
{
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
foreach ($categories as $key => $categorycursor) {
if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID) {
$levelofrootcategory = $categorycursor['level'];
break;
}
@ -145,10 +154,8 @@ $levelofmaincategories = $levelofrootcategory + 1;
$maincategories = array();
$subcategories = array();
foreach ($categories as $key => $categorycursor)
{
if ($categorycursor['level'] == $levelofmaincategories)
{
foreach ($categories as $key => $categorycursor) {
if ($categorycursor['level'] == $levelofmaincategories) {
$maincategories[$key] = $categorycursor;
} else {
$subcategories[$key] = $categorycursor;
@ -175,16 +182,16 @@ var invoiceid=0;
var app = this;
app.hasKeyboard = false;
this.keyboardPress = function() {
app.hasKeyboard = true;
$(window).unbind("keyup", app.keyboardPress);
localStorage.hasKeyboard = true;
console.log("has keyboard!")
app.hasKeyboard = true;
$(window).unbind("keyup", app.keyboardPress);
localStorage.hasKeyboard = true;
console.log("has keyboard!")
}
$(window).on("keyup", app.keyboardPress)
if(localStorage.hasKeyboard) {
app.hasKeyboard = true;
$(window).unbind("keyup", app.keyboardPress);
console.log("has keyboard from localStorage")
app.hasKeyboard = true;
$(window).unbind("keyup", app.keyboardPress);
console.log("has keyboard from localStorage")
}
*/
@ -219,8 +226,8 @@ function PrintCategories(first) {
}
$("#catdivdesc"+i).show();
$("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']);
$("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']);
$("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']);
$("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']);
$("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']);
$("#catdiv"+i).attr('class', 'wrapper');
$("#catwatermark"+i).show();
}
@ -253,8 +260,8 @@ function MoreCategories(moreorless) {
}
$("#catdivdesc"+i).show();
$("#catdesc"+i).text(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['label']);
$("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
$("#catdiv"+i).data("rowid",categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
$("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
$("#catdiv"+i).data("rowid",categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
$("#catwatermark"+i).show();
}
@ -274,7 +281,7 @@ function LoadProducts(position, issubcat) {
if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid');
else currentcat=$('#catdiv'+position).data('rowid');
}
if (currentcat == undefined) return;
if (currentcat == undefined) return;
pageproducts=0;
ishow=0; //product to show counter
@ -300,8 +307,7 @@ function LoadProducts(position, issubcat) {
//console.log("ishow"+ishow+" idata="+idata);
console.log(data[idata]);
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 '$("#prodesc"+ishow).text("");';
echo '$("#proimg"+ishow).attr("title","");';
@ -323,14 +329,12 @@ function LoadProducts(position, issubcat) {
$titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[idata]['barcode']";
?>
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 '$("#prodesc"+ishow).text(data[parseInt(idata)][\'label\']);';
echo '$("#proimg"+ishow).attr("title", titlestring);';
echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);';
}
else {
} else {
echo '$("#probutton"+ishow).show();';
echo '$("#probutton"+ishow).text(data[parseInt(idata)][\'label\']);';
}
@ -411,7 +415,7 @@ function MoreProducts(moreorless) {
function ClickProduct(position) {
console.log("ClickProduct");
$('#proimg'+position).animate({opacity: '0.5'}, 1);
$('#proimg'+position).animate({opacity: '0.5'}, 1);
$('#proimg'+position).animate({opacity: '1'}, 100);
if ($('#prodiv'+position).data('iscat')==1){
console.log("Click on a category at position "+position);
@ -454,8 +458,8 @@ function Customer() {
function History()
{
console.log("Open box to select the history");
$.colorbox({href:"../compta/facture/list.php?contextpage=poslist", width:"90%", height:"80%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("History"); ?>"});
console.log("Open box to select the history");
$.colorbox({href:"../compta/facture/list.php?contextpage=poslist", width:"90%", height:"80%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("History"); ?>"});
}
function Reduction() {
@ -593,83 +597,83 @@ function Edit(number) {
if (typeof(selectedtext) == "undefined") return; // We click on an action on the number pad but there is no line selected
var text=selectedtext+"<br> ";
var text=selectedtext+"<br> ";
if (number=='c'){
editnumber="";
Refresh();
return;
}
else if (number=='qty'){
console.log("Edit "+number);
if (editaction=='qty' && editnumber!=""){
$("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
editnumber="";
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#qty").html("<?php echo $langs->trans("Qty"); ?>");
});
if (number=='c'){
editnumber="";
Refresh();
return;
}
else if (number=='qty'){
console.log("Edit "+number);
if (editaction=='qty' && editnumber!=""){
$("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
editnumber="";
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#qty").html("<?php echo $langs->trans("Qty"); ?>");
});
setFocusOnSearchField();
return;
}
else {
editaction="qty";
}
}
else if (number=='p'){
console.log("Edit "+number);
if (editaction=='p' && editnumber!=""){
$("#poslines").load("invoice.php?action=updateprice&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
editnumber="";
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#price").html("<?php echo $langs->trans("Price"); ?>");
});
setFocusOnSearchField();
return;
}
else {
editaction="qty";
}
}
else if (number=='p'){
console.log("Edit "+number);
if (editaction=='p' && editnumber!=""){
$("#poslines").load("invoice.php?action=updateprice&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
editnumber="";
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#price").html("<?php echo $langs->trans("Price"); ?>");
});
ClearSearch();
return;
}
else {
editaction="p";
}
}
else if (number=='r'){
console.log("Edit "+number);
if (editaction=='r' && editnumber!=""){
$("#poslines").load("invoice.php?action=updatereduction&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
editnumber="";
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>");
});
ClearSearch();
return;
}
else {
editaction="p";
}
}
else if (number=='r'){
console.log("Edit "+number);
if (editaction=='r' && editnumber!=""){
$("#poslines").load("invoice.php?action=updatereduction&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
editnumber="";
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>");
});
ClearSearch();
return;
}
else {
editaction="r";
}
}
else {
editnumber=editnumber+number;
}
if (editaction=='qty'){
text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Qty").": "; ?>";
$("#qty").html("OK");
$("#price").html("<?php echo $langs->trans("Price"); ?>");
$("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>");
}
if (editaction=='p'){
text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Price").": "; ?>";
$("#qty").html("<?php echo $langs->trans("Qty"); ?>");
$("#price").html("OK");
$("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>");
}
if (editaction=='r'){
text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("ReductionShort").": "; ?>";
$("#qty").html("<?php echo $langs->trans("Qty"); ?>");
$("#price").html("<?php echo $langs->trans("Price"); ?>");
$("#reduction").html("OK");
}
$('#'+selectedline).find("td:first").html(text+editnumber);
ClearSearch();
return;
}
else {
editaction="r";
}
}
else {
editnumber=editnumber+number;
}
if (editaction=='qty'){
text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Qty").": "; ?>";
$("#qty").html("OK");
$("#price").html("<?php echo $langs->trans("Price"); ?>");
$("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>");
}
if (editaction=='p'){
text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Price").": "; ?>";
$("#qty").html("<?php echo $langs->trans("Qty"); ?>");
$("#price").html("OK");
$("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>");
}
if (editaction=='r'){
text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("ReductionShort").": "; ?>";
$("#qty").html("<?php echo $langs->trans("Qty"); ?>");
$("#price").html("<?php echo $langs->trans("Price"); ?>");
$("#reduction").html("OK");
}
$('#'+selectedline).find("td:first").html(text+editnumber);
}
function TakeposPrintingOrder(){
@ -691,8 +695,11 @@ function OpenDrawer(){
$.ajax({
type: "POST",
<?php
if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) echo "url: '".$conf->global->TAKEPOS_PRINT_SERVER."/printer/drawer.php',";
else echo "url: 'http://".$conf->global->TAKEPOS_PRINT_SERVER.":8111/print',";
if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) {
echo "url: '".$conf->global->TAKEPOS_PRINT_SERVER."/printer/drawer.php',";
} else {
echo "url: 'http://".$conf->global->TAKEPOS_PRINT_SERVER.":8111/print',";
}
?>
data: "opendrawer"
});
@ -725,23 +732,23 @@ function MoreActions(totalactions){
function ControlCashOpening()
{
$.colorbox({href:"../compta/cashcontrol/cashcontrol_card.php?action=create&contextpage=takepos", width:"90%", height:"60%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("NewCashFence"); ?>"});
$.colorbox({href:"../compta/cashcontrol/cashcontrol_card.php?action=create&contextpage=takepos", width:"90%", height:"60%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("NewCashFence"); ?>"});
}
function CloseCashFence(rowid)
{
$.colorbox({href:"../compta/cashcontrol/cashcontrol_card.php?id="+rowid+"&contextpage=takepos", width:"90%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("NewCashFence"); ?>"});
$.colorbox({href:"../compta/cashcontrol/cashcontrol_card.php?id="+rowid+"&contextpage=takepos", width:"90%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("NewCashFence"); ?>"});
}
function CashReport(rowid)
{
$.colorbox({href:"../compta/cashcontrol/report.php?id="+rowid+"&contextpage=takepos", width:"60%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("CashReport"); ?>"});
$.colorbox({href:"../compta/cashcontrol/report.php?id="+rowid+"&contextpage=takepos", width:"60%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("CashReport"); ?>"});
}
// TakePOS Popup
function ModalBox(ModalID)
{
var modal = document.getElementById(ModalID);
var modal = document.getElementById(ModalID);
modal.style.display = "block";
}
@ -757,36 +764,37 @@ function FullScreen() {
function WeighingScale(){
console.log("Weighing Scale");
$.ajax({
type: "POST",
url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/scale/index.php',
})
$.ajax({
type: "POST",
url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/scale/index.php',
})
.done(function( editnumber ) {
$("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
editnumber="";
});
editnumber="";
});
});
}
$( document ).ready(function() {
PrintCategories(0);
PrintCategories(0);
LoadProducts(0);
Refresh();
<?php
//IF NO TERMINAL SELECTED
if ($_SESSION["takeposterminal"] == "")
{
if ($_SESSION["takeposterminal"] == "") {
print "ModalBox('ModalTerminal');";
}
if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) {
$sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE";
$sql .= " entity = ".$conf->entity." AND ";
$sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'";
$sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE";
$sql .= " entity = ".$conf->entity." AND ";
$sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'";
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
// 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"); ?>
</span>
<?php echo " ";
if ($_SESSION["takeposterminal"] == "") echo "1";
else echo $_SESSION["takeposterminal"];
if ($_SESSION["takeposterminal"] == "") {
echo "1";
} else {
echo $_SESSION["takeposterminal"];
}
echo '<span class="hideonsmartphone"> - '.dol_print_date(dol_now(), "day").'</span>';
?>
</a>
@ -863,8 +874,7 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
<div class="modal-body">
<button type="button" class="block" onclick="location.href='index.php?setterminal=1'"><?php print $langs->trans("Terminal"); ?> 1</button>
<?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>';
}
?>
@ -885,10 +895,10 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
$sql .= " WHERE entity IN ('".getEntity('multicurrency')."')";
$resql = $db->query($sql);
if ($resql)
{
while ($obj = $db->fetch_object($resql))
print '<button type="button" class="block" onclick="location.href=\'index.php?setcurrency='.$obj->code.'\'">'.$obj->code.'</button>';
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
print '<button type="button" class="block" onclick="location.href=\'index.php?setcurrency='.$obj->code.'\'">'.$obj->code.'</button>';
}
}
?>
</div>
@ -910,7 +920,9 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
</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>
@ -947,12 +959,18 @@ $paiementsModes = array();
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
$paycode = $obj->code;
if ($paycode == 'LIQ') $paycode = 'CASH';
if ($paycode == 'CHQ') $paycode = 'CHEQUE';
if ($paycode == 'LIQ') {
$paycode = 'CASH';
}
if ($paycode == 'CHQ') {
$paycode = 'CHEQUE';
}
$constantforkey = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"];
//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();
$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();');
} else {
// BAR RESTAURANT specific menu
@ -995,30 +1012,28 @@ if ($conf->global->TAKEPOS_DIRECT_PAYMENT) {
}
// BAR RESTAURANT specific menu
if ($conf->global->TAKEPOS_BAR_RESTAURANT)
{
if ($conf->global->TAKEPOS_ORDER_PRINTERS)
{
if ($conf->global->TAKEPOS_BAR_RESTAURANT) {
if ($conf->global->TAKEPOS_ORDER_PRINTERS) {
$menus[$r++] = array('title'=>$langs->trans("Order"), 'action'=>'TakeposPrintingOrder();');
}
//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 (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);');
else $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposPrinting(placeid);');
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);');
} 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") {
$menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);');
} else {
$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();');
}
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\');');
}
}
@ -1037,14 +1052,14 @@ $sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE
$sql .= " entity = ".$conf->entity." AND ";
$sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
if ($num)
{
if ($num) {
$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.');');
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)) {
$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();');
}
@ -1076,15 +1092,16 @@ if ($conf->global->TAKEPOS_WEIGHING_SCALE)
<div class="div3">
<?php
$i = 0;
foreach ($menus as $menu)
{
foreach ($menus as $menu) {
$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="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>';
else echo '<button style="'.$menu['style'].'" 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>';
} 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)) {
@ -1098,16 +1115,23 @@ if ($conf->global->TAKEPOS_WEIGHING_SCALE)
</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 -->
<div class="div4">
<?php
$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
if ($count == ($MAXCATEG - 2)) {
//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 '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em;"></span>';
} 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)) { ?>
@ -1126,21 +1152,26 @@ if ($conf->global->TAKEPOS_WEIGHING_SCALE)
<?php } ?>
<div class="catwatermark" id='catwatermark<?php echo $count; ?>'>...</div>
</div>
<?php
<?php
$count++;
}
?>
</div>
<!-- Show product -->
<!-- Show product -->
<div class="div5">
<?php
<?php
$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.');"'; ?>>
<?php
<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
if ($count == ($MAXPRODUCT - 2)) {
//echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="proimg'.$count.'" />';
print '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em;"></span>';
@ -1148,21 +1179,22 @@ if ($conf->global->TAKEPOS_WEIGHING_SCALE)
//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>';
} else {
if ($conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) echo '<button type="button" id="probutton'.$count.'" class="productbutton" style="display: none;"></button>';
else {
if ($conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) {
echo '<button type="button" id="probutton'.$count.'" class="productbutton" style="display: none;"></button>';
} else {
print '<div class="" id="proprice'.$count.'"></div>';
print '<img class="imgwrapper" height="100%" title="" id="proimg'.$count.'">';
}
}
?>
<?php if ($count != ($MAXPRODUCT - 2) && $count != ($MAXPRODUCT - 1) && !$conf->global->TAKEPOS_HIDE_PRODUCT_IMAGES) { ?>
<div class="description" id="prodivdesc<?php echo $count; ?>">
<div class="description_content" id="prodesc<?php echo $count; ?>"></div>
</div>
<?php } ?>
<div class="catwatermark" id='prowatermark<?php echo $count; ?>'>...</div>
</div>
<?php
<div class="description" id="prodivdesc<?php echo $count; ?>">
<div class="description_content" id="prodesc<?php echo $count; ?>"></div>
</div>
<?php } ?>
<div class="catwatermark" id='prowatermark<?php echo $count; ?>'>...</div>
</div>
<?php
$count++;
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -25,11 +25,21 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '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');
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_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@ -50,19 +60,16 @@ if (empty($user->rights->takepos->run)) {
*/
$invoice = new Facture($db);
if ($invoiceid > 0)
{
if ($invoiceid > 0) {
$invoice->fetch($invoiceid);
} else {
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
if ($obj)
{
if ($obj) {
$invoiceid = $obj->rowid;
}
if (!$invoiceid)
{
if (!$invoiceid) {
$invoiceid = 0; // Invoice does not exist yet
} else {
$invoice->fetch($invoiceid);
@ -92,9 +99,15 @@ $resql = $db->query($sql);
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
$paycode = $obj->code;
if ($paycode == 'LIQ') $paycode = 'CASH';
if ($paycode == 'CB') $paycode = 'CB';
if ($paycode == 'CHQ') $paycode = 'CHEQUE';
if ($paycode == 'LIQ') {
$paycode = 'CASH';
}
if ($paycode == 'CB') {
$paycode = 'CB';
}
if ($paycode == 'CHQ') {
$paycode = 'CHEQUE';
}
$accountname = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"];
if (!empty($conf->global->$accountname) && $conf->global->$accountname > 0) {
@ -106,7 +119,9 @@ if ($resql) {
?>
<link rel="stylesheet" href="css/pos.css.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>
<body>
@ -114,58 +129,63 @@ if ($conf->global->TAKEPOS_COLOR_THEME == 1) print '<link rel="stylesheet" href=
<script>
<?php
$remaintopay = 0;
if ($invoice->id > 0)
{
if ($invoice->id > 0) {
$remaintopay = $invoice->getRemainToPay();
}
$alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0);
if ($conf->global->TAKEPOS_NUMPAD == 0) print "var received='';";
else print "var received=0;";
if ($conf->global->TAKEPOS_NUMPAD == 0) {
print "var received='';";
} else {
print "var received=0;";
}
?>
var alreadypayed = <?php echo $alreadypayed ?>;
function addreceived(price)
{
<?php
if (empty($conf->global->TAKEPOS_NUMPAD)) print 'received+=String(price);'."\n";
else print 'received+=parseFloat(price);'."\n";
<?php
if (empty($conf->global->TAKEPOS_NUMPAD)) {
print 'received+=String(price);'."\n";
} else {
print 'received+=parseFloat(price);'."\n";
}
?>
$('.change1').html(pricejs(parseFloat(received), 'MT'));
$('.change1').val(parseFloat(received));
$('.change1').html(pricejs(parseFloat(received), 'MT'));
$('.change1').val(parseFloat(received));
alreadypaydplusreceived=price2numjs(alreadypayed + parseFloat(received));
//console.log("already+received = "+alreadypaydplusreceived);
//console.log("total_ttc = "+<?php echo $invoice->total_ttc; ?>);
if (alreadypaydplusreceived > <?php echo $invoice->total_ttc; ?>)
{
//console.log("already+received = "+alreadypaydplusreceived);
//console.log("total_ttc = "+<?php echo $invoice->total_ttc; ?>);
if (alreadypaydplusreceived > <?php echo $invoice->total_ttc; ?>)
{
var change=parseFloat(alreadypayed + parseFloat(received) - <?php echo $invoice->total_ttc; ?>);
$('.change2').html(pricejs(change, 'MT'));
$('.change2').val(change);
$('.change1').removeClass('colorred');
$('.change1').addClass('colorgreen');
$('.change2').removeClass('colorwhite');
$('.change2').addClass('colorred');
$('.change2').val(change);
$('.change1').removeClass('colorred');
$('.change1').addClass('colorgreen');
$('.change2').removeClass('colorwhite');
$('.change2').addClass('colorred');
}
else
{
else
{
$('.change2').html(pricejs(0, 'MT'));
$('.change2').val(0);
if (alreadypaydplusreceived == <?php echo $invoice->total_ttc; ?>)
{
$('.change1').removeClass('colorred');
$('.change1').addClass('colorgreen');
$('.change2').removeClass('colorred');
$('.change2').addClass('colorwhite');
}
else
{
$('.change1').removeClass('colorgreen');
$('.change1').addClass('colorred');
$('.change2').removeClass('colorred');
$('.change2').addClass('colorwhite');
}
}
$('.change2').val(0);
if (alreadypaydplusreceived == <?php echo $invoice->total_ttc; ?>)
{
$('.change1').removeClass('colorred');
$('.change1').addClass('colorgreen');
$('.change2').removeClass('colorred');
$('.change2').addClass('colorwhite');
}
else
{
$('.change1').removeClass('colorgreen');
$('.change1').addClass('colorred');
$('.change2').removeClass('colorred');
$('.change2').addClass('colorwhite');
}
}
}
function reset()
@ -175,10 +195,10 @@ else print "var received=0;";
$('.change1').val(price2numjs(received));
$('.change2').html(pricejs(received, 'MT'));
$('.change2').val(price2numjs(received));
$('.change1').removeClass('colorgreen');
$('.change1').addClass('colorred');
$('.change2').removeClass('colorred');
$('.change2').addClass('colorwhite');
$('.change1').removeClass('colorgreen');
$('.change1').addClass('colorred');
$('.change2').removeClass('colorred');
$('.change2').addClass('colorwhite');
}
function Validate(payment)
@ -192,10 +212,10 @@ else print "var received=0;";
}
console.log("We click on the payment mode to pay amount = "+amountpayed);
parent.$("#poslines").load("invoice.php?place=<?php echo $place; ?>&action=valid&pay="+payment+"&amount="+amountpayed+"&excess="+excess+"&invoiceid="+invoiceid+"&accountid="+accountid, function() {
if (amountpayed > <?php echo $remaintopay; ?> || amountpayed == <?php echo $remaintopay; ?> || amountpayed==0 ) {
console.log("Close popup");
parent.$.colorbox.close();
}
if (amountpayed > <?php echo $remaintopay; ?> || amountpayed == <?php echo $remaintopay; ?> || amountpayed==0 ) {
console.log("Close popup");
parent.$.colorbox.close();
}
else {
console.log("Amount is not comple, so we do NOT close popup and reload it.");
location.reload();
@ -206,32 +226,32 @@ else print "var received=0;";
function ValidateSumup() {
console.log("Launch ValidateSumup");
<?php $_SESSION['SMP_CURRENT_PAYMENT'] = "NEW" ?>
var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
var amountpayed = $("#change1").val();
if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
amountpayed = <?php echo $invoice->total_ttc; ?>;
}
var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
var amountpayed = $("#change1").val();
if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
amountpayed = <?php echo $invoice->total_ttc; ?>;
}
// Starting sumup app
window.open('sumupmerchant://pay/1.0?affiliate-key=<?php echo $conf->global->TAKEPOS_SUMUP_AFFILIATE ?>&app-id=<?php echo $conf->global->TAKEPOS_SUMUP_APPID ?>&total=' + amountpayed + '&currency=EUR&title=' + invoiceid + '&callback=<?php echo DOL_MAIN_URL_ROOT ?>/takepos/smpcb.php');
// Starting sumup app
window.open('sumupmerchant://pay/1.0?affiliate-key=<?php echo $conf->global->TAKEPOS_SUMUP_AFFILIATE ?>&app-id=<?php echo $conf->global->TAKEPOS_SUMUP_APPID ?>&total=' + amountpayed + '&currency=EUR&title=' + invoiceid + '&callback=<?php echo DOL_MAIN_URL_ROOT ?>/takepos/smpcb.php');
var loop = window.setInterval(function () {
$.ajax('<?php echo DOL_URL_ROOT ?>/takepos/smpcb.php?status').done(function (data) {
console.log(data);
if (data === "SUCCESS") {
parent.$("#poslines").load("invoice.php?place=<?php echo $place; ?>&action=valid&pay=CB&amount=" + amountpayed + "&invoiceid=" + invoiceid, function () {
//parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
parent.$.colorbox.close();
//parent.setFocusOnSearchField(); // This does not have effect
});
clearInterval(loop);
} else if (data === "FAILED") {
parent.$.colorbox.close();
clearInterval(loop);
}
});
}, 2500);
}
var loop = window.setInterval(function () {
$.ajax('<?php echo DOL_URL_ROOT ?>/takepos/smpcb.php?status').done(function (data) {
console.log(data);
if (data === "SUCCESS") {
parent.$("#poslines").load("invoice.php?place=<?php echo $place; ?>&action=valid&pay=CB&amount=" + amountpayed + "&invoiceid=" + invoiceid, function () {
//parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
parent.$.colorbox.close();
//parent.setFocusOnSearchField(); // This does not have effect
});
clearInterval(loop);
} else if (data === "FAILED") {
parent.$.colorbox.close();
clearInterval(loop);
}
});
}, 2500);
}
</script>
<div style="position:relative; padding-top: 20px; left:5%; height:150px; width:90%;">
@ -245,7 +265,7 @@ else print "var received=0;";
</div>
<?php } ?>
<div class="paymentbordline paymentbordlinereceived">
<center><span class="takepospay"><font color="white"><?php echo $langs->trans("Received"); ?>: </font><span class="change1 colorred"><?php echo price(0, 1, '', 1, -1, -1, $invoice->multicurrency_code); ?></span><input type="hidden" id="change1" class="change1" value="0"></span></center>
<center><span class="takepospay"><font color="white"><?php echo $langs->trans("Received"); ?>: </font><span class="change1 colorred"><?php echo price(0, 1, '', 1, -1, -1, $invoice->multicurrency_code); ?></span><input type="hidden" id="change1" class="change1" value="0"></span></center>
</div>
<div class="paymentbordline paymentbordlinechange">
<center><span class="takepospay"><font color="white"><?php echo $langs->trans("Change"); ?>: </font><span class="change2 colorwhite"><?php echo price(0, 1, '', 1, -1, -1, $invoice->multicurrency_code); ?></span><input type="hidden" id="change2" class="change2" value="0"></span></center>
@ -294,13 +314,19 @@ print '<button type="button" class="calcbutton" onclick="addreceived('.($numpad
$payIcon = '';
if ($paycode == 'LIQ') {
$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') {
$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') {
$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>';
@ -317,13 +343,19 @@ print '<button type="button" class="calcbutton" onclick="addreceived('.($numpad
$payIcon = '';
if ($paycode == 'LIQ') {
$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') {
$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') {
$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>';
@ -341,13 +373,19 @@ print '<button type="button" class="calcbutton" onclick="addreceived('.($numpad
$payIcon = '';
if ($paycode == 'LIQ') {
$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') {
$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') {
$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>';

View File

@ -25,13 +25,25 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','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');
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');
}
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.'/categories/class/categorie.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');
$idproduct = GETPOST('idproduct', 'int');
if ($setterminal > 0)
{
if ($setterminal > 0) {
$_SESSION["takeposterminal"] = $setterminal;
}
@ -83,8 +94,7 @@ if ($action == "productinfo") {
print '<h1>'.$langs->trans('StatusOrderDelivered').'</h1>';
print '<button type="button" class="publicphonebutton2 phoneblue total" onclick="CheckPlease();">'.$langs->trans('Payment').'</button>';
print '<br>';
}
elseif ($action == "checkplease") {
} elseif ($action == "checkplease") {
if (GETPOSTISSET("payment")) {
print '<h1>'.$langs->trans('StatusOrderDelivered').'</h1>';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
@ -114,10 +124,8 @@ elseif ($action == "checkplease") {
$selectedline = GETPOST('selectedline', 'int');
$invoice = new Facture($db);
$invoice->fetch($placeid);
foreach ($invoice->lines as $line)
{
if ($line->id == $selectedline)
{
foreach ($invoice->lines as $line) {
if ($line->id == $selectedline) {
$prod = new Product($db);
$prod->fetch($line->fk_product);
print "<b>".$prod->label."</b><br>";
@ -133,7 +141,9 @@ elseif ($action == "checkplease") {
} else {
// Title
$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"/>
<meta name="apple-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
//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
$levelofrootcategory = 0;
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)
{
foreach ($categories as $key => $categorycursor)
{
if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID)
{
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
foreach ($categories as $key => $categorycursor) {
if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID) {
$levelofrootcategory = $categorycursor['level'];
break;
}
@ -164,10 +171,8 @@ elseif ($action == "checkplease") {
$maincategories = array();
$subcategories = array();
foreach ($categories as $key => $categorycursor)
{
if ($categorycursor['level'] == $levelofmaincategories)
{
foreach ($categories as $key => $categorycursor) {
if ($categorycursor['level'] == $levelofmaincategories) {
$maincategories[$key] = $categorycursor;
} else {
$subcategories[$key] = $categorycursor;
@ -193,23 +198,22 @@ var editnumber="";
$( document ).ready(function() {
console.log("Refresh");
console.log("Refresh");
LoadPlace(place);
});
function LoadPlace(placeid){
place=placeid;
place=placeid;
<?php
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
echo '$("#phonediv2").load("auto_order.php?mobilepage=invoice&place="+place, function() {
});';
}
else {
} else {
echo '$("#phonediv2").load("invoice.php?mobilepage=invoice&place="+place, function() {
});';
}
?>
LoadCats();
LoadCats();
}
function AddProduct(placeid, productid){
@ -219,8 +223,7 @@ function AddProduct(placeid, productid){
print 'place=placeid;
$("#phonediv1").load("auto_order.php?action=productinfo&place="+place+"&idproduct="+productid, function() {
});';
}
else {
} else {
print 'AddProductConfirm(placeid, productid);';
}
?>
@ -237,8 +240,7 @@ function AddProductConfirm(placeid, productid){
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
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() {
});';
}
@ -258,8 +260,7 @@ function SetQty(place, selectedline, qty){
});
}
<?php
}
else {
} else {
?>
if (qty==0){
$("#phonediv2").load("invoice.php?mobilepage=invoice&action=deleteline&token=<?php echo newToken(); ?>&place="+place+"&idline="+selectedline, function() {
@ -278,7 +279,7 @@ function SetQty(place, selectedline, qty){
function SetNote(place, selectedline){
var note = prompt("<?php $langs->trans('Note'); ?>", "");
$("#phonediv2").load("auto_order.php?mobilepage=invoice&action=updateqty&place="+place+"&idline="+selectedline+"&number="+qty, function() {
});
});
LoadCats();
}
@ -287,8 +288,7 @@ function LoadCats(){
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
echo '$("#phonediv1").load("auto_order.php?mobilepage=cats&place="+place, function() {
});';
}
else {
} else {
echo '$("#phonediv1").load("invoice.php?mobilepage=cats&place="+place, function() {
});';
}
@ -301,8 +301,7 @@ function LoadProducts(idcat){
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
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() {
});';
}
@ -310,20 +309,19 @@ function LoadProducts(idcat){
}
function LoadPlacesList(){
$("#phonediv1").load("invoice.php?mobilepage=places", function() {
});
$("#phonediv1").load("invoice.php?mobilepage=places", function() {
});
}
function TakeposPrintingOrder(){
console.log("TakeposPrintingOrder");
console.log("TakeposPrintingOrder");
<?php
if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) {
echo '$("#phonediv2").load("auto_order.php?action=order&mobilepage=order&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() {
});';
}
@ -331,7 +329,7 @@ function TakeposPrintingOrder(){
}
function Exit(){
window.location.href='../user/logout.php';
window.location.href='../user/logout.php';
}
function CheckPlease(payment){
@ -350,7 +348,9 @@ function CheckPlease(payment){
<body style="background-color:#D1D1D1;">
<?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="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="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>';
}
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 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>';

View File

@ -21,18 +21,30 @@
* \brief Public orders for customers
*/
if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1');
if (!defined("NOLOGIN")) {
define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
}
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';
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["takeposterminal"] = 1;
define('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE', 1);
if (GETPOSTISSET("mobilepage")) require '../invoice.php';
elseif (GETPOSTISSET("genimg")) require DOL_DOCUMENT_ROOT.'/takepos/genimg/index.php';
else require '../phone.php';
if (GETPOSTISSET("mobilepage")) {
require '../invoice.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
*/
if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1');
if (!defined("NOLOGIN")) {
define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
}
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_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>
<html>
@ -43,21 +51,18 @@ if (!$conf->global->TAKEPOS_QR_MENU) accessforbidden(); // If Restaurant Menu is
<body>
<!-- partial:index.partial.html -->
<body>
<div class="grid-container">
<div class="grid-x grid-padding-x menu2">
<div class="cell small-12">
<h1><?php print $mysoc->name; ?> - <small><?php print $langs->trans('RestaurantMenu'); ?></small></h1>
<div class="grid-container">
<div class="grid-x grid-padding-x menu2">
<div class="cell small-12">
<h1><?php print $mysoc->name; ?> - <small><?php print $langs->trans('RestaurantMenu'); ?></small></h1>
<?php
$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);
$levelofrootcategory = 0;
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)
{
foreach ($categories as $key => $categorycursor)
{
if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID)
{
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
foreach ($categories as $key => $categorycursor) {
if ($categorycursor['id'] == $conf->global->TAKEPOS_ROOT_CATEGORY_ID) {
$levelofrootcategory = $categorycursor['level'];
break;
}
@ -67,10 +72,8 @@ $levelofmaincategories = $levelofrootcategory + 1;
$maincategories = array();
$subcategories = array();
foreach ($categories as $key => $categorycursor)
{
if ($categorycursor['level'] == $levelofmaincategories)
{
foreach ($categories as $key => $categorycursor) {
if ($categorycursor['level'] == $levelofmaincategories) {
$maincategories[$key] = $categorycursor;
} else {
$subcategories[$key] = $categorycursor;
@ -103,12 +106,12 @@ foreach ($maincategories as $cat) {
?>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="text-muted"><?php print $mysoc->name; ?></p>
</div>
</footer>
</div>
<footer class="footer">
<div class="container">
<p class="text-muted"><?php print $mysoc->name; ?></p>
</div>
</footer>
</body>
<!-- partial -->
<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>

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('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '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');
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'; // 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');
if ($place > 0)
{
if ($place > 0) {
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
if ($obj)
{
if ($obj) {
$facid = $obj->rowid;
}
}
@ -86,13 +92,13 @@ if (!empty($hookmanager->resPrint)) {
<body>
<style>
.right {
text-align: right;
text-align: right;
}
.center {
text-align: center;
text-align: center;
}
.left {
text-align: left;
text-align: left;
}
</style>
<center>
@ -104,12 +110,15 @@ if (!empty($hookmanager->resPrint)) {
<p class="left">
<?php
$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 = '';
$substitutionarray = getCommonSubstitutionArray($langs);
if (!empty($conf->global->TAKEPOS_HEADER)) $newfreetext .= make_substitutions($conf->global->TAKEPOS_HEADER, $substitutionarray);
if (!empty($conf->global->{$constFreeText})) $newfreetext .= make_substitutions($conf->global->{$constFreeText}, $substitutionarray);
if (!empty($conf->global->TAKEPOS_HEADER)) {
$newfreetext .= make_substitutions($conf->global->TAKEPOS_HEADER, $substitutionarray);
}
if (!empty($conf->global->{$constFreeText})) {
$newfreetext .= make_substitutions($conf->global->{$constFreeText}, $substitutionarray);
}
print $newfreetext;
}
?>
@ -117,16 +126,22 @@ if (!empty($conf->global->TAKEPOS_HEADER) || !empty($conf->global->{$constFreeTe
<p class="right">
<?php
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 ($object->statut == Facture::STATUS_DRAFT) print str_replace(")", "", str_replace("-", " ".$langs->trans('Place')." ", str_replace("(PROV-POS", $langs->trans("Terminal")." ", $object->ref)));
else print $object->ref;
if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
{
if ($object->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]})
{
if (!empty($conf->global->TAKEPOS_RECEIPT_NAME)) {
print $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)));
} else {
print $object->ref;
}
if ($conf->global->TAKEPOS_SHOW_CUSTOMER) {
if ($object->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}) {
$soc = new Societe($db);
if ($object->socid > 0) $soc->fetch($object->socid);
else $soc->fetch($conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]});
if ($object->socid > 0) {
$soc->fetch($object->socid);
} else {
$soc->fetch($conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]});
}
print "<br>".$langs->trans("Customer").': '.$soc->name;
}
}
@ -135,52 +150,69 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
<br>
<table width="100%" style="border-top-style: double;">
<thead>
<thead>
<tr>
<th class="center"><?php print $langs->trans("Label"); ?></th>
<th class="right"><?php print $langs->trans("Qty"); ?></th>
<th class="right"><?php if ($gift != 1) print $langs->trans("Price"); ?></th>
<?php if (!empty($conf->global->TAKEPOS_SHOW_HT_RECEIPT)) { ?>
<th class="right"><?php if ($gift != 1) print $langs->trans("TotalHT"); ?></th>
<?php } ?>
<th class="right"><?php if ($gift != 1) print $langs->trans("TotalTTC"); ?></th>
<th class="center"><?php print $langs->trans("Label"); ?></th>
<th class="right"><?php print $langs->trans("Qty"); ?></th>
<th class="right"><?php if ($gift != 1) {
print $langs->trans("Price");
} ?></th>
<?php if (!empty($conf->global->TAKEPOS_SHOW_HT_RECEIPT)) { ?>
<th class="right"><?php if ($gift != 1) {
print $langs->trans("TotalHT");
} ?></th>
<?php } ?>
<th class="right"><?php if ($gift != 1) {
print $langs->trans("TotalTTC");
} ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($object->lines as $line)
{
</thead>
<tbody>
<?php
foreach ($object->lines as $line) {
?>
<tr>
<td>
<?php if (!empty($line->product_label)) echo $line->product_label;
else echo $line->description; ?>
</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>
<?php
if (!empty($conf->global->TAKEPOS_SHOW_HT_RECEIPT)) { ?>
<td class="right"><?php if ($gift != 1) echo price($line->total_ht, 1); ?></td>
<?php
}
?>
<td class="right"><?php if ($gift != 1) echo price($line->total_ttc, 1); ?></td>
</tr>
<?php
<tr>
<td>
<?php if (!empty($line->product_label)) {
echo $line->product_label;
} else {
echo $line->description;
} ?>
</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>
<?php
if (!empty($conf->global->TAKEPOS_SHOW_HT_RECEIPT)) { ?>
<td class="right"><?php if ($gift != 1) {
echo price($line->total_ht, 1);
} ?></td>
<?php
}
?>
<td class="right"><?php if ($gift != 1) {
echo price($line->total_ttc, 1);
} ?></td>
</tr>
<?php
}
?>
</tbody>
</tbody>
</table>
<br>
<table class="right">
<tr>
<th class="right"><?php if ($gift != 1) 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>
<th class="right"><?php if ($gift != 1) {
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>
<?php if ($conf->global->TAKEPOS_TICKET_VAT_GROUPPED) {
$vat_groups = array();
foreach ($object->lines as $line)
{
foreach ($object->lines as $line) {
if (!array_key_exists($line->tva_tx, $vat_groups)) {
$vat_groups[$line->tva_tx] = 0;
}
@ -189,18 +221,26 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
foreach ($vat_groups as $key => $val) {
?>
<tr>
<th align="right"><?php if ($gift != 1) 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>
<th align="right"><?php if ($gift != 1) {
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>
<?php
<?php
}
} else { ?>
<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>
<?php } ?>
<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>
<?php
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->fetch(0, $_SESSION["takeposcustomercurrency"]);
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>';
}
@ -221,8 +263,7 @@ if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) {
$sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$facid;
$sql .= " ORDER BY p.datep";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
@ -233,12 +274,13 @@ if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) {
echo '</td>';
echo '<td class="right">';
$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 '</td>';
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 '<td class="right">';
echo $langs->trans("Change");
@ -260,18 +302,21 @@ if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) {
<br>
<?php
$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 = '';
$substitutionarray = getCommonSubstitutionArray($langs);
if (!empty($conf->global->{$constFreeText})) $newfreetext .= make_substitutions($conf->global->{$constFreeText}, $substitutionarray);
if (!empty($conf->global->TAKEPOS_FOOTER)) $newfreetext .= make_substitutions($conf->global->TAKEPOS_FOOTER, $substitutionarray);
if (!empty($conf->global->{$constFreeText})) {
$newfreetext .= make_substitutions($conf->global->{$constFreeText}, $substitutionarray);
}
if (!empty($conf->global->TAKEPOS_FOOTER)) {
$newfreetext .= make_substitutions($conf->global->TAKEPOS_FOOTER, $substitutionarray);
}
print $newfreetext;
}
?>
<script type="text/javascript">
window.print();
window.print();
</script>
</body>
</html>

View File

@ -25,11 +25,21 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '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');
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_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@ -48,19 +58,16 @@ if (empty($user->rights->takepos->run)) {
*/
$invoice = new Facture($db);
if ($invoiceid > 0)
{
if ($invoiceid > 0) {
$invoice->fetch($invoiceid);
} else {
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
if ($obj)
{
if ($obj) {
$invoiceid = $obj->rowid;
}
if (!$invoiceid)
{
if (!$invoiceid) {
$invoiceid = 0; // Invoice does not exist yet
} else {
$invoice->fetch($invoiceid);
@ -87,111 +94,111 @@ if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->glob
<body>
<script>
var reductionType ='';
var reductionType ='';
var reductionTotal = '';
var editAction = '';
var editNumber = '';
var editAction = '';
var editNumber = '';
var htmlBtnOK = '<span style="font-size: 14pt;">OK</span>';
var htmlReductionPercent = '<?php echo dol_escape_js($htmlReductionPercent); ?>';
var htmlReductionAmount = '<?php echo dol_escape_js($htmlReductionAmount); ?>';
/**
* Reset values
*/
function Reset()
{
reductionType = '';
reductionTotal = '';
editAction = '';
editNumber = '';
jQuery('#reduction_total').val(reductionTotal);
/**
* Reset values
*/
function Reset()
{
reductionType = '';
reductionTotal = '';
editAction = '';
editNumber = '';
jQuery('#reduction_total').val(reductionTotal);
jQuery("#reduction_type_percent").html(htmlReductionPercent);
jQuery('#reduction_type_amount').html(htmlReductionAmount);
}
}
/**
* Edit action
*
* @param {string} number Number pressed
*/
function Edit(number)
{
console.log('Edit ' + number);
/**
* Edit action
*
* @param {string} number Number pressed
*/
function Edit(number)
{
console.log('Edit ' + number);
if (number === 'p') {
if (editAction === 'p' && reductionType === 'percent'){
ValidateReduction();
} else {
editAction = 'p';
}
reductionType = 'percent';
} else if (number === 'a') {
if (editAction === 'a' && reductionType === 'amount'){
ValidateReduction();
} else {
editAction = 'a';
}
reductionType = 'amount';
}
if (number === 'p') {
if (editAction === 'p' && reductionType === 'percent'){
ValidateReduction();
} else {
editAction = 'p';
}
reductionType = 'percent';
} else if (number === 'a') {
if (editAction === 'a' && reductionType === 'amount'){
ValidateReduction();
} else {
editAction = 'a';
}
reductionType = 'amount';
}
if (editAction === 'p'){
if (editAction === 'p'){
jQuery('#reduction_type_percent').html(htmlBtnOK);
jQuery('#reduction_type_amount').html(htmlReductionAmount);
} else if (editAction === 'a'){
} else if (editAction === 'a'){
jQuery('#reduction_type_amount').html(htmlBtnOK);
jQuery("#reduction_type_percent").html(htmlReductionPercent);
} else {
} else {
jQuery('#reduction_type_percent').html(htmlReductionPercent);
jQuery('#reduction_type_amount').html(htmlReductionAmount);
}
}
}
}
/**
* Add a number in reduction input
*
* @param {string} reductionNumber Number pressed
*/
function AddReduction(reductionNumber)
{
console.log('AddReduction ' + reductionNumber);
/**
* Add a number in reduction input
*
* @param {string} reductionNumber Number pressed
*/
function AddReduction(reductionNumber)
{
console.log('AddReduction ' + reductionNumber);
reductionTotal += String(reductionNumber);
jQuery('#reduction_total').val(reductionTotal);
}
reductionTotal += String(reductionNumber);
jQuery('#reduction_total').val(reductionTotal);
}
/**
* Validate a reduction
*/
/**
* Validate a reduction
*/
function ValidateReduction()
{
console.log('ValidateReduction');
console.log('ValidateReduction');
if (reductionTotal.length <= 0) {
console.error('Error no reduction');
return;
}
if (reductionTotal.length <= 0) {
console.error('Error no reduction');
return;
}
var reductionNumber = parseFloat(reductionTotal);
if (isNaN(reductionNumber)) {
console.error('Error not a valid number :', reductionNumber);
return;
}
var reductionNumber = parseFloat(reductionTotal);
if (isNaN(reductionNumber)) {
console.error('Error not a valid number :', reductionNumber);
return;
}
if (reductionType === 'percent') {
var invoiceid = <?php echo ($invoiceid > 0 ? $invoiceid : 0); ?>;
parent.$("#poslines").load("invoice.php?action=update_reduction_global&place=<?php echo $place; ?>&number="+reductionNumber+"&invoiceid="+invoiceid, function() {
Reset();
parent.$.colorbox.close();
});
} else if (reductionType === 'amount') {
var desc = "<?php echo dol_escape_js($langs->transnoentities('Reduction')); ?>";
parent.$("#poslines").load("invoice.php?action=freezone&place=<?php echo $place; ?>&number=-"+reductionNumber+"&desc="+desc, function() {
Reset();
parent.$.colorbox.close();
});
} else {
console.error('Error bad reduction type :', reductionType);
}
if (reductionType === 'percent') {
var invoiceid = <?php echo ($invoiceid > 0 ? $invoiceid : 0); ?>;
parent.$("#poslines").load("invoice.php?action=update_reduction_global&place=<?php echo $place; ?>&number="+reductionNumber+"&invoiceid="+invoiceid, function() {
Reset();
parent.$.colorbox.close();
});
} else if (reductionType === 'amount') {
var desc = "<?php echo dol_escape_js($langs->transnoentities('Reduction')); ?>";
parent.$("#poslines").load("invoice.php?action=freezone&place=<?php echo $place; ?>&number=-"+reductionNumber+"&desc="+desc, function() {
Reset();
parent.$.colorbox.close();
});
} else {
console.error('Error bad reduction type :', reductionType);
}
}
</script>

View File

@ -26,11 +26,21 @@
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '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');
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_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
@ -51,8 +61,7 @@ $invoice->fetch($facid);
$customer = new Societe($db);
$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/html.formmail.class.php';
$formmail = new FormMail($db);
@ -87,9 +96,9 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
<script>
function SendMail() {
$.ajax({
type: "GET",
url: "<?php print dol_buildpath('/takepos/send.php', 1).'?action=send&facid='.$facid.'&email='; ?>" + $("#email"). val(),
});
type: "GET",
url: "<?php print dol_buildpath('/takepos/send.php', 1).'?action=send&facid='.$facid.'&email='; ?>" + $("#email"). val(),
});
parent.$.colorbox.close();
}

View File

@ -21,11 +21,21 @@
* \brief Page with the content for smpcb payment
*/
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');
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';