'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '
';
print '';
@@ -120,8 +141,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON ptva.fk_typepaiement = pct.id";
$sql .= " WHERE ptva.fk_tva = tva.rowid";
$sql .= " AND tva.entity = ".$conf->entity;
- if ($year > 0)
- {
+ if ($year > 0) {
$sql .= " AND (";
// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
@@ -133,22 +153,22 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
|| preg_match('/^tva\./', $sortfield)
|| preg_match('/^ptva\./', $sortfield)
|| preg_match('/^pct\./', $sortfield)
- || preg_match('/^bank\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder);
+ || preg_match('/^bank\./', $sortfield)) {
+ $sql .= $db->order($sortfield, $sortorder);
+ }
//$sql.= $db->plimit($limit+1,$offset);
//print $sql;
dol_syslog("compta/tva/payments.php: select payment", LOG_DEBUG);
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
$total = 0;
$totalnb = 0;
$totalpaye = 0;
- while ($i < min($num, $limit))
- {
+ while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
$payment_vat_static->id = $obj->pid;
@@ -159,11 +179,13 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
print ''.$payment_vat_static->getNomUrl(1)." \n";
// Date payment
print ''.dol_print_date($db->jdate($obj->datep), 'day').' ';
- // Type payment
- print '';
- if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
- print $obj->num_payment.' ';
- // Account
+ // Type payment
+ print '';
+ if ($obj->payment_code) {
+ print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
+ }
+ print $obj->num_payment.' ';
+ // Account
print '';
$account = new Account($db);
$account->fetch($obj->fk_account);
@@ -185,7 +207,9 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
print ' '.price($obj->total).' ';
// Paid
print '';
- if ($obj->totalpaye) print price($obj->totalpaye);
+ if ($obj->totalpaye) {
+ print price($obj->totalpaye);
+ }
print ' ';
print ' ';
@@ -194,16 +218,15 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
$totalpaye = $totalpaye + $obj->totalpaye;
$i++;
}
- print ''.$langs->trans("Total").' ';
- print ' '; // A total here has no sense
- //print ' ';
- print ' ';
+ print ''.$langs->trans("Total").' ';
+ print ' '; // A total here has no sense
+ //print ' ';
print ' ';
print ' ';
- print ''.price($totalpaye)." ";
+ print ' ';
+ print ''.price($totalpaye)." ";
print " ";
- }
- else {
+ } else {
dol_print_error($db);
}
print '
';
diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php
index ba12b08b3b0..04f90ba02f9 100644
--- a/htdocs/compta/tva/quadri_detail.php
+++ b/htdocs/compta/tva/quadri_detail.php
@@ -46,12 +46,13 @@ $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "produ
$now = dol_now();
$current_date = dol_getdate($now);
-if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) $conf->global->SOCIETE_FISCAL_MONTH_START = 1;
+if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) {
+ $conf->global->SOCIETE_FISCAL_MONTH_START = 1;
+}
// Date range
$year = GETPOST("year", "int");
-if (empty($year))
-{
+if (empty($year)) {
$year_current = $current_date['year'];
$year_start = $year_current;
} else {
@@ -61,12 +62,12 @@ if (empty($year))
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
// Set default period if not defined
-if (empty($date_start) || empty($date_end)) // We define date_start and date_end
-{
+if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
$q = GETPOST("q", "int");
- if (empty($q))
- {
- if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else {
+ if (empty($q)) {
+ if (GETPOST("month", "int")) {
+ $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false);
+ } else {
if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter
$date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm');
$date_end = dol_time_plus_duree($date_start, 3, 'm') - 1;
@@ -88,25 +89,41 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
}
}
} else {
- if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
- if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
- if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
- if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); }
+ if ($q == 1) {
+ $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false);
+ }
+ if ($q == 2) {
+ $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false);
+ }
+ if ($q == 3) {
+ $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false);
+ }
+ if ($q == 4) {
+ $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false);
+ }
}
}
$min = price2num(GETPOST("min", "alpha"));
-if (empty($min)) $min = 0;
+if (empty($min)) {
+ $min = 0;
+}
// Define modetax (0 or 1)
// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
$modetax = $conf->global->TAX_MODE;
-if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int');
-if (empty($modetax)) $modetax = 0;
+if (GETPOSTISSET("modetax")) {
+ $modetax = GETPOST("modetax", 'int');
+}
+if (empty($modetax)) {
+ $modetax = 0;
+}
// Security check
$socid = GETPOST('socid', 'int');
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'tax', '', '', 'charges');
@@ -127,9 +144,10 @@ $paymentexpensereport_static = new PaymentExpenseReport($db);
$morequerystring = '';
$listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday');
-foreach ($listofparams as $param)
-{
- if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param);
+foreach ($listofparams as $param) {
+ if (GETPOST($param) != '') {
+ $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param);
+ }
}
$title = $langs->trans("VATReport")." ".dol_print_date($date_start)." -> ".dol_print_date($date_end);
@@ -149,9 +167,15 @@ $fsearch .= '
';
// Show report header
$name = $langs->trans("VATReportByRates");
$calcmode = '';
-if ($modetax == 0) $calcmode = $langs->trans('OptionVATDefault');
-if ($modetax == 1) $calcmode = $langs->trans('OptionVATDebitOption');
-if ($modetax == 2) $calcmode = $langs->trans('OptionPaymentForProductAndServices');
+if ($modetax == 0) {
+ $calcmode = $langs->trans('OptionVATDefault');
+}
+if ($modetax == 1) {
+ $calcmode = $langs->trans('OptionVATDebitOption');
+}
+if ($modetax == 2) {
+ $calcmode = $langs->trans('OptionPaymentForProductAndServices');
+}
$calcmode .= '
('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').') ';
// Set period
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
@@ -173,14 +197,24 @@ if ($nextquarter < 4) {
$description .= $fsearch;
$builddate = dol_now();
-if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description .= $langs->trans("RulesVATDueProducts");
-if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description .= $langs->trans("RulesVATInProducts");
-if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description .= '
'.$langs->trans("RulesVATDueServices");
-if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description .= '
'.$langs->trans("RulesVATInServices");
+if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') {
+ $description .= $langs->trans("RulesVATDueProducts");
+}
+if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') {
+ $description .= $langs->trans("RulesVATInProducts");
+}
+if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') {
+ $description .= '
'.$langs->trans("RulesVATDueServices");
+}
+if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') {
+ $description .= '
'.$langs->trans("RulesVATInServices");
+}
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= '
'.$langs->trans("DepositsAreNotIncluded");
}
-if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '
'.$langs->trans("ThisIsAnEstimatedValue");
+if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) {
+ $description .= '
'.$langs->trans("ThisIsAnEstimatedValue");
+}
// Customers invoices
$elementcust = $langs->trans("CustomersInvoices");
@@ -225,8 +259,7 @@ $columns = 5;
$x_coll = tax_by_rate('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell');
$x_paye = tax_by_rate('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy');
-if (!is_array($x_coll) || !is_array($x_paye))
-{
+if (!is_array($x_coll) || !is_array($x_paye)) {
$langs->load("errors");
if ($x_coll == -1) {
print '
'.$langs->trans("ErrorNoAccountancyModuleLoaded").' ';
@@ -238,15 +271,14 @@ if (!is_array($x_coll) || !is_array($x_paye))
} else {
$x_both = array();
//now, from these two arrays, get another array with one rate per line
- foreach (array_keys($x_coll) as $my_coll_rate)
- {
+ foreach (array_keys($x_coll) as $my_coll_rate) {
$x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
$x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
$x_both[$my_coll_rate]['paye']['totalht'] = 0;
$x_both[$my_coll_rate]['paye']['vat'] = 0;
$x_both[$my_coll_rate]['coll']['links'] = '';
$x_both[$my_coll_rate]['coll']['detail'] = array();
- foreach ($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) {
+ foreach ($x_coll[$my_coll_rate]['facid'] as $id => $dummy) {
$invoice_customer->id = $x_coll[$my_coll_rate]['facid'][$id];
$invoice_customer->ref = $x_coll[$my_coll_rate]['facnum'][$id];
$invoice_customer->type = $x_coll[$my_coll_rate]['type'][$id];
@@ -284,11 +316,9 @@ if (!is_array($x_coll) || !is_array($x_paye))
$x_both[$my_paye_rate]['paye']['links'] = '';
$x_both[$my_paye_rate]['paye']['detail'] = array();
- foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy)
- {
+ foreach ($x_paye[$my_paye_rate]['facid'] as $id => $dummy) {
// ExpenseReport
- if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment')
- {
+ if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') {
$expensereport->id = $x_paye[$my_paye_rate]['facid'][$id];
$expensereport->ref = $x_paye[$my_paye_rate]['facnum'][$id];
$expensereport->type = $x_paye[$my_paye_rate]['type'][$id];
@@ -349,7 +379,9 @@ if (!is_array($x_coll) || !is_array($x_paye))
$x_paye_ht = 0;
$span = $columns;
- if ($modetax != 1) $span += 2;
+ if ($modetax != 1) {
+ $span += 2;
+ }
//print '
'..') ';
@@ -357,12 +389,14 @@ if (!is_array($x_coll) || !is_array($x_paye))
print '
';
print ''.$elementcust.' ';
print ''.$langs->trans("DateInvoice").' ';
- if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''.$langs->trans("DatePayment").' ';
- else print ' ';
+ if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') {
+ print ''.$langs->trans("DatePayment").' ';
+ } else {
+ print ' ';
+ }
print ''.$namecust.' ';
print ''.$productcust.' ';
- if ($modetax != 1)
- {
+ if ($modetax != 1) {
print ''.$amountcust.' ';
print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").') ';
}
@@ -385,8 +419,7 @@ if (!is_array($x_coll) || !is_array($x_paye))
$subtot_coll_total_ht = 0;
$subtot_coll_vat = 0;
- if (is_array($x_both[$rate]['coll']['detail']))
- {
+ if (is_array($x_both[$rate]['coll']['detail'])) {
// VAT Rate
print " ";
print ''.$langs->trans("Rate").': '.vatrate($rate).'% ';
@@ -415,16 +448,18 @@ if (!is_array($x_coll) || !is_array($x_paye))
print ''.dol_print_date($fields['datef'], 'day').' ';
// Payment date
- if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''.dol_print_date($fields['datep'], 'day').' ';
- else print ' ';
+ if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') {
+ print ''.dol_print_date($fields['datep'], 'day').' ';
+ } else {
+ print ' ';
+ }
// Company name
print ''.$fields['company_link'].' ';
// Description
print '';
- if ($fields['pid'])
- {
+ if ($fields['pid']) {
$product_static->id = $fields['pid'];
$product_static->ref = $fields['pref'];
$product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
@@ -455,12 +490,10 @@ if (!is_array($x_coll) || !is_array($x_paye))
print ' ';
// Total HT
- if ($modetax != 1)
- {
+ if ($modetax != 1) {
print '';
print price($fields['totalht']);
- if (price2num($fields['ftotal_ttc']))
- {
+ if (price2num($fields['ftotal_ttc'])) {
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
$ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']);
//print ' ('.round($ratiolineinvoice*100,2).'%)';
@@ -470,18 +503,15 @@ if (!is_array($x_coll) || !is_array($x_paye))
// Payment
$ratiopaymentinvoice = 1;
- if ($modetax != 1)
- {
+ if ($modetax != 1) {
print ' ';
//print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
- if ($fields['payment_amount'] && $fields['ftotal_ttc'])
- {
+ if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
$payment_static->id = $fields['payment_id'];
print $payment_static->getNomUrl(2);
}
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
- || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice'))
- {
+ || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) {
print $langs->trans("NA");
} else {
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
@@ -527,8 +557,7 @@ if (!is_array($x_coll) || !is_array($x_paye))
print ' ';
}
- if (count($x_coll) == 0) // Show a total line if nothing shown
- {
+ if (count($x_coll) == 0) { // Show a total line if nothing shown
print '
';
print ' ';
print ''.$langs->trans("Total").': ';
@@ -548,8 +577,11 @@ if (!is_array($x_coll) || !is_array($x_paye))
print ' ';
print ''.$elementsup.' ';
print ''.$langs->trans("DateInvoice").' ';
- if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''.$langs->trans("DatePayment").' ';
- else print ' ';
+ if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') {
+ print ''.$langs->trans("DatePayment").' ';
+ } else {
+ print ' ';
+ }
print ''.$namesup.' ';
print ''.$productsup.' ';
if ($modetax != 1) {
@@ -560,18 +592,16 @@ if (!is_array($x_coll) || !is_array($x_paye))
print ''.$vatsup.' ';
print ' '."\n";
- foreach (array_keys($x_paye) as $rate)
- {
+ foreach (array_keys($x_paye) as $rate) {
$subtot_paye_total_ht = 0;
$subtot_paye_vat = 0;
- if (is_array($x_both[$rate]['paye']['detail']))
- {
+ if (is_array($x_both[$rate]['paye']['detail'])) {
print "
";
print ''.$langs->trans("Rate").': '.vatrate($rate).'% ';
print ' '."\n";
- foreach ($x_both[$rate]['paye']['detail'] as $index=>$fields) {
+ foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) {
// Define type
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
$type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
@@ -594,16 +624,18 @@ if (!is_array($x_coll) || !is_array($x_paye))
print '
'.dol_print_date($fields['datef'], 'day').' ';
// Payment date
- if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print '
'.dol_print_date($fields['datep'], 'day').' ';
- else print '
';
+ if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') {
+ print '
'.dol_print_date($fields['datep'], 'day').' ';
+ } else {
+ print '
';
+ }
// Company name
print '
'.$fields['company_link'].' ';
// Description
print '
';
- if ($fields['pid'])
- {
+ if ($fields['pid']) {
$product_static->id = $fields['pid'];
$product_static->ref = $fields['pref'];
$product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
@@ -634,12 +666,10 @@ if (!is_array($x_coll) || !is_array($x_paye))
print ' ';
// Total HT
- if ($modetax != 1)
- {
+ if ($modetax != 1) {
print '
';
print price($fields['totalht']);
- if (price2num($fields['ftotal_ttc']))
- {
+ if (price2num($fields['ftotal_ttc'])) {
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
$ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']);
//print ' ('.round($ratiolineinvoice*100,2).'%)';
@@ -649,18 +679,15 @@ if (!is_array($x_coll) || !is_array($x_paye))
// Payment
$ratiopaymentinvoice = 1;
- if ($modetax != 1)
- {
+ if ($modetax != 1) {
print ' ';
- if ($fields['payment_amount'] && $fields['ftotal_ttc'])
- {
+ if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
$paymentfourn_static->id = $fields['payment_id'];
print $paymentfourn_static->getNomUrl(2);
}
if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')
- || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice'))
- {
+ || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) {
print $langs->trans("NA");
} else {
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php
index 2aeb2e4e2a1..ca496540a47 100644
--- a/htdocs/contact/agenda.php
+++ b/htdocs/contact/agenda.php
@@ -65,36 +65,44 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$object->getCanvas($id);
$objcanvas = null;
$canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas"));
-if (!empty($canvas))
-{
+if (!empty($canvas)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
$objcanvas = new Canvas($db, $action);
$objcanvas->getCanvas('contact', 'contactcard', $canvas);
}
-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));
}
$search_agenda_label = GETPOST('search_agenda_label');
// Security check
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission
$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';
+if (!$sortfield) {
+ $sortfield = 'a.datep, a.id';
+}
+if (!$sortorder) {
+ $sortorder = 'DESC';
+}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('contactagenda', 'globalcard'));
@@ -106,20 +114,19 @@ $hookmanager->initHooks(array('contactagenda', 'globalcard'));
$parameters = array('id'=>$id, '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 (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 test are required to be compatible with all browsers
- {
+ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
$actioncode = '';
$search_agenda_label = '';
}
@@ -133,29 +140,30 @@ if (empty($reshook))
$form = new Form($db);
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
-if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname;
+if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
+ $title = $object->lastname;
+}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
-if ($socid > 0)
-{
+if ($socid > 0) {
$objsoc = new Societe($db);
$objsoc->fetch($socid);
}
-if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
-{
+if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// -----------------------------------------
// When used with CANVAS
// -----------------------------------------
- if (empty($object->error) && $id)
- {
- $object = new Contact($db);
- $result = $object->fetch($id);
- if ($result <= 0) dol_print_error('', $object->error);
- }
- $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
+ if (empty($object->error) && $id) {
+ $object = new Contact($db);
+ $result = $object->fetch($id);
+ if ($result <= 0) {
+ dol_print_error('', $object->error);
+ }
+ }
+ $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
$objcanvas->display_canvas($action); // Show template
} else {
// -----------------------------------------
@@ -163,26 +171,27 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// -----------------------------------------
// Confirm deleting contact
- if ($user->rights->societe->contact->supprimer)
- {
- if ($action == 'delete')
- {
+ if ($user->rights->societe->contact->supprimer) {
+ if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1);
}
}
/*
- * Onglets
- */
+ * Onglets
+ */
$head = array();
- if ($id > 0)
- {
+ if ($id > 0) {
// Si edition contact deja existant
$object = new Contact($db);
$res = $object->fetch($id, $user);
- if ($res < 0) { dol_print_error($db, $object->error); exit; }
+ if ($res < 0) {
+ dol_print_error($db, $object->error); exit;
+ }
$res = $object->fetch_optionals();
- if ($res < 0) { dol_print_error($db, $object->error); exit; }
+ if ($res < 0) {
+ dol_print_error($db, $object->error); exit;
+ }
// Show tabs
$head = contact_prepare_head($object);
@@ -190,13 +199,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
}
- if (!empty($id) && $action != 'edit' && $action != 'create')
- {
+ if (!empty($id) && $action != 'edit' && $action != 'create') {
$objsoc = new Societe($db);
/*
- * Fiche en mode visualisation
- */
+ * Fiche en mode visualisation
+ */
dol_htmloutput_errors($error, $errors);
@@ -205,14 +213,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$linkback = ''.$langs->trans("BackToList").' ';
$morehtmlref = '';
- if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
- {
+ if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
$objsoc = new Societe($db);
$objsoc->fetch($object->socid);
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : ';
- if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1);
- else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
+ if ($objsoc->id > 0) {
+ $morehtmlref .= $objsoc->getNomUrl(1);
+ } else {
+ $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
+ }
}
$morehtmlref .= '
';
@@ -238,29 +248,31 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$out = '';
$permok = $user->rights->agenda->myactions->create;
- if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok)
- {
- if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '');
+ if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
+ if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') {
+ $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '');
+ }
$out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&percentage=-1&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : ''));
$out .= '&datep='.urlencode(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)))
- {
- print ' ';
+ if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
+ print ' ';
$param = '&id='.$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 load_fiche_titre($langs->trans("ActionsOnContact"), $newcardbutton, '');
//print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1);
diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php
index f6f6fa0b45e..a32263cd65e 100644
--- a/htdocs/contact/canvas/actions_contactcard_common.class.php
+++ b/htdocs/contact/canvas/actions_contactcard_common.class.php
@@ -64,14 +64,16 @@ abstract class ActionsContactCardCommon
{
/*$ret = $this->getInstanceDao();
- if (is_object($this->object) && method_exists($this->object,'fetch'))
- {
- if (! empty($id)) $this->object->fetch($id);
- }
- else
- {*/
+ if (is_object($this->object) && method_exists($this->object,'fetch'))
+ {
+ if (! empty($id)) $this->object->fetch($id);
+ }
+ else
+ {*/
$object = new Contact($this->db);
- if (!empty($id)) $object->fetch($id);
+ if (!empty($id)) {
+ $object->fetch($id);
+ }
$this->object = $object;
//}
}
@@ -90,20 +92,19 @@ abstract class ActionsContactCardCommon
global $conf, $langs, $user, $canvas;
global $form, $formcompany, $objsoc;
- if ($action == 'add' || $action == 'update') $this->assign_post();
+ if ($action == 'add' || $action == 'update') {
+ $this->assign_post();
+ }
- foreach ($this->object as $key => $value)
- {
+ foreach ($this->object as $key => $value) {
$this->tpl[$key] = $value;
}
$this->tpl['error'] = $this->error;
$this->tpl['errors'] = $this->errors;
- 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".''."\n";
}
- if (is_object($objsoc) && $objsoc->id > 0)
- {
+ if (is_object($objsoc) && $objsoc->id > 0) {
$this->tpl['company'] = $objsoc->getNomUrl(1);
$this->tpl['company_id'] = $objsoc->id;
} else {
@@ -127,14 +127,25 @@ abstract class ActionsContactCardCommon
$this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id);
// Predefined with third party
- if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS))
- {
- if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address;
- if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip;
- if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town;
- if (dol_strlen(trim($this->object->phone_pro)) == 0) $this->object->phone_pro = $objsoc->phone;
- if (dol_strlen(trim($this->object->fax)) == 0) $this->object->fax = $objsoc->fax;
- if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email;
+ if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) {
+ if (dol_strlen(trim($this->object->address)) == 0) {
+ $this->tpl['address'] = $objsoc->address;
+ }
+ if (dol_strlen(trim($this->object->zip)) == 0) {
+ $this->object->zip = $objsoc->zip;
+ }
+ if (dol_strlen(trim($this->object->town)) == 0) {
+ $this->object->town = $objsoc->town;
+ }
+ if (dol_strlen(trim($this->object->phone_pro)) == 0) {
+ $this->object->phone_pro = $objsoc->phone;
+ }
+ if (dol_strlen(trim($this->object->fax)) == 0) {
+ $this->object->fax = $objsoc->fax;
+ }
+ if (dol_strlen(trim($this->object->email)) == 0) {
+ $this->object->email = $objsoc->email;
+ }
}
// Zip
@@ -143,28 +154,33 @@ abstract class ActionsContactCardCommon
// Town
$this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
- if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id;
+ if (dol_strlen(trim($this->object->country_id)) == 0) {
+ $this->object->country_id = $objsoc->country_id;
+ }
// Country
$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;
+ }
// Public or private
$selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate"));
$this->tpl['select_visibility'] = $form->selectarray('priv', $selectarray, $this->object->priv, 0);
}
- if ($action == 'view' || $action == 'edit' || $action == 'delete')
- {
+ if ($action == 'view' || $action == 'edit' || $action == 'delete') {
// Emailing
- if (!empty($conf->mailing->enabled))
- {
+ if (!empty($conf->mailing->enabled)) {
$langs->load("mails");
$this->tpl['nb_emailing'] = $this->object->getNbOfEMailings();
}
@@ -175,46 +191,41 @@ abstract class ActionsContactCardCommon
$this->object->load_ref_elements();
- if (!empty($conf->commande->enabled))
- {
+ if (!empty($conf->commande->enabled)) {
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders");
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande ? $this->object->ref_commande : $langs->trans("NoContactForAnyOrder");
$i++;
}
- if (!empty($conf->propal->enabled))
- {
+ if (!empty($conf->propal->enabled)) {
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals");
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal ? $this->object->ref_propal : $langs->trans("NoContactForAnyProposal");
$i++;
}
- if (!empty($conf->contrat->enabled))
- {
+ if (!empty($conf->contrat->enabled)) {
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts");
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat ? $this->object->ref_contrat : $langs->trans("NoContactForAnyContract");
$i++;
}
- if (!empty($conf->facture->enabled))
- {
+ if (!empty($conf->facture->enabled)) {
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForInvoices");
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation ? $this->object->ref_facturation : $langs->trans("NoContactForAnyInvoice");
$i++;
}
// Dolibarr user
- if ($this->object->user_id)
- {
+ if ($this->object->user_id) {
$dolibarr_user = new User($this->db);
$result = $dolibarr_user->fetch($this->object->user_id);
$this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
- } else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess");
+ } else {
+ $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess");
+ }
}
- if ($action == 'view' || $action == 'delete')
- {
+ if ($action == 'view' || $action == 'delete') {
$this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id');
- if ($this->object->socid > 0)
- {
+ if ($this->object->socid > 0) {
$objsoc = new Societe($this->db);
$objsoc->fetch($this->object->socid);
@@ -243,14 +254,13 @@ abstract class ActionsContactCardCommon
$this->tpl['note'] = nl2br($this->object->note);
}
- if ($action == 'create_user')
- {
+ if ($action == 'create_user') {
// Full firstname and lastname separated with a dot : firstname.lastname
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$login = dol_buildlogin($this->object->lastname, $this->object->firstname);
- $generated_password = getRandomPassword(false);
+ $generated_password = getRandomPassword(false);
$password = $generated_password;
// Create a form array
@@ -297,12 +307,10 @@ abstract class ActionsContactCardCommon
$this->object->canvas = $_POST["canvas"];
// We set country_id, and country_code label of the chosen country
- if ($this->object->country_id)
- {
+ if ($this->object->country_id) {
$sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id;
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $this->db->fetch_object($resql);
} else {
dol_print_error($this->db);
diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php
index d399584b48d..846f7440f97 100644
--- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php
+++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php
@@ -40,11 +40,11 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
*/
public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
{
- $this->db = $db;
+ $this->db = $db;
$this->dirmodule = $dirmodule;
- $this->targetmodule = $targetmodule;
- $this->canvas = $canvas;
- $this->card = $card;
+ $this->targetmodule = $targetmodule;
+ $this->canvas = $canvas;
+ $this->card = $card;
}
/**
@@ -55,13 +55,19 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
*/
private function getTitle($action)
{
- global $langs;
+ global $langs, $conf;
$out = '';
- if ($action == 'view') $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contact") : $langs->trans("ContactAddress"));
- if ($action == 'edit') $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("EditContact") : $langs->trans("EditContactAddress"));
- if ($action == 'create') $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress"));
+ if ($action == 'view') {
+ $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contact") : $langs->trans("ContactAddress"));
+ }
+ if ($action == 'edit') {
+ $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("EditContact") : $langs->trans("EditContactAddress"));
+ }
+ if ($action == 'create') {
+ $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress"));
+ }
return $out;
}
@@ -89,8 +95,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
$this->tpl['error'] = $this->error;
$this->tpl['errors'] = $this->errors;
- if ($action == 'view')
- {
+ if ($action == 'view') {
// Card header
$head = contact_prepare_head($this->object);
$title = $this->getTitle($action);
@@ -106,14 +111,12 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
$this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1);
} else {
// Confirm delete contact
- if ($action == 'delete' && $user->rights->societe->contact->supprimer)
- {
+ if ($action == 'delete' && $user->rights->societe->contact->supprimer) {
$this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1);
}
}
- if ($action == 'list')
- {
+ if ($action == 'list') {
$this->LoadListDatas($limit, $offset, $sortfield, $sortorder);
}
}
diff --git a/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php
index 98a66e499b9..bd5cf24e195 100644
--- a/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php
+++ b/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php
@@ -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;
}
diff --git a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php
index 2c82a868ed4..41fbdb5def9 100644
--- a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php
+++ b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php
@@ -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;
}
diff --git a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php
index 43fd48e3ef0..c624eca4026 100644
--- a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php
+++ b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php
@@ -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;
}
@@ -30,8 +29,12 @@ echo $this->control->tpl['showhead'];
dol_htmloutput_errors($this->control->tpl['error'], $this->control->tpl['errors']);
-if (!empty($this->control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user'];
-if (!empty($this->control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?>
+if (!empty($this->control->tpl['action_create_user'])) {
+ echo $this->control->tpl['action_create_user'];
+}
+if (!empty($this->control->tpl['action_delete'])) {
+ echo $this->control->tpl['action_delete'];
+} ?>
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 943c704b17f..0def459d444 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -71,24 +71,26 @@ $socialnetworks = getArrayOfSocialNetworks();
$object->getCanvas($id);
$objcanvas = null;
$canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas"));
-if (!empty($canvas))
-{
+if (!empty($canvas)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
$objcanvas = new Canvas($db, $action);
$objcanvas->getCanvas('contact', 'contactcard', $canvas);
}
// Security check
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('contactcard', 'globalcard'));
-if ($id > 0) $object->fetch($id);
+if ($id > 0) {
+ $object->fetch($id);
+}
-if (!($object->id > 0) && $action == 'view')
-{
+if (!($object->id > 0) && $action == 'view') {
$langs->load("errors");
print($langs->trans('ErrorRecordNotFound'));
exit;
@@ -100,36 +102,32 @@ if (!($object->id > 0) && $action == 'view')
$parameters = array('id'=>$id, '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 (empty($reshook)) {
// Cancel
- if (GETPOST('cancel', 'alpha') && !empty($backtopage))
- {
+ if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
// Creation utilisateur depuis contact
- if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer)
- {
+ if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) {
// Recuperation contact actuel
$result = $object->fetch($id);
- if ($result > 0)
- {
+ if ($result > 0) {
$db->begin();
// Creation user
$nuser = new User($db);
$result = $nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha)
- if ($result > 0)
- {
+ if ($result > 0) {
$result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha)
- if ($result2)
- {
+ if ($result2) {
$db->commit();
} else {
$error = $nuser->error; $errors = $nuser->errors;
@@ -146,11 +144,9 @@ if (empty($reshook))
// Confirmation desactivation
- if ($action == 'disable')
- {
+ if ($action == 'disable') {
$object->fetch($id);
- if ($object->setstatus(0) < 0)
- {
+ if ($object->setstatus(0) < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
@@ -159,11 +155,9 @@ if (empty($reshook))
}
// Confirmation activation
- if ($action == 'enable')
- {
+ if ($action == 'enable') {
$object->fetch($id);
- if ($object->setstatus(1) < 0)
- {
+ if ($object->setstatus(1) < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
@@ -172,11 +166,12 @@ if (empty($reshook))
}
// Add contact
- if ($action == 'add' && $user->rights->societe->contact->creer)
- {
+ if ($action == 'add' && $user->rights->societe->contact->creer) {
$db->begin();
- if ($canvas) $object->canvas = $canvas;
+ if ($canvas) {
+ $object->canvas = $canvas;
+ }
$object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity);
$object->socid = GETPOST("socid", 'int');
@@ -221,8 +216,7 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
- if ($ret < 0)
- {
+ if ($ret < 0) {
$error++;
$action = 'create';
}
@@ -233,8 +227,7 @@ if (empty($reshook))
$action = 'create';
}
- if (!empty($object->email) && !isValidEMail($object->email))
- {
+ if (!empty($object->email) && !isValidEMail($object->email)) {
$langs->load("errors");
$error++;
$errors[] = $langs->trans("ErrorBadEMail", GETPOST('email', 'alpha'));
@@ -279,11 +272,13 @@ if (empty($reshook))
}
}
- if (empty($error) && $id > 0)
- {
+ if (empty($error) && $id > 0) {
$db->commit();
- if (!empty($backtopage)) $url = $backtopage;
- else $url = 'card.php?id='.$id;
+ if (!empty($backtopage)) {
+ $url = $backtopage;
+ } else {
+ $url = 'card.php?id='.$id;
+ }
header("Location: ".$url);
exit;
} else {
@@ -291,8 +286,7 @@ if (empty($reshook))
}
}
- if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer)
- {
+ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer) {
$result = $object->fetch($id);
$object->oldcopy = clone $object;
@@ -313,10 +307,8 @@ if (empty($reshook))
}
}
- if ($action == 'update' && empty($cancel) && $user->rights->societe->contact->creer)
- {
- if (!GETPOST("lastname", 'alpha'))
- {
+ if ($action == 'update' && empty($cancel) && $user->rights->societe->contact->creer) {
+ if (!GETPOST("lastname", 'alpha')) {
$error++; $errors = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
$action = 'edit';
}
@@ -327,16 +319,14 @@ if (empty($reshook))
$action = 'edit';
}
- if (!empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)) && !isValidEMail(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)))
- {
+ if (!empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)) && !isValidEMail(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) {
$langs->load("errors");
$error++;
$errors[] = $langs->trans("ErrorBadEMail", GETPOST('email', 'alpha'));
$action = 'edit';
}
- if (!$error)
- {
+ if (!$error) {
$contactid = GETPOST("contactid", 'int');
$object->fetch($contactid);
$object->fetchRoles($contactid);
@@ -344,27 +334,22 @@ if (empty($reshook))
// Photo save
$dir = $conf->societe->multidir_output[$object->entity]."/contact/".$object->id."/photos";
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
- if (GETPOST('deletephoto') && $object->photo)
- {
+ if (GETPOST('deletephoto') && $object->photo) {
$fileimg = $dir.'/'.$object->photo;
$dirthumbs = $dir.'/thumbs';
dol_delete_file($fileimg);
dol_delete_dir_recursive($dirthumbs);
$object->photo = '';
}
- if ($file_OK)
- {
- if (image_format_supported($_FILES['photo']['name']) > 0)
- {
+ if ($file_OK) {
+ if (image_format_supported($_FILES['photo']['name']) > 0) {
dol_mkdir($dir);
- if (@is_dir($dir))
- {
+ if (@is_dir($dir)) {
$newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
$result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
- if (!$result > 0)
- {
+ if (!$result > 0) {
$errors[] = "ErrorFailedToSaveFile";
} else {
$object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
@@ -377,8 +362,7 @@ if (empty($reshook))
$errors[] = "ErrorBadImageFormat";
}
} else {
- switch ($_FILES['photo']['error'])
- {
+ switch ($_FILES['photo']['error']) {
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
$errors[] = "ErrorFileSizeTooLarge";
@@ -433,10 +417,11 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
- if ($ret < 0) $error++;
+ if ($ret < 0) {
+ $error++;
+ }
- if (!$error)
- {
+ if (!$error) {
$result = $object->update($contactid, $user);
if ($result > 0) {
@@ -445,8 +430,7 @@ if (empty($reshook))
$object->setCategories($categories);
// Update mass emailing flag into table mailing_unsubscribe
- if (GETPOSTISSET('no_email') && $object->email)
- {
+ if (GETPOSTISSET('no_email') && $object->email) {
$no_email = GETPOST('no_email', 'int');
$result=$object->setNoEmail($no_email);
if ($result<0) {
@@ -465,31 +449,31 @@ if (empty($reshook))
}
}
- if (!$error && empty($errors))
- {
- if (!empty($backtopage))
- {
- header("Location: ".$backtopage);
- exit;
- }
+ if (!$error && empty($errors)) {
+ if (!empty($backtopage)) {
+ header("Location: ".$backtopage);
+ exit;
+ }
}
}
- if ($action == 'setprospectcontactlevel' && $user->rights->societe->contact->creer)
- {
+ if ($action == 'setprospectcontactlevel' && $user->rights->societe->contact->creer) {
$object->fetch($id);
$object->fk_prospectlevel = GETPOST('prospect_contact_level_id', 'alpha');
$result = $object->update($object->id, $user);
- if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
+ if ($result < 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
}
// set communication status
- if ($action == 'setstcomm')
- {
+ if ($action == 'setstcomm') {
$object->fetch($id);
$object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcommcontact');
$result = $object->update($object->id, $user);
- if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
+ if ($result < 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
}
// Actions to send emails
@@ -506,7 +490,9 @@ if (empty($reshook))
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
-if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname;
+if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
+ $title = $object->lastname;
+}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
@@ -515,24 +501,23 @@ $formcompany = new FormCompany($db);
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
-if ($socid > 0)
-{
+if ($socid > 0) {
$objsoc = new Societe($db);
$objsoc->fetch($socid);
}
-if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
-{
+if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// -----------------------------------------
// When used with CANVAS
// -----------------------------------------
- if (empty($object->error) && $id)
- {
- $object = new Contact($db);
- $result = $object->fetch($id);
- if ($result <= 0) dol_print_error('', $object->error);
- }
- $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
+ if (empty($object->error) && $id) {
+ $object = new Contact($db);
+ $result = $object->fetch($id);
+ if ($result <= 0) {
+ dol_print_error('', $object->error);
+ }
+ }
+ $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
$objcanvas->display_canvas($action); // Show template
} else {
// -----------------------------------------
@@ -540,20 +525,17 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// -----------------------------------------
// Confirm deleting contact
- if ($user->rights->societe->contact->supprimer)
- {
- if ($action == 'delete')
- {
+ if ($user->rights->societe->contact->supprimer) {
+ if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1);
}
}
/*
- * Onglets
- */
+ * Onglets
+ */
$head = array();
- if ($id > 0)
- {
+ if ($id > 0) {
// Si edition contact deja existant
$object = new Contact($db);
$res = $object->fetch($id, $user);
@@ -569,21 +551,18 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
}
- if ($user->rights->societe->contact->creer)
- {
- if ($action == 'create')
- {
+ if ($user->rights->societe->contact->creer) {
+ if ($action == 'create') {
/*
- * Fiche en mode creation
- */
+ * Fiche en mode creation
+ */
$object->canvas = $canvas;
$object->state_id = GETPOST("state_id");
// We set country_id, country_code and label for the selected country
$object->country_id = $_POST["country_id"] ?GETPOST("country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id);
- if ($object->country_id)
- {
+ if ($object->country_id) {
$tmparray = getCountry($object->country_id, 'all');
$object->country_code = $tmparray['code'];
$object->country = $tmparray['label'];
@@ -596,8 +575,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// Show errors
dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
- if ($conf->use_javascript_ajax)
- {
+ if ($conf->use_javascript_ajax) {
print "\n".''."\n";
}
- if (!GETPOSTISSET("no_email") && !empty($object->email))
- {
+ if (!GETPOSTISSET("no_email") && !empty($object->email)) {
$result=$object->getNoEmail();
if ($result<0) {
setEventMessages($object->error, $object->errors, 'errors');
@@ -821,7 +812,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print ''.$langs->trans("ContactByDefaultFor").' ';
print '';
$contactType = $object->listeTypeContacts('external', '', 1);
- print $form->multiselectarray('roles', $contactType);
+ print $form->multiselectarray('roles', $contactType, array(), 0, 0, 'minwidth500');
print ' ';
}
@@ -829,8 +820,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3);
$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', $parameters);
}
@@ -846,8 +836,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// Date To Birth
print ''.$langs->trans("DateOfBirth").' ';
$form = new Form($db);
- if ($object->birthday)
- {
+ if ($object->birthday) {
print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0);
} else {
print $form->selectDate('', 'birthday', 0, 0, 1, "perso", 1, 0);
@@ -855,8 +844,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print ' ';
print ''.$langs->trans("Alert").' : ';
- if ($object->birthday_alert)
- {
+ if ($object->birthday_alert) {
print ' ';
} else {
print ' ';
@@ -870,8 +858,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '';
print '
';
- if (!empty($backtopage))
- {
+ if (!empty($backtopage)) {
print ' ';
print '
';
} else {
@@ -883,12 +870,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print "";
} elseif ($action == 'edit' && !empty($id)) {
/*
- * Fiche en mode edition
- */
+ * Fiche en mode edition
+ */
// We set country_id, and country_code label of the chosen country
- if (GETPOSTISSET("country_id") || $object->country_id)
- {
+ if (GETPOSTISSET("country_id") || $object->country_id) {
$tmparray = getCountry($object->country_id, 'all');
$object->country_code = $tmparray['code'];
$object->country = $tmparray['label'];
@@ -900,8 +886,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// Show errors
dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
- if ($conf->use_javascript_ajax)
- {
+ if ($conf->use_javascript_ajax) {
print "\n".''."\n";
}
- if (!GETPOSTISSET("no_email") && !empty($object->email))
- {
+ if (!GETPOSTISSET("no_email") && !empty($object->email)) {
$result=$object->getNoEmail();
if ($result<0) {
setEventMessages($object->error, $object->errors, 'errors');
@@ -1145,36 +1128,31 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$parameters = array('colspan' => ' colspan="3"', 'cols'=> '3');
$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', $parameters);
}
$object->load_ref_elements();
- if (!empty($conf->commande->enabled))
- {
+ if (!empty($conf->commande->enabled)) {
print '
'.$langs->trans("ContactForOrders").' ';
print $object->ref_commande ? $object->ref_commande : $langs->trans("NoContactForAnyOrder");
print ' ';
}
- if (!empty($conf->propal->enabled))
- {
+ if (!empty($conf->propal->enabled)) {
print '
'.$langs->trans("ContactForProposals").' ';
print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal");
print ' ';
}
- if (!empty($conf->contrat->enabled))
- {
+ if (!empty($conf->contrat->enabled)) {
print '
'.$langs->trans("ContactForContracts").' ';
print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract");
print ' ';
}
- if (!empty($conf->facture->enabled))
- {
+ if (!empty($conf->facture->enabled)) {
print '
'.$langs->trans("ContactForInvoices").' ';
print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice");
print ' ';
@@ -1182,12 +1160,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// Login Dolibarr
print '
'.$langs->trans("DolibarrLogin").' ';
- if ($object->user_id)
- {
+ if ($object->user_id) {
$dolibarr_user = new User($db);
$result = $dolibarr_user->fetch($object->user_id);
print $dolibarr_user->getLoginUrl(1);
- } else print $langs->trans("NoDolibarrAccess");
+ } else {
+ print $langs->trans("NoDolibarrAccess");
+ }
print ' ';
// Photo
@@ -1199,7 +1178,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print "
\n";
}
print '
';
@@ -1226,8 +1207,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$action = 'presend';
}
- if (!empty($id) && $action != 'edit' && $action != 'create')
- {
+ if (!empty($id) && $action != 'edit' && $action != 'create') {
$objsoc = new Societe($db);
// View mode
@@ -1237,15 +1217,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print dol_get_fiche_head($head, 'card', $title, -1, 'contact');
- if ($action == 'create_user')
- {
+ if ($action == 'create_user') {
// Full firstname and lastname separated with a dot : firstname.lastname
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$login = dol_buildlogin($object->lastname, $object->firstname);
$generated_password = '';
- if (!$ldap_sid) // TODO ldap_sid ?
- {
+ if (!$ldap_sid) { // TODO ldap_sid ?
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$generated_password = getRandomPassword(false);
}
@@ -1258,10 +1236,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
//array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External')))
);
$text = $langs->trans("ConfirmCreateContact").'
';
- if (!empty($conf->societe->enabled))
- {
- if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser");
- else $text .= $langs->trans("UserWillBeInternalUser");
+ if (!empty($conf->societe->enabled)) {
+ if ($object->socid > 0) {
+ $text .= $langs->trans("UserWillBeExternalUser");
+ } else {
+ $text .= $langs->trans("UserWillBeInternalUser");
+ }
}
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes');
}
@@ -1269,13 +1249,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$linkback = '
'.$langs->trans("BackToList").' ';
$morehtmlref = '
';
- if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
- {
+ if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
$objsoc->fetch($object->socid);
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : ';
- if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
- else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
+ if ($objsoc->id > 0) {
+ $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
+ } else {
+ $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
+ }
}
$morehtmlref .= '
';
@@ -1297,16 +1279,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '
'.$langs->trans("PostOrFunction").' '.$object->poste.' ';
// Email
- if (!empty($conf->mailing->enabled))
- {
+ if (!empty($conf->mailing->enabled)) {
$langs->load("mails");
print '
'.$langs->trans("NbOfEMailingsSend").' ';
print ''.$object->getNbOfEMailings().' ';
}
// Unsubscribe opt-out
- if (!empty($conf->mailing->enabled))
- {
+ if (!empty($conf->mailing->enabled)) {
$result=$object->getNoEmail();
if ($result<0) {
setEventMessages($object->error, $object->errors, 'errors');
@@ -1324,8 +1304,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$object->fetch_thirdparty();
if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
- if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3)
- {
+ if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3) {
print '
';
print '
';
@@ -1336,7 +1315,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '
';
print '
';
if ($action == 'editlevel') {
@@ -1354,8 +1335,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '';
foreach ($object->cacheprospectstatus as $key => $val) {
$titlealt = 'default';
- if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label'];
- if ($object->stcomm_id != $val['id']) print '
id.'&stcomm='.$val['code'].'&action=setstcomm&token='.newToken().'">'.img_action($titlealt, $val['code'], $val['picto']).' ';
+ if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
+ $titlealt = $val['label'];
+ }
+ if ($object->stcomm_id != $val['id']) {
+ print '
id.'&stcomm='.$val['code'].'&action=setstcomm&token='.newToken().'">'.img_action($titlealt, $val['code'], $val['picto']).' ';
+ }
}
print '
';
@@ -1391,45 +1376,48 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$object->load_ref_elements();
- if (!empty($conf->propal->enabled))
- {
+ if (!empty($conf->propal->enabled)) {
print ''.$langs->trans("ContactForProposals").' ';
print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal");
print ' ';
}
- if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled))
- {
+ if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) {
print '';
- if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } else print $langs->trans("ContactForOrders");
+ if (!empty($conf->expedition->enabled)) {
+ print $langs->trans("ContactForOrdersOrShipments");
+ } else {
+ print $langs->trans("ContactForOrders");
+ }
print ' ';
$none = $langs->trans("NoContactForAnyOrder");
- if (!empty($conf->expedition->enabled)) { $none = $langs->trans("NoContactForAnyOrderOrShipments"); }
+ if (!empty($conf->expedition->enabled)) {
+ $none = $langs->trans("NoContactForAnyOrderOrShipments");
+ }
print $object->ref_commande ? $object->ref_commande : $none;
print ' ';
}
- if (!empty($conf->contrat->enabled))
- {
+ if (!empty($conf->contrat->enabled)) {
print ''.$langs->trans("ContactForContracts").' ';
print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract");
print ' ';
}
- if (!empty($conf->facture->enabled))
- {
+ if (!empty($conf->facture->enabled)) {
print ''.$langs->trans("ContactForInvoices").' ';
print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice");
print ' ';
}
print ''.$langs->trans("DolibarrLogin").' ';
- if ($object->user_id)
- {
+ if ($object->user_id) {
$dolibarr_user = new User($db);
$result = $dolibarr_user->fetch($object->user_id);
print $dolibarr_user->getLoginUrl(1);
- } else print $langs->trans("NoDolibarrAccess");
+ } else {
+ print $langs->trans("NoDolibarrAccess");
+ }
print ' ';
print '';
@@ -1452,11 +1440,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if (empty($reshook) && $action != 'presend')
- {
+ if (empty($reshook) && $action != 'presend') {
if (empty($user->socid)) {
- if (!empty($object->email))
- {
+ if (!empty($object->email)) {
$langs->load("mails");
print '';
} else {
@@ -1465,30 +1451,25 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
}
}
- if ($user->rights->societe->contact->creer)
- {
+ if ($user->rights->societe->contact->creer) {
print ''.$langs->trans('Modify').' ';
}
- if (!$object->user_id && $user->rights->user->user->creer)
- {
+ if (!$object->user_id && $user->rights->user->user->creer) {
print ''.$langs->trans("CreateDolibarrLogin").' ';
}
// Activer
- if ($object->statut == 0 && $user->rights->societe->contact->creer)
- {
+ if ($object->statut == 0 && $user->rights->societe->contact->creer) {
print ''.$langs->trans("Reactivate").' ';
}
// Desactiver
- if ($object->statut == 1 && $user->rights->societe->contact->creer)
- {
+ if ($object->statut == 1 && $user->rights->societe->contact->creer) {
print ''.$langs->trans("DisableUser").' ';
}
// Delete
- if ($user->rights->societe->contact->supprimer)
- {
+ if ($user->rights->societe->contact->supprimer) {
print ''.$langs->trans('Delete').' ';
}
}
@@ -1500,8 +1481,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$action = 'presend';
}
- if ($action != 'presend')
- {
+ if ($action != 'presend') {
print '';
print '
';
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index 94eb700ab92..0c7f3ac73aa 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -260,10 +260,25 @@ class Contact extends CommonObject
public $birthday;
public $default_lang;
- public $ref_facturation; // Reference number of invoice for which it is contact
- public $ref_contrat; // Nb de reference contrat pour lequel il est contact
- public $ref_commande; // Nb de reference commande pour lequel il est contact
- public $ref_propal; // Nb de reference propal pour lequel il est contact
+ /**
+ * @var int Number of invoices for which he is contact
+ */
+ public $ref_facturation;
+
+ /**
+ * @var int Number of contracts for which he is contact
+ */
+ public $ref_contrat;
+
+ /**
+ * @var int Number of orders for which he is contact
+ */
+ public $ref_commande;
+
+ /**
+ * @var int Number of proposals for which he is contact
+ */
+ public $ref_propal;
/**
* @var int user ID
@@ -412,9 +427,15 @@ class Contact extends CommonObject
$this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name);
$this->firstname = trim($this->firstname);
$this->setUpperOrLowerCase();
- if (empty($this->socid)) $this->socid = 0;
- if (empty($this->priv)) $this->priv = 0;
- if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request
+ if (empty($this->socid)) {
+ $this->socid = 0;
+ }
+ if (empty($this->priv)) {
+ $this->priv = 0;
+ }
+ if (empty($this->statut)) {
+ $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request
+ }
$this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
@@ -452,40 +473,35 @@ class Contact extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."socpeople");
- if (!$error)
- {
+ if (!$error) {
$result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ...
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
$this->error = $this->db->lasterror();
}
}
- if (!$error)
- {
+ if (!$error) {
$result = $this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
$this->error = $this->db->lasterror();
}
}
- if (!$error)
- {
+ if (!$error) {
// Call trigger
$result = $this->call_trigger('CONTACT_CREATE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return $this->id;
} else {
@@ -537,13 +553,20 @@ class Contact extends CommonObject
$this->town = (empty($this->town) ? '' : trim($this->town));
$this->setUpperOrLowerCase();
$this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
- if (empty($this->statut)) $this->statut = 0;
- if (empty($this->civility_code) && !is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility
+ if (empty($this->statut)) {
+ $this->statut = 0;
+ }
+ if (empty($this->civility_code) && !is_numeric($this->civility_id)) {
+ $this->civility_code = $this->civility_id; // For backward compatibility
+ }
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET ";
- if ($this->socid > 0) $sql .= " fk_soc='".$this->db->escape($this->socid)."',";
- elseif ($this->socid == -1) $sql .= " fk_soc=null,";
+ if ($this->socid > 0) {
+ $sql .= " fk_soc='".$this->db->escape($this->socid)."',";
+ } elseif ($this->socid == -1) {
+ $sql .= " fk_soc=null,";
+ }
$sql .= " civility='".$this->db->escape($this->civility_code)."'";
$sql .= ", lastname='".$this->db->escape($this->lastname)."'";
$sql .= ", firstname='".$this->db->escape($this->firstname)."'";
@@ -565,8 +588,7 @@ class Contact extends CommonObject
$sql .= ", phone_mobile = ".(isset($this->phone_mobile) ? "'".$this->db->escape($this->phone_mobile)."'" : "null");
$sql .= ", priv = '".$this->db->escape($this->priv)."'";
$sql .= ", fk_prospectcontactlevel = '".$this->db->escape($this->fk_prospectlevel)."'";
- if (isset($this->stcomm_id))
- {
+ if (isset($this->stcomm_id)) {
$sql .= ", fk_stcommcontact = ".($this->stcomm_id > 0 || $this->stcomm_id == -1 ? $this->stcomm_id : "0");
}
$sql .= ", statut = ".$this->db->escape($this->statut);
@@ -577,8 +599,7 @@ class Contact extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
unset($this->country_code);
unset($this->country);
unset($this->state_code);
@@ -587,111 +608,95 @@ class Contact extends CommonObject
$action = 'update';
// Actions on extra fields
- if (!$error)
- {
+ if (!$error) {
$result = $this->insertExtraFields();
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
if (!$error) {
$result = $this->updateRoles();
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
- if (!$error && $this->user_id > 0)
- {
+ if (!$error && $this->user_id > 0) {
// If contact is linked to a user
$tmpobj = new User($this->db);
$tmpobj->fetch($this->user_id);
$usermustbemodified = 0;
- if ($tmpobj->office_phone != $this->phone_pro)
- {
+ if ($tmpobj->office_phone != $this->phone_pro) {
$tmpobj->office_phone = $this->phone_pro;
$usermustbemodified++;
}
- if ($tmpobj->office_fax != $this->fax)
- {
+ if ($tmpobj->office_fax != $this->fax) {
$tmpobj->office_fax = $this->fax;
$usermustbemodified++;
}
- if ($tmpobj->address != $this->address)
- {
+ if ($tmpobj->address != $this->address) {
$tmpobj->address = $this->address;
$usermustbemodified++;
}
- if ($tmpobj->town != $this->town)
- {
+ if ($tmpobj->town != $this->town) {
$tmpobj->town = $this->town;
$usermustbemodified++;
}
- if ($tmpobj->zip != $this->zip)
- {
+ if ($tmpobj->zip != $this->zip) {
$tmpobj->zip = $this->zip;
$usermustbemodified++;
}
- if ($tmpobj->zip != $this->zip)
- {
+ if ($tmpobj->zip != $this->zip) {
$tmpobj->state_id = $this->state_id;
$usermustbemodified++;
}
- if ($tmpobj->country_id != $this->country_id)
- {
+ if ($tmpobj->country_id != $this->country_id) {
$tmpobj->country_id = $this->country_id;
$usermustbemodified++;
}
- if ($tmpobj->email != $this->email)
- {
+ if ($tmpobj->email != $this->email) {
$tmpobj->email = $this->email;
$usermustbemodified++;
}
- if (!empty(array_diff($tmpobj->socialnetworks, $this->socialnetworks)))
- {
+ if (!empty(array_diff($tmpobj->socialnetworks, $this->socialnetworks))) {
$tmpobj->socialnetworks = $this->socialnetworks;
$usermustbemodified++;
}
- // if ($tmpobj->skype != $this->skype)
- // {
+ // if ($tmpobj->skype != $this->skype) {
// $tmpobj->skype = $this->skype;
// $usermustbemodified++;
// }
- // if ($tmpobj->twitter != $this->twitter)
- // {
+ // if ($tmpobj->twitter != $this->twitter) {
// $tmpobj->twitter = $this->twitter;
// $usermustbemodified++;
// }
- // if ($tmpobj->facebook != $this->facebook)
- // {
+ // if ($tmpobj->facebook != $this->facebook) {
// $tmpobj->facebook = $this->facebook;
// $usermustbemodified++;
// }
- // if ($tmpobj->linkedin != $this->linkedin)
- // {
+ // if ($tmpobj->linkedin != $this->linkedin) {
// $tmpobj->linkedin = $this->linkedin;
// $usermustbemodified++;
// }
- if ($usermustbemodified)
- {
+ if ($usermustbemodified) {
$result = $tmpobj->update($user, 0, 1, 1, 1);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
}
}
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('CONTACT_MODIFY', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return 1;
} else {
@@ -723,9 +728,13 @@ class Contact extends CommonObject
// phpcs:enable
global $conf;
$dn = '';
- if ($mode == 0) $dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN;
- elseif ($mode == 1) $dn = $conf->global->LDAP_CONTACT_DN;
- elseif ($mode == 2) $dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS];
+ if ($mode == 0) {
+ $dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN;
+ } elseif ($mode == 1) {
+ $dn = $conf->global->LDAP_CONTACT_DN;
+ } elseif ($mode == 2) {
+ $dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS];
+ }
return $dn;
}
@@ -750,34 +759,69 @@ class Contact extends CommonObject
$this->fullname = $this->getFullName($langs);
// Fields
- if ($this->fullname && !empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname;
- if ($this->lastname && !empty($conf->global->LDAP_CONTACT_FIELD_NAME)) $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname;
- if ($this->firstname && !empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname;
+ if ($this->fullname && !empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname;
+ }
+ if ($this->lastname && !empty($conf->global->LDAP_CONTACT_FIELD_NAME)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname;
+ }
+ if ($this->firstname && !empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname;
+ }
- if ($this->poste) $info["title"] = $this->poste;
+ if ($this->poste) {
+ $info["title"] = $this->poste;
+ }
if ($this->socid > 0) {
$soc = new Societe($this->db);
$soc->fetch($this->socid);
$info[$conf->global->LDAP_CONTACT_FIELD_COMPANY] = $soc->name;
- if ($soc->client == 1) $info["businessCategory"] = "Customers";
- if ($soc->client == 2) $info["businessCategory"] = "Prospects";
- if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers";
+ if ($soc->client == 1) {
+ $info["businessCategory"] = "Customers";
+ }
+ if ($soc->client == 2) {
+ $info["businessCategory"] = "Prospects";
+ }
+ if ($soc->fournisseur == 1) {
+ $info["businessCategory"] = "Suppliers";
+ }
+ }
+ if ($this->address && !empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address;
+ }
+ if ($this->zip && !empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip;
+ }
+ if ($this->town && !empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town;
+ }
+ if ($this->country_code && !empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code;
+ }
+ if ($this->phone_pro && !empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro;
+ }
+ if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso;
+ }
+ if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile;
+ }
+ if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax;
+ }
+ if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype;
+ }
+ if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2);
+ }
+ if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email;
}
- if ($this->address && !empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address;
- if ($this->zip && !empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip;
- if ($this->town && !empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town;
- if ($this->country_code && !empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code;
- if ($this->phone_pro && !empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro;
- if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso;
- if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile;
- if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax;
- if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype;
- if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2);
- if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email;
- if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
- {
+ if ($conf->global->LDAP_SERVER_TYPE == 'egroupware') {
$info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware
$info['uidnumber'] = $this->id;
@@ -796,8 +840,12 @@ class Contact extends CommonObject
$info["phpgwContactOwner"] = $this->egroupware_id;
- if ($this->email) $info["rfc822Mailbox"] = $this->email;
- if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
+ if ($this->email) {
+ $info["rfc822Mailbox"] = $this->email;
+ }
+ if ($this->phone_mobile) {
+ $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
+ }
}
return $info;
@@ -825,13 +873,14 @@ class Contact extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET";
$sql .= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null");
$sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null");
- if ($user) $sql .= ", fk_user_modif=".$user->id;
+ if ($user) {
+ $sql .= ", fk_user_modif=".$user->id;
+ }
$sql .= " WHERE rowid=".$this->db->escape($id);
dol_syslog(get_class($this)."::update_perso this->birthday=".$this->birthday." -", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$error++;
$this->error = $this->db->lasterror();
}
@@ -866,7 +915,9 @@ class Contact extends CommonObject
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('CONTACT_MODIFY', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
@@ -897,8 +948,7 @@ class Contact extends CommonObject
dol_syslog(get_class($this)."::fetch id=".$id." ref_ext=".$ref_ext." email=".$email, LOG_DEBUG);
- if (empty($id) && empty($ref_ext) && empty($email))
- {
+ if (empty($id) && empty($ref_ext) && empty($email)) {
$this->error = 'BadParameter';
return -1;
}
@@ -927,8 +977,9 @@ class Contact extends CommonObject
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcommcontact as st ON c.fk_stcommcontact = st.id';
- if ($id) $sql .= " WHERE c.rowid = ".((int) $id);
- else {
+ if ($id) {
+ $sql .= " WHERE c.rowid = ".((int) $id);
+ } else {
$sql .= " WHERE c.entity IN (".getEntity($this->element).")";
if ($ref_ext) {
$sql .= " AND c.ref_ext = '".$this->db->escape($ref_ext)."'";
@@ -939,17 +990,14 @@ class Contact extends CommonObject
}
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $this->db->num_rows($resql);
- if ($num > 1)
- {
+ if ($num > 1) {
$this->error = 'Fetch found several records. Rename one of contact to avoid duplicate.';
dol_syslog($this->error, LOG_ERR);
return 2;
- } elseif ($num) // $num = 1
- {
+ } elseif ($num) { // $num = 1
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@@ -1021,10 +1069,8 @@ class Contact extends CommonObject
$sql .= " WHERE u.fk_socpeople = ".$this->id;
$resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
+ if ($resql) {
+ if ($this->db->num_rows($resql)) {
$uobj = $this->db->fetch_object($resql);
$this->user_id = $uobj->rowid;
@@ -1040,17 +1086,14 @@ class Contact extends CommonObject
$this->fetch_optionals();
// Load also alerts of this user
- if ($user)
- {
+ if ($user) {
$sql = "SELECT fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."user_alert";
$sql .= " WHERE fk_user = ".$user->id." AND fk_contact = ".$this->db->escape($id);
$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->birthday_alert = 1;
@@ -1093,11 +1136,9 @@ class Contact extends CommonObject
{
unset($this->gender);
- if (in_array($this->civility_id, array('MR')) || in_array($this->civility_code, array('MR')))
- {
+ if (in_array($this->civility_id, array('MR')) || in_array($this->civility_code, array('MR'))) {
$this->gender = 'man';
- } elseif (in_array($this->civility_id, array('MME', 'MLE')) || in_array($this->civility_code, array('MME', 'MLE')))
- {
+ } elseif (in_array($this->civility_id, array('MME', 'MLE')) || in_array($this->civility_code, array('MME', 'MLE'))) {
$this->gender = 'woman';
}
}
@@ -1126,16 +1167,18 @@ class Contact extends CommonObject
dol_syslog(get_class($this)."::load_ref_elements", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
- while ($obj = $this->db->fetch_object($resql))
- {
- if ($obj->nb)
- {
- if ($obj->element == 'facture') $this->ref_facturation = $obj->nb;
- elseif ($obj->element == 'contrat') $this->ref_contrat = $obj->nb;
- elseif ($obj->element == 'commande') $this->ref_commande = $obj->nb;
- elseif ($obj->element == 'propal') $this->ref_propal = $obj->nb;
+ if ($resql) {
+ while ($obj = $this->db->fetch_object($resql)) {
+ if ($obj->nb) {
+ if ($obj->element == 'facture') {
+ $this->ref_facturation = $obj->nb;
+ } elseif ($obj->element == 'contrat') {
+ $this->ref_contrat = $obj->nb;
+ } elseif ($obj->element == 'commande') {
+ $this->ref_commande = $obj->nb;
+ } elseif ($obj->element == 'propal') {
+ $this->ref_propal = $obj->nb;
+ }
}
}
$this->db->free($resql);
@@ -1160,8 +1203,7 @@ class Contact extends CommonObject
$this->db->begin();
- if (!$error)
- {
+ if (!$error) {
// Get all rowid of element_contact linked to a type that is link to llx_socpeople
$sql = "SELECT ec.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."element_contact ec,";
@@ -1171,21 +1213,18 @@ class Contact extends CommonObject
$sql .= " AND tc.source='external'";
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
- while ($i < $num && !$error)
- {
+ while ($i < $num && !$error) {
$obj = $this->db->fetch_object($resql);
$sqldel = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sqldel .= " WHERE rowid = ".$obj->rowid;
dol_syslog(__METHOD__, LOG_DEBUG);
$result = $this->db->query($sqldel);
- if (!$result)
- {
+ if (!$result) {
$error++;
$this->error = $this->db->error().' sql='.$sqldel;
}
@@ -1198,56 +1237,48 @@ class Contact extends CommonObject
}
}
- if (!$error)
- {
+ if (!$error) {
// Remove Roles
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople = ".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$error++;
$this->error .= $this->db->lasterror();
$errorflag = -1;
}
}
- if (!$error)
- {
+ if (!$error) {
// Remove Roles
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople = ".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$error++;
$this->error .= $this->db->lasterror();
$errorflag = -1;
}
}
- if (!$error)
- {
+ if (!$error) {
// Remove category
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_contact WHERE fk_socpeople = ".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$error++;
$this->error .= $this->db->lasterror();
$errorflag = -1;
}
}
- if (!$error)
- {
+ if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople";
$sql .= " WHERE rowid=".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG);
$result = $this->db->query($sql);
- if (!$result)
- {
+ if (!$result) {
$error++;
$this->error = $this->db->error().' sql='.$sql;
}
@@ -1257,19 +1288,21 @@ class Contact extends CommonObject
if (!$error) {
// For avoid conflicts if trigger used
$result = $this->deleteExtraFields();
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
}
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('CONTACT_DELETE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return 1;
} else {
@@ -1294,10 +1327,8 @@ class Contact extends CommonObject
$sql .= " WHERE c.rowid = ".$this->db->escape($id);
$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->id = $obj->rowid;
@@ -1337,8 +1368,7 @@ class Contact extends CommonObject
$sql .= " AND m.entity IN (".getEntity($this->element).") AND mc.statut NOT IN (-1,0)"; // -1 error, 0 not sent, 1 sent with success
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $this->db->fetch_object($resql);
$nb = $obj->nb;
@@ -1368,8 +1398,7 @@ class Contact extends CommonObject
$result = ''; $label = '';
- if (!empty($this->photo) && class_exists('Form'))
- {
+ if (!empty($this->photo) && class_exists('Form')) {
$label .= '
';
$label .= Form::showphoto('contact', $this, 0, 40, 0, '', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip.
$label .= '
';
@@ -1379,67 +1408,83 @@ class Contact extends CommonObject
$label .= ' '.$this->getLibStatut(4);
$label .= '
'.$langs->trans("Name").': '.$this->getFullName($langs);
//if ($this->civility_id) $label.= '
' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code
- if (!empty($this->poste)) $label .= '
'.$langs->trans("Poste").': '.$this->poste;
+ if (!empty($this->poste)) {
+ $label .= '
'.$langs->trans("Poste").': '.$this->poste;
+ }
$label .= '
'.$langs->trans("EMail").': '.$this->email;
$phonelist = array();
$country_code = empty($this->country_code) ? '': $this->country_code;
- if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $country_code, $this->id, 0, '', ' ', 'phone');
- if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $country_code, $this->id, 0, '', ' ', 'mobile');
- if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $country_code, $this->id, 0, '', ' ', 'phone');
+ if ($this->phone_pro) {
+ $phonelist[] = dol_print_phone($this->phone_pro, $country_code, $this->id, 0, '', ' ', 'phone');
+ }
+ if ($this->phone_mobile) {
+ $phonelist[] = dol_print_phone($this->phone_mobile, $country_code, $this->id, 0, '', ' ', 'mobile');
+ }
+ if ($this->phone_perso) {
+ $phonelist[] = dol_print_phone($this->phone_perso, $country_code, $this->id, 0, '', ' ', 'phone');
+ }
$label .= '
'.$langs->trans("Phone").': '.implode(' ', $phonelist);
$label .= '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs);
$url = DOL_URL_ROOT.'/contact/card.php?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';
+ }
}
$url .= $moreparam;
$linkclose = "";
if (empty($notooltip)) {
- if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
- {
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowContact");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
- $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
- $linkclose .= ' class="classfortooltip"';
+ $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose .= ' class="classfortooltip"';
- /*
- $hookmanager->initHooks(array('contactdao'));
- $parameters=array('id'=>$this->id);
- $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
- if ($reshook > 0) $linkclose = $hookmanager->resPrint;
- */
+ /*
+ $hookmanager->initHooks(array('contactdao'));
+ $parameters=array('id'=>$this->id);
+ $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook > 0) $linkclose = $hookmanager->resPrint;
+ */
}
$linkstart = '
';
$linkend = ' ';
- if ($option == 'xxx')
- {
+ if ($option == 'xxx') {
$linkstart = '
';
$linkend = ' ';
}
$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 .= ($maxlen ?dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs));
+ 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 .= ($maxlen ?dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs));
+ }
$result .= $linkend;
global $action;
$hookmanager->initHooks(array('contactdao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook > 0) $result = $hookmanager->resPrint;
- else $result .= $hookmanager->resPrint;
+ if ($reshook > 0) {
+ $result = $hookmanager->resPrint;
+ } else {
+ $result .= $hookmanager->resPrint;
+ }
return $result;
}
@@ -1454,7 +1499,9 @@ class Contact extends CommonObject
global $langs;
$code = ($this->civility_code ? $this->civility_code : (!empty($this->civility_id) ? $this->civility : (!empty($this->civilite) ? $this->civilite : '')));
- if (empty($code)) return '';
+ if (empty($code)) {
+ return '';
+ }
$langs->load("dict");
return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code);
@@ -1498,7 +1545,9 @@ class Contact extends CommonObject
);
$statusType = 'status4';
- if ($status == 0 || $status == 5) $statusType = 'status5';
+ if ($status == 0 || $status == 5) {
+ $statusType = 'status5';
+ }
$label = $langs->trans($labelStatus[$status]);
$labelshort = $langs->trans($labelStatusShort[$status]);
@@ -1518,8 +1567,11 @@ class Contact extends CommonObject
{
// phpcs:enable
global $langs;
- if ($status == '1') return $langs->trans('ContactPrivate');
- else return $langs->trans('ContactPublic');
+ if ($status == '1') {
+ return $langs->trans('ContactPrivate');
+ } else {
+ return $langs->trans('ContactPublic');
+ }
}
@@ -1538,7 +1590,9 @@ class Contact extends CommonObject
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
- if ($obj) $socid = $obj->rowid;
+ if ($obj) {
+ $socid = $obj->rowid;
+ }
}
// Initialise parameters
@@ -1583,8 +1637,11 @@ class Contact extends CommonObject
$error = 0;
// Check parameters
- if ($this->statut == $status) return 0;
- else $this->statut = $status;
+ if ($this->statut == $status) {
+ return 0;
+ } else {
+ $this->statut = $status;
+ }
$this->db->begin();
@@ -1595,16 +1652,16 @@ class Contact extends CommonObject
$result = $this->db->query($sql);
dol_syslog(get_class($this)."::setstatus", LOG_DEBUG);
- if ($result)
- {
+ if ($result) {
// Call trigger
$result = $this->call_trigger('CONTACT_ENABLEDISABLE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if ($error)
- {
+ if ($error) {
$this->db->rollback();
return -$error;
} else {
@@ -1716,12 +1773,10 @@ class Contact extends CommonObject
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $this->db->fetch_object($resql);
$tab[] = array('fk_socpeople'=>$obj->id, 'type_contact'=>$obj->fk_c_type_contact);
@@ -1749,11 +1804,13 @@ class Contact extends CommonObject
$error = 0;
- if (!isset($this->roles)) return; // Avoid to loose roles when property not set
+ if (!isset($this->roles)) {
+ return; // Avoid to loose roles when property not set
+ }
$this->db->begin();
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople=".$this->id." AND entity IN (".getEntity("societe_contact").")";
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople=".((int) $this->id)." AND entity IN (".getEntity("societe_contact").")";
$result = $this->db->query($sql);
if (!$result) {
@@ -1791,8 +1848,7 @@ class Contact extends CommonObject
$sql .= ")";
$result = $this->db->query($sql);
- if (!$result)
- {
+ if (!$result) {
$this->errors[] = $this->db->lasterror().' sql='.$sql;
$error++;
}
@@ -1821,12 +1877,13 @@ class Contact extends CommonObject
global $langs;
$sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcommcontact";
- if ($active >= 0) $sql .= " WHERE active = ".$active;
+ if ($active >= 0) {
+ $sql .= " WHERE active = ".$active;
+ }
$resql = $this->db->query($sql);
$num = $this->db->num_rows($resql);
$i = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $this->db->fetch_object($resql);
$this->cacheprospectstatus[$obj->id] = array('id' => $obj->id, 'code' => $obj->code, 'label' => ($langs->trans("ST_".strtoupper($obj->code)) == "ST_".strtoupper($obj->code)) ? $obj->label : $langs->trans("ST_".strtoupper($obj->code)), 'picto' => $obj->picto);
$i++;
@@ -1856,8 +1913,7 @@ class Contact extends CommonObject
$lib = $langs->trans("ProspectLevel".$fk_prospectlevel);
// If lib not found in language file, we get label from cache/databse
- if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel))
- {
+ if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel)) {
$lib = $langs->getLabelFromKey($this->db, $fk_prospectlevel, 'c_prospectlevel', 'code', 'label');
}
return $lib;
@@ -1906,36 +1962,48 @@ class Contact extends CommonObject
global $langs;
$langs->load('customers');
- if ($mode == 2)
- {
- if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1");
- elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0");
- elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1");
- elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2");
- elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3");
- else {
+ if ($mode == 2) {
+ if ($statut == '-1' || $statut == 'ST_NO') {
+ return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1");
+ } elseif ($statut == '0' || $statut == 'ST_NEVER') {
+ return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0");
+ } elseif ($statut == '1' || $statut == 'ST_TODO') {
+ return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1");
+ } elseif ($statut == '2' || $statut == 'ST_PEND') {
+ return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2");
+ } elseif ($statut == '3' || $statut == 'ST_DONE') {
+ return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3");
+ } else {
return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label);
}
}
- if ($mode == 3)
- {
- if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto);
- elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto);
- elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto);
- elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto);
- elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto);
- else {
+ if ($mode == 3) {
+ if ($statut == '-1' || $statut == 'ST_NO') {
+ return img_action($langs->trans("StatusProspect-1"), -1, $picto);
+ } elseif ($statut == '0' || $statut == 'ST_NEVER') {
+ return img_action($langs->trans("StatusProspect0"), 0, $picto);
+ } elseif ($statut == '1' || $statut == 'ST_TODO') {
+ return img_action($langs->trans("StatusProspect1"), 1, $picto);
+ } elseif ($statut == '2' || $statut == 'ST_PEND') {
+ return img_action($langs->trans("StatusProspect2"), 2, $picto);
+ } elseif ($statut == '3' || $statut == 'ST_DONE') {
+ return img_action($langs->trans("StatusProspect3"), 3, $picto);
+ } else {
return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto);
}
}
- if ($mode == 4)
- {
- if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1");
- elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0");
- elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1");
- elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2");
- elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3");
- else {
+ if ($mode == 4) {
+ if ($statut == '-1' || $statut == 'ST_NO') {
+ return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1");
+ } elseif ($statut == '0' || $statut == 'ST_NEVER') {
+ return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0");
+ } elseif ($statut == '1' || $statut == 'ST_TODO') {
+ return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1");
+ } elseif ($statut == '2' || $statut == 'ST_PEND') {
+ return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2");
+ } elseif ($statut == '3' || $statut == 'ST_DONE') {
+ return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3");
+ } else {
return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label);
}
}
@@ -1955,24 +2023,19 @@ class Contact extends CommonObject
$error = 0;
// Update mass emailing flag into table mailing_unsubscribe
- if ($this->email)
- {
+ if ($this->email) {
$this->db->begin();
- if ($no_email)
- {
+ if ($no_email) {
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$this->db->escape($this->email)."'";
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $this->db->fetch_object($resql);
$noemail = $obj->nb;
- if (empty($noemail))
- {
+ if (empty($noemail)) {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$this->db->escape($this->email)."', ".$this->db->escape(getEntity('mailing', 0)).", '".$this->db->idate(dol_now())."')";
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$error++;
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
@@ -1986,8 +2049,7 @@ class Contact extends CommonObject
} else {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$this->db->escape($this->email)."' AND entity = ".$this->db->escape(getEntity('mailing', 0));
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$error++;
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
@@ -2015,8 +2077,7 @@ class Contact extends CommonObject
*/
public function getNoEmail()
{
- if ($this->email)
- {
+ if ($this->email) {
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($this->email)."'";
$resql = $this->db->query($sql);
if ($resql) {
diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php
index da00374cc2a..1e0f5b06094 100644
--- a/htdocs/contact/consumption.php
+++ b/htdocs/contact/consumption.php
@@ -37,8 +37,12 @@ $id = GETPOST('id', 'int');
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
$object = new Contact($db);
-if ($id > 0) $object->fetch($id);
-if (empty($object->thirdparty)) $object->fetch_thirdparty();
+if ($id > 0) {
+ $object->fetch($id);
+}
+if (empty($object->thirdparty)) {
+ $object->fetch_thirdparty();
+}
$socid = $object->thirdparty->id;
// Sort & Order fields
@@ -46,12 +50,18 @@ $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");
@@ -60,8 +70,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 = '';
@@ -84,7 +93,9 @@ $hookmanager->initHooks(array('consumptioncontact'));
$parameters = array('id'=>$id);
$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');
+}
/*
@@ -99,8 +110,7 @@ $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("C
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
-if (empty($id))
-{
+if (empty($id)) {
dol_print_error($db);
exit;
}
@@ -111,13 +121,15 @@ print dol_get_fiche_head($head, 'consumption', $langs->trans("ContactsAddresses"
$linkback = '
'.$langs->trans("BackToList").' ';
$morehtmlref = '
';
-if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
-{
+if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
$objsoc->fetch($socid);
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : ';
- if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
- else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
+ if ($objsoc->id > 0) {
+ $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
+ } else {
+ $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
+ }
}
$morehtmlref .= '
';
@@ -133,22 +145,34 @@ print '
'.$langs->trans("UserTitle").' ';
print $object->getCivilityLabel();
print ' ';
-if ($object->thirdparty->client)
-{
+if ($object->thirdparty->client) {
$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 ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
+if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) {
+ $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
+}
-if ($object->thirdparty->fournisseur)
-{
+if ($object->thirdparty->fournisseur) {
$thirdTypeArray['supplier'] = $langs->trans("supplier");
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders');
+ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) {
+ $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
+ }
+ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) {
+ $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders');
+ }
// There no contact type for supplier proposals
// if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals');
@@ -166,8 +190,7 @@ print '
'."\n";
- if (empty($id))
- {
+ if (empty($id)) {
$hidegeneratedfilelistifempty = 1;
- if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
+ if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
+ $hidegeneratedfilelistifempty = 0;
+ }
// Show list of available documents
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
diff --git a/htdocs/expensereport/note.php b/htdocs/expensereport/note.php
index ebb66ce42fd..b0156c6a475 100644
--- a/htdocs/expensereport/note.php
+++ b/htdocs/expensereport/note.php
@@ -41,26 +41,29 @@ $childids = $user->getAllChildIds(1);
// Security check
$socid = 0;
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'expensereport', $id, 'expensereport');
$object = new ExpenseReport($db);
-if (!$object->fetch($id, $ref) > 0)
-{
+if (!$object->fetch($id, $ref) > 0) {
dol_print_error($db);
}
$permissionnote = $user->rights->expensereport->creer; // Used by the include of actions_setnotes.inc.php
-if ($object->id > 0)
-{
+if ($object->id > 0) {
// Check current user can read this expense report
$canread = 0;
- if (!empty($user->rights->expensereport->readall)) $canread = 1;
- if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) $canread = 1;
- if (!$canread)
- {
+ if (!empty($user->rights->expensereport->readall)) {
+ $canread = 1;
+ }
+ if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) {
+ $canread = 1;
+ }
+ if (!$canread) {
accessforbidden();
}
}
@@ -82,8 +85,7 @@ llxHeader("", $title, $helpurl);
$form = new Form($db);
-if ($id > 0 || !empty($ref))
-{
+if ($id > 0 || !empty($ref)) {
$object = new ExpenseReport($db);
$object->fetch($id, $ref);
$object->info($object->id);
diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php
index 14c95f2d68a..608309ceee0 100644
--- a/htdocs/expensereport/payment/card.php
+++ b/htdocs/expensereport/payment/card.php
@@ -26,7 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php';
-if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+if (!empty($conf->banque->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+}
// Load translation files required by the page
$langs->loadLangs(array('bills', 'banks', 'companies', 'trips'));
@@ -36,16 +38,19 @@ $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm');
// Security check
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
// TODO Add rule to restrict access payment
//$result = restrictedArea($user, 'facture', $id,'');
$object = new PaymentExpenseReport($db);
-if ($id > 0)
-{
+if ($id > 0) {
$result = $object->fetch($id);
- if (!$result) dol_print_error($db, 'Failed to get payment id '.$id);
+ if (!$result) {
+ dol_print_error($db, 'Failed to get payment id '.$id);
+ }
}
@@ -54,13 +59,11 @@ if ($id > 0)
*/
// Delete payment
-if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expensereport->supprimer)
-{
+if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expensereport->supprimer) {
$db->begin();
$result = $object->delete($user);
- if ($result > 0)
- {
+ if ($result > 0) {
$db->commit();
header("Location: ".DOL_URL_ROOT."/expensereport/index.php");
exit;
@@ -86,8 +89,7 @@ print dol_get_fiche_head($head, 'payment', $langs->trans("ExpenseReportPayment")
/*
* Confirm deleting of the payment
*/
-if ($action == 'delete')
-{
+if ($action == 'delete') {
print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
}
@@ -118,14 +120,11 @@ print '
'.$langs->trans('Note').' '.nl2
$disable_delete = 0;
// Bank account
-if (!empty($conf->banque->enabled))
-{
- if ($object->bank_account)
- {
+if (!empty($conf->banque->enabled)) {
+ if ($object->bank_account) {
$bankline = new AccountLine($db);
$bankline->fetch($object->bank_line);
- if ($bankline->rappro)
- {
+ if ($bankline->rappro) {
$disable_delete = 1;
$title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment"));
}
@@ -167,8 +166,7 @@ $sql .= ' AND per.rowid = '.$id;
dol_syslog("expensereport/payment/card.php", LOG_DEBUG);
$resql = $db->query($sql);
-if ($resql)
-{
+if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
@@ -186,10 +184,8 @@ if ($resql)
print ' '.$langs->trans('Status').' ';
print "\n";
- if ($num > 0)
- {
- while ($i < $num)
- {
+ if ($num > 0) {
+ while ($i < $num) {
$objp = $db->fetch_object($resql);
print '
';
@@ -216,8 +212,7 @@ if ($resql)
print " \n";
- if ($objp->paid == 1) // If at least one invoice is paid, disable delete
- {
+ if ($objp->paid == 1) { // If at least one invoice is paid, disable delete
$disable_delete = 2;
$title_button = $langs->trans("CantRemovePaymentWithOneInvoicePaid");
}
@@ -242,12 +237,9 @@ if ($resql)
*/
print '
';
-if ($action == '')
-{
- if ($user->rights->expensereport->supprimer)
- {
- if (!$disable_delete)
- {
+if ($action == '') {
+ if ($user->rights->expensereport->supprimer) {
+ if (!$disable_delete) {
print '
'.$langs->trans('Delete').' ';
} else {
print '
'.$langs->trans('Delete').' ';
diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php
index b66103f38f5..926559769b4 100644
--- a/htdocs/expensereport/payment/payment.php
+++ b/htdocs/expensereport/payment/payment.php
@@ -39,8 +39,7 @@ $accountid = GETPOST('accountid', 'int');
// Security check
$socid = 0;
-if ($user->socid > 0)
-{
+if ($user->socid > 0) {
$socid = $user->socid;
}
@@ -49,12 +48,10 @@ if ($user->socid > 0)
* Actions
*/
-if ($action == 'add_payment')
-{
+if ($action == 'add_payment') {
$error = 0;
- if ($_POST["cancel"])
- {
+ if ($_POST["cancel"]) {
$loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$id;
header("Location: ".$loc);
exit;
@@ -62,53 +59,44 @@ if ($action == 'add_payment')
$expensereport = new ExpenseReport($db);
$result = $expensereport->fetch($id, $ref);
- if (!$result)
- {
+ if (!$result) {
$error++;
setEventMessages($expensereport->error, $expensereport->errors, 'errors');
}
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
- if (!($_POST["fk_typepayment"] > 0))
- {
+ if (!($_POST["fk_typepayment"] > 0)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors');
$error++;
}
- if ($datepaid == '')
- {
+ if ($datepaid == '') {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
$error++;
}
- if (!empty($conf->banque->enabled) && !($accountid > 0))
- {
+ if (!empty($conf->banque->enabled) && !($accountid > 0)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToDebit")), null, 'errors');
$error++;
}
- if (!$error)
- {
+ if (!$error) {
$paymentid = 0;
$total = 0;
// Read possible payments
- foreach ($_POST as $key => $value)
- {
- if (substr($key, 0, 7) == 'amount_')
- {
+ foreach ($_POST as $key => $value) {
+ if (substr($key, 0, 7) == 'amount_') {
$amounts[$expensereport->fk_user_author] = price2num($_POST[$key]);
$total += price2num($_POST[$key]);
}
}
- if (count($amounts) <= 0)
- {
+ if (count($amounts) <= 0) {
$error++;
$errmsg = 'ErrorNoPaymentDefined';
}
- if (!$error)
- {
+ if (!$error) {
$db->begin();
// Create a line of payments
@@ -121,21 +109,17 @@ if ($action == 'add_payment')
$payment->num_payment = GETPOST("num_payment", 'alphanothtml');
$payment->note_public = GETPOST("note_public", 'restricthtml');
- if (!$error)
- {
+ if (!$error) {
$paymentid = $payment->create($user);
- if ($paymentid < 0)
- {
+ if ($paymentid < 0) {
setEventMessages($payment->error, $payment->errors, 'errors');
$error++;
}
}
- if (!$error)
- {
+ if (!$error) {
$result = $payment->addPaymentToBank($user, 'payment_expensereport', '(ExpenseReportPayment)', $accountid, '', '');
- if (!$result > 0)
- {
+ if (!$result > 0) {
setEventMessages($payment->error, $payment->errors, 'errors');
$error++;
}
@@ -152,8 +136,7 @@ if ($action == 'add_payment')
}
}
- if (!$error)
- {
+ if (!$error) {
$db->commit();
$loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$id;
header('Location: '.$loc);
@@ -178,8 +161,7 @@ $form = new Form($db);
// Form to create expense report payment
-if ($action == 'create' || empty($action))
-{
+if ($action == 'create' || empty($action)) {
$expensereport = new ExpenseReport($db);
$expensereport->fetch($id, $ref);
@@ -226,8 +208,7 @@ if ($action == 'create' || empty($action))
$sql .= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".$id;
$sql .= ' AND e.entity IN ('.getEntity('expensereport').')';
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $db->fetch_object($resql);
$sumpaid = $obj->total;
$db->free();
@@ -257,8 +238,7 @@ if ($action == 'create' || empty($action))
print "
\n";
print ' ';
- if (!empty($conf->banque->enabled))
- {
+ if (!empty($conf->banque->enabled)) {
print '';
print ''.$langs->trans('AccountToDebit').' ';
print '';
@@ -299,8 +279,7 @@ if ($action == 'create' || empty($action))
$total = 0;
$totalrecu = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$objp = $expensereport;
print ' ';
@@ -310,12 +289,12 @@ if ($action == 'create' || empty($action))
print ''.price($sumpaid)." ";
print ''.price($objp->total_ttc - $sumpaid)." ";
print '';
- if ($sumpaid < $objp->total_ttc)
- {
+ if ($sumpaid < $objp->total_ttc) {
$namef = "amount_".$objp->id;
$nameRemain = "remain_".$objp->id; // autofill remainder amount
- if (!empty($conf->use_javascript_ajax)) // autofill remainder amount
+ if (!empty($conf->use_javascript_ajax)) { // autofill remainder amount
print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->total_ttc - $sumpaid)."'"); // autofill remainder amount
+ }
$remaintopay = $objp->total_ttc - $sumpaid; // autofill remainder amount
print ' '; // autofill remainder amount
print ' ';
@@ -331,8 +310,7 @@ if ($action == 'create' || empty($action))
$totalrecu += $objp->am;
$i++;
}
- if ($i > 1)
- {
+ if ($i > 1) {
// Print total
print ' ';
print ''.$langs->trans("Total").': ';
diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php
index f3a3e263fa7..87bac2dde1a 100644
--- a/htdocs/expensereport/stats/index.php
+++ b/htdocs/expensereport/stats/index.php
@@ -38,16 +38,19 @@ $mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer';
$object_status = GETPOST('object_status', 'intcomma');
$userid = GETPOST('userid', 'int');
-$socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0;
+$socid = GETPOST('socid', 'int'); if ($socid < 0) {
+ $socid = 0;
+}
$id = GETPOST('id', 'int');
// Security check
-if ($user->socid > 0)
-{
+if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'expensereport', $id, '');
$nowyear = strftime("%Y", dol_now());
@@ -75,7 +78,9 @@ print load_fiche_titre($title, '', 'trip');
dol_mkdir($dir);
$stats = new ExpenseReportStats($db, $socid, $userid);
-if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND e.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')';
+if ($object_status != '' && $object_status >= -1) {
+ $stats->where .= ' AND e.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')';
+}
// Build graphic number of object
// $data = array(array('Lib',val1,val2,val3),...)
@@ -88,12 +93,10 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file
$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++;
}
@@ -120,12 +123,10 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&
$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++;
}
@@ -146,25 +147,30 @@ if (!$mesg)
$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
-if (!$user->rights->societe->client->voir || $user->socid)
-{
+if (!$user->rights->societe->client->voir || $user->socid) {
$filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png';
- if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png';
- if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png';
+ if ($mode == 'customer') {
+ $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png';
+ }
+ if ($mode == 'supplier') {
+ $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png';
+ }
} else {
$filename_avg = $dir.'/ordersaverage-'.$year.'.png';
- if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png';
- if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png';
+ if ($mode == 'customer') {
+ $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png';
+ }
+ if ($mode == 'supplier') {
+ $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png';
+ }
}
$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++;
}
@@ -189,7 +195,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;
@@ -223,7 +231,9 @@ print ' ';
// User
print ''.$langs->trans("User").' ';
$include = '';
-if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $include = 'hierarchy';
+if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) {
+ $include = 'hierarchy';
+}
print $form->select_dolusers($userid, 'userid', 1, '', 0, $include, '', 0, 0, 0, '', 0, '', 'maxwidth300');
print ' ';
// Status
@@ -235,7 +245,9 @@ print '';
print '';
print $form->textwithpicto($langs->trans("Year"), $langs->trans("DateValidation"));
print ' ';
-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 ' ';
@@ -254,11 +266,9 @@ print ''.$langs->trans("AmountAverage").' ';
print '';
$oldyear = 0;
-foreach ($data as $val)
-{
+foreach ($data as $val) {
$year = $val['year'];
- while ($year && $oldyear > $year + 1)
- { // If we have empty year
+ while ($year && $oldyear > $year + 1) { // If we have empty year
$oldyear--;
print '';
@@ -287,7 +297,9 @@ print '';
// Show graphs
print '
';
-if ($mesg) { print $mesg; } else {
+if ($mesg) {
+ print $mesg;
+} else {
print $px1->show();
print " \n";
print $px2->show();
diff --git a/htdocs/expensereport/tpl/expensereport_addfile.tpl.php b/htdocs/expensereport/tpl/expensereport_addfile.tpl.php
index 9b2cd49faec..c27136ebd38 100644
--- a/htdocs/expensereport/tpl/expensereport_addfile.tpl.php
+++ b/htdocs/expensereport/tpl/expensereport_addfile.tpl.php
@@ -9,11 +9,9 @@ $permission = $user->rights->expensereport->creer;
// We define var to enable the feature to add prefix of uploaded files
$savingdocmask = '';
-if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX))
-{
+if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX)) {
//var_dump($modulepart);
- if (in_array($modulepart, array('facture_fournisseur', 'commande_fournisseur', 'facture', 'commande', 'propal', 'supplier_proposal', 'ficheinter', 'contract', 'expedition', 'project', 'project_task', 'expensereport', 'tax', 'produit', 'product_batch')))
- {
+ if (in_array($modulepart, array('facture_fournisseur', 'commande_fournisseur', 'facture', 'commande', 'propal', 'supplier_proposal', 'ficheinter', 'contract', 'expedition', 'project', 'project_task', 'expensereport', 'tax', 'produit', 'product_batch'))) {
$savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
}
}
@@ -35,6 +33,6 @@ $formfile->form_attach_new_file(
'accept',
'',
1
- );
+);
print ' ';
diff --git a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php
index 04bb2a71990..640f4c17b5d 100644
--- a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php
+++ b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php
@@ -1,7 +1,6 @@
global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES))
-{
+if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) {
print ''."\n";
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -12,23 +11,20 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES))
$nbFiles = count($arrayoffiles);
$nbLinks = Link::count($db, $object->element, $object->id);
- if ($nbFiles > 0)
- {
+ if ($nbFiles > 0) {
print 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' style="display: none"' : '').'>';
print '';
//print ''.$langs->trans("AttachTheNewLineToTheDocument").' ';
$modulepart = 'expensereport'; $maxheightmini = 48;
$relativepath = (!empty($object->ref) ?dol_sanitizeFileName($object->ref) : '').'/';
$filei = 0;
- foreach ($arrayoffiles as $file)
- {
+ foreach ($arrayoffiles as $file) {
$urlforhref = array();
$filei++;
print '';
$fileinfo = pathinfo($file['fullname']);
- if (image_format_supported($file['name']) > 0)
- {
+ if (image_format_supported($file['name']) > 0) {
$minifile = getImageFileNameForSize($file['name'], '_mini'); // For new thumbs using same ext (in lower case however) than original
//print $file['path'].'/'.$minifile.'
';
$urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
@@ -46,8 +42,7 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES))
$error = 0;
$thumbshown = '';
- if (preg_match('/\.pdf$/i', $file['name']))
- {
+ if (preg_match('/\.pdf$/i', $file['name'])) {
$urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
$filepdf = $conf->expensereport->dir_output.'/'.$relativepath.$file['name'];
@@ -56,27 +51,26 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES))
$pdfexists = file_exists($filepdf);
- if ($pdfexists)
- {
+ if ($pdfexists) {
// Conversion du PDF en image png si fichier png non existant
- if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf)))
- {
- if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experience trouble with pdf thumb generation and imagick, you can disable here.
- {
+ if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
+ if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) { // If you experience trouble with pdf thumb generation and imagick, you can disable here.
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png
- if ($ret < 0) $error++;
+ if ($ret < 0) {
+ $error++;
+ }
}
}
}
- if ($pdfexists && !$error)
- {
+ if ($pdfexists && !$error) {
$heightforphotref = 70;
- if (!empty($conf->dol_optimize_smallscreen)) $heightforphotref = 60;
+ if (!empty($conf->dol_optimize_smallscreen)) {
+ $heightforphotref = 60;
+ }
// If the preview file is found
- if (file_exists($fileimage))
- {
+ if (file_exists($fileimage)) {
$thumbshown = '
';
}
}
@@ -98,10 +92,8 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES))
//var_dump(GETPOST($file['relativename'])); var_dump($file['relativename']); var_dump($_FILES['userfile']['name']);
// If a file was just uploaded, we check to preselect it
if (is_array($_FILES['userfile']['name'])) {
- foreach ($_FILES['userfile']['name'] as $tmpfile)
- {
- if ($file['relativename'] == (GETPOST('savingdocmask', 'alpha') ? dol_sanitizeFileName($object->ref.'-') : '').$tmpfile)
- {
+ foreach ($_FILES['userfile']['name'] as $tmpfile) {
+ if ($file['relativename'] == (GETPOST('savingdocmask', 'alpha') ? dol_sanitizeFileName($object->ref.'-') : '').$tmpfile) {
$checked = ' checked';
break;
} elseif ($file['relativename'] && in_array($file['relativename'], GETPOST('attachfile', 'array'))) {
@@ -111,8 +103,7 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES))
}
}
// If we edit a line already linked, then $filenamelinked is defined to the filename (without path) of linked file
- if (!empty($filenamelinked) && $filenamelinked == $file['relativename'])
- {
+ if (!empty($filenamelinked) && $filenamelinked == $file['relativename']) {
$checked = ' checked';
}
print '
';
diff --git a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php
index a0ef7c353c6..31c5526903b 100644
--- a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php
@@ -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,13 +34,12 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$var = true;
$total = 0;
-foreach ($linkedObjectBlock as $key => $objectlink)
-{
+foreach ($linkedObjectBlock as $key => $objectlink) {
?>
>
trans("ExpenseReport"); ?>
- getNomUrl(1); ?>
-
+ getNomUrl(1); ?>
+
date_debut, 'day'); ?>
rights->expensereport->lire) {
diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php
index e4725db3946..174a7271d25 100644
--- a/htdocs/exports/class/export.class.php
+++ b/htdocs/exports/class/export.class.php
@@ -96,50 +96,49 @@ class Export
$modulesdir = dolGetModulesDirs();
- foreach ($modulesdir as $dir)
- {
+ foreach ($modulesdir as $dir) {
// Search available exports
$handle = @opendir(dol_osencode($dir));
- if (is_resource($handle))
- {
+ if (is_resource($handle)) {
// Search module files
- while (($file = readdir($handle)) !== false)
- {
+ while (($file = readdir($handle)) !== false) {
$reg = array();
- if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg))
- {
+ if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) {
$modulename = $reg[1];
// Defined if module is enabled
$enabled = true;
$part = strtolower(preg_replace('/^mod/i', '', $modulename));
- if ($part == 'propale') $part = 'propal';
- if (empty($conf->$part->enabled)) $enabled = false;
+ if ($part == 'propale') {
+ $part = 'propal';
+ }
+ if (empty($conf->$part->enabled)) {
+ $enabled = false;
+ }
- if ($enabled)
- {
+ if ($enabled) {
// Loading Class
$file = $dir.$modulename.".class.php";
$classname = $modulename;
require_once $file;
$module = new $classname($this->db);
- if (isset($module->export_code) && is_array($module->export_code))
- {
- foreach ($module->export_code as $r => $value)
- {
+ if (isset($module->export_code) && is_array($module->export_code)) {
+ foreach ($module->export_code as $r => $value) {
//print $i.'-'.$filter.'-'.$modulename.'-'.join(',',$module->export_code).' ';
- if ($filter && ($filter != $module->export_code[$r])) continue;
+ if ($filter && ($filter != $module->export_code[$r])) {
+ continue;
+ }
// Test if condition to show are ok
- if (!empty($module->export_enabled[$r]) && !verifCond($module->export_enabled[$r])) continue;
+ if (!empty($module->export_enabled[$r]) && !verifCond($module->export_enabled[$r])) {
+ continue;
+ }
// Test if permissions are ok
$bool = true;
- if (isset($module->export_permission))
- {
- foreach ($module->export_permission[$r] as $val)
- {
+ if (isset($module->export_permission)) {
+ foreach ($module->export_permission[$r] as $val) {
$perm = $val;
//print_r("$perm[0]-$perm[1]-$perm[2] ");
if (!empty($perm[2])) {
@@ -147,8 +146,12 @@ class Export
} else {
$bool = isset($user->rights->{$perm[0]}->{$perm[1]}) ? $user->rights->{$perm[0]}->{$perm[1]} : false;
}
- if ($perm[0] == 'user' && $user->admin) $bool = true;
- if (!$bool) break;
+ if ($perm[0] == 'user' && $user->admin) {
+ $bool = true;
+ }
+ if (!$bool) {
+ break;
+ }
}
}
//print $bool." $perm[0]"." ";
@@ -158,10 +161,8 @@ class Export
// {
// Charge fichier lang en rapport
$langtoload = $module->getLangFilesArray();
- if (is_array($langtoload))
- {
- foreach ($langtoload as $key)
- {
+ if (is_array($langtoload)) {
+ foreach ($langtoload as $key) {
$langs->load($key);
}
}
@@ -234,12 +235,18 @@ class Export
$i = 0;
//print_r($array_selected);
- foreach ($this->array_export_fields[$indice] as $key => $value)
- {
- if (!array_key_exists($key, $array_selected)) continue; // Field not selected
- if (preg_match('/^none\./', $key)) continue; // A field that must not appears into SQL
- if ($i > 0) $sql .= ', ';
- else $i++;
+ foreach ($this->array_export_fields[$indice] as $key => $value) {
+ if (!array_key_exists($key, $array_selected)) {
+ continue; // Field not selected
+ }
+ if (preg_match('/^none\./', $key)) {
+ continue; // A field that must not appears into SQL
+ }
+ if ($i > 0) {
+ $sql .= ', ';
+ } else {
+ $i++;
+ }
if (strpos($key, ' as ') === false) {
$newfield = $key.' as '.str_replace(array('.', '-', '(', ')'), '_', $key);
@@ -252,14 +259,16 @@ class Export
$sql .= $this->array_export_sql_end[$indice];
// Add the WHERE part. Filtering into sql if a filtering array is provided
- if (is_array($array_filterValue) && !empty($array_filterValue))
- {
+ if (is_array($array_filterValue) && !empty($array_filterValue)) {
$sqlWhere = '';
// Loop on each condition to add
- foreach ($array_filterValue as $key => $value)
- {
- if (preg_match('/GROUP_CONCAT/i', $key)) continue;
- if ($value != '') $sqlWhere .= " and ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
+ foreach ($array_filterValue as $key => $value) {
+ if (preg_match('/GROUP_CONCAT/i', $key)) {
+ continue;
+ }
+ if ($value != '') {
+ $sqlWhere .= " and ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
+ }
}
$sql .= $sqlWhere;
}
@@ -268,12 +277,12 @@ class Export
$sql .= $this->array_export_sql_order[$indice];
// Add the HAVING part.
- if (is_array($array_filterValue) && !empty($array_filterValue))
- {
+ if (is_array($array_filterValue) && !empty($array_filterValue)) {
// Loop on each condition to add
- foreach ($array_filterValue as $key => $value)
- {
- if (preg_match('/GROUP_CONCAT/i', $key) and $value != '') $sql .= " HAVING ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
+ foreach ($array_filterValue as $key => $value) {
+ if (preg_match('/GROUP_CONCAT/i', $key) and $value != '') {
+ $sql .= " HAVING ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
+ }
}
}
@@ -297,37 +306,41 @@ class Export
// build the input field on depend of the type of file
switch ($InfoFieldList[0]) {
case 'Text':
- if (!(strpos($ValueField, '%') === false))
+ if (!(strpos($ValueField, '%') === false)) {
$szFilterQuery .= " ".$NameField." LIKE '".$ValueField."'";
- else $szFilterQuery .= " ".$NameField." = '".$ValueField."'";
+ } else {
+ $szFilterQuery .= " ".$NameField." = '".$ValueField."'";
+ }
break;
case 'Date':
- if (strpos($ValueField, "+") > 0)
- {
+ if (strpos($ValueField, "+") > 0) {
// mode plage
$ValueArray = explode("+", $ValueField);
$szFilterQuery = "(".$this->conditionDate($NameField, trim($ValueArray[0]), ">=");
$szFilterQuery .= " AND ".$this->conditionDate($NameField, trim($ValueArray[1]), "<=").")";
} else {
- if (is_numeric(substr($ValueField, 0, 1)))
+ if (is_numeric(substr($ValueField, 0, 1))) {
$szFilterQuery = $this->conditionDate($NameField, trim($ValueField), "=");
- else $szFilterQuery = $this->conditionDate($NameField, trim(substr($ValueField, 1)), substr($ValueField, 0, 1));
+ } else {
+ $szFilterQuery = $this->conditionDate($NameField, trim(substr($ValueField, 1)), substr($ValueField, 0, 1));
+ }
}
break;
case 'Duree':
break;
case 'Numeric':
// si le signe -
- if (strpos($ValueField, "+") > 0)
- {
+ if (strpos($ValueField, "+") > 0) {
// mode plage
$ValueArray = explode("+", $ValueField);
$szFilterQuery = "(".$NameField.">=".$ValueArray[0];
$szFilterQuery .= " AND ".$NameField."<=".$ValueArray[1].")";
} else {
- if (is_numeric(substr($ValueField, 0, 1)))
+ if (is_numeric(substr($ValueField, 0, 1))) {
$szFilterQuery = " ".$NameField."=".$ValueField;
- else $szFilterQuery = " ".$NameField.substr($ValueField, 0, 1).substr($ValueField, 1);
+ } else {
+ $szFilterQuery = " ".$NameField.substr($ValueField, 0, 1).substr($ValueField, 1);
+ }
}
break;
case 'Boolean':
@@ -335,12 +348,14 @@ class Export
break;
case 'Status':
case 'List':
- if (is_numeric($ValueField))
+ if (is_numeric($ValueField)) {
$szFilterQuery = " ".$NameField."=".$ValueField;
- else {
- if (!(strpos($ValueField, '%') === false))
+ } else {
+ if (!(strpos($ValueField, '%') === false)) {
$szFilterQuery = " ".$NameField." LIKE '".$ValueField."'";
- else $szFilterQuery = " ".$NameField." = '".$ValueField."'";
+ } else {
+ $szFilterQuery = " ".$NameField." = '".$ValueField."'";
+ }
}
break;
default:
@@ -361,9 +376,13 @@ class Export
public function conditionDate($Field, $Value, $Sens)
{
// TODO date_format is forbidden, not performant and not portable. Use instead BETWEEN
- if (strlen($Value) == 4) $Condition = " date_format(".$Field.",'%Y') ".$Sens." '".$Value."'";
- elseif (strlen($Value) == 6) $Condition = " date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'";
- else $Condition = " date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value;
+ if (strlen($Value) == 4) {
+ $Condition = " date_format(".$Field.",'%Y') ".$Sens." '".$Value."'";
+ } elseif (strlen($Value) == 6) {
+ $Condition = " date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'";
+ } else {
+ $Condition = " date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value;
+ }
return $Condition;
}
@@ -385,8 +404,7 @@ class Export
$InfoFieldList = explode(":", $TypeField);
// build the input field on depend of the type of file
- switch ($InfoFieldList[0])
- {
+ switch ($InfoFieldList[0]) {
case 'Text':
case 'Date':
$szFilterField = ' ';
@@ -403,15 +421,21 @@ class Export
case 'Boolean':
$szFilterField = '';
$szFilterField .= '';
$szFilterField .= ' ';
$szFilterField .= " ";
break;
@@ -422,51 +446,50 @@ class Export
// 3 : Name of field with key (if it is not "rowid"). Used this field as key for combo list.
// 4 : Name of element for getEntity().
- if (!empty($InfoFieldList[3]))
+ if (!empty($InfoFieldList[3])) {
$keyList = $InfoFieldList[3];
- else $keyList = 'rowid';
+ } else {
+ $keyList = 'rowid';
+ }
$sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3]) ? '' : ', '.$InfoFieldList[3].' as code');
- if ($InfoFieldList[1] == 'c_stcomm') $sql = 'SELECT id as id, '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3]) ? '' : ', '.$InfoFieldList[3].' as code');
- if ($InfoFieldList[1] == 'c_country') $sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label, code as code';
+ if ($InfoFieldList[1] == 'c_stcomm') {
+ $sql = 'SELECT id as id, '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3]) ? '' : ', '.$InfoFieldList[3].' as code');
+ }
+ if ($InfoFieldList[1] == 'c_country') {
+ $sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label, code as code';
+ }
$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[1];
if (!empty($InfoFieldList[4])) {
$sql .= ' WHERE entity IN ('.getEntity($InfoFieldList[4]).')';
}
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$szFilterField = '';
$szFilterField .= ' ';
$num = $this->db->num_rows($resql);
$i = 0;
- if ($num)
- {
- while ($i < $num)
- {
+ if ($num) {
+ while ($i < $num) {
$obj = $this->db->fetch_object($resql);
- if ($obj->label == '-')
- {
+ if ($obj->label == '-') {
// Discard entry '-'
$i++;
continue;
}
//var_dump($InfoFieldList[1]);
$labeltoshow = dol_trunc($obj->label, 18);
- if ($InfoFieldList[1] == 'c_stcomm')
- {
+ if ($InfoFieldList[1] == 'c_stcomm') {
$langs->load("companies");
$labeltoshow = (($langs->trans("StatusProspect".$obj->id) != "StatusProspect".$obj->id) ? $langs->trans("StatusProspect".$obj->id) : $obj->label);
}
- if ($InfoFieldList[1] == 'c_country')
- {
+ if ($InfoFieldList[1] == 'c_country') {
//var_dump($sql);
$langs->load("dict");
$labeltoshow = (($langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label);
}
- if (!empty($ValueField) && $ValueField == $obj->rowid)
- {
+ if (!empty($ValueField) && $ValueField == $obj->rowid) {
$szFilterField .= ''.$labeltoshow.' ';
} else {
$szFilterField .= ''.$labeltoshow.' ';
@@ -477,7 +500,9 @@ class Export
$szFilterField .= " ";
$this->db->free($resql);
- } else dol_print_error($this->db);
+ } else {
+ dol_print_error($this->db);
+ }
break;
}
@@ -542,8 +567,7 @@ class Export
dol_syslog(__METHOD__." ".$model.", ".$datatoexport.", ".implode(",", $array_selected));
// Check parameters or context properties
- if (empty($this->array_export_fields) || !is_array($this->array_export_fields))
- {
+ if (empty($this->array_export_fields) || !is_array($this->array_export_fields)) {
$this->error = "ErrorBadParameter";
dol_syslog($this->error, LOG_ERR);
return -1;
@@ -556,22 +580,20 @@ class Export
require_once $dir.$file;
$objmodel = new $classname($this->db);
- if (!empty($sqlquery)) $sql = $sqlquery;
- else {
+ if (!empty($sqlquery)) {
+ $sql = $sqlquery;
+ } else {
// Define value for indice from $datatoexport
$foundindice = 0;
- foreach ($this->array_export_code as $key => $dataset)
- {
- if ($datatoexport == $dataset)
- {
+ foreach ($this->array_export_code as $key => $dataset) {
+ if ($datatoexport == $dataset) {
$indice = $key;
$foundindice++;
//print "Found indice = ".$indice." for dataset=".$datatoexport."\n";
break;
}
}
- if (empty($foundindice))
- {
+ if (empty($foundindice)) {
$this->error = "ErrorBadParameter can't find dataset ".$datatoexport." into preload arrays this->array_export_code";
return -1;
}
@@ -582,13 +604,11 @@ class Export
$this->sqlusedforexport = $sql;
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
//$this->array_export_label[$indice]
if (!empty($conf->global->EXPORT_PREFIX_SPEC)) {
$filename = $conf->global->EXPORT_PREFIX_SPEC."_".$datatoexport;
- }
- else {
+ } else {
$filename = "export_".$datatoexport;
}
$filename .= '.'.$objmodel->getDriverExtension();
@@ -600,55 +620,48 @@ class Export
dol_mkdir($dirname);
$result = $objmodel->open_file($dirname."/".$filename, $outputlangs);
- if ($result >= 0)
- {
+ if ($result >= 0) {
// Genere en-tete
$objmodel->write_header($outputlangs);
// Genere ligne de titre
$objmodel->write_title($this->array_export_fields[$indice], $array_selected, $outputlangs, isset($this->array_export_TypeFields[$indice]) ? $this->array_export_TypeFields[$indice] : null);
- while ($obj = $this->db->fetch_object($resql))
- {
+ while ($obj = $this->db->fetch_object($resql)) {
// Process special operations
- if (!empty($this->array_export_special[$indice]))
- {
- foreach ($this->array_export_special[$indice] as $key => $value)
- {
- if (!array_key_exists($key, $array_selected)) continue; // Field not selected
+ if (!empty($this->array_export_special[$indice])) {
+ foreach ($this->array_export_special[$indice] as $key => $value) {
+ if (!array_key_exists($key, $array_selected)) {
+ continue; // Field not selected
+ }
// Operation NULLIFNEG
- if ($this->array_export_special[$indice][$key] == 'NULLIFNEG')
- {
+ if ($this->array_export_special[$indice][$key] == 'NULLIFNEG') {
//$alias=$this->array_export_alias[$indice][$key];
$alias = str_replace(array('.', '-', '(', ')'), '_', $key);
- if ($obj->$alias < 0) $obj->$alias = '';
- }
- // Operation ZEROIFNEG
- elseif ($this->array_export_special[$indice][$key] == 'ZEROIFNEG')
- {
+ if ($obj->$alias < 0) {
+ $obj->$alias = '';
+ }
+ } elseif ($this->array_export_special[$indice][$key] == 'ZEROIFNEG') {
+ // Operation ZEROIFNEG
//$alias=$this->array_export_alias[$indice][$key];
$alias = str_replace(array('.', '-', '(', ')'), '_', $key);
- if ($obj->$alias < 0) $obj->$alias = '0';
- }
- // Operation GETNUMOPENDAYS (for Holiday module)
- elseif ($this->array_export_special[$indice][$key] == 'getNumOpenDays')
- {
+ if ($obj->$alias < 0) {
+ $obj->$alias = '0';
+ }
+ } elseif ($this->array_export_special[$indice][$key] == 'getNumOpenDays') {
+ // Operation GETNUMOPENDAYS (for Holiday module)
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
//$alias=$this->array_export_alias[$indice][$key];
$alias = str_replace(array('.', '-', '(', ')'), '_', $key);
$obj->$alias = num_open_day(dol_stringtotime($obj->d_date_debut, 1), dol_stringtotime($obj->d_date_fin, 1), 0, 1, $obj->d_halfday, $mysoc->country_code);
- }
- // Operation INVOICEREMAINTOPAY
- elseif ($this->array_export_special[$indice][$key] == 'getRemainToPay')
- {
+ } elseif ($this->array_export_special[$indice][$key] == 'getRemainToPay') {
+ // Operation INVOICEREMAINTOPAY
//$alias=$this->array_export_alias[$indice][$key];
$alias = str_replace(array('.', '-', '(', ')'), '_', $key);
$remaintopay = '';
- if ($obj->f_rowid > 0)
- {
+ if ($obj->f_rowid > 0) {
global $tmpobjforcomputecall;
- if (!is_object($tmpobjforcomputecall))
- {
+ if (!is_object($tmpobjforcomputecall)) {
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$tmpobjforcomputecall = new Facture($this->db);
}
@@ -725,8 +738,7 @@ class Export
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$this->db->commit();
return 1;
} else {
@@ -751,11 +763,9 @@ class Export
dol_syslog("Export::fetch", LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$obj = $this->db->fetch_object($result);
- if ($obj)
- {
+ if ($obj) {
$this->id = $obj->rowid;
$this->model_name = $obj->label;
$this->datatoexport = $obj->type;
@@ -794,13 +804,13 @@ class Export
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
+ if (!$resql) {
+ $error++; $this->errors[] = "Error ".$this->db->lasterror();
+ }
// Commit or rollback
- if ($error)
- {
- foreach ($this->errors as $errmsg)
- {
+ if ($error) {
+ foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@@ -829,12 +839,10 @@ class Export
$sql .= " ORDER BY rowid";
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$num = $this->db->num_rows($result);
$i = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $this->db->fetch_object($result);
$keyModel = array_search($obj->type, $this->array_export_code);
print " ";
diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php
index c80ee4d248f..f1099f9692f 100644
--- a/htdocs/exports/export.php
+++ b/htdocs/exports/export.php
@@ -54,14 +54,14 @@ $entitytoicon = array(
'subscription' => 'payment',
'payment' => 'payment',
'tax' => 'generic',
- 'tax_type' => 'generic',
- 'other' => 'generic',
+ 'tax_type' => 'generic',
+ 'other' => 'generic',
'account' => 'account',
'product' => 'product',
'virtualproduct'=>'product',
'subproduct' => 'product',
'product_supplier_ref' => 'product',
- 'stock' => 'stock',
+ 'stock' => 'stock',
'warehouse' => 'stock',
'batch' => 'stock',
'stockbatch' => 'stock',
@@ -159,17 +159,16 @@ $usefilters = 1;
* Actions
*/
-if ($action == 'selectfield') // Selection of field at step 2
-{
+if ($action == 'selectfield') { // Selection of field at step 2
$fieldsarray = $objexport->array_export_fields[0];
$fieldsentitiesarray = $objexport->array_export_entities[0];
$fieldsdependenciesarray = $objexport->array_export_dependencies[0];
- if ($field == 'all')
- {
- foreach ($fieldsarray as $key=>$val)
- {
- if (!empty($array_selected[$key])) continue; // If already selected, check next
+ if ($field == 'all') {
+ foreach ($fieldsarray as $key => $val) {
+ if (!empty($array_selected[$key])) {
+ continue; // If already selected, check next
+ }
$array_selected[$key] = count($array_selected) + 1;
//print_r($array_selected);
$_SESSION["export_selected_fields"] = $array_selected;
@@ -180,29 +179,30 @@ if ($action == 'selectfield') // Selection of field at step 2
$array_selected[$field] = count($array_selected) + 1; // We tag the key $field as "selected"
// We check if there is a dependency to activate
/*var_dump($field);
- var_dump($fieldsentitiesarray[$field]);
- var_dump($fieldsdependenciesarray);*/
+ var_dump($fieldsentitiesarray[$field]);
+ var_dump($fieldsdependenciesarray);*/
$listofdependencies = array();
- if (!empty($fieldsentitiesarray[$field]) && !empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]]))
- {
+ if (!empty($fieldsentitiesarray[$field]) && !empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]])) {
// We found a dependency on the type of field
$tmp = $fieldsdependenciesarray[$fieldsentitiesarray[$field]]; // $fieldsdependenciesarray=array('element'=>'fd.rowid') or array('element'=>array('fd.rowid','ab.rowid'))
- if (is_array($tmp)) $listofdependencies = $tmp;
- else $listofdependencies = array($tmp);
- } elseif (!empty($field) && !empty($fieldsdependenciesarray[$field]))
- {
+ if (is_array($tmp)) {
+ $listofdependencies = $tmp;
+ } else {
+ $listofdependencies = array($tmp);
+ }
+ } elseif (!empty($field) && !empty($fieldsdependenciesarray[$field])) {
// We found a dependency on a dedicated field
$tmp = $fieldsdependenciesarray[$field]; // $fieldsdependenciesarray=array('fd.fieldx'=>'fd.rowid') or array('fd.fieldx'=>array('fd.rowid','ab.rowid'))
- if (is_array($tmp)) $listofdependencies = $tmp;
- else $listofdependencies = array($tmp);
+ if (is_array($tmp)) {
+ $listofdependencies = $tmp;
+ } else {
+ $listofdependencies = array($tmp);
+ }
}
- if (count($listofdependencies))
- {
- foreach ($listofdependencies as $fieldid)
- {
- if (empty($array_selected[$fieldid]))
- {
+ if (count($listofdependencies)) {
+ foreach ($listofdependencies as $fieldid) {
+ if (empty($array_selected[$fieldid])) {
$array_selected[$fieldid] = count($array_selected) + 1; // We tag the key $fieldid as "selected"
$warnings[] = $langs->trans("ExportFieldAutomaticallyAdded", $langs->transnoentitiesnoconv($fieldsarray[$fieldid]));
}
@@ -214,10 +214,8 @@ if ($action == 'selectfield') // Selection of field at step 2
setEventMessages($warnings, null, 'warnings');
}
}
-if ($action == 'unselectfield')
-{
- if ($_GET["field"] == 'all')
- {
+if ($action == 'unselectfield') {
+ if ($_GET["field"] == 'all') {
$array_selected = array();
$_SESSION["export_selected_fields"] = $array_selected;
} else {
@@ -226,8 +224,7 @@ if ($action == 'unselectfield')
asort($array_selected);
$i = 0;
$array_selected_save = $array_selected;
- foreach ($array_selected as $code=>$value)
- {
+ foreach ($array_selected as $code => $value) {
$i++;
$array_selected[$code] = $i;
//print "x $code x $i y ";
@@ -236,52 +233,48 @@ if ($action == 'unselectfield')
}
}
-if ($action == 'downfield' || $action == 'upfield')
-{
+if ($action == 'downfield' || $action == 'upfield') {
$pos = $array_selected[$_GET["field"]];
- if ($action == 'downfield') $newpos = $pos + 1;
- if ($action == 'upfield') $newpos = $pos - 1;
+ if ($action == 'downfield') {
+ $newpos = $pos + 1;
+ }
+ if ($action == 'upfield') {
+ $newpos = $pos - 1;
+ }
// Recherche code avec qui switcher
$newcode = "";
- foreach ($array_selected as $code=>$value)
- {
- if ($value == $newpos)
- {
+ foreach ($array_selected as $code => $value) {
+ if ($value == $newpos) {
$newcode = $code;
break;
}
}
//print("Switch pos=$pos (code=".$_GET["field"].") and newpos=$newpos (code=$newcode)");
- if ($newcode) // Si newcode trouve (protection contre resoumission de page)
- {
+ if ($newcode) { // Si newcode trouve (protection contre resoumission de page)
$array_selected[$_GET["field"]] = $newpos;
$array_selected[$newcode] = $pos;
$_SESSION["export_selected_fields"] = $array_selected;
}
}
-if ($step == 1 || $action == 'cleanselect')
-{
+if ($step == 1 || $action == 'cleanselect') {
$_SESSION["export_selected_fields"] = array();
$_SESSION["export_filtered_fields"] = array();
$array_selected = array();
$array_filtervalue = array();
}
-if ($action == 'builddoc')
-{
+if ($action == 'builddoc') {
$max_execution_time_for_importexport = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME); // 5mn if not defined
$max_time = @ini_get("max_execution_time");
- if ($max_time && $max_time < $max_execution_time_for_importexport)
- {
+ if ($max_time && $max_time < $max_execution_time_for_importexport) {
dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.". We try to increase it dynamically.");
@ini_set("max_execution_time", $max_execution_time_for_importexport); // This work only if safe mode is off. also web servers has timeout of 300
}
// Build export file
$result = $objexport->build_file($user, GETPOST('model', 'alpha'), $datatoexport, $array_selected, $array_filtervalue);
- if ($result < 0)
- {
+ if ($result < 0) {
setEventMessages($objexport->error, $objexport->errors, 'errors');
$sqlusedforexport = $objexport->sqlusedforexport;
} else {
@@ -291,47 +284,46 @@ if ($action == 'builddoc')
}
// Delete file
-if ($step == 5 && $action == 'confirm_deletefile' && $confirm == 'yes')
-{
+if ($step == 5 && $action == 'confirm_deletefile' && $confirm == 'yes') {
$file = $upload_dir."/".GETPOST('file'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret = dol_delete_file($file);
- if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
- else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
+ if ($ret) {
+ setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
+ } else {
+ setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
+ }
header('Location: '.$_SERVER["PHP_SELF"].'?step='.$step.'&datatoexport='.$datatoexport);
exit;
}
-if ($action == 'deleteprof')
-{
- if (GETPOST("id", 'int'))
- {
+if ($action == 'deleteprof') {
+ if (GETPOST("id", 'int')) {
$objexport->fetch(GETPOST('id', 'int'));
$result = $objexport->delete($user);
}
}
// TODO The export for filter is not yet implemented (old code created conflicts with step 2). We must use same way of working and same combo list of predefined export than step 2.
-if ($action == 'add_export_model')
-{
- if ($export_name)
- {
+if ($action == 'add_export_model') {
+ if ($export_name) {
asort($array_selected);
// Set save string
$hexa = '';
- foreach ($array_selected as $key=>$val)
- {
- if ($hexa) $hexa .= ',';
+ foreach ($array_selected as $key => $val) {
+ if ($hexa) {
+ $hexa .= ',';
+ }
$hexa .= $key;
}
$hexafiltervalue = '';
- if (!empty($array_filtervalue) && is_array($array_filtervalue))
- {
- foreach ($array_filtervalue as $key=>$val)
- {
- if ($hexafiltervalue) $hexafiltervalue .= ',';
+ if (!empty($array_filtervalue) && is_array($array_filtervalue)) {
+ foreach ($array_filtervalue as $key => $val) {
+ if ($hexafiltervalue) {
+ $hexafiltervalue .= ',';
+ }
$hexafiltervalue .= $key.'='.$val;
}
}
@@ -342,14 +334,15 @@ if ($action == 'add_export_model')
$objexport->hexafiltervalue = $hexafiltervalue;
$result = $objexport->create($user);
- if ($result >= 0)
- {
+ if ($result >= 0) {
setEventMessages($langs->trans("ExportModelSaved", $objexport->model_name), null, 'mesgs');
} else {
$langs->load("errors");
- if ($objexport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS')
+ if ($objexport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
setEventMessages($langs->trans("ErrorExportDuplicateProfil"), null, 'errors');
- else setEventMessages($objexport->error, $objexport->errors, 'errors');
+ } else {
+ setEventMessages($objexport->error, $objexport->errors, 'errors');
+ }
}
} else {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportModelName")), null, 'errors');
@@ -357,8 +350,7 @@ if ($action == 'add_export_model')
}
// Reload a predefined export model
-if ($step == 2 && $action == 'select_model')
-{
+if ($step == 2 && $action == 'select_model') {
$_SESSION["export_selected_fields"] = array();
$_SESSION["export_filtered_fields"] = array();
@@ -366,12 +358,10 @@ if ($step == 2 && $action == 'select_model')
$array_filtervalue = array();
$result = $objexport->fetch($exportmodelid);
- if ($result > 0)
- {
+ if ($result > 0) {
$fieldsarray = preg_split("/,(?! [^(]*\))/", $objexport->hexa);
$i = 1;
- foreach ($fieldsarray as $val)
- {
+ foreach ($fieldsarray as $val) {
$array_selected[$val] = $i;
$i++;
}
@@ -379,8 +369,7 @@ if ($step == 2 && $action == 'select_model')
$fieldsarrayvalue = explode(',', $objexport->hexafiltervalue);
$i = 1;
- foreach ($fieldsarrayvalue as $val)
- {
+ foreach ($fieldsarrayvalue as $val) {
$tmp = explode('=', $val);
$array_filtervalue[$tmp[0]] = $tmp[1];
$i++;
@@ -390,21 +379,20 @@ if ($step == 2 && $action == 'select_model')
}
// Get form with filters
-if ($step == 4 && $action == 'submitFormField')
-{
+if ($step == 4 && $action == 'submitFormField') {
// on boucle sur les champs selectionne pour recuperer la valeur
- if (is_array($objexport->array_export_TypeFields[0]))
- {
+ if (is_array($objexport->array_export_TypeFields[0])) {
$_SESSION["export_filtered_fields"] = array();
- foreach ($objexport->array_export_TypeFields[0] as $code => $type) // $code: s.fieldname $value: Text|Boolean|List:ccc
- {
+ foreach ($objexport->array_export_TypeFields[0] as $code => $type) { // $code: s.fieldname $value: Text|Boolean|List:ccc
$newcode = (string) preg_replace('/\./', '_', $code);
//print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n ";
$filterqualified = 1;
- if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'restricthtml') == '') $filterqualified = 0;
- elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'restricthtml')) && GETPOST($newcode, 'restricthtml') <= 0)) $filterqualified = 0;
- if ($filterqualified)
- {
+ if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'restricthtml') == '') {
+ $filterqualified = 0;
+ } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'restricthtml')) && GETPOST($newcode, 'restricthtml') <= 0)) {
+ $filterqualified = 0;
+ }
+ if ($filterqualified) {
//print 'Filter on '.$newcode.' type='.$type.' value='.$_POST[$newcode]."\n";
$objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'restricthtml');
}
@@ -419,8 +407,7 @@ if ($step == 4 && $action == 'submitFormField')
* View
*/
-if ($step == 1 || !$datatoexport)
-{
+if ($step == 1 || !$datatoexport) {
llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
$h = 0;
@@ -443,13 +430,11 @@ if ($step == 1 || !$datatoexport)
print ' ';
print ' ';
- if (count($objexport->array_export_module))
- {
+ if (count($objexport->array_export_module)) {
asort($objexport->array_export_code_for_sort);
//var_dump($objexport->array_export_code_for_sort);
//$sortedarrayofmodules = dol_sort_array($objexport->array_export_module, 'module_position', 'asc', 0, 0, 1);
- foreach ($objexport->array_export_code_for_sort as $key => $value)
- {
+ foreach ($objexport->array_export_code_for_sort as $key => $value) {
print '';
//print img_object($objexport->array_export_module[$key]->getName(),$export->array_export_module[$key]->picto).' ';
print $objexport->array_export_module[$key]->getName();
@@ -466,7 +451,7 @@ if ($step == 1 || !$datatoexport)
} else {
print $langs->trans("NotEnoughPermissions");
}
- print ' ';
+ print ' ';
}
} else {
print ''.$langs->trans("NoExportableData").' ';
@@ -477,8 +462,7 @@ if ($step == 1 || !$datatoexport)
print '';
}
-if ($step == 2 && $datatoexport)
-{
+if ($step == 2 && $datatoexport) {
llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
$h = 0;
@@ -505,14 +489,14 @@ if ($step == 2 && $datatoexport)
print $objexport->array_export_module[0]->getName();
print '';
- // Lot de donnees a exporter
- print ''.$langs->trans("DatasetToExport").' ';
- print '';
- $entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
- $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
- print img_object($objexport->array_export_module[0]->getName(), $entityicon).' ';
- print $objexport->array_export_label[0];
- print ' ';
+ // Lot de donnees a exporter
+ print ''.$langs->trans("DatasetToExport").' ';
+ print '';
+ $entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
+ $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
+ print img_object($objexport->array_export_module[0]->getName(), $entityicon).' ';
+ print $objexport->array_export_label[0];
+ print ' ';
print '
';
print '
';
@@ -568,8 +552,7 @@ if ($step == 2 && $datatoexport)
$i = 0;
- foreach ($fieldsarray as $code=>$label)
- {
+ foreach ($fieldsarray as $code => $label) {
print '
';
$i++;
@@ -583,8 +566,7 @@ if ($step == 2 && $datatoexport)
//print $code.'-'.$label.'-'.$entity;
$tmparray = explode(':', $entityicon);
- if (count($tmparray) >= 2)
- {
+ if (count($tmparray) >= 2) {
$entityicon = $tmparray[0];
$entitylang = $tmparray[1];
}
@@ -595,27 +577,22 @@ if ($step == 2 && $datatoexport)
$tablename = getablenamefromfield($code, $sqlmaxforexport);
$htmltext = ''.$langs->trans("Name").": ".$text.' ';
- if (!empty($objexport->array_export_special[0][$code]))
- {
+ if (!empty($objexport->array_export_special[0][$code])) {
$htmltext .= ''.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." : ".$objexport->array_export_special[0][$code]." ";
} else {
$htmltext .= ''.$langs->trans("Table")." -> ".$langs->trans("Field").": ".$tablename." -> ".preg_replace('/^.*\./', '', $code)." ";
}
- if (!empty($objexport->array_export_examplevalues[0][$code]))
- {
+ if (!empty($objexport->array_export_examplevalues[0][$code])) {
$htmltext .= ''.$langs->trans("SourceExample").': '.$objexport->array_export_examplevalues[0][$code].' ';
}
- if (!empty($objexport->array_export_TypeFields[0][$code]))
- {
+ if (!empty($objexport->array_export_TypeFields[0][$code])) {
$htmltext .= ''.$langs->trans("Type").': '.$objexport->array_export_TypeFields[0][$code].' ';
}
- if (!empty($objexport->array_export_help[0][$code]))
- {
+ if (!empty($objexport->array_export_help[0][$code])) {
$htmltext .= ''.$langs->trans("Help").': '.$langs->trans($objexport->array_export_help[0][$code]).' ';
}
- if (isset($array_selected[$code]) && $array_selected[$code])
- {
+ if (isset($array_selected[$code]) && $array_selected[$code]) {
// Selected fields
print ' ';
print ''.img_left('default', 0, 'style="max-width: 20px"').' ';
@@ -642,15 +619,13 @@ if ($step == 2 && $datatoexport)
print '';
/*
- * Barre d'action
- */
+ * Barre d'action
+ */
print '';
- if (count($array_selected))
- {
+ if (count($array_selected)) {
// If filters exist
- if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0]))
- {
+ if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
print '
'.$langs->trans("NextStep").' ';
} else {
print '
'.$langs->trans("NextStep").' ';
@@ -662,10 +637,8 @@ if ($step == 2 && $datatoexport)
print '
';
}
-if ($step == 3 && $datatoexport)
-{
- if (count($array_selected) < 1) // This occurs when going back to page after sessecion expired
- {
+if ($step == 3 && $datatoexport) {
+ if (count($array_selected) < 1) { // This occurs when going back to page after sessecion expired
// Switch to step 2
header("Location: ".DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport);
exit;
@@ -713,8 +686,7 @@ if ($step == 3 && $datatoexport)
// Nbre champs exportes
print ' '.$langs->trans("ExportedFields").' ';
$list = '';
- foreach ($array_selected as $code=>$value)
- {
+ foreach ($array_selected as $code => $value) {
$list .= (!empty($list) ? ', ' : '');
$list .= (isset($objexport->array_export_fields[0][$code]) ? $langs->trans($objexport->array_export_fields[0][$code]) : '');
}
@@ -755,8 +727,7 @@ if ($step == 3 && $datatoexport)
$i = 0;
// on boucle sur les champs
- foreach ($fieldsarray as $code => $label)
- {
+ foreach ($fieldsarray as $code => $label) {
print '';
$i++;
@@ -767,8 +738,7 @@ if ($step == 3 && $datatoexport)
print '';
// If value of entityicon=entitylang='icon:Label'
$tmparray = explode(':', $entityicon);
- if (count($tmparray) >= 2)
- {
+ if (count($tmparray) >= 2) {
$entityicon = $tmparray[0];
$entitylang = $tmparray[1];
}
@@ -782,22 +752,18 @@ if ($step == 3 && $datatoexport)
$tablename = getablenamefromfield($code, $sqlmaxforexport);
$htmltext = ''.$langs->trans("Name").': '.$text.' ';
- if (!empty($objexport->array_export_special[0][$code]))
- {
+ if (!empty($objexport->array_export_special[0][$code])) {
$htmltext .= ''.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." : ".$objexport->array_export_special[0][$code]." ";
} else {
$htmltext .= ''.$langs->trans("Table")." -> ".$langs->trans("Field").": ".$tablename." -> ".preg_replace('/^.*\./', '', $code)." ";
}
- if (!empty($objexport->array_export_examplevalues[0][$code]))
- {
+ if (!empty($objexport->array_export_examplevalues[0][$code])) {
$htmltext .= ''.$langs->trans("SourceExample").': '.$objexport->array_export_examplevalues[0][$code].' ';
}
- if (!empty($objexport->array_export_TypeFields[0][$code]))
- {
+ if (!empty($objexport->array_export_TypeFields[0][$code])) {
$htmltext .= ''.$langs->trans("Type").': '.$objexport->array_export_TypeFields[0][$code].' ';
}
- if (!empty($objexport->array_export_help[0][$code]))
- {
+ if (!empty($objexport->array_export_help[0][$code])) {
$htmltext .= ''.$langs->trans("Help").': '.$langs->trans($objexport->array_export_help[0][$code]).' ';
}
@@ -807,11 +773,9 @@ if ($step == 3 && $datatoexport)
// Filter value
print ' ';
- if (!empty($Typefieldsarray[$code])) // Example: Text, List:c_country:label:rowid, Number, Boolean
- {
+ if (!empty($Typefieldsarray[$code])) { // Example: Text, List:c_country:label:rowid, Number, Boolean
$szInfoFiltre = $objexport->genDocFilter($Typefieldsarray[$code]);
- if ($szInfoFiltre) // Is there an info help for this filter ?
- {
+ if ($szInfoFiltre) { // Is there an info help for this filter ?
$tmp = $objexport->build_filterField($Typefieldsarray[$code], $code, $ValueFilter);
print $form->textwithpicto($tmp, $szInfoFiltre);
} else {
@@ -837,10 +801,8 @@ if ($step == 3 && $datatoexport)
print '';
}
-if ($step == 4 && $datatoexport)
-{
- if (count($array_selected) < 1) // This occurs when going back to page after sessecion expired
- {
+if ($step == 4 && $datatoexport) {
+ if (count($array_selected) < 1) { // This occurs when going back to page after sessecion expired
// Switch to step 2
header("Location: ".DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport);
exit;
@@ -862,8 +824,7 @@ if ($step == 4 && $datatoexport)
$h++;
// If filters exist
- if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0]))
- {
+ if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
$head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport;
$head[$h][1] = $langs->trans("Step")." 3";
$h++;
@@ -888,20 +849,19 @@ if ($step == 4 && $datatoexport)
print $objexport->array_export_module[0]->getName();
print ' ';
- // Lot de donnees a exporter
- print '
'.$langs->trans("DatasetToExport").' ';
- print '';
+ // Lot de donnees a exporter
+ print ' '.$langs->trans("DatasetToExport").' ';
+ print '';
$entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
$entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
- print img_object($objexport->array_export_module[0]->getName(), $entityicon).' ';
- print $objexport->array_export_label[0];
- print ' ';
+ print img_object($objexport->array_export_module[0]->getName(), $entityicon).' ';
+ print $objexport->array_export_label[0];
+ print '
';
// List of exported fields
print ''.$langs->trans("ExportedFields").' ';
$list = '';
- foreach ($array_selected as $code=>$value)
- {
+ foreach ($array_selected as $code => $value) {
$list .= (!empty($list) ? ', ' : '');
$list .= $langs->trans($objexport->array_export_fields[0][$code]);
}
@@ -909,19 +869,18 @@ if ($step == 4 && $datatoexport)
print ' ';
// List of filtered fiels
- if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0]))
- {
+ if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
print ''.$langs->trans("FilteredFields").' ';
$list = '';
- if (!empty($array_filtervalue))
- {
- foreach ($array_filtervalue as $code=>$value)
- {
- if (isset($objexport->array_export_fields[0][$code]))
- {
+ if (!empty($array_filtervalue)) {
+ foreach ($array_filtervalue as $code => $value) {
+ if (isset($objexport->array_export_fields[0][$code])) {
$list .= ($list ? ', ' : '');
- if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) $list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
- else $list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
+ if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) {
+ $list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
+ } else {
+ $list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
+ }
}
}
}
@@ -949,8 +908,7 @@ if ($step == 4 && $datatoexport)
//print ''.$langs->trans("FieldsTitle").' ';
print ' ';
- foreach ($array_selected as $code=>$value)
- {
+ foreach ($array_selected as $code => $value) {
print '';
$entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
@@ -960,8 +918,7 @@ if ($step == 4 && $datatoexport)
print '';
// If value of entityicon=entitylang='icon:Label'
$tmparray = explode(':', $entityicon);
- if (count($tmparray) >= 2)
- {
+ if (count($tmparray) >= 2) {
$entityicon = $tmparray[0];
$entitylang = $tmparray[1];
}
@@ -974,22 +931,18 @@ if ($step == 4 && $datatoexport)
$tablename = getablenamefromfield($code, $sqlmaxforexport);
$htmltext = ''.$langs->trans("Name").': '.$text.' ';
- if (!empty($objexport->array_export_special[0][$code]))
- {
+ if (!empty($objexport->array_export_special[0][$code])) {
$htmltext .= ''.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." : ".$objexport->array_export_special[0][$code]." ";
} else {
$htmltext .= ''.$langs->trans("Table")." -> ".$langs->trans("Field").": ".$tablename." -> ".preg_replace('/^.*\./', '', $code)." ";
}
- if (!empty($objexport->array_export_examplevalues[0][$code]))
- {
+ if (!empty($objexport->array_export_examplevalues[0][$code])) {
$htmltext .= ''.$langs->trans("SourceExample").': '.$objexport->array_export_examplevalues[0][$code].' ';
}
- if (!empty($objexport->array_export_TypeFields[0][$code]))
- {
+ if (!empty($objexport->array_export_TypeFields[0][$code])) {
$htmltext .= ''.$langs->trans("Type").': '.$objexport->array_export_TypeFields[0][$code].' ';
}
- if (!empty($objexport->array_export_help[0][$code]))
- {
+ if (!empty($objexport->array_export_help[0][$code])) {
$htmltext .= ''.$langs->trans("Help").': '.$langs->trans($objexport->array_export_help[0][$code]).' ';
}
@@ -1001,8 +954,12 @@ if ($step == 4 && $datatoexport)
print ' ';
print $value.' ';
print ' ';
- if ($value < count($array_selected)) print ''.img_down().' ';
- if ($value > 1) print ''.img_up().' ';
+ if ($value < count($array_selected)) {
+ print ''.img_down().' ';
+ }
+ if ($value > 1) {
+ print ''.img_up().' ';
+ }
print ' ';
//print ' ';
@@ -1017,13 +974,12 @@ if ($step == 4 && $datatoexport)
print '';
/*
- * Barre d'action
- *
- */
+ * Barre d'action
+ *
+ */
print '';
- if (count($array_selected))
- {
+ if (count($array_selected)) {
print '
'.$langs->trans("NextStep").' ';
}
@@ -1031,8 +987,7 @@ if ($step == 4 && $datatoexport)
// Area for profils export
- if (count($array_selected))
- {
+ if (count($array_selected)) {
print '
';
print '
';
@@ -1062,15 +1017,15 @@ if ($step == 4 && $datatoexport)
$sql = "SELECT rowid, label";
$sql .= " FROM ".MAIN_DB_PREFIX."export_model";
$sql .= " WHERE type = '".$db->escape($datatoexport)."'";
- if (empty($conf->global->EXPORTS_SHARE_MODELS))$sql .= " AND fk_user=".$user->id;
+ if (empty($conf->global->EXPORTS_SHARE_MODELS)) {
+ $sql .= " AND fk_user=".$user->id;
+ }
$sql .= " ORDER BY rowid";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
print '
';
print $obj->label;
@@ -1092,10 +1047,8 @@ if ($step == 4 && $datatoexport)
}
}
-if ($step == 5 && $datatoexport)
-{
- if (count($array_selected) < 1) // This occurs when going back to page after sessecion expired
- {
+if ($step == 5 && $datatoexport) {
+ if (count($array_selected) < 1) { // This occurs when going back to page after sessecion expired
// Switch to step 2
header("Location: ".DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport);
exit;
@@ -1117,8 +1070,7 @@ if ($step == 5 && $datatoexport)
$h++;
// si le filtrage est parametre pour l'export ou pas
- if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0]))
- {
+ if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
$head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport;
$head[$h][1] = $langs->trans("Step")." 3";
$h++;
@@ -1137,10 +1089,9 @@ if ($step == 5 && $datatoexport)
print dol_get_fiche_head($head, $hselected, '', -2);
/*
- * Confirmation suppression fichier
- */
- if ($action == 'remove_file')
- {
+ * Confirmation suppression fichier
+ */
+ if ($action == 'remove_file') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?step=5&datatoexport='.$datatoexport.'&file='.urlencode(GETPOST("file")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
}
@@ -1156,39 +1107,37 @@ if ($step == 5 && $datatoexport)
print $objexport->array_export_module[0]->getName();
print ' ';
- // Dataset to export
- print '
'.$langs->trans("DatasetToExport").' ';
- print '';
- $entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
- $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
- print img_object($objexport->array_export_module[0]->getName(), $entityicon).' ';
- print $objexport->array_export_label[0];
- print ' ';
+ // Dataset to export
+ print '
'.$langs->trans("DatasetToExport").' ';
+ print '';
+ $entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
+ $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
+ print img_object($objexport->array_export_module[0]->getName(), $entityicon).' ';
+ print $objexport->array_export_label[0];
+ print ' ';
// List of exported fields
print '
'.$langs->trans("ExportedFields").' ';
$list = '';
- foreach ($array_selected as $code=>$label)
- {
+ foreach ($array_selected as $code => $label) {
$list .= (!empty($list) ? ', ' : '');
$list .= $langs->trans($objexport->array_export_fields[0][$code]);
}
print ''.$list.' ';
// List of filtered fields
- if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0]))
- {
+ if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
print '
'.$langs->trans("FilteredFields").' ';
$list = '';
- if (!empty($array_filtervalue))
- {
- foreach ($array_filtervalue as $code=>$value)
- {
- if (isset($objexport->array_export_fields[0][$code]))
- {
+ if (!empty($array_filtervalue)) {
+ foreach ($array_filtervalue as $code => $value) {
+ if (isset($objexport->array_export_fields[0][$code])) {
$list .= ($list ? ', ' : '');
- if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) $list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
- else $list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
+ if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) {
+ $list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
+ } else {
+ $list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
+ }
}
}
}
@@ -1211,10 +1160,8 @@ if ($step == 5 && $datatoexport)
$liste = $objmodelexport->liste_modeles($db);
$listeall = $liste;
- foreach ($listeall as $key => $val)
- {
- if (preg_match('/__\(Disabled\)__/', $listeall[$key]))
- {
+ foreach ($listeall as $key => $val) {
+ if (preg_match('/__\(Disabled\)__/', $listeall[$key])) {
$listeall[$key] = preg_replace('/__\(Disabled\)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $listeall[$key]);
unset($liste[$key]);
}
@@ -1237,13 +1184,14 @@ if ($step == 5 && $datatoexport)
print '';
- if ($sqlusedforexport && $user->admin)
- {
+ if ($sqlusedforexport && $user->admin) {
print info_admin($langs->trans("SQLUsedForExport").': '.$sqlusedforexport, 0, 0, 1, '', 'TechnicalInformation');
}
- if (!is_dir($conf->export->dir_temp)) dol_mkdir($conf->export->dir_temp);
+ if (!is_dir($conf->export->dir_temp)) {
+ dol_mkdir($conf->export->dir_temp);
+ }
// Show existing generated documents
// NB: La fonction show_documents rescanne les modules qd genallowed=1, sinon prend $liste
@@ -1273,8 +1221,9 @@ function getablenamefromfield($code, $sqlmaxforexport)
$newsql = preg_replace('/^(.*) FROM /i', '', $newsql); // Remove part before the FROM
$newsql = preg_replace('/WHERE (.*)$/i', '', $newsql); // Remove part after the WHERE so we have now only list of table aliases in a string. We must keep the ' ' before WHERE
- if (preg_match($regexstring, $newsql, $reg))
- {
+ if (preg_match($regexstring, $newsql, $reg)) {
return $reg[1]; // The tablename
- } else return '';
+ } else {
+ return '';
+ }
}
diff --git a/htdocs/exports/index.php b/htdocs/exports/index.php
index 79655a19b2f..3bff58453ab 100644
--- a/htdocs/exports/index.php
+++ b/htdocs/exports/index.php
@@ -48,8 +48,7 @@ print ' ';
print '';
-if (count($export->array_export_code))
-{
+if (count($export->array_export_code)) {
print dolGetButtonTitle($langs->trans('NewExport'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/exports/export.php?leftmenu=export', '', $user->rights->export->creer);
}
print '
';
@@ -71,10 +70,8 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
$model = new ModeleExports($db);
$liste = $model->liste_modeles($db); // This is not a static method for exports because method load non static properties
-foreach ($liste as $key => $val)
-{
- if (preg_match('/__\(Disabled\)__/', $liste[$key]))
- {
+foreach ($liste as $key => $val) {
+ if (preg_match('/__\(Disabled\)__/', $liste[$key])) {
$liste[$key] = preg_replace('/__\(Disabled\)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $liste[$key]);
}
diff --git a/htdocs/externalsite/admin/externalsite.php b/htdocs/externalsite/admin/externalsite.php
index 66c6d265dec..47f0a3d57be 100644
--- a/htdocs/externalsite/admin/externalsite.php
+++ b/htdocs/externalsite/admin/externalsite.php
@@ -26,14 +26,17 @@
* \brief Page de configuration du module externalsite
*/
-if (!defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti CSRF attack test
+if (!defined('NOSCANPOSTFORINJECTION')) {
+ define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti CSRF attack test
+}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-if (!$user->admin)
+if (!$user->admin) {
accessforbidden();
+}
// Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'externalsite'));
@@ -43,8 +46,7 @@ $def = array();
$action = GETPOST('action', 'aZ09');
// Sauvegardes parametres
-if ($action == 'update')
-{
+if ($action == 'update') {
$i = 0;
$db->begin();
@@ -55,8 +57,7 @@ if ($action == 'update')
$i += dolibarr_set_const($db, 'EXTERNALSITE_LABEL', trim($label), 'chaine', 0, '', $conf->entity);
$i += dolibarr_set_const($db, 'EXTERNALSITE_URL', trim($exturl), 'chaine', 0, '', $conf->entity);
- if ($i >= 2)
- {
+ if ($i >= 2) {
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
diff --git a/htdocs/externalsite/frames.php b/htdocs/externalsite/frames.php
index 4827d832af4..04b48ba3cad 100644
--- a/htdocs/externalsite/frames.php
+++ b/htdocs/externalsite/frames.php
@@ -44,35 +44,29 @@ $keyforcontent = GETPOST('keyforcontent', 'aZ09');
* View
*/
-if (empty($keyforcontent) && empty($conf->global->EXTERNALSITE_URL))
-{
+if (empty($keyforcontent) && empty($conf->global->EXTERNALSITE_URL)) {
llxHeader();
print ''.$langs->trans('ExternalSiteModuleNotComplete').'
';
llxFooter();
exit;
}
-if (!empty($keyforcontent))
-{
+if (!empty($keyforcontent)) {
llxHeader();
print '';
if (!preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent)
- && !preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent))
- {
+ && !preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent)) {
$langs->load("errors");
print $langs->trans("ErrorBadSyntaxForParamKeyForContent", 'EXTERNAL_SITE_CONTENT_', 'EXTERNAL_SITE_URL_');
- } elseif (empty($conf->global->$keyforcontent))
- {
+ } elseif (empty($conf->global->$keyforcontent)) {
$langs->load("errors");
print $langs->trans("ErrorVariableKeyForContentMustBeSet", 'EXTERNAL_SITE_CONTENT_'.$keyforcontent, 'EXTERNAL_SITE_URL_'.$keyforcontent);
} else {
- if (preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent))
- {
+ if (preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent)) {
print $conf->global->$keyforcontent;
- } elseif (preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent))
- {
+ } elseif (preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent)) {
/*print "
@@ -80,17 +74,17 @@ if (!empty($keyforcontent))
global->MAIN_MENU_INVERT)?"rows":"cols")."=\"".$heightforframes.",*\" border=0 framespacing=0 frameborder=0>
-
+
";
print ' ';
print "
-
-
+
+
-
-
+
+
@@ -111,8 +105,7 @@ if (!empty($keyforcontent))
print '';
llxFooter();
} else {
- if (preg_match('/^\//', $conf->global->EXTERNALSITE_URL) || preg_match('/^http/i', $conf->global->EXTERNALSITE_URL))
- {
+ if (preg_match('/^\//', $conf->global->EXTERNALSITE_URL) || preg_match('/^http/i', $conf->global->EXTERNALSITE_URL)) {
print "
diff --git a/htdocs/fichinter/admin/fichinter_extrafields.php b/htdocs/fichinter/admin/fichinter_extrafields.php
index 0fa5a930f05..2fec51a0f5b 100644
--- a/htdocs/fichinter/admin/fichinter_extrafields.php
+++ b/htdocs/fichinter/admin/fichinter_extrafields.php
@@ -39,13 +39,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 = 'fichinter'; //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 '
";
@@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit')
/* */
/* ************************************************************************** */
-if ($action == 'create')
-{
+if ($action == 'create') {
print '
';
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 "
";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
diff --git a/htdocs/fichinter/admin/fichinterdet_extrafields.php b/htdocs/fichinter/admin/fichinterdet_extrafields.php
index f648548c3b4..1cbdeb4cf0a 100644
--- a/htdocs/fichinter/admin/fichinterdet_extrafields.php
+++ b/htdocs/fichinter/admin/fichinterdet_extrafields.php
@@ -39,13 +39,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 = 'fichinterdet'; //Must be the $element of the class that manage extrafield
-if (!$user->admin) accessforbidden();
+if (!$user->admin) {
+ accessforbidden();
+}
/*
@@ -78,8 +82,7 @@ print dol_get_fiche_end();
// Buttons
-if ($action != 'create' && $action != 'edit')
-{
+if ($action != 'create' && $action != 'edit') {
print '
";
@@ -92,8 +95,7 @@ if ($action != 'create' && $action != 'edit')
/* */
/* ************************************************************************** */
-if ($action == 'create')
-{
+if ($action == 'create') {
print '
';
print load_fiche_titre($langs->trans('NewAttribute'));
@@ -105,8 +107,7 @@ if ($action == 'create')
/* Edition d'un champ optionnel */
/* */
/* ************************************************************************** */
-if ($action == 'edit' && !empty($attrname))
-{
+if ($action == 'edit' && !empty($attrname)) {
print "
";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php
index f245084f8db..775f83ef500 100644
--- a/htdocs/fichinter/card-rec.php
+++ b/htdocs/fichinter/card-rec.php
@@ -52,22 +52,29 @@ $langs->loadLangs(array("interventions", "admin", "compta", "bills"));
// Security check
$id = (GETPOST('fichinterid', 'int') ?GETPOST('fichinterid', 'int') : GETPOST('id', 'int'));
$action = GETPOST('action', 'aZ09');
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$objecttype = 'fichinter_rec';
-if ($action == "create" || $action == "add") $objecttype = '';
+if ($action == "create" || $action == "add") {
+ $objecttype = '';
+}
$result = restrictedArea($user, 'ficheinter', $id, $objecttype);
-if ($page == -1)
+if ($page == -1) {
$page = 0;
+}
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
-if ($sortorder == "")
+if ($sortorder == "") {
$sortorder = "DESC";
+}
-if ($sortfield == "")
+if ($sortfield == "") {
$sortfield = "f.datec";
+}
$object = new FichinterRec($db);
$extrafields = new ExtraFields($db);
@@ -212,7 +219,9 @@ if ($action == 'add') {
// Set next date of execution
$object->fetch($id);
$date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear'));
- if (!empty($date)) $object->setNextDate($date);
+ if (!empty($date)) {
+ $object->setNextDate($date);
+ }
} elseif ($action == 'setnb_gen_max' && $user->rights->ficheinter->creer) {
// Set max period
$object->fetch($id);
@@ -224,7 +233,9 @@ if ($action == 'add') {
* View
*/
-llxHeader('', $langs->trans("RepeatableIntervention"), 'ch-fichinter.html#s-fac-fichinter-rec');
+$help_url = '';
+
+llxHeader('', $langs->trans("RepeatableIntervention"), $help_url);
$form = new Form($db);
$companystatic = new Societe($db);
@@ -259,8 +270,12 @@ if ($action == 'create') {
print dol_get_fiche_head();
$rowspan = 4;
- if (!empty($conf->projet->enabled) && $object->fk_project > 0) $rowspan++;
- if (!empty($conf->contrat->enabled) && $object->fk_contrat > 0) $rowspan++;
+ if (!empty($conf->projet->enabled) && $object->fk_project > 0) {
+ $rowspan++;
+ }
+ if (!empty($conf->contrat->enabled) && $object->fk_contrat > 0) {
+ $rowspan++;
+ }
print '
';
} else {
- if ($object->frequency > 0)
+ if ($object->frequency > 0) {
print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
- else print $langs->trans("NotARecurringInterventionalTemplate");
+ } else {
+ print $langs->trans("NotARecurringInterventionalTemplate");
+ }
}
print '
';
@@ -617,12 +634,16 @@ if ($action == 'create') {
print '
';
if ($user->rights->ficheinter->creer && ($action == 'nb_gen_max' || $object->frequency > 0)) {
print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer);
- } else print $langs->trans("MaxPeriodNumber");
+ } else {
+ print $langs->trans("MaxPeriodNumber");
+ }
print ' ';
if ($action == 'nb_gen_max' || $object->frequency > 0) {
print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max : '', $object, $user->rights->facture->creer);
- } else print '';
+ } else {
+ print '';
+ }
print ' ';
print '';
@@ -686,13 +707,19 @@ if ($action == 'create') {
$i = 0;
while ($i < $num) {
// Show product and description
- if (isset($object->lines[$i]->product_type))
+ if (isset($object->lines[$i]->product_type)) {
$type = $object->lines[$i]->product_type;
- else $object->lines[$i]->fk_product_type;
+ } else {
+ $object->lines[$i]->fk_product_type;
+ }
// Try to enhance type detection using date_start and date_end for free lines when type
// was not saved.
- if (!empty($objp->date_start)) $type = 1;
- if (!empty($objp->date_end)) $type = 1;
+ if (!empty($objp->date_start)) {
+ $type = 1;
+ }
+ if (!empty($objp->date_end)) {
+ $type = 1;
+ }
// Show line
print '
';
@@ -725,7 +752,9 @@ if ($action == 'create') {
print $langs->trans('Delete').'';
}
print '';
- } else print $langs->trans("ErrorRecordNotFound");
+ } else {
+ print $langs->trans("ErrorRecordNotFound");
+ }
} else {
/*
* List mode
@@ -741,14 +770,24 @@ if ($action == 'create') {
}
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.entity = ".$conf->entity;
- if ($socid) $sql .= " AND s.rowid = ".$socid;
+ 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 ($search_ref) $sql .= natural_search('f.titre', $search_ref);
- if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
- if ($search_frequency == '1') $sql .= ' AND f.frequency > 0';
- if ($search_frequency == '0') $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
+ if ($search_ref) {
+ $sql .= natural_search('f.titre', $search_ref);
+ }
+ if ($search_societe) {
+ $sql .= natural_search('s.nom', $search_societe);
+ }
+ if ($search_frequency == '1') {
+ $sql .= ' AND f.frequency > 0';
+ }
+ if ($search_frequency == '0') {
+ $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
+ }
//$sql .= " ORDER BY $sortfield $sortorder, rowid DESC ";
@@ -853,8 +892,12 @@ if ($action == 'create') {
print '';
print $langs->trans("CreateFichInter").' ';
- } else print $langs->trans("DateIsNotEnough");
- } else print " ";
+ } else {
+ print $langs->trans("DateIsNotEnough");
+ }
+ } else {
+ print " ";
+ }
print "";
diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php
index 6c1dd4ddeb2..d1507d52418 100644
--- a/htdocs/fichinter/card.php
+++ b/htdocs/fichinter/card.php
@@ -36,18 +36,15 @@ require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.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';
}
-if ($conf->contrat->enabled)
-{
+if ($conf->contrat->enabled) {
require_once DOL_DOCUMENT_ROOT."/core/class/html.formcontract.class.php";
require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php";
}
-if (!empty($conf->global->FICHEINTER_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.".php"))
-{
+if (!empty($conf->global->FICHEINTER_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.".php")) {
require_once DOL_DOCUMENT_ROOT."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.'.php';
}
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
@@ -75,7 +72,9 @@ $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
// Security check
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@@ -87,11 +86,14 @@ $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
-if ($id > 0 || !empty($ref))
-{
+if ($id > 0 || !empty($ref)) {
$ret = $object->fetch($id, $ref);
- if ($ret > 0) $ret = $object->fetch_thirdparty();
- if ($ret < 0) dol_print_error('', $object->error);
+ if ($ret > 0) {
+ $ret = $object->fetch_thirdparty();
+ }
+ if ($ret < 0) {
+ dol_print_error('', $object->error);
+ }
}
$permissionnote = $user->rights->ficheinter->creer; // Used by the include of actions_setnotes.inc.php
@@ -106,14 +108,13 @@ $error = 0;
$parameters = array('socid'=>$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 ($cancel)
- {
- if (!empty($backtopage))
- {
+if (empty($reshook)) {
+ if ($cancel) {
+ if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
@@ -125,20 +126,16 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
// Action clone object
- if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->ficheinter->creer)
- {
- if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers'))
- {
+ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->ficheinter->creer) {
+ if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) {
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
} else {
- if ($object->id > 0)
- {
+ if ($object->id > 0) {
// Because createFromClone modifies the object, we must clone it so that we can restore it later
$orig = clone $object;
$result = $object->createFromClone($user, $socid);
- if ($result > 0)
- {
+ if ($result > 0) {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
exit;
} else {
@@ -150,21 +147,21 @@ if (empty($reshook))
}
}
- if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer)
- {
+ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer) {
$result = $object->setValid($user);
- if ($result >= 0)
- {
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
- {
+ if ($result >= 0) {
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
- if (!empty($newlang))
- {
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
+ }
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ $newlang = $object->thirdparty->default_lang;
+ }
+ if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
@@ -178,15 +175,17 @@ if (empty($reshook))
}
} elseif ($action == 'confirm_modify' && $confirm == 'yes' && $user->rights->ficheinter->creer) {
$result = $object->setDraft($user);
- if ($result >= 0)
- {
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
- {
+ if ($result >= 0) {
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
+ }
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ $newlang = $object->thirdparty->default_lang;
+ }
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@@ -212,16 +211,13 @@ if (empty($reshook))
$object->note_private = GETPOST('note_private', 'restricthtml');
$object->note_public = GETPOST('note_public', 'restricthtml');
- if ($object->socid > 0)
- {
+ if ($object->socid > 0) {
// If creation from another object of another module (Example: origin=propal, originid=1)
- if (!empty($origin) && !empty($originid))
- {
+ if (!empty($origin) && !empty($originid)) {
// Parse element/subelement (ex: project_task)
$regs = array();
$element = $subelement = GETPOST('origin', 'alphanohtml');
- if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs))
- {
+ if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs)) {
$element = $regs[1];
$subelement = $regs[2];
}
@@ -242,8 +238,7 @@ if (empty($reshook))
// Possibility to add external linked objects with hooks
$object->linked_objects[$object->origin] = $object->origin_id;
- if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects']))
- {
+ if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) {
$object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']);
}
@@ -261,8 +256,7 @@ if (empty($reshook))
$id = $object->create($user);
- if ($id > 0)
- {
+ if ($id > 0) {
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
$classname = ucfirst($subelement);
@@ -270,12 +264,10 @@ if (empty($reshook))
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
$result = $srcobject->fetch($object->origin_id);
- if ($result > 0)
- {
+ if ($result > 0) {
$srcobject->fetch_thirdparty();
$lines = $srcobject->lines;
- if (empty($lines) && method_exists($srcobject, 'fetch_lines'))
- {
+ if (empty($lines) && method_exists($srcobject, 'fetch_lines')) {
$srcobject->fetch_lines();
$lines = $srcobject->lines;
}
@@ -283,9 +275,10 @@ if (empty($reshook))
if (is_array($lines)) {
$num = count($lines);
- for ($i = 0; $i < $num; $i++)
- {
- if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines
+ for ($i = 0; $i < $num; $i++) {
+ if (!in_array($lines[$i]->id, $selectedLines)) {
+ continue; // Skip unselected lines
+ }
$product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : Product::TYPE_PRODUCT);
@@ -293,8 +286,7 @@ if (empty($reshook))
$duration = 3600; // Default to one hour
// Predefined products & services
- if ($lines[$i]->fk_product > 0)
- {
+ if ($lines[$i]->fk_product > 0) {
$prod = new Product($db);
$prod->id = $lines[$i]->fk_product;
@@ -305,8 +297,12 @@ if (empty($reshook))
$prod->fetch($lines[$i]->fk_product);
$outputlangs = $langs;
$newlang = '';
- if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
- if (empty($newlang)) $newlang = $srcobject->thirdparty->default_lang;
+ if (empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
+ }
+ if (empty($newlang)) {
+ $newlang = $srcobject->thirdparty->default_lang;
+ }
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@@ -367,12 +363,11 @@ if (empty($reshook))
$id,
$desc,
$date_intervention,
- $duration,
- $array_options
+ $duration,
+ $array_options
);
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
break;
}
@@ -395,16 +390,14 @@ if (empty($reshook))
$action = 'create';
}
- if (!$error)
- {
+ if (!$error) {
// Extrafields
$array_options = $extrafields->getOptionalsFromPost($object->table_element);
$object->array_options = $array_options;
$result = $object->create($user);
- if ($result > 0)
- {
+ if ($result > 0) {
$id = $result; // Force raffraichissement sur fiche venant d'etre cree
} else {
$langs->load("errors");
@@ -429,22 +422,19 @@ if (empty($reshook))
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
- }
-
- // Set into a project
- elseif ($action == 'classin' && $user->rights->ficheinter->creer)
- {
+ } elseif ($action == 'classin' && $user->rights->ficheinter->creer) {
+ // Set into a project
$result = $object->setProject(GETPOST('projectid', 'int'));
- if ($result < 0) dol_print_error($db, $object->error);
- }
-
- // Set into a contract
- elseif ($action == 'setcontract' && $user->rights->contrat->creer)
- {
+ if ($result < 0) {
+ dol_print_error($db, $object->error);
+ }
+ } elseif ($action == 'setcontract' && $user->rights->contrat->creer) {
+ // Set into a contract
$result = $object->set_contrat($user, GETPOST('contratid', 'int'));
- if ($result < 0) dol_print_error($db, $object->error);
- } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer)
- {
+ if ($result < 0) {
+ dol_print_error($db, $object->error);
+ }
+ } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer) {
$result = $object->delete($user);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@@ -452,32 +442,26 @@ if (empty($reshook))
header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter&restore_lastsearch_values=1');
exit;
- } elseif ($action == 'setdescription' && $user->rights->ficheinter->creer)
- {
+ } elseif ($action == 'setdescription' && $user->rights->ficheinter->creer) {
$result = $object->set_description($user, GETPOST('description'));
- if ($result < 0) dol_print_error($db, $object->error);
- }
-
- // Add line
- elseif ($action == "addline" && $user->rights->ficheinter->creer)
- {
- if (!GETPOST('np_desc', 'restricthtml') && empty($conf->global->FICHINTER_EMPTY_LINE_DESC))
- {
+ if ($result < 0) {
+ dol_print_error($db, $object->error);
+ }
+ } elseif ($action == "addline" && $user->rights->ficheinter->creer) {
+ // Add line
+ if (!GETPOST('np_desc', 'restricthtml') && empty($conf->global->FICHINTER_EMPTY_LINE_DESC)) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description"));
$error++;
}
- if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && !GETPOST('durationhour', 'int') && !GETPOST('durationmin', 'int'))
- {
+ if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && !GETPOST('durationhour', 'int') && !GETPOST('durationmin', 'int')) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Duration"));
$error++;
}
- if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && GETPOST('durationhour', 'int') >= 24 && GETPOST('durationmin', 'int') > 0)
- {
+ if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && GETPOST('durationhour', 'int') >= 24 && GETPOST('durationmin', 'int') > 0) {
$mesg = $langs->trans("ErrorValueTooHigh");
$error++;
}
- if (!$error)
- {
+ if (!$error) {
$db->begin();
$desc = GETPOST('np_desc', 'restricthtml');
@@ -500,19 +484,23 @@ if (empty($reshook))
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
- if (!empty($newlang))
- {
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
+ }
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ $newlang = $object->thirdparty->default_lang;
+ }
+ if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
- if ($result >= 0)
- {
+ if ($result >= 0) {
$db->commit();
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs);
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
+ fichinter_create($db, $object, $object->model_pdf, $outputlangs);
+ }
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
} else {
@@ -520,11 +508,8 @@ if (empty($reshook))
$db->rollback();
}
}
- }
-
- // Classify Billed
- elseif ($action == 'classifybilled' && $user->rights->ficheinter->creer)
- {
+ } elseif ($action == 'classifybilled' && $user->rights->ficheinter->creer) {
+ // Classify Billed
$result = $object->setStatut(2);
if ($result > 0) {
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
@@ -532,61 +517,42 @@ if (empty($reshook))
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
- }
-
- // Classify unbilled
- elseif ($action == 'classifyunbilled' && $user->rights->ficheinter->creer)
- {
+ } elseif ($action == 'classifyunbilled' && $user->rights->ficheinter->creer) {
+ // Classify unbilled
$result = $object->setStatut(1);
- if ($result > 0)
- {
+ if ($result > 0) {
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
} else {
$mesg = $object->error;
}
- }
-
- // Classify Done
- elseif ($action == 'classifydone' && $user->rights->ficheinter->creer)
- {
+ } elseif ($action == 'classifydone' && $user->rights->ficheinter->creer) {
+ // Classify Done
$result = $object->setStatut(3);
- if ($result > 0)
- {
+ if ($result > 0) {
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
- }
-
- // Reopen
- elseif ($action == 'confirm_reopen' && $user->rights->ficheinter->creer)
- {
+ } elseif ($action == 'confirm_reopen' && $user->rights->ficheinter->creer) {
+ // Reopen
$result = $object->setStatut(Fichinter::STATUS_VALIDATED);
- if ($result > 0)
- {
+ if ($result > 0) {
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
- }
- else {
+ } else {
$mesg = $object->error;
}
- }
-
- /*
- * Mise a jour d'une ligne d'intervention
- */
- elseif ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST('save', 'alpha') == $langs->trans("Save")) {
+ } elseif ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST('save', 'alpha') == $langs->trans("Save")) {
+ // Mise a jour d'une ligne d'intervention
$objectline = new FichinterLigne($db);
- if ($objectline->fetch($lineid) <= 0)
- {
+ if ($objectline->fetch($lineid) <= 0) {
dol_print_error($db);
exit;
}
- if ($object->fetch($objectline->fk_fichinter) <= 0)
- {
+ if ($object->fetch($objectline->fk_fichinter) <= 0) {
dol_print_error($db);
exit;
}
@@ -606,8 +572,7 @@ if (empty($reshook))
$objectline->array_options = $array_options;
$result = $objectline->update($user);
- if ($result < 0)
- {
+ if ($result < 0) {
dol_print_error($db);
exit;
}
@@ -615,34 +580,32 @@ if (empty($reshook))
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
- if (!empty($newlang))
- {
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
+ }
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ $newlang = $object->thirdparty->default_lang;
+ }
+ if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs);
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
+ fichinter_create($db, $object, $object->model_pdf, $outputlangs);
+ }
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
- }
-
- /*
- * Supprime une ligne d'intervention AVEC confirmation
- */
- elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->ficheinter->creer)
- {
+ } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->ficheinter->creer) {
+ // Supprime une ligne d'intervention AVEC confirmation
$objectline = new FichinterLigne($db);
- if ($objectline->fetch($lineid) <= 0)
- {
+ if ($objectline->fetch($lineid) <= 0) {
dol_print_error($db);
exit;
}
$result = $objectline->deleteline($user);
- if ($object->fetch($objectline->fk_fichinter) <= 0)
- {
+ if ($object->fetch($objectline->fk_fichinter) <= 0) {
dol_print_error($db);
exit;
}
@@ -650,52 +613,61 @@ if (empty($reshook))
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
- if (!empty($newlang))
- {
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
+ }
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ $newlang = $object->thirdparty->default_lang;
+ }
+ if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs);
- }
-
- /*
- * Set position of lines
- */
- elseif ($action == 'up' && $user->rights->ficheinter->creer)
- {
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
+ fichinter_create($db, $object, $object->model_pdf, $outputlangs);
+ }
+ } elseif ($action == 'up' && $user->rights->ficheinter->creer) {
+ // Set position of lines
$object->line_up($lineid);
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
- if (!empty($newlang))
- {
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
+ }
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ $newlang = $object->thirdparty->default_lang;
+ }
+ if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs);
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
+ fichinter_create($db, $object, $object->model_pdf, $outputlangs);
+ }
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid);
exit;
- } elseif ($action == 'down' && $user->rights->ficheinter->creer)
- {
+ } elseif ($action == 'down' && $user->rights->ficheinter->creer) {
$object->line_down($lineid);
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
- if (!empty($newlang))
- {
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
+ }
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ $newlang = $object->thirdparty->default_lang;
+ }
+ if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs);
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
+ fichinter_create($db, $object, $object->model_pdf, $outputlangs);
+ }
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid);
exit;
@@ -715,66 +687,55 @@ if (empty($reshook))
$permissiontoadd = $user->rights->ficheinter->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
- if ($action == 'update_extras')
- {
+ if ($action == 'update_extras') {
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
- if ($ret < 0) $error++;
+ if ($ret < 0) {
+ $error++;
+ }
- if (!$error)
- {
+ if (!$error) {
// Actions on extra fields
$result = $object->insertExtraFields('INTERVENTION_MODIFY');
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
- if ($error) $action = 'edit_extras';
+ if ($error) {
+ $action = 'edit_extras';
+ }
}
- if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheinter->creer)
- {
- if ($action == 'addcontact')
- {
- if ($result > 0 && $id > 0)
- {
+ if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheinter->creer) {
+ if ($action == 'addcontact') {
+ 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 = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
} else {
$mesg = $object->error;
}
}
- }
-
- // bascule du statut d'un contact
- elseif ($action == 'swapstatut')
- {
+ } elseif ($action == 'swapstatut') {
+ // bascule du statut d'un contact
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
- }
-
- // Efface un contact
- elseif ($action == 'deletecontact')
- {
+ } elseif ($action == 'deletecontact') {
+ // Efface un contact
$result = $object->delete_contact(GETPOST('lineid', 'int'));
- if ($result >= 0)
- {
+ if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@@ -791,13 +752,16 @@ if (empty($reshook))
$form = new Form($db);
$formfile = new FormFile($db);
-if ($conf->contrat->enabled) $formcontract = new FormContract($db);
-if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
+if ($conf->contrat->enabled) {
+ $formcontract = new FormContract($db);
+}
+if (!empty($conf->projet->enabled)) {
+ $formproject = new FormProjets($db);
+}
llxHeader('', $langs->trans("Intervention"));
-if ($action == 'create')
-{
+if ($action == 'create') {
// Create new intervention
$soc = new Societe($db);
@@ -810,21 +774,20 @@ if ($action == 'create')
dol_htmloutput_mesg($mesg);
}
- if ($socid) $res = $soc->fetch($socid);
+ if ($socid) {
+ $res = $soc->fetch($socid);
+ }
- if (GETPOST('origin', 'alphanohtml') && GETPOST('originid', 'int'))
- {
+ if (GETPOST('origin', 'alphanohtml') && GETPOST('originid', 'int')) {
// Parse element/subelement (ex: project_task)
$regs = array();
$element = $subelement = GETPOST('origin', 'alphanohtml');
- if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs))
- {
+ if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs)) {
$element = $regs[1];
$subelement = $regs[2];
}
- if ($element == 'project')
- {
+ if ($element == 'project') {
$projectid = GETPOST('originid', 'int');
} else {
// For compatibility
@@ -843,8 +806,7 @@ if ($action == 'create')
$classname = ucfirst($subelement);
$objectsrc = new $classname($db);
$objectsrc->fetch(GETPOST('originid'));
- if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines'))
- {
+ if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) {
$objectsrc->fetch_lines();
$lines = $objectsrc->lines;
}
@@ -864,8 +826,7 @@ if ($action == 'create')
$projectid = GETPOST('projectid', 'int');
}
- if (!$conf->global->FICHEINTER_ADDON)
- {
+ if (!$conf->global->FICHEINTER_ADDON) {
dol_print_error($db, $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined"));
exit;
}
@@ -878,8 +839,7 @@ if ($action == 'create')
//$modFicheinter = new $obj;
//$numpr = $modFicheinter->getNextValue($soc, $object);
- if ($socid > 0)
- {
+ if ($socid > 0) {
$soc = new Societe($db);
$soc->fetch($socid);
@@ -904,35 +864,31 @@ if ($action == 'create')
print ' ';
// Project
- if (!empty($conf->projet->enabled))
- {
+ if (!empty($conf->projet->enabled)) {
$formproject = new FormProjets($db);
$langs->load("project");
print '
'.$langs->trans("Project").' ';
/* Fix: If a project must be linked to any companies (suppliers or not), project must be not be set as limited to customer but must be not linked to any particular thirdparty
- if ($societe->fournisseur==1)
- $numprojet=select_projects(-1,$_POST["projectid"],'projectid');
- else
- $numprojet=select_projects($societe->id,$_POST["projectid"],'projectid');
- */
+ if ($societe->fournisseur==1)
+ $numprojet=select_projects(-1,$_POST["projectid"],'projectid');
+ else
+ $numprojet=select_projects($societe->id,$_POST["projectid"],'projectid');
+ */
$numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid');
- if ($numprojet == 0)
- {
+ if ($numprojet == 0) {
print ' ';
}
print ' ';
}
// Contract
- if ($conf->contrat->enabled)
- {
+ if ($conf->contrat->enabled) {
$langs->load("contracts");
print '
'.$langs->trans("Contract").' ';
$numcontrat = $formcontract->select_contract($soc->id, GETPOST('contratid', 'int'), 'contratid', 0, 1, 1);
- if ($numcontrat == 0)
- {
+ if ($numcontrat == 0) {
print ' ';
}
print ' ';
@@ -956,8 +912,7 @@ if ($action == 'create')
print '
';
// Private note
- if (empty($user->socid))
- {
+ if (empty($user->socid)) {
print '';
print ''.$langs->trans('NotePrivate').' ';
print '';
@@ -971,47 +926,46 @@ if ($action == 'create')
$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');
}
// Show link to origin object
- if (!empty($origin) && !empty($originid) && is_object($objectsrc))
- {
+ if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
$newclassname = $classname;
- if ($newclassname == 'Propal') $newclassname = 'CommercialProposal';
+ if ($newclassname == 'Propal') {
+ $newclassname = 'CommercialProposal';
+ }
print ' '.$langs->trans($newclassname).' '.$objectsrc->getNomUrl(1).' ';
// Amount
/* Hide amount because we only copy services so amount may differ than source
- print '' . $langs->trans('AmountHT') . ' ' . price($objectsrc->total_ht) . ' ';
- print '' . $langs->trans('AmountVAT') . ' ' . price($objectsrc->total_tva) . " ";
- if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE
- {
- print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ' ' . price($objectsrc->total_localtax1) . " ";
- }
+ print '' . $langs->trans('AmountHT') . ' ' . price($objectsrc->total_ht) . ' ';
+ print '' . $langs->trans('AmountVAT') . ' ' . price($objectsrc->total_tva) . " ";
+ if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE
+ {
+ print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ' ' . price($objectsrc->total_localtax1) . " ";
+ }
- if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF
- {
- print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ' ' . price($objectsrc->total_localtax2) . " ";
- }
+ if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF
+ {
+ print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ' ' . price($objectsrc->total_localtax2) . " ";
+ }
- print '' . $langs->trans('AmountTTC') . ' ' . price($objectsrc->total_ttc) . " ";
+ print '' . $langs->trans('AmountTTC') . ' ' . price($objectsrc->total_ttc) . " ";
- if (!empty($conf->multicurrency->enabled))
- {
- print '' . $langs->trans('MulticurrencyAmountHT') . ' ' . price($objectsrc->multicurrency_total_ht) . ' ';
- print '' . $langs->trans('MulticurrencyAmountVAT') . ' ' . price($objectsrc->multicurrency_total_tva) . " ";
- print '' . $langs->trans('MulticurrencyAmountTTC') . ' ' . price($objectsrc->multicurrency_total_ttc) . " ";
- }
- */
+ if (!empty($conf->multicurrency->enabled))
+ {
+ print '' . $langs->trans('MulticurrencyAmountHT') . ' ' . price($objectsrc->multicurrency_total_ht) . ' ';
+ print '' . $langs->trans('MulticurrencyAmountVAT') . ' ' . price($objectsrc->multicurrency_total_tva) . " ";
+ print '' . $langs->trans('MulticurrencyAmountTTC') . ' ' . price($objectsrc->multicurrency_total_ttc) . " ";
+ }
+ */
}
print '
';
- if (is_object($objectsrc))
- {
+ if (is_object($objectsrc)) {
print ' ';
print ' ';
} elseif ($origin == 'project' && !empty($projectid)) {
@@ -1045,8 +999,7 @@ if ($action == 'create')
print dol_get_fiche_head('');
- if (is_object($objectsrc))
- {
+ if (is_object($objectsrc)) {
print ' ';
print ' ';
} elseif ($origin == 'project' && !empty($projectid)) {
@@ -1070,11 +1023,10 @@ if ($action == 'create')
print '';
}
-} elseif ($id > 0 || !empty($ref))
-{
+} elseif ($id > 0 || !empty($ref)) {
/*
* Affichage en mode visu
- */
+ */
$object->fetch($id, $ref);
$object->fetch_thirdparty();
@@ -1095,21 +1047,17 @@ if ($action == 'create')
$formconfirm = '';
// Confirm deletion of intervention
- if ($action == 'delete')
- {
+ if ($action == 'delete') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteIntervention'), $langs->trans('ConfirmDeleteIntervention'), 'confirm_delete', '', 0, 1);
}
// Confirm validation
- if ($action == 'validate')
- {
+ if ($action == 'validate') {
// on verifie si l'objet est en numerotation provisoire
$ref = substr($object->ref, 1, 4);
- if ($ref == 'PROV')
- {
+ if ($ref == 'PROV') {
$numref = $object->getNextNumRef($soc);
- if (empty($numref))
- {
+ if (empty($numref)) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
@@ -1122,20 +1070,17 @@ if ($action == 'create')
}
// Confirm back to draft
- if ($action == 'modify')
- {
+ if ($action == 'modify') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ModifyIntervention'), $langs->trans('ConfirmModifyIntervention'), 'confirm_modify', '', 0, 1);
}
// Confirm back to open
- if ($action == 'reopen')
- {
+ if ($action == 'reopen') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Reopen'), $langs->trans('ConfirmReopenIntervention', $object->ref), 'confirm_reopen', '', 0, 1);
}
// Confirm deletion of line
- if ($action == 'ask_deleteline')
- {
+ if ($action == 'ask_deleteline') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&line_id='.$lineid, $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline', '', 0, 1);
}
@@ -1153,12 +1098,14 @@ if ($action == 'create')
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneIntervention', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
- if (!$formconfirm)
- {
+ if (!$formconfirm) {
$parameters = array('formConfirm' => $formconfirm, 'lineid'=>$lineid);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
- elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
+ if (empty($reshook)) {
+ $formconfirm .= $hookmanager->resPrint;
+ } elseif ($reshook > 0) {
+ $formconfirm = $hookmanager->resPrint;
+ }
}
// Print form confirm
@@ -1176,12 +1123,10 @@ if ($action == 'create')
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project
- if (!empty($conf->projet->enabled))
- {
+ if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->ficheinter->creer)
- {
+ if ($user->rights->ficheinter->creer) {
if ($action != 'classify') {
$morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : ';
}
@@ -1219,8 +1164,7 @@ if ($action == 'create')
print '';
- if (!empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES))
- {
+ if (!empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES)) {
// Date Start
print ''.$langs->trans("Dateo").' ';
print '';
@@ -1252,8 +1196,7 @@ if ($action == 'create')
print ' ';
// Contract
- if ($conf->contrat->enabled)
- {
+ if ($conf->contrat->enabled) {
$langs->load('contracts');
print '';
print '';
@@ -1261,21 +1204,18 @@ if ($action == 'create')
print '';
print ' ';
- if ($action == 'contrat')
- {
+ if ($action == 'contrat') {
$formcontract = new Formcontract($db);
$formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1, 1);
} else {
- if ($object->fk_contrat)
- {
+ if ($object->fk_contrat) {
$contratstatic = new Contrat($db);
$contratstatic->fetch($object->fk_contrat);
//print ''.$projet->title.' ';
@@ -1301,8 +1241,7 @@ if ($action == 'create')
print '';
- if (empty($conf->global->FICHINTER_DISABLE_DETAILS))
- {
+ if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
// Duration
print ''.$langs->trans("TotalDuration").' ';
print ''.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).' ';
@@ -1318,23 +1257,20 @@ if ($action == 'create')
print '
';
- if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
- {
+ if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
$blocname = 'contacts';
$title = $langs->trans('ContactsAddresses');
include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
}
- if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB))
- {
+ if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
$blocname = 'notes';
$title = $langs->trans('Notes');
include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
}
// Line of interventions
- if (empty($conf->global->FICHINTER_DISABLE_DETAILS))
- {
+ if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
print 'id.'" name="addinter" method="post">';
print ' ';
print ' ';
@@ -1356,13 +1292,11 @@ if ($action == 'create')
$sql .= ' ORDER BY ft.rang ASC, ft.date ASC, ft.rowid';
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
- if ($num)
- {
+ if ($num) {
print ' ';
print '';
print '';
@@ -1404,8 +1338,7 @@ if ($action == 'create')
print "\n";
// Icon to edit and delete
- if ($object->statut == 0 && $user->rights->ficheinter->creer)
- {
+ if ($object->statut == 0 && $user->rights->ficheinter->creer) {
print '';
print 'id.'&action=editline&line_id='.$objp->rowid.'#'.$objp->rowid.'">';
print img_edit();
@@ -1414,16 +1347,13 @@ if ($action == 'create')
print img_delete();
print ' ';
print '';
- if ($num > 1)
- {
- if ($i > 0)
- {
+ if ($num > 1) {
+ if ($i > 0) {
print 'id.'&action=up&line_id='.$objp->rowid.'">';
print img_up();
print ' ';
}
- if ($i < $num - 1)
- {
+ if ($i < $num - 1) {
print 'id.'&action=down&line_id='.$objp->rowid.'">';
print img_down();
print ' ';
@@ -1447,8 +1377,7 @@ if ($action == 'create')
}
// Line in update mode
- if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && GETPOST('line_id', 'int') == $objp->rowid)
- {
+ if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && GETPOST('line_id', 'int') == $objp->rowid) {
print ' ';
// No.
@@ -1478,8 +1407,9 @@ if ($action == 'create')
print '';
if (empty($conf->global->FICHINTER_WITHOUT_DURATION)) {
$selectmode = 'select';
- if (!empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION))
+ if (!empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION)) {
$selectmode = 'text';
+ }
$form->select_duration('duration', $objp->duree, 0, $selectmode);
}
print ' ';
@@ -1504,10 +1434,8 @@ if ($action == 'create')
$db->free($resql);
// Add new line
- if ($object->statut == 0 && $user->rights->ficheinter->creer && $action <> 'editline' && empty($conf->global->FICHINTER_DISABLE_DETAILS))
- {
- if (!$num)
- {
+ if ($object->statut == 0 && $user->rights->ficheinter->creer && $action <> 'editline' && empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
+ if (!$num) {
print ' ';
print '';
print '';
@@ -1522,7 +1450,7 @@ if ($action == 'create')
print $langs->trans('Description').'';
print ''.$langs->trans('Date').' ';
print ''.(empty($conf->global->FICHINTER_WITHOUT_DURATION) ? $langs->trans('Duration') : '').' ';
- print ' ';
+ print ' ';
print " \n";
}
@@ -1580,16 +1508,20 @@ if ($action == 'create')
print $lineadd->showOptionals($extrafields, 'edit', array('colspan'=>5));
- if (!$num) print '
';
+ if (!$num) {
+ print '
';
+ }
}
- if ($num) print '
';
+ if ($num) {
+ print '
';
+ }
} else {
dol_print_error($db);
}
print ''."\n";
- }
+ }
print dol_get_fiche_end();
@@ -1605,10 +1537,8 @@ if ($action == 'create')
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
- if (empty($reshook))
- {
- if ($user->socid == 0)
- {
+ if (empty($reshook)) {
+ if ($user->socid == 0) {
if ($action != 'editdescription' && ($action != 'presend')) {
// Validate
if ($object->statut == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || !empty($conf->global->FICHINTER_DISABLE_DETAILS))) {
@@ -1619,31 +1549,33 @@ if ($action == 'create')
}
// Modify
- if ($object->statut == Fichinter::STATUS_VALIDATED && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->unvalidate)))
- {
+ if ($object->statut == Fichinter::STATUS_VALIDATED && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->unvalidate))) {
print '';
}
// Reopen
- if ($object->statut >= Fichinter::STATUS_CLOSED)
- {
- if ($user->rights->ficheinter->creer)
- {
+ if ($object->statut >= Fichinter::STATUS_CLOSED) {
+ if ($user->rights->ficheinter->creer) {
print '';
- } else print '';
+ } else {
+ print '';
+ }
}
// Send
if (empty($user->socid)) {
- if ($object->statut > Fichinter::STATUS_DRAFT)
- {
- if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send)
- {
+ if ($object->statut > Fichinter::STATUS_DRAFT) {
+ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send) {
print '';
- } else print '';
+ } else {
+ print '';
+ }
}
}
@@ -1655,30 +1587,30 @@ if ($action == 'create')
}
// Proposal
- if ($conf->service->enabled && !empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
- {
+ if ($conf->service->enabled && !empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT) {
$langs->load("propal");
- if ($object->statut < Fichinter::STATUS_BILLED)
- {
- if ($user->rights->propal->creer) print '';
- else print '';
+ if ($object->statut < Fichinter::STATUS_BILLED) {
+ if ($user->rights->propal->creer) {
+ print '';
+ } else {
+ print '';
+ }
}
}
// Invoicing
- if (!empty($conf->facture->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
- {
+ if (!empty($conf->facture->enabled) && $object->statut > Fichinter::STATUS_DRAFT) {
$langs->load("bills");
- if ($object->statut < Fichinter::STATUS_BILLED)
- {
- if ($user->rights->facture->creer) print '';
- else print '';
+ if ($object->statut < Fichinter::STATUS_BILLED) {
+ if ($user->rights->facture->creer) {
+ print '';
+ } else {
+ print '';
+ }
}
- if (!empty($conf->global->FICHINTER_CLASSIFY_BILLED)) // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
- {
- if ($object->statut != Fichinter::STATUS_BILLED)
- {
+ if (!empty($conf->global->FICHINTER_CLASSIFY_BILLED)) { // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
+ if ($object->statut != Fichinter::STATUS_BILLED) {
print '';
} else {
print '';
@@ -1687,8 +1619,7 @@ if ($action == 'create')
}
// Done
- if (empty($conf->global->FICHINTER_CLASSIFY_BILLED) && $object->statut > Fichinter::STATUS_DRAFT && $object->statut < Fichinter::STATUS_CLOSED)
- {
+ if (empty($conf->global->FICHINTER_CLASSIFY_BILLED) && $object->statut > Fichinter::STATUS_DRAFT && $object->statut < Fichinter::STATUS_CLOSED) {
print '';
}
@@ -1698,8 +1629,7 @@ if ($action == 'create')
}
// Delete
- if (($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer)
- {
+ if (($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer) {
print '';
}
@@ -1709,8 +1639,7 @@ if ($action == 'create')
print '';
- if ($action != 'presend')
- {
+ if ($action != 'presend') {
print '';
/*
diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php
index 7046a61e2d5..a5ba127a54d 100644
--- a/htdocs/fichinter/class/api_interventions.class.php
+++ b/htdocs/fichinter/class/api_interventions.class.php
@@ -32,7 +32,7 @@ class Interventions extends DolibarrApi
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
- static $FIELDS = array(
+ public static $FIELDS = array(
'socid',
'fk_project',
'description',
@@ -41,7 +41,7 @@ class Interventions extends DolibarrApi
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
- static $FIELDSLINE = array(
+ public static $FIELDSLINE = array(
'description',
'date',
'duree',
@@ -117,27 +117,37 @@ class Interventions 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."fichinter 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('intervention').')';
- 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) {
$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 = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@@ -146,8 +156,7 @@ class Interventions extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
- if ($page < 0)
- {
+ if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
@@ -158,13 +167,11 @@ class Interventions extends DolibarrApi
dol_syslog("API Rest request");
$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);
$fichinter_static = new Fichinter($this->db);
if ($fichinter_static->fetch($obj->rowid)) {
@@ -216,28 +223,28 @@ class Interventions extends DolibarrApi
* @return int
*/
/* TODO
- public function getLines($id)
- {
- if(! DolibarrApiAccess::$user->rights->ficheinter->lire) {
- throw new RestException(401);
- }
+ public function getLines($id)
+ {
+ if(! DolibarrApiAccess::$user->rights->ficheinter->lire) {
+ throw new RestException(401);
+ }
- $result = $this->fichinter->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Intervention not found');
- }
+ $result = $this->fichinter->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Intervention not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
- $this->fichinter->getLinesArray();
- $result = array();
- foreach ($this->fichinter->lines as $line) {
- array_push($result,$this->_cleanObjectDatas($line));
- }
- return $result;
- }
- */
+ if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+ $this->fichinter->getLinesArray();
+ $result = array();
+ foreach ($this->fichinter->lines as $line) {
+ array_push($result,$this->_cleanObjectDatas($line));
+ }
+ return $result;
+ }
+ */
/**
* Add a line to given intervention
@@ -270,11 +277,11 @@ class Interventions extends DolibarrApi
}
$updateRes = $this->fichinter->addLine(
- DolibarrApiAccess::$user,
- $id,
- $this->fichinter->description,
- $this->fichinter->date,
- $this->fichinter->duree
+ DolibarrApiAccess::$user,
+ $id,
+ $this->fichinter->description,
+ $this->fichinter->date,
+ $this->fichinter->duree
);
if ($updateRes > 0) {
@@ -369,8 +376,7 @@ class Interventions extends DolibarrApi
*/
public function closeFichinter($id)
{
- if (!DolibarrApiAccess::$user->rights->ficheinter->creer)
- {
+ if (!DolibarrApiAccess::$user->rights->ficheinter->creer) {
throw new RestException(401, "Insuffisant rights");
}
$result = $this->fichinter->fetch($id);
@@ -408,8 +414,9 @@ class Interventions extends DolibarrApi
{
$fichinter = array();
foreach (Interventions::$FIELDS as $field) {
- if (!isset($data[$field]))
+ if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
+ }
$fichinter[$field] = $data[$field];
}
return $fichinter;
@@ -447,8 +454,9 @@ class Interventions extends DolibarrApi
{
$fichinter = array();
foreach (Interventions::$FIELDSLINE as $field) {
- if (!isset($data[$field]))
+ if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
+ }
$fichinter[$field] = $data[$field];
}
return $fichinter;
diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php
index 39ac094132a..cea1b1ca48c 100644
--- a/htdocs/fichinter/class/fichinter.class.php
+++ b/htdocs/fichinter/class/fichinter.class.php
@@ -204,8 +204,7 @@ class Fichinter extends CommonObject
$sql = "SELECT count(fi.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as fi";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON fi.fk_soc = s.rowid";
- 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";
@@ -213,10 +212,8 @@ class Fichinter extends CommonObject
$sql .= " ".$clause." fi.entity IN (".getEntity('intervention').")";
$resql = $this->db->query($sql);
- if ($resql)
- {
- while ($obj = $this->db->fetch_object($resql))
- {
+ if ($resql) {
+ while ($obj = $this->db->fetch_object($resql)) {
$this->nb["interventions"] = $obj->nb;
}
$this->db->free($resql);
@@ -244,21 +241,20 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::create ref=".$this->ref);
// Check parameters
- if (!empty($this->ref)) // We check that ref is not already used
- {
+ if (!empty($this->ref)) { // We check that ref is not already used
$result = self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used
- if ($result > 0)
- {
+ if ($result > 0) {
$this->error = 'ErrorRefAlreadyExists';
dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING);
$this->db->rollback();
return -1;
}
}
- if (!is_numeric($this->duration)) $this->duration = 0;
+ if (!is_numeric($this->duration)) {
+ $this->duration = 0;
+ }
- if ($this->socid <= 0)
- {
+ if ($this->socid <= 0) {
$this->error = 'ErrorBadParameterForFunc';
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1;
@@ -304,42 +300,42 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."fichinter");
- if ($this->id)
- {
+ if ($this->id) {
$this->ref = '(PROV'.$this->id.')';
$sql = 'UPDATE '.MAIN_DB_PREFIX."fichinter SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql) $error++;
+ if (!$resql) {
+ $error++;
+ }
}
- if (!$error)
- {
+ if (!$error) {
$result = $this->insertExtraFields();
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
// Add linked object
- if (!$error && $this->origin && $this->origin_id)
- {
+ if (!$error && $this->origin && $this->origin_id) {
$ret = $this->add_object_linked();
- if (!$ret) dol_print_error($this->db);
+ if (!$ret) {
+ dol_print_error($this->db);
+ }
}
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('FICHINTER_CREATE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
@@ -370,14 +366,14 @@ class Fichinter extends CommonObject
{
global $conf;
- if (!is_numeric($this->duration)) {
- $this->duration = 0;
- }
- if (!dol_strlen($this->fk_project)) {
- $this->fk_project = 0;
- }
+ if (!is_numeric($this->duration)) {
+ $this->duration = 0;
+ }
+ if (!dol_strlen($this->fk_project)) {
+ $this->fk_project = 0;
+ }
- $error = 0;
+ $error = 0;
$this->db->begin();
@@ -391,22 +387,20 @@ class Fichinter extends CommonObject
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
- if ($this->db->query($sql))
- {
- if (!$error)
- {
+ if ($this->db->query($sql)) {
+ if (!$error) {
$result = $this->insertExtraFields();
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('FICHINTER_MODIFY', $user);
- if ($result < 0) { $error++; $this->db->rollback(); return -1; }
+ if ($result < 0) {
+ $error++; $this->db->rollback(); return -1;
+ }
// End call triggers
}
@@ -437,14 +431,14 @@ class Fichinter extends CommonObject
if ($ref) {
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.ref='".$this->db->escape($ref)."'";
- } else $sql .= " WHERE f.rowid=".$rowid;
+ } else {
+ $sql .= " WHERE f.rowid=".$rowid;
+ }
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$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->id = $obj->rowid;
@@ -470,7 +464,9 @@ class Fichinter extends CommonObject
$this->extraparams = (array) json_decode($obj->extraparams, true);
- if ($this->statut == 0) $this->brouillon = 1;
+ if ($this->statut == 0) {
+ $this->brouillon = 1;
+ }
// Retrieve extrafields
$this->fetch_optionals();
@@ -479,8 +475,7 @@ class Fichinter extends CommonObject
* Lines
*/
$result = $this->fetch_lines();
- if ($result < 0)
- {
+ if ($result < 0) {
return -3;
}
$this->db->free($resql);
@@ -505,8 +500,7 @@ class Fichinter extends CommonObject
$error = 0;
// Protection
- if ($this->statut <= self::STATUS_DRAFT)
- {
+ if ($this->statut <= self::STATUS_DRAFT) {
return 0;
}
@@ -519,8 +513,7 @@ class Fichinter extends CommonObject
$sql .= " WHERE rowid = ".$this->id;
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
if (!$error) {
$this->oldcopy = clone $this;
}
@@ -528,7 +521,9 @@ class Fichinter extends CommonObject
if (!$error) {
// Call trigger
$result = $this->call_trigger('FICHINTER_UNVALIDATE', $user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
}
if (!$error) {
@@ -560,15 +555,13 @@ class Fichinter extends CommonObject
$error = 0;
- if ($this->statut != 1)
- {
+ if ($this->statut != 1) {
$this->db->begin();
$now = dol_now();
// Define new ref
- if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
- {
+ if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
$num = $this->getNextNumRef($this->thirdparty);
} else {
$num = $this->ref;
@@ -586,51 +579,48 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::setValid", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
dol_print_error($this->db);
$error++;
}
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('FICHINTER_VALIDATE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if (!$error)
- {
+ if (!$error) {
$this->oldref = $this->ref;
// Rename directory if dir was a temporary ref
- if (preg_match('/^[\(]?PROV/i', $this->ref))
- {
+ if (preg_match('/^[\(]?PROV/i', $this->ref)) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Now we rename also files into index
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'ficheinter/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'ficheinter/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
- if (!$resql) { $error++; $this->error = $this->db->lasterror(); }
+ if (!$resql) {
+ $error++; $this->error = $this->db->lasterror();
+ }
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->ficheinter->dir_output.'/'.$oldref;
$dirdest = $conf->ficheinter->dir_output.'/'.$newref;
- if (!$error && file_exists($dirsource))
- {
+ if (!$error && file_exists($dirsource)) {
dol_syslog(get_class($this)."::setValid rename dir ".$dirsource." into ".$dirdest);
- if (@rename($dirsource, $dirdest))
- {
+ if (@rename($dirsource, $dirdest)) {
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles = dol_dir_list($conf->ficheinter->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
- foreach ($listoffiles as $fileentry)
- {
+ foreach ($listoffiles as $fileentry) {
$dirsource = $fileentry['name'];
$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
$dirsource = $fileentry['path'].'/'.$dirsource;
@@ -643,8 +633,7 @@ class Fichinter extends CommonObject
}
// Set new ref and define current statut
- if (!$error)
- {
+ if (!$error) {
$this->ref = $num;
$this->statut = 1;
$this->brouillon = 0;
@@ -740,8 +729,7 @@ class Fichinter extends CommonObject
{
// phpcs:enable
// Init/load array of translation of status
- if (empty($this->statuts) || empty($this->statuts_short) || empty($this->statuts_logo))
- {
+ if (empty($this->statuts) || empty($this->statuts_short) || empty($this->statuts_logo)) {
global $langs;
$langs->load("fichinter");
@@ -785,19 +773,20 @@ class Fichinter extends CommonObject
$url = DOL_URL_ROOT.'/fichinter/card.php?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("ShowIntervention");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
@@ -817,16 +806,23 @@ class Fichinter extends CommonObject
$linkend = '';
$result .= $linkstart;
- if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($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, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ if ($withpicto != 2) {
+ $result .= $this->ref;
+ }
$result .= $linkend;
global $action;
$hookmanager->initHooks(array('interventiondao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook > 0) $result = $hookmanager->resPrint;
- else $result .= $hookmanager->resPrint;
+ if ($reshook > 0) {
+ $result = $hookmanager->resPrint;
+ } else {
+ $result .= $hookmanager->resPrint;
+ }
return $result;
}
@@ -844,8 +840,7 @@ class Fichinter extends CommonObject
global $conf, $db, $langs;
$langs->load("interventions");
- if (!empty($conf->global->FICHEINTER_ADDON))
- {
+ if (!empty($conf->global->FICHEINTER_ADDON)) {
$mybool = false;
$file = "mod_".$conf->global->FICHEINTER_ADDON.".php";
@@ -870,8 +865,7 @@ class Fichinter extends CommonObject
$numref = "";
$numref = $obj->getNextValue($soc, $this);
- if ($numref != "")
- {
+ if ($numref != "") {
return $numref;
} else {
dol_print_error($db, "Fichinter::getNextNumRef ".$obj->error);
@@ -905,10 +899,8 @@ class Fichinter extends CommonObject
$sql .= " WHERE f.rowid = ".$id;
$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->id = $obj->rowid;
@@ -921,14 +913,12 @@ class Fichinter extends CommonObject
$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_modification)
- {
+ if ($obj->fk_user_modification) {
$muser = new User($this->db);
$muser->fetch($obj->fk_user_modification);
$this->user_modification = $muser;
@@ -956,27 +946,27 @@ class Fichinter extends CommonObject
$this->db->begin();
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('FICHINTER_DELETE', $user);
- if ($result < 0) { $error++; $this->db->rollback(); return -1; }
+ if ($result < 0) {
+ $error++; $this->db->rollback(); return -1;
+ }
// End call triggers
}
// Delete linked object
- if (!$error)
- {
+ if (!$error) {
$res = $this->deleteObjectLinked();
- if ($res < 0) $error++;
+ if ($res < 0) {
+ $error++;
+ }
}
// Delete linked contacts
- if (!$error)
- {
+ if (!$error) {
$res = $this->delete_linked_contact();
- if ($res < 0)
- {
+ if ($res < 0) {
$this->error = 'ErrorFailToDeleteLinkedContact';
$error++;
}
@@ -988,62 +978,61 @@ class Fichinter extends CommonObject
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_fichinter = ".$this->id.")";
$resql = $this->db->query($sql);
- if (!$resql) $error++;
+ if (!$resql) {
+ $error++;
+ }
}
- if (!$error)
- {
+ if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet";
$sql .= " WHERE fk_fichinter = ".$this->id;
$resql = $this->db->query($sql);
- if (!$resql) $error++;
+ if (!$resql) {
+ $error++;
+ }
}
- if (!$error)
- {
+ if (!$error) {
// Remove extrafields
$res = $this->deleteExtraFields();
- if ($res < 0) $error++;
+ if ($res < 0) {
+ $error++;
+ }
}
- if (!$error)
- {
+ if (!$error) {
// Delete object
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter";
$sql .= " WHERE rowid = ".$this->id;
dol_syslog("Fichinter::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql) $error++;
+ if (!$resql) {
+ $error++;
+ }
}
- if (!$error)
- {
+ if (!$error) {
// Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
$this->deleteEcmFiles();
// Remove directory with files
$fichinterref = dol_sanitizeFileName($this->ref);
- if ($conf->ficheinter->dir_output)
- {
+ if ($conf->ficheinter->dir_output) {
$dir = $conf->ficheinter->dir_output."/".$fichinterref;
$file = $conf->ficheinter->dir_output."/".$fichinterref."/".$fichinterref.".pdf";
- if (file_exists($file))
- {
+ if (file_exists($file)) {
dol_delete_preview($this);
- if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers
- {
+ if (!dol_delete_file($file, 0, 0, 0, $this)) { // For triggers
$langs->load("errors");
$this->error = $langs->trans("ErrorFailToDeleteFile", $file);
return 0;
}
}
- if (file_exists($dir))
- {
- if (!dol_delete_dir_recursive($dir))
- {
+ if (file_exists($dir)) {
+ if (!dol_delete_dir_recursive($dir)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorFailToDeleteDir", $dir);
return 0;
@@ -1052,8 +1041,7 @@ class Fichinter extends CommonObject
}
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return 1;
} else {
@@ -1075,15 +1063,13 @@ class Fichinter extends CommonObject
// phpcs:enable
global $conf;
- if ($user->rights->ficheinter->creer)
- {
+ if ($user->rights->ficheinter->creer) {
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
$sql .= " SET datei = '".$this->db->idate($date_delivery)."'";
$sql .= " WHERE rowid = ".$this->id;
$sql .= " AND fk_statut = 0";
- if ($this->db->query($sql))
- {
+ if ($this->db->query($sql)) {
$this->date_delivery = $date_delivery;
return 1;
} else {
@@ -1107,15 +1093,13 @@ class Fichinter extends CommonObject
// phpcs:enable
global $conf;
- if ($user->rights->ficheinter->creer)
- {
+ if ($user->rights->ficheinter->creer) {
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
$sql .= " SET description = '".$this->db->escape($description)."',";
$sql .= " fk_user_modif = ".$user->id;
$sql .= " WHERE rowid = ".$this->id;
- if ($this->db->query($sql))
- {
+ if ($this->db->query($sql)) {
$this->description = $description;
return 1;
} else {
@@ -1140,14 +1124,12 @@ class Fichinter extends CommonObject
// phpcs:enable
global $conf;
- if ($user->rights->ficheinter->creer)
- {
+ if ($user->rights->ficheinter->creer) {
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
$sql .= " SET fk_contrat = ".((int) $contractid);
$sql .= " WHERE rowid = ".$this->id;
- if ($this->db->query($sql))
- {
+ if ($this->db->query($sql)) {
$this->fk_contrat = $contractid;
return 1;
} else {
@@ -1176,19 +1158,18 @@ class Fichinter extends CommonObject
$this->db->begin();
// get extrafields so they will be clone
- foreach ($this->lines as $line)
+ foreach ($this->lines as $line) {
$line->fetch_optionals();
+ }
// Load source object
$objFrom = clone $this;
// Change socid if needed
- if (!empty($socid) && $socid != $this->socid)
- {
+ if (!empty($socid) && $socid != $this->socid) {
$objsoc = new Societe($this->db);
- if ($objsoc->fetch($socid) > 0)
- {
+ if ($objsoc->fetch($socid) > 0) {
$this->socid = $objsoc->id;
//$this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
//$this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
@@ -1213,31 +1194,31 @@ class Fichinter extends CommonObject
// Create clone
$this->context['createfromclone'] = 'createfromclone';
$result = $this->create($user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
- if (!$error)
- {
+ if (!$error) {
// Add lines because it is not included into create function
- foreach ($this->lines as $line)
- {
+ foreach ($this->lines as $line) {
$this->addline($user, $this->id, $line->desc, $line->datei, $line->duration);
}
// Hook of thirdparty module
- if (is_object($hookmanager))
- {
+ if (is_object($hookmanager)) {
$parameters = array('objFrom'=>$objFrom);
$action = '';
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) $error++;
+ if ($reshook < 0) {
+ $error++;
+ }
}
}
unset($this->context['createfromclone']);
// End
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return $this->id;
} else {
@@ -1262,8 +1243,7 @@ class Fichinter extends CommonObject
{
dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration");
- if ($this->statut == 0)
- {
+ if ($this->statut == 0) {
$this->db->begin();
// Insertion ligne
@@ -1280,8 +1260,7 @@ class Fichinter extends CommonObject
$result = $line->insert($user);
- if ($result >= 0)
- {
+ if ($result >= 0) {
$this->db->commit();
return 1;
} else {
@@ -1317,8 +1296,7 @@ class Fichinter extends CommonObject
$this->duration = 0;
$nbp = 25;
$xnbp = 0;
- while ($xnbp < $nbp)
- {
+ while ($xnbp < $nbp) {
$line = new FichinterLigne($this->db);
$line->desc = $langs->trans("Description")." ".$xnbp;
$line->datei = ($now - 3600 * (1 + $xnbp));
@@ -1348,12 +1326,10 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$objp = $this->db->fetch_object($resql);
$line = new FichinterLigne($this->db);
@@ -1466,8 +1442,7 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::fetch", LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid;
$this->id = $objp->rowid;
@@ -1503,14 +1478,12 @@ class FichinterLigne extends CommonObjectLine
$this->db->begin();
$rangToUse = $this->rang;
- if ($rangToUse == -1)
- {
+ if ($rangToUse == -1) {
// Recupere rang max de la ligne d'intervention dans $rangmax
$sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'fichinterdet';
$sql .= ' WHERE fk_fichinter ='.$this->fk_fichinter;
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $this->db->fetch_object($resql);
$rangToUse = $obj->max + 1;
} else {
@@ -1532,16 +1505,13 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::insert", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet');
$this->rowid = $this->id;
- if (!$error)
- {
+ if (!$error) {
$result = $this->insertExtraFields();
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
@@ -1549,15 +1519,15 @@ class FichinterLigne extends CommonObjectLine
$result = $this->update_total();
- if ($result > 0)
- {
+ if ($result > 0) {
$this->rang = $rangToUse;
- if (!$notrigger)
- {
+ if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('LINEFICHINTER_CREATE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
}
@@ -1602,31 +1572,27 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::update", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
- if (!$error)
- {
+ if ($resql) {
+ if (!$error) {
$result = $this->insertExtraFields();
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
$result = $this->update_total();
- if ($result > 0)
- {
- if (!$notrigger)
- {
+ if ($result > 0) {
+ if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('LINEFICHINTER_UPDATE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return $result;
} else {
@@ -1660,11 +1626,12 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::update_total", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $this->db->fetch_object($resql);
$total_duration = 0;
- if (!empty($obj->total_duration)) $total_duration = $obj->total_duration;
+ if (!empty($obj->total_duration)) {
+ $total_duration = $obj->total_duration;
+ }
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
$sql .= " SET duree = ".$total_duration;
@@ -1674,8 +1641,7 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::update_total", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$this->db->commit();
return 1;
} else {
@@ -1703,8 +1669,7 @@ class FichinterLigne extends CommonObjectLine
$error = 0;
- if ($this->statut == 0)
- {
+ if ($this->statut == 0) {
dol_syslog(get_class($this)."::deleteline lineid=".$this->id);
$this->db->begin();
@@ -1718,16 +1683,15 @@ class FichinterLigne extends CommonObjectLine
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE rowid = ".$this->id;
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$result = $this->update_total();
- if ($result > 0)
- {
- if (!$notrigger)
- {
+ if ($result > 0) {
+ if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('LINEFICHINTER_DELETE', $user);
- if ($result < 0) { $error++; $this->db->rollback(); return -1; }
+ if ($result < 0) {
+ $error++; $this->db->rollback(); return -1;
+ }
// End call triggers
}
diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php
index 418e1232bb8..8ed842a70c9 100644
--- a/htdocs/fichinter/class/fichinterrec.class.php
+++ b/htdocs/fichinter/class/fichinterrec.class.php
@@ -214,8 +214,8 @@ class FichinterRec extends Fichinter
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
/*
- * Lines
- */
+ * Lines
+ */
$num = count($fichintsrc->lines);
for ($i = 0; $i < $num; $i++) {
//var_dump($fichintsrc->lines[$i]);
@@ -239,13 +239,14 @@ class FichinterRec extends Fichinter
$fichintsrc->lines[$i]->fk_unit
);
- if ($result_insert < 0)
+ if ($result_insert < 0) {
$error++;
+ }
}
- if ($error)
+ if ($error) {
$this->db->rollback();
- else {
+ } else {
$this->db->commit();
return $this->id;
}
@@ -277,8 +278,11 @@ class FichinterRec extends Fichinter
$sql .= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.auto_validate';
$sql .= ', f.note_private, f.note_public, f.fk_user_author';
$sql .= ' FROM '.MAIN_DB_PREFIX.'fichinter_rec as f';
- if ($rowid > 0) $sql .= ' WHERE f.rowid='.$rowid;
- elseif ($ref) $sql .= " WHERE f.titre='".$this->db->escape($ref)."'";
+ if ($rowid > 0) {
+ $sql .= ' WHERE f.rowid='.$rowid;
+ } elseif ($ref) {
+ $sql .= " WHERE f.titre='".$this->db->escape($ref)."'";
+ }
dol_syslog(get_class($this)."::fetch rowid=".$rowid, LOG_DEBUG);
@@ -421,7 +425,9 @@ class FichinterRec extends Fichinter
*/
public function delete($rowid = 0, $notrigger = 0, $idwarehouse = -1)
{
- if (empty($rowid)) $rowid = $this->id;
+ if (empty($rowid)) {
+ $rowid = $this->id;
+ }
dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG);
@@ -481,14 +487,20 @@ class FichinterRec extends Fichinter
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Check parameters
- if ($type < 0) return -1;
+ if ($type < 0) {
+ return -1;
+ }
if ($this->brouillon) {
// Clean parameters
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
- if (!$qty) $qty = 1;
- if (!$info_bits) $info_bits = 0;
+ if (!$qty) {
+ $qty = 1;
+ }
+ if (!$info_bits) {
+ $info_bits = 0;
+ }
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
if (!preg_match('/\((.*)\)/', $txtva)) {
@@ -623,7 +635,9 @@ class FichinterRec extends Fichinter
$url = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$this->id;
- if ($short) return $url;
+ if ($short) {
+ return $url;
+ }
$picto = 'intervention';
@@ -709,7 +723,9 @@ class FichinterRec extends Fichinter
dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG);
if ($this->db->query($sql)) {
$this->frequency = $frequency;
- if (!empty($unit)) $this->unit_frequency = $unit;
+ if (!empty($unit)) {
+ $this->unit_frequency = $unit;
+ }
return 1;
} else {
dol_print_error($this->db);
@@ -732,13 +748,17 @@ class FichinterRec extends Fichinter
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null");
- if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1';
+ if ($increment_nb_gen_done > 0) {
+ $sql .= ', nb_gen_done = nb_gen_done + 1';
+ }
$sql .= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG);
if ($this->db->query($sql)) {
$this->date_when = $date;
- if ($increment_nb_gen_done > 0) $this->nb_gen_done++;
+ if ($increment_nb_gen_done > 0) {
+ $this->nb_gen_done++;
+ }
return 1;
} else {
dol_print_error($this->db);
@@ -759,7 +779,9 @@ class FichinterRec extends Fichinter
return -1;
}
- if (empty($nb)) $nb = 0;
+ if (empty($nb)) {
+ $nb = 0;
+ }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET nb_gen_max = '.$nb;
@@ -818,8 +840,9 @@ class FichinterRec extends Fichinter
$sql .= ' SET nb_gen_done = nb_gen_done + 1';
$sql .= ' , date_last_gen = now()';
// si on et arrivé à la fin des génération
- if ($this->nb_gen_max == $this->nb_gen_done + 1)
+ if ($this->nb_gen_max == $this->nb_gen_done + 1) {
$sql .= ' , statut = 1';
+ }
$sql .= ' WHERE rowid = '.$this->id;
diff --git a/htdocs/fichinter/class/fichinterstats.class.php b/htdocs/fichinter/class/fichinterstats.class.php
index 5df841bf6f2..a0d22cf1e2a 100644
--- a/htdocs/fichinter/class/fichinterstats.class.php
+++ b/htdocs/fichinter/class/fichinterstats.class.php
@@ -64,8 +64,7 @@ class FichinterStats extends Stats
$this->userid = $userid;
$this->cachefilesuffix = $mode;
- if ($mode == 'customer')
- {
+ if ($mode == 'customer') {
$object = new Fichinter($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as c";
$this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl";
@@ -73,14 +72,17 @@ class FichinterStats extends Stats
$this->field_line = '0';
//$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled
}
- if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if (!$user->rights->societe->client->voir && !$this->socid) {
+ $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
+ }
$this->where .= ($this->where ? ' AND ' : '')."c.entity IN (".getEntity('fichinter').')';
- if ($this->socid)
- {
+ if ($this->socid) {
$this->where .= " AND c.fk_soc = ".$this->socid;
}
- if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid;
+ if ($this->userid > 0) {
+ $this->where .= ' AND c.fk_user_author = '.$this->userid;
+ }
}
/**
@@ -96,7 +98,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
$sql .= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$this->socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
@@ -118,7 +122,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0";
$sql .= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$this->socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= " WHERE ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');
@@ -139,7 +145,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%m') as dm, 0";
$sql .= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$this->socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
@@ -161,7 +169,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%m') as dm, 0";
$sql .= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$this->socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
@@ -181,7 +191,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg";
$sql .= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$this->socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= " WHERE ".$this->where;
$sql .= " GROUP BY year";
$sql .= $this->db->order('year', 'DESC');
diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php
index bace3d10231..7957479e611 100644
--- a/htdocs/fichinter/contact.php
+++ b/htdocs/fichinter/contact.php
@@ -39,13 +39,14 @@ $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, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db);
$result = $object->fetch($id, $ref);
-if (!$result)
-{
+if (!$result) {
print 'Record not found';
exit;
}
@@ -54,17 +55,14 @@ if (!$result)
* Adding a new contact
*/
-if ($action == 'addcontact' && $user->rights->ficheinter->creer)
-{
- if ($result > 0 && $id > 0)
- {
+if ($action == 'addcontact' && $user->rights->ficheinter->creer) {
+ 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 {
@@ -77,21 +75,14 @@ if ($action == 'addcontact' && $user->rights->ficheinter->creer)
setEventMessages($mesg, null, 'errors');
}
-}
-
-// Toggle the status of a contact
-elseif ($action == 'swapstatut' && $user->rights->ficheinter->creer)
-{
+} elseif ($action == 'swapstatut' && $user->rights->ficheinter->creer) {
+ // Toggle the status of a contact
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
-}
-
-// Deletes a contact
-elseif ($action == 'deletecontact' && $user->rights->ficheinter->creer)
-{
+} elseif ($action == 'deletecontact' && $user->rights->ficheinter->creer) {
+ // Deletes a contact
$result = $object->delete_contact(GETPOST('lineid', 'int'));
- if ($result >= 0)
- {
+ if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@@ -114,8 +105,7 @@ llxHeader('', $langs->trans("Intervention"));
// Mode vue et edition
-if ($id > 0 || !empty($ref))
-{
+if ($id > 0 || !empty($ref)) {
$object->fetch_thirdparty();
$head = fichinter_prepare_head($object);
@@ -133,12 +123,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 .= '
'.$langs->trans('Project').' ';
- if ($user->rights->ficheinter->creer)
- {
+ if ($user->rights->ficheinter->creer) {
if ($action != 'classify') {
//$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
@@ -174,15 +162,20 @@ if ($id > 0 || !empty($ref))
print '
';
- if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser = 1;
- if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty = 1;
+ if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) {
+ $hideaddcontactforuser = 1;
+ }
+ if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) {
+ $hideaddcontactforthirdparty = 1;
+ }
// 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;
+ }
}
}
diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php
index 1b9326468f4..ba1f22c122b 100644
--- a/htdocs/fichinter/document.php
+++ b/htdocs/fichinter/document.php
@@ -47,7 +47,9 @@ $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
// Security check
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
@@ -56,12 +58,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 Fichinter($db);
@@ -75,7 +83,7 @@ $modulepart = 'fichinter';
* Actions
*/
-include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
@@ -86,8 +94,7 @@ $form = new Form($db);
llxHeader('', $langs->trans("Intervention"));
-if ($object->id)
-{
+if ($object->id) {
$object->fetch_thirdparty();
$head = fichinter_prepare_head($object);
@@ -98,8 +105,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'];
}
@@ -115,12 +121,10 @@ if ($object->id)
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project
- if (!empty($conf->projet->enabled))
- {
+ if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '
'.$langs->trans('Project').' ';
- if ($user->rights->commande->creer)
- {
+ if ($user->rights->commande->creer) {
if ($action != 'classify') {
//$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php
index 3ea69f8d185..863463e8d0e 100644
--- a/htdocs/fichinter/index.php
+++ b/htdocs/fichinter/index.php
@@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
-if (!$user->rights->ficheinter->lire) accessforbidden();
+if (!$user->rights->ficheinter->lire) {
+ accessforbidden();
+}
$hookmanager = new HookManager($db);
@@ -42,8 +44,7 @@ $langs->load("interventions");
// Security check
$socid = GETPOST('socid', 'int');
-if ($user->socid > 0)
-{
+if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
@@ -66,8 +67,7 @@ print load_fiche_titre($langs->trans("InterventionsArea"), '', 'intervention');
print '
';
-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
// Search ficheinter
$var = false;
print '
';
@@ -88,15 +88,20 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles
$sql = "SELECT count(f.rowid), f.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."fichinter as f";
-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 f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.fk_soc = s.rowid";
-if ($user->socid) $sql .= ' AND f.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 f.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 .= " GROUP BY f.fk_statut";
$resql = $db->query($sql);
-if ($resql)
-{
+if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
@@ -106,15 +111,15 @@ if ($resql)
$vals = array();
$bool = false;
// -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 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))
{
$bool = (!empty($row[2]) ?true:false);
- if (!isset($vals[$row[1].$bool])) $vals[$row[1].$bool] = 0;
+ if (!isset($vals[$row[1].$bool])) {
+ $vals[$row[1].$bool] = 0;
+ }
$vals[$row[1].$bool] += $row[0];
$totalinprocess += $row[0];
}
@@ -131,19 +136,28 @@ if ($resql)
print ''.$langs->trans("Statistics").' - '.$langs->trans("Interventions").' '."\n";
$listofstatus = array(0, 1, 3);
$bool = false;
- foreach ($listofstatus as $status)
- {
+ foreach ($listofstatus as $status) {
$dataseries[] = array($fichinterstatic->LibStatut($status, $bool, 1), (isset($vals[$status.$bool]) ? (int) $vals[$status.$bool] : 0));
- if ($status == 3 && !$bool) $bool = true;
- else $bool = false;
+ if ($status == 3 && !$bool) {
+ $bool = true;
+ } else {
+ $bool = false;
+ }
- if ($status == Fichinter::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
- if ($status == Fichinter::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1;
- if ($status == Fichinter::STATUS_BILLED) $colorseries[$status] = $badgeStatus4;
- if ($status == Fichinter::STATUS_CLOSED) $colorseries[$status] = $badgeStatus6;
+ if ($status == Fichinter::STATUS_DRAFT) {
+ $colorseries[$status] = '-'.$badgeStatus0;
+ }
+ if ($status == Fichinter::STATUS_VALIDATED) {
+ $colorseries[$status] = $badgeStatus1;
+ }
+ if ($status == Fichinter::STATUS_BILLED) {
+ $colorseries[$status] = $badgeStatus4;
+ }
+ if ($status == Fichinter::STATUS_CLOSED) {
+ $colorseries[$status] = $badgeStatus6;
+ }
}
- if ($conf->use_javascript_ajax)
- {
+ if ($conf->use_javascript_ajax) {
print '';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@@ -160,10 +174,8 @@ if ($resql)
print ' ';
}
$bool = false;
- foreach ($listofstatus as $status)
- {
- if (!$conf->use_javascript_ajax)
- {
+ foreach ($listofstatus as $status) {
+ if (!$conf->use_javascript_ajax) {
print '';
print ''.$fichinterstatic->LibStatut($status, $bool, 0).' ';
print ''.(isset($vals[$status.$bool]) ? $vals[$status.$bool] : 0).' ';
@@ -171,8 +183,11 @@ if ($resql)
print ' ';
print ' ';
print " \n";
- if ($status == 3 && !$bool) $bool = true;
- else $bool = false;
+ if ($status == 3 && !$bool) {
+ $bool = true;
+ } else {
+ $bool = false;
+ }
}
}
//if ($totalinprocess != $total)
@@ -187,32 +202,34 @@ if ($resql)
/*
* Draft orders
*/
-if (!empty($conf->ficheinter->enabled))
-{
+if (!empty($conf->ficheinter->enabled)) {
$sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
$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 f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.fk_statut = 0";
- if ($socid) $sql .= " AND f.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 f.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 '';
print '
';
print '';
print ''.$langs->trans("DraftFichinter").' ';
$langs->load("fichinter");
$num = $db->num_rows($resql);
- if ($num)
- {
+ if ($num) {
$i = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
print '';
print '';
@@ -239,29 +256,32 @@ $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.date_valid as datec, f.tms as date
$sql .= " s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f,";
$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 f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.fk_soc = s.rowid";
//$sql.= " AND c.fk_statut > 2";
-if ($socid) $sql .= " AND f.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 f.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 f.tms DESC";
$sql .= $db->plimit($max, 0);
$resql = $db->query($sql);
-if ($resql)
-{
+if ($resql) {
print '';
print '
';
print '';
print ''.$langs->trans("LastModifiedInterventions", $max).' ';
$num = $db->num_rows($resql);
- if ($num)
- {
+ if ($num) {
$i = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
print '';
@@ -296,29 +316,35 @@ if ($resql)
}
}
print "
";
-} else dol_print_error($db);
+} else {
+ dol_print_error($db);
+}
/*
* interventions to process
*/
-if (!empty($conf->ficheinter->enabled))
-{
+if (!empty($conf->ficheinter->enabled)) {
$sql = "SELECT f.rowid, f.ref, f.fk_statut, s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
$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 f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.fk_statut = 1";
- if ($socid) $sql .= " AND f.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 f.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 f.rowid DESC";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql);
print '';
@@ -326,11 +352,9 @@ if (!empty($conf->ficheinter->enabled))
print '
';
print ''.$langs->trans("FichinterToProcess").' '.$num.' ';
- if ($num)
- {
+ if ($num) {
$i = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($resql);
print '
';
print '';
@@ -366,7 +390,9 @@ if (!empty($conf->ficheinter->enabled))
}
print "
";
- } else dol_print_error($db);
+ } else {
+ dol_print_error($db);
+ }
}
print ' ';
diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php
index a53c69b77bd..39ac695f84e 100644
--- a/htdocs/fichinter/info.php
+++ b/htdocs/fichinter/info.php
@@ -40,13 +40,14 @@ $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
// Security check
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db);
-if (!$object->fetch($id, $ref) > 0)
-{
+if (!$object->fetch($id, $ref) > 0) {
dol_print_error($db);
exit;
}
@@ -77,15 +78,14 @@ $morehtmlref = '
';
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project
-if (!empty($conf->projet->enabled))
-{
+if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '
'.$langs->trans('Project').' ';
- if ($user->rights->commande->creer)
- {
- if ($action != 'classify')
+ if ($user->rights->commande->creer) {
+ if ($action != 'classify') {
//$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
+ }
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '
';
diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php
index d054f5e5bcc..8f0ae8e626f 100644
--- a/htdocs/fichinter/list.php
+++ b/htdocs/fichinter/list.php
@@ -32,13 +32,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
-if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
+if (!empty($conf->projet->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+}
+if (!empty($conf->contrat->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
+}
// Load translation files required by the page
$langs->loadLangs(array('companies', 'bills', 'interventions'));
-if (!empty($conf->projet->enabled)) $langs->load("projects");
-if (!empty($conf->contrat->enabled)) $langs->load("contracts");
+if (!empty($conf->projet->enabled)) {
+ $langs->load("projects");
+}
+if (!empty($conf->contrat->enabled)) {
+ $langs->load("contracts");
+}
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha');
@@ -59,7 +67,9 @@ $socid = GETPOST('socid', 'int');
// Security check
$id = GETPOST('id', 'int');
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$diroutputmassaction = $conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id;
@@ -68,14 +78,17 @@ $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 = "DESC";
-if (!$sortfield)
-{
- $sortfield = "f.ref";
+if (!$sortorder) {
+ $sortorder = "DESC";
+}
+if (!$sortfield) {
+ $sortfield = "f.ref";
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@@ -97,8 +110,12 @@ $fieldstosearchall = array(
'f.note_public'=>'NotePublic',
'fd.description'=>'DescriptionOfLine',
);
-if (empty($user->socid)) $fieldstosearchall["f.note_private"] = "NotePrivate";
-if (!empty($conf->global->FICHINTER_DISABLE_DETAILS)) unset($fieldstosearchall['fd.description']);
+if (empty($user->socid)) {
+ $fieldstosearchall["f.note_private"] = "NotePrivate";
+}
+if (!empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
+ unset($fieldstosearchall['fd.description']);
+}
// Definition of fields for list
$arrayfields = array(
@@ -127,21 +144,25 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
* Actions
*/
-if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
-if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; }
+if (GETPOST('cancel', 'alpha')) {
+ $action = 'list'; $massaction = '';
+}
+if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
+ $massaction = '';
+}
$parameters = array('socid'=>$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)) {
// Selection of new fields
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
- {
+ 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
$search_ref = "";
$search_company = "";
$search_projet_ref = "";
@@ -187,10 +208,8 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$atleastonefieldinlines = 0;
-foreach ($arrayfields as $tmpkey => $tmpval)
-{
- if (preg_match('/^fd\./', $tmpkey) && !empty($arrayfields[$tmpkey]['checked']))
- {
+foreach ($arrayfields as $tmpkey => $tmpval) {
+ if (preg_match('/^fd\./', $tmpkey) && !empty($arrayfields[$tmpkey]['checked'])) {
$atleastonefieldinlines++;
break;
}
@@ -198,7 +217,9 @@ foreach ($arrayfields as $tmpkey => $tmpval)
$sql = "SELECT";
$sql .= " f.ref, f.rowid, f.fk_statut as status, f.description, f.datec as date_creation, f.tms as date_update, f.note_public, f.note_private,";
-if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= " fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,";
+if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) {
+ $sql .= " fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,";
+}
$sql .= " s.nom as name, s.rowid as socid, s.client, s.fournisseur, s.email, s.status as thirdpartystatus";
if (!empty($conf->projet->enabled)) {
$sql .= ", pr.rowid as projet_id, pr.ref as projet_ref, pr.title as projet_title";
@@ -208,7 +229,9 @@ if (!empty($conf->contrat->enabled)) {
}
// 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 : '');
+ 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();
@@ -221,9 +244,15 @@ if (!empty($conf->projet->enabled)) {
if (!empty($conf->contrat->enabled)) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contrat as c on f.fk_contrat = c.rowid";
}
-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 (f.rowid = ef.fk_object)";
-if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
-if (!$user->rights->societe->client->voir && empty($socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+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 (f.rowid = ef.fk_object)";
+}
+if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) {
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
+}
+if (!$user->rights->societe->client->voir && empty($socid)) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+}
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.fk_soc = s.rowid";
@@ -240,16 +269,21 @@ if ($search_contrat_ref) {
$sql .= natural_search('c.ref', $search_contrat_ref);
}
if ($search_desc) {
- if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= natural_search(array('f.description', 'fd.description'), $search_desc);
- else $sql .= natural_search(array('f.description'), $search_desc);
+ if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) {
+ $sql .= natural_search(array('f.description', 'fd.description'), $search_desc);
+ } else {
+ $sql .= natural_search(array('f.description'), $search_desc);
+ }
}
if ($search_status != '' && $search_status >= 0) {
$sql .= ' AND f.fk_statut = '.urlencode($search_status);
}
-if (!$user->rights->societe->client->voir && empty($socid))
+if (!$user->rights->societe->client->voir && empty($socid)) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
-if ($socid)
+}
+if ($socid) {
$sql .= " AND s.rowid = ".$socid;
+}
if ($sall) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
}
@@ -263,12 +297,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;
}
@@ -278,30 +310,50 @@ $sql .= $db->plimit($limit + 1, $offset);
//print $sql;
$resql = $db->query($sql);
-if ($resql)
-{
+if ($resql) {
$num = $db->num_rows($resql);
$arrayofselected = is_array($toselect) ? $toselect : array();
- if ($socid > 0)
- {
+ if ($socid > 0) {
$soc = new Societe($db);
$soc->fetch($socid);
- if (empty($search_company)) $search_company = $soc->name;
+ if (empty($search_company)) {
+ $search_company = $soc->name;
+ }
}
$param = '';
- if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
- if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
- if ($sall) $param .= "&sall=".urlencode($sall);
- if ($socid) $param .= "&socid=".urlencode($socid);
- if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
- if ($search_company) $param .= "&search_company=".urlencode($search_company);
- if ($search_desc) $param .= "&search_desc=".urlencode($search_desc);
- if ($search_status != '' && $search_status > -1) $param .= "&search_status=".urlencode($search_status);
- if ($show_files) $param .= '&show_files='.urlencode($show_files);
- 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 ($sall) {
+ $param .= "&sall=".urlencode($sall);
+ }
+ if ($socid) {
+ $param .= "&socid=".urlencode($socid);
+ }
+ if ($search_ref) {
+ $param .= "&search_ref=".urlencode($search_ref);
+ }
+ if ($search_company) {
+ $param .= "&search_company=".urlencode($search_company);
+ }
+ if ($search_desc) {
+ $param .= "&search_desc=".urlencode($search_desc);
+ }
+ if ($search_status != '' && $search_status > -1) {
+ $param .= "&search_status=".urlencode($search_status);
+ }
+ if ($show_files) {
+ $param .= '&show_files='.urlencode($show_files);
+ }
+ if ($optioncss != '') {
+ $param .= '&optioncss='.urlencode($optioncss);
+ }
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@@ -311,19 +363,27 @@ if ($resql)
'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
);
- if ($user->rights->ficheinter->supprimer) $arrayofmassactions['predelete'] = ' '.$langs->trans("Delete");
- if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
+ if ($user->rights->ficheinter->supprimer) {
+ $arrayofmassactions['predelete'] = ' '.$langs->trans("Delete");
+ }
+ if (in_array($massaction, array('presend', 'predelete'))) {
+ $arrayofmassactions = array();
+ }
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = '';
$url = DOL_URL_ROOT.'/fichinter/card.php?action=create';
- if (!empty($socid)) $url .= '&socid='.$socid;
+ if (!empty($socid)) {
+ $url .= '&socid='.$socid;
+ }
$newcardbutton = dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', $url, '', $user->rights->ficheinter->creer);
// Lines of title fields
print ' '."\n";
- if ($optioncss != '') print ' ';
+ if ($optioncss != '') {
+ print ' ';
+ }
print ' ';
print ' ';
print ' ';
@@ -339,9 +399,10 @@ if ($resql)
$trackid = 'int'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
- if ($sall)
- {
- foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
+ if ($sall) {
+ foreach ($fieldstosearchall as $key => $val) {
+ $fieldstosearchall[$key] = $langs->trans($val);
+ }
print ''.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
';
}
@@ -349,48 +410,47 @@ if ($resql)
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object 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 '';
print $moreforfilter;
print '
';
}
- if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
+ if ($massactionbutton) {
+ $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
+ }
print '';
print '
'."\n";
print '';
- if (!empty($arrayfields['f.ref']['checked']))
- {
+ if (!empty($arrayfields['f.ref']['checked'])) {
print '';
print ' ';
print ' ';
}
- if (!empty($arrayfields['s.nom']['checked']))
- {
+ if (!empty($arrayfields['s.nom']['checked'])) {
print '';
print ' ';
print ' ';
}
- if (!empty($arrayfields['pr.ref']['checked']))
- {
+ if (!empty($arrayfields['pr.ref']['checked'])) {
print '';
print ' ';
print ' ';
}
- if (!empty($arrayfields['c.ref']['checked']))
- {
+ if (!empty($arrayfields['c.ref']['checked'])) {
print '';
print ' ';
print ' ';
}
- if (!empty($arrayfields['f.description']['checked']))
- {
+ if (!empty($arrayfields['f.description']['checked'])) {
print '';
print ' ';
print ' ';
@@ -402,51 +462,45 @@ if ($resql)
$parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
- if (!empty($arrayfields['f.datec']['checked']))
- {
+ if (!empty($arrayfields['f.datec']['checked'])) {
// Date creation
print '';
print ' ';
}
- if (!empty($arrayfields['f.tms']['checked']))
- {
+ if (!empty($arrayfields['f.tms']['checked'])) {
// Date modification
print '';
print ' ';
}
- if (!empty($arrayfields['f.note_public']['checked']))
- {
+ if (!empty($arrayfields['f.note_public']['checked'])) {
// Note public
print '';
print ' ';
}
- if (!empty($arrayfields['f.note_private']['checked']))
- {
+ if (!empty($arrayfields['f.note_private']['checked'])) {
// Note private
print '';
print ' ';
}
// Status
- if (!empty($arrayfields['f.fk_statut']['checked']))
- {
+ if (!empty($arrayfields['f.fk_statut']['checked'])) {
print '';
$tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short
$liststatus = $objectstatic->statuts_short;
- if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
+ if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) {
+ unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
+ }
print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1);
print ' ';
}
// Fields of detail line
- if (!empty($arrayfields['fd.description']['checked']))
- {
+ if (!empty($arrayfields['fd.description']['checked'])) {
print ' ';
}
- if (!empty($arrayfields['fd.date']['checked']))
- {
+ if (!empty($arrayfields['fd.date']['checked'])) {
print ' ';
}
- if (!empty($arrayfields['fd.duree']['checked']))
- {
+ if (!empty($arrayfields['fd.duree']['checked'])) {
print ' ';
}
print '';
@@ -457,33 +511,58 @@ if ($resql)
print " \n";
print '';
- if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
- if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
- if (!empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder);
- if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder);
- if (!empty($arrayfields['f.description']['checked'])) print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder);
+ if (!empty($arrayfields['f.ref']['checked'])) {
+ print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
+ }
+ if (!empty($arrayfields['s.nom']['checked'])) {
+ print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
+ }
+ if (!empty($arrayfields['pr.ref']['checked'])) {
+ print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder);
+ }
+ if (!empty($arrayfields['c.ref']['checked'])) {
+ print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder);
+ }
+ if (!empty($arrayfields['f.description']['checked'])) {
+ print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder);
+ }
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
- if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
- if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
- if (!empty($arrayfields['f.note_public']['checked'])) print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
- if (!empty($arrayfields['f.note_private']['checked'])) print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
- if (!empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
- if (!empty($arrayfields['fd.description']['checked'])) print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], '');
- if (!empty($arrayfields['fd.date']['checked'])) print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center ');
- if (!empty($arrayfields['fd.duree']['checked'])) print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right ');
+ if (!empty($arrayfields['f.datec']['checked'])) {
+ print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
+ }
+ if (!empty($arrayfields['f.tms']['checked'])) {
+ print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
+ }
+ if (!empty($arrayfields['f.note_public']['checked'])) {
+ print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
+ }
+ if (!empty($arrayfields['f.note_private']['checked'])) {
+ print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
+ }
+ if (!empty($arrayfields['f.fk_statut']['checked'])) {
+ print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
+ }
+ if (!empty($arrayfields['fd.description']['checked'])) {
+ print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], '');
+ }
+ if (!empty($arrayfields['fd.date']['checked'])) {
+ print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center ');
+ }
+ if (!empty($arrayfields['fd.duree']['checked'])) {
+ print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right ');
+ }
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print " \n";
$total = 0;
$i = 0;
$totalarray = array();
- while ($i < min($num, $limit))
- {
+ while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
$objectstatic->id = $obj->rowid;
@@ -500,8 +579,7 @@ if ($resql)
print '';
- if (!empty($arrayfields['f.ref']['checked']))
- {
+ if (!empty($arrayfields['f.ref']['checked'])) {
print "";
print '';
@@ -512,15 +590,13 @@ if ($resql)
// Warning
$warnornote = '';
//if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
- if (!empty($obj->note_private))
- {
+ if (!empty($obj->note_private)) {
$warnornote .= ($warnornote ? ' ' : '');
$warnornote .= '';
$warnornote .= ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').' ';
$warnornote .= ' ';
}
- if ($warnornote)
- {
+ if ($warnornote) {
print '';
print $warnornote;
print ' ';
@@ -535,17 +611,19 @@ if ($resql)
print '
';
print " \n";
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
}
- if (!empty($arrayfields['s.nom']['checked']))
- {
+ if (!empty($arrayfields['s.nom']['checked'])) {
print '';
print $companystatic->getNomUrl(1, '', 44);
print ' ';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
}
- if (!empty($arrayfields['pr.ref']['checked']))
- {
+ if (!empty($arrayfields['pr.ref']['checked'])) {
print '';
$projetstatic->id = $obj->projet_id;
$projetstatic->ref = $obj->projet_ref;
@@ -554,10 +632,11 @@ if ($resql)
print $projetstatic->getNomUrl(1, '');
}
print ' ';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
}
- if (!empty($arrayfields['c.ref']['checked']))
- {
+ if (!empty($arrayfields['c.ref']['checked'])) {
print '';
$contratstatic->id = $obj->contrat_id;
$contratstatic->ref = $obj->contrat_ref;
@@ -567,12 +646,15 @@ if ($resql)
print $contratstatic->getNomUrl(1, '');
print ' ';
}
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
}
- if (!empty($arrayfields['f.description']['checked']))
- {
+ if (!empty($arrayfields['f.description']['checked'])) {
print ''.dol_trunc(dolGetFirstLineOfText($obj->description), 48).' ';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
}
// Extra fields
@@ -582,71 +664,84 @@ if ($resql)
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
- if (!empty($arrayfields['f.datec']['checked']))
- {
+ if (!empty($arrayfields['f.datec']['checked'])) {
print '';
print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
print ' ';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
}
// Date modification
- if (!empty($arrayfields['f.tms']['checked']))
- {
+ if (!empty($arrayfields['f.tms']['checked'])) {
print '';
print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
print ' ';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
}
// Note public
- if (!empty($arrayfields['f.note_public']['checked']))
- {
+ if (!empty($arrayfields['f.note_public']['checked'])) {
print '';
print dol_escape_htmltag($obj->note_public);
print ' ';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
}
// Note private
- if (!empty($arrayfields['f.note_private']['checked']))
- {
+ if (!empty($arrayfields['f.note_private']['checked'])) {
print '';
print dol_escape_htmltag($obj->note_private);
print ' ';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
}
// Status
- if (!empty($arrayfields['f.fk_statut']['checked']))
- {
+ if (!empty($arrayfields['f.fk_statut']['checked'])) {
print ''.$objectstatic->getLibStatut(5).' ';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
}
// Fields of detail of line
- if (!empty($arrayfields['fd.description']['checked']))
- {
+ if (!empty($arrayfields['fd.description']['checked'])) {
print ''.dolGetFirstLineOfText($obj->descriptiondetail).' ';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
}
- if (!empty($arrayfields['fd.date']['checked']))
- {
+ if (!empty($arrayfields['fd.date']['checked'])) {
print ''.dol_print_date($db->jdate($obj->dp), 'dayhour')." \n";
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
}
- if (!empty($arrayfields['fd.duree']['checked']))
- {
+ if (!empty($arrayfields['fd.duree']['checked'])) {
print ''.convertSecondToTime($obj->duree, 'allhourmin').' ';
- if (!$i) $totalarray['nbfield']++;
- if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree';
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ if (!$i) {
+ $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree';
+ }
$totalarray['val']['fd.duree'] += $obj->duree;
}
// Action column
print '';
- 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 ' ';
}
print ' ';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
print " \n";
@@ -669,7 +764,9 @@ if ($resql)
print "\n";
$hidegeneratedfilelistifempty = 1;
- if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
+ if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
+ $hidegeneratedfilelistifempty = 0;
+ }
// Show list of available documents
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php
index dddbe79e33e..fcc790bf8c2 100644
--- a/htdocs/fichinter/note.php
+++ b/htdocs/fichinter/note.php
@@ -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, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db);
@@ -62,8 +64,7 @@ llxHeader('', $langs->trans("Intervention"));
$form = new Form($db);
-if ($id > 0 || !empty($ref))
-{
+if ($id > 0 || !empty($ref)) {
$object->fetch_thirdparty();
$head = fichinter_prepare_head($object);
@@ -80,12 +81,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 .= ' '.$langs->trans('Project').' ';
- if ($user->rights->commande->creer)
- {
+ if ($user->rights->commande->creer) {
if ($action != 'classify') {
//$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php
index 19e7f86d8a0..29a5f9976b0 100644
--- a/htdocs/fichinter/stats/index.php
+++ b/htdocs/fichinter/stats/index.php
@@ -30,13 +30,14 @@ $WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
$mode = 'customer';
-if (!$user->rights->ficheinter->lire) accessforbidden();
+if (!$user->rights->ficheinter->lire) {
+ accessforbidden();
+}
$userid = GETPOST('userid', 'int');
$socid = GETPOST('socid', 'int');
// Security check
-if ($user->socid > 0)
-{
+if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
@@ -70,15 +71,16 @@ print load_fiche_titre($title, '', 'intervention');
dol_mkdir($dir);
$stats = new FichinterStats($db, $socid, $mode, ($userid > 0 ? $userid : 0));
-if ($object_status != '' && $object_status > -1) $stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')';
+if ($object_status != '' && $object_status > -1) {
+ $stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')';
+}
// Build graphic number of object
$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
// $data = array(array('Lib',val1,val2,val3),...)
-if (!$user->rights->societe->client->voir || $user->socid)
-{
+if (!$user->rights->societe->client->voir || $user->socid) {
$filenamenb = $dir.'/interventionsnbinyear-'.$user->id.'-'.$year.'.png';
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.'-'.$year.'.png';
} else {
@@ -88,12 +90,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
$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++;
}
@@ -115,8 +115,7 @@ if (!$mesg)
$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
// $data = array(array('Lib',val1,val2,val3),...)
-if (!$user->rights->societe->client->voir || $user->socid)
-{
+if (!$user->rights->societe->client->voir || $user->socid) {
$filenameamount = $dir.'/interventionsamountinyear-'.$user->id.'-'.$year.'.png';
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png';
} else {
@@ -126,12 +125,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
$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++;
}
@@ -152,8 +149,7 @@ if (!$mesg)
$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
-if (!$user->rights->societe->client->voir || $user->socid)
-{
+if (!$user->rights->societe->client->voir || $user->socid) {
$filename_avg = $dir.'/interventionsaverage-'.$user->id.'-'.$year.'.png';
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.'-'.$year.'.png';
} else {
@@ -163,12 +159,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
$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++;
}
@@ -196,7 +190,9 @@ foreach ($data as $val) {
$arrayyears[$val['year']] = $val['year'];
}
}
-if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
+if (!count($arrayyears)) {
+ $arrayyears[$nowyear] = $nowyear;
+}
$h = 0;
$head = array();
@@ -236,13 +232,19 @@ print '';
print '
'.$langs->trans("Status").' ';
$tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short
$liststatus = $objectstatic->statuts_short;
- if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
+if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) {
+ unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
+}
print $form->selectarray('object_status', $liststatus, $object_status, 1, 0, 0, '', 1);
print ' ';
// Year
print ''.$langs->trans("Year").' ';
- if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
- if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
+if (!in_array($year, $arrayyears)) {
+ $arrayyears[$year] = $year;
+}
+if (!in_array($nowyear, $arrayyears)) {
+ $arrayyears[$nowyear] = $nowyear;
+}
arsort($arrayyears);
print $form->selectarray('year', $arrayyears, $year, 0);
print ' ';
@@ -265,11 +267,9 @@ print '% ';
print '';
$oldyear = 0;
-foreach ($data as $val)
-{
+foreach ($data as $val) {
$year = $val['year'];
- while (!empty($year) && $oldyear > $year + 1)
- {
+ while (!empty($year) && $oldyear > $year + 1) {
// If we have empty year
$oldyear--;
@@ -307,12 +307,14 @@ print '';
// Show graphs
print '
';
-if ($mesg) { print $mesg; } else {
+if ($mesg) {
+ print $mesg;
+} else {
print $px1->show();
/*print " \n";
- print $px2->show();
- print " \n";
- print $px3->show();*/
+ print $px2->show();
+ print " \n";
+ print $px3->show();*/
}
print '
';
diff --git a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php
index b483e877e5e..ba754ec3321 100644
--- a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php
@@ -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;
}
@@ -36,17 +35,18 @@ $langs->load("interventions");
$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
$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';
+ }
?>
-
+
trans("Intervention"); ?>
- getNomUrl(1); ?>
-
+ getNomUrl(1); ?>
+
datev, 'day'); ?>
getLibStatut(3); ?>
diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php
index 8d9778b177e..9fbdcc88eab 100644
--- a/htdocs/filefunc.inc.php
+++ b/htdocs/filefunc.inc.php
@@ -30,14 +30,19 @@
* \brief File that include conf.php file and commons lib like functions.lib.php
*/
-if (!defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE', 'Dolibarr');
-if (!defined('DOL_VERSION')) define('DOL_VERSION', '14.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
+if (!defined('DOL_APPLICATION_TITLE')) {
+ define('DOL_APPLICATION_TITLE', 'Dolibarr');
+}
+if (!defined('DOL_VERSION')) {
+ define('DOL_VERSION', '14.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
+}
-if (!defined('EURO')) define('EURO', chr(128));
+if (!defined('EURO')) {
+ define('EURO', chr(128));
+}
// Define syslog constants
-if (!defined('LOG_DEBUG'))
-{
+if (!defined('LOG_DEBUG')) {
if (!function_exists("syslog")) {
// For PHP versions without syslog (like running on Windows OS)
define('LOG_EMERG', 0);
@@ -52,7 +57,9 @@ if (!defined('LOG_DEBUG'))
}
// End of common declaration part
-if (defined('DOL_INC_FOR_VERSION_ERROR')) return;
+if (defined('DOL_INC_FOR_VERSION_ERROR')) {
+ return;
+}
// Define vars
@@ -73,15 +80,13 @@ $conffiletoshow = "htdocs/conf/conf.php";
// Include configuration
$result = @include_once $conffile; // Keep @ because with some error reporting this break the redirect done when file not found
-if (!$result && !empty($_SERVER["GATEWAY_INTERFACE"])) // If install not done and we are in a web session
-{
- if (!empty($_SERVER["CONTEXT_PREFIX"])) // CONTEXT_PREFIX and CONTEXT_DOCUMENT_ROOT are not defined on all apache versions
- {
+if (!$result && !empty($_SERVER["GATEWAY_INTERFACE"])) { // If install not done and we are in a web session
+ if (!empty($_SERVER["CONTEXT_PREFIX"])) { // CONTEXT_PREFIX and CONTEXT_DOCUMENT_ROOT are not defined on all apache versions
$path = $_SERVER["CONTEXT_PREFIX"]; // example '/dolibarr/' when using an apache alias.
- if (!preg_match('/\/$/', $path)) $path .= '/';
- }
- elseif (preg_match('/index\.php/', $_SERVER['PHP_SELF']))
- {
+ if (!preg_match('/\/$/', $path)) {
+ $path .= '/';
+ }
+ } elseif (preg_match('/index\.php/', $_SERVER['PHP_SELF'])) {
// When we ask index.php, we MUST BE SURE that $path is '' at the end. This is required to make install process
// when using apache alias like '/dolibarr/' that point to htdocs.
// Note: If calling page was an index.php not into htdocs (ie comm/index.php, ...), then this redirect will fails,
@@ -94,11 +99,16 @@ if (!$result && !empty($_SERVER["GATEWAY_INTERFACE"])) // If install not done
$TDir = explode('/', $_SERVER['PHP_SELF']);
$path = '';
$i = count($TDir);
- while ($i--)
- {
- if (empty($TDir[$i]) || $TDir[$i] == 'htdocs') break;
- if ($TDir[$i] == 'dolibarr') break;
- if (substr($TDir[$i], -4, 4) == '.php') continue;
+ while ($i--) {
+ if (empty($TDir[$i]) || $TDir[$i] == 'htdocs') {
+ break;
+ }
+ if ($TDir[$i] == 'dolibarr') {
+ break;
+ }
+ if (substr($TDir[$i], -4, 4) == '.php') {
+ continue;
+ }
$path .= '../';
}
@@ -109,15 +119,16 @@ if (!$result && !empty($_SERVER["GATEWAY_INTERFACE"])) // If install not done
}
// Force PHP error_reporting setup (Dolibarr may report warning without this)
-if (!empty($dolibarr_strict_mode))
-{
+if (!empty($dolibarr_strict_mode)) {
error_reporting(E_ALL | E_STRICT);
} else {
error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
}
// Disable php display errors
-if (!empty($dolibarr_main_prod)) ini_set('display_errors', 'Off');
+if (!empty($dolibarr_main_prod)) {
+ ini_set('display_errors', 'Off');
+}
// Clean parameters
$dolibarr_main_data_root = trim($dolibarr_main_data_root);
@@ -126,39 +137,63 @@ $dolibarr_main_url_root_alt = (empty($dolibarr_main_url_root_alt) ? '' : trim($d
$dolibarr_main_document_root = trim($dolibarr_main_document_root);
$dolibarr_main_document_root_alt = (empty($dolibarr_main_document_root_alt) ? '' : trim($dolibarr_main_document_root_alt));
-if (empty($dolibarr_main_db_port)) $dolibarr_main_db_port = 3306; // For compatibility with old configs, if not defined, we take 'mysql' type
-if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type = 'mysqli'; // For compatibility with old configs, if not defined, we take 'mysql' type
+if (empty($dolibarr_main_db_port)) {
+ $dolibarr_main_db_port = 3306; // For compatibility with old configs, if not defined, we take 'mysql' type
+}
+if (empty($dolibarr_main_db_type)) {
+ $dolibarr_main_db_type = 'mysqli'; // For compatibility with old configs, if not defined, we take 'mysql' type
+}
// 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_prefix)) $dolibarr_main_db_prefix = 'llx_';
-if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set = ($dolibarr_main_db_type == 'mysqli' ? 'utf8' : ''); // Old installation
-if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation = ($dolibarr_main_db_type == 'mysqli' ? 'utf8_unicode_ci' : ''); // Old installation
-if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0;
-if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = '';
-if (empty($dolibarr_main_limit_users)) $dolibarr_main_limit_users = 0;
-if (empty($dolibarr_mailing_limit_sendbyweb)) $dolibarr_mailing_limit_sendbyweb = 0;
-if (empty($dolibarr_mailing_limit_sendbycli)) $dolibarr_mailing_limit_sendbycli = 0;
-if (empty($dolibarr_strict_mode)) $dolibarr_strict_mode = 0; // For debug in php strict mode
+if ($dolibarr_main_db_type == 'mysql') {
+ $dolibarr_main_db_type = 'mysqli';
+}
+if (empty($dolibarr_main_db_prefix)) {
+ $dolibarr_main_db_prefix = 'llx_';
+}
+if (empty($dolibarr_main_db_character_set)) {
+ $dolibarr_main_db_character_set = ($dolibarr_main_db_type == 'mysqli' ? 'utf8' : ''); // Old installation
+}
+if (empty($dolibarr_main_db_collation)) {
+ $dolibarr_main_db_collation = ($dolibarr_main_db_type == 'mysqli' ? 'utf8_unicode_ci' : ''); // Old installation
+}
+if (empty($dolibarr_main_db_encryption)) {
+ $dolibarr_main_db_encryption = 0;
+}
+if (empty($dolibarr_main_db_cryptkey)) {
+ $dolibarr_main_db_cryptkey = '';
+}
+if (empty($dolibarr_main_limit_users)) {
+ $dolibarr_main_limit_users = 0;
+}
+if (empty($dolibarr_mailing_limit_sendbyweb)) {
+ $dolibarr_mailing_limit_sendbyweb = 0;
+}
+if (empty($dolibarr_mailing_limit_sendbycli)) {
+ $dolibarr_mailing_limit_sendbycli = 0;
+}
+if (empty($dolibarr_strict_mode)) {
+ $dolibarr_strict_mode = 0; // For debug in php strict mode
+}
// Security: CSRF protection
// This test check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST'])
// when we post forms (we allow GET to allow direct link to access a particular page).
// Note about $_SERVER[HTTP_HOST/SERVER_NAME]: http://shiflett.org/blog/2006/mar/server-name-versus-http-host
// See also option $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN for a stronger CSRF protection.
-if (!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck))
-{
- if (!empty($_SERVER['REQUEST_METHOD']) && !in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) && !empty($_SERVER['HTTP_HOST']))
- {
+if (!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck)) {
+ if (!empty($_SERVER['REQUEST_METHOD']) && !in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) && !empty($_SERVER['HTTP_HOST'])) {
$csrfattack = false;
- if (empty($_SERVER['HTTP_REFERER'])) $csrfattack = true; // An evil browser was used
- else {
+ if (empty($_SERVER['HTTP_REFERER'])) {
+ $csrfattack = true; // An evil browser was used
+ } else {
$tmpa = parse_url($_SERVER['HTTP_HOST']);
$tmpb = parse_url($_SERVER['HTTP_REFERER']);
- if ((empty($tmpa['host']) ? $tmpa['path'] : $tmpa['host']) != (empty($tmpb['host']) ? $tmpb['path'] : $tmpb['host'])) $csrfattack = true;
+ if ((empty($tmpa['host']) ? $tmpa['path'] : $tmpa['host']) != (empty($tmpb['host']) ? $tmpb['path'] : $tmpb['host'])) {
+ $csrfattack = true;
+ }
}
- if ($csrfattack)
- {
+ if ($csrfattack) {
//print 'NOCSRFCHECK='.defined('NOCSRFCHECK').' REQUEST_METHOD='.$_SERVER['REQUEST_METHOD'].' HTTP_HOST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER'];
// Note: We can't use dol_escape_htmltag here to escape output because lib functions.lib.ph is not yet loaded.
print "Access refused by CSRF protection in main.inc.php. Referer of form (".htmlentities($_SERVER['HTTP_REFERER'], ENT_COMPAT, 'UTF-8').") is outside the server that serve this page (with method = ".htmlentities($_SERVER['REQUEST_METHOD'], ENT_COMPAT, 'UTF-8').").\n";
@@ -168,20 +203,17 @@ if (!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck))
}
// Another test is done later on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on.
}
-if (empty($dolibarr_main_db_host))
-{
+if (empty($dolibarr_main_db_host)) {
print ''."\n";
die;
}
-if (empty($dolibarr_main_url_root))
-{
+if (empty($dolibarr_main_url_root)) {
print 'Value for parameter \'dolibarr_main_url_root\' is not defined in your \'htdocs\conf\conf.php\' file. '."\n";
print 'You must add this parameter with your full Dolibarr root Url (Example: http://myvirtualdomain/ or http://mydomain/mydolibarrurl/)'."\n";
die;
}
-if (empty($dolibarr_main_data_root))
-{
+if (empty($dolibarr_main_data_root)) {
// Si repertoire documents non defini, on utilise celui par defaut
$dolibarr_main_data_root = str_replace("/htdocs", "", $dolibarr_main_document_root);
$dolibarr_main_data_root .= "/documents";
@@ -204,14 +236,14 @@ if (!empty($_SERVER["DOCUMENT_ROOT"])) {
$paths = explode('/', str_replace('\\', '/', $_SERVER["SCRIPT_NAME"])); // C) Value reported by web server, to say full path on filesystem of a file. Ex: /dolibarr/htdocs/admin/system/phpinfo.php
// Try to detect if $_SERVER["DOCUMENT_ROOT"]+start of $_SERVER["SCRIPT_NAME"] is $dolibarr_main_document_root. If yes, relative url to add before dol files is this start part.
$concatpath = '';
-foreach ($paths as $tmppath) // We check to find (B+start of C)=A
-{
- if (empty($tmppath)) continue;
+foreach ($paths as $tmppath) { // We check to find (B+start of C)=A
+ if (empty($tmppath)) {
+ continue;
+ }
$concatpath .= '/'.$tmppath;
//if ($tmppath) $concatpath.='/'.$tmppath;
//print $_SERVER["SCRIPT_NAME"].'-'.$pathroot.'-'.$concatpath.'-'.$real_dolibarr_main_document_root.'-'.realpath($pathroot.$concatpath).' ';
- if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) // @ avoid warning when safe_mode is on.
- {
+ if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) { // @ avoid warning when safe_mode is on.
//print "Found relative url = ".$concatpath;
$tmp3 = $concatpath;
$found = 1;
@@ -220,14 +252,21 @@ foreach ($paths as $tmppath) // We check to find (B+start of C)=A
//else print "Not found yet for concatpath=".$concatpath." \n";
}
//print "found=".$found." dolibarr_main_url_root=".$dolibarr_main_url_root."\n";
-if (!$found) $tmp = $dolibarr_main_url_root; // If autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT).
-else $tmp = 'http'.(((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') && (empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] != 443)) ? '' : 's').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] == 80 || $_SERVER["SERVER_PORT"] == 443) ? '' : ':'.$_SERVER["SERVER_PORT"]).($tmp3 ? (preg_match('/^\//', $tmp3) ? '' : '/').$tmp3 : '');
+if (!$found) {
+ $tmp = $dolibarr_main_url_root; // If autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT).
+} else {
+ $tmp = 'http'.(((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') && (empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] != 443)) ? '' : 's').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] == 80 || $_SERVER["SERVER_PORT"] == 443) ? '' : ':'.$_SERVER["SERVER_PORT"]).($tmp3 ? (preg_match('/^\//', $tmp3) ? '' : '/').$tmp3 : '');
+}
//print "tmp1=".$tmp1." tmp2=".$tmp2." tmp3=".$tmp3." tmp=".$tmp."\n";
-if (!empty($dolibarr_main_force_https)) $tmp = preg_replace('/^http:/i', 'https:', $tmp);
+if (!empty($dolibarr_main_force_https)) {
+ $tmp = preg_replace('/^http:/i', 'https:', $tmp);
+}
define('DOL_MAIN_URL_ROOT', $tmp); // URL absolute root (https://sss/dolibarr, ...)
$uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
$suburi = strstr($uri, '/'); // $suburi contains url without domain:port
-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', ...)
//print DOL_MAIN_URL_ROOT.'-'.DOL_URL_ROOT."\n";
@@ -241,29 +280,54 @@ define('MAIN_DB_PREFIX', $dolibarr_main_db_prefix);
* To use other version than embeded libraries, define here constant to path. Use '' to use include class path autodetect.
*/
// Path to root libraries
-if (!defined('ADODB_PATH')) { define('ADODB_PATH', (!isset($dolibarr_lib_ADODB_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/adodbtime/' : (empty($dolibarr_lib_ADODB_PATH) ? '' : $dolibarr_lib_ADODB_PATH.'/')); }
-if (!defined('TCPDF_PATH')) { define('TCPDF_PATH', (empty($dolibarr_lib_TCPDF_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/tecnickcom/tcpdf/' : $dolibarr_lib_TCPDF_PATH.'/'); }
-if (!defined('TCPDI_PATH')) { define('TCPDI_PATH', (empty($dolibarr_lib_TCPDI_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/tcpdi/' : $dolibarr_lib_TCPDI_PATH.'/'); }
-if (!defined('NUSOAP_PATH')) { define('NUSOAP_PATH', (!isset($dolibarr_lib_NUSOAP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/nusoap/lib/' : (empty($dolibarr_lib_NUSOAP_PATH) ? '' : $dolibarr_lib_NUSOAP_PATH.'/')); }
-if (!defined('PHPEXCELNEW_PATH')) { define('PHPEXCELNEW_PATH', (!isset($dolibarr_lib_PHPEXCELNEW_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/phpoffice/PhpSpreadsheet/' : (empty($dolibarr_lib_PHPEXCELNEW_PATH) ? '' : $dolibarr_lib_PHPEXCELNEW_PATH.'/')); }
-if (!defined('ODTPHP_PATH')) { define('ODTPHP_PATH', (!isset($dolibarr_lib_ODTPHP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/odtphp/' : (empty($dolibarr_lib_ODTPHP_PATH) ? '' : $dolibarr_lib_ODTPHP_PATH.'/')); }
-if (!defined('ODTPHP_PATHTOPCLZIP')) { define('ODTPHP_PATHTOPCLZIP', (!isset($dolibarr_lib_ODTPHP_PATHTOPCLZIP)) ?DOL_DOCUMENT_ROOT.'/includes/odtphp/zip/pclzip/' : (empty($dolibarr_lib_ODTPHP_PATHTOPCLZIP) ? '' : $dolibarr_lib_ODTPHP_PATHTOPCLZIP.'/')); }
-if (!defined('JS_CKEDITOR')) { define('JS_CKEDITOR', (!isset($dolibarr_js_CKEDITOR)) ? '' : (empty($dolibarr_js_CKEDITOR) ? '' : $dolibarr_js_CKEDITOR.'/')); }
-if (!defined('JS_JQUERY')) { define('JS_JQUERY', (!isset($dolibarr_js_JQUERY)) ? '' : (empty($dolibarr_js_JQUERY) ? '' : $dolibarr_js_JQUERY.'/')); }
-if (!defined('JS_JQUERY_UI')) { define('JS_JQUERY_UI', (!isset($dolibarr_js_JQUERY_UI)) ? '' : (empty($dolibarr_js_JQUERY_UI) ? '' : $dolibarr_js_JQUERY_UI.'/')); }
+if (!defined('ADODB_PATH')) {
+ define('ADODB_PATH', (!isset($dolibarr_lib_ADODB_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/adodbtime/' : (empty($dolibarr_lib_ADODB_PATH) ? '' : $dolibarr_lib_ADODB_PATH.'/'));
+}
+if (!defined('TCPDF_PATH')) {
+ define('TCPDF_PATH', (empty($dolibarr_lib_TCPDF_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/tecnickcom/tcpdf/' : $dolibarr_lib_TCPDF_PATH.'/');
+}
+if (!defined('TCPDI_PATH')) {
+ define('TCPDI_PATH', (empty($dolibarr_lib_TCPDI_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/tcpdi/' : $dolibarr_lib_TCPDI_PATH.'/');
+}
+if (!defined('NUSOAP_PATH')) {
+ define('NUSOAP_PATH', (!isset($dolibarr_lib_NUSOAP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/nusoap/lib/' : (empty($dolibarr_lib_NUSOAP_PATH) ? '' : $dolibarr_lib_NUSOAP_PATH.'/'));
+}
+if (!defined('PHPEXCELNEW_PATH')) {
+ define('PHPEXCELNEW_PATH', (!isset($dolibarr_lib_PHPEXCELNEW_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/phpoffice/PhpSpreadsheet/' : (empty($dolibarr_lib_PHPEXCELNEW_PATH) ? '' : $dolibarr_lib_PHPEXCELNEW_PATH.'/'));
+}
+if (!defined('ODTPHP_PATH')) {
+ define('ODTPHP_PATH', (!isset($dolibarr_lib_ODTPHP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/odtphp/' : (empty($dolibarr_lib_ODTPHP_PATH) ? '' : $dolibarr_lib_ODTPHP_PATH.'/'));
+}
+if (!defined('ODTPHP_PATHTOPCLZIP')) {
+ define('ODTPHP_PATHTOPCLZIP', (!isset($dolibarr_lib_ODTPHP_PATHTOPCLZIP)) ?DOL_DOCUMENT_ROOT.'/includes/odtphp/zip/pclzip/' : (empty($dolibarr_lib_ODTPHP_PATHTOPCLZIP) ? '' : $dolibarr_lib_ODTPHP_PATHTOPCLZIP.'/'));
+}
+if (!defined('JS_CKEDITOR')) {
+ define('JS_CKEDITOR', (!isset($dolibarr_js_CKEDITOR)) ? '' : (empty($dolibarr_js_CKEDITOR) ? '' : $dolibarr_js_CKEDITOR.'/'));
+}
+if (!defined('JS_JQUERY')) {
+ define('JS_JQUERY', (!isset($dolibarr_js_JQUERY)) ? '' : (empty($dolibarr_js_JQUERY) ? '' : $dolibarr_js_JQUERY.'/'));
+}
+if (!defined('JS_JQUERY_UI')) {
+ define('JS_JQUERY_UI', (!isset($dolibarr_js_JQUERY_UI)) ? '' : (empty($dolibarr_js_JQUERY_UI) ? '' : $dolibarr_js_JQUERY_UI.'/'));
+}
// Other required path
-if (!defined('DOL_DEFAULT_TTF')) { define('DOL_DEFAULT_TTF', (!isset($dolibarr_font_DOL_DEFAULT_TTF)) ?DOL_DOCUMENT_ROOT.'/includes/fonts/Aerial.ttf' : (empty($dolibarr_font_DOL_DEFAULT_TTF) ? '' : $dolibarr_font_DOL_DEFAULT_TTF)); }
-if (!defined('DOL_DEFAULT_TTF_BOLD')) { define('DOL_DEFAULT_TTF_BOLD', (!isset($dolibarr_font_DOL_DEFAULT_TTF_BOLD)) ?DOL_DOCUMENT_ROOT.'/includes/fonts/AerialBd.ttf' : (empty($dolibarr_font_DOL_DEFAULT_TTF_BOLD) ? '' : $dolibarr_font_DOL_DEFAULT_TTF_BOLD)); }
+if (!defined('DOL_DEFAULT_TTF')) {
+ define('DOL_DEFAULT_TTF', (!isset($dolibarr_font_DOL_DEFAULT_TTF)) ?DOL_DOCUMENT_ROOT.'/includes/fonts/Aerial.ttf' : (empty($dolibarr_font_DOL_DEFAULT_TTF) ? '' : $dolibarr_font_DOL_DEFAULT_TTF));
+}
+if (!defined('DOL_DEFAULT_TTF_BOLD')) {
+ define('DOL_DEFAULT_TTF_BOLD', (!isset($dolibarr_font_DOL_DEFAULT_TTF_BOLD)) ?DOL_DOCUMENT_ROOT.'/includes/fonts/AerialBd.ttf' : (empty($dolibarr_font_DOL_DEFAULT_TTF_BOLD) ? '' : $dolibarr_font_DOL_DEFAULT_TTF_BOLD));
+}
/*
* Include functions
*/
-if (!defined('ADODB_DATE_VERSION')) include_once ADODB_PATH.'adodb-time.inc.php';
+if (!defined('ADODB_DATE_VERSION')) {
+ include_once ADODB_PATH.'adodb-time.inc.php';
+}
-if (!file_exists(DOL_DOCUMENT_ROOT."/core/lib/functions.lib.php"))
-{
+if (!file_exists(DOL_DOCUMENT_ROOT."/core/lib/functions.lib.php")) {
print "Error: Dolibarr config file content seems to be not correctly defined. \n";
print "Please run dolibarr setup by calling page /install . \n";
exit;
diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php
index 0c0d8f42c9e..e0cd9beff0c 100644
--- a/htdocs/fourn/ajax/getSupplierPrices.php
+++ b/htdocs/fourn/ajax/getSupplierPrices.php
@@ -22,10 +22,18 @@
* \brief File to return an Ajax response to get list of possible prices for margin calculation
*/
-if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
-if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
-if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
-if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
+if (!defined('NOTOKENRENEWAL')) {
+ define('NOTOKENRENEWAL', '1'); // Disables token renewal
+}
+if (!defined('NOREQUIREMENU')) {
+ define('NOREQUIREMENU', '1');
+}
+if (!defined('NOREQUIREAJAX')) {
+ define('NOREQUIREAJAX', '1');
+}
+if (!defined('NOREQUIRESOC')) {
+ define('NOREQUIRESOC', '1');
+}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
@@ -46,47 +54,45 @@ top_httphead();
//print ''."\n";
-if ($idprod > 0)
-{
+if ($idprod > 0) {
$producttmp = new ProductFournisseur($db);
$producttmp->fetch($idprod);
$sorttouse = 's.nom, pfp.quantity, pfp.price';
- if (GETPOST('bestpricefirst')) $sorttouse = 'pfp.unitprice, s.nom, pfp.quantity, pfp.price';
+ if (GETPOST('bestpricefirst')) {
+ $sorttouse = 'pfp.unitprice, s.nom, pfp.quantity, pfp.price';
+ }
$productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, $sorttouse); // We list all price per supplier, and then firstly with the lower quantity. So we can choose first one with enough quantity into list.
- if (is_array($productSupplierArray))
- {
- foreach ($productSupplierArray as $productSupplier)
- {
+ if (is_array($productSupplierArray)) {
+ foreach ($productSupplierArray as $productSupplier) {
$price = $productSupplier->fourn_price * (1 - $productSupplier->fourn_remise_percent / 100);
$unitprice = $productSupplier->fourn_unitprice * (1 - $productSupplier->fourn_remise_percent / 100);
$title = $productSupplier->fourn_name.' - '.$productSupplier->fourn_ref.' - ';
- if ($productSupplier->fourn_qty == 1)
- {
+ if ($productSupplier->fourn_qty == 1) {
$title .= price($price, 0, $langs, 0, 0, -1, $conf->currency)."/";
}
$title .= $productSupplier->fourn_qty.' '.($productSupplier->fourn_qty == 1 ? $langs->trans("Unit") : $langs->trans("Units"));
- if ($productSupplier->fourn_qty > 1)
- {
+ if ($productSupplier->fourn_qty > 1) {
$title .= " - ";
$title .= price($unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit");
$price = $unitprice;
}
$label = price($price, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit");
- if ($productSupplier->fourn_ref) $label .= ' ('.$productSupplier->fourn_ref.')';
+ if ($productSupplier->fourn_ref) {
+ $label .= ' ('.$productSupplier->fourn_ref.')';
+ }
$prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price, 0, '', 0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price()
}
}
// After best supplier prices and before costprice
- if (!empty($conf->stock->enabled))
- {
+ if (!empty($conf->stock->enabled)) {
// Add price for pmp
$price = $producttmp->pmp;
$prices[] = array("id" => 'pmpprice', "price" => price2num($price), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price()
diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php
index 9d18f3cfd1a..3b9a0df399b 100644
--- a/htdocs/fourn/card.php
+++ b/htdocs/fourn/card.php
@@ -7,6 +7,7 @@
* Copyright (C) 2014 Jean Heimburger
* Copyright (C) 2015 Marcos García
* Copyright (C) 2015 Raphaël Doursenaud
+ * Copyright (C) 2021 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,8 +36,12 @@ require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
-if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
-if (!empty($conf->categorie->enabled)) 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->categorie->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+}
// Load translation files required by page
$langs->loadLangs(array(
@@ -53,7 +58,9 @@ $cancelbutton = GETPOST('cancel', 'alpha');
// Security check
$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
-if ($user->socid) $id = $user->socid;
+if ($user->socid) {
+ $id = $user->socid;
+}
$result = restrictedArea($user, 'societe&fournisseur', $id, '&societe', '', 'rowid');
$object = new Fournisseur($db);
@@ -81,44 +88,48 @@ if ($object->id > 0) {
$parameters = array('id'=>$id);
$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 ($cancelbutton)
- {
+if (empty($reshook)) {
+ if ($cancelbutton) {
$action = "";
}
- if ($action == 'setsupplieraccountancycode')
- {
+ if ($action == 'setsupplieraccountancycode') {
$result = $object->fetch($id);
- $object->code_compta_fournisseur = $_POST["supplieraccountancycode"];
+ $object->code_compta_fournisseur = GETPOST("supplieraccountancycode");
$result = $object->update($object->id, $user, 1, 0, 1);
- if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
+ if ($result < 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
}
// terms of the settlement
- if ($action == 'setconditions' && $user->rights->societe->creer)
- {
+ if ($action == 'setconditions' && $user->rights->societe->creer) {
$object->fetch($id);
$result = $object->setPaymentTerms(GETPOST('cond_reglement_supplier_id', 'int'));
- if ($result < 0) dol_print_error($db, $object->error);
+ if ($result < 0) {
+ dol_print_error($db, $object->error);
+ }
}
// mode de reglement
- if ($action == 'setmode' && $user->rights->societe->creer)
- {
+ if ($action == 'setmode' && $user->rights->societe->creer) {
$object->fetch($id);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_supplier_id', 'int'));
- if ($result < 0) dol_print_error($db, $object->error);
+ if ($result < 0) {
+ dol_print_error($db, $object->error);
+ }
}
// update supplier order min amount
- if ($action == 'setsupplier_order_min_amount')
- {
+ if ($action == 'setsupplier_order_min_amount') {
$object->fetch($id);
$object->supplier_order_min_amount = price2num(GETPOST('supplier_order_min_amount', 'alpha'));
$result = $object->update($object->id, $user);
- if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
+ if ($result < 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
}
if ($action == 'update_extras') {
@@ -129,15 +140,20 @@ if (empty($reshook))
// Fill array 'array_options' with data from update form
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
- if ($ret < 0) $error++;
-
- if (!$error)
- {
- $result = $object->insertExtraFields('COMPANY_MODIFY');
- if ($result < 0) $error++;
+ if ($ret < 0) {
+ $error++;
}
- if ($error) $action = 'edit_extras';
+ if (!$error) {
+ $result = $object->insertExtraFields('COMPANY_MODIFY');
+ if ($result < 0) {
+ $error++;
+ }
+ }
+
+ if ($error) {
+ $action = 'edit_extras';
+ }
}
}
@@ -149,17 +165,19 @@ if (empty($reshook))
$contactstatic = new Contact($db);
$form = new Form($db);
-if ($id > 0 && empty($object->id))
-{
+if ($id > 0 && empty($object->id)) {
// Load data of third party
$res = $object->fetch($id);
- if ($object->id <= 0) dol_print_error($db, $object->error);
+ if ($object->id <= 0) {
+ dol_print_error($db, $object->error);
+ }
}
-if ($object->id > 0)
-{
+if ($object->id > 0) {
$title = $langs->trans("ThirdParty")." - ".$langs->trans('Supplier');
- if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$langs->trans('Supplier');
+ if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
+ $title = $object->name." - ".$langs->trans('Supplier');
+ }
$help_url = '';
llxHeader('', $title, $help_url);
@@ -177,29 +195,27 @@ if ($object->id > 0)
print '';
print '
';
- print '
';
+ print '';
// Type Prospect/Customer/Supplier
print ''.$langs->trans('NatureOfThirdParty').' ';
print $object->getTypeUrl(1);
print ' ';
- if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
- {
+ if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
print ''.$langs->trans('Prefix').' '.$object->prefix_comm.' ';
}
- if ($object->fournisseur)
- {
+ if ($object->fournisseur) {
print '';
- print ''.$langs->trans("SupplierCode").' ';
- print $object->code_fournisseur;
- $tmpcheck = $object->check_codefournisseur();
- if ($tmpcheck != 0 && $tmpcheck != -5) {
- print ' ('.$langs->trans("WrongSupplierCode").') ';
- }
- print ' ';
- print ' ';
+ print ''.$langs->trans("SupplierCode").' ';
+ print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
+ $tmpcheck = $object->check_codefournisseur();
+ if ($tmpcheck != 0 && $tmpcheck != -5) {
+ print ' ('.$langs->trans("WrongSupplierCode").') ';
+ }
+ print ' ';
+ print '';
$langs->load('compta');
print '';
@@ -221,14 +237,12 @@ if ($object->id > 0)
print ' ';
// Local Taxes
- if ($mysoc->useLocalTax(1))
- {
+ if ($mysoc->useLocalTax(1)) {
print ''.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).' ';
print yn($object->localtax1_assuj);
print ' ';
}
- if ($mysoc->useLocalTax(2))
- {
+ if ($mysoc->useLocalTax(2)) {
print ''.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).' ';
print yn($object->localtax2_assuj);
print ' ';
@@ -236,7 +250,7 @@ if ($object->id > 0)
// TVA Intra
print ''.$langs->trans('VATIntra').' ';
- print $object->tva_intra;
+ print showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra));
print ' ';
// Default terms of the settlement
@@ -246,11 +260,12 @@ if ($object->id > 0)
print '';
print '';
- if ($action == 'editconditions')
- {
+ if ($action == 'editconditions') {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_supplier_id, 'cond_reglement_supplier_id', -1, 1);
} else {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_supplier_id, 'none');
@@ -263,11 +278,12 @@ if ($object->id > 0)
print '';
print ' ';
- if ($action == 'editmode')
- {
+ if ($action == 'editmode') {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_supplier_id, 'mode_reglement_supplier_id', 'DBIT', 1, 1);
} else {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_supplier_id, 'none');
@@ -280,8 +296,7 @@ if ($object->id > 0)
print '';
print $langs->trans("CustomerRelativeDiscountShort");
print ' ';
- if ($user->rights->societe->creer && !$user->socid > 0)
- {
+ if ($user->rights->societe->creer && !$user->socid > 0) {
print ''.img_edit($langs->trans("Modify")).' ';
}
print '
';
@@ -294,22 +309,24 @@ if ($object->id > 0)
print ' ';
print $langs->trans("CustomerAbsoluteDiscountShort");
print ' ';
- if ($user->rights->societe->creer && !$user->socid > 0)
- {
+ if ($user->rights->societe->creer && !$user->socid > 0) {
print 'id).'">'.img_edit($langs->trans("Modify")).' ';
}
print '
';
print '';
print '';
$amount_discount = $object->getAvailableDiscounts('', '', 0, 1);
- if ($amount_discount < 0) dol_print_error($db, $object->error);
- if ($amount_discount > 0) print 'id).'">'.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).' ';
+ if ($amount_discount < 0) {
+ dol_print_error($db, $object->error);
+ }
+ if ($amount_discount > 0) {
+ print 'id).'">'.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).' ';
+ }
//else print $langs->trans("DiscountNone");
print ' ';
print '';
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT))
- {
+ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) {
print '';
print '';
print $form->editfieldkey("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->rights->societe->creer);
@@ -321,8 +338,7 @@ if ($object->id > 0)
}
// Categories
- if (!empty($conf->categorie->enabled))
- {
+ if (!empty($conf->categorie->enabled)) {
$langs->load("categories");
print ' '.$langs->trans("SuppliersCategoriesShort").' ';
print '';
@@ -335,16 +351,14 @@ if ($object->id > 0)
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
// Module Adherent
- if (!empty($conf->adherent->enabled))
- {
+ if (!empty($conf->adherent->enabled)) {
$langs->load("members");
$langs->load("users");
print ' '.$langs->trans("LinkedToDolibarrMember").' ';
print '';
$adh = new Adherent($db);
$result = $adh->fetch('', '', $object->id);
- if ($result > 0)
- {
+ if ($result > 0) {
$adh->ref = $adh->getFullName($langs);
print $adh->getNomUrl(1);
} else {
@@ -371,8 +385,7 @@ if ($object->id > 0)
$boxstat .= '';
$boxstat .= '';
- if ($conf->supplier_proposal->enabled)
- {
+ if ($conf->supplier_proposal->enabled) {
// Box proposals
$tmp = $object->getOutstandingProposals('supplier');
$outstandingOpened = $tmp['opened'];
@@ -381,16 +394,19 @@ if ($object->id > 0)
$text = $langs->trans("OverAllSupplierProposals");
$link = DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->id;
$icon = 'bill';
- if ($link) $boxstat .= '';
+ if ($link) {
+ $boxstat .= ' ';
+ }
$boxstat .= '';
$boxstat .= ''.img_object("", $icon).' '.$text.' ';
$boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).' ';
$boxstat .= '
';
- if ($link) $boxstat .= ' ';
+ if ($link) {
+ $boxstat .= '';
+ }
}
- if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
- {
+ if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
// Box proposals
$tmp = $object->getOutstandingOrders('supplier');
$outstandingOpened = $tmp['opened'];
@@ -399,16 +415,19 @@ if ($object->id > 0)
$text = $langs->trans("OverAllOrders");
$link = DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id;
$icon = 'bill';
- if ($link) $boxstat .= '';
+ if ($link) {
+ $boxstat .= ' ';
+ }
$boxstat .= '';
$boxstat .= ''.img_object("", $icon).' '.$text.' ';
$boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).' ';
$boxstat .= '
';
- if ($link) $boxstat .= ' ';
+ if ($link) {
+ $boxstat .= '';
+ }
}
- if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
- {
+ if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
$tmp = $object->getOutstandingBills('supplier');
$outstandingOpened = $tmp['opened'];
$outstandingTotal = $tmp['total_ht'];
@@ -417,23 +436,31 @@ if ($object->id > 0)
$text = $langs->trans("OverAllInvoices");
$link = DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id;
$icon = 'bill';
- if ($link) $boxstat .= '';
+ if ($link) {
+ $boxstat .= ' ';
+ }
$boxstat .= '';
$boxstat .= ''.img_object("", $icon).' '.$text.' ';
$boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).' ';
$boxstat .= '
';
- if ($link) $boxstat .= ' ';
+ if ($link) {
+ $boxstat .= '';
+ }
// Box outstanding bill
$text = $langs->trans("CurrentOutstandingBill");
$link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id;
$icon = 'bill';
- if ($link) $boxstat .= '';
+ if ($link) {
+ $boxstat .= ' ';
+ }
$boxstat .= '';
$boxstat .= ''.img_object("", $icon).' '.$text.' ';
$boxstat .= ''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.' ';
$boxstat .= '
';
- if ($link) $boxstat .= ' ';
+ if ($link) {
+ $boxstat .= '';
+ }
$tmp = $object->getOutstandingBills('supplier', 1);
$outstandingOpenedLate = $tmp['opened'];
@@ -441,12 +468,16 @@ if ($object->id > 0)
$text = $langs->trans("CurrentOutstandingBillLate");
$link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id;
$icon = 'bill';
- if ($link) $boxstat .= '';
+ if ($link) {
+ $boxstat .= ' ';
+ }
$boxstat .= '';
$boxstat .= ''.img_object("", $icon).' '.$text.' ';
$boxstat .= ''.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.' ';
$boxstat .= '
';
- if ($link) $boxstat .= ' ';
+ if ($link) {
+ $boxstat .= '';
+ }
}
}
@@ -468,13 +499,12 @@ if ($object->id > 0)
print ' ';
print '
';
print ' ';
- */
+ */
/*
* List of products
*/
- if (!empty($conf->product->enabled) || !empty($conf->service->enabled))
- {
+ if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
$langs->load("products");
//Query from product/liste.php
$sql = 'SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity,';
@@ -487,7 +517,9 @@ if ($object->id > 0)
$sql .= $db->plimit($MAXLIST);
$query = $db->query($sql);
- if (!$query) dol_print_error($db);
+ if (!$query) {
+ dol_print_error($db);
+ }
$num = $db->num_rows($query);
@@ -498,12 +530,10 @@ if ($object->id > 0)
print ' ';
$return = array();
- if ($num > 0)
- {
+ if ($num > 0) {
$productstatic = new Product($db);
- while ($objp = $db->fetch_object($query))
- {
+ while ($objp = $db->fetch_object($query)) {
$productstatic->id = $objp->rowid;
$productstatic->ref = $objp->ref;
$productstatic->label = $objp->label;
@@ -523,11 +553,9 @@ if ($object->id > 0)
//print ''.dol_print_date($objp->tms, 'day').' ';
print '';
//print (isset($objp->unitprice) ? price($objp->unitprice) : '');
- if (isset($objp->price))
- {
+ if (isset($objp->price)) {
print price($objp->price);
- if ($objp->quantity > 1)
- {
+ if ($objp->quantity > 1) {
print ' / ';
print $objp->quantity;
}
@@ -546,11 +574,10 @@ if ($object->id > 0)
*/
$proposalstatic = new SupplierProposal($db);
- if ($user->rights->supplier_proposal->lire)
- {
+ if ($user->rights->supplier_proposal->lire) {
$langs->loadLangs(array("supplier_proposal"));
- $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total as total_ttc";
+ $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p ";
$sql .= " WHERE p.fk_soc =".$object->id;
$sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
@@ -558,13 +585,11 @@ if ($object->id > 0)
$sql .= " ".$db->plimit($MAXLIST);
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num > 0)
- {
+ if ($num > 0) {
print '';
print '';
@@ -576,8 +601,7 @@ if ($object->id > 0)
print ' ';
}
- while ($i < $num && $i <= $MAXLIST)
- {
+ while ($i < $num && $i <= $MAXLIST) {
$obj = $db->fetch_object($resql);
print '';
@@ -590,8 +614,7 @@ if ($object->id > 0)
print $proposalstatic->getNomUrl(1);
print '';
print '';
- if ($obj->dc)
- {
+ if ($obj->dc) {
print dol_print_date($db->jdate($obj->dc), 'day');
} else {
print "-";
@@ -603,7 +626,9 @@ if ($object->id > 0)
}
$db->free($resql);
- if ($num > 0) print "
";
+ if ($num > 0) {
+ print "
";
+ }
} else {
dol_print_error($db);
}
@@ -614,8 +639,7 @@ if ($object->id > 0)
*/
$orderstatic = new CommandeFournisseur($db);
- if ($user->rights->fournisseur->commande->lire)
- {
+ if ($user->rights->fournisseur->commande->lire) {
// TODO move to DAO class
// Check if there are supplier orders billable
$sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
@@ -626,8 +650,7 @@ if ($object->id > 0)
$sql2 .= " AND c.entity IN (".getEntity('commande_fournisseur').")";
$sql2 .= ' AND s.rowid = '.$object->id;
// Show orders we can bill
- if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS))
- {
+ if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) {
$sql2 .= " AND c.fk_statut IN (".$db->sanitize(CommandeFournisseur::STATUS_RECEIVED_COMPLETELY).")"; // Must match filter in htdocs/fourn/commande/list.php
} else {
// CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY
@@ -651,25 +674,22 @@ if ($object->id > 0)
$sql .= " WHERE p.fk_soc =".$object->id;
$sql .= " AND p.entity IN (".getEntity('commande_fournisseur').")";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$object_count = $db->fetch_object($resql);
$num = $object_count->total;
}
- $sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total_ttc";
+ $sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p";
$sql .= " WHERE p.fk_soc =".$object->id;
$sql .= " AND p.entity IN (".getEntity('commande_fournisseur').")";
$sql .= " ORDER BY p.date_commande DESC";
$sql .= " ".$db->plimit($MAXLIST);
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
- if ($num > 0)
- {
+ if ($num > 0) {
print '
';
print '';
@@ -681,8 +701,7 @@ if ($object->id > 0)
print ' ';
}
- while ($i < $num && $i < $MAXLIST)
- {
+ while ($i < $num && $i < $MAXLIST) {
$obj = $db->fetch_object($resql);
print '';
@@ -695,8 +714,7 @@ if ($object->id > 0)
print $orderstatic->getNomUrl(1);
print '';
print '';
- if ($obj->dc)
- {
+ if ($obj->dc) {
print dol_print_date($db->jdate($obj->dc), 'day');
} else {
print "-";
@@ -708,7 +726,9 @@ if ($object->id > 0)
}
$db->free($resql);
- if ($num > 0) print "
";
+ if ($num > 0) {
+ print "
";
+ }
} else {
dol_print_error($db);
}
@@ -721,8 +741,7 @@ if ($object->id > 0)
$langs->load('bills');
$facturestatic = new FactureFournisseur($db);
- if ($user->rights->fournisseur->facture->lire)
- {
+ if ($user->rights->fournisseur->facture->lire) {
// TODO move to DAO class
$sql = 'SELECT f.rowid, f.libelle as label, f.ref, f.ref_supplier, f.fk_statut, f.datef as df, f.total_ht, f.total_tva, f.total_ttc as amount,f.paye,';
$sql .= ' SUM(pf.amount) as am';
@@ -733,12 +752,10 @@ if ($object->id > 0)
$sql .= ' GROUP BY f.rowid,f.libelle,f.ref,f.ref_supplier,f.fk_statut,f.datef,f.total_ht,f.total_tva,f.total_ttc,f.paye';
$sql .= ' ORDER BY f.datef DESC';
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- if ($num > 0)
- {
+ if ($num > 0) {
print '
';
print '';
@@ -749,8 +766,7 @@ if ($object->id > 0)
print ' ';
}
- while ($i < min($num, $MAXLIST))
- {
+ while ($i < min($num, $MAXLIST)) {
$obj = $db->fetch_object($resql);
print '';
@@ -777,7 +793,9 @@ if ($object->id > 0)
$i++;
}
$db->free($resql);
- if ($num > 0) print '
';
+ if ($num > 0) {
+ print '