'.($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')).'
';
}
@@ -410,16 +411,14 @@ class FormTicket
}
// Notify thirdparty at creation
- if (empty($this->ispublic))
- {
+ if (empty($this->ispublic)) {
print ' | ';
print img_picto('', 'project').$formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
@@ -429,14 +428,15 @@ class FormTicket
// Other attributes
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $ticketstat, $this->action); // Note that $action and $object may have been modified by hook
- if (empty($reshook))
- {
+ if (empty($reshook)) {
print $ticketstat->showOptionals($extrafields, 'create');
}
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..8f1c457cd15 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';
@@ -400,7 +472,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 +487,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 +496,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 +526,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 +537,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 +566,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 +599,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 +610,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 +634,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 +666,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 +688,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 +715,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 +742,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 +777,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 +804,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 +826,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 +861,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 +888,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 +901,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 +942,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 +997,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 +1009,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 +1024,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 +1032,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 +1065,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 +1080,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 +1095,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 +1175,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 +1235,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 +1338,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 +1376,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 +1396,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 +1420,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 +1436,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 +1450,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 +1460,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 +1492,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 +1509,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 +1563,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 +1625,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 +1656,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 ' |
';
+ print '';
*/
print '';
print '';
}
- if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id;
+ if ($oldprojectforbreak != -1) {
+ $oldprojectforbreak = $projectstatic->id;
+ }
print ''."\n";
// User
@@ -1908,18 +2035,25 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
// 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";
// Planned Workload
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 %
@@ -1930,19 +2064,23 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
// 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;
@@ -1950,14 +2088,12 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
//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;
}
@@ -1970,20 +2106,20 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
foreach ($TFirstDay as &$fday) {
$fday--;
}
- foreach ($TWeek as $weekNb)
- {
+ foreach ($TWeek as $weekNb) {
$weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id];
$totalforeachweek[$weekNb] += $weekWorkLoad;
$alreadyspent = '';
- if ($weekWorkLoad > 0) $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin');
+ if ($weekWorkLoad > 0) {
+ $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin');
+ }
$alttitle = $langs->trans("AddHereTimeSpentForWeek", $weekNb);
$tableCell = '';
$placeholder = '';
- if ($alreadyspent)
- {
+ if ($alreadyspent) {
$tableCell .= '';
//$placeholder=' placeholder="00:00"';
//$tableCell.='+';
@@ -1999,11 +2135,13 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
// Warning
print ' | ';
- if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
- elseif ($disabledtask)
- {
+ 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 ($fuser->id != $user->id) {
+ $titleassigntask = $langs->trans("AssignTaskToUser", '...');
+ }
print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
}
@@ -2015,15 +2153,13 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
// Call to show task with a lower level (task under the current task)
$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 = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek);
//var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
//var_dump($ret);
- foreach ($ret as $key => $val)
- {
+ foreach ($ret as $key => $val) {
$totalforeachweek[$key] += $val;
}
//var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
@@ -2052,14 +2188,11 @@ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
{
//print 'Search in line with parent id = '.$parent.' ';
$numlines = count($lines);
- for ($i = 0; $i < $numlines; $i++)
- {
+ for ($i = 0; $i < $numlines; $i++) {
// Process line $lines[$i]
- if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent)
- {
+ if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) {
// If task is legitimate to show, no more need to search deeper
- if (isset($taskrole[$lines[$i]->id]))
- {
+ if (isset($taskrole[$lines[$i]->id])) {
//print 'Found a legitimate task id='.$lines[$i]->id.' ';
$inc++;
return $inc;
@@ -2068,7 +2201,9 @@ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole);
//print 'Found inc='.$inc.' ';
- if ($inc > 0) return $inc;
+ if ($inc > 0) {
+ return $inc;
+ }
}
}
@@ -2119,7 +2254,9 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
$project_year_filter = 0;
$title = $langs->trans("Projects");
- if (strcmp($status, '') && $status >= 0) $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$status]);
+ if (strcmp($status, '') && $status >= 0) {
+ $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$status]);
+ }
$arrayidtypeofcontact = array();
@@ -2127,8 +2264,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
print '';
$sql = " FROM ".MAIN_DB_PREFIX."projet as p";
- if ($mytasks)
- {
+ if ($mytasks) {
$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
$sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
$sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
@@ -2137,27 +2273,24 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
}
$sql .= " WHERE p.entity IN (".getEntity('project').")";
$sql .= " AND p.rowid IN (".$projectsListId.")";
- if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
- if ($mytasks)
- {
+ if ($socid) {
+ $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
+ }
+ if ($mytasks) {
$sql .= " AND p.rowid = t.fk_projet";
$sql .= " AND ec.element_id = t.rowid";
$sql .= " AND ec.fk_socpeople = ".$user->id;
$sql .= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
$sql .= " AND ctc.element = 'project_task'";
}
- if ($status >= 0)
- {
+ if ($status >= 0) {
$sql .= " AND p.fk_statut = ".(int) $status;
}
- if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE))
- {
+ if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
$project_year_filter = GETPOST("project_year_filter");
//Check if empty or invalid year. Wildcard ignores the sql check
- if ($project_year_filter != "*")
- {
- if (empty($project_year_filter) || !ctype_digit($project_year_filter))
- {
+ if ($project_year_filter != "*") {
+ if (empty($project_year_filter) || !ctype_digit($project_year_filter)) {
$project_year_filter = date("Y");
}
$sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")";
@@ -2170,18 +2303,20 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
$sql1 = "SELECT p.rowid as projectid";
$sql1 .= $sql;
$resql = $db->query($sql1);
- if ($resql)
- {
+ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
- while ($i < $num)
- {
+ while ($i < $num) {
$objp = $db->fetch_object($resql);
$arrayidofprojects[$objp->projectid] = $objp->projectid;
$i++;
}
- } else dol_print_error($db);
- if (empty($arrayidofprojects)) $arrayidofprojects[0] = -1;
+ } else {
+ dol_print_error($db);
+ }
+ if (empty($arrayidofprojects)) {
+ $arrayidofprojects[0] = -1;
+ }
// Get list of project with calculation on tasks
$sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc,";
@@ -2201,8 +2336,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
$sql2 .= " ORDER BY p.title, p.ref";
$resql = $db->query($sql2);
- if ($resql)
- {
+ if ($resql) {
$total_task = 0;
$total_opp_amount = 0;
$ponderated_opp_amount = 0;
@@ -2213,25 +2347,30 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
print '';
print_liste_field_titre($title.''.$num.'', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
- if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
- {
- if (!in_array('prospectionstatus', $hiddenfields)) print_liste_field_titre("OpportunityStatus", "", "", "", "", '', $sortfield, $sortorder, 'right ');
+ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
+ if (!in_array('prospectionstatus', $hiddenfields)) {
+ print_liste_field_titre("OpportunityStatus", "", "", "", "", '', $sortfield, $sortorder, 'right ');
+ }
print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder);
//print_liste_field_titre('OpportunityWeightedAmount', '', '', '', '', 'align="right"', $sortfield, $sortorder);
}
- if (empty($conf->global->PROJECT_HIDE_TASKS))
- {
+ if (empty($conf->global->PROJECT_HIDE_TASKS)) {
print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder);
- if (!in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", '', $sortfield, $sortorder, 'right ');
- if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", '', $sortfield, $sortorder, 'right ');
+ if (!in_array('plannedworkload', $hiddenfields)) {
+ print_liste_field_titre("PlannedWorkload", "", "", "", "", '', $sortfield, $sortorder, 'right ');
+ }
+ if (!in_array('declaredprogress', $hiddenfields)) {
+ print_liste_field_titre("ProgressDeclared", "", "", "", "", '', $sortfield, $sortorder, 'right ');
+ }
+ }
+ if (!in_array('projectstatus', $hiddenfields)) {
+ print_liste_field_titre("Status", "", "", "", "", '', $sortfield, $sortorder, 'right ');
}
- if (!in_array('projectstatus', $hiddenfields)) print_liste_field_titre("Status", "", "", "", "", '', $sortfield, $sortorder, 'right ');
print " \n";
$total_plannedworkload = 0;
$total_declaredprogressworkload = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$objp = $db->fetch_object($resql);
$projectstatic->id = $objp->projectid;
@@ -2240,8 +2379,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
// Check is user has read permission on project
$userAccess = $projectstatic->restrictedProjectArea($user);
- if ($userAccess >= 0)
- {
+ if ($userAccess >= 0) {
$projectstatic->ref = $objp->ref;
$projectstatic->status = $objp->status;
$projectstatic->title = $objp->title;
@@ -2252,12 +2390,13 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
print '';
print $projectstatic->getNomUrl(1, '', 0, '', '-', 0, -1, 'nowraponall');
- if (!in_array('projectlabel', $hiddenfields)) print ' '.dol_trunc($objp->title, 24).'';
+ if (!in_array('projectlabel', $hiddenfields)) {
+ print ' '.dol_trunc($objp->title, 24).'';
+ }
print ' | ';
print '';
- if ($objp->fk_soc > 0)
- {
+ if ($objp->fk_soc > 0) {
$thirdpartystatic->id = $objp->socid;
$thirdpartystatic->name = $objp->socname;
//$thirdpartystatic->name_alias = $objp->name_alias;
@@ -2274,8 +2413,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
}
print ' | ';
- if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
- {
+ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
if (!in_array('prospectionstatus', $hiddenfields)) {
print '';
// Because color of prospection status has no meaning yet, it is used if hidden constant is set
@@ -2309,22 +2447,21 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
$alttext = $langs->trans("OpportunityWeightedAmount").' '.price($opp_weighted_amount, 0, '', 1, -1, 0, $conf->currency);
$ponderated_opp_amount += price2num($opp_weighted_amount);
}
- if ($objp->opp_amount) print ''.price($objp->opp_amount, 0, '', 1, -1, 0, $conf->currency).'';
+ if ($objp->opp_amount) {
+ print ''.price($objp->opp_amount, 0, '', 1, -1, 0, $conf->currency).'';
+ }
print ' | ';
}
- if (empty($conf->global->PROJECT_HIDE_TASKS))
- {
+ if (empty($conf->global->PROJECT_HIDE_TASKS)) {
print ''.$objp->nb.' | ';
$plannedworkload = $objp->planned_workload;
$total_plannedworkload += $plannedworkload;
- if (!in_array('plannedworkload', $hiddenfields))
- {
+ if (!in_array('plannedworkload', $hiddenfields)) {
print ''.($plannedworkload ?convertSecondToTime($plannedworkload) : '').' | ';
}
- if (!in_array('declaredprogress', $hiddenfields))
- {
+ if (!in_array('declaredprogress', $hiddenfields)) {
$declaredprogressworkload = $objp->declared_progess_workload;
$total_declaredprogressworkload += $declaredprogressworkload;
print '';
@@ -2351,8 +2488,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
print ' | ';
print '| '.$langs->trans("Total")." | | ";
- if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
- {
+ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
if (!in_array('prospectionstatus', $hiddenfields)) {
print ' | ';
}
@@ -2361,11 +2497,14 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
print $form->textwithpicto(price($total_opp_amount, 0, '', 1, -1, 0, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc").' : '.price($ponderated_opp_amount, 0, '', 1, -1, 0, $conf->currency));
print '';
}
- if (empty($conf->global->PROJECT_HIDE_TASKS))
- {
+ if (empty($conf->global->PROJECT_HIDE_TASKS)) {
print ''.$total_task.' | ';
- if (!in_array('plannedworkload', $hiddenfields)) print ''.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').' | ';
- if (!in_array('declaredprogress', $hiddenfields)) print ''.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').' | ';
+ if (!in_array('plannedworkload', $hiddenfields)) {
+ print ''.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').' | ';
+ }
+ if (!in_array('declaredprogress', $hiddenfields)) {
+ print ''.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').' | ';
+ }
}
if (!in_array('projectstatus', $hiddenfields)) {
print ' | ';
@@ -2380,8 +2519,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
print " ";
print '';
- if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE))
- {
+ if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
//Add the year filter input
print ' |
-
- |
-
- |
- textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"), 1, 0, '', 0, 2, 'helpvalue1')?>
- textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"), 1, 0, '', 0, 2, 'helpvalue2')?>
- textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"), 1, 0, '', 0, 2, 'helpvalue3')?>
- textwithpicto('', $langs->trans("ExtrafieldParamHelplink").'
'.$langs->trans("Examples").': '.$listofexamplesforlink, 1, 0, '', 0, 2, 'helpvalue4')?>
- textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"), 1, 0, '', 0, 2, 'helpvalue5')?>
- textwithpicto('', $langs->trans("ExtrafieldParamHelpSeparator"), 1, 0, '', 0, 2, 'helpvalue6')?>
- |
-
+
+ |
+
+ |
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"), 1, 0, '', 0, 2, 'helpvalue1')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"), 1, 0, '', 0, 2, 'helpvalue2')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"), 1, 0, '', 0, 2, 'helpvalue3')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelplink").'
'.$langs->trans("Examples").': '.$listofexamplesforlink, 1, 0, '', 0, 2, 'helpvalue4')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"), 1, 0, '', 0, 2, 'helpvalue5')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpSeparator"), 1, 0, '', 0, 2, 'helpvalue6')?>
+ |
+
|
@@ -301,7 +297,7 @@ if (in_array($type, array_keys($typewecanchangeinto)))
multicompany->enabled) { ?>
-