'; // 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/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 3866405bee8..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');
@@ -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 ' | ';
$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 ': ';
- 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 1d2cb3355a5..62d0d444c3e 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -473,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 {
@@ -558,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)."'";
@@ -586,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);
@@ -598,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);
@@ -608,25 +608,21 @@ 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);
@@ -685,14 +681,18 @@ class Contact extends CommonObject
// }
if ($usermustbemodified) {
$result = $tmpobj->update($user, 0, 1, 1, 1);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
}
}
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('CONTACT_MODIFY', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
@@ -759,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;
@@ -805,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;
@@ -834,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();
}
@@ -875,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
}
@@ -906,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;
}
@@ -936,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)."'";
@@ -948,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;
@@ -1030,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;
@@ -1049,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;
@@ -1102,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';
}
}
@@ -1135,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);
@@ -1169,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,";
@@ -1180,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;
}
@@ -1207,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;
}
@@ -1266,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 {
@@ -1303,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;
@@ -1346,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;
@@ -1377,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 .= ' ';
@@ -1388,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;
}
@@ -1463,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);
@@ -1507,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]);
@@ -1527,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');
+ }
}
@@ -1547,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
@@ -1592,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();
@@ -1604,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 {
@@ -1725,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);
@@ -1758,7 +1804,9 @@ 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();
@@ -1800,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++;
}
@@ -1830,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++;
@@ -1865,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;
@@ -1915,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);
}
}
@@ -1964,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;
@@ -1995,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;
@@ -2024,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 ' | ';
- if ($withdolfichehead) print dol_get_fiche_end();
+ if ($withdolfichehead) {
+ print dol_get_fiche_end();
+ }
print '';
print ' ';
@@ -761,7 +761,9 @@ class FormTicket
// Set tmp user directory
$vardir = $conf->user->dir_output."/".$user->id;
$upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path
- if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir);
+ if (is_dir($upload_dir)) {
+ dol_delete_dir_recursive($upload_dir);
+ }
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
unset($_SESSION["listofpaths".$keytoavoidconflict]);
@@ -782,23 +784,25 @@ class FormTicket
$formmail = new FormMail($this->db);
$addfileaction = 'addfile';
- if (!is_object($form)) $form = new Form($this->db);
+ if (!is_object($form)) {
+ $form = new Form($this->db);
+ }
// Load translation files required by the page
$langs->loadLangs(array('other', 'mails'));
// Clear temp files. Must be done at beginning, before call of triggers
- if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
- {
+ if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) {
$this->clear_attached_files();
}
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->param['langsmodels'];
- if (!empty($newlang))
- {
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ $newlang = $this->param['langsmodels'];
+ }
+ if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
$outputlangs->load('other');
@@ -806,11 +810,9 @@ class FormTicket
// Get message template for $this->param["models"] into c_email_templates
$arraydefaultmessage = -1;
- if ($this->param['models'] != 'none')
- {
+ if ($this->param['models'] != 'none') {
$model_id = 0;
- if (array_key_exists('models_id', $this->param))
- {
+ if (array_key_exists('models_id', $this->param)) {
$model_id = $this->param["models_id"];
}
@@ -823,20 +825,23 @@ class FormTicket
$listofmimes = array();
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
- if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
- {
- if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit']))
- {
- foreach ($this->param['fileinit'] as $file)
- {
+ if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) {
+ if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) {
+ foreach ($this->param['fileinit'] as $file) {
$this->add_attached_files($file, basename($file), dol_mimetype($file));
}
}
}
- if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
- if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
- if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
+ if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
+ $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
+ }
+ if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
+ $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
+ }
+ if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
+ $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
+ }
// Define output language
$outputlangs = $langs;
@@ -902,8 +907,7 @@ class FormTicket
print ' ';
// External users can't send message email
- if ($user->rights->ticket->write && !$user->socid)
- {
+ if ($user->rights->ticket->write && !$user->socid) {
print ' | ';
$checkbox_selected = (GETPOST('send_email') == "1" ? ' checked' : '');
print ' ';
diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php
index 8cbb7967415..9f1afab13f7 100644
--- a/htdocs/core/class/html.formwebsite.class.php
+++ b/htdocs/core/class/html.formwebsite.class.php
@@ -68,21 +68,17 @@ class FormWebsite
$sql .= " WHERE 1 = 1";
$sql .= " ORDER BY rowid";
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$out .= ' | ';
+ }
}
return 1;
}
diff --git a/htdocs/core/lib/loan.lib.php b/htdocs/core/lib/loan.lib.php
index 3a34d3e57c4..c86d0ecce13 100644
--- a/htdocs/core/lib/loan.lib.php
+++ b/htdocs/core/lib/loan.lib.php
@@ -60,7 +60,9 @@ function loan_prepare_head($object)
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id;
$head[$tab][1] = $langs->trans("Documents");
- if (($nbFiles + $nbLinks) > 0) $head[$tab][1] .= ''.($nbFiles + $nbLinks).'';
+ if (($nbFiles + $nbLinks) > 0) {
+ $head[$tab][1] .= ''.($nbFiles + $nbLinks).'';
+ }
$head[$tab][2] = 'documents';
$tab++;
@@ -68,7 +70,9 @@ function loan_prepare_head($object)
$nbNote = (empty($object->note_private) ? 0 : 1) + (empty($object->note_public) ? 0 : 1);
$head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id;
$head[$tab][1] = $langs->trans("Notes");
- if ($nbNote > 0) $head[$tab][1] .= ''.$nbNote.'';
+ if ($nbNote > 0) {
+ $head[$tab][1] .= ''.$nbNote.'';
+ }
$head[$tab][2] = 'note';
$tab++;
}
diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php
index 50330686805..93378d77390 100644
--- a/htdocs/core/lib/member.lib.php
+++ b/htdocs/core/lib/member.lib.php
@@ -43,8 +43,7 @@ function member_prepare_head(Adherent $object)
$h++;
if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_ACTIVE))
- && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin)))
- {
+ && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) {
$langs->load("ldap");
$head[$h][0] = DOL_URL_ROOT.'/adherents/ldap.php?id='.$object->id;
@@ -53,13 +52,14 @@ function member_prepare_head(Adherent $object)
$h++;
}
- if (!empty($user->rights->adherent->cotisation->lire))
- {
+ if (!empty($user->rights->adherent->cotisation->lire)) {
$nbSubscription = is_array($object->subscriptions) ?count($object->subscriptions) : 0;
$head[$h][0] = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$object->id;
$head[$h][1] = $langs->trans("Subscriptions");
$head[$h][2] = 'subscription';
- if ($nbSubscription > 0) $head[$h][1] .= ''.$nbSubscription.'';
+ if ($nbSubscription > 0) {
+ $head[$h][1] .= ''.$nbSubscription.'';
+ }
$h++;
}
@@ -70,13 +70,21 @@ function member_prepare_head(Adherent $object)
complete_head_from_modules($conf, $langs, $object, $head, $h, 'member');
$nbNote = 0;
- if (!empty($object->note)) $nbNote++;
- if (!empty($object->note_private)) $nbNote++;
- if (!empty($object->note_public)) $nbNote++;
+ if (!empty($object->note)) {
+ $nbNote++;
+ }
+ if (!empty($object->note_private)) {
+ $nbNote++;
+ }
+ if (!empty($object->note_public)) {
+ $nbNote++;
+ }
$head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Note");
$head[$h][2] = 'note';
- if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.'';
+ if ($nbNote > 0) {
+ $head[$h][1] .= ''.$nbNote.'';
+ }
$h++;
// Attachments
@@ -87,17 +95,17 @@ function member_prepare_head(Adherent $object)
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
- if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).'';
+ if (($nbFiles + $nbLinks) > 0) {
+ $head[$h][1] .= ''.($nbFiles + $nbLinks).'';
+ }
$head[$h][2] = 'document';
$h++;
// Show agenda tab
- if (!empty($conf->agenda->enabled))
- {
+ if (!empty($conf->agenda->enabled)) {
$head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
$head[$h][1] = $langs->trans("Events");
- if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
- {
+ if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$head[$h][1] .= '/';
$head[$h][1] .= $langs->trans("Agenda");
}
@@ -129,8 +137,7 @@ function member_type_prepare_head(AdherentType $object)
$h++;
// Multilangs
- if (!empty($conf->global->MAIN_MULTILANGS))
- {
+ if (!empty($conf->global->MAIN_MULTILANGS)) {
$head[$h][0] = DOL_URL_ROOT."/adherents/type_translation.php?rowid=".$object->id;
$head[$h][1] = $langs->trans("Translation");
$head[$h][2] = 'translation';
@@ -138,8 +145,7 @@ function member_type_prepare_head(AdherentType $object)
}
if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE))
- && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin)))
- {
+ && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) {
$langs->load("ldap");
$head[$h][0] = DOL_URL_ROOT.'/adherents/type_ldap.php?rowid='.$object->id;
diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php
index 484b3933e42..ce603415009 100644
--- a/htdocs/core/lib/memory.lib.php
+++ b/htdocs/core/lib/memory.lib.php
@@ -71,7 +71,9 @@ function dol_setcache($memoryid, $data, $expire = 0)
$result = 0;
if (strpos($memoryid, 'count_') === 0) { // The memoryid key start with 'count_...'
- if (empty($conf->global->MAIN_CACHE_COUNT)) return 0;
+ if (empty($conf->global->MAIN_CACHE_COUNT)) {
+ return 0;
+ }
}
if (!empty($conf->memcached->enabled) && class_exists('Memcached')) {
@@ -81,7 +83,9 @@ function dol_setcache($memoryid, $data, $expire = 0)
$dolmemcache = new Memcached();
$tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
$result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
- if (!$result) return -1;
+ if (!$result) {
+ return -1;
+ }
}
$memoryid = session_name() . '_' . $memoryid;
@@ -100,7 +104,9 @@ function dol_setcache($memoryid, $data, $expire = 0)
$dolmemcache = new Memcache();
$tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
$result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
- if (!$result) return -1;
+ if (!$result) {
+ return -1;
+ }
}
$memoryid = session_name() . '_' . $memoryid;
@@ -131,7 +137,9 @@ function dol_getcache($memoryid)
global $conf;
if (strpos($memoryid, 'count_') === 0) { // The memoryid key start with 'count_...'
- if (empty($conf->global->MAIN_CACHE_COUNT)) return null;
+ if (empty($conf->global->MAIN_CACHE_COUNT)) {
+ return null;
+ }
}
// Using a memcached server
@@ -141,7 +149,9 @@ function dol_getcache($memoryid)
$m = new Memcached();
$tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
$result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
- if (!$result) return -1;
+ if (!$result) {
+ return -1;
+ }
}
$memoryid = session_name() . '_' . $memoryid;
@@ -164,7 +174,9 @@ function dol_getcache($memoryid)
$m = new Memcache();
$tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
$result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
- if (!$result) return -1;
+ if (!$result) {
+ return -1;
+ }
}
$memoryid = session_name() . '_' . $memoryid;
@@ -235,9 +247,13 @@ function dol_setshmop($memoryid, $data, $expire)
global $shmkeys, $shmoffset;
//print 'dol_setshmop memoryid='.$memoryid." \n";
- if (empty($shmkeys[$memoryid]) || !function_exists("shmop_write")) return 0;
+ if (empty($shmkeys[$memoryid]) || !function_exists("shmop_write")) {
+ return 0;
+ }
$shmkey = dol_getshmopaddress($memoryid);
- if (empty($shmkey)) return 0; // No key reserved for this memoryid, we can't cache this memoryid
+ if (empty($shmkey)) {
+ return 0; // No key reserved for this memoryid, we can't cache this memoryid
+ }
$newdata = serialize($data);
$size = strlen($newdata);
@@ -273,14 +289,19 @@ function dol_getshmop($memoryid)
return null;
}
$shmkey = dol_getshmopaddress($memoryid);
- if (empty($shmkey)) return null; // No key reserved for this memoryid, we can't cache this memoryid
+ if (empty($shmkey)) {
+ return null; // No key reserved for this memoryid, we can't cache this memoryid
+ }
//print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey." \n";
$handle = @shmop_open($shmkey, 'a', 0, 0);
if ($handle) {
$size = trim(shmop_read($handle, 0, 6));
- if ($size) $data = unserialize(shmop_read($handle, 6, $size));
- else return -1;
+ if ($size) {
+ $data = unserialize(shmop_read($handle, 6, $size));
+ } else {
+ return -1;
+ }
shmop_close($handle);
} else {
return null; // Can't open existing block, so we suppose it was not created, so nothing were cached yet for the memoryid
diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php
index ff14ec56e18..0c6029ebb00 100644
--- a/htdocs/core/lib/modulebuilder.lib.php
+++ b/htdocs/core/lib/modulebuilder.lib.php
@@ -41,31 +41,30 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
{
global $db, $langs;
- if (empty($objectname)) return -1;
- if (empty($readdir)) $readdir = $destdir;
+ if (empty($objectname)) {
+ return -1;
+ }
+ if (empty($readdir)) {
+ $readdir = $destdir;
+ }
- if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval']))
- {
+ if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) {
dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.');
return -1;
}
// Check parameters
- if (count($addfieldentry) > 0)
- {
- if (empty($addfieldentry['name']))
- {
+ if (count($addfieldentry) > 0) {
+ if (empty($addfieldentry['name'])) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Name")), null, 'errors');
return -2;
}
- if (empty($addfieldentry['label']))
- {
+ if (empty($addfieldentry['label'])) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
return -2;
}
if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration)/', $addfieldentry['type'])
- && !preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type']))
- {
+ && !preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type'])) {
setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors');
return -2;
}
@@ -73,8 +72,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
$pathoffiletoeditsrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
$pathoffiletoedittarget = $destdir.'/class/'.strtolower($objectname).'.class.php'.($readdir != $destdir ? '.new' : '');
- if (!dol_is_file($pathoffiletoeditsrc))
- {
+ if (!dol_is_file($pathoffiletoeditsrc)) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
return -3;
@@ -85,8 +83,11 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
try {
include_once $pathoffiletoeditsrc;
- if (class_exists($objectname)) $object = new $objectname($db);
- else return -4;
+ if (class_exists($objectname)) {
+ $object = new $objectname($db);
+ } else {
+ return -4;
+ }
// Backup old file
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
@@ -95,17 +96,14 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
$contentclass = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
// Update ->fields (add or remove entries)
- if (count($object->fields))
- {
- if (is_array($addfieldentry) && count($addfieldentry))
- {
+ if (count($object->fields)) {
+ if (is_array($addfieldentry) && count($addfieldentry)) {
$name = $addfieldentry['name'];
unset($addfieldentry['name']);
$object->fields[$name] = $addfieldentry;
}
- if (!empty($delfieldentry))
- {
+ if (!empty($delfieldentry)) {
$name = $delfieldentry;
unset($object->fields[$name]);
}
@@ -120,40 +118,62 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
$texttoinsert .= "\t".' */'."\n";
$texttoinsert .= "\t".'public $fields=array('."\n";
- if (count($object->fields))
- {
- foreach ($object->fields as $key => $val)
- {
+ if (count($object->fields)) {
+ foreach ($object->fields as $key => $val) {
$i++;
$texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',";
$texttoinsert .= " 'enabled'=>'".($val['enabled'] !== '' ? $val['enabled'] : 1)."',";
$texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).",";
$texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).",";
$texttoinsert .= " 'visible'=>".($val['visible'] !== '' ? $val['visible'] : -1).",";
- if ($val['noteditable']) $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',";
- if ($val['default'] || $val['default'] === '0') $texttoinsert .= " 'default'=>'".$val['default']."',";
- if ($val['index']) $texttoinsert .= " 'index'=>".$val['index'].",";
- if ($val['foreignkey']) $texttoinsert .= " 'foreignkey'=>'".$val['foreignkey']."',";
- if ($val['searchall']) $texttoinsert .= " 'searchall'=>".$val['searchall'].",";
- if ($val['isameasure']) $texttoinsert .= " 'isameasure'=>'".$val['isameasure']."',";
- if ($val['css']) $texttoinsert .= " 'css'=>'".$val['css']."',";
- if ($val['help']) $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\",";
- if ($val['showoncombobox']) $texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',";
- if ($val['disabled']) $texttoinsert .= " 'disabled'=>'".$val['disabled']."',";
- if ($val['autofocusoncreate']) $texttoinsert .= " 'autofocusoncreate'=>'".$val['autofocusoncreate']."',";
- if ($val['arrayofkeyval'])
- {
+ if ($val['noteditable']) {
+ $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',";
+ }
+ if ($val['default'] || $val['default'] === '0') {
+ $texttoinsert .= " 'default'=>'".$val['default']."',";
+ }
+ if ($val['index']) {
+ $texttoinsert .= " 'index'=>".$val['index'].",";
+ }
+ if ($val['foreignkey']) {
+ $texttoinsert .= " 'foreignkey'=>'".$val['foreignkey']."',";
+ }
+ if ($val['searchall']) {
+ $texttoinsert .= " 'searchall'=>".$val['searchall'].",";
+ }
+ if ($val['isameasure']) {
+ $texttoinsert .= " 'isameasure'=>'".$val['isameasure']."',";
+ }
+ if ($val['css']) {
+ $texttoinsert .= " 'css'=>'".$val['css']."',";
+ }
+ if ($val['help']) {
+ $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\",";
+ }
+ if ($val['showoncombobox']) {
+ $texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',";
+ }
+ if ($val['disabled']) {
+ $texttoinsert .= " 'disabled'=>'".$val['disabled']."',";
+ }
+ if ($val['autofocusoncreate']) {
+ $texttoinsert .= " 'autofocusoncreate'=>'".$val['autofocusoncreate']."',";
+ }
+ if ($val['arrayofkeyval']) {
$texttoinsert .= " 'arrayofkeyval'=>array(";
$i = 0;
- foreach ($val['arrayofkeyval'] as $key2 => $val2)
- {
- if ($i) $texttoinsert .= ", ";
+ foreach ($val['arrayofkeyval'] as $key2 => $val2) {
+ if ($i) {
+ $texttoinsert .= ", ";
+ }
$texttoinsert .= "'".$key2."'=>'".$val2."'";
$i++;
}
$texttoinsert .= "),";
}
- if ($val['comment']) $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\"";
+ if ($val['comment']) {
+ $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\"";
+ }
$texttoinsert .= "),\n";
}
@@ -162,12 +182,10 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
$texttoinsert .= "\t".');'."\n";
//print ($texttoinsert);exit;
- if (count($object->fields))
- {
+ if (count($object->fields)) {
//$typetotypephp=array('integer'=>'integer', 'duration'=>'integer', 'varchar'=>'string');
- foreach ($object->fields as $key => $val)
- {
+ foreach ($object->fields as $key => $val) {
$i++;
//$typephp=$typetotypephp[$val['type']];
$texttoinsert .= "\t".'public $'.$key.";";
@@ -192,8 +210,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
@chmod($pathoffiletoedittarget, octdec($newmask));
return $object;
- } catch (Exception $e)
- {
+ } catch (Exception $e) {
print $e->getMessage();
return -5;
}
@@ -218,8 +235,12 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
$error = 0;
- if (empty($objectname)) return -1;
- if (empty($readdir)) $readdir = $destdir;
+ if (empty($objectname)) {
+ return -1;
+ }
+ if (empty($readdir)) {
+ $readdir = $destdir;
+ }
$pathoffiletoclasssrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
@@ -232,8 +253,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : '');
}
- if (!dol_is_file($pathoffiletoeditsrc))
- {
+ if (!dol_is_file($pathoffiletoeditsrc)) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
return -1;
@@ -241,14 +261,15 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
// Load object from myobject.class.php
try {
- if (!is_object($object))
- {
+ if (!is_object($object)) {
include_once $pathoffiletoclasssrc;
- if (class_exists($objectname)) $object = new $objectname($db);
- else return -1;
+ if (class_exists($objectname)) {
+ $object = new $objectname($db);
+ } else {
+ return -1;
+ }
}
- } catch (Exception $e)
- {
+ } catch (Exception $e) {
print $e->getMessage();
}
@@ -259,31 +280,41 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
$i = 0;
$texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n";
- if (count($object->fields))
- {
- foreach ($object->fields as $key => $val)
- {
+ if (count($object->fields)) {
+ foreach ($object->fields as $key => $val) {
$i++;
$type = $val['type'];
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
- if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database
- elseif ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
- elseif (in_array($type, array('link', 'sellist', 'duration'))) $type = 'integer';
+ if ($type == 'html') {
+ $type = 'text'; // html modulebuilder type is a text type in database
+ } elseif ($type == 'price') {
+ $type = 'double'; // html modulebuilder type is a text type in database
+ } elseif (in_array($type, array('link', 'sellist', 'duration'))) {
+ $type = 'integer';
+ }
$texttoinsert .= "\t".$key." ".$type;
- if ($key == 'rowid') $texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY';
- if ($key == 'entity') $texttoinsert .= ' DEFAULT 1';
- else {
- if ($val['default'] != '')
- {
- if (preg_match('/^null$/i', $val['default'])) $texttoinsert .= " DEFAULT NULL";
- elseif (preg_match('/varchar/', $type)) $texttoinsert .= " DEFAULT '".$db->escape($val['default'])."'";
- else $texttoinsert .= (($val['default'] > 0) ? ' DEFAULT '.$val['default'] : '');
+ if ($key == 'rowid') {
+ $texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY';
+ }
+ if ($key == 'entity') {
+ $texttoinsert .= ' DEFAULT 1';
+ } else {
+ if ($val['default'] != '') {
+ if (preg_match('/^null$/i', $val['default'])) {
+ $texttoinsert .= " DEFAULT NULL";
+ } elseif (preg_match('/varchar/', $type)) {
+ $texttoinsert .= " DEFAULT '".$db->escape($val['default'])."'";
+ } else {
+ $texttoinsert .= (($val['default'] > 0) ? ' DEFAULT '.$val['default'] : '');
+ }
}
}
$texttoinsert .= (($val['notnull'] > 0) ? ' NOT NULL' : '');
- if ($i < count($object->fields)) $texttoinsert .= ", ";
+ if ($i < count($object->fields)) {
+ $texttoinsert .= ", ";
+ }
$texttoinsert .= "\n";
}
}
@@ -292,8 +323,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql);
$result = file_put_contents($pathoffiletoedittarget, $contentsql);
- if ($result)
- {
+ if ($result) {
@chmod($pathoffiletoedittarget, octdec($newmask));
} else {
$error++;
@@ -312,21 +342,16 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
$i = 0;
$texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n";
- if (count($object->fields))
- {
- foreach ($object->fields as $key => $val)
- {
+ if (count($object->fields)) {
+ foreach ($object->fields as $key => $val) {
$i++;
- if (!empty($val['index']))
- {
+ if (!empty($val['index'])) {
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");";
$texttoinsert .= "\n";
}
- if (!empty($val['foreignkey']))
- {
+ if (!empty($val['foreignkey'])) {
$tmp = explode('.', $val['foreignkey']);
- if (!empty($tmp[0]) && !empty($tmp[1]))
- {
+ if (!empty($tmp[0]) && !empty($tmp[1])) {
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES llx_".preg_replace('/^llx_/', '', $tmp[0])."(".$tmp[1].");";
$texttoinsert .= "\n";
}
@@ -340,8 +365,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
dol_mkdir(dirname($pathoffiletoedittarget));
$result2 = file_put_contents($pathoffiletoedittarget, $contentsql);
- if ($result)
- {
+ if ($result) {
@chmod($pathoffiletoedittarget, octdec($newmask));
} else {
$error++;
diff --git a/htdocs/core/lib/multicurrency.lib.php b/htdocs/core/lib/multicurrency.lib.php
index a3f7d56ec90..e77a9ee8081 100644
--- a/htdocs/core/lib/multicurrency.lib.php
+++ b/htdocs/core/lib/multicurrency.lib.php
@@ -65,8 +65,7 @@ function multicurrencyLimitPrepareHead($aCurrencies)
$i = 0;
$head = array();
- foreach ($aCurrencies as $currency)
- {
+ foreach ($aCurrencies as $currency) {
$head[$i][0] = $_SERVER['PHP_SELF'].'?currencycode='.$currency;
$head[$i][1] = $langs->trans("Currency".$currency).' ('.$langs->getCurrencySymbol($currency).')';
$head[$i][2] = $currency;
diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php
index a006aad8964..48356868143 100644
--- a/htdocs/core/lib/oauth.lib.php
+++ b/htdocs/core/lib/oauth.lib.php
@@ -27,8 +27,7 @@
$supportedoauth2array = array(
'OAUTH_GOOGLE_NAME'=>'google',
);
-if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
-{
+if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
$supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = 'stripetest';
$supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = 'stripelive';
}
diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php
index 9bd92a2c79b..9e7d4f8d55a 100644
--- a/htdocs/core/lib/order.lib.php
+++ b/htdocs/core/lib/order.lib.php
@@ -34,43 +34,58 @@
function commande_prepare_head(Commande $object)
{
global $db, $langs, $conf, $user;
- if (!empty($conf->expedition->enabled)) $langs->load("sendings");
+ if (!empty($conf->expedition->enabled)) {
+ $langs->load("sendings");
+ }
$langs->load("orders");
$h = 0;
$head = array();
- if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
- {
+ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
$head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("CustomerOrder");
$head[$h][2] = 'order';
$h++;
}
- if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
- {
+ if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
- if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.'';
+ if ($nbContact > 0) {
+ $head[$h][1] .= ''.$nbContact.'';
+ }
$head[$h][2] = 'contact';
$h++;
}
if (($conf->expedition_bon->enabled && $user->rights->expedition->lire)
- || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->lire))
- {
+ || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->lire)) {
$nbShipments = $object->getNbOfShipments(); $nbReceiption = 0;
$head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id;
$text = '';
- if ($conf->expedition_bon->enabled) $text .= $langs->trans("Shipments");
- if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled) $text .= ' - ';
- if ($conf->delivery_note->enabled) $text .= $langs->trans("Receivings");
- if ($nbShipments > 0 || $nbReceiption > 0) $text .= ''.($nbShipments ? $nbShipments : 0);
- if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text .= ' - ';
- if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text .= ($nbReceiption ? $nbReceiption : 0);
- if ($nbShipments > 0 || $nbReceiption > 0) $text .= '';
+ if ($conf->expedition_bon->enabled) {
+ $text .= $langs->trans("Shipments");
+ }
+ if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled) {
+ $text .= ' - ';
+ }
+ if ($conf->delivery_note->enabled) {
+ $text .= $langs->trans("Receivings");
+ }
+ if ($nbShipments > 0 || $nbReceiption > 0) {
+ $text .= ''.($nbShipments ? $nbShipments : 0);
+ }
+ if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) {
+ $text .= ' - ';
+ }
+ if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) {
+ $text .= ($nbReceiption ? $nbReceiption : 0);
+ }
+ if ($nbShipments > 0 || $nbReceiption > 0) {
+ $text .= '';
+ }
$head[$h][1] = $text;
$head[$h][2] = 'shipping';
$h++;
@@ -82,14 +97,19 @@ function commande_prepare_head(Commande $object)
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'order');
- if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
- {
+ if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
$nbNote = 0;
- if (!empty($object->note_private)) $nbNote++;
- if (!empty($object->note_public)) $nbNote++;
+ if (!empty($object->note_private)) {
+ $nbNote++;
+ }
+ if (!empty($object->note_public)) {
+ $nbNote++;
+ }
$head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
- if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.'';
+ if ($nbNote > 0) {
+ $head[$h][1] .= ''.$nbNote.'';
+ }
$head[$h][2] = 'note';
$h++;
}
@@ -101,7 +121,9 @@ function commande_prepare_head(Commande $object)
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
- if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).'';
+ if (($nbFiles + $nbLinks) > 0) {
+ $head[$h][1] .= ''.($nbFiles + $nbLinks).'';
+ }
$head[$h][2] = 'documents';
$h++;
diff --git a/htdocs/core/lib/parsemd.lib.php b/htdocs/core/lib/parsemd.lib.php
index ef0de8c1298..72903dd9e76 100644
--- a/htdocs/core/lib/parsemd.lib.php
+++ b/htdocs/core/lib/parsemd.lib.php
@@ -31,17 +31,14 @@
*/
function dolMd2Html($content, $parser = 'parsedown', $replaceimagepath = null)
{
- if (is_array($replaceimagepath))
- {
- foreach ($replaceimagepath as $key => $val)
- {
+ if (is_array($replaceimagepath)) {
+ foreach ($replaceimagepath as $key => $val) {
$keytoreplace = ']('.$key;
$valafter = ']('.$val;
$content = preg_replace('/'.preg_quote($keytoreplace, '/').'/m', $valafter, $content);
}
}
- if ($parser == 'parsedown')
- {
+ if ($parser == 'parsedown') {
include_once DOL_DOCUMENT_ROOT.'/includes/parsedown/Parsedown.php';
$Parsedown = new Parsedown();
$content = $Parsedown->text($content);
@@ -63,10 +60,8 @@ function dolMd2Html($content, $parser = 'parsedown', $replaceimagepath = null)
*/
function dolMd2Asciidoc($content, $parser = 'dolibarr', $replaceimagepath = null)
{
- if (is_array($replaceimagepath))
- {
- foreach ($replaceimagepath as $key => $val)
- {
+ if (is_array($replaceimagepath)) {
+ foreach ($replaceimagepath as $key => $val) {
$keytoreplace = ']('.$key;
$valafter = ']('.$val;
$content = preg_replace('/'.preg_quote($keytoreplace, '/').'/m', $valafter, $content);
diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php
index 601dad3275d..835986f5f83 100644
--- a/htdocs/core/lib/payments.lib.php
+++ b/htdocs/core/lib/payments.lib.php
@@ -137,18 +137,15 @@ function getValidOnlinePaymentMethods($paymentmethod = '')
$validpaymentmethod = array();
- if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled))
- {
+ if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled)) {
$langs->load("paypal");
$validpaymentmethod['paypal'] = 'valid';
}
- if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled))
- {
+ if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled)) {
$langs->load("paybox");
$validpaymentmethod['paybox'] = 'valid';
}
- if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled))
- {
+ if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled)) {
$langs->load("stripe");
$validpaymentmethod['stripe'] = 'valid';
}
@@ -205,102 +202,142 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$urltouse = DOL_MAIN_URL_ROOT;
- if ($localorexternal) $urltouse = $urlwithroot;
+ if ($localorexternal) {
+ $urltouse = $urlwithroot;
+ }
- if ($type == 'free')
- {
+ if ($type == 'free') {
$out = $urltouse.'/public/payment/newpayment.php?amount='.($mode ? '' : '').$amount.($mode ? '' : '').'&tag='.($mode ? '' : '').$freetag.($mode ? '' : '');
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN))
- {
- if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
- else $out .= '&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
+ if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
+ $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
+ } else {
+ $out .= '&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
+ }
}
//if ($mode) $out.='&noidempotency=1';
- } elseif ($type == 'order')
- {
+ } elseif ($type == 'order') {
$out = $urltouse.'/public/payment/newpayment.php?source=order&ref='.($mode ? '' : '');
- if ($mode == 1) $out .= 'order_ref';
- if ($mode == 0) $out .= urlencode($ref);
+ if ($mode == 1) {
+ $out .= 'order_ref';
+ }
+ if ($mode == 0) {
+ $out .= urlencode($ref);
+ }
$out .= ($mode ? '' : '');
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN))
- {
- if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
- else {
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
+ if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
+ $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
+ } else {
$out .= '&securekey='.($mode ? '' : '');
- if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)";
- if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
+ if ($mode == 1) {
+ $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)";
+ }
+ if ($mode == 0) {
+ $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
+ }
$out .= ($mode ? '' : '');
}
}
- } elseif ($type == 'invoice')
- {
+ } elseif ($type == 'invoice') {
$out = $urltouse.'/public/payment/newpayment.php?source=invoice&ref='.($mode ? '' : '');
- if ($mode == 1) $out .= 'invoice_ref';
- if ($mode == 0) $out .= urlencode($ref);
+ if ($mode == 1) {
+ $out .= 'invoice_ref';
+ }
+ if ($mode == 0) {
+ $out .= urlencode($ref);
+ }
$out .= ($mode ? '' : '');
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN))
- {
- if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
- else {
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
+ if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
+ $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
+ } else {
$out .= '&securekey='.($mode ? '' : '');
- if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)";
- if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
+ if ($mode == 1) {
+ $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)";
+ }
+ if ($mode == 0) {
+ $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
+ }
$out .= ($mode ? '' : '');
}
}
- } elseif ($type == 'contractline')
- {
+ } elseif ($type == 'contractline') {
$out = $urltouse.'/public/payment/newpayment.php?source=contractline&ref='.($mode ? '' : '');
- if ($mode == 1) $out .= 'contractline_ref';
- if ($mode == 0) $out .= urlencode($ref);
+ if ($mode == 1) {
+ $out .= 'contractline_ref';
+ }
+ if ($mode == 0) {
+ $out .= urlencode($ref);
+ }
$out .= ($mode ? '' : '');
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN))
- {
- if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
- else {
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
+ if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
+ $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
+ } else {
$out .= '&securekey='.($mode ? '' : '');
- if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)";
- if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
+ if ($mode == 1) {
+ $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)";
+ }
+ if ($mode == 0) {
+ $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
+ }
$out .= ($mode ? '' : '');
}
}
- } elseif ($type == 'member' || $type == 'membersubscription')
- {
+ } elseif ($type == 'member' || $type == 'membersubscription') {
$out = $urltouse.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode ? '' : '');
- if ($mode == 1) $out .= 'member_ref';
- if ($mode == 0) $out .= urlencode($ref);
+ if ($mode == 1) {
+ $out .= 'member_ref';
+ }
+ if ($mode == 0) {
+ $out .= urlencode($ref);
+ }
$out .= ($mode ? '' : '');
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN))
- {
- if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
- else {
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
+ if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
+ $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
+ } else {
$out .= '&securekey='.($mode ? '' : '');
- if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)";
- if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
+ if ($mode == 1) {
+ $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)";
+ }
+ if ($mode == 0) {
+ $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
+ }
$out .= ($mode ? '' : '');
}
}
}
- if ($type == 'donation')
- {
+ if ($type == 'donation') {
$out = $urltouse.'/public/payment/newpayment.php?source=donation&ref='.($mode ? '' : '');
- if ($mode == 1) $out .= 'donation_ref';
- if ($mode == 0) $out .= urlencode($ref);
+ if ($mode == 1) {
+ $out .= 'donation_ref';
+ }
+ if ($mode == 0) {
+ $out .= urlencode($ref);
+ }
$out .= ($mode ? '' : '');
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN))
- {
- if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
- else {
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
+ if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
+ $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
+ } else {
$out .= '&securekey='.($mode ? '' : '');
- if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + donation_ref)";
- if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
+ if ($mode == 1) {
+ $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + donation_ref)";
+ }
+ if ($mode == 0) {
+ $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
+ }
$out .= ($mode ? '' : '');
}
}
}
// For multicompany
- if (!empty($out) && !empty($conf->multicompany->enabled)) $out .= "&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities
+ if (!empty($out) && !empty($conf->multicompany->enabled)) {
+ $out .= "&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities
+ }
return $out;
}
@@ -323,78 +360,86 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0,
// Juridical status
$line1 = "";
- if ($fromcompany->forme_juridique_code)
- {
+ if ($fromcompany->forme_juridique_code) {
$line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code);
}
// Capital
- if ($fromcompany->capital)
- {
+ if ($fromcompany->capital) {
$line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency);
}
// Prof Id 1
- if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2))
- {
+ if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) {
$field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code);
- if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field = $reg[1];
+ }
$line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1;
}
// Prof Id 2
- if ($fromcompany->idprof2)
- {
+ if ($fromcompany->idprof2) {
$field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code);
- if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field = $reg[1];
+ }
$line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2;
}
// Second line of company infos
$line2 = "";
// Prof Id 3
- if ($fromcompany->idprof3)
- {
+ if ($fromcompany->idprof3) {
$field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code);
- if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field = $reg[1];
+ }
$line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3;
}
// Prof Id 4
- if ($fromcompany->idprof4)
- {
+ if ($fromcompany->idprof4) {
$field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code);
- if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field = $reg[1];
+ }
$line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4;
}
// IntraCommunautary VAT
- if ($fromcompany->tva_intra != '')
- {
+ if ($fromcompany->tva_intra != '') {
$line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra;
}
print ' ';
print ''."\n";
- if ($addformmessage)
- {
+ if ($addformmessage) {
print '';
print ' ';
$parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix;
- if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform);
- elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM);
+ if (!empty($conf->global->$parammessageform)) {
+ print $langs->transnoentities($conf->global->$parammessageform);
+ } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) {
+ print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM);
+ }
// Add other message if VAT exists
- if ($object->total_vat != 0 || $object->total_tva != 0)
- {
+ if ($object->total_vat != 0 || $object->total_tva != 0) {
$parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix;
- if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform);
- elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT);
+ if (!empty($conf->global->$parammessageform)) {
+ print $langs->transnoentities($conf->global->$parammessageform);
+ } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) {
+ print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT);
+ }
}
}
print '
'."\n";
print $fromcompany->name.' ';
print $line1;
- if (strlen($line1.$line2) > 50) print ' ';
- else print ' - ';
+ if (strlen($line1.$line2) > 50) {
+ print ' ';
+ } else {
+ print ' - ';
+ }
print $line2;
print ' '."\n";
}
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 613a68b56d8..08559c3ebd6 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -51,8 +51,7 @@ function pdf_getFormat(Translate $outputlangs = null, $mode = 'setup')
// Default value if setup was not done and/or entry into c_paper_format not defined
$width = 210; $height = 297; $unit = 'mm';
- if ($mode == 'auto' || empty($conf->global->MAIN_PDF_FORMAT) || $conf->global->MAIN_PDF_FORMAT == 'auto')
- {
+ if ($mode == 'auto' || empty($conf->global->MAIN_PDF_FORMAT) || $conf->global->MAIN_PDF_FORMAT == 'auto') {
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$pdfformat = dol_getDefaultFormat($outputlangs);
} else {
@@ -62,11 +61,9 @@ function pdf_getFormat(Translate $outputlangs = null, $mode = 'setup')
$sql = "SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format";
$sql .= " WHERE code = '".$db->escape($pdfformat)."'";
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $db->fetch_object($resql);
- if ($obj)
- {
+ if ($obj) {
$width = (int) $obj->width;
$height = (int) $obj->height;
$unit = $obj->unit;
@@ -90,8 +87,7 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P')
global $conf;
// Define constant for TCPDF
- if (!defined('K_TCPDF_EXTERNAL_CONFIG'))
- {
+ if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {
define('K_TCPDF_EXTERNAL_CONFIG', 1); // this avoid using tcpdf_config file
define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/');
define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/');
@@ -133,21 +129,27 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P')
require_once TCPDF_PATH.'tcpdf.php';
// We need to instantiate tcpdi object (instead of tcpdf) to use merging features. But we can disable it (this will break all merge features).
- if (empty($conf->global->MAIN_DISABLE_TCPDI)) require_once TCPDI_PATH.'tcpdi.php';
+ if (empty($conf->global->MAIN_DISABLE_TCPDI)) {
+ require_once TCPDI_PATH.'tcpdi.php';
+ }
//$arrayformat=pdf_getFormat();
//$format=array($arrayformat['width'],$arrayformat['height']);
//$metric=$arrayformat['unit'];
$pdfa = false; // PDF-1.3
- if (!empty($conf->global->PDF_USE_1A)) $pdfa = true; // PDF1/A
+ if (!empty($conf->global->PDF_USE_1A)) {
+ $pdfa = true; // PDF1/A
+ }
- if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa);
- else $pdf = new TCPDF($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa);
+ if (class_exists('TCPDI')) {
+ $pdf = new TCPDI($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa);
+ } else {
+ $pdf = new TCPDF($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa);
+ }
// Protection and encryption of pdf
- if (!empty($conf->global->PDF_SECURITY_ENCRYPTION))
- {
+ if (!empty($conf->global->PDF_SECURITY_ENCRYPTION)) {
/* Permission supported by TCPDF
- print : Print the document;
- modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';
@@ -223,13 +225,13 @@ function pdf_getPDFFont($outputlangs)
{
global $conf;
- if (!empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT;
+ if (!empty($conf->global->MAIN_PDF_FORCE_FONT)) {
+ return $conf->global->MAIN_PDF_FORCE_FONT;
+ }
$font = 'Helvetica'; // By default, for FPDI, or ISO language on TCPDF
- if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower)
- {
- if ($outputlangs->trans('FONTFORPDF') != 'FONTFORPDF')
- {
+ if (class_exists('TCPDF')) { // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower)
+ if ($outputlangs->trans('FONTFORPDF') != 'FONTFORPDF') {
$font = $outputlangs->trans('FONTFORPDF');
}
}
@@ -247,14 +249,14 @@ function pdf_getPDFFontSize($outputlangs)
global $conf;
$size = 10; // By default, for FPDI or ISO language on TCPDF
- if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 font like DejaVuSans if required (slower)
- {
- if ($outputlangs->trans('FONTSIZEFORPDF') != 'FONTSIZEFORPDF')
- {
+ if (class_exists('TCPDF')) { // If TCPDF on, we can use an UTF8 font like DejaVuSans if required (slower)
+ if ($outputlangs->trans('FONTSIZEFORPDF') != 'FONTSIZEFORPDF') {
$size = (int) $outputlangs->trans('FONTSIZEFORPDF');
}
}
- if (!empty($conf->global->MAIN_PDF_FORCE_FONT_SIZE)) $size = $conf->global->MAIN_PDF_FORCE_FONT_SIZE;
+ if (!empty($conf->global->MAIN_PDF_FORCE_FONT_SIZE)) {
+ $size = $conf->global->MAIN_PDF_FORCE_FONT_SIZE;
+ }
return $size;
}
@@ -274,10 +276,11 @@ function pdf_getHeightForLogo($logo, $url = false)
$maxwidth = 130;
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
$tmp = dol_getImageSize($logo, $url);
- if ($tmp['height'])
- {
+ if ($tmp['height']) {
$width = round($height * $tmp['width'] / $tmp['height']);
- if ($width > $maxwidth) $height = $height * $maxwidth / $width;
+ if ($width > $maxwidth) {
+ $height = $height * $maxwidth / $width;
+ }
}
//print $tmp['width'].' '.$tmp['height'].' '.$width; exit;
return $height;
@@ -377,82 +380,103 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t
{
global $conf, $hookmanager;
- if ($mode == 'source' && !is_object($sourcecompany)) return -1;
- if ($mode == 'target' && !is_object($targetcompany)) return -1;
+ if ($mode == 'source' && !is_object($sourcecompany)) {
+ return -1;
+ }
+ if ($mode == 'target' && !is_object($targetcompany)) {
+ return -1;
+ }
- if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state = getState($sourcecompany->state_id);
- if (!empty($targetcompany->state_id) && empty($targetcompany->state)) $targetcompany->state = getState($targetcompany->state_id);
+ if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) {
+ $sourcecompany->state = getState($sourcecompany->state_id);
+ }
+ if (!empty($targetcompany->state_id) && empty($targetcompany->state)) {
+ $targetcompany->state = getState($targetcompany->state_id);
+ }
$reshook = 0;
$stringaddress = '';
- if (is_object($hookmanager))
- {
+ if (is_object($hookmanager)) {
$parameters = array('sourcecompany' => &$sourcecompany, 'targetcompany' => &$targetcompany, 'targetcontact' => &$targetcontact, 'outputlangs' => $outputlangs, 'mode' => $mode, 'usecontact' => $usecontact);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_build_address', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$stringaddress .= $hookmanager->resPrint;
}
- if (empty($reshook))
- {
- if ($mode == 'source')
- {
+ if (empty($reshook)) {
+ if ($mode == 'source') {
$withCountry = 0;
- if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1;
+ if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
+ $withCountry = 1;
+ }
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n";
- if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS))
- {
+ if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) {
// Phone
- if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
+ if ($sourcecompany->phone) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
+ }
// Fax
- if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
+ if ($sourcecompany->fax) {
+ $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
+ }
// EMail
- if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email);
+ if ($sourcecompany->email) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email);
+ }
// Web
- if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url);
+ if ($sourcecompany->url) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url);
+ }
}
// Intra VAT
- if (!empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS))
- {
- if ($sourcecompany->tva_intra) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra);
+ if (!empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS)) {
+ if ($sourcecompany->tva_intra) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra);
+ }
}
// Professionnal Ids
$reg = array();
- if (!empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof1))
- {
+ if (!empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof1)) {
$tmp = $outputlangs->transcountrynoentities("ProfId1", $sourcecompany->country_code);
- if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp = $reg[1];
+ }
$stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1);
}
- if (!empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof2))
- {
+ if (!empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof2)) {
$tmp = $outputlangs->transcountrynoentities("ProfId2", $sourcecompany->country_code);
- if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp = $reg[1];
+ }
$stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2);
}
- if (!empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof3))
- {
+ if (!empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof3)) {
$tmp = $outputlangs->transcountrynoentities("ProfId3", $sourcecompany->country_code);
- if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp = $reg[1];
+ }
$stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3);
}
- if (!empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof4))
- {
+ if (!empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof4)) {
$tmp = $outputlangs->transcountrynoentities("ProfId4", $sourcecompany->country_code);
- if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp = $reg[1];
+ }
$stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4);
}
- if (!empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof5))
- {
+ if (!empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof5)) {
$tmp = $outputlangs->transcountrynoentities("ProfId5", $sourcecompany->country_code);
- if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp = $reg[1];
+ }
$stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5);
}
- if (!empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof6))
- {
+ if (!empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof6)) {
$tmp = $outputlangs->transcountrynoentities("ProfId6", $sourcecompany->country_code);
- if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp = $reg[1];
+ }
$stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6);
}
if (!empty($conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS)) {
@@ -460,10 +484,8 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t
}
}
- if ($mode == 'target' || preg_match('/targetwithdetails/', $mode))
- {
- if ($usecontact)
- {
+ if ($mode == 'target' || preg_match('/targetwithdetails/', $mode)) {
+ if ($usecontact) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
if (!empty($targetcontact->address)) {
@@ -472,8 +494,7 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t
$companytouseforaddress = $targetcompany;
// Contact on a thirdparty that is a different thirdparty than the thirdparty of object
- if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id)
- {
+ if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) {
$targetcontact->fetch_thirdparty();
$companytouseforaddress = $targetcontact->thirdparty;
}
@@ -487,118 +508,142 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code));
}
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode))
- {
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) {
// Phone
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode))
- {
- if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
- if (!empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
- if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) $stringaddress .= " / ";
- if (!empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) {
+ if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
+ }
+ if (!empty($targetcontact->phone_pro)) {
+ $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
+ }
+ if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) {
+ $stringaddress .= " / ";
+ }
+ if (!empty($targetcontact->phone_mobile)) {
+ $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
+ }
}
// Fax
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode))
- {
- if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) {
+ if ($targetcontact->fax) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
+ }
}
// EMail
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode))
- {
- if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email);
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) {
+ if ($targetcontact->email) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email);
+ }
}
// Web
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode))
- {
- if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url);
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) {
+ if ($targetcontact->url) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url);
+ }
}
}
} else {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany));
// Country
- if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code));
+ if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code));
+ }
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode))
- {
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) {
// Phone
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode))
- {
- if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
- if (!empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
- if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) $stringaddress .= " / ";
- if (!empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) {
+ if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
+ }
+ if (!empty($targetcompany->phone)) {
+ $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
+ }
+ if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) {
+ $stringaddress .= " / ";
+ }
+ if (!empty($targetcompany->phone_mobile)) {
+ $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
+ }
}
// Fax
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode))
- {
- if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) {
+ if ($targetcompany->fax) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);
+ }
}
// EMail
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode))
- {
- if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email);
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) {
+ if ($targetcompany->email) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email);
+ }
}
// Web
- if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode))
- {
- if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url);
+ if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) {
+ if ($targetcompany->url) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url);
+ }
}
}
}
// Intra VAT
- if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS))
- {
- if ($targetcompany->tva_intra) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
+ if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) {
+ if ($targetcompany->tva_intra) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
+ }
}
// Professionnal Ids
- if (!empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && !empty($targetcompany->idprof1))
- {
+ if (!empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && !empty($targetcompany->idprof1)) {
$tmp = $outputlangs->transcountrynoentities("ProfId1", $targetcompany->country_code);
- if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp = $reg[1];
+ }
$stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1);
}
- if (!empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && !empty($targetcompany->idprof2))
- {
+ if (!empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && !empty($targetcompany->idprof2)) {
$tmp = $outputlangs->transcountrynoentities("ProfId2", $targetcompany->country_code);
- if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp = $reg[1];
+ }
$stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2);
}
- if (!empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && !empty($targetcompany->idprof3))
- {
+ if (!empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && !empty($targetcompany->idprof3)) {
$tmp = $outputlangs->transcountrynoentities("ProfId3", $targetcompany->country_code);
- if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp = $reg[1];
+ }
$stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3);
}
- if (!empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && !empty($targetcompany->idprof4))
- {
+ if (!empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && !empty($targetcompany->idprof4)) {
$tmp = $outputlangs->transcountrynoentities("ProfId4", $targetcompany->country_code);
- if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp = $reg[1];
+ }
$stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4);
}
- if (!empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && !empty($targetcompany->idprof5))
- {
+ if (!empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && !empty($targetcompany->idprof5)) {
$tmp = $outputlangs->transcountrynoentities("ProfId5", $targetcompany->country_code);
- if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp = $reg[1];
+ }
$stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5);
}
- if (!empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && !empty($targetcompany->idprof6))
- {
+ if (!empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && !empty($targetcompany->idprof6)) {
$tmp = $outputlangs->transcountrynoentities("ProfId6", $targetcompany->country_code);
- if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp = $reg[1];
+ }
$stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6);
}
// Public note
- if (!empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS))
- {
- if ($mode == 'source' && !empty($sourcecompany->note_public))
- {
+ if (!empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) {
+ if ($mode == 'source' && !empty($sourcecompany->note_public)) {
$stringaddress .= ($stringaddress ? "\n" : '').dol_string_nohtmltag($sourcecompany->note_public);
}
- if (($mode == 'target' || preg_match('/targetwithdetails/', $mode)) && !empty($targetcompany->note_public))
- {
+ if (($mode == 'target' || preg_match('/targetwithdetails/', $mode)) && !empty($targetcompany->note_public)) {
$stringaddress .= ($stringaddress ? "\n" : '').dol_string_nohtmltag($targetcompany->note_public);
}
}
@@ -622,8 +667,7 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height)
global $conf;
// Add a background image on document
- if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image
- {
+ if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) { // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image
$pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image
$pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height);
$pdf->SetAutoPageBreak(1, 0); // Restore pagebreak
@@ -665,10 +709,15 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
global $langs, $mysoc, $user;
// Print Draft Watermark
- if ($unit == 'pt') $k = 1;
- elseif ($unit == 'mm') $k = 72 / 25.4;
- elseif ($unit == 'cm') $k = 72 / 2.54;
- elseif ($unit == 'in') $k = 72;
+ if ($unit == 'pt') {
+ $k = 1;
+ } elseif ($unit == 'mm') {
+ $k = 72 / 25.4;
+ } elseif ($unit == 'cm') {
+ $k = 72 / 2.54;
+ } elseif ($unit == 'in') {
+ $k = 72;
+ }
// Make substitution
$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, null);
@@ -719,8 +768,7 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0,
$diffsizecontent = (empty($conf->global->PDF_DIFFSIZE_CONTENT) ? 4 : $conf->global->PDF_DIFFSIZE_CONTENT);
$pdf->SetXY($curx, $cury);
- if (empty($onlynumber))
- {
+ if (empty($onlynumber)) {
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0);
$cury += 4;
@@ -730,36 +778,36 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0,
// Use correct name of bank id according to country
$bickey = "BICNumber";
- if ($account->getCountryCode() == 'IN') $bickey = "SWIFT";
+ if ($account->getCountryCode() == 'IN') {
+ $bickey = "SWIFT";
+ }
// Get format of bank account according to its country
$usedetailedbban = $account->useDetailedBBAN();
//$onlynumber=0; $usedetailedbban=1; // For tests
- if ($usedetailedbban)
- {
+ if ($usedetailedbban) {
$savcurx = $curx;
- if (empty($onlynumber))
- {
+ if (empty($onlynumber)) {
$pdf->SetFont('', '', $default_font_size - $diffsizecontent);
$pdf->SetXY($curx, $cury);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': '.$outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
$cury += 3;
}
- if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) // Note that some countries still need bank number, BIC/IBAN not enougth for them
- {
+ if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) { // Note that some countries still need bank number, BIC/IBAN not enougth for them
// Note:
// bank = code_banque (FR), sort code (GB, IR. Example: 12-34-56)
// desk = code guichet (FR), used only when $usedetailedbban = 1
// number = account number
// key = check control key used only when $usedetailedbban = 1
- if (empty($onlynumber)) $pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6);
+ if (empty($onlynumber)) {
+ $pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6);
+ }
- foreach ($account->getFieldsToShow() as $val)
- {
+ foreach ($account->getFieldsToShow() as $val) {
$pdf->SetXY($curx, $cury + 4);
$pdf->SetFont('', '', $default_font_size - 3);
@@ -812,7 +860,9 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0,
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': '.$outputlangs->convToOutputCharset($account->number), 0, 'L', 0);
$cury += 3;
- if ($diffsizecontent <= 2) $cury += 1;
+ if ($diffsizecontent <= 2) {
+ $cury += 1;
+ }
}
$pdf->SetFont('', '', $default_font_size - $diffsizecontent);
@@ -840,17 +890,17 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0,
// Use correct name of bank id according to country
$ibankey = FormBank::getIBANLabel($account);
- if (!empty($account->iban))
- {
+ if (!empty($account->iban)) {
//Remove whitespaces to ensure we are dealing with the format we expect
$ibanDisplay_temp = str_replace(' ', '', $outputlangs->convToOutputCharset($account->iban));
$ibanDisplay = "";
$nbIbanDisplay_temp = dol_strlen($ibanDisplay_temp);
- for ($i = 0; $i < $nbIbanDisplay_temp; $i++)
- {
+ for ($i = 0; $i < $nbIbanDisplay_temp; $i++) {
$ibanDisplay .= $ibanDisplay_temp[$i];
- if ($i % 4 == 3 && $i > 0) $ibanDisplay .= " ";
+ if ($i % 4 == 3 && $i > 0) {
+ $ibanDisplay .= " ";
+ }
}
$pdf->SetFont('', 'B', $default_font_size - 3);
@@ -859,8 +909,7 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0,
$cury += 3;
}
- if (!empty($account->bic))
- {
+ if (!empty($account->bic)) {
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->SetXY($curx, $cury);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': '.$outputlangs->convToOutputCharset($account->bic), 0, 'L', 0);
@@ -894,8 +943,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
$dims = $pdf->getPageDimensions();
// Line of free text
- if (empty($hidefreetext) && !empty($conf->global->$paramfreetext))
- {
+ if (empty($hidefreetext) && !empty($conf->global->$paramfreetext)) {
$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
// More substitution keys
$substitutionarray['__FROM_NAME__'] = $fromcompany->name;
@@ -915,124 +963,118 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
// First line of company infos
$line1 = ""; $line2 = ""; $line3 = ""; $line4 = "";
- if ($showdetails == 1 || $showdetails == 3)
- {
+ if ($showdetails == 1 || $showdetails == 3) {
// Company name
- if ($fromcompany->name)
- {
+ if ($fromcompany->name) {
$line1 .= ($line1 ? " - " : "").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name;
}
// Address
- if ($fromcompany->address)
- {
+ if ($fromcompany->address) {
$line1 .= ($line1 ? " - " : "").str_replace("\n", ", ", $fromcompany->address);
}
// Zip code
- if ($fromcompany->zip)
- {
+ if ($fromcompany->zip) {
$line1 .= ($line1 ? " - " : "").$fromcompany->zip;
}
// Town
- if ($fromcompany->town)
- {
+ if ($fromcompany->town) {
$line1 .= ($line1 ? " " : "").$fromcompany->town;
}
// Country
- if ($fromcompany->country)
- {
+ if ($fromcompany->country) {
$line1 .= ($line1 ? ", " : "").$fromcompany->country;
}
// Phone
- if ($fromcompany->phone)
- {
+ if ($fromcompany->phone) {
$line2 .= ($line2 ? " - " : "").$outputlangs->transnoentities("Phone").": ".$fromcompany->phone;
}
// Fax
- if ($fromcompany->fax)
- {
+ if ($fromcompany->fax) {
$line2 .= ($line2 ? " - " : "").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax;
}
// URL
- if ($fromcompany->url)
- {
+ if ($fromcompany->url) {
$line2 .= ($line2 ? " - " : "").$fromcompany->url;
}
// Email
- if ($fromcompany->email)
- {
+ if ($fromcompany->email) {
$line2 .= ($line2 ? " - " : "").$fromcompany->email;
}
}
- if ($showdetails == 2 || $showdetails == 3 || ($fromcompany->country_code == 'DE'))
- {
+ if ($showdetails == 2 || $showdetails == 3 || ($fromcompany->country_code == 'DE')) {
// Managers
- if ($fromcompany->managers)
- {
+ if ($fromcompany->managers) {
$line2 .= ($line2 ? " - " : "").$fromcompany->managers;
}
}
// Line 3 of company infos
// Juridical status
- if ($fromcompany->forme_juridique_code)
- {
+ if ($fromcompany->forme_juridique_code) {
$line3 .= ($line3 ? " - " : "").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code));
}
// Capital
- if ($fromcompany->capital)
- {
+ if ($fromcompany->capital) {
$tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string
- if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency));
- else $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs);
+ if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) {
+ $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency));
+ } else {
+ $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs);
+ }
}
// Prof Id 1
- if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2))
- {
+ if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) {
$field = $outputlangs->transcountrynoentities("ProfId1", $fromcompany->country_code);
- if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field = $reg[1];
+ }
$line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1);
}
// Prof Id 2
- if ($fromcompany->idprof2)
- {
+ if ($fromcompany->idprof2) {
$field = $outputlangs->transcountrynoentities("ProfId2", $fromcompany->country_code);
- if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field = $reg[1];
+ }
$line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2);
}
// Line 4 of company infos
// Prof Id 3
- if ($fromcompany->idprof3)
- {
+ if ($fromcompany->idprof3) {
$field = $outputlangs->transcountrynoentities("ProfId3", $fromcompany->country_code);
- if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field = $reg[1];
+ }
$line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3);
}
// Prof Id 4
- if ($fromcompany->idprof4)
- {
+ if ($fromcompany->idprof4) {
$field = $outputlangs->transcountrynoentities("ProfId4", $fromcompany->country_code);
- if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field = $reg[1];
+ }
$line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4);
}
// Prof Id 5
- if ($fromcompany->idprof5)
- {
+ if ($fromcompany->idprof5) {
$field = $outputlangs->transcountrynoentities("ProfId5", $fromcompany->country_code);
- if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field = $reg[1];
+ }
$line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5);
}
// Prof Id 6
- if ($fromcompany->idprof6)
- {
+ if ($fromcompany->idprof6) {
$field = $outputlangs->transcountrynoentities("ProfId6", $fromcompany->country_code);
- if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field = $reg[1];
+ }
$line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6);
}
// IntraCommunautary VAT
- if ($fromcompany->tva_intra != '')
- {
+ if ($fromcompany->tva_intra != '') {
$line4 .= ($line4 ? " - " : "").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra);
}
@@ -1041,11 +1083,9 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
// The start of the bottom of this page footer is positioned according to # of lines
$freetextheight = 0;
- if ($line) // Free text
- {
+ if ($line) { // Free text
//$line="sample text \nfdsfsdf \nghfghg ";
- if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
- {
+ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
$width = 20000; $align = 'L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
if (!empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) {
$width = 200; $align = 'C';
@@ -1060,11 +1100,9 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
$marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0);
$posy = $marginwithfooter + 0;
- if ($line) // Free text
- {
+ if ($line) { // Free text
$pdf->SetXY($dims['lm'], -$posy);
- if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) // by default
- {
+ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { // by default
$pdf->MultiCell(0, 3, $line, 0, $align, 0);
} else {
$pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk'] - $marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0));
@@ -1076,8 +1114,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
$pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy);
$posy--;
- if (!empty($line1))
- {
+ if (!empty($line1)) {
$pdf->SetFont('', 'B', 7);
$pdf->SetXY($dims['lm'], -$posy);
$pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line1, 0, 'C', 0);
@@ -1085,8 +1122,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
$pdf->SetFont('', '', 7);
}
- if (!empty($line2))
- {
+ if (!empty($line2)) {
$pdf->SetFont('', 'B', 7);
$pdf->SetXY($dims['lm'], -$posy);
$pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line2, 0, 'C', 0);
@@ -1094,22 +1130,19 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
$pdf->SetFont('', '', 7);
}
- if (!empty($line3))
- {
+ if (!empty($line3)) {
$pdf->SetXY($dims['lm'], -$posy);
$pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line3, 0, 'C', 0);
}
- if (!empty($line4))
- {
+ if (!empty($line4)) {
$posy -= 3;
$pdf->SetXY($dims['lm'], -$posy);
$pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line4, 0, 'C', 0);
}
// Show page nb only on iso languages (so default Helvetica font)
- if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica')
- {
+ if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') {
$pdf->SetXY($dims['wk'] - $dims['rm'] - 15, -$posy);
//print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit;
$pdf->MultiCell(15, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
@@ -1135,13 +1168,10 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
function pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
{
$linkedobjects = pdf_getLinkedObjects($object, $outputlangs);
- if (!empty($linkedobjects))
- {
- foreach ($linkedobjects as $linkedobject)
- {
+ if (!empty($linkedobjects)) {
+ foreach ($linkedobjects as $linkedobject) {
$reftoshow = $linkedobject["ref_title"].' : '.$linkedobject["ref_value"];
- if (!empty($linkedobject["date_value"]))
- {
+ if (!empty($linkedobject["date_value"])) {
$reftoshow .= ' / '.$linkedobject["date_value"];
}
@@ -1178,18 +1208,20 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos
$reshook = 0;
$result = '';
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('pdf'=>$pdf, 'i'=>$i, 'outputlangs'=>$outputlangs, 'w'=>$w, 'h'=>$h, 'posx'=>$posx, 'posy'=>$posy, 'hideref'=>$hideref, 'hidedesc'=>$hidedesc, 'issupplierline'=>$issupplierline, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_writelinedesc', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
+ if (!empty($hookmanager->resPrint)) {
+ $result .= $hookmanager->resPrint;
+ }
}
- if (empty($reshook))
- {
+ if (empty($reshook)) {
$labelproductservice = pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline);
//var_dump($labelproductservice);exit;
@@ -1229,8 +1261,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
$note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : '');
$dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false);
- if ($issupplierline)
- {
+ if ($issupplierline) {
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$prodser = new ProductFournisseur($db);
} else {
@@ -1238,16 +1269,14 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
$prodser = new Product($db);
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
- include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
}
}
- if ($idprod)
- {
+ if ($idprod) {
$prodser->fetch($idprod);
// If a predefined product and multilang and on other lang, we renamed label with label translated
- if (!empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang))
- {
+ if (!empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) {
$translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it)
// TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation
@@ -1269,11 +1298,15 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
} else {
$textwasmodified = ($desc == $prodser->description);
}
- if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"];
+ if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) {
+ $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"];
+ }
// Set note
$textwasmodified = ($note == $prodser->note);
- if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note = $prodser->multilangs[$outputlangs->defaultlang]["note"];
+ if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) {
+ $note = $prodser->multilangs[$outputlangs->defaultlang]["note"];
+ }
}
} elseif ($object->element == 'facture' || $object->element == 'facturefourn') {
if ($object->type == $object::TYPE_DEPOSIT) {
@@ -1299,34 +1332,30 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
}
// Description long of product line
- if (!empty($desc) && ($desc != $label))
- {
- if ($libelleproduitservice && empty($hidedesc))
- {
+ if (!empty($desc) && ($desc != $label)) {
+ if ($libelleproduitservice && empty($hidedesc)) {
$libelleproduitservice .= '__N__';
}
- if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except)
- {
+ if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) {
$discount = new DiscountAbsolute($db);
$discount->fetch($object->lines[$i]->fk_remise_except);
$sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source;
$libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref);
- } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except)
- {
+ } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) {
$discount = new DiscountAbsolute($db);
$discount->fetch($object->lines[$i]->fk_remise_except);
$sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source;
$libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref);
// Add date of deposit
- if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice .= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')';
- } elseif ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except)
- {
+ if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
+ $libelleproduitservice .= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')';
+ }
+ } elseif ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) {
$discount = new DiscountAbsolute($db);
$discount->fetch($object->lines[$i]->fk_remise_except);
$libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source);
- } elseif ($desc == '(EXCESS PAID)' && $object->lines[$i]->fk_remise_except)
- {
+ } elseif ($desc == '(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) {
$discount = new DiscountAbsolute($db);
$discount->fetch($object->lines[$i]->fk_remise_except);
$libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source);
@@ -1371,7 +1400,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
if ($issupplierline) {
if (empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) { // Common case
$ref_prodserv = $prodser->ref; // Show local ref
- if ($ref_supplier) $ref_prodserv .= ($prodser->ref ? ' (' : '').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref ? ')' : '');
+ if ($ref_supplier) {
+ $ref_prodserv .= ($prodser->ref ? ' (' : '').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref ? ')' : '');
+ }
} elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) {
$ref_prodserv = $ref_supplier;
} elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) {
@@ -1381,69 +1412,68 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
$ref_prodserv = $prodser->ref; // Show local ref only
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
- $productCustomerPriceStatic = new Productcustomerprice($db);
- $filter = array('fk_product' => $idprod, 'fk_soc' => $object->socid);
+ $productCustomerPriceStatic = new Productcustomerprice($db);
+ $filter = array('fk_product' => $idprod, 'fk_soc' => $object->socid);
- $nbCustomerPrices = $productCustomerPriceStatic->fetch_all('', '', 1, 0, $filter);
+ $nbCustomerPrices = $productCustomerPriceStatic->fetch_all('', '', 1, 0, $filter);
- if ($nbCustomerPrices > 0) {
- $productCustomerPrice = $productCustomerPriceStatic->lines[0];
+ if ($nbCustomerPrices > 0) {
+ $productCustomerPrice = $productCustomerPriceStatic->lines[0];
- if (! empty($productCustomerPrice->ref_customer)) {
- switch ($conf->global->PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE) {
- case 1:
- $ref_prodserv = $productCustomerPrice->ref_customer;
- break;
+ if (! empty($productCustomerPrice->ref_customer)) {
+ switch ($conf->global->PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE) {
+ case 1:
+ $ref_prodserv = $productCustomerPrice->ref_customer;
+ break;
- case 2:
- $ref_prodserv = $productCustomerPrice->ref_customer . ' (' . $outputlangs->transnoentitiesnoconv('InternalRef') . ' ' . $ref_prodserv . ')';
- break;
+ case 2:
+ $ref_prodserv = $productCustomerPrice->ref_customer . ' (' . $outputlangs->transnoentitiesnoconv('InternalRef') . ' ' . $ref_prodserv . ')';
+ break;
- default:
- $ref_prodserv = $ref_prodserv . ' (' . $outputlangs->transnoentitiesnoconv('RefCustomer') . ' ' . $productCustomerPrice->ref_customer . ')';
- }
- }
- }
+ default:
+ $ref_prodserv = $ref_prodserv . ' (' . $outputlangs->transnoentitiesnoconv('RefCustomer') . ' ' . $productCustomerPrice->ref_customer . ')';
+ }
+ }
+ }
}
}
- if (!empty($libelleproduitservice) && !empty($ref_prodserv)) $ref_prodserv .= " - ";
+ if (!empty($libelleproduitservice) && !empty($ref_prodserv)) {
+ $ref_prodserv .= " - ";
+ }
}
- if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { $ref_prodserv = ''.$ref_prodserv.''; }
+ if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
+ $ref_prodserv = ''.$ref_prodserv.'';
+ }
$libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice;
// Add an additional description for the category products
- if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled))
- {
+ if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) {
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$categstatic = new Categorie($db);
// recovering the list of all the categories linked to product
$tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT);
- foreach ($tblcateg as $cate)
- {
+ foreach ($tblcateg as $cate) {
// Adding the descriptions if they are filled
$desccateg = $cate->description;
- if ($desccateg)
+ if ($desccateg) {
$libelleproduitservice .= '__N__'.$desccateg;
+ }
}
}
- if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end))
- {
+ if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end)) {
$format = 'day';
$period = '';
// Show duration if exists
- if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
- {
+ if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) {
$period = '('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs), dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')';
}
- if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end)
- {
+ if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end) {
$period = '('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')';
}
- if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end)
- {
+ if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end) {
$period = '('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')';
}
//print '>'.$outputlangs->charset_output.','.$period;
@@ -1455,23 +1485,30 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
//print $libelleproduitservice;
}
- if ($dbatch)
- {
+ if ($dbatch) {
$format = 'day';
- foreach ($dbatch as $detail)
- {
+ foreach ($dbatch as $detail) {
$dte = array();
- if ($detail->eatby) $dte[] = $outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs));
- if ($detail->sellby) $dte[] = $outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs));
- if ($detail->batch) $dte[] = $outputlangs->transnoentitiesnoconv('printBatch', $detail->batch);
+ if ($detail->eatby) {
+ $dte[] = $outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs));
+ }
+ if ($detail->sellby) {
+ $dte[] = $outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs));
+ }
+ if ($detail->batch) {
+ $dte[] = $outputlangs->transnoentitiesnoconv('printBatch', $detail->batch);
+ }
$dte[] = $outputlangs->transnoentitiesnoconv('printQty', $detail->qty);
$libelleproduitservice .= "__N__ ".implode(" - ", $dte);
}
}
// Now we convert \n into br
- if (dol_textishtml($libelleproduitservice)) $libelleproduitservice = preg_replace('/__N__/', ' ', $libelleproduitservice);
- else $libelleproduitservice = preg_replace('/__N__/', "\n", $libelleproduitservice);
+ if (dol_textishtml($libelleproduitservice)) {
+ $libelleproduitservice = preg_replace('/__N__/', ' ', $libelleproduitservice);
+ } else {
+ $libelleproduitservice = preg_replace('/__N__/', "\n", $libelleproduitservice);
+ }
$libelleproduitservice = dol_htmlentitiesbr($libelleproduitservice, 1);
return $libelleproduitservice;
@@ -1493,17 +1530,17 @@ function pdf_getlinenum($object, $i, $outputlangs, $hidedetails = 0)
$reshook = 0;
$result = '';
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlinenum', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$result .= $hookmanager->resPrint;
}
- if (empty($reshook))
- {
+ if (empty($reshook)) {
$result .= dol_htmlentitiesbr($object->lines[$i]->num);
}
return $result;
@@ -1526,17 +1563,17 @@ function pdf_getlineref($object, $i, $outputlangs, $hidedetails = 0)
$reshook = 0;
$result = '';
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlineref', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$result .= $hookmanager->resPrint;
}
- if (empty($reshook))
- {
+ if (empty($reshook)) {
$result .= dol_htmlentitiesbr($object->lines[$i]->product_ref);
}
return $result;
@@ -1558,17 +1595,17 @@ function pdf_getlineref_supplier($object, $i, $outputlangs, $hidedetails = 0)
$reshook = 0;
$result = '';
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlineref_supplier', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$result .= $hookmanager->resPrint;
}
- if (empty($reshook))
- {
+ if (empty($reshook)) {
$result .= dol_htmlentitiesbr($object->lines[$i]->ref_supplier);
}
return $result;
@@ -1590,38 +1627,41 @@ function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0)
$result = '';
$reshook = 0;
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlinevatrate', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
+ if (!empty($hookmanager->resPrint)) {
+ $result .= $hookmanager->resPrint;
+ }
}
- if (empty($reshook))
- {
- if (empty($hidedetails) || $hidedetails > 1)
- {
+ if (empty($reshook)) {
+ if (empty($hidedetails) || $hidedetails > 1) {
$tmpresult = '';
$tmpresult .= vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1);
- if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX))
- {
- if ($object->lines[$i]->total_localtax1 != 0)
- {
- if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult .= '/';
- else $tmpresult = '';
+ if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) {
+ if ($object->lines[$i]->total_localtax1 != 0) {
+ if (preg_replace('/[\s0%]/', '', $tmpresult)) {
+ $tmpresult .= '/';
+ } else {
+ $tmpresult = '';
+ }
$tmpresult .= vatrate(abs($object->lines[$i]->localtax1_tx), 0);
}
}
- if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX))
- {
- if ($object->lines[$i]->total_localtax2 != 0)
- {
- if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult .= '/';
- else $tmpresult = '';
+ if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) {
+ if ($object->lines[$i]->total_localtax2 != 0) {
+ if (preg_replace('/[\s0%]/', '', $tmpresult)) {
+ $tmpresult .= '/';
+ } else {
+ $tmpresult = '';
+ }
$tmpresult .= vatrate(abs($object->lines[$i]->localtax2_tx), 0);
}
}
@@ -1647,25 +1687,28 @@ function pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails = 0)
global $conf, $hookmanager;
$sign = 1;
- if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+ if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
+ $sign = -1;
+ }
$result = '';
$reshook = 0;
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlineupexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
+ if (!empty($hookmanager->resPrint)) {
+ $result .= $hookmanager->resPrint;
+ }
}
- if (empty($reshook))
- {
- if (empty($hidedetails) || $hidedetails > 1)
- {
+ if (empty($reshook)) {
+ if (empty($hidedetails) || $hidedetails > 1) {
$subprice = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice);
$result .= price($sign * $subprice, 0, $outputlangs);
}
@@ -1687,24 +1730,30 @@ function pdf_getlineupwithtax($object, $i, $outputlangs, $hidedetails = 0)
global $hookmanager, $conf;
$sign = 1;
- if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+ if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
+ $sign = -1;
+ }
$result = '';
$reshook = 0;
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlineupwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
+ if (!empty($hookmanager->resPrint)) {
+ $result .= $hookmanager->resPrint;
+ }
}
- if (empty($reshook))
- {
- if (empty($hidedetails) || $hidedetails > 1) $result .= price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice) * ($object->lines[$i]->tva_tx) / 100), 0, $outputlangs);
+ if (empty($reshook)) {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ $result .= price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice) * ($object->lines[$i]->tva_tx) / 100), 0, $outputlangs);
+ }
}
return $result;
}
@@ -1725,20 +1774,26 @@ function pdf_getlineqty($object, $i, $outputlangs, $hidedetails = 0)
$result = '';
$reshook = 0;
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlineqty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resPrint)) $result = $hookmanager->resPrint;
+ if (!empty($hookmanager->resPrint)) {
+ $result = $hookmanager->resPrint;
+ }
}
- if (empty($reshook))
- {
- if ($object->lines[$i]->special_code == 3) return '';
- if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty;
+ if (empty($reshook)) {
+ if ($object->lines[$i]->special_code == 3) {
+ return '';
+ }
+ if (empty($hidedetails) || $hidedetails > 1) {
+ $result .= $object->lines[$i]->qty;
+ }
}
return $result;
}
@@ -1759,20 +1814,26 @@ function pdf_getlineqty_asked($object, $i, $outputlangs, $hidedetails = 0)
$reshook = 0;
$result = '';
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlineqty_asked', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
+ if (!empty($hookmanager->resPrint)) {
+ $result .= $hookmanager->resPrint;
+ }
}
- if (empty($reshook))
- {
- if ($object->lines[$i]->special_code == 3) return '';
- if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty_asked;
+ if (empty($reshook)) {
+ if ($object->lines[$i]->special_code == 3) {
+ return '';
+ }
+ if (empty($hidedetails) || $hidedetails > 1) {
+ $result .= $object->lines[$i]->qty_asked;
+ }
}
return $result;
}
@@ -1793,20 +1854,26 @@ function pdf_getlineqty_shipped($object, $i, $outputlangs, $hidedetails = 0)
$reshook = 0;
$result = '';
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
+ if (!empty($hookmanager->resPrint)) {
+ $result .= $hookmanager->resPrint;
+ }
}
- if (empty($reshook))
- {
- if ($object->lines[$i]->special_code == 3) return '';
- if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty_shipped;
+ if (empty($reshook)) {
+ if ($object->lines[$i]->special_code == 3) {
+ return '';
+ }
+ if (empty($hidedetails) || $hidedetails > 1) {
+ $result .= $object->lines[$i]->qty_shipped;
+ }
}
return $result;
}
@@ -1827,20 +1894,26 @@ function pdf_getlineqty_keeptoship($object, $i, $outputlangs, $hidedetails = 0)
$reshook = 0;
$result = '';
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
+ if (!empty($hookmanager->resPrint)) {
+ $result .= $hookmanager->resPrint;
+ }
}
- if (empty($reshook))
- {
- if ($object->lines[$i]->special_code == 3) return '';
- if (empty($hidedetails) || $hidedetails > 1) $result .= ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped);
+ if (empty($reshook)) {
+ if ($object->lines[$i]->special_code == 3) {
+ return '';
+ }
+ if (empty($hidedetails) || $hidedetails > 1) {
+ $result .= ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped);
+ }
}
return $result;
}
@@ -1862,8 +1935,7 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag
$reshook = 0;
$result = '';
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
if (!empty($object->lines[$i]->fk_parent_line)) {
$special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
@@ -1877,11 +1949,14 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
+ if (!empty($hookmanager->resPrint)) {
+ $result .= $hookmanager->resPrint;
+ }
}
- if (empty($reshook))
- {
- if (empty($hidedetails) || $hidedetails > 1) $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short'));
+ if (empty($reshook)) {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short'));
+ }
}
return $result;
}
@@ -1905,20 +1980,26 @@ function pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails = 0)
$reshook = 0;
$result = '';
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlineremisepercent', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
+ if (!empty($hookmanager->resPrint)) {
+ $result .= $hookmanager->resPrint;
+ }
}
- if (empty($reshook))
- {
- if ($object->lines[$i]->special_code == 3) return '';
- if (empty($hidedetails) || $hidedetails > 1) $result .= dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs);
+ if (empty($reshook)) {
+ if ($object->lines[$i]->special_code == 3) {
+ return '';
+ }
+ if (empty($hidedetails) || $hidedetails > 1) {
+ $result .= dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs);
+ }
}
return $result;
}
@@ -1935,37 +2016,42 @@ function pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails = 0)
*/
function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = null)
{
- if (empty($hookmanager)) global $hookmanager;
+ if (empty($hookmanager)) {
+ global $hookmanager;
+ }
global $conf;
$reshook = 0;
$result = '';
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
+ if (!empty($hookmanager->resPrint)) {
+ return $hookmanager->resPrint;
+ }
}
- if (empty($reshook))
- {
- if ($object->lines[$i]->special_code == 3) return '';
- if (empty($hidedetails) || $hidedetails > 1)
- {
- if ($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF)
- {
+ if (empty($reshook)) {
+ if ($object->lines[$i]->special_code == 3) {
+ return '';
+ }
+ if (empty($hidedetails) || $hidedetails > 1) {
+ if ($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF) {
$prev_progress = 0;
- if (method_exists($object, 'get_prev_progress'))
- {
- $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
+ if (method_exists($object, 'get_prev_progress')) {
+ $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
}
- $result = ($object->lines[$i]->situation_percent - $prev_progress).'%';
- } else $result = $object->lines[$i]->situation_percent.'%';
- }
+ $result = ($object->lines[$i]->situation_percent - $prev_progress).'%';
+ } else {
+ $result = $object->lines[$i]->situation_percent.'%';
+ }
+ }
}
return $result;
}
@@ -1984,37 +2070,36 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0)
global $conf, $hookmanager;
$sign = 1;
- if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+ if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
+ $sign = -1;
+ }
$reshook = 0;
$result = '';
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code, 'sign'=>$sign);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
- }
- if (empty($reshook))
- {
- if ($object->lines[$i]->special_code == 3)
- {
- $result .= $outputlangs->transnoentities("Option");
+ if (!empty($hookmanager->resPrint)) {
+ $result .= $hookmanager->resPrint;
}
- elseif (empty($hidedetails) || $hidedetails > 1)
- {
+ }
+ if (empty($reshook)) {
+ if ($object->lines[$i]->special_code == 3) {
+ $result .= $outputlangs->transnoentities("Option");
+ } elseif (empty($hidedetails) || $hidedetails > 1) {
$total_ht = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht);
- if (!empty($object->lines[$i]->situation_percent) && $object->lines[$i]->situation_percent > 0)
- {
+ if (!empty($object->lines[$i]->situation_percent) && $object->lines[$i]->situation_percent > 0) {
// TODO Remove this. The total should be saved correctly in database instead of being modified here.
$prev_progress = 0;
$progress = 1;
- if (method_exists($object->lines[$i], 'get_prev_progress'))
- {
+ if (method_exists($object->lines[$i], 'get_prev_progress')) {
$prev_progress = $object->lines[$i]->get_prev_progress($object->id);
$progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100;
}
@@ -2041,37 +2126,36 @@ function pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails = 0)
global $hookmanager, $conf;
$sign = 1;
- if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+ if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
+ $sign = -1;
+ }
$reshook = 0;
$result = '';
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
- if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
- {
+ if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
- }
- if (empty($reshook))
- {
- if ($object->lines[$i]->special_code == 3)
- {
- $result .= $outputlangs->transnoentities("Option");
+ if (!empty($hookmanager->resPrint)) {
+ $result .= $hookmanager->resPrint;
}
- elseif (empty($hidedetails) || $hidedetails > 1)
- {
+ }
+ if (empty($reshook)) {
+ if ($object->lines[$i]->special_code == 3) {
+ $result .= $outputlangs->transnoentities("Option");
+ } elseif (empty($hidedetails) || $hidedetails > 1) {
$total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ttc : $object->lines[$i]->total_ttc);
- if ($object->lines[$i]->situation_percent > 0)
- {
+ if ($object->lines[$i]->situation_percent > 0) {
// TODO Remove this. The total should be saved correctly in database instead of being modified here.
$prev_progress = 0;
$progress = 1;
- if (method_exists($object->lines[$i], 'get_prev_progress'))
- {
+ if (method_exists($object->lines[$i], 'get_prev_progress')) {
$prev_progress = $object->lines[$i]->get_prev_progress($object->id);
$progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100;
}
@@ -2101,26 +2185,22 @@ function pdf_getTotalQty($object, $type, $outputlangs)
$nblines = count($object->lines);
// Loop on each lines
- for ($i = 0; $i < $nblines; $i++)
- {
- if ($object->lines[$i]->special_code != 3)
- {
- if ($type == 'all')
- {
+ for ($i = 0; $i < $nblines; $i++) {
+ if ($object->lines[$i]->special_code != 3) {
+ if ($type == 'all') {
$total += $object->lines[$i]->qty;
- } elseif ($type == 9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
- {
+ } elseif ($type == 9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) {
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
$action = '';
$reshook = $hookmanager->executeHooks('pdf_getTotalQty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
return $hookmanager->resPrint;
- } elseif ($type == 0 && $object->lines[$i]->product_type == 0)
- {
+ } elseif ($type == 0 && $object->lines[$i]->product_type == 0) {
$total += $object->lines[$i]->qty;
- } elseif ($type == 1 && $object->lines[$i]->product_type == 1)
- {
+ } elseif ($type == 1 && $object->lines[$i]->product_type == 1) {
$total += $object->lines[$i]->qty;
}
}
@@ -2145,81 +2225,73 @@ function pdf_getLinkedObjects($object, $outputlangs)
$object->fetchObjectLinked();
- foreach ($object->linkedObjects as $objecttype => $objects)
- {
- if ($objecttype == 'facture')
- {
+ foreach ($object->linkedObjects as $objecttype => $objects) {
+ if ($objecttype == 'facture') {
// For invoice, we don't want to have a reference line on document. Image we are using recuring invoice, we will have a line longer than document width.
- } elseif ($objecttype == 'propal' || $objecttype == 'supplier_proposal')
- {
+ } elseif ($objecttype == 'propal' || $objecttype == 'supplier_proposal') {
$outputlangs->load('propal');
- foreach ($objects as $elementobject)
- {
+ foreach ($objects as $elementobject) {
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal");
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal");
$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs);
}
- } elseif ($objecttype == 'commande' || $objecttype == 'supplier_order')
- {
+ } elseif ($objecttype == 'commande' || $objecttype == 'supplier_order') {
$outputlangs->load('orders');
- foreach ($objects as $elementobject)
- {
+ foreach ($objects as $elementobject) {
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder");
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '').($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : '');
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate");
$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs);
}
- } elseif ($objecttype == 'contrat')
- {
+ } elseif ($objecttype == 'contrat') {
$outputlangs->load('contracts');
- foreach ($objects as $elementobject)
- {
+ foreach ($objects as $elementobject) {
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract");
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract");
$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat, 'day', '', $outputlangs);
}
- } elseif ($objecttype == 'fichinter')
- {
+ } elseif ($objecttype == 'fichinter') {
$outputlangs->load('interventions');
- foreach ($objects as $elementobject)
- {
+ foreach ($objects as $elementobject) {
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("InterRef");
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("InterDate");
$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->datec, 'day', '', $outputlangs);
}
- } elseif ($objecttype == 'shipping')
- {
+ } elseif ($objecttype == 'shipping') {
$outputlangs->loadLangs(array("orders", "sendings"));
- foreach ($objects as $x => $elementobject)
- {
+ foreach ($objects as $x => $elementobject) {
$order = null;
// We concat this record info into fields xxx_value. title is overwrote.
- if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order
- {
+ if (empty($object->linkedObjects['commande']) && $object->element != 'commande') { // There is not already a link to order and object is not the order, so we show also info with order
$elementobject->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0);
if (!empty($elementobject->linkedObjectsIds['commande'])) {
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$order = new Commande($db);
$ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande']));
- if ($ret < 1) { $order = null; }
+ if ($ret < 1) {
+ $order = null;
+ }
}
}
- if (!is_object($order))
- {
+ if (!is_object($order)) {
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending");
- if (!empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] .= ' / ';
+ if (!empty($linkedobjects[$objecttype]['ref_value'])) {
+ $linkedobjects[$objecttype]['ref_value'] .= ' / ';
+ }
$linkedobjects[$objecttype]['ref_value'] .= $outputlangs->transnoentities($elementobject->ref);
//$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateShipment");
//if (! empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'].=' / ';
//$linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery,'day','',$outputlangs);
} else {
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending");
- if (empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : '');
+ if (empty($linkedobjects[$objecttype]['ref_value'])) {
+ $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : '');
+ }
$linkedobjects[$objecttype]['ref_value'] .= ' / '.$outputlangs->transnoentities($elementobject->ref);
//$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate") . ($elementobject->date_delivery ? ' / ' . $outputlangs->transnoentities("DateShipment") : '');
//if (empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'] = dol_print_date($order->date,'day','',$outputlangs);
@@ -2230,12 +2302,13 @@ function pdf_getLinkedObjects($object, $outputlangs)
}
// For add external linked objects
- if (is_object($hookmanager))
- {
+ if (is_object($hookmanager)) {
$parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs);
$action = '';
$hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if (!empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray;
+ if (!empty($hookmanager->resArray)) {
+ $linkedobjects = $hookmanager->resArray;
+ }
}
return $linkedobjects;
@@ -2256,11 +2329,9 @@ function pdf_getSizeForImage($realpath)
$maxheight = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT) ? 32 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT);
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
$tmp = dol_getImageSize($realpath);
- if ($tmp['height'])
- {
+ if ($tmp['height']) {
$width = (int) round($maxheight * $tmp['width'] / $tmp['height']); // I try to use maxheight
- if ($width > $maxwidth) // Pb with maxheight, so i use maxwidth
- {
+ if ($width > $maxwidth) { // Pb with maxheight, so i use maxwidth
$width = $maxwidth;
$height = (int) round($maxwidth * $tmp['height'] / $tmp['width']);
} else // No pb with maxheight
@@ -2284,15 +2355,17 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails =
{
global $conf, $hookmanager;
$sign = 1;
- if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
- if ($object->lines[$i]->special_code == 3)
- {
+ if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
+ $sign = -1;
+ }
+ if ($object->lines[$i]->special_code == 3) {
return $outputlangs->transnoentities("Option");
} else {
- if (is_object($hookmanager))
- {
+ if (is_object($hookmanager)) {
$special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ if (!empty($object->lines[$i]->fk_parent_line)) {
+ $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+ }
$parameters = array(
'i'=>$i,
@@ -2303,13 +2376,14 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails =
$action = '';
- if ($hookmanager->executeHooks('getlinetotalremise', $parameters, $object, $action) > 0)
- {
+ if ($hookmanager->executeHooks('getlinetotalremise', $parameters, $object, $action) > 0) {
return $hookmanager->resPrint; // Note that $action and $object may have been modified by some hooks
}
}
- if (empty($hidedetails) || $hidedetails > 1) return $sign * (($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht);
+ if (empty($hidedetails) || $hidedetails > 1) {
+ return $sign * (($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht);
+ }
}
return '';
}
diff --git a/htdocs/core/lib/prelevement.lib.php b/htdocs/core/lib/prelevement.lib.php
index 75bf914b964..bc81ee2bfbd 100644
--- a/htdocs/core/lib/prelevement.lib.php
+++ b/htdocs/core/lib/prelevement.lib.php
@@ -85,14 +85,22 @@ function prelevement_prepare_head(BonPrelevement $object)
function prelevement_check_config($type = 'direct-debit')
{
global $conf, $db;
- if ($type == 'bank-transfer'){
- if (empty($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT)) return -1;
+ if ($type == 'bank-transfer') {
+ if (empty($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT)) {
+ return -1;
+ }
//if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
- if (empty($conf->global->PAYMENTBYBANKTRANSFER_USER)) return -1;
- }else {
- if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1;
+ if (empty($conf->global->PAYMENTBYBANKTRANSFER_USER)) {
+ return -1;
+ }
+ } else {
+ if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) {
+ return -1;
+ }
//if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
- if (empty($conf->global->PRELEVEMENT_USER)) return -1;
+ if (empty($conf->global->PRELEVEMENT_USER)) {
+ return -1;
+ }
}
return 0;
}
diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php
index 98311d093cd..3a73f47a6a0 100644
--- a/htdocs/core/lib/price.lib.php
+++ b/htdocs/core/lib/price.lib.php
@@ -90,13 +90,15 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
$result = array();
// Clean parameters
- if (empty($info_bits)) $info_bits = 0;
- if (empty($txtva)) $txtva = 0;
- if (empty($seller) || !is_object($seller))
- {
+ if (empty($info_bits)) {
+ $info_bits = 0;
+ }
+ if (empty($txtva)) {
+ $txtva = 0;
+ }
+ if (empty($seller) || !is_object($seller)) {
dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter seller that is missing", LOG_WARNING);
- if (!is_object($mysoc)) // mysoc may be not defined (during migration process)
- {
+ if (!is_object($mysoc)) { // mysoc may be not defined (during migration process)
$mysoc = new Societe($db);
$mysoc->setMysoc($conf);
}
@@ -116,11 +118,19 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
$countryid = $seller->country_id;
- if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate = (float) $uselocaltax1_rate;
- if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate = (float) $uselocaltax2_rate;
+ if (is_numeric($uselocaltax1_rate)) {
+ $uselocaltax1_rate = (float) $uselocaltax1_rate;
+ }
+ if (is_numeric($uselocaltax2_rate)) {
+ $uselocaltax2_rate = (float) $uselocaltax2_rate;
+ }
- if ($uselocaltax1_rate < 0) $uselocaltax1_rate = $seller->localtax1_assuj;
- if ($uselocaltax2_rate < 0) $uselocaltax2_rate = $seller->localtax2_assuj;
+ if ($uselocaltax1_rate < 0) {
+ $uselocaltax1_rate = $seller->localtax1_assuj;
+ }
+ if ($uselocaltax2_rate < 0) {
+ $uselocaltax2_rate = $seller->localtax2_assuj;
+ }
//var_dump($uselocaltax1_rate.' - '.$uselocaltax2_rate);
dol_syslog('Price.lib::calcul_price_total qty='.$qty.' pu='.$pu.' remise_percent_ligne='.$remise_percent_ligne.' txtva='.$txtva.' uselocaltax1_rate='.$uselocaltax1_rate.' uselocaltax2_rate='.$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$price_base_type.' type='.$type.' progress='.$progress);
@@ -144,33 +154,37 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
$sql .= " WHERE cv.taux = ".$txtva;
$sql .= " AND cv.fk_pays = ".$countryid;
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $db->fetch_object($resql);
- if ($obj)
- {
+ if ($obj) {
$localtax1_rate = (float) $obj->localtax1; // Use float to force to get first numeric value when value is x:y:z
$localtax2_rate = (float) $obj->localtax2; // Use float to force to get first numeric value when value is -19:-15:-9
$localtax1_type = $obj->localtax1_type;
$localtax2_type = $obj->localtax2_type;
//var_dump($localtax1_rate.' '.$localtax2_rate.' '.$localtax1_type.' '.$localtax2_type);
}
- } else dol_print_error($db);
+ } else {
+ dol_print_error($db);
+ }
}
// pu calculation from pu_devise if pu empty
if (empty($pu) && !empty($pu_devise)) {
- if (!empty($multicurrency_tx)) $pu = $pu_devise / $multicurrency_tx;
- else {
+ if (!empty($multicurrency_tx)) {
+ $pu = $pu_devise / $multicurrency_tx;
+ } else {
dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (multicurrency_tx empty when pu_devise not) ', LOG_ERR);
return array();
}
}
- if ($pu === '') $pu = 0;
+ if ($pu === '') {
+ $pu = 0;
+ }
// pu_devise calculation from pu
if (empty($pu_devise) && !empty($multicurrency_tx)) {
- if (is_numeric($pu) && is_numeric($multicurrency_tx)) $pu_devise = $pu * $multicurrency_tx;
- else {
+ if (is_numeric($pu) && is_numeric($multicurrency_tx)) {
+ $pu_devise = $pu * $multicurrency_tx;
+ } else {
dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (pu or multicurrency_tx are not numeric)', LOG_ERR);
return array();
}
@@ -182,13 +196,14 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
$tot_avec_remise = $tot_avec_remise_ligne * (1 - ($remise_percent_global / 100));
// initialize result array
- for ($i = 0; $i <= 15; $i++) $result[$i] = 0;
+ for ($i = 0; $i <= 15; $i++) {
+ $result[$i] = 0;
+ }
// if there's some localtax including vat, we calculate localtaxes (we will add later)
// if input unit price is 'HT', we need to have the totals with main VAT for a correct calculation
- if ($price_base_type != 'TTC')
- {
+ if ($price_base_type != 'TTC') {
$tot_sans_remise_wt = price2num($tot_sans_remise * (1 + ($txtva / 100)), 'MU');
$tot_avec_remise_wt = price2num($tot_avec_remise * (1 + ($txtva / 100)), 'MU');
$pu_wt = price2num($pu * (1 + ($txtva / 100)), 'MU');
@@ -207,22 +222,26 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
$apply_tax = true;
break;
case '4': // localtax on product
- if ($type == 0) $apply_tax = true;
+ if ($type == 0) {
+ $apply_tax = true;
+ }
break;
case '6': // localtax on service
- if ($type == 1) $apply_tax = true;
+ if ($type == 1) {
+ $apply_tax = true;
+ }
break;
}
if ($uselocaltax1_rate && $apply_tax) {
- $result[14] = price2num(($tot_sans_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_sans_remise_wt, 'MT');
- $localtaxes[0] += $result[14];
+ $result[14] = price2num(($tot_sans_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_sans_remise_wt, 'MT');
+ $localtaxes[0] += $result[14];
- $result[9] = price2num(($tot_avec_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_avec_remise_wt, 'MT');
- $localtaxes[1] += $result[9];
+ $result[9] = price2num(($tot_avec_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_avec_remise_wt, 'MT');
+ $localtaxes[1] += $result[9];
- $result[11] = price2num(($pu_wt * (1 + ($localtax1_rate / 100))) - $pu_wt, 'MU');
- $localtaxes[2] += $result[11];
+ $result[11] = price2num(($pu_wt * (1 + ($localtax1_rate / 100))) - $pu_wt, 'MU');
+ $localtaxes[2] += $result[11];
}
$apply_tax = false;
@@ -231,26 +250,29 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
$apply_tax = true;
break;
case '4': // localtax on product
- if ($type == 0) $apply_tax = true;
+ if ($type == 0) {
+ $apply_tax = true;
+ }
break;
case '6': // localtax on service
- if ($type == 1) $apply_tax = true;
+ if ($type == 1) {
+ $apply_tax = true;
+ }
break;
}
if ($uselocaltax2_rate && $apply_tax) {
- $result[15] = price2num(($tot_sans_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_sans_remise_wt, 'MT');
- $localtaxes[0] += $result[15];
+ $result[15] = price2num(($tot_sans_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_sans_remise_wt, 'MT');
+ $localtaxes[0] += $result[15];
- $result[10] = price2num(($tot_avec_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_avec_remise_wt, 'MT');
- $localtaxes[1] += $result[10];
+ $result[10] = price2num(($tot_avec_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_avec_remise_wt, 'MT');
+ $localtaxes[1] += $result[10];
- $result[12] = price2num(($pu_wt * (1 + ($localtax2_rate / 100))) - $pu_wt, 'MU');
- $localtaxes[2] += $result[12];
+ $result[12] = price2num(($pu_wt * (1 + ($localtax2_rate / 100))) - $pu_wt, 'MU');
+ $localtaxes[2] += $result[12];
}
//dol_syslog("price.lib::calcul_price_total $qty, $pu, $remise_percent_ligne, $txtva, $price_base_type $info_bits");
- if ($price_base_type == 'HT')
- {
+ if ($price_base_type == 'HT') {
// We work to define prices using the price without tax
$result[6] = price2num($tot_sans_remise, 'MT');
$result[8] = price2num($tot_sans_remise * (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)) + $localtaxes[0], 'MT'); // Selon TVA NPR ou non
@@ -287,8 +309,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
// if there's some localtax without vat, we calculate localtaxes (we will add them at end)
//If input unit price is 'TTC', we need to have the totals without main VAT for a correct calculation
- if ($price_base_type == 'TTC')
- {
+ if ($price_base_type == 'TTC') {
$tot_sans_remise = price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MU');
$tot_avec_remise = price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MU');
$pu = price2num($pu / (1 + ($txtva / 100)), 'MU');
@@ -300,21 +321,25 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
$apply_tax = true;
break;
case '3': // localtax on product
- if ($type == 0) $apply_tax = true;
+ if ($type == 0) {
+ $apply_tax = true;
+ }
break;
case '5': // localtax on service
- if ($type == 1) $apply_tax = true;
+ if ($type == 1) {
+ $apply_tax = true;
+ }
break;
}
if ($uselocaltax1_rate && $apply_tax) {
- $result[14] = price2num(($tot_sans_remise * (1 + ($localtax1_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax1 for total_ht_without_discount
- $result[8] += $result[14]; // total_ttc_without_discount + tax1
+ $result[14] = price2num(($tot_sans_remise * (1 + ($localtax1_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax1 for total_ht_without_discount
+ $result[8] += $result[14]; // total_ttc_without_discount + tax1
- $result[9] = price2num(($tot_avec_remise * (1 + ($localtax1_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax1 for total_ht
- $result[2] += $result[9]; // total_ttc + tax1
+ $result[9] = price2num(($tot_avec_remise * (1 + ($localtax1_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax1 for total_ht
+ $result[2] += $result[9]; // total_ttc + tax1
- $result[11] = price2num(($pu * (1 + ($localtax1_rate / 100))) - $pu, 'MU'); // amount tax1 for pu_ht
- $result[5] += $result[11]; // pu_ht + tax1
+ $result[11] = price2num(($pu * (1 + ($localtax1_rate / 100))) - $pu, 'MU'); // amount tax1 for pu_ht
+ $result[5] += $result[11]; // pu_ht + tax1
}
$apply_tax = false;
@@ -323,28 +348,30 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
$apply_tax = true;
break;
case '3': // localtax on product
- if ($type == 0) $apply_tax = true;
+ if ($type == 0) {
+ $apply_tax = true;
+ }
break;
case '5': // localtax on service
- if ($type == 1) $apply_tax = true;
+ if ($type == 1) {
+ $apply_tax = true;
+ }
break;
}
if ($uselocaltax2_rate && $apply_tax) {
- $result[15] = price2num(($tot_sans_remise * (1 + ($localtax2_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax2 for total_ht_without_discount
- $result[8] += $result[15]; // total_ttc_without_discount + tax2
+ $result[15] = price2num(($tot_sans_remise * (1 + ($localtax2_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax2 for total_ht_without_discount
+ $result[8] += $result[15]; // total_ttc_without_discount + tax2
- $result[10] = price2num(($tot_avec_remise * (1 + ($localtax2_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax2 for total_ht
- $result[2] += $result[10]; // total_ttc + tax2
+ $result[10] = price2num(($tot_avec_remise * (1 + ($localtax2_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax2 for total_ht
+ $result[2] += $result[10]; // total_ttc + tax2
- $result[12] = price2num(($pu * (1 + ($localtax2_rate / 100))) - $pu, 'MU'); // amount tax2 for pu_ht
- $result[5] += $result[12]; // pu_ht + tax2
+ $result[12] = price2num(($pu * (1 + ($localtax2_rate / 100))) - $pu, 'MU'); // amount tax2 for pu_ht
+ $result[5] += $result[12]; // pu_ht + tax2
}
// If rounding is not using base 10 (rare)
- if (!empty($conf->global->MAIN_ROUNDING_RULE_TOT))
- {
- if ($price_base_type == 'HT')
- {
+ if (!empty($conf->global->MAIN_ROUNDING_RULE_TOT)) {
+ if ($price_base_type == 'HT') {
$result[0] = round($result[0] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
@@ -360,8 +387,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
}
// Multicurrency
- if ($multicurrency_tx != 1)
- {
+ if ($multicurrency_tx != 1) {
if ($multicurrency_code) {
$savMAIN_MAX_DECIMALS_UNIT = $conf->global->MAIN_MAX_DECIMALS_UNIT;
$savMAIN_MAX_DECIMALS_TOT = $conf->global->MAIN_MAX_DECIMALS_TOT;
diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php
index 9ce8d84d7e3..52db9f88e24 100644
--- a/htdocs/core/lib/product.lib.php
+++ b/htdocs/core/lib/product.lib.php
@@ -38,7 +38,9 @@ function product_prepare_head($object)
$langs->load("products");
$label = $langs->trans('Product');
- if ($object->isService()) $label = $langs->trans('Service');
+ if ($object->isService()) {
+ $label = $langs->trans('Service');
+ }
$h = 0;
$head = array();
@@ -48,20 +50,17 @@ function product_prepare_head($object)
$head[$h][2] = 'card';
$h++;
- if (!empty($object->status))
- {
+ if (!empty($object->status)) {
$head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$object->id;
$head[$h][1] = $langs->trans("SellingPrices");
$head[$h][2] = 'price';
$h++;
}
- if (!empty($object->status_buy) || (!empty($conf->margin->enabled) && !empty($object->status))) // If margin is on and product on sell, we may need the cost price even if product os not on purchase
- {
+ if (!empty($object->status_buy) || (!empty($conf->margin->enabled) && !empty($object->status))) { // If margin is on and product on sell, we may need the cost price even if product os not on purchase
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->lire)
|| (!empty($conf->margin->enabled) && $user->rights->margin->liretous)
- )
- {
+ ) {
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id;
$head[$h][1] = $langs->trans("BuyingPrices");
$head[$h][2] = 'suppliers';
@@ -70,8 +69,7 @@ function product_prepare_head($object)
}
// Multilangs
- if (!empty($conf->global->MAIN_MULTILANGS))
- {
+ if (!empty($conf->global->MAIN_MULTILANGS)) {
$head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$object->id;
$head[$h][1] = $langs->trans("Translation");
$head[$h][2] = 'translation';
@@ -79,13 +77,14 @@ function product_prepare_head($object)
}
// Sub products
- if (!empty($conf->global->PRODUIT_SOUSPRODUITS))
- {
+ if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) {
$head[$h][0] = DOL_URL_ROOT."/product/composition/card.php?id=".$object->id;
$head[$h][1] = $langs->trans('AssociatedProducts');
$nbFatherAndChild = $object->hasFatherOrChild();
- if ($nbFatherAndChild > 0) $head[$h][1] .= ''.$nbFatherAndChild.'';
+ if ($nbFatherAndChild > 0) {
+ $head[$h][1] .= ''.$nbFatherAndChild.'';
+ }
$head[$h][2] = 'subproduct';
$h++;
}
@@ -97,22 +96,21 @@ function product_prepare_head($object)
$prodcomb = new ProductCombination($db);
- if ($prodcomb->fetchByFkProductChild($object->id) <= 0)
- {
+ if ($prodcomb->fetchByFkProductChild($object->id) <= 0) {
$head[$h][0] = DOL_URL_ROOT."/variants/combinations.php?id=".$object->id;
$head[$h][1] = $langs->trans('ProductCombinations');
$head[$h][2] = 'combinations';
$nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id);
- if ($nbVariant > 0) $head[$h][1] .= ''.$nbVariant.'';
+ if ($nbVariant > 0) {
+ $head[$h][1] .= ''.$nbVariant.'';
+ }
}
$h++;
}
- if ($object->isProduct() || ($object->isService() && !empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option)
- {
- if (!empty($conf->stock->enabled) && $user->rights->stock->lire)
- {
+ if ($object->isProduct() || ($object->isService() && !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { // If physical product we can stock (or service with option)
+ if (!empty($conf->stock->enabled) && $user->rights->stock->lire) {
$head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$object->id;
$head[$h][1] = $langs->trans("Stock");
$head[$h][2] = 'stock';
@@ -121,17 +119,14 @@ function product_prepare_head($object)
}
// Tab to link resources
- if (!empty($conf->resource->enabled))
- {
- if ($object->isProduct() && !empty($conf->global->RESOURCE_ON_PRODUCTS))
- {
+ if (!empty($conf->resource->enabled)) {
+ if ($object->isProduct() && !empty($conf->global->RESOURCE_ON_PRODUCTS)) {
$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=product&ref='.$object->ref;
$head[$h][1] = $langs->trans("Resources");
$head[$h][2] = 'resources';
$h++;
}
- if ($object->isService() && !empty($conf->global->RESOURCE_ON_SERVICES))
- {
+ if ($object->isService() && !empty($conf->global->RESOURCE_ON_SERVICES)) {
$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=service&ref='.$object->ref;
$head[$h][1] = $langs->trans("Resources");
$head[$h][2] = 'resources';
@@ -156,14 +151,19 @@ function product_prepare_head($object)
complete_head_from_modules($conf, $langs, $object, $head, $h, 'product');
// Notes
- if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
- {
+ if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
$nbNote = 0;
- if (!empty($object->note_private)) $nbNote++;
- if (!empty($object->note_public)) $nbNote++;
+ if (!empty($object->note_private)) {
+ $nbNote++;
+ }
+ if (!empty($object->note_public)) {
+ $nbNote++;
+ }
$head[$h][0] = DOL_URL_ROOT.'/product/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
- if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.'';
+ if ($nbNote > 0) {
+ $head[$h][1] .= ''.$nbNote.'';
+ }
$head[$h][2] = 'note';
$h++;
}
@@ -171,18 +171,28 @@ function product_prepare_head($object)
// Attachments
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
- if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
- if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
+ if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) {
+ $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
+ }
+ if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) {
+ $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
+ }
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
- if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
- if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
+ if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) {
+ $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
+ }
+ if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) {
+ $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
+ }
$nbFiles += count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
}
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
- if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).'';
+ if (($nbFiles + $nbLinks) > 0) {
+ $head[$h][1] .= ''.($nbFiles + $nbLinks).'';
+ }
$head[$h][2] = 'documents';
$h++;
@@ -191,8 +201,7 @@ function product_prepare_head($object)
// Log
$head[$h][0] = DOL_URL_ROOT.'/product/agenda.php?id='.$object->id;
$head[$h][1] = $langs->trans("Events");
- if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
- {
+ if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$head[$h][1] .= '/';
$head[$h][1] .= $langs->trans("Agenda");
}
@@ -231,7 +240,9 @@ function productlot_prepare_head($object)
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT."/product/stock/productlot_document.php?id=".$object->id;
$head[$h][1] = $langs->trans("Documents");
- if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).'';
+ if (($nbFiles + $nbLinks) > 0) {
+ $head[$h][1] .= ''.($nbFiles + $nbLinks).'';
+ }
$head[$h][2] = 'documents';
$h++;
@@ -245,11 +256,11 @@ function productlot_prepare_head($object)
// Log
/*
- $head[$h][0] = DOL_URL_ROOT.'/product/info.php?id='.$object->id;
- $head[$h][1] = $langs->trans("Info");
- $head[$h][2] = 'info';
- $h++;
- */
+ $head[$h][0] = DOL_URL_ROOT.'/product/info.php?id='.$object->id;
+ $head[$h][1] = $langs->trans("Info");
+ $head[$h][2] = 'info';
+ $h++;
+ */
return $head;
}
@@ -273,8 +284,7 @@ function product_admin_prepare_head()
$head[$h][2] = 'general';
$h++;
- if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL))
- {
+ if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) {
$head[$h] = array(
0 => DOL_URL_ROOT."/product/admin/price_rules.php",
1 => $langs->trans('MultipriceRules'),
@@ -358,11 +368,12 @@ function show_stats_for_company($product, $socid)
print '';
// Customer proposals
- if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
- {
+ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
$nblines++;
$ret = $product->load_stats_propale($socid);
- if ($ret < 0) dol_print_error($db);
+ if ($ret < 0) {
+ dol_print_error($db);
+ }
$langs->load("propal");
print '| ';
print ''.img_object('', 'propal').' '.$langs->trans("Proposals").'';
@@ -376,11 +387,12 @@ function show_stats_for_company($product, $socid)
print ' | ';
}
// Supplier proposals
- if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
- {
+ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) {
$nblines++;
$ret = $product->load_stats_proposal_supplier($socid);
- if ($ret < 0) dol_print_error($db);
+ if ($ret < 0) {
+ dol_print_error($db);
+ }
$langs->load("propal");
print '| ';
print ''.img_object('', 'supplier_proposal').' '.$langs->trans("SupplierProposals").'';
@@ -394,11 +406,12 @@ function show_stats_for_company($product, $socid)
print ' | ';
}
// Customer orders
- if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
- {
+ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
$nblines++;
$ret = $product->load_stats_commande($socid);
- if ($ret < 0) dol_print_error($db);
+ if ($ret < 0) {
+ dol_print_error($db);
+ }
$langs->load("orders");
print '| ';
print ''.img_object('', 'order').' '.$langs->trans("CustomersOrders").'';
@@ -412,11 +425,12 @@ function show_stats_for_company($product, $socid)
print ' | ';
}
// Supplier orders
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire)
- {
+ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) {
$nblines++;
$ret = $product->load_stats_commande_fournisseur($socid);
- if ($ret < 0) dol_print_error($db);
+ if ($ret < 0) {
+ dol_print_error($db);
+ }
$langs->load("orders");
print '| ';
print ''.img_object('', 'supplier_order').' '.$langs->trans("SuppliersOrders").'';
@@ -430,11 +444,12 @@ function show_stats_for_company($product, $socid)
print ' | ';
}
// Customer invoices
- if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
- {
+ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
$nblines++;
$ret = $product->load_stats_facture($socid);
- if ($ret < 0) dol_print_error($db);
+ if ($ret < 0) {
+ dol_print_error($db);
+ }
$langs->load("bills");
print '| ';
print ''.img_object('', 'bill').' '.$langs->trans("CustomersInvoices").'';
@@ -448,11 +463,12 @@ function show_stats_for_company($product, $socid)
print ' | ';
}
// Supplier invoices
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire)
- {
+ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) {
$nblines++;
$ret = $product->load_stats_facture_fournisseur($socid);
- if ($ret < 0) dol_print_error($db);
+ if ($ret < 0) {
+ dol_print_error($db);
+ }
$langs->load("bills");
print '| ';
print ''.img_object('', 'supplier_invoice').' '.$langs->trans("SuppliersInvoices").'';
@@ -467,11 +483,12 @@ function show_stats_for_company($product, $socid)
}
// Contracts
- if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire)
- {
+ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) {
$nblines++;
$ret = $product->load_stats_contrat($socid);
- if ($ret < 0) dol_print_error($db);
+ if ($ret < 0) {
+ dol_print_error($db);
+ }
$langs->load("contracts");
print ' | ';
print ''.img_object('', 'contract').' '.$langs->trans("Contracts").'';
@@ -486,8 +503,7 @@ function show_stats_for_company($product, $socid)
}
// BOM
- if (!empty($conf->bom->enabled) && $user->rights->bom->read)
- {
+ if (!empty($conf->bom->enabled) && $user->rights->bom->read) {
$nblines++;
$ret = $product->load_stats_bom($socid);
if ($ret < 0) {
@@ -510,8 +526,7 @@ function show_stats_for_company($product, $socid)
}
// MO
- if (!empty($conf->mrp->enabled) && $user->rights->mrp->read)
- {
+ if (!empty($conf->mrp->enabled) && $user->rights->mrp->read) {
$nblines++;
$ret = $product->load_stats_mo($socid);
if ($ret < 0) {
@@ -579,19 +594,16 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho
$outputlangs = $langs;
}
- if (empty($measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label]))
- {
+ if (empty($measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label])) {
require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
$measuringUnits = new CUnits($db);
- if ($measuring_style == '' && $scale == '')
- {
+ if ($measuring_style == '' && $scale == '') {
$arrayforfilter = array(
't.rowid' => $unit,
't.active' => 1
);
- } elseif ($scale !== '')
- {
+ } elseif ($scale !== '') {
$arrayforfilter = array(
't.scale' => $scale,
't.unit_type' => $measuring_style,
@@ -610,8 +622,11 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho
return -1;
} else {
if (is_array($measuringUnits->records) && count($measuringUnits->records) > 0) {
- if ($use_short_label) $labeltoreturn = $measuringUnits->records[key($measuringUnits->records)]->short_label;
- else $labeltoreturn = $outputlangs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label);
+ if ($use_short_label) {
+ $labeltoreturn = $measuringUnits->records[key($measuringUnits->records)]->short_label;
+ } else {
+ $labeltoreturn = $outputlangs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label);
+ }
} else {
$labeltoreturn = '';
}
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index c11cc4a74d6..6db0e905320 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -48,12 +48,13 @@ function project_prepare_head(Project $project)
$nbContact = count($project->liste_contact(-1, 'internal')) + count($project->liste_contact(-1, 'external'));
$head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$project->id;
$head[$h][1] = $langs->trans("ProjectContact");
- if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.'';
+ if ($nbContact > 0) {
+ $head[$h][1] .= ''.$nbContact.'';
+ }
$head[$h][2] = 'contact';
$h++;
- if (empty($conf->global->PROJECT_HIDE_TASKS))
- {
+ if (empty($conf->global->PROJECT_HIDE_TASKS)) {
// Then tab for sub level of projet, i mean tasks
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$project->id;
$head[$h][1] = $langs->trans("Tasks");
@@ -61,7 +62,9 @@ function project_prepare_head(Project $project)
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
$taskstatic = new Task($db);
$nbTasks = count($taskstatic->getTasksArray(0, 0, $project->id, 0, 0));
- if ($nbTasks > 0) $head[$h][1] .= ''.($nbTasks).'';
+ if ($nbTasks > 0) {
+ $head[$h][1] .= ''.($nbTasks).'';
+ }
$head[$h][2] = 'tasks';
$h++;
@@ -73,15 +76,20 @@ function project_prepare_head(Project $project)
$sql .= " WHERE t.fk_task = pt.rowid";
$sql .= " AND pt.fk_projet =".$project->id;
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $db->fetch_object($resql);
- if ($obj) $nbTimeSpent = 1;
- } else dol_print_error($db);
+ if ($obj) {
+ $nbTimeSpent = 1;
+ }
+ } else {
+ dol_print_error($db);
+ }
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$project->id;
$head[$h][1] = $langs->trans("TimeSpent");
- if ($nbTimeSpent > 0) $head[$h][1] .= '...';
+ if ($nbTimeSpent > 0) {
+ $head[$h][1] .= '...';
+ }
$head[$h][2] = 'timespent';
$h++;
}
@@ -89,34 +97,75 @@ function project_prepare_head(Project $project)
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
|| !empty($conf->propal->enabled) || !empty($conf->commande->enabled)
|| !empty($conf->facture->enabled) || !empty($conf->contrat->enabled)
- || !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled))
- {
+ || !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled)) {
$count = 0;
- if (!empty($conf->propal->enabled)) $count += $project->getElementCount('propal', 'propal');
- if (!empty($conf->commande->enabled)) $count += $project->getElementCount('order', 'commande');
- if (!empty($conf->facture->enabled)) $count += $project->getElementCount('invoice', 'facture');
- if (!empty($conf->facture->enabled)) $count += $project->getElementCount('invoice_predefined', 'facture_rec');
- if (!empty($conf->supplier_proposal->enabled)) $count += $project->getElementCount('proposal_supplier', 'supplier_proposal');
- if (!empty($conf->supplier_order->enabled)) $count += $project->getElementCount('order_supplier', 'commande_fournisseur');
- if (!empty($conf->supplier_invoice->enabled)) $count += $project->getElementCount('invoice_supplier', 'facture_fourn');
- if (!empty($conf->contrat->enabled)) $count += $project->getElementCount('contract', 'contrat');
- if (!empty($conf->ficheinter->enabled)) $count += $project->getElementCount('intervention', 'fichinter');
- if (!empty($conf->expedition->enabled)) $count += $project->getElementCount('shipping', 'expedition');
- if (!empty($conf->mrp->enabled)) $count += $project->getElementCount('mrp', 'mrp_mo', 'fk_project');
- if (!empty($conf->deplacement->enabled)) $count += $project->getElementCount('trip', 'deplacement');
- if (!empty($conf->expensereport->enabled)) $count += $project->getElementCount('expensereport', 'expensereport');
- if (!empty($conf->don->enabled)) $count += $project->getElementCount('donation', 'don');
- if (!empty($conf->loan->enabled)) $count += $project->getElementCount('loan', 'loan');
- if (!empty($conf->tax->enabled)) $count += $project->getElementCount('chargesociales', 'chargesociales');
- if (!empty($conf->projet->enabled)) $count += $project->getElementCount('project_task', 'projet_task');
- if (!empty($conf->stock->enabled)) $count += $project->getElementCount('stock_mouvement', 'stock');
- if (!empty($conf->salaries->enabled)) $count += $project->getElementCount('salaries', 'payment_salary');
- if (!empty($conf->banque->enabled)) $count += $project->getElementCount('variouspayment', 'payment_various');
+ if (!empty($conf->propal->enabled)) {
+ $count += $project->getElementCount('propal', 'propal');
+ }
+ if (!empty($conf->commande->enabled)) {
+ $count += $project->getElementCount('order', 'commande');
+ }
+ if (!empty($conf->facture->enabled)) {
+ $count += $project->getElementCount('invoice', 'facture');
+ }
+ if (!empty($conf->facture->enabled)) {
+ $count += $project->getElementCount('invoice_predefined', 'facture_rec');
+ }
+ if (!empty($conf->supplier_proposal->enabled)) {
+ $count += $project->getElementCount('proposal_supplier', 'supplier_proposal');
+ }
+ if (!empty($conf->supplier_order->enabled)) {
+ $count += $project->getElementCount('order_supplier', 'commande_fournisseur');
+ }
+ if (!empty($conf->supplier_invoice->enabled)) {
+ $count += $project->getElementCount('invoice_supplier', 'facture_fourn');
+ }
+ if (!empty($conf->contrat->enabled)) {
+ $count += $project->getElementCount('contract', 'contrat');
+ }
+ if (!empty($conf->ficheinter->enabled)) {
+ $count += $project->getElementCount('intervention', 'fichinter');
+ }
+ if (!empty($conf->expedition->enabled)) {
+ $count += $project->getElementCount('shipping', 'expedition');
+ }
+ if (!empty($conf->mrp->enabled)) {
+ $count += $project->getElementCount('mrp', 'mrp_mo', 'fk_project');
+ }
+ if (!empty($conf->deplacement->enabled)) {
+ $count += $project->getElementCount('trip', 'deplacement');
+ }
+ if (!empty($conf->expensereport->enabled)) {
+ $count += $project->getElementCount('expensereport', 'expensereport');
+ }
+ if (!empty($conf->don->enabled)) {
+ $count += $project->getElementCount('donation', 'don');
+ }
+ if (!empty($conf->loan->enabled)) {
+ $count += $project->getElementCount('loan', 'loan');
+ }
+ if (!empty($conf->tax->enabled)) {
+ $count += $project->getElementCount('chargesociales', 'chargesociales');
+ }
+ if (!empty($conf->projet->enabled)) {
+ $count += $project->getElementCount('project_task', 'projet_task');
+ }
+ if (!empty($conf->stock->enabled)) {
+ $count += $project->getElementCount('stock_mouvement', 'stock');
+ }
+ if (!empty($conf->salaries->enabled)) {
+ $count += $project->getElementCount('salaries', 'payment_salary');
+ }
+ if (!empty($conf->banque->enabled)) {
+ $count += $project->getElementCount('variouspayment', 'payment_various');
+ }
$head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$project->id;
$head[$h][1] = $langs->trans("ProjectOverview");
- if ($count > 0) $head[$h][1] .= ''.$count.'';
+ if ($count > 0) {
+ $head[$h][1] .= ''.$count.'';
+ }
$head[$h][2] = 'element';
$h++;
}
@@ -127,7 +176,9 @@ function project_prepare_head(Project $project)
$nbConfOrBooth = 1;
$head[$h][0] = DOL_URL_ROOT . '/projet/event.php?id=' . $project->id;
$head[$h][1] = $langs->trans("ConferenceOrBoothTab");
- if ($nbContact > 0) $head[$h][1] .= '' . $nbConfOrBooth . '';
+ if ($nbContact > 0) {
+ $head[$h][1] .= '' . $nbConfOrBooth . '';
+ }
$head[$h][2] = 'eventorganisation';
$h++;
}
@@ -139,14 +190,19 @@ function project_prepare_head(Project $project)
complete_head_from_modules($conf, $langs, $project, $head, $h, 'project');
- if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
- {
+ if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
$nbNote = 0;
- if (!empty($project->note_private)) $nbNote++;
- if (!empty($project->note_public)) $nbNote++;
+ if (!empty($project->note_private)) {
+ $nbNote++;
+ }
+ if (!empty($project->note_public)) {
+ $nbNote++;
+ }
$head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$project->id;
$head[$h][1] = $langs->trans('Notes');
- if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.'';
+ if ($nbNote > 0) {
+ $head[$h][1] .= ''.$nbNote.'';
+ }
$head[$h][2] = 'notes';
$h++;
}
@@ -158,25 +214,27 @@ function project_prepare_head(Project $project)
$nbLinks = Link::count($db, $project->element, $project->id);
$head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$project->id;
$head[$h][1] = $langs->trans('Documents');
- if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).'';
+ if (($nbFiles + $nbLinks) > 0) {
+ $head[$h][1] .= ''.($nbFiles + $nbLinks).'';
+ }
$head[$h][2] = 'document';
$h++;
// Manage discussion
- if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT))
- {
+ if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) {
$nbComments = $project->getNbComments();
$head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$project->id;
$head[$h][1] = $langs->trans("CommentLink");
- if ($nbComments > 0) $head[$h][1] .= ''.$nbComments.'';
+ if ($nbComments > 0) {
+ $head[$h][1] .= ''.$nbComments.'';
+ }
$head[$h][2] = 'project_comment';
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$project->id;
$head[$h][1] .= $langs->trans("Events");
- if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
- {
+ if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$head[$h][1] .= '/';
$head[$h][1] .= $langs->trans("Agenda");
}
@@ -209,7 +267,9 @@ function task_prepare_head($object)
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
$head[$h][1] = $langs->trans("TaskRessourceLinks");
- if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.'';
+ if ($nbContact > 0) {
+ $head[$h][1] .= ''.$nbContact.'';
+ }
$head[$h][2] = 'task_contact';
$h++;
@@ -221,15 +281,20 @@ function task_prepare_head($object)
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
$sql .= " WHERE t.fk_task =".$object->id;
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $db->fetch_object($resql);
- if ($obj) $nbTimeSpent = 1;
- } else dol_print_error($db);
+ if ($obj) {
+ $nbTimeSpent = 1;
+ }
+ } else {
+ dol_print_error($db);
+ }
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
$head[$h][1] = $langs->trans("TimeSpent");
- if ($nbTimeSpent > 0) $head[$h][1] .= '...';
+ if ($nbTimeSpent > 0) {
+ $head[$h][1] .= '...';
+ }
$head[$h][2] = 'task_time';
$h++;
@@ -239,14 +304,19 @@ function task_prepare_head($object)
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'task');
- if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
- {
+ if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
$nbNote = 0;
- if (!empty($object->note_private)) $nbNote++;
- if (!empty($object->note_public)) $nbNote++;
+ if (!empty($object->note_private)) {
+ $nbNote++;
+ }
+ if (!empty($object->note_public)) {
+ $nbNote++;
+ }
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
$head[$h][1] = $langs->trans('Notes');
- if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.'';
+ if ($nbNote > 0) {
+ $head[$h][1] .= ''.$nbNote.'';
+ }
$head[$h][2] = 'task_notes';
$h++;
}
@@ -258,17 +328,20 @@ function task_prepare_head($object)
$nbFiles = count(dol_dir_list($filesdir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][1] = $langs->trans('Documents');
- if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).'';
+ if (($nbFiles + $nbLinks) > 0) {
+ $head[$h][1] .= ''.($nbFiles + $nbLinks).'';
+ }
$head[$h][2] = 'task_document';
$h++;
// Manage discussion
- if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK))
- {
+ if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) {
$nbComments = $object->getNbComments();
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : '');
$head[$h][1] = $langs->trans("CommentLink");
- if ($nbComments > 0) $head[$h][1] .= ''.$nbComments.'';
+ if ($nbComments > 0) {
+ $head[$h][1] .= ''.$nbComments.'';
+ }
$head[$h][2] = 'task_comment';
$h++;
}
@@ -295,26 +368,25 @@ function project_timesheet_prepare_head($mode, $fuser = null)
$param = '';
$param .= ($mode ? '&mode='.$mode : '');
- if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param .= '&search_usertoprocessid='.$fuser->id;
+ if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) {
+ $param .= '&search_usertoprocessid='.$fuser->id;
+ }
- if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERMONTH))
- {
+ if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERMONTH)) {
$head[$h][0] = DOL_URL_ROOT."/projet/activity/permonth.php".($param ? '?'.$param : '');
$head[$h][1] = $langs->trans("InputPerMonth");
$head[$h][2] = 'inputpermonth';
$h++;
}
- if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK))
- {
+ if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) {
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : '');
$head[$h][1] = $langs->trans("InputPerWeek");
$head[$h][2] = 'inputperweek';
$h++;
}
- if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME))
- {
+ if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) {
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param ? '?'.$param : '');
$head[$h][1] = $langs->trans("InputPerDay");
$head[$h][2] = 'inputperday';
@@ -367,6 +439,15 @@ function project_admin_prepare_head()
$head[$h][2] = 'attributes_task';
$h++;
+ if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) {
+ $langs->load("members");
+
+ $head[$h][0] = DOL_URL_ROOT.'/projet/admin/website.php';
+ $head[$h][1] = $langs->trans("BlankSubscriptionForm");
+ $head[$h][2] = 'website';
+ $h++;
+ }
+
complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin', 'remove');
return $head;
@@ -400,7 +481,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
$projectsArrayId = explode(',', $projectsListId);
if ($filterprogresscalc !== '') {
- foreach ($lines as $key=>$line) {
+ foreach ($lines as $key => $line) {
if (!empty($line->planned_workload) && !empty($line->duration)) {
$filterprogresscalc = str_replace(' = ', ' == ', $filterprogresscalc);
if (!eval($filterprogresscalc)) {
@@ -415,8 +496,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
// We declare counter as global because we want to edit them into recursive call
global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned, $total_projectlinesa_declared_if_planned, $total_projectlinesa_tobill, $total_projectlinesa_billed;
- if ($level == 0)
- {
+ if ($level == 0) {
$total_projectlinesa_spent = 0;
$total_projectlinesa_planned = 0;
$total_projectlinesa_spent_if_planned = 0;
@@ -425,31 +505,28 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
$total_projectlinesa_billed = 0;
}
- for ($i = 0; $i < $numlines; $i++)
- {
- if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines
+ for ($i = 0; $i < $numlines; $i++) {
+ if ($parent == 0 && $level >= 0) {
+ $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines
+ }
// Process line
// print "i:".$i."-".$lines[$i]->fk_project.' ';
- if ($lines[$i]->fk_parent == $parent || $level < 0) // if $level = -1, we dont' use sublevel recursion, we show all lines
- {
+ if ($lines[$i]->fk_parent == $parent || $level < 0) { // if $level = -1, we dont' use sublevel recursion, we show all lines
// Show task line.
$showline = 1;
$showlineingray = 0;
// If there is filters to use
- if (is_array($taskrole))
- {
+ if (is_array($taskrole)) {
// If task not legitimate to show, search if a legitimate task exists later in tree
- if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent)
- {
+ if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) {
// So search if task has a subtask legitimate to show
$foundtaskforuserdeeper = 0;
searchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole);
//print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.' ';
- if ($foundtaskforuserdeeper > 0)
- {
+ if ($foundtaskforuserdeeper > 0) {
$showlineingray = 1; // We will show line but in gray
} else {
$showline = 0; // No reason to show line
@@ -458,11 +535,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
} else {
// Caller did not ask to filter on tasks of a specific user (this probably means he want also tasks of all users, into public project
// or into all other projects if user has permission to).
- if (empty($user->rights->projet->all->lire))
- {
+ if (empty($user->rights->projet->all->lire)) {
// User is not allowed on this project and project is not public, so we hide line
- if (!in_array($lines[$i]->fk_project, $projectsArrayId))
- {
+ if (!in_array($lines[$i]->fk_project, $projectsArrayId)) {
// Note that having a user assigned to a task into a project user has no permission on, should not be possible
// because assignement on task can be done only on contact of project.
// If assignement was done and after, was removed from contact of project, then we can hide the line.
@@ -471,11 +546,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
}
}
- if ($showline)
- {
+ if ($showline) {
// Break on a new project
- if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
- {
+ if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
$var = !$var;
$lastprojectid = $lines[$i]->fk_project;
}
@@ -502,13 +575,15 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
$taskstatic->duration_effective = $lines[$i]->duration;
- if ($showproject)
- {
+ if ($showproject) {
// Project ref
print " | ";
//if ($showlineingray) print '';
- if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1);
- else print $projectstatic->getNomUrl(1, 'nolink');
+ if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) {
+ print $projectstatic->getNomUrl(1);
+ } else {
+ print $projectstatic->getNomUrl(1, 'nolink');
+ }
//if ($showlineingray) print '';
print " | ";
@@ -533,8 +608,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
// Title of task
if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) {
print "";
- if ($showlineingray)
+ if ($showlineingray) {
print '';
+ }
//else print '';
for ($k = 0; $k < $level; $k++) {
print ' ';
@@ -543,8 +619,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
for ($k = 0; $k < $level; $k++) {
print ' ';
}
- if ($showlineingray)
+ if ($showlineingray) {
print '';
+ }
//else print '';
print " | \n";
}
@@ -566,15 +643,20 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) {
print '';
print dol_print_date($lines[$i]->date_end, 'dayhour');
- if ($taskstatic->hasDelay())
+ if ($taskstatic->hasDelay()) {
print img_warning($langs->trans("Late"));
+ }
print ' | ';
}
$plannedworkloadoutputformat = 'allhourmin';
$timespentoutputformat = 'allhourmin';
- if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
- if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
+ if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) {
+ $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
+ }
+ if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) {
+ $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
+ }
// Planned Workload (in working hours)
if (count($arrayfields) > 0 && !empty($arrayfields['t.planned_workload']['checked'])) {
@@ -593,15 +675,21 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
// Time spent
if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) {
print '';
- if ($showlineingray)
+ if ($showlineingray) {
print '';
- else print '';
- if ($lines[$i]->duration)
+ } else {
+ print '';
+ }
+ if ($lines[$i]->duration) {
print convertSecondToTime($lines[$i]->duration, $timespentoutputformat);
- else print '--:--';
- if ($showlineingray)
+ } else {
+ print '--:--';
+ }
+ if ($showlineingray) {
print '';
- else print '';
+ } else {
+ print '';
+ }
print ' | ';
}
@@ -609,9 +697,11 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) {
print '';
if ($lines[$i]->planned_workload || $lines[$i]->duration) {
- if ($lines[$i]->planned_workload)
+ if ($lines[$i]->planned_workload) {
print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).' %';
- else print ''.$langs->trans('WorkloadNotDefined').'';
+ } else {
+ print ''.$langs->trans('WorkloadNotDefined').'';
+ }
}
print ' | ';
}
@@ -634,8 +724,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
print '';
}
- if ($showbilltime)
- {
+ if ($showbilltime) {
// Time not billed
if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) {
print '';
@@ -662,18 +751,19 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
}
// Contacts of task
- if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST))
- {
+ if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) {
print ' | ';
- foreach (array('internal', 'external') as $source)
- {
+ foreach (array('internal', 'external') as $source) {
$tab = $lines[$i]->liste_contact(-1, $source);
$num = count($tab);
if (!empty($num)) {
foreach ($tab as $contacttask) {
//var_dump($contacttask);
- if ($source == 'internal') $c = new User($db);
- else $c = new Contact($db);
+ if ($source == 'internal') {
+ $c = new User($db);
+ } else {
+ $c = new Contact($db);
+ }
$c->fetch($contacttask['id']);
print $c->getNomUrl(1).' ('.$contacttask['libelle'].') ';
}
@@ -696,19 +786,26 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
print " | \n";
- if (!$showlineingray) $inc++;
+ if (!$showlineingray) {
+ $inc++;
+ }
- if ($level >= 0) // Call sublevels
- {
+ if ($level >= 0) { // Call sublevels
$level++;
- if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, $filterprogresscalc, $showbilltime, $arrayfields);
+ if ($lines[$i]->id) {
+ projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick, $projectidfortotallink, $filterprogresscalc, $showbilltime, $arrayfields);
+ }
$level--;
}
$total_projectlinesa_spent += $lines[$i]->duration;
$total_projectlinesa_planned += $lines[$i]->planned_workload;
- if ($lines[$i]->planned_workload) $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
- if ($lines[$i]->planned_workload) $total_projectlinesa_declared_if_planned += $lines[$i]->planned_workload * $lines[$i]->progress / 100;
+ if ($lines[$i]->planned_workload) {
+ $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
+ }
+ if ($lines[$i]->planned_workload) {
+ $total_projectlinesa_declared_if_planned += $lines[$i]->planned_workload * $lines[$i]->progress / 100;
+ }
}
} else {
//$level--;
@@ -716,14 +813,21 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
}
if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0)
- && $level <= 0)
- {
+ && $level <= 0) {
print '';
print '| '.$langs->trans("Total").' | ';
- if ($showproject) print ' | | ';
- if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) print ' | ';
- if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) print ' | ';
- if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) print ' | ';
+ if ($showproject) {
+ print ' | | ';
+ }
+ if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) {
+ print ' | ';
+ }
+ if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) {
+ print ' | ';
+ }
+ if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) {
+ print ' | ';
+ }
if (count($arrayfields) > 0 && !empty($arrayfields['t.planned_workload']['checked'])) {
print '';
print convertSecondToTime($total_projectlinesa_planned, 'allhourmin');
@@ -731,11 +835,13 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
}
if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) {
print ' | ';
- if ($projectidfortotallink > 0)
+ if ($projectidfortotallink > 0) {
print '';
+ }
print convertSecondToTime($total_projectlinesa_spent, 'allhourmin');
- if ($projectidfortotallink > 0)
+ if ($projectidfortotallink > 0) {
print '';
+ }
print ' | ';
}
@@ -764,14 +870,16 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) {
print '';
- if ($total_projectlinesa_planned)
+ if ($total_projectlinesa_planned) {
print $totalCalculatedProgress.' %';
+ }
print ' | ';
}
if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) {
print '';
- if ($total_projectlinesa_planned)
+ if ($total_projectlinesa_planned) {
print ''.$totalAverageDeclaredProgress.' %';
+ }
print ' | ';
}
@@ -789,8 +897,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
print '';
}
- if ($showbilltime)
- {
+ if ($showbilltime) {
if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) {
print '';
print convertSecondToTime($total_projectlinesa_tobill, 'allhourmin');
@@ -803,8 +910,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
}
}
// Contacts of task
- if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST))
- {
+ if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) {
print ' | | ';
}
print ' | ';
@@ -845,45 +951,40 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec
$numlines = count($lines);
// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
- if ($parent == 0) // Always and only if at first level
- {
- for ($i = 0; $i < $numlines; $i++)
- {
- if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i];
+ if ($parent == 0) { // Always and only if at first level
+ for ($i = 0; $i < $numlines; $i++) {
+ if ($lines[$i]->fk_task_parent) {
+ $lineswithoutlevel0[] = $lines[$i];
+ }
}
}
- if (empty($oldprojectforbreak))
- {
+ if (empty($oldprojectforbreak)) {
$oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break
}
//dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
- for ($i = 0; $i < $numlines; $i++)
- {
- if ($parent == 0) $level = 0;
+ for ($i = 0; $i < $numlines; $i++) {
+ if ($parent == 0) {
+ $level = 0;
+ }
//if ($lines[$i]->fk_task_parent == $parent)
//{
// If we want all or we have a role on task, we show it
- if (empty($mine) || !empty($tasksrole[$lines[$i]->id]))
- {
+ if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
// Break on a new project
- if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
- {
+ if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
$lastprojectid = $lines[$i]->fk_project;
- if ($preselectedday)
- {
+ if ($preselectedday) {
$projectstatic->id = $lines[$i]->fk_project;
}
}
- if (empty($workloadforid[$projectstatic->id]))
- {
- if ($preselectedday)
- {
+ if (empty($workloadforid[$projectstatic->id])) {
+ if ($preselectedday) {
$projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
$workloadforid[$projectstatic->id] = 1;
}
@@ -905,13 +1006,11 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec
$thirdpartystatic->name = $lines[$i]->thirdparty_name;
$thirdpartystatic->email = $lines[$i]->thirdparty_email;
- if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id))
- {
+ if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
print ' '."\n";
print '| ';
print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
- if ($projectstatic->title)
- {
+ if ($projectstatic->title) {
print ' - ';
print $projectstatic->title;
}
@@ -919,7 +1018,9 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec
print ' | ';
}
- if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id;
+ if ($oldprojectforbreak != -1) {
+ $oldprojectforbreak = $projectstatic->id;
+ }
print ''."\n";
@@ -932,8 +1033,7 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec
// Project
print "";
- if ($oldprojectforbreak == -1)
- {
+ if ($oldprojectforbreak == -1) {
print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
print ' '.$projectstatic->title;
}
@@ -941,17 +1041,23 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec
// Thirdparty
print ' | ';
- if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10);
+ if ($thirdpartystatic->id > 0) {
+ print $thirdpartystatic->getNomUrl(1, 'project', 10);
+ }
print ' | ';
// Ref
print '';
print '';
- for ($k = 0; $k < $level; $k++) print " ";
+ for ($k = 0; $k < $level; $k++) {
+ print " ";
+ }
print $taskstatic->getNomUrl(1, 'withproject', 'time');
// Label task
print ' ';
- for ($k = 0; $k < $level; $k++) print " ";
+ for ($k = 0; $k < $level; $k++) {
+ print " ";
+ }
print $taskstatic->label;
//print " ";
//for ($k = 0 ; $k < $level ; $k++) print " ";
@@ -968,14 +1074,12 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec
//var_dump($lines[$i]);
//var_dump($projectsrole[$lines[$i]->fk_project]);
// If at least one role for project
- if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
- {
+ if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
$disabledproject = 0;
$disabledtask = 0;
}
// If $restricteditformytask is on and I have no role on task, i disable edit
- if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
- {
+ if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
$disabledtask = 1;
}
@@ -985,9 +1089,13 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec
print ' | ';
$cssonholiday = '';
- if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday ';
- elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning ';
- elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon ';
+ if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) {
+ $cssonholiday .= 'onholidayallday ';
+ } elseif (!$isavailable[$preselectedday]['morning']) {
+ $cssonholiday .= 'onholidaymorning ';
+ } elseif (!$isavailable[$preselectedday]['afternoon']) {
+ $cssonholiday .= 'onholidayafternoon ';
+ }
// Duration
print '';
@@ -996,7 +1104,9 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec
$totalforeachline[$preselectedday] += $lines[$i]->timespent_duration;
$alreadyspent = '';
- if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
+ if ($dayWorkLoad > 0) {
+ $alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
+ }
print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin');
@@ -1074,54 +1184,47 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$numlines = count($lines);
// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
- if ($parent == 0) // Always and only if at first level
- {
- for ($i = 0; $i < $numlines; $i++)
- {
- if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i];
+ if ($parent == 0) { // Always and only if at first level
+ for ($i = 0; $i < $numlines; $i++) {
+ if ($lines[$i]->fk_task_parent) {
+ $lineswithoutlevel0[] = $lines[$i];
+ }
}
}
- if (empty($oldprojectforbreak))
- {
+ if (empty($oldprojectforbreak)) {
$oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break
}
//dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
- for ($i = 0; $i < $numlines; $i++)
- {
- if ($parent == 0) $level = 0;
+ for ($i = 0; $i < $numlines; $i++) {
+ if ($parent == 0) {
+ $level = 0;
+ }
- if ($lines[$i]->fk_task_parent == $parent)
- {
+ if ($lines[$i]->fk_task_parent == $parent) {
$obj = &$lines[$i]; // To display extrafields
// If we want all or we have a role on task, we show it
- if (empty($mine) || !empty($tasksrole[$lines[$i]->id]))
- {
+ if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
- if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) // we have no role on task and we request to hide such cases
- {
+ if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases
continue;
}
// Break on a new project
- if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
- {
+ if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
$lastprojectid = $lines[$i]->fk_project;
- if ($preselectedday)
- {
+ if ($preselectedday) {
$projectstatic->id = $lines[$i]->fk_project;
}
}
- if (empty($workloadforid[$projectstatic->id]))
- {
- if ($preselectedday)
- {
+ if (empty($workloadforid[$projectstatic->id])) {
+ if ($preselectedday) {
$projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
- $workloadforid[$projectstatic->id] = 1;
+ $workloadforid[$projectstatic->id] = 1;
}
}
@@ -1141,91 +1244,98 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$thirdpartystatic->name = $lines[$i]->thirdparty_name;
$thirdpartystatic->email = $lines[$i]->thirdparty_email;
- if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id))
- {
+ if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
$addcolspan = 0;
- if (!empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++;
- if (!empty($arrayfields['t.progress']['checked'])) $addcolspan++;
- foreach ($arrayfields as $key => $val)
- {
- if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++;
+ if (!empty($arrayfields['t.planned_workload']['checked'])) {
+ $addcolspan++;
+ }
+ if (!empty($arrayfields['t.progress']['checked'])) {
+ $addcolspan++;
+ }
+ foreach ($arrayfields as $key => $val) {
+ if ($val['checked'] && substr($key, 0, 5) == 'efpt.') {
+ $addcolspan++;
+ }
}
print ' | '."\n";
print '';
print $projectstatic->getNomUrl(1, '', 0, ''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
- if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1);
- if ($projectstatic->title)
- {
+ if ($thirdpartystatic->id > 0) {
+ print ' - '.$thirdpartystatic->getNomUrl(1);
+ }
+ if ($projectstatic->title) {
print ' - ';
print ''.$projectstatic->title.'';
}
/*
- $colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
- print '';
+ $colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
+ print '';
- print '';
+ print ' ';
- // PROJECT fields
- if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
- if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
- if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
- if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
- if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
+ // PROJECT fields
+ if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
+ if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
+ if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
+ if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
+ if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
- $extrafieldsobjectkey='projet';
- $extrafieldsobjectprefix='efp.';
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
+ $extrafieldsobjectkey='projet';
+ $extrafieldsobjectprefix='efp.';
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
- print ' ';
- print '';
+ print ' ';
+ print '';
- // PROJECT fields
- if (! empty($arrayfields['p.fk_opp_status']['checked']))
- {
- print '| ';
- $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
- if ($code) print $langs->trans("OppStatus".$code);
- print " | \n";
- }
- if (! empty($arrayfields['p.opp_amount']['checked']))
- {
- print '';
- print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
- print " | \n";
- }
- if (! empty($arrayfields['p.opp_percent']['checked']))
- {
- print '';
- print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
- print " | \n";
- }
- if (! empty($arrayfields['p.budget_amount']['checked']))
- {
- print '';
- print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
- print " | \n";
- }
- if (! empty($arrayfields['p.usage_bill_time']['checked']))
- {
- print '';
- print yn($lines[$i]->usage_bill_time);
- print " | \n";
- }
+ // PROJECT fields
+ if (! empty($arrayfields['p.fk_opp_status']['checked']))
+ {
+ print '';
+ $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
+ if ($code) print $langs->trans("OppStatus".$code);
+ print " | \n";
+ }
+ if (! empty($arrayfields['p.opp_amount']['checked']))
+ {
+ print '';
+ print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
+ print " | \n";
+ }
+ if (! empty($arrayfields['p.opp_percent']['checked']))
+ {
+ print '';
+ print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
+ print " | \n";
+ }
+ if (! empty($arrayfields['p.budget_amount']['checked']))
+ {
+ print '';
+ print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
+ print " | \n";
+ }
+ if (! empty($arrayfields['p.usage_bill_time']['checked']))
+ {
+ print '';
+ print yn($lines[$i]->usage_bill_time);
+ print " | \n";
+ }
- $extrafieldsobjectkey='projet';
- $extrafieldsobjectprefix='efp.';
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+ $extrafieldsobjectkey='projet';
+ $extrafieldsobjectprefix='efp.';
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- print ' ';
- print ' ';
+ print '';
+ print ' ';
*/
print ' | ';
print ' ';
}
- if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id;
+ if ($oldprojectforbreak != -1) {
+ $oldprojectforbreak = $projectstatic->id;
+ }
print ''."\n";
@@ -1237,30 +1347,36 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
*/
// Project
- if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT))
- {
+ if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
print "| ";
- if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
+ if ($oldprojectforbreak == -1) {
+ print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
+ }
print " | ";
}
// Thirdparty
- if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT))
- {
+ if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
print '';
- if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10);
+ if ($thirdpartystatic->id > 0) {
+ print $thirdpartystatic->getNomUrl(1, 'project', 10);
+ }
print ' | ';
}
// Ref
print '';
print '';
- for ($k = 0; $k < $level; $k++) print '';
+ for ($k = 0; $k < $level; $k++) {
+ print ' ';
+ }
print $taskstatic->getNomUrl(1, 'withproject', 'time');
// Label task
print ' ';
print ''.$taskstatic->label.'';
- for ($k = 0; $k < $level; $k++) print " ";
+ for ($k = 0; $k < $level; $k++) {
+ print " ";
+ }
print " | \n";
// TASK extrafields
@@ -1269,17 +1385,18 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Planned Workload
- if (!empty($arrayfields['t.planned_workload']['checked']))
- {
+ if (!empty($arrayfields['t.planned_workload']['checked'])) {
print '';
- if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
- else print '--:--';
+ if ($lines[$i]->planned_workload) {
+ print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
+ } else {
+ print '--:--';
+ }
print ' | ';
}
// Progress declared %
- if (!empty($arrayfields['t.progress']['checked']))
- {
+ if (!empty($arrayfields['t.progress']['checked'])) {
print '';
print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
print ' | ';
@@ -1288,19 +1405,23 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
// Time spent by everybody
print '';
// $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user
- if ($lines[$i]->duration)
- {
+ if ($lines[$i]->duration) {
print '';
print convertSecondToTime($lines[$i]->duration, 'allhourmin');
print '';
- } else print '--:--';
+ } else {
+ print '--:--';
+ }
print " | \n";
// Time spent by user
print '';
$tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
- if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
- else print '--:--';
+ if ($tmptimespent['total_duration']) {
+ print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
+ } else {
+ print '--:--';
+ }
print " | \n";
$disabledproject = 1; $disabledtask = 1;
@@ -1308,14 +1429,12 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
//var_dump($lines[$i]);
//var_dump($projectsrole[$lines[$i]->fk_project]);
// If at least one role for project
- if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
- {
+ if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) {
$disabledproject = 0;
$disabledtask = 0;
}
// If $restricteditformytask is on and I have no role on task, i disable edit
- if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
- {
+ if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) {
$disabledtask = 1;
}
@@ -1326,9 +1445,13 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
print '';
$cssonholiday = '';
- if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday ';
- elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning ';
- elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon ';
+ if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) {
+ $cssonholiday .= 'onholidayallday ';
+ } elseif (!$isavailable[$preselectedday]['morning']) {
+ $cssonholiday .= 'onholidaymorning ';
+ } elseif (!$isavailable[$preselectedday]['afternoon']) {
+ $cssonholiday .= 'onholidayafternoon ';
+ }
global $daytoparse;
$tmparray = dol_getdate($daytoparse, true); // detail of current day
@@ -1336,8 +1459,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$idw = ($tmparray['wday'] - (empty($conf->global->MAIN_START_WEEK) ? 0 : 1));
global $numstartworkingday, $numendworkingday;
$cssweekend = '';
- if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css.
- {
+ if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css.
$cssweekend = 'weekend';
}
@@ -1347,7 +1469,9 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$totalforeachday[$preselectedday] += $dayWorkLoad;
$alreadyspent = '';
- if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
+ if ($dayWorkLoad > 0) {
+ $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin');
+ }
$idw = 0;
@@ -1377,14 +1501,16 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
// Warning
print '';
- if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
- elseif ($disabledtask)
- {
- $titleassigntask = $langs->trans("AssignTaskToMe");
- if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
+ if ((!$lines[$i]->public) && $disabledproject) {
+ print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
+ } elseif ($disabledtask) {
+ $titleassigntask = $langs->trans("AssignTaskToMe");
+ if ($fuser->id != $user->id) {
+ $titleassigntask = $langs->trans("AssignTaskToUser", '...');
+ }
- print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
- }
+ print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
+ }
print ' | ';
print " \n";
@@ -1392,15 +1518,13 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$inc++;
$level++;
- if ($lines[$i]->id > 0)
- {
+ if ($lines[$i]->id > 0) {
//var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
//var_dump($totalforeachday);
$ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
//var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
//var_dump($ret);
- foreach ($ret as $key => $val)
- {
+ foreach ($ret as $key => $val) {
$totalforeachday[$key] += $val;
}
//var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
@@ -1448,50 +1572,45 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$lineswithoutlevel0 = array();
// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
- if ($parent == 0) // Always and only if at first level
- {
- for ($i = 0; $i < $numlines; $i++)
- {
- if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i];
+ if ($parent == 0) { // Always and only if at first level
+ for ($i = 0; $i < $numlines; $i++) {
+ if ($lines[$i]->fk_task_parent) {
+ $lineswithoutlevel0[] = $lines[$i];
+ }
}
}
//dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
- if (empty($oldprojectforbreak))
- {
+ if (empty($oldprojectforbreak)) {
$oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break
}
- for ($i = 0; $i < $numlines; $i++)
- {
- if ($parent == 0) $level = 0;
+ for ($i = 0; $i < $numlines; $i++) {
+ if ($parent == 0) {
+ $level = 0;
+ }
- if ($lines[$i]->fk_task_parent == $parent)
- {
+ if ($lines[$i]->fk_task_parent == $parent) {
$obj = &$lines[$i]; // To display extrafields
// If we want all or we have a role on task, we show it
- if (empty($mine) || !empty($tasksrole[$lines[$i]->id]))
- {
+ if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) {
//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
- if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) // we have no role on task and we request to hide such cases
- {
+ if ($restricteditformytask == 2 && empty($tasksrole[$lines[$i]->id])) { // we have no role on task and we request to hide such cases
continue;
}
// Break on a new project
- if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
- {
+ if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
$lastprojectid = $lines[$i]->fk_project;
$projectstatic->id = $lines[$i]->fk_project;
}
//var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
//var_dump($projectstatic->weekWorkLoadPerTask);
- if (empty($workloadforid[$projectstatic->id]))
- {
+ if (empty($workloadforid[$projectstatic->id])) {
$projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
$workloadforid[$projectstatic->id] = 1;
}
@@ -1515,22 +1634,27 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$thirdpartystatic->name = $lines[$i]->thirdparty_name;
$thirdpartystatic->email = $lines[$i]->thirdparty_email;
- if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id))
- {
+ if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) {
$addcolspan = 0;
- if (!empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++;
- if (!empty($arrayfields['t.progress']['checked'])) $addcolspan++;
- foreach ($arrayfields as $key => $val)
- {
- if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++;
+ if (!empty($arrayfields['t.planned_workload']['checked'])) {
+ $addcolspan++;
+ }
+ if (!empty($arrayfields['t.progress']['checked'])) {
+ $addcolspan++;
+ }
+ foreach ($arrayfields as $key => $val) {
+ if ($val['checked'] && substr($key, 0, 5) == 'efpt.') {
+ $addcolspan++;
+ }
}
print ''."\n";
print '| ';
print $projectstatic->getNomUrl(1, '', 0, ''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
- if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1);
- if ($projectstatic->title)
- {
+ if ($thirdpartystatic->id > 0) {
+ print ' - '.$thirdpartystatic->getNomUrl(1);
+ }
+ if ($projectstatic->title) {
print ' - ';
print ''.$projectstatic->title.'';
}
@@ -1541,65 +1665,67 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
print ' | ';
// PROJECT fields
- if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
- if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
- if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
- if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
- if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
+ if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
+ if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
+ if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
+ if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
+ if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
- $extrafieldsobjectkey='projet';
- $extrafieldsobjectprefix='efp.';
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
+ $extrafieldsobjectkey='projet';
+ $extrafieldsobjectprefix='efp.';
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
- print ' ';
- print '';
+ print ' ';
+ print '';
- // PROJECT fields
- if (! empty($arrayfields['p.fk_opp_status']['checked']))
- {
- print '| ';
- $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
- if ($code) print $langs->trans("OppStatus".$code);
- print " | \n";
- }
- if (! empty($arrayfields['p.opp_amount']['checked']))
- {
- print '';
- print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
- print " | \n";
- }
- if (! empty($arrayfields['p.opp_percent']['checked']))
- {
- print '';
- print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
- print " | \n";
- }
- if (! empty($arrayfields['p.budget_amount']['checked']))
- {
- print '';
- print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
- print " | \n";
- }
- if (! empty($arrayfields['p.usage_bill_time']['checked']))
- {
- print '';
- print yn($lines[$i]->usage_bill_time);
- print " | \n";
- }
+ // PROJECT fields
+ if (! empty($arrayfields['p.fk_opp_status']['checked']))
+ {
+ print '';
+ $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
+ if ($code) print $langs->trans("OppStatus".$code);
+ print " | \n";
+ }
+ if (! empty($arrayfields['p.opp_amount']['checked']))
+ {
+ print '';
+ print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
+ print " | \n";
+ }
+ if (! empty($arrayfields['p.opp_percent']['checked']))
+ {
+ print '';
+ print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
+ print " | \n";
+ }
+ if (! empty($arrayfields['p.budget_amount']['checked']))
+ {
+ print '';
+ print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
+ print " | \n";
+ }
+ if (! empty($arrayfields['p.usage_bill_time']['checked']))
+ {
+ print '';
+ print yn($lines[$i]->usage_bill_time);
+ print " | \n";
+ }
- $extrafieldsobjectkey='projet';
- $extrafieldsobjectprefix='efp.';
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+ $extrafieldsobjectkey='projet';
+ $extrafieldsobjectprefix='efp.';
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- print ' ';
- print ' ';
+ print ' |