@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * \brief File of predefined functions for HTML forms for order module |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | -require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; |
|
| 25 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Class to manage HTML output components for orders |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param string $hmlname Name of HTML select element |
| 40 | 40 | * @return void |
| 41 | 41 | */ |
| 42 | - public function selectSupplierOrderStatus($selected='', $short=0, $hmlname='order_status') |
|
| 42 | + public function selectSupplierOrderStatus($selected = '', $short = 0, $hmlname = 'order_status') |
|
| 43 | 43 | { |
| 44 | 44 | $options = array(); |
| 45 | 45 | |
@@ -74,18 +74,18 @@ discard block |
||
| 74 | 74 | * @param int $addempty 0=list with no empty value, 1=list with empty value |
| 75 | 75 | * @return array Tableau des sources de commandes |
| 76 | 76 | */ |
| 77 | - public function selectInputMethod($selected='',$htmlname='source_id',$addempty=0) |
|
| 77 | + public function selectInputMethod($selected = '', $htmlname = 'source_id', $addempty = 0) |
|
| 78 | 78 | { |
| 79 | 79 | global $langs; |
| 80 | 80 | |
| 81 | - $listofmethods=array(); |
|
| 81 | + $listofmethods = array(); |
|
| 82 | 82 | |
| 83 | 83 | $sql = "SELECT rowid, code, libelle as label"; |
| 84 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_input_method"; |
|
| 85 | - $sql.= " WHERE active = 1"; |
|
| 84 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_input_method"; |
|
| 85 | + $sql .= " WHERE active = 1"; |
|
| 86 | 86 | |
| 87 | 87 | dol_syslog(get_class($this)."::selectInputMethod", LOG_DEBUG); |
| 88 | - $resql=$this->db->query($sql); |
|
| 88 | + $resql = $this->db->query($sql); |
|
| 89 | 89 | |
| 90 | 90 | if (!$resql) { |
| 91 | 91 | dol_print_error($this->db); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $listofmethods[$obj->rowid] = $langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : $obj->label; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - print Form::selectarray($htmlname,$listofmethods,$selected,$addempty); |
|
| 99 | + print Form::selectarray($htmlname, $listofmethods, $selected, $addempty); |
|
| 100 | 100 | |
| 101 | 101 | return 1; |
| 102 | 102 | } |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | * @param int $fk_user Utilisateur créant le modèle |
| 68 | 68 | * @return void |
| 69 | 69 | */ |
| 70 | - function select_export_model($selected='', $htmlname='exportmodelid', $type='', $useempty=0, $fk_user=null) |
|
| 70 | + function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0, $fk_user = null) |
|
| 71 | 71 | { |
| 72 | 72 | // phpcs:enable |
| 73 | 73 | $sql = "SELECT rowid, label"; |
| 74 | - $sql.= " FROM ".MAIN_DB_PREFIX."export_model"; |
|
| 75 | - $sql.= " WHERE type = '".$type."'"; |
|
| 76 | - if (!empty($fk_user)) $sql.=" AND fk_user=".$fk_user; |
|
| 77 | - $sql.= " ORDER BY rowid"; |
|
| 74 | + $sql .= " FROM ".MAIN_DB_PREFIX."export_model"; |
|
| 75 | + $sql .= " WHERE type = '".$type."'"; |
|
| 76 | + if (!empty($fk_user)) $sql .= " AND fk_user=".$fk_user; |
|
| 77 | + $sql .= " ORDER BY rowid"; |
|
| 78 | 78 | $result = $this->db->query($sql); |
| 79 | 79 | if ($result) |
| 80 | 80 | { |
@@ -119,13 +119,13 @@ discard block |
||
| 119 | 119 | * @param int $useempty Affiche valeur vide dans liste |
| 120 | 120 | * @return void |
| 121 | 121 | */ |
| 122 | - function select_import_model($selected='', $htmlname='importmodelid', $type='', $useempty=0) |
|
| 122 | + function select_import_model($selected = '', $htmlname = 'importmodelid', $type = '', $useempty = 0) |
|
| 123 | 123 | { |
| 124 | 124 | // phpcs:enable |
| 125 | 125 | $sql = "SELECT rowid, label"; |
| 126 | - $sql.= " FROM ".MAIN_DB_PREFIX."import_model"; |
|
| 127 | - $sql.= " WHERE type = '".$type."'"; |
|
| 128 | - $sql.= " ORDER BY rowid"; |
|
| 126 | + $sql .= " FROM ".MAIN_DB_PREFIX."import_model"; |
|
| 127 | + $sql .= " WHERE type = '".$type."'"; |
|
| 128 | + $sql .= " ORDER BY rowid"; |
|
| 129 | 129 | $result = $this->db->query($sql); |
| 130 | 130 | if ($result) |
| 131 | 131 | { |
@@ -168,19 +168,19 @@ discard block |
||
| 168 | 168 | * @param string $htmlname Name of combo list |
| 169 | 169 | * @return integer |
| 170 | 170 | */ |
| 171 | - function select_ecotaxes($selected='', $htmlname='ecotaxe_id') |
|
| 171 | + function select_ecotaxes($selected = '', $htmlname = 'ecotaxe_id') |
|
| 172 | 172 | { |
| 173 | 173 | // phpcs:enable |
| 174 | 174 | global $langs; |
| 175 | 175 | |
| 176 | 176 | $sql = "SELECT e.rowid, e.code, e.label, e.price, e.organization,"; |
| 177 | - $sql.= " c.label as country"; |
|
| 178 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_ecotaxe as e,".MAIN_DB_PREFIX."c_country as c"; |
|
| 179 | - $sql.= " WHERE e.active = 1 AND e.fk_pays = c.rowid"; |
|
| 180 | - $sql.= " ORDER BY country, e.organization ASC, e.code ASC"; |
|
| 177 | + $sql .= " c.label as country"; |
|
| 178 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_ecotaxe as e,".MAIN_DB_PREFIX."c_country as c"; |
|
| 179 | + $sql .= " WHERE e.active = 1 AND e.fk_pays = c.rowid"; |
|
| 180 | + $sql .= " ORDER BY country, e.organization ASC, e.code ASC"; |
|
| 181 | 181 | |
| 182 | 182 | dol_syslog(get_class($this).'::select_ecotaxes', LOG_DEBUG); |
| 183 | - $resql=$this->db->query($sql); |
|
| 183 | + $resql = $this->db->query($sql); |
|
| 184 | 184 | if ($resql) |
| 185 | 185 | { |
| 186 | 186 | print '<select class="flat" name="'.$htmlname.'">'; |
@@ -227,26 +227,26 @@ discard block |
||
| 227 | 227 | * @param string $country_code Country Code |
| 228 | 228 | * @return string HTML select list |
| 229 | 229 | */ |
| 230 | - function select_revenue_stamp($selected='', $htmlname='revenuestamp', $country_code='') |
|
| 230 | + function select_revenue_stamp($selected = '', $htmlname = 'revenuestamp', $country_code = '') |
|
| 231 | 231 | { |
| 232 | 232 | // phpcs:enable |
| 233 | 233 | global $langs; |
| 234 | 234 | |
| 235 | - $out=''; |
|
| 235 | + $out = ''; |
|
| 236 | 236 | |
| 237 | 237 | $sql = "SELECT r.taux, r.revenuestamp_type"; |
| 238 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_revenuestamp as r,".MAIN_DB_PREFIX."c_country as c"; |
|
| 239 | - $sql.= " WHERE r.active = 1 AND r.fk_pays = c.rowid"; |
|
| 240 | - $sql.= " AND c.code = '".$country_code."'"; |
|
| 238 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_revenuestamp as r,".MAIN_DB_PREFIX."c_country as c"; |
|
| 239 | + $sql .= " WHERE r.active = 1 AND r.fk_pays = c.rowid"; |
|
| 240 | + $sql .= " AND c.code = '".$country_code."'"; |
|
| 241 | 241 | |
| 242 | 242 | dol_syslog(get_class($this).'::select_revenue_stamp', LOG_DEBUG); |
| 243 | - $resql=$this->db->query($sql); |
|
| 243 | + $resql = $this->db->query($sql); |
|
| 244 | 244 | if ($resql) |
| 245 | 245 | { |
| 246 | - $out.='<select class="flat" name="'.$htmlname.'">'; |
|
| 246 | + $out .= '<select class="flat" name="'.$htmlname.'">'; |
|
| 247 | 247 | $num = $this->db->num_rows($resql); |
| 248 | 248 | $i = 0; |
| 249 | - $out.='<option value="0"> </option>'."\n"; |
|
| 249 | + $out .= '<option value="0"> </option>'."\n"; |
|
| 250 | 250 | if ($num) |
| 251 | 251 | { |
| 252 | 252 | while ($i < $num) |
@@ -254,19 +254,19 @@ discard block |
||
| 254 | 254 | $obj = $this->db->fetch_object($resql); |
| 255 | 255 | if (($selected && $selected == $obj->taux) || $num == 1) |
| 256 | 256 | { |
| 257 | - $out.='<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent"' : '').' selected>'; |
|
| 257 | + $out .= '<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent"' : '').' selected>'; |
|
| 258 | 258 | } |
| 259 | 259 | else |
| 260 | 260 | { |
| 261 | - $out.='<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent"' : '').'>'; |
|
| 261 | + $out .= '<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent"' : '').'>'; |
|
| 262 | 262 | //print '<option onmouseover="showtip(\''.$obj->libelle.'\')" onMouseout="hidetip()" value="'.$obj->rowid.'">'; |
| 263 | 263 | } |
| 264 | - $out.=$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : ''); |
|
| 265 | - $out.='</option>'; |
|
| 264 | + $out .= $obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : ''); |
|
| 265 | + $out .= '</option>'; |
|
| 266 | 266 | $i++; |
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | - $out.='</select>'; |
|
| 269 | + $out .= '</select>'; |
|
| 270 | 270 | return $out; |
| 271 | 271 | } |
| 272 | 272 | else |
@@ -290,27 +290,27 @@ discard block |
||
| 290 | 290 | * @param int $showempty Add also an empty line |
| 291 | 291 | * @return string HTML select string |
| 292 | 292 | */ |
| 293 | - function select_percent($selected=0,$htmlname='percent',$disabled=0,$increment=5,$start=0,$end=100,$showempty=0) |
|
| 293 | + function select_percent($selected = 0, $htmlname = 'percent', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0) |
|
| 294 | 294 | { |
| 295 | 295 | // phpcs:enable |
| 296 | - $return = '<select class="flat" name="'.$htmlname.'" '.($disabled?'disabled':'').'>'; |
|
| 297 | - if ($showempty) $return.='<option value="-1"'.(($selected == -1 || $selected == '')?' selected':'').'> </option>'; |
|
| 296 | + $return = '<select class="flat" name="'.$htmlname.'" '.($disabled ? 'disabled' : '').'>'; |
|
| 297 | + if ($showempty) $return .= '<option value="-1"'.(($selected == -1 || $selected == '') ? ' selected' : '').'> </option>'; |
|
| 298 | 298 | |
| 299 | - for ($i = $start ; $i <= $end ; $i += $increment) |
|
| 299 | + for ($i = $start; $i <= $end; $i += $increment) |
|
| 300 | 300 | { |
| 301 | 301 | if ($selected != '' && (int) $selected == $i) |
| 302 | 302 | { |
| 303 | - $return.= '<option value="'.$i.'" selected>'; |
|
| 303 | + $return .= '<option value="'.$i.'" selected>'; |
|
| 304 | 304 | } |
| 305 | 305 | else |
| 306 | 306 | { |
| 307 | - $return.= '<option value="'.$i.'">'; |
|
| 307 | + $return .= '<option value="'.$i.'">'; |
|
| 308 | 308 | } |
| 309 | - $return.= $i.' % '; |
|
| 310 | - $return.= '</option>'; |
|
| 309 | + $return .= $i.' % '; |
|
| 310 | + $return .= '</option>'; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - $return.= '</select>'; |
|
| 313 | + $return .= '</select>'; |
|
| 314 | 314 | |
| 315 | 315 | return $return; |
| 316 | 316 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | * @return string Html combo list code |
| 329 | 329 | * @see select_all_categories |
| 330 | 330 | */ |
| 331 | - function select_categories($type, $selected=0, $htmlname='search_categ', $nocateg=0, $showempty=1, $morecss='') |
|
| 331 | + function select_categories($type, $selected = 0, $htmlname = 'search_categ', $nocateg = 0, $showempty = 1, $morecss = '') |
|
| 332 | 332 | { |
| 333 | 333 | // phpcs:enable |
| 334 | 334 | global $conf, $langs; |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | // For backward compatibility |
| 338 | 338 | if (is_numeric($type)) |
| 339 | 339 | { |
| 340 | - dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); |
|
| 340 | + dol_syslog(__METHOD__.': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | // Load list of "categories" |
@@ -348,30 +348,30 @@ discard block |
||
| 348 | 348 | // Enhance with select2 |
| 349 | 349 | if ($conf->use_javascript_ajax) |
| 350 | 350 | { |
| 351 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 351 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
| 352 | 352 | $comboenhancement = ajax_combobox('select_categ_'.$htmlname); |
| 353 | - $moreforfilter.=$comboenhancement; |
|
| 353 | + $moreforfilter .= $comboenhancement; |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | // Print a select with each of them |
| 357 | - $moreforfilter.='<select class="flat minwidth100'.($morecss?' '.$morecss:'').'" id="select_categ_'.$htmlname.'" name="'.$htmlname.'">'; |
|
| 358 | - if ($showempty) $moreforfilter.='<option value="0"> </option>'; // Should use -1 to say nothing |
|
| 357 | + $moreforfilter .= '<select class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" id="select_categ_'.$htmlname.'" name="'.$htmlname.'">'; |
|
| 358 | + if ($showempty) $moreforfilter .= '<option value="0"> </option>'; // Should use -1 to say nothing |
|
| 359 | 359 | |
| 360 | 360 | if (is_array($tab_categs)) |
| 361 | 361 | { |
| 362 | 362 | foreach ($tab_categs as $categ) |
| 363 | 363 | { |
| 364 | - $moreforfilter.='<option value="'.$categ['id'].'"'; |
|
| 365 | - if ($categ['id'] == $selected) $moreforfilter.=' selected'; |
|
| 366 | - $moreforfilter.='>'.dol_trunc($categ['fulllabel'],50,'middle').'</option>'; |
|
| 364 | + $moreforfilter .= '<option value="'.$categ['id'].'"'; |
|
| 365 | + if ($categ['id'] == $selected) $moreforfilter .= ' selected'; |
|
| 366 | + $moreforfilter .= '>'.dol_trunc($categ['fulllabel'], 50, 'middle').'</option>'; |
|
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | if ($nocateg) |
| 370 | 370 | { |
| 371 | 371 | $langs->load("categories"); |
| 372 | - $moreforfilter.='<option value="-2"'.($selected == -2 ? ' selected':'').'>- '.$langs->trans("NotCategorized").' -</option>'; |
|
| 372 | + $moreforfilter .= '<option value="-2"'.($selected == -2 ? ' selected' : '').'>- '.$langs->trans("NotCategorized").' -</option>'; |
|
| 373 | 373 | } |
| 374 | - $moreforfilter.='</select>'; |
|
| 374 | + $moreforfilter .= '</select>'; |
|
| 375 | 375 | |
| 376 | 376 | return $moreforfilter; |
| 377 | 377 | } |
@@ -389,44 +389,44 @@ discard block |
||
| 389 | 389 | * @param string $morecss More CSS |
| 390 | 390 | * @return string Html combo list code |
| 391 | 391 | */ |
| 392 | - function select_salesrepresentatives($selected,$htmlname,$user,$showstatus=0,$showempty=1,$morecss='') |
|
| 392 | + function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '') |
|
| 393 | 393 | { |
| 394 | 394 | // phpcs:enable |
| 395 | - global $conf,$langs; |
|
| 395 | + global $conf, $langs; |
|
| 396 | 396 | $langs->load('users'); |
| 397 | 397 | |
| 398 | 398 | $out = ''; |
| 399 | 399 | // Enhance with select2 |
| 400 | 400 | if ($conf->use_javascript_ajax) |
| 401 | 401 | { |
| 402 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 402 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
| 403 | 403 | |
| 404 | 404 | $comboenhancement = ajax_combobox($htmlname); |
| 405 | 405 | if ($comboenhancement) |
| 406 | 406 | { |
| 407 | - $out.=$comboenhancement; |
|
| 407 | + $out .= $comboenhancement; |
|
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | // Select each sales and print them in a select input |
| 411 | - $out.='<select class="flat'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
|
| 412 | - if ($showempty) $out.='<option value="0"> </option>'; |
|
| 411 | + $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
|
| 412 | + if ($showempty) $out .= '<option value="0"> </option>'; |
|
| 413 | 413 | |
| 414 | 414 | // Get list of users allowed to be viewed |
| 415 | 415 | $sql_usr = "SELECT u.rowid, u.lastname, u.firstname, u.statut, u.login"; |
| 416 | - $sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u"; |
|
| 417 | - $sql_usr.= " WHERE u.entity IN (0,".$conf->entity.")"; |
|
| 418 | - if (empty($user->rights->user->user->lire)) $sql_usr.=" AND u.rowid = ".$user->id; |
|
| 419 | - if (! empty($user->societe_id)) $sql_usr.=" AND u.fk_soc = ".$user->societe_id; |
|
| 416 | + $sql_usr .= " FROM ".MAIN_DB_PREFIX."user as u"; |
|
| 417 | + $sql_usr .= " WHERE u.entity IN (0,".$conf->entity.")"; |
|
| 418 | + if (empty($user->rights->user->user->lire)) $sql_usr .= " AND u.rowid = ".$user->id; |
|
| 419 | + if (!empty($user->societe_id)) $sql_usr .= " AND u.fk_soc = ".$user->societe_id; |
|
| 420 | 420 | // Add existing sales representatives of thirdparty of external user |
| 421 | 421 | if (empty($user->rights->user->user->lire) && $user->societe_id) |
| 422 | 422 | { |
| 423 | - $sql_usr.=" UNION "; |
|
| 424 | - $sql_usr.= "SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut, u2.login"; |
|
| 425 | - $sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u2, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 426 | - $sql_usr.= " WHERE u2.entity IN (0,".$conf->entity.")"; |
|
| 427 | - $sql_usr.= " AND u2.rowid = sc.fk_user AND sc.fk_soc=".$user->societe_id; |
|
| 423 | + $sql_usr .= " UNION "; |
|
| 424 | + $sql_usr .= "SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut, u2.login"; |
|
| 425 | + $sql_usr .= " FROM ".MAIN_DB_PREFIX."user as u2, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 426 | + $sql_usr .= " WHERE u2.entity IN (0,".$conf->entity.")"; |
|
| 427 | + $sql_usr .= " AND u2.rowid = sc.fk_user AND sc.fk_soc=".$user->societe_id; |
|
| 428 | 428 | } |
| 429 | - $sql_usr.= " ORDER BY statut DESC, lastname ASC"; // Do not use 'ORDER BY u.statut' here, not compatible with the UNION. |
|
| 429 | + $sql_usr .= " ORDER BY statut DESC, lastname ASC"; // Do not use 'ORDER BY u.statut' here, not compatible with the UNION. |
|
| 430 | 430 | //print $sql_usr;exit; |
| 431 | 431 | |
| 432 | 432 | $resql_usr = $this->db->query($sql_usr); |
@@ -435,34 +435,34 @@ discard block |
||
| 435 | 435 | while ($obj_usr = $this->db->fetch_object($resql_usr)) |
| 436 | 436 | { |
| 437 | 437 | |
| 438 | - $out.='<option value="'.$obj_usr->rowid.'"'; |
|
| 438 | + $out .= '<option value="'.$obj_usr->rowid.'"'; |
|
| 439 | 439 | |
| 440 | - if ($obj_usr->rowid == $selected) $out.=' selected'; |
|
| 440 | + if ($obj_usr->rowid == $selected) $out .= ' selected'; |
|
| 441 | 441 | |
| 442 | - $out.='>'; |
|
| 443 | - $out.=dolGetFirstLastname($obj_usr->firstname,$obj_usr->lastname); |
|
| 442 | + $out .= '>'; |
|
| 443 | + $out .= dolGetFirstLastname($obj_usr->firstname, $obj_usr->lastname); |
|
| 444 | 444 | // Complete name with more info |
| 445 | - $moreinfo=0; |
|
| 446 | - if (! empty($conf->global->MAIN_SHOW_LOGIN)) |
|
| 445 | + $moreinfo = 0; |
|
| 446 | + if (!empty($conf->global->MAIN_SHOW_LOGIN)) |
|
| 447 | 447 | { |
| 448 | - $out.=($moreinfo?' - ':' (').$obj_usr->login; |
|
| 448 | + $out .= ($moreinfo ? ' - ' : ' (').$obj_usr->login; |
|
| 449 | 449 | $moreinfo++; |
| 450 | 450 | } |
| 451 | 451 | if ($showstatus >= 0) |
| 452 | 452 | { |
| 453 | 453 | if ($obj_usr->statut == 1 && $showstatus == 1) |
| 454 | 454 | { |
| 455 | - $out.=($moreinfo?' - ':' (').$langs->trans('Enabled'); |
|
| 455 | + $out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Enabled'); |
|
| 456 | 456 | $moreinfo++; |
| 457 | 457 | } |
| 458 | 458 | if ($obj_usr->statut == 0) |
| 459 | 459 | { |
| 460 | - $out.=($moreinfo?' - ':' (').$langs->trans('Disabled'); |
|
| 460 | + $out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Disabled'); |
|
| 461 | 461 | $moreinfo++; |
| 462 | 462 | } |
| 463 | 463 | } |
| 464 | - $out.=($moreinfo?')':''); |
|
| 465 | - $out.='</option>'; |
|
| 464 | + $out .= ($moreinfo ? ')' : ''); |
|
| 465 | + $out .= '</option>'; |
|
| 466 | 466 | } |
| 467 | 467 | $this->db->free($resql_usr); |
| 468 | 468 | } |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | { |
| 471 | 471 | dol_print_error($this->db); |
| 472 | 472 | } |
| 473 | - $out.='</select>'; |
|
| 473 | + $out .= '</select>'; |
|
| 474 | 474 | |
| 475 | 475 | return $out; |
| 476 | 476 | } |
@@ -490,21 +490,21 @@ discard block |
||
| 490 | 490 | * @param string $morecss More css |
| 491 | 491 | * @return void |
| 492 | 492 | */ |
| 493 | - function selectProjectTasks($selectedtask='', $projectid=0, $htmlname='task_parent', $modeproject=0, $modetask=0, $mode=0, $useempty=0, $disablechildoftaskid=0, $filteronprojstatus='', $morecss='') |
|
| 493 | + function selectProjectTasks($selectedtask = '', $projectid = 0, $htmlname = 'task_parent', $modeproject = 0, $modetask = 0, $mode = 0, $useempty = 0, $disablechildoftaskid = 0, $filteronprojstatus = '', $morecss = '') |
|
| 494 | 494 | { |
| 495 | 495 | global $user, $langs; |
| 496 | 496 | |
| 497 | 497 | require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
| 498 | 498 | |
| 499 | 499 | //print $modeproject.'-'.$modetask; |
| 500 | - $task=new Task($this->db); |
|
| 501 | - $tasksarray=$task->getTasksArray($modetask?$user:0, $modeproject?$user:0, $projectid, 0, $mode, '', $filteronprojstatus); |
|
| 500 | + $task = new Task($this->db); |
|
| 501 | + $tasksarray = $task->getTasksArray($modetask ? $user : 0, $modeproject ? $user : 0, $projectid, 0, $mode, '', $filteronprojstatus); |
|
| 502 | 502 | if ($tasksarray) |
| 503 | 503 | { |
| 504 | - print '<select class="flat'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 504 | + print '<select class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 505 | 505 | if ($useempty) print '<option value="0"> </option>'; |
| 506 | - $j=0; |
|
| 507 | - $level=0; |
|
| 506 | + $j = 0; |
|
| 507 | + $level = 0; |
|
| 508 | 508 | $this->_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid, $disablechildoftaskid); |
| 509 | 509 | print '</select>'; |
| 510 | 510 | |
@@ -528,14 +528,14 @@ discard block |
||
| 528 | 528 | * @param int $disablechildoftaskid 1=Disable task that are child of the provided task id |
| 529 | 529 | * @return void |
| 530 | 530 | */ |
| 531 | - private function _pLineSelect(&$inc, $parent, $lines, $level=0, $selectedtask=0, $selectedproject=0, $disablechildoftaskid=0) |
|
| 531 | + private function _pLineSelect(&$inc, $parent, $lines, $level = 0, $selectedtask = 0, $selectedproject = 0, $disablechildoftaskid = 0) |
|
| 532 | 532 | { |
| 533 | 533 | global $langs, $user, $conf; |
| 534 | 534 | |
| 535 | - $lastprojectid=0; |
|
| 535 | + $lastprojectid = 0; |
|
| 536 | 536 | |
| 537 | - $numlines=count($lines); |
|
| 538 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 537 | + $numlines = count($lines); |
|
| 538 | + for ($i = 0; $i < $numlines; $i++) |
|
| 539 | 539 | { |
| 540 | 540 | if ($lines[$i]->fk_parent == $parent) |
| 541 | 541 | { |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | if ($i > 0) print '<option value="0" disabled>----------</option>'; |
| 552 | 552 | print '<option value="'.$lines[$i]->fk_project.'_0"'; |
| 553 | 553 | if ($selectedproject == $lines[$i]->fk_project) print ' selected'; |
| 554 | - print '>'; // Project -> Task |
|
| 554 | + print '>'; // Project -> Task |
|
| 555 | 555 | print $langs->trans("Project").' '.$lines[$i]->projectref; |
| 556 | 556 | if (empty($lines[$i]->public)) |
| 557 | 557 | { |
@@ -564,22 +564,22 @@ discard block |
||
| 564 | 564 | //print '-'.$parent.'-'.$lines[$i]->fk_project.'-'.$lastprojectid; |
| 565 | 565 | print "</option>\n"; |
| 566 | 566 | |
| 567 | - $lastprojectid=$lines[$i]->fk_project; |
|
| 567 | + $lastprojectid = $lines[$i]->fk_project; |
|
| 568 | 568 | $inc++; |
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | - $newdisablechildoftaskid=$disablechildoftaskid; |
|
| 572 | + $newdisablechildoftaskid = $disablechildoftaskid; |
|
| 573 | 573 | |
| 574 | 574 | // Print task |
| 575 | 575 | if (isset($lines[$i]->id)) // We use isset because $lines[$i]->id may be null if project has no task and are on root project (tasks may be caught by a left join). We enter here only if '0' or >0 |
| 576 | 576 | { |
| 577 | 577 | // Check if we must disable entry |
| 578 | - $disabled=0; |
|
| 578 | + $disabled = 0; |
|
| 579 | 579 | if ($disablechildoftaskid && (($lines[$i]->id == $disablechildoftaskid || $lines[$i]->fk_parent == $disablechildoftaskid))) |
| 580 | 580 | { |
| 581 | 581 | $disabled++; |
| 582 | - if ($lines[$i]->fk_parent == $disablechildoftaskid) $newdisablechildoftaskid=$lines[$i]->id; // If task is child of a disabled parent, we will propagate id to disable next child too |
|
| 582 | + if ($lines[$i]->fk_parent == $disablechildoftaskid) $newdisablechildoftaskid = $lines[$i]->id; // If task is child of a disabled parent, we will propagate id to disable next child too |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | print '<option value="'.$lines[$i]->fk_project.'_'.$lines[$i]->id.'"'; |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | print ' ('.$langs->trans("Visibility").': '.$langs->trans("SharedProject").')'; |
| 598 | 598 | } |
| 599 | 599 | if ($lines[$i]->id) print ' > '; |
| 600 | - for ($k = 0 ; $k < $level ; $k++) |
|
| 600 | + for ($k = 0; $k < $level; $k++) |
|
| 601 | 601 | { |
| 602 | 602 | print " "; |
| 603 | 603 | } |
@@ -621,13 +621,13 @@ discard block |
||
| 621 | 621 | * @return string HTML code for color thumb |
| 622 | 622 | * @see selectColor |
| 623 | 623 | */ |
| 624 | - static function showColor($color, $textifnotdefined='') |
|
| 624 | + static function showColor($color, $textifnotdefined = '') |
|
| 625 | 625 | { |
| 626 | - $textcolor='FFF'; |
|
| 626 | + $textcolor = 'FFF'; |
|
| 627 | 627 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
| 628 | - if(colorIsLight($color)) $textcolor='000'; |
|
| 628 | + if (colorIsLight($color)) $textcolor = '000'; |
|
| 629 | 629 | |
| 630 | - $color = colorArrayToHex(colorStringToArray($color,array()),''); |
|
| 630 | + $color = colorArrayToHex(colorStringToArray($color, array()), ''); |
|
| 631 | 631 | |
| 632 | 632 | if ($color) print '<input type="text" class="colorthumb" disabled style="padding: 1px; margin-top: 0; margin-bottom: 0; color: #'.$textcolor.'; background-color: #'.$color.'" value="'.$color.'">'; |
| 633 | 633 | else print $textifnotdefined; |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | * @deprecated Use instead selectColor |
| 647 | 647 | * @see selectColor() |
| 648 | 648 | */ |
| 649 | - function select_color($set_color='', $prefix='f_color', $form_name='', $showcolorbox=1, $arrayofcolors='') |
|
| 649 | + function select_color($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = '') |
|
| 650 | 650 | { |
| 651 | 651 | // phpcs:enable |
| 652 | 652 | print $this->selectColor($set_color, $prefix, $form_name, $showcolorbox, $arrayofcolors); |
@@ -664,25 +664,25 @@ discard block |
||
| 664 | 664 | * @return string |
| 665 | 665 | * @see showColor |
| 666 | 666 | */ |
| 667 | - static function selectColor($set_color='', $prefix='f_color', $form_name='', $showcolorbox=1, $arrayofcolors='', $morecss='') |
|
| 667 | + static function selectColor($set_color = '', $prefix = 'f_color', $form_name = '', $showcolorbox = 1, $arrayofcolors = '', $morecss = '') |
|
| 668 | 668 | { |
| 669 | 669 | // Deprecation warning |
| 670 | 670 | if ($form_name) { |
| 671 | - dol_syslog(__METHOD__ . ": form_name parameter is deprecated", LOG_WARNING); |
|
| 671 | + dol_syslog(__METHOD__.": form_name parameter is deprecated", LOG_WARNING); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | - global $langs,$conf; |
|
| 674 | + global $langs, $conf; |
|
| 675 | 675 | |
| 676 | - $out=''; |
|
| 676 | + $out = ''; |
|
| 677 | 677 | |
| 678 | - if (! is_array($arrayofcolors) || count($arrayofcolors) < 1) |
|
| 678 | + if (!is_array($arrayofcolors) || count($arrayofcolors) < 1) |
|
| 679 | 679 | { |
| 680 | 680 | $langs->load("other"); |
| 681 | 681 | if (empty($conf->dol_use_jmobile)) |
| 682 | 682 | { |
| 683 | - $out.= '<link rel="stylesheet" media="screen" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/jpicker/css/jPicker-1.1.6.css" />'; |
|
| 684 | - $out.= '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jpicker/jpicker-1.1.6.js"></script>'; |
|
| 685 | - $out.= '<script type="text/javascript"> |
|
| 683 | + $out .= '<link rel="stylesheet" media="screen" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/jpicker/css/jPicker-1.1.6.css" />'; |
|
| 684 | + $out .= '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jpicker/jpicker-1.1.6.js"></script>'; |
|
| 685 | + $out .= '<script type="text/javascript"> |
|
| 686 | 686 | jQuery(document).ready(function(){ |
| 687 | 687 | $(\'#colorpicker'.$prefix.'\').jPicker( { |
| 688 | 688 | window: { |
@@ -720,15 +720,15 @@ discard block |
||
| 720 | 720 | } ); }); |
| 721 | 721 | </script>'; |
| 722 | 722 | } |
| 723 | - $out.= '<input id="colorpicker'.$prefix.'" name="'.$prefix.'" size="6" maxlength="7" class="flat'.($morecss?' '.$morecss:'').'" type="text" value="'.$set_color.'" />'; |
|
| 723 | + $out .= '<input id="colorpicker'.$prefix.'" name="'.$prefix.'" size="6" maxlength="7" class="flat'.($morecss ? ' '.$morecss : '').'" type="text" value="'.$set_color.'" />'; |
|
| 724 | 724 | } |
| 725 | 725 | else // In most cases, this is not used. We used instead function with no specific list of colors |
| 726 | 726 | { |
| 727 | 727 | if (empty($conf->dol_use_jmobile)) |
| 728 | 728 | { |
| 729 | - $out.= '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/colorpicker/jquery.colorpicker.css" type="text/css" media="screen" />'; |
|
| 730 | - $out.= '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/colorpicker/jquery.colorpicker.js" type="text/javascript"></script>'; |
|
| 731 | - $out.= '<script type="text/javascript"> |
|
| 729 | + $out .= '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/colorpicker/jquery.colorpicker.css" type="text/css" media="screen" />'; |
|
| 730 | + $out .= '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/colorpicker/jquery.colorpicker.js" type="text/javascript"></script>'; |
|
| 731 | + $out .= '<script type="text/javascript"> |
|
| 732 | 732 | jQuery(document).ready(function(){ |
| 733 | 733 | jQuery(\'#colorpicker'.$prefix.'\').colorpicker({ |
| 734 | 734 | size: 14, |
@@ -738,15 +738,15 @@ discard block |
||
| 738 | 738 | }); |
| 739 | 739 | </script>'; |
| 740 | 740 | } |
| 741 | - $out.= '<select id="colorpicker'.$prefix.'" class="flat'.($morecss?' '.$morecss:'').'" name="'.$prefix.'">'; |
|
| 741 | + $out .= '<select id="colorpicker'.$prefix.'" class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$prefix.'">'; |
|
| 742 | 742 | //print '<option value="-1"> </option>'; |
| 743 | 743 | foreach ($arrayofcolors as $val) |
| 744 | 744 | { |
| 745 | - $out.= '<option value="'.$val.'"'; |
|
| 746 | - if ($set_color == $val) $out.= ' selected'; |
|
| 747 | - $out.= '>'.$val.'</option>'; |
|
| 745 | + $out .= '<option value="'.$val.'"'; |
|
| 746 | + if ($set_color == $val) $out .= ' selected'; |
|
| 747 | + $out .= '>'.$val.'</option>'; |
|
| 748 | 748 | } |
| 749 | - $out.= '</select>'; |
|
| 749 | + $out .= '</select>'; |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | return $out; |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | * @param int $y Hauteur de l'image en pixels |
| 764 | 764 | * @return void |
| 765 | 765 | */ |
| 766 | - function CreateColorIcon($color,$module,$name,$x='12',$y='12') |
|
| 766 | + function CreateColorIcon($color, $module, $name, $x = '12', $y = '12') |
|
| 767 | 767 | { |
| 768 | 768 | // phpcs:enable |
| 769 | 769 | global $conf; |
@@ -771,25 +771,25 @@ discard block |
||
| 771 | 771 | $file = $conf->$module->dir_temp.'/'.$name.'.png'; |
| 772 | 772 | |
| 773 | 773 | // On cree le repertoire contenant les icones |
| 774 | - if (! file_exists($conf->$module->dir_temp)) |
|
| 774 | + if (!file_exists($conf->$module->dir_temp)) |
|
| 775 | 775 | { |
| 776 | 776 | dol_mkdir($conf->$module->dir_temp); |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | // On cree l'image en vraies couleurs |
| 780 | - $image = imagecreatetruecolor($x,$y); |
|
| 780 | + $image = imagecreatetruecolor($x, $y); |
|
| 781 | 781 | |
| 782 | - $color = substr($color,1,6); |
|
| 782 | + $color = substr($color, 1, 6); |
|
| 783 | 783 | |
| 784 | - $rouge = hexdec(substr($color,0,2)); //conversion du canal rouge |
|
| 785 | - $vert = hexdec(substr($color,2,2)); //conversion du canal vert |
|
| 786 | - $bleu = hexdec(substr($color,4,2)); //conversion du canal bleu |
|
| 784 | + $rouge = hexdec(substr($color, 0, 2)); //conversion du canal rouge |
|
| 785 | + $vert = hexdec(substr($color, 2, 2)); //conversion du canal vert |
|
| 786 | + $bleu = hexdec(substr($color, 4, 2)); //conversion du canal bleu |
|
| 787 | 787 | |
| 788 | - $couleur = imagecolorallocate($image,$rouge,$vert,$bleu); |
|
| 788 | + $couleur = imagecolorallocate($image, $rouge, $vert, $bleu); |
|
| 789 | 789 | //print $rouge.$vert.$bleu; |
| 790 | - imagefill($image,0,0,$couleur); //on remplit l'image |
|
| 790 | + imagefill($image, 0, 0, $couleur); //on remplit l'image |
|
| 791 | 791 | // On cree la couleur et on l'attribue a une variable pour ne pas la perdre |
| 792 | - ImagePng($image,$file); //renvoie une image sous format png |
|
| 792 | + ImagePng($image, $file); //renvoie une image sous format png |
|
| 793 | 793 | ImageDestroy($image); |
| 794 | 794 | } |
| 795 | 795 | |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | * @param int $useempty Affiche valeur vide dans liste |
| 803 | 803 | * @return string |
| 804 | 804 | */ |
| 805 | - function select_dayofweek($selected='',$htmlname='weekid',$useempty=0) |
|
| 805 | + function select_dayofweek($selected = '', $htmlname = 'weekid', $useempty = 0) |
|
| 806 | 806 | { |
| 807 | 807 | // phpcs:enable |
| 808 | 808 | global $langs; |
@@ -850,17 +850,17 @@ discard block |
||
| 850 | 850 | * @param string $morecss More Css |
| 851 | 851 | * @return string |
| 852 | 852 | */ |
| 853 | - function select_month($selected='', $htmlname='monthid', $useempty=0, $longlabel=0, $morecss='') |
|
| 853 | + function select_month($selected = '', $htmlname = 'monthid', $useempty = 0, $longlabel = 0, $morecss = '') |
|
| 854 | 854 | { |
| 855 | 855 | // phpcs:enable |
| 856 | 856 | global $langs; |
| 857 | 857 | |
| 858 | 858 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
| 859 | 859 | |
| 860 | - if ($longlabel) $montharray = monthArray($langs, 0); // Get array |
|
| 860 | + if ($longlabel) $montharray = monthArray($langs, 0); // Get array |
|
| 861 | 861 | else $montharray = monthArray($langs, 1); |
| 862 | 862 | |
| 863 | - $select_month = '<select class="flat'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 863 | + $select_month = '<select class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 864 | 864 | if ($useempty) |
| 865 | 865 | { |
| 866 | 866 | $select_month .= '<option value="0"> </option>'; |
@@ -897,10 +897,10 @@ discard block |
||
| 897 | 897 | * @param string $morecss More CSS |
| 898 | 898 | * @return string |
| 899 | 899 | */ |
| 900 | - function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='', $morecss='valignmiddle widthauto') |
|
| 900 | + function select_year($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle widthauto') |
|
| 901 | 901 | { |
| 902 | 902 | // phpcs:enable |
| 903 | - print $this->selectyear($selected,$htmlname,$useempty,$min_year,$max_year,$offset,$invert,$option,$morecss); |
|
| 903 | + print $this->selectyear($selected, $htmlname, $useempty, $min_year, $max_year, $offset, $invert, $option, $morecss); |
|
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | /** |
@@ -917,41 +917,41 @@ discard block |
||
| 917 | 917 | * @param string $morecss More css |
| 918 | 918 | * @return string |
| 919 | 919 | */ |
| 920 | - function selectyear($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='', $morecss='valignmiddle widthauto') |
|
| 920 | + function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle widthauto') |
|
| 921 | 921 | { |
| 922 | - $out=''; |
|
| 922 | + $out = ''; |
|
| 923 | 923 | |
| 924 | - $currentyear = date("Y")+$offset; |
|
| 925 | - $max_year = $currentyear+$max_year; |
|
| 926 | - $min_year = $currentyear-$min_year; |
|
| 927 | - if(empty($selected) && empty($useempty)) $selected = $currentyear; |
|
| 924 | + $currentyear = date("Y") + $offset; |
|
| 925 | + $max_year = $currentyear + $max_year; |
|
| 926 | + $min_year = $currentyear - $min_year; |
|
| 927 | + if (empty($selected) && empty($useempty)) $selected = $currentyear; |
|
| 928 | 928 | |
| 929 | - $out.= '<select class="flat'.($morecss?' '.$morecss:'').'" id="' . $htmlname . '" name="' . $htmlname . '"'.$option.' >'; |
|
| 930 | - if($useempty) |
|
| 929 | + $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'"'.$option.' >'; |
|
| 930 | + if ($useempty) |
|
| 931 | 931 | { |
| 932 | - $selected_html=''; |
|
| 932 | + $selected_html = ''; |
|
| 933 | 933 | if ($selected == '') $selected_html = ' selected'; |
| 934 | - $out.= '<option value=""' . $selected_html . '> </option>'; |
|
| 934 | + $out .= '<option value=""'.$selected_html.'> </option>'; |
|
| 935 | 935 | } |
| 936 | - if (! $invert) |
|
| 936 | + if (!$invert) |
|
| 937 | 937 | { |
| 938 | 938 | for ($y = $max_year; $y >= $min_year; $y--) |
| 939 | 939 | { |
| 940 | - $selected_html=''; |
|
| 940 | + $selected_html = ''; |
|
| 941 | 941 | if ($selected > 0 && $y == $selected) $selected_html = ' selected'; |
| 942 | - $out.= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>'; |
|
| 942 | + $out .= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>'; |
|
| 943 | 943 | } |
| 944 | 944 | } |
| 945 | 945 | else |
| 946 | 946 | { |
| 947 | 947 | for ($y = $min_year; $y <= $max_year; $y++) |
| 948 | 948 | { |
| 949 | - $selected_html=''; |
|
| 949 | + $selected_html = ''; |
|
| 950 | 950 | if ($selected > 0 && $y == $selected) $selected_html = ' selected'; |
| 951 | - $out.= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>'; |
|
| 951 | + $out .= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>'; |
|
| 952 | 952 | } |
| 953 | 953 | } |
| 954 | - $out.= "</select>\n"; |
|
| 954 | + $out .= "</select>\n"; |
|
| 955 | 955 | |
| 956 | 956 | return $out; |
| 957 | 957 | } |
@@ -968,10 +968,10 @@ discard block |
||
| 968 | 968 | * @param int $originid Id de l'origine |
| 969 | 969 | * @return void |
| 970 | 970 | */ |
| 971 | - function form_address($page, $selected, $socid, $htmlname='address_id', $origin='', $originid='') |
|
| 971 | + function form_address($page, $selected, $socid, $htmlname = 'address_id', $origin = '', $originid = '') |
|
| 972 | 972 | { |
| 973 | 973 | // phpcs:enable |
| 974 | - global $langs,$conf; |
|
| 974 | + global $langs, $conf; |
|
| 975 | 975 | global $form; |
| 976 | 976 | |
| 977 | 977 | if ($htmlname != "none") |
@@ -989,9 +989,9 @@ discard block |
||
| 989 | 989 | { |
| 990 | 990 | if ($selected) |
| 991 | 991 | { |
| 992 | - require_once DOL_DOCUMENT_ROOT .'/societe/class/address.class.php'; |
|
| 993 | - $address=new Address($this->db); |
|
| 994 | - $result=$address->fetch_address($selected); |
|
| 992 | + require_once DOL_DOCUMENT_ROOT.'/societe/class/address.class.php'; |
|
| 993 | + $address = new Address($this->db); |
|
| 994 | + $result = $address->fetch_address($selected); |
|
| 995 | 995 | print '<a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$address->socid.'&id='.$address->id.'&action=edit&origin='.$origin.'&originid='.$originid.'>'.$address->label.'</a>'; |
| 996 | 996 | } |
| 997 | 997 | else |
@@ -1011,72 +1011,72 @@ discard block |
||
| 1011 | 1011 | * @param String $areacode Code of area for pages ('0'=value for Home page) |
| 1012 | 1012 | * @return array array('selectboxlist'=>, 'boxactivated'=>, 'boxlista'=>, 'boxlistb'=>) |
| 1013 | 1013 | */ |
| 1014 | - static function getBoxesArea($user,$areacode) |
|
| 1014 | + static function getBoxesArea($user, $areacode) |
|
| 1015 | 1015 | { |
| 1016 | - global $conf,$langs,$db; |
|
| 1016 | + global $conf, $langs, $db; |
|
| 1017 | 1017 | |
| 1018 | 1018 | include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; |
| 1019 | 1019 | |
| 1020 | - $confuserzone='MAIN_BOXES_'.$areacode; |
|
| 1020 | + $confuserzone = 'MAIN_BOXES_'.$areacode; |
|
| 1021 | 1021 | |
| 1022 | 1022 | // $boxactivated will be array of boxes enabled into global setup |
| 1023 | 1023 | // $boxidactivatedforuser will be array of boxes choosed by user |
| 1024 | 1024 | |
| 1025 | - $selectboxlist=''; |
|
| 1026 | - $boxactivated=InfoBox::listBoxes($db, 'activated', $areacode, (empty($user->conf->$confuserzone)?null:$user), array(), 0); // Search boxes of common+user (or common only if user has no specific setup) |
|
| 1025 | + $selectboxlist = ''; |
|
| 1026 | + $boxactivated = InfoBox::listBoxes($db, 'activated', $areacode, (empty($user->conf->$confuserzone) ?null:$user), array(), 0); // Search boxes of common+user (or common only if user has no specific setup) |
|
| 1027 | 1027 | |
| 1028 | - $boxidactivatedforuser=array(); |
|
| 1029 | - foreach($boxactivated as $box) |
|
| 1028 | + $boxidactivatedforuser = array(); |
|
| 1029 | + foreach ($boxactivated as $box) |
|
| 1030 | 1030 | { |
| 1031 | - if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user |
|
| 1031 | + if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id] = $box->id; // We keep only boxes to show for user |
|
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | 1034 | // Define selectboxlist |
| 1035 | - $arrayboxtoactivatelabel=array(); |
|
| 1036 | - if (! empty($user->conf->$confuserzone)) |
|
| 1035 | + $arrayboxtoactivatelabel = array(); |
|
| 1036 | + if (!empty($user->conf->$confuserzone)) |
|
| 1037 | 1037 | { |
| 1038 | - $boxorder=''; |
|
| 1039 | - $langs->load("boxes"); // Load label of boxes |
|
| 1040 | - foreach($boxactivated as $box) |
|
| 1038 | + $boxorder = ''; |
|
| 1039 | + $langs->load("boxes"); // Load label of boxes |
|
| 1040 | + foreach ($boxactivated as $box) |
|
| 1041 | 1041 | { |
| 1042 | - if (! empty($boxidactivatedforuser[$box->id])) continue; // Already visible for user |
|
| 1043 | - $label=$langs->transnoentitiesnoconv($box->boxlabel); |
|
| 1042 | + if (!empty($boxidactivatedforuser[$box->id])) continue; // Already visible for user |
|
| 1043 | + $label = $langs->transnoentitiesnoconv($box->boxlabel); |
|
| 1044 | 1044 | //if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph").')'; |
| 1045 | - if (preg_match('/graph/',$box->class) && $conf->browser->layout != 'phone') |
|
| 1045 | + if (preg_match('/graph/', $box->class) && $conf->browser->layout != 'phone') |
|
| 1046 | 1046 | { |
| 1047 | - $label=$label.' <span class="fa fa-bar-chart"></span>'; |
|
| 1047 | + $label = $label.' <span class="fa fa-bar-chart"></span>'; |
|
| 1048 | 1048 | } |
| 1049 | - $arrayboxtoactivatelabel[$box->id]=$label; // We keep only boxes not shown for user, to show into combo list |
|
| 1049 | + $arrayboxtoactivatelabel[$box->id] = $label; // We keep only boxes not shown for user, to show into combo list |
|
| 1050 | 1050 | } |
| 1051 | - foreach($boxidactivatedforuser as $boxid) |
|
| 1051 | + foreach ($boxidactivatedforuser as $boxid) |
|
| 1052 | 1052 | { |
| 1053 | - if (empty($boxorder)) $boxorder.='A:'; |
|
| 1054 | - $boxorder.=$boxid.','; |
|
| 1053 | + if (empty($boxorder)) $boxorder .= 'A:'; |
|
| 1054 | + $boxorder .= $boxid.','; |
|
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | 1057 | //var_dump($boxidactivatedforuser); |
| 1058 | 1058 | |
| 1059 | 1059 | // Class Form must have been already loaded |
| 1060 | - $selectboxlist.='<!-- Form with select box list -->'."\n"; |
|
| 1061 | - $selectboxlist.='<form id="addbox" name="addbox" method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
| 1062 | - $selectboxlist.='<input type="hidden" name="addbox" value="addbox">'; |
|
| 1063 | - $selectboxlist.='<input type="hidden" name="userid" value="'.$user->id.'">'; |
|
| 1064 | - $selectboxlist.='<input type="hidden" name="areacode" value="'.$areacode.'">'; |
|
| 1065 | - $selectboxlist.='<input type="hidden" name="boxorder" value="'.$boxorder.'">'; |
|
| 1066 | - $selectboxlist.=Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone', 0, 'hidden selected', 0, 1); |
|
| 1067 | - if (empty($conf->use_javascript_ajax)) $selectboxlist.=' <input type="submit" class="button" value="'.$langs->trans("AddBox").'">'; |
|
| 1068 | - $selectboxlist.='</form>'; |
|
| 1069 | - if (! empty($conf->use_javascript_ajax)) |
|
| 1060 | + $selectboxlist .= '<!-- Form with select box list -->'."\n"; |
|
| 1061 | + $selectboxlist .= '<form id="addbox" name="addbox" method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
| 1062 | + $selectboxlist .= '<input type="hidden" name="addbox" value="addbox">'; |
|
| 1063 | + $selectboxlist .= '<input type="hidden" name="userid" value="'.$user->id.'">'; |
|
| 1064 | + $selectboxlist .= '<input type="hidden" name="areacode" value="'.$areacode.'">'; |
|
| 1065 | + $selectboxlist .= '<input type="hidden" name="boxorder" value="'.$boxorder.'">'; |
|
| 1066 | + $selectboxlist .= Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone', 0, 'hidden selected', 0, 1); |
|
| 1067 | + if (empty($conf->use_javascript_ajax)) $selectboxlist .= ' <input type="submit" class="button" value="'.$langs->trans("AddBox").'">'; |
|
| 1068 | + $selectboxlist .= '</form>'; |
|
| 1069 | + if (!empty($conf->use_javascript_ajax)) |
|
| 1070 | 1070 | { |
| 1071 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 1072 | - $selectboxlist.=ajax_combobox("boxcombo"); |
|
| 1071 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
| 1072 | + $selectboxlist .= ajax_combobox("boxcombo"); |
|
| 1073 | 1073 | } |
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | 1076 | // Javascript code for dynamic actions |
| 1077 | - if (! empty($conf->use_javascript_ajax)) |
|
| 1077 | + if (!empty($conf->use_javascript_ajax)) |
|
| 1078 | 1078 | { |
| 1079 | - $selectboxlist.='<script type="text/javascript" language="javascript"> |
|
| 1079 | + $selectboxlist .= '<script type="text/javascript" language="javascript"> |
|
| 1080 | 1080 | |
| 1081 | 1081 | // To update list of activated boxes |
| 1082 | 1082 | function updateBoxOrder(closing) { |
@@ -1090,7 +1090,7 @@ discard block |
||
| 1090 | 1090 | async: false |
| 1091 | 1091 | }); |
| 1092 | 1092 | // We force reload to be sure to get all boxes into list |
| 1093 | - window.location.search=\'mainmenu='.GETPOST("mainmenu","aZ09").'&leftmenu='.GETPOST('leftmenu',"aZ09").'&action=delbox\'; |
|
| 1093 | + window.location.search=\'mainmenu='.GETPOST("mainmenu", "aZ09").'&leftmenu='.GETPOST('leftmenu', "aZ09").'&action=delbox\'; |
|
| 1094 | 1094 | } |
| 1095 | 1095 | else |
| 1096 | 1096 | { |
@@ -1112,11 +1112,11 @@ discard block |
||
| 1112 | 1112 | url: \''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.'&userid='.$user->id.'\', |
| 1113 | 1113 | async: false |
| 1114 | 1114 | }); |
| 1115 | - window.location.search=\'mainmenu='.GETPOST("mainmenu","aZ09").'&leftmenu='.GETPOST('leftmenu',"aZ09").'&action=addbox&boxid=\'+boxid; |
|
| 1115 | + window.location.search=\'mainmenu='.GETPOST("mainmenu", "aZ09").'&leftmenu='.GETPOST('leftmenu', "aZ09").'&action=addbox&boxid=\'+boxid; |
|
| 1116 | 1116 | } |
| 1117 | 1117 | });'; |
| 1118 | - if (! count($arrayboxtoactivatelabel)) $selectboxlist.='jQuery("#boxcombo").hide();'; |
|
| 1119 | - $selectboxlist.=' |
|
| 1118 | + if (!count($arrayboxtoactivatelabel)) $selectboxlist .= 'jQuery("#boxcombo").hide();'; |
|
| 1119 | + $selectboxlist .= ' |
|
| 1120 | 1120 | |
| 1121 | 1121 | jQuery("#boxhalfleft, #boxhalfright").sortable({ |
| 1122 | 1122 | handle: \'.boxhandle\', |
@@ -1141,80 +1141,80 @@ discard block |
||
| 1141 | 1141 | |
| 1142 | 1142 | });'."\n"; |
| 1143 | 1143 | |
| 1144 | - $selectboxlist.='</script>'."\n"; |
|
| 1144 | + $selectboxlist .= '</script>'."\n"; |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | // Define boxlista and boxlistb |
| 1148 | - $nbboxactivated=count($boxidactivatedforuser); |
|
| 1148 | + $nbboxactivated = count($boxidactivatedforuser); |
|
| 1149 | 1149 | |
| 1150 | 1150 | if ($nbboxactivated) |
| 1151 | 1151 | { |
| 1152 | 1152 | // Load translation files required by the page |
| 1153 | - $langs->loadLangs(array("boxes","projects")); |
|
| 1153 | + $langs->loadLangs(array("boxes", "projects")); |
|
| 1154 | 1154 | |
| 1155 | - $emptybox=new ModeleBoxes($db); |
|
| 1155 | + $emptybox = new ModeleBoxes($db); |
|
| 1156 | 1156 | |
| 1157 | - $boxlista.="\n<!-- Box left container -->\n"; |
|
| 1157 | + $boxlista .= "\n<!-- Box left container -->\n"; |
|
| 1158 | 1158 | |
| 1159 | 1159 | // Define $box_max_lines |
| 1160 | - $box_max_lines=5; |
|
| 1161 | - if (! empty($conf->global->MAIN_BOXES_MAXLINES)) $box_max_lines=$conf->global->MAIN_BOXES_MAXLINES; |
|
| 1160 | + $box_max_lines = 5; |
|
| 1161 | + if (!empty($conf->global->MAIN_BOXES_MAXLINES)) $box_max_lines = $conf->global->MAIN_BOXES_MAXLINES; |
|
| 1162 | 1162 | |
| 1163 | - $ii=0; |
|
| 1163 | + $ii = 0; |
|
| 1164 | 1164 | foreach ($boxactivated as $key => $box) |
| 1165 | 1165 | { |
| 1166 | - if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; |
|
| 1167 | - if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='A'.sprintf("%02d",($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0 |
|
| 1168 | - if (preg_match('/^A/i',$box->box_order)) // column A |
|
| 1166 | + if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; |
|
| 1167 | + if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order = 'A'.sprintf("%02d", ($ii + 1)); // When box_order was not yet set to Axx or Bxx and is still 0 |
|
| 1168 | + if (preg_match('/^A/i', $box->box_order)) // column A |
|
| 1169 | 1169 | { |
| 1170 | 1170 | $ii++; |
| 1171 | 1171 | //print 'box_id '.$boxactivated[$ii]->box_id.' '; |
| 1172 | 1172 | //print 'box_order '.$boxactivated[$ii]->box_order.'<br>'; |
| 1173 | 1173 | // Show box |
| 1174 | 1174 | $box->loadBox($box_max_lines); |
| 1175 | - $boxlista.= $box->outputBox(); |
|
| 1175 | + $boxlista .= $box->outputBox(); |
|
| 1176 | 1176 | } |
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | if ($conf->browser->layout != 'phone') |
| 1180 | 1180 | { |
| 1181 | - $emptybox->box_id='A'; |
|
| 1182 | - $emptybox->info_box_head=array(); |
|
| 1183 | - $emptybox->info_box_contents=array(); |
|
| 1184 | - $boxlista.= $emptybox->outputBox(array(),array()); |
|
| 1181 | + $emptybox->box_id = 'A'; |
|
| 1182 | + $emptybox->info_box_head = array(); |
|
| 1183 | + $emptybox->info_box_contents = array(); |
|
| 1184 | + $boxlista .= $emptybox->outputBox(array(), array()); |
|
| 1185 | 1185 | } |
| 1186 | - $boxlista.= "<!-- End box left container -->\n"; |
|
| 1186 | + $boxlista .= "<!-- End box left container -->\n"; |
|
| 1187 | 1187 | |
| 1188 | - $boxlistb.= "\n<!-- Box right container -->\n"; |
|
| 1188 | + $boxlistb .= "\n<!-- Box right container -->\n"; |
|
| 1189 | 1189 | |
| 1190 | - $ii=0; |
|
| 1190 | + $ii = 0; |
|
| 1191 | 1191 | foreach ($boxactivated as $key => $box) |
| 1192 | 1192 | { |
| 1193 | - if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; |
|
| 1194 | - if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='B'.sprintf("%02d",($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0 |
|
| 1195 | - if (preg_match('/^B/i',$box->box_order)) // colonne B |
|
| 1193 | + if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; |
|
| 1194 | + if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order = 'B'.sprintf("%02d", ($ii + 1)); // When box_order was not yet set to Axx or Bxx and is still 0 |
|
| 1195 | + if (preg_match('/^B/i', $box->box_order)) // colonne B |
|
| 1196 | 1196 | { |
| 1197 | 1197 | $ii++; |
| 1198 | 1198 | //print 'box_id '.$boxactivated[$ii]->box_id.' '; |
| 1199 | 1199 | //print 'box_order '.$boxactivated[$ii]->box_order.'<br>'; |
| 1200 | 1200 | // Show box |
| 1201 | 1201 | $box->loadBox($box_max_lines); |
| 1202 | - $boxlistb.= $box->outputBox(); |
|
| 1202 | + $boxlistb .= $box->outputBox(); |
|
| 1203 | 1203 | } |
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | 1206 | if ($conf->browser->layout != 'phone') |
| 1207 | 1207 | { |
| 1208 | - $emptybox->box_id='B'; |
|
| 1209 | - $emptybox->info_box_head=array(); |
|
| 1210 | - $emptybox->info_box_contents=array(); |
|
| 1211 | - $boxlistb.= $emptybox->outputBox(array(),array()); |
|
| 1208 | + $emptybox->box_id = 'B'; |
|
| 1209 | + $emptybox->info_box_head = array(); |
|
| 1210 | + $emptybox->info_box_contents = array(); |
|
| 1211 | + $boxlistb .= $emptybox->outputBox(array(), array()); |
|
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | - $boxlistb.= "<!-- End box right container -->\n"; |
|
| 1214 | + $boxlistb .= "<!-- End box right container -->\n"; |
|
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | - return array('selectboxlist'=>count($boxactivated)?$selectboxlist:'', 'boxactivated'=>$boxactivated, 'boxlista'=>$boxlista, 'boxlistb'=>$boxlistb); |
|
| 1217 | + return array('selectboxlist'=>count($boxactivated) ? $selectboxlist : '', 'boxactivated'=>$boxactivated, 'boxlista'=>$boxlista, 'boxlistb'=>$boxlistb); |
|
| 1218 | 1218 | } |
| 1219 | 1219 | |
| 1220 | 1220 | |
@@ -1231,7 +1231,7 @@ discard block |
||
| 1231 | 1231 | * @param string $moreattrib More attributes on HTML select tag |
| 1232 | 1232 | * @return void |
| 1233 | 1233 | */ |
| 1234 | - function select_dictionary($htmlname,$dictionarytable,$keyfield='code',$labelfield='label',$selected='',$useempty=0,$moreattrib='') |
|
| 1234 | + function select_dictionary($htmlname, $dictionarytable, $keyfield = 'code', $labelfield = 'label', $selected = '', $useempty = 0, $moreattrib = '') |
|
| 1235 | 1235 | { |
| 1236 | 1236 | // phpcs:enable |
| 1237 | 1237 | global $langs, $conf; |
@@ -1239,8 +1239,8 @@ discard block |
||
| 1239 | 1239 | $langs->load("admin"); |
| 1240 | 1240 | |
| 1241 | 1241 | $sql = "SELECT rowid, ".$keyfield.", ".$labelfield; |
| 1242 | - $sql.= " FROM ".MAIN_DB_PREFIX.$dictionarytable; |
|
| 1243 | - $sql.= " ORDER BY ".$labelfield; |
|
| 1242 | + $sql .= " FROM ".MAIN_DB_PREFIX.$dictionarytable; |
|
| 1243 | + $sql .= " ORDER BY ".$labelfield; |
|
| 1244 | 1244 | |
| 1245 | 1245 | dol_syslog(get_class($this)."::select_dictionary", LOG_DEBUG); |
| 1246 | 1246 | $result = $this->db->query($sql); |
@@ -1250,7 +1250,7 @@ discard block |
||
| 1250 | 1250 | $i = 0; |
| 1251 | 1251 | if ($num) |
| 1252 | 1252 | { |
| 1253 | - print '<select id="select'.$htmlname.'" class="flat selectdictionary" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>'; |
|
| 1253 | + print '<select id="select'.$htmlname.'" class="flat selectdictionary" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>'; |
|
| 1254 | 1254 | if ($useempty == 1 || ($useempty == 2 && $num > 1)) |
| 1255 | 1255 | { |
| 1256 | 1256 | print '<option value="-1"> </option>'; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * \ingroup core |
| 26 | 26 | * \brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire |
| 27 | 27 | */ |
| 28 | -require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; |
|
| 28 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public $db; |
| 43 | 43 | |
| 44 | - public $withform; // 1=Include HTML form tag and show submit button, 0=Do not include form tag and submit button, -1=Do not include form tag but include submit button |
|
| 44 | + public $withform; // 1=Include HTML form tag and show submit button, 0=Do not include form tag and submit button, -1=Do not include form tag but include submit button |
|
| 45 | 45 | |
| 46 | 46 | public $fromname; |
| 47 | 47 | public $frommail; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | public $tomail; |
| 73 | 73 | public $trackid; |
| 74 | 74 | |
| 75 | - public $withsubstit; // Show substitution array |
|
| 75 | + public $withsubstit; // Show substitution array |
|
| 76 | 76 | public $withfrom; |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * @var int|int[] |
| 87 | 87 | */ |
| 88 | - public $withto; // Show recipient emails |
|
| 88 | + public $withto; // Show recipient emails |
|
| 89 | 89 | |
| 90 | - public $withtofree; // Show free text for recipient emails |
|
| 90 | + public $withtofree; // Show free text for recipient emails |
|
| 91 | 91 | public $withtocc; |
| 92 | 92 | public $withtoccc; |
| 93 | 93 | public $withtopic; |
| 94 | - public $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files |
|
| 95 | - public $withmaindocfile; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default) |
|
| 94 | + public $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files |
|
| 95 | + public $withmaindocfile; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default) |
|
| 96 | 96 | public $withbody; |
| 97 | 97 | |
| 98 | 98 | public $withfromreadonly; |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | public $withcancel; |
| 107 | 107 | public $withfckeditor; |
| 108 | 108 | |
| 109 | - public $substit=array(); |
|
| 110 | - public $substit_lines=array(); |
|
| 111 | - public $param=array(); |
|
| 109 | + public $substit = array(); |
|
| 110 | + public $substit_lines = array(); |
|
| 111 | + public $param = array(); |
|
| 112 | 112 | |
| 113 | - public $withtouser=array(); |
|
| 114 | - public $withtoccuser=array(); |
|
| 113 | + public $withtouser = array(); |
|
| 114 | + public $withtoccuser = array(); |
|
| 115 | 115 | |
| 116 | 116 | public $lines_model; |
| 117 | 117 | |
@@ -125,30 +125,30 @@ discard block |
||
| 125 | 125 | { |
| 126 | 126 | $this->db = $db; |
| 127 | 127 | |
| 128 | - $this->withform=1; |
|
| 129 | - |
|
| 130 | - $this->withfrom=1; |
|
| 131 | - $this->withto=1; |
|
| 132 | - $this->withtofree=1; |
|
| 133 | - $this->withtocc=1; |
|
| 134 | - $this->withtoccc=0; |
|
| 135 | - $this->witherrorsto=0; |
|
| 136 | - $this->withtopic=1; |
|
| 137 | - $this->withfile=0; // 1=Add section "Attached files". 2=Can add files. |
|
| 138 | - $this->withmaindocfile=0; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default) |
|
| 139 | - $this->withbody=1; |
|
| 140 | - |
|
| 141 | - $this->withfromreadonly=1; |
|
| 142 | - $this->withreplytoreadonly=1; |
|
| 143 | - $this->withtoreadonly=0; |
|
| 144 | - $this->withtoccreadonly=0; |
|
| 145 | - $this->withtocccreadonly=0; |
|
| 146 | - $this->witherrorstoreadonly=0; |
|
| 147 | - $this->withtopicreadonly=0; |
|
| 148 | - $this->withfilereadonly=0; |
|
| 149 | - $this->withbodyreadonly=0; |
|
| 150 | - $this->withdeliveryreceiptreadonly=0; |
|
| 151 | - $this->withfckeditor=-1; // -1 = Auto |
|
| 128 | + $this->withform = 1; |
|
| 129 | + |
|
| 130 | + $this->withfrom = 1; |
|
| 131 | + $this->withto = 1; |
|
| 132 | + $this->withtofree = 1; |
|
| 133 | + $this->withtocc = 1; |
|
| 134 | + $this->withtoccc = 0; |
|
| 135 | + $this->witherrorsto = 0; |
|
| 136 | + $this->withtopic = 1; |
|
| 137 | + $this->withfile = 0; // 1=Add section "Attached files". 2=Can add files. |
|
| 138 | + $this->withmaindocfile = 0; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default) |
|
| 139 | + $this->withbody = 1; |
|
| 140 | + |
|
| 141 | + $this->withfromreadonly = 1; |
|
| 142 | + $this->withreplytoreadonly = 1; |
|
| 143 | + $this->withtoreadonly = 0; |
|
| 144 | + $this->withtoccreadonly = 0; |
|
| 145 | + $this->withtocccreadonly = 0; |
|
| 146 | + $this->witherrorstoreadonly = 0; |
|
| 147 | + $this->withtopicreadonly = 0; |
|
| 148 | + $this->withfilereadonly = 0; |
|
| 149 | + $this->withbodyreadonly = 0; |
|
| 150 | + $this->withdeliveryreceiptreadonly = 0; |
|
| 151 | + $this->withfckeditor = -1; // -1 = Auto |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -160,15 +160,15 @@ discard block |
||
| 160 | 160 | function clear_attached_files() |
| 161 | 161 | { |
| 162 | 162 | // phpcs:enable |
| 163 | - global $conf,$user; |
|
| 163 | + global $conf, $user; |
|
| 164 | 164 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 165 | 165 | |
| 166 | 166 | // Set tmp user directory |
| 167 | - $vardir=$conf->user->dir_output."/".$user->id; |
|
| 168 | - $upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path |
|
| 167 | + $vardir = $conf->user->dir_output."/".$user->id; |
|
| 168 | + $upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path |
|
| 169 | 169 | if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir); |
| 170 | 170 | |
| 171 | - $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined |
|
| 171 | + $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined |
|
| 172 | 172 | unset($_SESSION["listofpaths".$keytoavoidconflict]); |
| 173 | 173 | unset($_SESSION["listofnames".$keytoavoidconflict]); |
| 174 | 174 | unset($_SESSION["listofmimes".$keytoavoidconflict]); |
@@ -183,28 +183,28 @@ discard block |
||
| 183 | 183 | * @param string $type Mime type (can be dol_mimetype($file)) |
| 184 | 184 | * @return void |
| 185 | 185 | */ |
| 186 | - function add_attached_files($path, $file='', $type='') |
|
| 186 | + function add_attached_files($path, $file = '', $type = '') |
|
| 187 | 187 | { |
| 188 | 188 | // phpcs:enable |
| 189 | - $listofpaths=array(); |
|
| 190 | - $listofnames=array(); |
|
| 191 | - $listofmimes=array(); |
|
| 192 | - |
|
| 193 | - if (empty($file)) $file=basename($path); |
|
| 194 | - if (empty($type)) $type=dol_mimetype($file); |
|
| 195 | - |
|
| 196 | - $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined |
|
| 197 | - if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
| 198 | - if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
| 199 | - if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
| 200 | - if (! in_array($file,$listofnames)) |
|
| 189 | + $listofpaths = array(); |
|
| 190 | + $listofnames = array(); |
|
| 191 | + $listofmimes = array(); |
|
| 192 | + |
|
| 193 | + if (empty($file)) $file = basename($path); |
|
| 194 | + if (empty($type)) $type = dol_mimetype($file); |
|
| 195 | + |
|
| 196 | + $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined |
|
| 197 | + if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); |
|
| 198 | + if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); |
|
| 199 | + if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); |
|
| 200 | + if (!in_array($file, $listofnames)) |
|
| 201 | 201 | { |
| 202 | - $listofpaths[]=$path; |
|
| 203 | - $listofnames[]=$file; |
|
| 204 | - $listofmimes[]=$type; |
|
| 205 | - $_SESSION["listofpaths".$keytoavoidconflict]=join(';',$listofpaths); |
|
| 206 | - $_SESSION["listofnames".$keytoavoidconflict]=join(';',$listofnames); |
|
| 207 | - $_SESSION["listofmimes".$keytoavoidconflict]=join(';',$listofmimes); |
|
| 202 | + $listofpaths[] = $path; |
|
| 203 | + $listofnames[] = $file; |
|
| 204 | + $listofmimes[] = $type; |
|
| 205 | + $_SESSION["listofpaths".$keytoavoidconflict] = join(';', $listofpaths); |
|
| 206 | + $_SESSION["listofnames".$keytoavoidconflict] = join(';', $listofnames); |
|
| 207 | + $_SESSION["listofmimes".$keytoavoidconflict] = join(';', $listofmimes); |
|
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | |
@@ -218,22 +218,22 @@ discard block |
||
| 218 | 218 | function remove_attached_files($keytodelete) |
| 219 | 219 | { |
| 220 | 220 | // phpcs:enable |
| 221 | - $listofpaths=array(); |
|
| 222 | - $listofnames=array(); |
|
| 223 | - $listofmimes=array(); |
|
| 224 | - |
|
| 225 | - $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined |
|
| 226 | - if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
| 227 | - if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
| 228 | - if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
| 221 | + $listofpaths = array(); |
|
| 222 | + $listofnames = array(); |
|
| 223 | + $listofmimes = array(); |
|
| 224 | + |
|
| 225 | + $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined |
|
| 226 | + if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); |
|
| 227 | + if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); |
|
| 228 | + if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); |
|
| 229 | 229 | if ($keytodelete >= 0) |
| 230 | 230 | { |
| 231 | 231 | unset ($listofpaths[$keytodelete]); |
| 232 | 232 | unset ($listofnames[$keytodelete]); |
| 233 | 233 | unset ($listofmimes[$keytodelete]); |
| 234 | - $_SESSION["listofpaths".$keytoavoidconflict]=join(';',$listofpaths); |
|
| 235 | - $_SESSION["listofnames".$keytoavoidconflict]=join(';',$listofnames); |
|
| 236 | - $_SESSION["listofmimes".$keytoavoidconflict]=join(';',$listofmimes); |
|
| 234 | + $_SESSION["listofpaths".$keytoavoidconflict] = join(';', $listofpaths); |
|
| 235 | + $_SESSION["listofnames".$keytoavoidconflict] = join(';', $listofnames); |
|
| 236 | + $_SESSION["listofmimes".$keytoavoidconflict] = join(';', $listofmimes); |
|
| 237 | 237 | //var_dump($_SESSION['listofpaths']); |
| 238 | 238 | } |
| 239 | 239 | } |
@@ -247,14 +247,14 @@ discard block |
||
| 247 | 247 | function get_attached_files() |
| 248 | 248 | { |
| 249 | 249 | // phpcs:enable |
| 250 | - $listofpaths=array(); |
|
| 251 | - $listofnames=array(); |
|
| 252 | - $listofmimes=array(); |
|
| 253 | - |
|
| 254 | - $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined |
|
| 255 | - if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
| 256 | - if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
| 257 | - if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
| 250 | + $listofpaths = array(); |
|
| 251 | + $listofnames = array(); |
|
| 252 | + $listofmimes = array(); |
|
| 253 | + |
|
| 254 | + $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined |
|
| 255 | + if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); |
|
| 256 | + if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); |
|
| 257 | + if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); |
|
| 258 | 258 | return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes); |
| 259 | 259 | } |
| 260 | 260 | |
@@ -268,10 +268,10 @@ discard block |
||
| 268 | 268 | * @param string $removefileaction Name of action when removing file attachments |
| 269 | 269 | * @return void |
| 270 | 270 | */ |
| 271 | - function show_form($addfileaction='addfile',$removefileaction='removefile') |
|
| 271 | + function show_form($addfileaction = 'addfile', $removefileaction = 'removefile') |
|
| 272 | 272 | { |
| 273 | 273 | // phpcs:enable |
| 274 | - print $this->get_form($addfileaction,$removefileaction); |
|
| 274 | + print $this->get_form($addfileaction, $removefileaction); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -285,18 +285,18 @@ discard block |
||
| 285 | 285 | * @param string $removefileaction Name of action when removing file attachments |
| 286 | 286 | * @return string Form to show |
| 287 | 287 | */ |
| 288 | - function get_form($addfileaction='addfile', $removefileaction='removefile') |
|
| 288 | + function get_form($addfileaction = 'addfile', $removefileaction = 'removefile') |
|
| 289 | 289 | { |
| 290 | 290 | // phpcs:enable |
| 291 | 291 | global $conf, $langs, $user, $hookmanager, $form; |
| 292 | 292 | |
| 293 | - if (! is_object($form)) $form=new Form($this->db); |
|
| 293 | + if (!is_object($form)) $form = new Form($this->db); |
|
| 294 | 294 | |
| 295 | 295 | // Load translation files required by the page |
| 296 | 296 | $langs->loadLangs(array('other', 'mails')); |
| 297 | 297 | |
| 298 | 298 | // Clear temp files. Must be done at beginning, before call of triggers |
| 299 | - if (GETPOST('mode','alpha') == 'init' || (GETPOST('modelmailselected','alpha') && GETPOST('modelmailselected','alpha') != '-1')) |
|
| 299 | + if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) |
|
| 300 | 300 | { |
| 301 | 301 | $this->clear_attached_files(); |
| 302 | 302 | } |
@@ -304,12 +304,12 @@ discard block |
||
| 304 | 304 | // Call hook getFormMail |
| 305 | 305 | $hookmanager->initHooks(array('formmail')); |
| 306 | 306 | |
| 307 | - $parameters=array( |
|
| 307 | + $parameters = array( |
|
| 308 | 308 | 'addfileaction' => $addfileaction, |
| 309 | 309 | 'removefileaction'=> $removefileaction, |
| 310 | 310 | 'trackid'=> $this->trackid |
| 311 | 311 | ); |
| 312 | - $reshook=$hookmanager->executeHooks('getFormMail', $parameters, $this); |
|
| 312 | + $reshook = $hookmanager->executeHooks('getFormMail', $parameters, $this); |
|
| 313 | 313 | |
| 314 | 314 | if (!empty($reshook)) |
| 315 | 315 | { |
@@ -317,15 +317,15 @@ discard block |
||
| 317 | 317 | } |
| 318 | 318 | else |
| 319 | 319 | { |
| 320 | - $out=''; |
|
| 320 | + $out = ''; |
|
| 321 | 321 | |
| 322 | - $disablebademails=1; |
|
| 322 | + $disablebademails = 1; |
|
| 323 | 323 | |
| 324 | 324 | // Define output language |
| 325 | 325 | $outputlangs = $langs; |
| 326 | 326 | $newlang = ''; |
| 327 | 327 | if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->param['langsmodels']; |
| 328 | - if (! empty($newlang)) |
|
| 328 | + if (!empty($newlang)) |
|
| 329 | 329 | { |
| 330 | 330 | $outputlangs = new Translate("", $conf); |
| 331 | 331 | $outputlangs->setDefaultLang($newlang); |
@@ -336,61 +336,61 @@ discard block |
||
| 336 | 336 | $arraydefaultmessage = -1; |
| 337 | 337 | if ($this->param['models'] != 'none') |
| 338 | 338 | { |
| 339 | - $model_id=0; |
|
| 340 | - if (array_key_exists('models_id',$this->param)) |
|
| 339 | + $model_id = 0; |
|
| 340 | + if (array_key_exists('models_id', $this->param)) |
|
| 341 | 341 | { |
| 342 | - $model_id=$this->param["models_id"]; |
|
| 342 | + $model_id = $this->param["models_id"]; |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); // If $model_id is empty, preselect the first one |
|
| 345 | + $arraydefaultmessage = $this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); // If $model_id is empty, preselect the first one |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | // Define list of attached files |
| 349 | - $listofpaths=array(); |
|
| 350 | - $listofnames=array(); |
|
| 351 | - $listofmimes=array(); |
|
| 352 | - $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined |
|
| 349 | + $listofpaths = array(); |
|
| 350 | + $listofnames = array(); |
|
| 351 | + $listofmimes = array(); |
|
| 352 | + $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined |
|
| 353 | 353 | |
| 354 | - if (GETPOST('mode','alpha') == 'init' || (GETPOST('modelmailselected','alpha') && GETPOST('modelmailselected','alpha') != '-1')) |
|
| 354 | + if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) |
|
| 355 | 355 | { |
| 356 | - if (! empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) |
|
| 356 | + if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) |
|
| 357 | 357 | { |
| 358 | - foreach($this->param['fileinit'] as $file) |
|
| 358 | + foreach ($this->param['fileinit'] as $file) |
|
| 359 | 359 | { |
| 360 | 360 | $this->add_attached_files($file, basename($file), dol_mimetype($file)); |
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
| 366 | - if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
| 367 | - if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
| 365 | + if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); |
|
| 366 | + if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); |
|
| 367 | + if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); |
|
| 368 | 368 | |
| 369 | 369 | |
| 370 | - $out.= "\n".'<!-- Begin form mail type='.$this->param["models"].' --><div id="mailformdiv"></div>'."\n"; |
|
| 370 | + $out .= "\n".'<!-- Begin form mail type='.$this->param["models"].' --><div id="mailformdiv"></div>'."\n"; |
|
| 371 | 371 | if ($this->withform == 1) |
| 372 | 372 | { |
| 373 | - $out.= '<form method="POST" name="mailform" id="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'#formmail">'."\n"; |
|
| 373 | + $out .= '<form method="POST" name="mailform" id="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'#formmail">'."\n"; |
|
| 374 | 374 | |
| 375 | - $out.= '<a id="formmail" name="formmail"></a>'; |
|
| 376 | - $out.= '<input style="display:none" type="submit" id="sendmail" name="sendmail">'; |
|
| 377 | - $out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />'; |
|
| 378 | - $out.= '<input type="hidden" name="trackid" value="'.$this->trackid.'" />'; |
|
| 375 | + $out .= '<a id="formmail" name="formmail"></a>'; |
|
| 376 | + $out .= '<input style="display:none" type="submit" id="sendmail" name="sendmail">'; |
|
| 377 | + $out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />'; |
|
| 378 | + $out .= '<input type="hidden" name="trackid" value="'.$this->trackid.'" />'; |
|
| 379 | 379 | } |
| 380 | - if (! empty($this->withfrom)) |
|
| 380 | + if (!empty($this->withfrom)) |
|
| 381 | 381 | { |
| 382 | - if (! empty($this->withfromreadonly)) |
|
| 382 | + if (!empty($this->withfromreadonly)) |
|
| 383 | 383 | { |
| 384 | - $out.= '<input type="hidden" id="fromname" name="fromname" value="'.$this->fromname.'" />'; |
|
| 385 | - $out.= '<input type="hidden" id="frommail" name="frommail" value="'.$this->frommail.'" />'; |
|
| 384 | + $out .= '<input type="hidden" id="fromname" name="fromname" value="'.$this->fromname.'" />'; |
|
| 385 | + $out .= '<input type="hidden" id="frommail" name="frommail" value="'.$this->frommail.'" />'; |
|
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | 388 | foreach ($this->param as $key=>$value) |
| 389 | 389 | { |
| 390 | - $out.= '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'" />'."\n"; |
|
| 390 | + $out .= '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'" />'."\n"; |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - $modelmail_array=array(); |
|
| 393 | + $modelmail_array = array(); |
|
| 394 | 394 | if ($this->param['models'] != 'none') |
| 395 | 395 | { |
| 396 | 396 | $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); |
@@ -398,69 +398,69 @@ discard block |
||
| 398 | 398 | { |
| 399 | 399 | setEventMessages($this->error, $this->errors, 'errors'); |
| 400 | 400 | } |
| 401 | - foreach($this->lines_model as $line) |
|
| 401 | + foreach ($this->lines_model as $line) |
|
| 402 | 402 | { |
| 403 | 403 | $langs->trans("members"); |
| 404 | 404 | if (preg_match('/\((.*)\)/', $line->label, $reg)) |
| 405 | 405 | { |
| 406 | - $modelmail_array[$line->id]=$langs->trans($reg[1]); // langs->trans when label is __(xxx)__ |
|
| 406 | + $modelmail_array[$line->id] = $langs->trans($reg[1]); // langs->trans when label is __(xxx)__ |
|
| 407 | 407 | } |
| 408 | 408 | else |
| 409 | 409 | { |
| 410 | - $modelmail_array[$line->id]=$line->label; |
|
| 410 | + $modelmail_array[$line->id] = $line->label; |
|
| 411 | 411 | } |
| 412 | - if ($line->lang) $modelmail_array[$line->id].=' ('.$line->lang.')'; |
|
| 413 | - if ($line->private) $modelmail_array[$line->id].=' - '.$langs->trans("Private"); |
|
| 412 | + if ($line->lang) $modelmail_array[$line->id] .= ' ('.$line->lang.')'; |
|
| 413 | + if ($line->private) $modelmail_array[$line->id] .= ' - '.$langs->trans("Private"); |
|
| 414 | 414 | //if ($line->fk_user != $user->id) $modelmail_array[$line->id].=' - '.$langs->trans("By").' '; |
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | // Zone to select email template |
| 419 | - if (count($modelmail_array)>0) |
|
| 419 | + if (count($modelmail_array) > 0) |
|
| 420 | 420 | { |
| 421 | 421 | // If list of template is filled |
| 422 | - $out.= '<div class="center" style="padding: 0px 0 12px 0">'."\n"; |
|
| 423 | - $out.= '<span class="opacitymedium">'.$langs->trans('SelectMailModel').':</span> '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100'); |
|
| 424 | - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')),1); |
|
| 425 | - $out.= ' '; |
|
| 426 | - $out.= '<input class="button" type="submit" value="'.$langs->trans('Apply').'" name="modelselected" id="modelselected">'; |
|
| 427 | - $out.= ' '; |
|
| 428 | - $out.= '</div>'; |
|
| 422 | + $out .= '<div class="center" style="padding: 0px 0 12px 0">'."\n"; |
|
| 423 | + $out .= '<span class="opacitymedium">'.$langs->trans('SelectMailModel').':</span> '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100'); |
|
| 424 | + if ($user->admin) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')), 1); |
|
| 425 | + $out .= ' '; |
|
| 426 | + $out .= '<input class="button" type="submit" value="'.$langs->trans('Apply').'" name="modelselected" id="modelselected">'; |
|
| 427 | + $out .= ' '; |
|
| 428 | + $out .= '</div>'; |
|
| 429 | 429 | } |
| 430 | - elseif (! empty($this->param['models']) && in_array($this->param['models'], array( |
|
| 431 | - 'propal_send','order_send','facture_send', |
|
| 432 | - 'shipping_send','fichinter_send','supplier_proposal_send','order_supplier_send', |
|
| 433 | - 'invoice_supplier_send','thirdparty','contract','user','all' |
|
| 430 | + elseif (!empty($this->param['models']) && in_array($this->param['models'], array( |
|
| 431 | + 'propal_send', 'order_send', 'facture_send', |
|
| 432 | + 'shipping_send', 'fichinter_send', 'supplier_proposal_send', 'order_supplier_send', |
|
| 433 | + 'invoice_supplier_send', 'thirdparty', 'contract', 'user', 'all' |
|
| 434 | 434 | ))) |
| 435 | 435 | { |
| 436 | 436 | // If list of template is empty |
| 437 | - $out.= '<div class="center" style="padding: 0px 0 12px 0">'."\n"; |
|
| 438 | - $out.= $langs->trans('SelectMailModel').': <select name="modelmailselected" disabled="disabled"><option value="none">'.$langs->trans("NoTemplateDefined").'</option></select>'; // Do not put 'disabled' on 'option' tag, it is already on 'select' and it makes chrome crazy. |
|
| 439 | - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')),1); |
|
| 440 | - $out.= ' '; |
|
| 441 | - $out.= '<input class="button" type="submit" value="'.$langs->trans('Apply').'" name="modelselected" disabled="disabled" id="modelselected">'; |
|
| 442 | - $out.= ' '; |
|
| 443 | - $out.= '</div>'; |
|
| 437 | + $out .= '<div class="center" style="padding: 0px 0 12px 0">'."\n"; |
|
| 438 | + $out .= $langs->trans('SelectMailModel').': <select name="modelmailselected" disabled="disabled"><option value="none">'.$langs->trans("NoTemplateDefined").'</option></select>'; // Do not put 'disabled' on 'option' tag, it is already on 'select' and it makes chrome crazy. |
|
| 439 | + if ($user->admin) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')), 1); |
|
| 440 | + $out .= ' '; |
|
| 441 | + $out .= '<input class="button" type="submit" value="'.$langs->trans('Apply').'" name="modelselected" disabled="disabled" id="modelselected">'; |
|
| 442 | + $out .= ' '; |
|
| 443 | + $out .= '</div>'; |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | |
| 447 | 447 | |
| 448 | - $out.= '<table class="tableforemailform boxtablenotop" width="100%">'."\n"; |
|
| 448 | + $out .= '<table class="tableforemailform boxtablenotop" width="100%">'."\n"; |
|
| 449 | 449 | |
| 450 | 450 | // Substitution array/string |
| 451 | - $helpforsubstitution=''; |
|
| 452 | - if (is_array($this->substit) && count($this->substit)) $helpforsubstitution.=$langs->trans('AvailableVariables').' :<br>'."\n"; |
|
| 453 | - foreach($this->substit as $key => $val) |
|
| 451 | + $helpforsubstitution = ''; |
|
| 452 | + if (is_array($this->substit) && count($this->substit)) $helpforsubstitution .= $langs->trans('AvailableVariables').' :<br>'."\n"; |
|
| 453 | + foreach ($this->substit as $key => $val) |
|
| 454 | 454 | { |
| 455 | - $helpforsubstitution.=$key.' -> '.$langs->trans(dol_string_nohtmltag($val)).'<br>'; |
|
| 455 | + $helpforsubstitution .= $key.' -> '.$langs->trans(dol_string_nohtmltag($val)).'<br>'; |
|
| 456 | 456 | } |
| 457 | - if (! empty($this->withsubstit)) // Unset or set ->withsubstit=0 to disable this. |
|
| 457 | + if (!empty($this->withsubstit)) // Unset or set ->withsubstit=0 to disable this. |
|
| 458 | 458 | { |
| 459 | - $out.= '<tr><td colspan="2" align="right">'; |
|
| 459 | + $out .= '<tr><td colspan="2" align="right">'; |
|
| 460 | 460 | //$out.='<div class="floatright">'; |
| 461 | - if (is_numeric($this->withsubstit)) $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltip'); // Old usage |
|
| 462 | - else $out.= $form->textwithpicto($langs->trans('AvailableVariables'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltip'); // New usage |
|
| 463 | - $out.= "</td></tr>\n"; |
|
| 461 | + if (is_numeric($this->withsubstit)) $out .= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltip'); // Old usage |
|
| 462 | + else $out .= $form->textwithpicto($langs->trans('AvailableVariables'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltip'); // New usage |
|
| 463 | + $out .= "</td></tr>\n"; |
|
| 464 | 464 | //$out.='</div>'; |
| 465 | 465 | } |
| 466 | 466 | |
@@ -470,33 +470,33 @@ discard block |
||
| 470 | 470 | var_dump($this->fromname);*/ |
| 471 | 471 | |
| 472 | 472 | // From |
| 473 | - if (! empty($this->withfrom)) |
|
| 473 | + if (!empty($this->withfrom)) |
|
| 474 | 474 | { |
| 475 | - if (! empty($this->withfromreadonly)) |
|
| 475 | + if (!empty($this->withfromreadonly)) |
|
| 476 | 476 | { |
| 477 | - $out.= '<tr><td class="fieldrequired minwidth200">'.$langs->trans("MailFrom").'</td><td>'; |
|
| 477 | + $out .= '<tr><td class="fieldrequired minwidth200">'.$langs->trans("MailFrom").'</td><td>'; |
|
| 478 | 478 | |
| 479 | 479 | // $this->fromtype is the default value to use to select sender |
| 480 | - if (! ($this->fromtype === 'user' && $this->fromid > 0) |
|
| 481 | - && ! ($this->fromtype === 'company') |
|
| 482 | - && ! ($this->fromtype === 'robot') |
|
| 483 | - && ! preg_match('/user_aliases/', $this->fromtype) |
|
| 484 | - && ! preg_match('/global_aliases/', $this->fromtype) |
|
| 485 | - && ! preg_match('/senderprofile/', $this->fromtype) |
|
| 480 | + if (!($this->fromtype === 'user' && $this->fromid > 0) |
|
| 481 | + && !($this->fromtype === 'company') |
|
| 482 | + && !($this->fromtype === 'robot') |
|
| 483 | + && !preg_match('/user_aliases/', $this->fromtype) |
|
| 484 | + && !preg_match('/global_aliases/', $this->fromtype) |
|
| 485 | + && !preg_match('/senderprofile/', $this->fromtype) |
|
| 486 | 486 | ) |
| 487 | 487 | { |
| 488 | 488 | // Use this->fromname and this->frommail or error if not defined |
| 489 | - $out.= $this->fromname; |
|
| 489 | + $out .= $this->fromname; |
|
| 490 | 490 | if ($this->frommail) |
| 491 | 491 | { |
| 492 | - $out.= ' <'.$this->frommail.'>'; |
|
| 492 | + $out .= ' <'.$this->frommail.'>'; |
|
| 493 | 493 | } |
| 494 | 494 | else |
| 495 | 495 | { |
| 496 | 496 | if ($this->fromtype) |
| 497 | 497 | { |
| 498 | 498 | $langs->load('errors'); |
| 499 | - $out.= '<span class="warning"> <'.$langs->trans('ErrorNoMailDefinedForThisUser').'> </span>'; |
|
| 499 | + $out .= '<span class="warning"> <'.$langs->trans('ErrorNoMailDefinedForThisUser').'> </span>'; |
|
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | 502 | } else { |
@@ -506,23 +506,23 @@ discard block |
||
| 506 | 506 | if (empty($user->email)) |
| 507 | 507 | { |
| 508 | 508 | $langs->load('errors'); |
| 509 | - $liste['user'] = $user->getFullName($langs) . ' <'.$langs->trans('ErrorNoMailDefinedForThisUser').'>'; |
|
| 509 | + $liste['user'] = $user->getFullName($langs).' <'.$langs->trans('ErrorNoMailDefinedForThisUser').'>'; |
|
| 510 | 510 | } |
| 511 | 511 | else |
| 512 | 512 | { |
| 513 | - $liste['user'] = $user->getFullName($langs) .' <'.$user->email.'>'; |
|
| 513 | + $liste['user'] = $user->getFullName($langs).' <'.$user->email.'>'; |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | // Add also company main email |
| 517 | - $liste['company'] = $conf->global->MAIN_INFO_SOCIETE_NOM .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; |
|
| 517 | + $liste['company'] = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; |
|
| 518 | 518 | |
| 519 | 519 | // Add also email aliases if there is some |
| 520 | - $listaliases=array('user_aliases'=>$user->email_aliases, 'global_aliases'=>$conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); |
|
| 520 | + $listaliases = array('user_aliases'=>$user->email_aliases, 'global_aliases'=>$conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); |
|
| 521 | 521 | |
| 522 | 522 | // Also add robot email |
| 523 | - if (! empty($this->fromalsorobot)) |
|
| 523 | + if (!empty($this->fromalsorobot)) |
|
| 524 | 524 | { |
| 525 | - if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && $conf->global->MAIN_MAIL_EMAIL_FROM != $conf->global->MAIN_INFO_SOCIETE_MAIL) |
|
| 525 | + if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && $conf->global->MAIN_MAIL_EMAIL_FROM != $conf->global->MAIN_INFO_SOCIETE_MAIL) |
|
| 526 | 526 | { |
| 527 | 527 | $liste['robot'] = $conf->global->MAIN_MAIL_EMAIL_FROM; |
| 528 | 528 | if ($this->frommail) |
@@ -533,13 +533,13 @@ discard block |
||
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | // Add also email aliases from the c_email_senderprofile table |
| 536 | - $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1 ORDER BY position'; |
|
| 536 | + $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1 ORDER BY position'; |
|
| 537 | 537 | $resql = $this->db->query($sql); |
| 538 | 538 | if ($resql) |
| 539 | 539 | { |
| 540 | 540 | $num = $this->db->num_rows($resql); |
| 541 | - $i=0; |
|
| 542 | - while($i < $num) |
|
| 541 | + $i = 0; |
|
| 542 | + while ($i < $num) |
|
| 543 | 543 | { |
| 544 | 544 | $obj = $this->db->fetch_object($resql); |
| 545 | 545 | if ($obj) |
@@ -551,244 +551,244 @@ discard block |
||
| 551 | 551 | } |
| 552 | 552 | else dol_print_error($this->db); |
| 553 | 553 | |
| 554 | - foreach($listaliases as $typealias => $listalias) |
|
| 554 | + foreach ($listaliases as $typealias => $listalias) |
|
| 555 | 555 | { |
| 556 | - $posalias=0; |
|
| 557 | - $listaliasarray=explode(',', $listalias); |
|
| 556 | + $posalias = 0; |
|
| 557 | + $listaliasarray = explode(',', $listalias); |
|
| 558 | 558 | foreach ($listaliasarray as $listaliasval) |
| 559 | 559 | { |
| 560 | 560 | $posalias++; |
| 561 | - $listaliasval=trim($listaliasval); |
|
| 561 | + $listaliasval = trim($listaliasval); |
|
| 562 | 562 | if ($listaliasval) |
| 563 | 563 | { |
| 564 | - $listaliasval=preg_replace('/</', '<', $listaliasval); |
|
| 565 | - $listaliasval=preg_replace('/>/', '>', $listaliasval); |
|
| 566 | - if (! preg_match('/</', $listaliasval)) $listaliasval='<'.$listaliasval.'>'; |
|
| 567 | - $liste[$typealias.'_'.$posalias]=$listaliasval; |
|
| 564 | + $listaliasval = preg_replace('/</', '<', $listaliasval); |
|
| 565 | + $listaliasval = preg_replace('/>/', '>', $listaliasval); |
|
| 566 | + if (!preg_match('/</', $listaliasval)) $listaliasval = '<'.$listaliasval.'>'; |
|
| 567 | + $liste[$typealias.'_'.$posalias] = $listaliasval; |
|
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | // Set the default "From" |
| 573 | - $defaultfrom=''; |
|
| 574 | - $reshook=$hookmanager->executeHooks('getDefaultFromEmail', $parameters, $this); |
|
| 573 | + $defaultfrom = ''; |
|
| 574 | + $reshook = $hookmanager->executeHooks('getDefaultFromEmail', $parameters, $this); |
|
| 575 | 575 | if (empty($reshook)) |
| 576 | 576 | { |
| 577 | 577 | $defaultfrom = $this->fromtype; |
| 578 | 578 | } |
| 579 | - if (! empty($hookmanager->resArray['defaultfrom'])) $defaultfrom=$hookmanager->resArray['defaultfrom']; |
|
| 579 | + if (!empty($hookmanager->resArray['defaultfrom'])) $defaultfrom = $hookmanager->resArray['defaultfrom']; |
|
| 580 | 580 | |
| 581 | 581 | // Using combo here make the '<email>' no more visible on list. |
| 582 | 582 | //$out.= ' '.$form->selectarray('fromtype', $liste, $this->fromtype, 0, 0, 0, '', 0, 0, 0, '', 'fromforsendingprofile maxwidth200onsmartphone', 1, '', $disablebademails); |
| 583 | - $out.= ' '.$form->selectarray('fromtype', $liste, $defaultfrom, 0, 0, 0, '', 0, 0, 0, '', 'fromforsendingprofile maxwidth200onsmartphone', 0, '', $disablebademails); |
|
| 583 | + $out .= ' '.$form->selectarray('fromtype', $liste, $defaultfrom, 0, 0, 0, '', 0, 0, 0, '', 'fromforsendingprofile maxwidth200onsmartphone', 0, '', $disablebademails); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - $out.= "</td></tr>\n"; |
|
| 586 | + $out .= "</td></tr>\n"; |
|
| 587 | 587 | } |
| 588 | 588 | else |
| 589 | 589 | { |
| 590 | - $out.= '<tr><td class="fieldrequired width200">'.$langs->trans("MailFrom")."</td><td>"; |
|
| 591 | - $out.= $langs->trans("Name").':<input type="text" id="fromname" name="fromname" class="maxwidth200onsmartphone" value="'.$this->fromname.'" />'; |
|
| 592 | - $out.= ' '; |
|
| 593 | - $out.= $langs->trans("EMail").':<<input type="text" id="frommail" name="frommail" class="maxwidth200onsmartphone" value="'.$this->frommail.'" />>'; |
|
| 594 | - $out.= "</td></tr>\n"; |
|
| 590 | + $out .= '<tr><td class="fieldrequired width200">'.$langs->trans("MailFrom")."</td><td>"; |
|
| 591 | + $out .= $langs->trans("Name").':<input type="text" id="fromname" name="fromname" class="maxwidth200onsmartphone" value="'.$this->fromname.'" />'; |
|
| 592 | + $out .= ' '; |
|
| 593 | + $out .= $langs->trans("EMail").':<<input type="text" id="frommail" name="frommail" class="maxwidth200onsmartphone" value="'.$this->frommail.'" />>'; |
|
| 594 | + $out .= "</td></tr>\n"; |
|
| 595 | 595 | } |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | // To |
| 599 | - if (! empty($this->withto) || is_array($this->withto)) |
|
| 599 | + if (!empty($this->withto) || is_array($this->withto)) |
|
| 600 | 600 | { |
| 601 | - $out.= '<tr><td class="fieldrequired">'; |
|
| 602 | - if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); |
|
| 603 | - else $out.= $langs->trans("MailTo"); |
|
| 604 | - $out.= '</td><td>'; |
|
| 601 | + $out .= '<tr><td class="fieldrequired">'; |
|
| 602 | + if ($this->withtofree) $out .= $form->textwithpicto($langs->trans("MailTo"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); |
|
| 603 | + else $out .= $langs->trans("MailTo"); |
|
| 604 | + $out .= '</td><td>'; |
|
| 605 | 605 | if ($this->withtoreadonly) |
| 606 | 606 | { |
| 607 | - if (! empty($this->toname) && ! empty($this->tomail)) |
|
| 607 | + if (!empty($this->toname) && !empty($this->tomail)) |
|
| 608 | 608 | { |
| 609 | - $out.= '<input type="hidden" id="toname" name="toname" value="'.$this->toname.'" />'; |
|
| 610 | - $out.= '<input type="hidden" id="tomail" name="tomail" value="'.$this->tomail.'" />'; |
|
| 609 | + $out .= '<input type="hidden" id="toname" name="toname" value="'.$this->toname.'" />'; |
|
| 610 | + $out .= '<input type="hidden" id="tomail" name="tomail" value="'.$this->tomail.'" />'; |
|
| 611 | 611 | if ($this->totype == 'thirdparty') |
| 612 | 612 | { |
| 613 | - $soc=new Societe($this->db); |
|
| 613 | + $soc = new Societe($this->db); |
|
| 614 | 614 | $soc->fetch($this->toid); |
| 615 | - $out.= $soc->getNomUrl(1); |
|
| 615 | + $out .= $soc->getNomUrl(1); |
|
| 616 | 616 | } |
| 617 | 617 | else if ($this->totype == 'contact') |
| 618 | 618 | { |
| 619 | - $contact=new Contact($this->db); |
|
| 619 | + $contact = new Contact($this->db); |
|
| 620 | 620 | $contact->fetch($this->toid); |
| 621 | - $out.= $contact->getNomUrl(1); |
|
| 621 | + $out .= $contact->getNomUrl(1); |
|
| 622 | 622 | } |
| 623 | 623 | else |
| 624 | 624 | { |
| 625 | - $out.= $this->toname; |
|
| 625 | + $out .= $this->toname; |
|
| 626 | 626 | } |
| 627 | - $out.= ' <'.$this->tomail.'>'; |
|
| 627 | + $out .= ' <'.$this->tomail.'>'; |
|
| 628 | 628 | if ($this->withtofree) |
| 629 | 629 | { |
| 630 | - $out.= '<br>'.$langs->trans("and").' <input class="minwidth200" id="sendto" name="sendto" value="'.(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"").'" />'; |
|
| 630 | + $out .= '<br>'.$langs->trans("and").' <input class="minwidth200" id="sendto" name="sendto" value="'.(!is_array($this->withto) && !is_numeric($this->withto) ? (isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto) : "").'" />'; |
|
| 631 | 631 | } |
| 632 | 632 | } |
| 633 | 633 | else |
| 634 | 634 | { |
| 635 | 635 | // Note withto may be a text like 'AllRecipientSelected' |
| 636 | - $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; |
|
| 636 | + $out .= (!is_array($this->withto) && !is_numeric($this->withto)) ? $this->withto : ""; |
|
| 637 | 637 | } |
| 638 | 638 | } |
| 639 | 639 | else |
| 640 | 640 | { |
| 641 | - if (! empty($this->withtofree)) |
|
| 641 | + if (!empty($this->withtofree)) |
|
| 642 | 642 | { |
| 643 | - $out.= '<input class="minwidth200" id="sendto" name="sendto" value="'.(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"").'" />'; |
|
| 643 | + $out .= '<input class="minwidth200" id="sendto" name="sendto" value="'.(!is_array($this->withto) && !is_numeric($this->withto) ? (isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto) : "").'" />'; |
|
| 644 | 644 | } |
| 645 | - if (! empty($this->withto) && is_array($this->withto)) |
|
| 645 | + if (!empty($this->withto) && is_array($this->withto)) |
|
| 646 | 646 | { |
| 647 | - if (! empty($this->withtofree)) $out.= " ".$langs->trans("and")."/".$langs->trans("or")." "; |
|
| 647 | + if (!empty($this->withtofree)) $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; |
|
| 648 | 648 | // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time |
| 649 | 649 | $tmparray = $this->withto; |
| 650 | - foreach($tmparray as $key => $val) |
|
| 650 | + foreach ($tmparray as $key => $val) |
|
| 651 | 651 | { |
| 652 | - $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); |
|
| 652 | + $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); |
|
| 653 | 653 | } |
| 654 | - $withtoselected=GETPOST("receiver",'none'); // Array of selected value |
|
| 655 | - if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action','aZ09') == 'presend') |
|
| 654 | + $withtoselected = GETPOST("receiver", 'none'); // Array of selected value |
|
| 655 | + if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') |
|
| 656 | 656 | { |
| 657 | 657 | $withtoselected = array_keys($tmparray); |
| 658 | 658 | } |
| 659 | - $out.= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); |
|
| 659 | + $out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); |
|
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | - $out.= "</td></tr>\n"; |
|
| 662 | + $out .= "</td></tr>\n"; |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | // To User |
| 666 | - if (! empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) |
|
| 666 | + if (!empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) |
|
| 667 | 667 | { |
| 668 | - $out.= '<tr><td>'; |
|
| 669 | - $out.= $langs->trans("MailToUsers"); |
|
| 670 | - $out.= '</td><td>'; |
|
| 668 | + $out .= '<tr><td>'; |
|
| 669 | + $out .= $langs->trans("MailToUsers"); |
|
| 670 | + $out .= '</td><td>'; |
|
| 671 | 671 | |
| 672 | 672 | // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time |
| 673 | 673 | $tmparray = $this->withtouser; |
| 674 | - foreach($tmparray as $key => $val) |
|
| 674 | + foreach ($tmparray as $key => $val) |
|
| 675 | 675 | { |
| 676 | - $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); |
|
| 676 | + $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); |
|
| 677 | 677 | } |
| 678 | - $withtoselected=GETPOST("receiveruser",'none'); // Array of selected value |
|
| 679 | - if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action','aZ09') == 'presend') |
|
| 678 | + $withtoselected = GETPOST("receiveruser", 'none'); // Array of selected value |
|
| 679 | + if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') |
|
| 680 | 680 | { |
| 681 | 681 | $withtoselected = array_keys($tmparray); |
| 682 | 682 | } |
| 683 | - $out.= $form->multiselectarray("receiveruser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); |
|
| 684 | - $out.= "</td></tr>\n"; |
|
| 683 | + $out .= $form->multiselectarray("receiveruser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); |
|
| 684 | + $out .= "</td></tr>\n"; |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | // withoptiononeemailperrecipient |
| 688 | - if (! empty($this->withoptiononeemailperrecipient)) |
|
| 688 | + if (!empty($this->withoptiononeemailperrecipient)) |
|
| 689 | 689 | { |
| 690 | - $out.= '<tr><td class="minwidth200">'; |
|
| 691 | - $out.= $langs->trans("GroupEmails"); |
|
| 692 | - $out.= '</td><td>'; |
|
| 693 | - $out.=' <input type="checkbox" name="oneemailperrecipient"'.($this->withoptiononeemailperrecipient > 0?' checked="checked"':'').'> '; |
|
| 694 | - $out.= $langs->trans("OneEmailPerRecipient"); |
|
| 695 | - $out.='<span class="hideonsmartphone">'; |
|
| 696 | - $out.=' - '; |
|
| 697 | - $out.= $langs->trans("WarningIfYouCheckOneRecipientPerEmail"); |
|
| 698 | - $out.='</span>'; |
|
| 699 | - $out.= '</td></tr>'; |
|
| 690 | + $out .= '<tr><td class="minwidth200">'; |
|
| 691 | + $out .= $langs->trans("GroupEmails"); |
|
| 692 | + $out .= '</td><td>'; |
|
| 693 | + $out .= ' <input type="checkbox" name="oneemailperrecipient"'.($this->withoptiononeemailperrecipient > 0 ? ' checked="checked"' : '').'> '; |
|
| 694 | + $out .= $langs->trans("OneEmailPerRecipient"); |
|
| 695 | + $out .= '<span class="hideonsmartphone">'; |
|
| 696 | + $out .= ' - '; |
|
| 697 | + $out .= $langs->trans("WarningIfYouCheckOneRecipientPerEmail"); |
|
| 698 | + $out .= '</span>'; |
|
| 699 | + $out .= '</td></tr>'; |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | // CC |
| 703 | - if (! empty($this->withtocc) || is_array($this->withtocc)) |
|
| 703 | + if (!empty($this->withtocc) || is_array($this->withtocc)) |
|
| 704 | 704 | { |
| 705 | - $out.= '<tr><td>'; |
|
| 706 | - $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); |
|
| 707 | - $out.= '</td><td>'; |
|
| 705 | + $out .= '<tr><td>'; |
|
| 706 | + $out .= $form->textwithpicto($langs->trans("MailCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); |
|
| 707 | + $out .= '</td><td>'; |
|
| 708 | 708 | if ($this->withtoccreadonly) |
| 709 | 709 | { |
| 710 | - $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; |
|
| 710 | + $out .= (!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : ""; |
|
| 711 | 711 | } |
| 712 | 712 | else |
| 713 | 713 | { |
| 714 | - $out.= '<input class="minwidth200" id="sendtocc" name="sendtocc" value="'.((! is_array($this->withtocc) && ! is_numeric($this->withtocc))? (isset($_POST["sendtocc"])?$_POST["sendtocc"]:$this->withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; |
|
| 715 | - if (! empty($this->withtocc) && is_array($this->withtocc)) |
|
| 714 | + $out .= '<input class="minwidth200" id="sendtocc" name="sendtocc" value="'.((!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? (isset($_POST["sendtocc"]) ? $_POST["sendtocc"] : $this->withtocc) : (isset($_POST["sendtocc"]) ? $_POST["sendtocc"] : "")).'" />'; |
|
| 715 | + if (!empty($this->withtocc) && is_array($this->withtocc)) |
|
| 716 | 716 | { |
| 717 | - $out.= " ".$langs->trans("and")."/".$langs->trans("or")." "; |
|
| 717 | + $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; |
|
| 718 | 718 | // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time |
| 719 | 719 | $tmparray = $this->withtocc; |
| 720 | - foreach($tmparray as $key => $val) |
|
| 720 | + foreach ($tmparray as $key => $val) |
|
| 721 | 721 | { |
| 722 | - $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); |
|
| 722 | + $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); |
|
| 723 | 723 | } |
| 724 | - $withtoccselected=GETPOST("receivercc"); // Array of selected value |
|
| 725 | - $out.= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500',null, ""); |
|
| 724 | + $withtoccselected = GETPOST("receivercc"); // Array of selected value |
|
| 725 | + $out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', null, ""); |
|
| 726 | 726 | } |
| 727 | 727 | } |
| 728 | - $out.= "</td></tr>\n"; |
|
| 728 | + $out .= "</td></tr>\n"; |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | // To User cc |
| 732 | - if (! empty($this->withtoccuser) && is_array($this->withtoccuser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) |
|
| 732 | + if (!empty($this->withtoccuser) && is_array($this->withtoccuser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) |
|
| 733 | 733 | { |
| 734 | - $out.= '<tr><td>'; |
|
| 735 | - $out.= $langs->trans("MailToCCUsers"); |
|
| 736 | - $out.= '</td><td>'; |
|
| 734 | + $out .= '<tr><td>'; |
|
| 735 | + $out .= $langs->trans("MailToCCUsers"); |
|
| 736 | + $out .= '</td><td>'; |
|
| 737 | 737 | |
| 738 | 738 | // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time |
| 739 | 739 | $tmparray = $this->withtoccuser; |
| 740 | - foreach($tmparray as $key => $val) |
|
| 740 | + foreach ($tmparray as $key => $val) |
|
| 741 | 741 | { |
| 742 | - $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); |
|
| 742 | + $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); |
|
| 743 | 743 | } |
| 744 | - $withtoselected=GETPOST("receiverccuser",'none'); // Array of selected value |
|
| 745 | - if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action','aZ09') == 'presend') |
|
| 744 | + $withtoselected = GETPOST("receiverccuser", 'none'); // Array of selected value |
|
| 745 | + if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') |
|
| 746 | 746 | { |
| 747 | 747 | $withtoselected = array_keys($tmparray); |
| 748 | 748 | } |
| 749 | - $out.= $form->multiselectarray("receiverccuser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); |
|
| 750 | - $out.= "</td></tr>\n"; |
|
| 749 | + $out .= $form->multiselectarray("receiverccuser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); |
|
| 750 | + $out .= "</td></tr>\n"; |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | // CCC |
| 754 | - if (! empty($this->withtoccc) || is_array($this->withtoccc)) { |
|
| 754 | + if (!empty($this->withtoccc) || is_array($this->withtoccc)) { |
|
| 755 | 755 | $out .= $this->getHtmlForWithCcc(); |
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | // Replyto |
| 759 | - if (! empty($this->withreplyto)) |
|
| 759 | + if (!empty($this->withreplyto)) |
|
| 760 | 760 | { |
| 761 | 761 | if ($this->withreplytoreadonly) |
| 762 | 762 | { |
| 763 | - $out.= '<input type="hidden" id="replyname" name="replyname" value="'.$this->replytoname.'" />'; |
|
| 764 | - $out.= '<input type="hidden" id="replymail" name="replymail" value="'.$this->replytomail.'" />'; |
|
| 765 | - $out.= "<tr><td>".$langs->trans("MailReply")."</td><td>".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); |
|
| 766 | - $out.= "</td></tr>\n"; |
|
| 763 | + $out .= '<input type="hidden" id="replyname" name="replyname" value="'.$this->replytoname.'" />'; |
|
| 764 | + $out .= '<input type="hidden" id="replymail" name="replymail" value="'.$this->replytomail.'" />'; |
|
| 765 | + $out .= "<tr><td>".$langs->trans("MailReply")."</td><td>".$this->replytoname.($this->replytomail ? (" <".$this->replytomail.">") : ""); |
|
| 766 | + $out .= "</td></tr>\n"; |
|
| 767 | 767 | } |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | // Errorsto |
| 771 | - if (! empty($this->witherrorsto)) { |
|
| 771 | + if (!empty($this->witherrorsto)) { |
|
| 772 | 772 | $out .= $this->getHtmlForWithErrorsTo(); |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | // Ask delivery receipt |
| 776 | - if (! empty($this->withdeliveryreceipt)) { |
|
| 776 | + if (!empty($this->withdeliveryreceipt)) { |
|
| 777 | 777 | $out .= $this->getHtmlForDeliveryReceipt(); |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | // Topic |
| 781 | - if (! empty($this->withtopic)) { |
|
| 781 | + if (!empty($this->withtopic)) { |
|
| 782 | 782 | $out .= $this->getHtmlForTopic(); |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | // Attached files |
| 786 | - if (! empty($this->withfile)) |
|
| 786 | + if (!empty($this->withfile)) |
|
| 787 | 787 | { |
| 788 | - $out.= '<tr>'; |
|
| 789 | - $out.= '<td>'.$langs->trans("MailFile").'</td>'; |
|
| 788 | + $out .= '<tr>'; |
|
| 789 | + $out .= '<td>'.$langs->trans("MailFile").'</td>'; |
|
| 790 | 790 | |
| 791 | - $out.= '<td>'; |
|
| 791 | + $out .= '<td>'; |
|
| 792 | 792 | |
| 793 | 793 | if ($this->withmaindocfile) // withmaindocfile is set to 1 or -1 to show the checkbox (-1 = checked or 1 = not checked) |
| 794 | 794 | { |
@@ -803,94 +803,94 @@ discard block |
||
| 803 | 803 | } |
| 804 | 804 | } |
| 805 | 805 | |
| 806 | - if (! empty($this->withmaindocfile)) |
|
| 806 | + if (!empty($this->withmaindocfile)) |
|
| 807 | 807 | { |
| 808 | 808 | if ($this->withmaindocfile == 1) |
| 809 | 809 | { |
| 810 | - $out.='<input type="checkbox" name="addmaindocfile" value="1" />'; |
|
| 810 | + $out .= '<input type="checkbox" name="addmaindocfile" value="1" />'; |
|
| 811 | 811 | } |
| 812 | 812 | if ($this->withmaindocfile == -1) |
| 813 | 813 | { |
| 814 | - $out.='<input type="checkbox" name="addmaindocfile" value="1" checked="checked" />'; |
|
| 814 | + $out .= '<input type="checkbox" name="addmaindocfile" value="1" checked="checked" />'; |
|
| 815 | 815 | } |
| 816 | - $out.=' '.$langs->trans("JoinMainDoc").'.<br>'; |
|
| 816 | + $out .= ' '.$langs->trans("JoinMainDoc").'.<br>'; |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | if (is_numeric($this->withfile)) |
| 820 | 820 | { |
| 821 | 821 | // TODO Trick to have param removedfile containing nb of file to delete. But this does not works without javascript |
| 822 | - $out.= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n"; |
|
| 823 | - $out.= '<script type="text/javascript" language="javascript">'; |
|
| 824 | - $out.= 'jQuery(document).ready(function () {'; |
|
| 825 | - $out.= ' jQuery(".removedfile").click(function() {'; |
|
| 826 | - $out.= ' jQuery(".removedfilehidden").val(jQuery(this).val());'; |
|
| 827 | - $out.= ' });'; |
|
| 828 | - $out.= '})'; |
|
| 829 | - $out.= '</script>'."\n"; |
|
| 822 | + $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n"; |
|
| 823 | + $out .= '<script type="text/javascript" language="javascript">'; |
|
| 824 | + $out .= 'jQuery(document).ready(function () {'; |
|
| 825 | + $out .= ' jQuery(".removedfile").click(function() {'; |
|
| 826 | + $out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());'; |
|
| 827 | + $out .= ' });'; |
|
| 828 | + $out .= '})'; |
|
| 829 | + $out .= '</script>'."\n"; |
|
| 830 | 830 | if (count($listofpaths)) |
| 831 | 831 | { |
| 832 | - foreach($listofpaths as $key => $val) |
|
| 832 | + foreach ($listofpaths as $key => $val) |
|
| 833 | 833 | { |
| 834 | - $out.= '<div id="attachfile_'.$key.'">'; |
|
| 835 | - $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; |
|
| 836 | - if (! $this->withfilereadonly) |
|
| 834 | + $out .= '<div id="attachfile_'.$key.'">'; |
|
| 835 | + $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; |
|
| 836 | + if (!$this->withfilereadonly) |
|
| 837 | 837 | { |
| 838 | - $out.= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key+1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />'; |
|
| 838 | + $out .= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />'; |
|
| 839 | 839 | //$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>'; |
| 840 | 840 | } |
| 841 | - $out.= '<br></div>'; |
|
| 841 | + $out .= '<br></div>'; |
|
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | else if (empty($this->withmaindocfile)) // Do not show message if we asked to show the checkbox |
| 845 | 845 | { |
| 846 | - $out.= $langs->trans("NoAttachedFiles").'<br>'; |
|
| 846 | + $out .= $langs->trans("NoAttachedFiles").'<br>'; |
|
| 847 | 847 | } |
| 848 | 848 | if ($this->withfile == 2) // Can add other files |
| 849 | 849 | { |
| 850 | - if (!empty($conf->global->FROM_MAIL_USE_INPUT_FILE_MULTIPLE)) $out.= '<input type="file" class="flat" id="addedfile" name="addedfile[]" value="'.$langs->trans("Upload").'" multiple />'; |
|
| 851 | - else $out.= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />'; |
|
| 852 | - $out.= ' '; |
|
| 853 | - $out.= '<input class="button" type="submit" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />'; |
|
| 850 | + if (!empty($conf->global->FROM_MAIL_USE_INPUT_FILE_MULTIPLE)) $out .= '<input type="file" class="flat" id="addedfile" name="addedfile[]" value="'.$langs->trans("Upload").'" multiple />'; |
|
| 851 | + else $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />'; |
|
| 852 | + $out .= ' '; |
|
| 853 | + $out .= '<input class="button" type="submit" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />'; |
|
| 854 | 854 | } |
| 855 | 855 | } |
| 856 | 856 | else |
| 857 | 857 | { |
| 858 | - $out.=$this->withfile; |
|
| 858 | + $out .= $this->withfile; |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | - $out.= "</td></tr>\n"; |
|
| 861 | + $out .= "</td></tr>\n"; |
|
| 862 | 862 | } |
| 863 | 863 | |
| 864 | 864 | // Message |
| 865 | - if (! empty($this->withbody)) |
|
| 865 | + if (!empty($this->withbody)) |
|
| 866 | 866 | { |
| 867 | - $defaultmessage=GETPOST('message','none'); |
|
| 868 | - if (! GETPOST('modelselected','alpha') || GETPOST('modelmailselected') != '-1') |
|
| 867 | + $defaultmessage = GETPOST('message', 'none'); |
|
| 868 | + if (!GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') |
|
| 869 | 869 | { |
| 870 | 870 | if ($arraydefaultmessage && $arraydefaultmessage->content) { |
| 871 | 871 | $defaultmessage = $arraydefaultmessage->content; |
| 872 | - } elseif (! is_numeric($this->withbody)) { |
|
| 872 | + } elseif (!is_numeric($this->withbody)) { |
|
| 873 | 873 | $defaultmessage = $this->withbody; |
| 874 | 874 | } |
| 875 | 875 | } |
| 876 | 876 | |
| 877 | 877 | // Complete substitution array with the url to make online payment |
| 878 | - $paymenturl=''; $validpaymentmethod=array(); |
|
| 878 | + $paymenturl = ''; $validpaymentmethod = array(); |
|
| 879 | 879 | if (empty($this->substit['__REF__'])) |
| 880 | 880 | { |
| 881 | - $paymenturl=''; |
|
| 881 | + $paymenturl = ''; |
|
| 882 | 882 | } |
| 883 | 883 | else |
| 884 | 884 | { |
| 885 | 885 | // Set the online payment url link into __ONLINE_PAYMENT_URL__ key |
| 886 | 886 | require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; |
| 887 | - $langs->loadLangs(array('paypal','other')); |
|
| 888 | - $typeforonlinepayment='free'; |
|
| 889 | - if ($this->param["models"]=='order' || $this->param["models"]=='order_send') $typeforonlinepayment='order'; // TODO use detection on something else than template |
|
| 890 | - if ($this->param["models"]=='invoice' || $this->param["models"]=='facture_send') $typeforonlinepayment='invoice'; // TODO use detection on something else than template |
|
| 891 | - if ($this->param["models"]=='member') $typeforonlinepayment='member'; // TODO use detection on something else than template |
|
| 892 | - $url=getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']); |
|
| 893 | - $paymenturl=$url; |
|
| 887 | + $langs->loadLangs(array('paypal', 'other')); |
|
| 888 | + $typeforonlinepayment = 'free'; |
|
| 889 | + if ($this->param["models"] == 'order' || $this->param["models"] == 'order_send') $typeforonlinepayment = 'order'; // TODO use detection on something else than template |
|
| 890 | + if ($this->param["models"] == 'invoice' || $this->param["models"] == 'facture_send') $typeforonlinepayment = 'invoice'; // TODO use detection on something else than template |
|
| 891 | + if ($this->param["models"] == 'member') $typeforonlinepayment = 'member'; // TODO use detection on something else than template |
|
| 892 | + $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']); |
|
| 893 | + $paymenturl = $url; |
|
| 894 | 894 | |
| 895 | 895 | $validpaymentmethod = getValidOnlinePaymentMethods(''); |
| 896 | 896 | } |
@@ -898,13 +898,13 @@ discard block |
||
| 898 | 898 | if (count($validpaymentmethod) > 0 && $paymenturl) |
| 899 | 899 | { |
| 900 | 900 | $langs->load('other'); |
| 901 | - $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']=str_replace('\n', "\n", $langs->transnoentities("PredefinedMailContentLink", $paymenturl)); |
|
| 902 | - $this->substit['__ONLINE_PAYMENT_URL__']=$paymenturl; |
|
| 901 | + $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = str_replace('\n', "\n", $langs->transnoentities("PredefinedMailContentLink", $paymenturl)); |
|
| 902 | + $this->substit['__ONLINE_PAYMENT_URL__'] = $paymenturl; |
|
| 903 | 903 | } |
| 904 | 904 | else |
| 905 | 905 | { |
| 906 | - $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']=''; |
|
| 907 | - $this->substit['__ONLINE_PAYMENT_URL__']=''; |
|
| 906 | + $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = ''; |
|
| 907 | + $this->substit['__ONLINE_PAYMENT_URL__'] = ''; |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | //Add lines substitution key from each line |
@@ -914,96 +914,96 @@ discard block |
||
| 914 | 914 | { |
| 915 | 915 | foreach ($this->substit_lines as $substit_line) |
| 916 | 916 | { |
| 917 | - $lines .= make_substitutions($defaultlines,$substit_line)."\n"; |
|
| 917 | + $lines .= make_substitutions($defaultlines, $substit_line)."\n"; |
|
| 918 | 918 | } |
| 919 | 919 | } |
| 920 | - $this->substit['__LINES__']=$lines; |
|
| 920 | + $this->substit['__LINES__'] = $lines; |
|
| 921 | 921 | |
| 922 | - $defaultmessage=str_replace('\n',"\n",$defaultmessage); |
|
| 922 | + $defaultmessage = str_replace('\n', "\n", $defaultmessage); |
|
| 923 | 923 | |
| 924 | 924 | // Deal with format differences between message and signature (text / HTML) |
| 925 | 925 | if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__USER_SIGNATURE__'])) { |
| 926 | 926 | $this->substit['__USER_SIGNATURE__'] = dol_nl2br($this->substit['__USER_SIGNATURE__']); |
| 927 | - } else if(!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) { |
|
| 927 | + } else if (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) { |
|
| 928 | 928 | $defaultmessage = dol_nl2br($defaultmessage); |
| 929 | 929 | } |
| 930 | 930 | |
| 931 | - if (isset($_POST["message"]) && ! $_POST['modelselected']) $defaultmessage=$_POST["message"]; |
|
| 931 | + if (isset($_POST["message"]) && !$_POST['modelselected']) $defaultmessage = $_POST["message"]; |
|
| 932 | 932 | else |
| 933 | 933 | { |
| 934 | - $defaultmessage=make_substitutions($defaultmessage,$this->substit); |
|
| 934 | + $defaultmessage = make_substitutions($defaultmessage, $this->substit); |
|
| 935 | 935 | // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty) |
| 936 | - $defaultmessage=preg_replace("/^(<br>)+/","",$defaultmessage); |
|
| 937 | - $defaultmessage=preg_replace("/^\n+/","",$defaultmessage); |
|
| 936 | + $defaultmessage = preg_replace("/^(<br>)+/", "", $defaultmessage); |
|
| 937 | + $defaultmessage = preg_replace("/^\n+/", "", $defaultmessage); |
|
| 938 | 938 | } |
| 939 | 939 | |
| 940 | - $out.= '<tr>'; |
|
| 941 | - $out.= '<td valign="top">'; |
|
| 942 | - $out.=$form->textwithpicto($langs->trans('MailText'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody'); |
|
| 943 | - $out.='</td>'; |
|
| 944 | - $out.= '<td>'; |
|
| 940 | + $out .= '<tr>'; |
|
| 941 | + $out .= '<td valign="top">'; |
|
| 942 | + $out .= $form->textwithpicto($langs->trans('MailText'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody'); |
|
| 943 | + $out .= '</td>'; |
|
| 944 | + $out .= '<td>'; |
|
| 945 | 945 | if ($this->withbodyreadonly) |
| 946 | 946 | { |
| 947 | - $out.= nl2br($defaultmessage); |
|
| 948 | - $out.= '<input type="hidden" id="message" name="message" value="'.$defaultmessage.'" />'; |
|
| 947 | + $out .= nl2br($defaultmessage); |
|
| 948 | + $out .= '<input type="hidden" id="message" name="message" value="'.$defaultmessage.'" />'; |
|
| 949 | 949 | } |
| 950 | 950 | else |
| 951 | 951 | { |
| 952 | - if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; |
|
| 952 | + if (!isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; |
|
| 953 | 953 | |
| 954 | 954 | // Editor wysiwyg |
| 955 | 955 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 956 | 956 | if ($this->withfckeditor == -1) |
| 957 | 957 | { |
| 958 | - if (! empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $this->withfckeditor=1; |
|
| 959 | - else $this->withfckeditor=0; |
|
| 958 | + if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $this->withfckeditor = 1; |
|
| 959 | + else $this->withfckeditor = 0; |
|
| 960 | 960 | } |
| 961 | 961 | |
| 962 | - $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,'95%'); |
|
| 963 | - $out.= $doleditor->Create(1); |
|
| 962 | + $doleditor = new DolEditor('message', $defaultmessage, '', 280, $this->ckeditortoolbar, 'In', true, true, $this->withfckeditor, 8, '95%'); |
|
| 963 | + $out .= $doleditor->Create(1); |
|
| 964 | 964 | } |
| 965 | - $out.= "</td></tr>\n"; |
|
| 965 | + $out .= "</td></tr>\n"; |
|
| 966 | 966 | } |
| 967 | 967 | |
| 968 | - $out.= '</table>'."\n"; |
|
| 968 | + $out .= '</table>'."\n"; |
|
| 969 | 969 | |
| 970 | 970 | if ($this->withform == 1 || $this->withform == -1) |
| 971 | 971 | { |
| 972 | - $out.= '<br><div class="center">'; |
|
| 973 | - $out.= '<input class="button" type="submit" id="sendmail" name="sendmail" value="'.$langs->trans("SendMail").'"'; |
|
| 972 | + $out .= '<br><div class="center">'; |
|
| 973 | + $out .= '<input class="button" type="submit" id="sendmail" name="sendmail" value="'.$langs->trans("SendMail").'"'; |
|
| 974 | 974 | // Add a javascript test to avoid to forget to submit file before sending email |
| 975 | 975 | if ($this->withfile == 2 && $conf->use_javascript_ajax) |
| 976 | 976 | { |
| 977 | - $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; |
|
| 977 | + $out .= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; |
|
| 978 | 978 | } |
| 979 | - $out.= ' />'; |
|
| 979 | + $out .= ' />'; |
|
| 980 | 980 | if ($this->withcancel) |
| 981 | 981 | { |
| 982 | - $out.= ' '; |
|
| 983 | - $out.= '<input class="button" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'" />'; |
|
| 982 | + $out .= ' '; |
|
| 983 | + $out .= '<input class="button" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'" />'; |
|
| 984 | 984 | } |
| 985 | - $out.= '</div>'."\n"; |
|
| 985 | + $out .= '</div>'."\n"; |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | - if ($this->withform == 1) $out.= '</form>'."\n"; |
|
| 988 | + if ($this->withform == 1) $out .= '</form>'."\n"; |
|
| 989 | 989 | |
| 990 | 990 | // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set |
| 991 | - if (! empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) |
|
| 991 | + if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) |
|
| 992 | 992 | { |
| 993 | - $out.= '<script type="text/javascript" language="javascript">'; |
|
| 994 | - $out.= 'jQuery(document).ready(function () {'; |
|
| 995 | - $out.= ' $(document).on("keypress", \'#mailform\', function (e) { /* Note this is called at every key pressed ! */ |
|
| 993 | + $out .= '<script type="text/javascript" language="javascript">'; |
|
| 994 | + $out .= 'jQuery(document).ready(function () {'; |
|
| 995 | + $out .= ' $(document).on("keypress", \'#mailform\', function (e) { /* Note this is called at every key pressed ! */ |
|
| 996 | 996 | var code = e.keyCode || e.which; |
| 997 | 997 | if (code == 13) { |
| 998 | 998 | e.preventDefault(); |
| 999 | 999 | return false; |
| 1000 | 1000 | } |
| 1001 | 1001 | });'; |
| 1002 | - $out.=' })'; |
|
| 1003 | - $out.= '</script>'; |
|
| 1002 | + $out .= ' })'; |
|
| 1003 | + $out .= '</script>'; |
|
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | - $out.= "<!-- End form mail -->\n"; |
|
| 1006 | + $out .= "<!-- End form mail -->\n"; |
|
| 1007 | 1007 | |
| 1008 | 1008 | return $out; |
| 1009 | 1009 | } |
@@ -1018,31 +1018,31 @@ discard block |
||
| 1018 | 1018 | { |
| 1019 | 1019 | global $conf, $langs, $form; |
| 1020 | 1020 | $out = '<tr><td>'; |
| 1021 | - $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); |
|
| 1022 | - $out.= '</td><td>'; |
|
| 1023 | - if (! empty($this->withtocccreadonly)) { |
|
| 1024 | - $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; |
|
| 1021 | + $out .= $form->textwithpicto($langs->trans("MailCCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); |
|
| 1022 | + $out .= '</td><td>'; |
|
| 1023 | + if (!empty($this->withtocccreadonly)) { |
|
| 1024 | + $out .= (!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : ""; |
|
| 1025 | 1025 | } else { |
| 1026 | - $out.= '<input class="minwidth200" id="sendtoccc" name="sendtoccc" value="'.((! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))? (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:$this->withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; |
|
| 1027 | - if (! empty($this->withtoccc) && is_array($this->withtoccc)) { |
|
| 1028 | - $out.= " ".$langs->trans("and")."/".$langs->trans("or")." "; |
|
| 1026 | + $out .= '<input class="minwidth200" id="sendtoccc" name="sendtoccc" value="'.((!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? (isset($_POST["sendtoccc"]) ? $_POST["sendtoccc"] : $this->withtoccc) : (isset($_POST["sendtoccc"]) ? $_POST["sendtoccc"] : "")).'" />'; |
|
| 1027 | + if (!empty($this->withtoccc) && is_array($this->withtoccc)) { |
|
| 1028 | + $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; |
|
| 1029 | 1029 | // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time |
| 1030 | 1030 | $tmparray = $this->withtoccc; |
| 1031 | 1031 | foreach ($tmparray as $key => $val) { |
| 1032 | - $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); |
|
| 1032 | + $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); |
|
| 1033 | 1033 | } |
| 1034 | - $withtocccselected=GETPOST("receiverccc"); // Array of selected value |
|
| 1035 | - $out.= $form->multiselectarray("receiverccc", $tmparray, $withtocccselected, null, null, null,null, "90%"); |
|
| 1034 | + $withtocccselected = GETPOST("receiverccc"); // Array of selected value |
|
| 1035 | + $out .= $form->multiselectarray("receiverccc", $tmparray, $withtocccselected, null, null, null, null, "90%"); |
|
| 1036 | 1036 | } |
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | - $showinfobcc=''; |
|
| 1040 | - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO; |
|
| 1041 | - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO; |
|
| 1042 | - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; |
|
| 1043 | - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO; |
|
| 1044 | - if ($showinfobcc) $out.=' + '.$showinfobcc; |
|
| 1045 | - $out.= "</td></tr>\n"; |
|
| 1039 | + $showinfobcc = ''; |
|
| 1040 | + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO; |
|
| 1041 | + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO; |
|
| 1042 | + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; |
|
| 1043 | + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO; |
|
| 1044 | + if ($showinfobcc) $out .= ' + '.$showinfobcc; |
|
| 1045 | + $out .= "</td></tr>\n"; |
|
| 1046 | 1046 | return $out; |
| 1047 | 1047 | } |
| 1048 | 1048 | |
@@ -1055,16 +1055,16 @@ discard block |
||
| 1055 | 1055 | { |
| 1056 | 1056 | global $conf, $langs; |
| 1057 | 1057 | //if (! $this->errorstomail) $this->errorstomail=$this->frommail; |
| 1058 | - $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); |
|
| 1058 | + $errorstomail = (!empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); |
|
| 1059 | 1059 | if ($this->witherrorstoreadonly) { |
| 1060 | - $out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>'; |
|
| 1060 | + $out .= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>'; |
|
| 1061 | 1061 | $out = '<input type="hidden" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />'; |
| 1062 | - $out.= $errorstomail; |
|
| 1063 | - $out.= "</td></tr>\n"; |
|
| 1062 | + $out .= $errorstomail; |
|
| 1063 | + $out .= "</td></tr>\n"; |
|
| 1064 | 1064 | } else { |
| 1065 | - $out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>'; |
|
| 1066 | - $out.= '<input size="30" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />'; |
|
| 1067 | - $out.= "</td></tr>\n"; |
|
| 1065 | + $out .= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>'; |
|
| 1066 | + $out .= '<input size="30" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />'; |
|
| 1067 | + $out .= "</td></tr>\n"; |
|
| 1068 | 1068 | } |
| 1069 | 1069 | return $out; |
| 1070 | 1070 | } |
@@ -1079,17 +1079,17 @@ discard block |
||
| 1079 | 1079 | global $conf, $langs, $form; |
| 1080 | 1080 | $out = '<tr><td>'.$langs->trans("DeliveryReceipt").'</td><td>'; |
| 1081 | 1081 | |
| 1082 | - if (! empty($this->withdeliveryreceiptreadonly)) { |
|
| 1083 | - $out.= yn($this->withdeliveryreceipt); |
|
| 1082 | + if (!empty($this->withdeliveryreceiptreadonly)) { |
|
| 1083 | + $out .= yn($this->withdeliveryreceipt); |
|
| 1084 | 1084 | } else { |
| 1085 | - $defaultvaluefordeliveryreceipt=0; |
|
| 1086 | - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_PROPAL) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $defaultvaluefordeliveryreceipt=1; |
|
| 1087 | - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_SUPPLIER_PROPOSAL) && ! empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $defaultvaluefordeliveryreceipt=1; |
|
| 1088 | - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $defaultvaluefordeliveryreceipt=1; |
|
| 1089 | - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $defaultvaluefordeliveryreceipt=1; |
|
| 1090 | - $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:$defaultvaluefordeliveryreceipt), 1); |
|
| 1085 | + $defaultvaluefordeliveryreceipt = 0; |
|
| 1086 | + if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_PROPAL) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') $defaultvaluefordeliveryreceipt = 1; |
|
| 1087 | + if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_SUPPLIER_PROPOSAL) && !empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $defaultvaluefordeliveryreceipt = 1; |
|
| 1088 | + if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && !empty($this->param['models']) && $this->param['models'] == 'order_send') $defaultvaluefordeliveryreceipt = 1; |
|
| 1089 | + if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') $defaultvaluefordeliveryreceipt = 1; |
|
| 1090 | + $out .= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"]) ? $_POST["deliveryreceipt"] : $defaultvaluefordeliveryreceipt), 1); |
|
| 1091 | 1091 | } |
| 1092 | - $out.= "</td></tr>\n"; |
|
| 1092 | + $out .= "</td></tr>\n"; |
|
| 1093 | 1093 | return $out; |
| 1094 | 1094 | } |
| 1095 | 1095 | |
@@ -1101,29 +1101,29 @@ discard block |
||
| 1101 | 1101 | public function getHtmlForTopic() |
| 1102 | 1102 | { |
| 1103 | 1103 | global $conf, $langs, $form; |
| 1104 | - $defaulttopic = GETPOST('subject','none'); |
|
| 1105 | - if (! GETPOST('modelselected','alpha') || GETPOST('modelmailselected') != '-1') { |
|
| 1104 | + $defaulttopic = GETPOST('subject', 'none'); |
|
| 1105 | + if (!GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') { |
|
| 1106 | 1106 | if ($arraydefaultmessage && $arraydefaultmessage->topic) { |
| 1107 | 1107 | $defaulttopic = $arraydefaultmessage->topic; |
| 1108 | - } elseif (! is_numeric($this->withtopic)) { |
|
| 1108 | + } elseif (!is_numeric($this->withtopic)) { |
|
| 1109 | 1109 | $defaulttopic = $this->withtopic; |
| 1110 | 1110 | } |
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | - $defaulttopic=make_substitutions($defaulttopic,$this->substit); |
|
| 1113 | + $defaulttopic = make_substitutions($defaulttopic, $this->substit); |
|
| 1114 | 1114 | |
| 1115 | 1115 | $out = '<tr>'; |
| 1116 | - $out.= '<td class="fieldrequired">'; |
|
| 1117 | - $out.= $form->textwithpicto($langs->trans('MailTopic'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfromtopic'); |
|
| 1118 | - $out.= '</td>'; |
|
| 1119 | - $out.= '<td>'; |
|
| 1116 | + $out .= '<td class="fieldrequired">'; |
|
| 1117 | + $out .= $form->textwithpicto($langs->trans('MailTopic'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfromtopic'); |
|
| 1118 | + $out .= '</td>'; |
|
| 1119 | + $out .= '<td>'; |
|
| 1120 | 1120 | if ($this->withtopicreadonly) { |
| 1121 | - $out.= $defaulttopic; |
|
| 1122 | - $out.= '<input type="hidden" class="quatrevingtpercent" id="subject" name="subject" value="'.$defaulttopic.'" />'; |
|
| 1121 | + $out .= $defaulttopic; |
|
| 1122 | + $out .= '<input type="hidden" class="quatrevingtpercent" id="subject" name="subject" value="'.$defaulttopic.'" />'; |
|
| 1123 | 1123 | } else { |
| 1124 | - $out.= '<input type="text" class="quatrevingtpercent" id="subject" name="subject" value="'. ((isset($_POST["subject"]) && ! $_POST['modelselected'])?$_POST["subject"]:($defaulttopic?$defaulttopic:'')) .'" />'; |
|
| 1124 | + $out .= '<input type="text" class="quatrevingtpercent" id="subject" name="subject" value="'.((isset($_POST["subject"]) && !$_POST['modelselected']) ? $_POST["subject"] : ($defaulttopic ? $defaulttopic : '')).'" />'; |
|
| 1125 | 1125 | } |
| 1126 | - $out.= "</td></tr>\n"; |
|
| 1126 | + $out .= "</td></tr>\n"; |
|
| 1127 | 1127 | return $out; |
| 1128 | 1128 | } |
| 1129 | 1129 | |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | * @param string $label Label of template |
| 1141 | 1141 | * @return ModelMail One instance of ModelMail |
| 1142 | 1142 | */ |
| 1143 | - public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1, $label='') |
|
| 1143 | + public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '') |
|
| 1144 | 1144 | { |
| 1145 | 1145 | $ret = new ModelMail(); |
| 1146 | 1146 | |
@@ -1151,18 +1151,18 @@ discard block |
||
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | 1153 | $sql = "SELECT rowid, label, topic, joinfiles, content, content_lines, lang"; |
| 1154 | - $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; |
|
| 1155 | - $sql.= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')"; |
|
| 1156 | - $sql.= " AND entity IN (".getEntity('c_email_templates').")"; |
|
| 1157 | - $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned |
|
| 1158 | - if ($active >= 0) $sql.=" AND active = ".$active; |
|
| 1159 | - if ($label) $sql.=" AND label ='".$db->escape($label)."'"; |
|
| 1160 | - if (! ($id > 0) && is_object($outputlangs)) $sql.= " AND (lang = '".$db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')"; |
|
| 1161 | - if ($id > 0) $sql.= " AND rowid=".$id; |
|
| 1162 | - if ($id == -1) $sql.= " AND position=0"; |
|
| 1163 | - if (is_object($outputlangs)) $sql.= $db->order("position,lang,label","ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' |
|
| 1164 | - else $sql.= $db->order("position,lang,label","ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined |
|
| 1165 | - $sql.= $db->plimit(1); |
|
| 1154 | + $sql .= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; |
|
| 1155 | + $sql .= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')"; |
|
| 1156 | + $sql .= " AND entity IN (".getEntity('c_email_templates').")"; |
|
| 1157 | + $sql .= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned |
|
| 1158 | + if ($active >= 0) $sql .= " AND active = ".$active; |
|
| 1159 | + if ($label) $sql .= " AND label ='".$db->escape($label)."'"; |
|
| 1160 | + if (!($id > 0) && is_object($outputlangs)) $sql .= " AND (lang = '".$db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')"; |
|
| 1161 | + if ($id > 0) $sql .= " AND rowid=".$id; |
|
| 1162 | + if ($id == -1) $sql .= " AND position=0"; |
|
| 1163 | + if (is_object($outputlangs)) $sql .= $db->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' |
|
| 1164 | + else $sql .= $db->order("position,lang,label", "ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined |
|
| 1165 | + $sql .= $db->plimit(1); |
|
| 1166 | 1166 | //print $sql; |
| 1167 | 1167 | |
| 1168 | 1168 | $resql = $db->query($sql); |
@@ -1180,32 +1180,32 @@ discard block |
||
| 1180 | 1180 | $ret->content_lines = $obj->content_lines; |
| 1181 | 1181 | $ret->joinfiles = $obj->joinfiles; |
| 1182 | 1182 | } |
| 1183 | - elseif($id == -2) { |
|
| 1183 | + elseif ($id == -2) { |
|
| 1184 | 1184 | // Not found with the provided label |
| 1185 | 1185 | return -1; |
| 1186 | 1186 | } |
| 1187 | 1187 | else { // If there is no template at all |
| 1188 | - $defaultmessage=''; |
|
| 1189 | - if ($type_template=='body') { $defaultmessage=$this->withbody; } // Special case to use this->withbody as content |
|
| 1190 | - elseif ($type_template=='facture_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoice"); } |
|
| 1191 | - elseif ($type_template=='facture_relance') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } |
|
| 1192 | - elseif ($type_template=='propal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendProposal"); } |
|
| 1193 | - elseif ($type_template=='supplier_proposal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierProposal"); } |
|
| 1194 | - elseif ($type_template=='order_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendOrder"); } |
|
| 1195 | - elseif ($type_template=='order_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); } |
|
| 1196 | - elseif ($type_template=='invoice_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } |
|
| 1197 | - elseif ($type_template=='shipping_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendShipping"); } |
|
| 1198 | - elseif ($type_template=='fichinter_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } |
|
| 1199 | - elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); } |
|
| 1200 | - elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); } |
|
| 1201 | - elseif (!empty($type_template)) { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContent".ucfirst($type_template)); } |
|
| 1188 | + $defaultmessage = ''; |
|
| 1189 | + if ($type_template == 'body') { $defaultmessage = $this->withbody; } // Special case to use this->withbody as content |
|
| 1190 | + elseif ($type_template == 'facture_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoice"); } |
|
| 1191 | + elseif ($type_template == 'facture_relance') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } |
|
| 1192 | + elseif ($type_template == 'propal_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendProposal"); } |
|
| 1193 | + elseif ($type_template == 'supplier_proposal_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierProposal"); } |
|
| 1194 | + elseif ($type_template == 'order_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendOrder"); } |
|
| 1195 | + elseif ($type_template == 'order_supplier_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); } |
|
| 1196 | + elseif ($type_template == 'invoice_supplier_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } |
|
| 1197 | + elseif ($type_template == 'shipping_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendShipping"); } |
|
| 1198 | + elseif ($type_template == 'fichinter_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } |
|
| 1199 | + elseif ($type_template == 'thirdparty') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentThirdparty"); } |
|
| 1200 | + elseif ($type_template == 'user') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentUser"); } |
|
| 1201 | + elseif (!empty($type_template)) { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContent".ucfirst($type_template)); } |
|
| 1202 | 1202 | |
| 1203 | 1203 | $ret->label = 'default'; |
| 1204 | 1204 | $ret->lang = $outputlangs->defaultlang; |
| 1205 | 1205 | $ret->topic = ''; |
| 1206 | 1206 | $ret->joinfiles = 1; |
| 1207 | 1207 | $ret->content = $defaultmessage; |
| 1208 | - $ret->content_lines =''; |
|
| 1208 | + $ret->content_lines = ''; |
|
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | 1211 | $db->free($resql); |
@@ -1229,27 +1229,27 @@ discard block |
||
| 1229 | 1229 | */ |
| 1230 | 1230 | public function isEMailTemplate($type_template, $user, $outputlangs) |
| 1231 | 1231 | { |
| 1232 | - $ret=array(); |
|
| 1232 | + $ret = array(); |
|
| 1233 | 1233 | |
| 1234 | 1234 | $sql = "SELECT label, topic, content, lang"; |
| 1235 | - $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; |
|
| 1236 | - $sql.= " WHERE type_template='".$this->db->escape($type_template)."'"; |
|
| 1237 | - $sql.= " AND entity IN (".getEntity('c_email_templates').")"; |
|
| 1238 | - $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; |
|
| 1239 | - if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; |
|
| 1240 | - $sql.= $this->db->order("lang,label","ASC"); |
|
| 1235 | + $sql .= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; |
|
| 1236 | + $sql .= " WHERE type_template='".$this->db->escape($type_template)."'"; |
|
| 1237 | + $sql .= " AND entity IN (".getEntity('c_email_templates').")"; |
|
| 1238 | + $sql .= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; |
|
| 1239 | + if (is_object($outputlangs)) $sql .= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; |
|
| 1240 | + $sql .= $this->db->order("lang,label", "ASC"); |
|
| 1241 | 1241 | //print $sql; |
| 1242 | 1242 | |
| 1243 | 1243 | $resql = $this->db->query($sql); |
| 1244 | 1244 | if ($resql) |
| 1245 | 1245 | { |
| 1246 | - $num= $this->db->num_rows($resql); |
|
| 1246 | + $num = $this->db->num_rows($resql); |
|
| 1247 | 1247 | $this->db->free($resql); |
| 1248 | 1248 | return $num; |
| 1249 | 1249 | } |
| 1250 | 1250 | else |
| 1251 | 1251 | { |
| 1252 | - $this->error=get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror(); |
|
| 1252 | + $this->error = get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror(); |
|
| 1253 | 1253 | return -1; |
| 1254 | 1254 | } |
| 1255 | 1255 | } |
@@ -1264,46 +1264,46 @@ discard block |
||
| 1264 | 1264 | * @param int $active 1=Only active template, 0=Only disabled, -1=All |
| 1265 | 1265 | * @return int <0 if KO, nb of records found if OK |
| 1266 | 1266 | */ |
| 1267 | - public function fetchAllEMailTemplate($type_template, $user, $outputlangs, $active=1) |
|
| 1267 | + public function fetchAllEMailTemplate($type_template, $user, $outputlangs, $active = 1) |
|
| 1268 | 1268 | { |
| 1269 | - $ret=array(); |
|
| 1269 | + $ret = array(); |
|
| 1270 | 1270 | |
| 1271 | 1271 | $sql = "SELECT rowid, label, topic, content, content_lines, lang, fk_user, private, position"; |
| 1272 | - $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; |
|
| 1273 | - $sql.= " WHERE type_template IN ('".$this->db->escape($type_template)."', 'all')"; |
|
| 1274 | - $sql.= " AND entity IN (".getEntity('c_email_templates').")"; |
|
| 1275 | - $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // See all public templates or templates I own. |
|
| 1276 | - if ($active >= 0) $sql.=" AND active = ".$active; |
|
| 1272 | + $sql .= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; |
|
| 1273 | + $sql .= " WHERE type_template IN ('".$this->db->escape($type_template)."', 'all')"; |
|
| 1274 | + $sql .= " AND entity IN (".getEntity('c_email_templates').")"; |
|
| 1275 | + $sql .= " AND (private = 0 OR fk_user = ".$user->id.")"; // See all public templates or templates I own. |
|
| 1276 | + if ($active >= 0) $sql .= " AND active = ".$active; |
|
| 1277 | 1277 | //if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; // Return all languages |
| 1278 | - $sql.= $this->db->order("position,lang,label","ASC"); |
|
| 1278 | + $sql .= $this->db->order("position,lang,label", "ASC"); |
|
| 1279 | 1279 | //print $sql; |
| 1280 | 1280 | |
| 1281 | 1281 | $resql = $this->db->query($sql); |
| 1282 | 1282 | if ($resql) |
| 1283 | 1283 | { |
| 1284 | - $num=$this->db->num_rows($resql); |
|
| 1285 | - $this->lines_model=array(); |
|
| 1284 | + $num = $this->db->num_rows($resql); |
|
| 1285 | + $this->lines_model = array(); |
|
| 1286 | 1286 | while ($obj = $this->db->fetch_object($resql)) |
| 1287 | 1287 | { |
| 1288 | 1288 | $line = new ModelMail(); |
| 1289 | - $line->id=$obj->rowid; |
|
| 1290 | - $line->label=$obj->label; |
|
| 1291 | - $line->lang=$obj->lang; |
|
| 1292 | - $line->fk_user=$obj->fk_user; |
|
| 1293 | - $line->private=$obj->private; |
|
| 1294 | - $line->position=$obj->position; |
|
| 1295 | - $line->topic=$obj->topic; |
|
| 1296 | - $line->content=$obj->content; |
|
| 1297 | - $line->content_lines=$obj->content_lines; |
|
| 1298 | - |
|
| 1299 | - $this->lines_model[]=$line; |
|
| 1289 | + $line->id = $obj->rowid; |
|
| 1290 | + $line->label = $obj->label; |
|
| 1291 | + $line->lang = $obj->lang; |
|
| 1292 | + $line->fk_user = $obj->fk_user; |
|
| 1293 | + $line->private = $obj->private; |
|
| 1294 | + $line->position = $obj->position; |
|
| 1295 | + $line->topic = $obj->topic; |
|
| 1296 | + $line->content = $obj->content; |
|
| 1297 | + $line->content_lines = $obj->content_lines; |
|
| 1298 | + |
|
| 1299 | + $this->lines_model[] = $line; |
|
| 1300 | 1300 | } |
| 1301 | 1301 | $this->db->free($resql); |
| 1302 | 1302 | return $num; |
| 1303 | 1303 | } |
| 1304 | 1304 | else |
| 1305 | 1305 | { |
| 1306 | - $this->error=get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror(); |
|
| 1306 | + $this->error = get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror(); |
|
| 1307 | 1307 | return -1; |
| 1308 | 1308 | } |
| 1309 | 1309 | } |
@@ -1322,11 +1322,11 @@ discard block |
||
| 1322 | 1322 | { |
| 1323 | 1323 | global $conf, $user; |
| 1324 | 1324 | |
| 1325 | - $parameters=array(); |
|
| 1326 | - $tmparray=getCommonSubstitutionArray($outputlangs, 0, null, $object); |
|
| 1325 | + $parameters = array(); |
|
| 1326 | + $tmparray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
|
| 1327 | 1327 | complete_substitutions_array($tmparray, $outputlangs, null, $parameters); |
| 1328 | 1328 | |
| 1329 | - $this->substit=$tmparray; |
|
| 1329 | + $this->substit = $tmparray; |
|
| 1330 | 1330 | |
| 1331 | 1331 | // Fill substit_lines with each object lines content |
| 1332 | 1332 | if (is_array($object->lines)) |
@@ -1350,7 +1350,7 @@ discard block |
||
| 1350 | 1350 | // Create dynamic tags for __PRODUCT_EXTRAFIELD_FIELD__ |
| 1351 | 1351 | if (!empty($line->fk_product)) |
| 1352 | 1352 | { |
| 1353 | - if (! is_object($extrafields)) $extrafields = new ExtraFields($this->db); |
|
| 1353 | + if (!is_object($extrafields)) $extrafields = new ExtraFields($this->db); |
|
| 1354 | 1354 | $extrafields->fetch_name_optionals_label('product', true); |
| 1355 | 1355 | $product = new Product($this->db); |
| 1356 | 1356 | $product->fetch($line->fk_product, '', '', 1); |
@@ -1358,7 +1358,7 @@ discard block |
||
| 1358 | 1358 | if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) |
| 1359 | 1359 | { |
| 1360 | 1360 | foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) { |
| 1361 | - $substit_line['__PRODUCT_EXTRAFIELD_' . strtoupper($key) . '__'] = $product->array_options['options_' . $key]; |
|
| 1361 | + $substit_line['__PRODUCT_EXTRAFIELD_'.strtoupper($key).'__'] = $product->array_options['options_'.$key]; |
|
| 1362 | 1362 | } |
| 1363 | 1363 | } |
| 1364 | 1364 | } |
@@ -1375,31 +1375,31 @@ discard block |
||
| 1375 | 1375 | * @param Object $object Object if applicable |
| 1376 | 1376 | * @return array Array of substitution values for emails. |
| 1377 | 1377 | */ |
| 1378 | - static function getAvailableSubstitKey($mode='formemail', $object=null) |
|
| 1378 | + static function getAvailableSubstitKey($mode = 'formemail', $object = null) |
|
| 1379 | 1379 | { |
| 1380 | 1380 | global $conf, $langs; |
| 1381 | 1381 | |
| 1382 | - $tmparray=array(); |
|
| 1382 | + $tmparray = array(); |
|
| 1383 | 1383 | if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines') |
| 1384 | 1384 | { |
| 1385 | - $parameters=array('mode'=>$mode); |
|
| 1386 | - $tmparray=getCommonSubstitutionArray($langs, 2, null, $object); // Note: On email templated edition, this is null because it is related to all type of objects |
|
| 1385 | + $parameters = array('mode'=>$mode); |
|
| 1386 | + $tmparray = getCommonSubstitutionArray($langs, 2, null, $object); // Note: On email templated edition, this is null because it is related to all type of objects |
|
| 1387 | 1387 | complete_substitutions_array($tmparray, $langs, null, $parameters); |
| 1388 | 1388 | |
| 1389 | 1389 | if ($mode == 'formwithlines') |
| 1390 | 1390 | { |
| 1391 | - $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function |
|
| 1391 | + $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function |
|
| 1392 | 1392 | } |
| 1393 | 1393 | if ($mode == 'formforlines') |
| 1394 | 1394 | { |
| 1395 | - $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function |
|
| 1395 | + $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function |
|
| 1396 | 1396 | } |
| 1397 | 1397 | } |
| 1398 | 1398 | |
| 1399 | 1399 | if ($mode == 'emailing') |
| 1400 | 1400 | { |
| 1401 | - $parameters=array('mode'=>$mode); |
|
| 1402 | - $tmparray=getCommonSubstitutionArray($langs, 2, array('object','objectamount'), $object); // Note: On email templated edition, this is null because it is related to all type of objects |
|
| 1401 | + $parameters = array('mode'=>$mode); |
|
| 1402 | + $tmparray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount'), $object); // Note: On email templated edition, this is null because it is related to all type of objects |
|
| 1403 | 1403 | complete_substitutions_array($tmparray, $langs, null, $parameters); |
| 1404 | 1404 | |
| 1405 | 1405 | // For mass emailing, we have different keys |
@@ -1419,18 +1419,18 @@ discard block |
||
| 1419 | 1419 | //,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing |
| 1420 | 1420 | |
| 1421 | 1421 | $onlinepaymentenabled = 0; |
| 1422 | - if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++; |
|
| 1423 | - if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++; |
|
| 1424 | - if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++; |
|
| 1425 | - if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
| 1422 | + if (!empty($conf->paypal->enabled)) $onlinepaymentenabled++; |
|
| 1423 | + if (!empty($conf->paybox->enabled)) $onlinepaymentenabled++; |
|
| 1424 | + if (!empty($conf->stripe->enabled)) $onlinepaymentenabled++; |
|
| 1425 | + if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) |
|
| 1426 | 1426 | { |
| 1427 | - $tmparray['__SECUREKEYPAYMENT__']=$conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 1428 | - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) |
|
| 1427 | + $tmparray['__SECUREKEYPAYMENT__'] = $conf->global->PAYMENT_SECURITY_TOKEN; |
|
| 1428 | + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) |
|
| 1429 | 1429 | { |
| 1430 | - if ($conf->adherent->enabled) $tmparray['__SECUREKEYPAYMENT_MEMBER__']='SecureKeyPAYMENTUniquePerMember'; |
|
| 1431 | - if ($conf->facture->enabled) $tmparray['__SECUREKEYPAYMENT_INVOICE__']='SecureKeyPAYMENTUniquePerInvoice'; |
|
| 1432 | - if ($conf->commande->enabled) $tmparray['__SECUREKEYPAYMENT_ORDER__']='SecureKeyPAYMENTUniquePerOrder'; |
|
| 1433 | - if ($conf->contrat->enabled) $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__']='SecureKeyPAYMENTUniquePerContractLine'; |
|
| 1430 | + if ($conf->adherent->enabled) $tmparray['__SECUREKEYPAYMENT_MEMBER__'] = 'SecureKeyPAYMENTUniquePerMember'; |
|
| 1431 | + if ($conf->facture->enabled) $tmparray['__SECUREKEYPAYMENT_INVOICE__'] = 'SecureKeyPAYMENTUniquePerInvoice'; |
|
| 1432 | + if ($conf->commande->enabled) $tmparray['__SECUREKEYPAYMENT_ORDER__'] = 'SecureKeyPAYMENTUniquePerOrder'; |
|
| 1433 | + if ($conf->contrat->enabled) $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'SecureKeyPAYMENTUniquePerContractLine'; |
|
| 1434 | 1434 | } |
| 1435 | 1435 | } |
| 1436 | 1436 | else |
@@ -1445,9 +1445,9 @@ discard block |
||
| 1445 | 1445 | } |
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | - foreach($tmparray as $key => $val) |
|
| 1448 | + foreach ($tmparray as $key => $val) |
|
| 1449 | 1449 | { |
| 1450 | - if (empty($val)) $tmparray[$key]=$key; |
|
| 1450 | + if (empty($val)) $tmparray[$key] = $key; |
|
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | return $tmparray; |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \ingroup notification |
| 24 | 24 | * \brief File of class to manage notifications |
| 25 | 25 | */ |
| 26 | -require_once DOL_DOCUMENT_ROOT .'/core/class/CMailFile.class.php'; |
|
| 26 | +require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | /** |
| 45 | 45 | * @var string Error code (or message) |
| 46 | 46 | */ |
| 47 | - public $error=''; |
|
| 47 | + public $error = ''; |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @var string[] Error codes (or messages) |
@@ -105,32 +105,32 @@ discard block |
||
| 105 | 105 | * @param Object $object Object the notification is about |
| 106 | 106 | * @return string Message |
| 107 | 107 | */ |
| 108 | - function confirmMessage($action,$socid,$object) |
|
| 108 | + function confirmMessage($action, $socid, $object) |
|
| 109 | 109 | { |
| 110 | 110 | global $langs; |
| 111 | 111 | $langs->load("mails"); |
| 112 | 112 | |
| 113 | - $listofnotiftodo=$this->getNotificationsArray($action,$socid,$object,0); |
|
| 113 | + $listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0); |
|
| 114 | 114 | |
| 115 | - $nb=-1; |
|
| 116 | - if (is_array($listofnotiftodo)) $nb=count($listofnotiftodo); |
|
| 117 | - if ($nb < 0) $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend"); |
|
| 118 | - if ($nb == 0) $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("NoNotificationsWillBeSent"); |
|
| 119 | - if ($nb == 1) $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("ANotificationsWillBeSent"); |
|
| 120 | - if ($nb >= 2) $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("SomeNotificationsWillBeSent",$nb); |
|
| 115 | + $nb = -1; |
|
| 116 | + if (is_array($listofnotiftodo)) $nb = count($listofnotiftodo); |
|
| 117 | + if ($nb < 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend"); |
|
| 118 | + if ($nb == 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent"); |
|
| 119 | + if ($nb == 1) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent"); |
|
| 120 | + if ($nb >= 2) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb); |
|
| 121 | 121 | |
| 122 | 122 | if (is_array($listofnotiftodo)) |
| 123 | 123 | { |
| 124 | - $i=0; |
|
| 124 | + $i = 0; |
|
| 125 | 125 | foreach ($listofnotiftodo as $key => $val) |
| 126 | 126 | { |
| 127 | - if ($i) $texte.=', '; |
|
| 128 | - else $texte.=' ('; |
|
| 129 | - if ($val['isemailvalid']) $texte.=$val['email']; |
|
| 130 | - else $texte.=$val['emaildesc']; |
|
| 127 | + if ($i) $texte .= ', '; |
|
| 128 | + else $texte .= ' ('; |
|
| 129 | + if ($val['isemailvalid']) $texte .= $val['email']; |
|
| 130 | + else $texte .= $val['emaildesc']; |
|
| 131 | 131 | $i++; |
| 132 | 132 | } |
| 133 | - if ($i) $texte.=')'; |
|
| 133 | + if ($i) $texte .= ')'; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | return $texte; |
@@ -146,35 +146,35 @@ discard block |
||
| 146 | 146 | * @param array $scope Scope where to search |
| 147 | 147 | * @return array|int <0 if KO, array of notifications to send if OK |
| 148 | 148 | */ |
| 149 | - function getNotificationsArray($notifcode, $socid=0, $object=null, $userid=0, $scope=array('thirdparty', 'user', 'global')) |
|
| 149 | + function getNotificationsArray($notifcode, $socid = 0, $object = null, $userid = 0, $scope = array('thirdparty', 'user', 'global')) |
|
| 150 | 150 | { |
| 151 | 151 | global $conf, $user; |
| 152 | 152 | |
| 153 | - $error=0; |
|
| 154 | - $resarray=array(); |
|
| 153 | + $error = 0; |
|
| 154 | + $resarray = array(); |
|
| 155 | 155 | |
| 156 | 156 | $valueforthreshold = 0; |
| 157 | 157 | if (is_object($object)) $valueforthreshold = $object->total_ht; |
| 158 | 158 | |
| 159 | - if (! $error) |
|
| 159 | + if (!$error) |
|
| 160 | 160 | { |
| 161 | 161 | if ($socid >= 0 && in_array('thirdparty', $scope)) |
| 162 | 162 | { |
| 163 | 163 | $sql = "SELECT a.code, c.email, c.rowid"; |
| 164 | - $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; |
|
| 165 | - $sql.= " ".MAIN_DB_PREFIX."socpeople as c,"; |
|
| 166 | - $sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,"; |
|
| 167 | - $sql.= " ".MAIN_DB_PREFIX."societe as s"; |
|
| 168 | - $sql.= " WHERE n.fk_contact = c.rowid"; |
|
| 169 | - $sql.= " AND a.rowid = n.fk_action"; |
|
| 170 | - $sql.= " AND n.fk_soc = s.rowid"; |
|
| 164 | + $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; |
|
| 165 | + $sql .= " ".MAIN_DB_PREFIX."socpeople as c,"; |
|
| 166 | + $sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a,"; |
|
| 167 | + $sql .= " ".MAIN_DB_PREFIX."societe as s"; |
|
| 168 | + $sql .= " WHERE n.fk_contact = c.rowid"; |
|
| 169 | + $sql .= " AND a.rowid = n.fk_action"; |
|
| 170 | + $sql .= " AND n.fk_soc = s.rowid"; |
|
| 171 | 171 | if ($notifcode) |
| 172 | 172 | { |
| 173 | - if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage |
|
| 174 | - else $sql.= " AND a.code = '".$notifcode."'"; // New usage |
|
| 173 | + if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage |
|
| 174 | + else $sql .= " AND a.code = '".$notifcode."'"; // New usage |
|
| 175 | 175 | } |
| 176 | - $sql.= " AND s.entity IN (".getEntity('societe').")"; |
|
| 177 | - if ($socid > 0) $sql.= " AND s.rowid = ".$socid; |
|
| 176 | + $sql .= " AND s.entity IN (".getEntity('societe').")"; |
|
| 177 | + if ($socid > 0) $sql .= " AND s.rowid = ".$socid; |
|
| 178 | 178 | |
| 179 | 179 | dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); |
| 180 | 180 | |
@@ -182,14 +182,14 @@ discard block |
||
| 182 | 182 | if ($resql) |
| 183 | 183 | { |
| 184 | 184 | $num = $this->db->num_rows($resql); |
| 185 | - $i=0; |
|
| 185 | + $i = 0; |
|
| 186 | 186 | while ($i < $num) |
| 187 | 187 | { |
| 188 | 188 | $obj = $this->db->fetch_object($resql); |
| 189 | 189 | if ($obj) |
| 190 | 190 | { |
| 191 | - $newval2=trim($obj->email); |
|
| 192 | - $isvalid=isValidEmail($newval2); |
|
| 191 | + $newval2 = trim($obj->email); |
|
| 192 | + $isvalid = isValidEmail($newval2); |
|
| 193 | 193 | if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid); |
| 194 | 194 | } |
| 195 | 195 | $i++; |
@@ -198,28 +198,28 @@ discard block |
||
| 198 | 198 | else |
| 199 | 199 | { |
| 200 | 200 | $error++; |
| 201 | - $this->error=$this->db->lasterror(); |
|
| 201 | + $this->error = $this->db->lasterror(); |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - if (! $error) |
|
| 206 | + if (!$error) |
|
| 207 | 207 | { |
| 208 | 208 | if ($userid >= 0 && in_array('user', $scope)) |
| 209 | 209 | { |
| 210 | 210 | $sql = "SELECT a.code, c.email, c.rowid"; |
| 211 | - $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; |
|
| 212 | - $sql.= " ".MAIN_DB_PREFIX."user as c,"; |
|
| 213 | - $sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a"; |
|
| 214 | - $sql.= " WHERE n.fk_user = c.rowid"; |
|
| 215 | - $sql.= " AND a.rowid = n.fk_action"; |
|
| 211 | + $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; |
|
| 212 | + $sql .= " ".MAIN_DB_PREFIX."user as c,"; |
|
| 213 | + $sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a"; |
|
| 214 | + $sql .= " WHERE n.fk_user = c.rowid"; |
|
| 215 | + $sql .= " AND a.rowid = n.fk_action"; |
|
| 216 | 216 | if ($notifcode) |
| 217 | 217 | { |
| 218 | - if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage |
|
| 219 | - else $sql.= " AND a.code = '".$notifcode."'"; // New usage |
|
| 218 | + if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage |
|
| 219 | + else $sql .= " AND a.code = '".$notifcode."'"; // New usage |
|
| 220 | 220 | } |
| 221 | - $sql.= " AND c.entity IN (".getEntity('user').")"; |
|
| 222 | - if ($userid > 0) $sql.= " AND c.rowid = ".$userid; |
|
| 221 | + $sql .= " AND c.entity IN (".getEntity('user').")"; |
|
| 222 | + if ($userid > 0) $sql .= " AND c.rowid = ".$userid; |
|
| 223 | 223 | |
| 224 | 224 | dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); |
| 225 | 225 | |
@@ -227,14 +227,14 @@ discard block |
||
| 227 | 227 | if ($resql) |
| 228 | 228 | { |
| 229 | 229 | $num = $this->db->num_rows($resql); |
| 230 | - $i=0; |
|
| 230 | + $i = 0; |
|
| 231 | 231 | while ($i < $num) |
| 232 | 232 | { |
| 233 | 233 | $obj = $this->db->fetch_object($resql); |
| 234 | 234 | if ($obj) |
| 235 | 235 | { |
| 236 | - $newval2=trim($obj->email); |
|
| 237 | - $isvalid=isValidEmail($newval2); |
|
| 236 | + $newval2 = trim($obj->email); |
|
| 237 | + $isvalid = isValidEmail($newval2); |
|
| 238 | 238 | if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid); |
| 239 | 239 | } |
| 240 | 240 | $i++; |
@@ -243,49 +243,49 @@ discard block |
||
| 243 | 243 | else |
| 244 | 244 | { |
| 245 | 245 | $error++; |
| 246 | - $this->error=$this->db->lasterror(); |
|
| 246 | + $this->error = $this->db->lasterror(); |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - if (! $error) |
|
| 251 | + if (!$error) |
|
| 252 | 252 | { |
| 253 | 253 | if (in_array('global', $scope)) |
| 254 | 254 | { |
| 255 | 255 | // List of notifications enabled for fixed email |
| 256 | - foreach($conf->global as $key => $val) |
|
| 256 | + foreach ($conf->global as $key => $val) |
|
| 257 | 257 | { |
| 258 | 258 | if ($notifcode) |
| 259 | 259 | { |
| 260 | - if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; |
|
| 260 | + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; |
|
| 261 | 261 | } |
| 262 | 262 | else |
| 263 | 263 | { |
| 264 | - if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; |
|
| 264 | + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | $threshold = (float) $reg[1]; |
| 268 | 268 | if ($valueforthreshold < $threshold) continue; |
| 269 | 269 | |
| 270 | - $tmpemail=explode(',',$val); |
|
| 271 | - foreach($tmpemail as $key2 => $val2) |
|
| 270 | + $tmpemail = explode(',', $val); |
|
| 271 | + foreach ($tmpemail as $key2 => $val2) |
|
| 272 | 272 | { |
| 273 | - $newval2=trim($val2); |
|
| 273 | + $newval2 = trim($val2); |
|
| 274 | 274 | if ($newval2 == '__SUPERVISOREMAIL__') |
| 275 | 275 | { |
| 276 | 276 | if ($user->fk_user > 0) |
| 277 | 277 | { |
| 278 | - $tmpuser=new User($this->db); |
|
| 278 | + $tmpuser = new User($this->db); |
|
| 279 | 279 | $tmpuser->fetch($user->fk_user); |
| 280 | - if ($tmpuser->email) $newval2=trim($tmpuser->email); |
|
| 281 | - else $newval2=''; |
|
| 280 | + if ($tmpuser->email) $newval2 = trim($tmpuser->email); |
|
| 281 | + else $newval2 = ''; |
|
| 282 | 282 | } |
| 283 | - else $newval2=''; |
|
| 283 | + else $newval2 = ''; |
|
| 284 | 284 | } |
| 285 | 285 | if ($newval2) |
| 286 | 286 | { |
| 287 | - $isvalid=isValidEmail($newval2, 0); |
|
| 288 | - if (empty($resarray[$newval2])) $resarray[$newval2]=array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid); |
|
| 287 | + $isvalid = isValidEmail($newval2, 0); |
|
| 288 | + if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid); |
|
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | } |
@@ -309,19 +309,19 @@ discard block |
||
| 309 | 309 | * @param array $mimefilename_list List of attached file name in message |
| 310 | 310 | * @return int <0 if KO, or number of changes if OK |
| 311 | 311 | */ |
| 312 | - function send($notifcode, $object, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array()) |
|
| 312 | + function send($notifcode, $object, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array()) |
|
| 313 | 313 | { |
| 314 | - global $user,$conf,$langs,$mysoc; |
|
| 314 | + global $user, $conf, $langs, $mysoc; |
|
| 315 | 315 | global $hookmanager; |
| 316 | 316 | global $dolibarr_main_url_root; |
| 317 | 317 | |
| 318 | - if (! in_array($notifcode, $this->arrayofnotifsupported)) return 0; |
|
| 318 | + if (!in_array($notifcode, $this->arrayofnotifsupported)) return 0; |
|
| 319 | 319 | |
| 320 | 320 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 321 | - if (! is_object($hookmanager)) |
|
| 321 | + if (!is_object($hookmanager)) |
|
| 322 | 322 | { |
| 323 | 323 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
| 324 | - $hookmanager=new HookManager($this->db); |
|
| 324 | + $hookmanager = new HookManager($this->db); |
|
| 325 | 325 | } |
| 326 | 326 | $hookmanager->initHooks(array('notification')); |
| 327 | 327 | |
@@ -330,72 +330,72 @@ discard block |
||
| 330 | 330 | $langs->load("other"); |
| 331 | 331 | |
| 332 | 332 | // Define $urlwithroot |
| 333 | - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
| 334 | - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
| 333 | + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); |
|
| 334 | + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
| 335 | 335 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
| 336 | 336 | |
| 337 | 337 | // Define some vars |
| 338 | 338 | $application = 'Dolibarr'; |
| 339 | - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE; |
|
| 339 | + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE; |
|
| 340 | 340 | $replyto = $conf->notification->email_from; |
| 341 | 341 | $object_type = ''; |
| 342 | 342 | $link = ''; |
| 343 | 343 | $num = 0; |
| 344 | 344 | |
| 345 | - $oldref=(empty($object->oldref)?$object->ref:$object->oldref); |
|
| 346 | - $newref=(empty($object->newref)?$object->ref:$object->newref); |
|
| 345 | + $oldref = (empty($object->oldref) ? $object->ref : $object->oldref); |
|
| 346 | + $newref = (empty($object->newref) ? $object->ref : $object->newref); |
|
| 347 | 347 | |
| 348 | 348 | $sql = ''; |
| 349 | 349 | |
| 350 | 350 | // Check notification per third party |
| 351 | 351 | if ($object->socid > 0) |
| 352 | 352 | { |
| 353 | - $sql.= "SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,"; |
|
| 354 | - $sql.= " a.rowid as adid, a.label, a.code, n.rowid, n.type"; |
|
| 355 | - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c,"; |
|
| 356 | - $sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,"; |
|
| 357 | - $sql.= " ".MAIN_DB_PREFIX."notify_def as n,"; |
|
| 358 | - $sql.= " ".MAIN_DB_PREFIX."societe as s"; |
|
| 359 | - $sql.= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action"; |
|
| 360 | - $sql.= " AND n.fk_soc = s.rowid"; |
|
| 361 | - if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage |
|
| 362 | - else $sql.= " AND a.code = '".$notifcode."'"; // New usage |
|
| 353 | + $sql .= "SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,"; |
|
| 354 | + $sql .= " a.rowid as adid, a.label, a.code, n.rowid, n.type"; |
|
| 355 | + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c,"; |
|
| 356 | + $sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a,"; |
|
| 357 | + $sql .= " ".MAIN_DB_PREFIX."notify_def as n,"; |
|
| 358 | + $sql .= " ".MAIN_DB_PREFIX."societe as s"; |
|
| 359 | + $sql .= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action"; |
|
| 360 | + $sql .= " AND n.fk_soc = s.rowid"; |
|
| 361 | + if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage |
|
| 362 | + else $sql .= " AND a.code = '".$notifcode."'"; // New usage |
|
| 363 | 363 | $sql .= " AND s.rowid = ".$object->socid; |
| 364 | 364 | |
| 365 | - $sql.= "\nUNION\n"; |
|
| 365 | + $sql .= "\nUNION\n"; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // Check notification per user |
| 369 | - $sql.= "SELECT 'touserid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.lang as default_lang,"; |
|
| 370 | - $sql.= " a.rowid as adid, a.label, a.code, n.rowid, n.type"; |
|
| 371 | - $sql.= " FROM ".MAIN_DB_PREFIX."user as c,"; |
|
| 372 | - $sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,"; |
|
| 373 | - $sql.= " ".MAIN_DB_PREFIX."notify_def as n"; |
|
| 374 | - $sql.= " WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action"; |
|
| 375 | - if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage |
|
| 376 | - else $sql.= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage |
|
| 369 | + $sql .= "SELECT 'touserid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.lang as default_lang,"; |
|
| 370 | + $sql .= " a.rowid as adid, a.label, a.code, n.rowid, n.type"; |
|
| 371 | + $sql .= " FROM ".MAIN_DB_PREFIX."user as c,"; |
|
| 372 | + $sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a,"; |
|
| 373 | + $sql .= " ".MAIN_DB_PREFIX."notify_def as n"; |
|
| 374 | + $sql .= " WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action"; |
|
| 375 | + if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage |
|
| 376 | + else $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage |
|
| 377 | 377 | |
| 378 | 378 | $result = $this->db->query($sql); |
| 379 | 379 | if ($result) |
| 380 | 380 | { |
| 381 | 381 | $num = $this->db->num_rows($result); |
| 382 | - $projtitle=''; |
|
| 383 | - if (! empty($object->fk_project)) |
|
| 382 | + $projtitle = ''; |
|
| 383 | + if (!empty($object->fk_project)) |
|
| 384 | 384 | { |
| 385 | 385 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 386 | 386 | $proj = new Project($this->db); |
| 387 | 387 | $proj->fetch($object->fk_project); |
| 388 | - $projtitle='('.$proj->title.')'; |
|
| 388 | + $projtitle = '('.$proj->title.')'; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | if ($num > 0) |
| 392 | 392 | { |
| 393 | 393 | $i = 0; |
| 394 | - while ($i < $num && ! $error) // For each notification couple defined (third party/actioncode) |
|
| 394 | + while ($i < $num && !$error) // For each notification couple defined (third party/actioncode) |
|
| 395 | 395 | { |
| 396 | 396 | $obj = $this->db->fetch_object($result); |
| 397 | 397 | |
| 398 | - $sendto = dolGetFirstLastname($obj->firstname,$obj->lastname) . " <".$obj->email.">"; |
|
| 398 | + $sendto = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">"; |
|
| 399 | 399 | $notifcodedefid = $obj->adid; |
| 400 | 400 | |
| 401 | 401 | if (dol_strlen($obj->email)) |
@@ -406,107 +406,107 @@ discard block |
||
| 406 | 406 | { |
| 407 | 407 | $outputlangs = new Translate('', $conf); |
| 408 | 408 | $outputlangs->setDefaultLang($obj->default_lang); |
| 409 | - $outputlangs->loadLangs(array("main","other")); |
|
| 409 | + $outputlangs->loadLangs(array("main", "other")); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - $subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification").($projtitle?' '.$projtitle:''); |
|
| 412 | + $subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : ''); |
|
| 413 | 413 | |
| 414 | 414 | switch ($notifcode) { |
| 415 | 415 | case 'BILL_VALIDATE': |
| 416 | - $link='/compta/facture/card.php?facid='.$object->id; |
|
| 416 | + $link = '/compta/facture/card.php?facid='.$object->id; |
|
| 417 | 417 | $dir_output = $conf->facture->dir_output; |
| 418 | 418 | $object_type = 'facture'; |
| 419 | - $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoiceValidated",$newref); |
|
| 419 | + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoiceValidated", $newref); |
|
| 420 | 420 | break; |
| 421 | 421 | case 'BILL_PAYED': |
| 422 | - $link='/compta/facture/card.php?facid='.$object->id; |
|
| 422 | + $link = '/compta/facture/card.php?facid='.$object->id; |
|
| 423 | 423 | $dir_output = $conf->facture->dir_output; |
| 424 | 424 | $object_type = 'facture'; |
| 425 | - $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoicePayed",$newref); |
|
| 425 | + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoicePayed", $newref); |
|
| 426 | 426 | break; |
| 427 | 427 | case 'ORDER_VALIDATE': |
| 428 | - $link='/commande/card.php?id='.$object->id; |
|
| 428 | + $link = '/commande/card.php?id='.$object->id; |
|
| 429 | 429 | $dir_output = $conf->commande->dir_output; |
| 430 | 430 | $object_type = 'order'; |
| 431 | - $mesg = $outputlangs->transnoentitiesnoconv("EMailTextOrderValidated",$newref); |
|
| 431 | + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextOrderValidated", $newref); |
|
| 432 | 432 | break; |
| 433 | 433 | case 'PROPAL_VALIDATE': |
| 434 | - $link='/comm/propal/card.php?id='.$object->id; |
|
| 434 | + $link = '/comm/propal/card.php?id='.$object->id; |
|
| 435 | 435 | $dir_output = $conf->propal->multidir_output[$object->entity]; |
| 436 | 436 | $object_type = 'propal'; |
| 437 | - $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalValidated",$newref); |
|
| 437 | + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalValidated", $newref); |
|
| 438 | 438 | break; |
| 439 | 439 | case 'PROPAL_CLOSE_SIGNED': |
| 440 | - $link='/comm/propal/card.php?id='.$object->id; |
|
| 440 | + $link = '/comm/propal/card.php?id='.$object->id; |
|
| 441 | 441 | $dir_output = $conf->propal->multidir_output[$object->entity]; |
| 442 | 442 | $object_type = 'propal'; |
| 443 | - $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$newref); |
|
| 443 | + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $newref); |
|
| 444 | 444 | break; |
| 445 | 445 | case 'FICHINTER_ADD_CONTACT': |
| 446 | - $link='/fichinter/card.php?id='.$object->id; |
|
| 446 | + $link = '/fichinter/card.php?id='.$object->id; |
|
| 447 | 447 | $dir_output = $conf->ficheinter->dir_output; |
| 448 | 448 | $object_type = 'ficheinter'; |
| 449 | - $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionAddedContact",$newref); |
|
| 449 | + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $newref); |
|
| 450 | 450 | break; |
| 451 | 451 | case 'FICHINTER_VALIDATE': |
| 452 | - $link='/fichinter/card.php?id='.$object->id; |
|
| 452 | + $link = '/fichinter/card.php?id='.$object->id; |
|
| 453 | 453 | $dir_output = $conf->ficheinter->dir_output; |
| 454 | 454 | $object_type = 'ficheinter'; |
| 455 | - $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionValidated",$newref); |
|
| 455 | + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionValidated", $newref); |
|
| 456 | 456 | break; |
| 457 | 457 | case 'ORDER_SUPPLIER_VALIDATE': |
| 458 | - $link='/fourn/commande/card.php?id='.$object->id; |
|
| 458 | + $link = '/fourn/commande/card.php?id='.$object->id; |
|
| 459 | 459 | $dir_output = $conf->fournisseur->commande->dir_output; |
| 460 | 460 | $object_type = 'order_supplier'; |
| 461 | 461 | $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; |
| 462 | - $mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderValidatedBy",$newref,$user->getFullName($langs)); |
|
| 463 | - $mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 462 | + $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $newref, $user->getFullName($langs)); |
|
| 463 | + $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 464 | 464 | break; |
| 465 | 465 | case 'ORDER_SUPPLIER_APPROVE': |
| 466 | - $link='/fourn/commande/card.php?id='.$object->id; |
|
| 466 | + $link = '/fourn/commande/card.php?id='.$object->id; |
|
| 467 | 467 | $dir_output = $conf->fournisseur->commande->dir_output; |
| 468 | 468 | $object_type = 'order_supplier'; |
| 469 | 469 | $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; |
| 470 | - $mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$newref,$user->getFullName($langs)); |
|
| 471 | - $mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 470 | + $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $newref, $user->getFullName($langs)); |
|
| 471 | + $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 472 | 472 | break; |
| 473 | 473 | case 'ORDER_SUPPLIER_REFUSE': |
| 474 | - $link='/fourn/commande/card.php?id='.$object->id; |
|
| 474 | + $link = '/fourn/commande/card.php?id='.$object->id; |
|
| 475 | 475 | $dir_output = $conf->fournisseur->commande->dir_output; |
| 476 | 476 | $object_type = 'order_supplier'; |
| 477 | 477 | $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; |
| 478 | - $mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderRefusedBy",$newref,$user->getFullName($langs)); |
|
| 479 | - $mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 478 | + $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $newref, $user->getFullName($langs)); |
|
| 479 | + $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 480 | 480 | break; |
| 481 | 481 | case 'SHIPPING_VALIDATE': |
| 482 | 482 | $dir_output = $conf->expedition->dir_output.'/sending/'; |
| 483 | 483 | $object_type = 'order_supplier'; |
| 484 | - $mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpeditionValidated",$newref); |
|
| 484 | + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpeditionValidated", $newref); |
|
| 485 | 485 | break; |
| 486 | 486 | case 'EXPENSE_REPORT_VALIDATE': |
| 487 | 487 | $dir_output = $conf->expensereport->dir_output; |
| 488 | 488 | $object_type = 'expensereport'; |
| 489 | - $mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpenseReportValidated",$newref); |
|
| 489 | + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpenseReportValidated", $newref); |
|
| 490 | 490 | break; |
| 491 | 491 | case 'EXPENSE_REPORT_APPROVE': |
| 492 | 492 | $dir_output = $conf->expensereport->dir_output; |
| 493 | 493 | $object_type = 'expensereport'; |
| 494 | - $mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpenseReportApproved",$newref); |
|
| 494 | + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpenseReportApproved", $newref); |
|
| 495 | 495 | break; |
| 496 | 496 | case 'HOLIDAY_VALIDATE': |
| 497 | 497 | $dir_output = $conf->holiday->dir_output; |
| 498 | 498 | $object_type = 'holiday'; |
| 499 | - $mesg = $outputlangs->transnoentitiesnoconv("EMailTextHolidayValidated",$newref); |
|
| 499 | + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextHolidayValidated", $newref); |
|
| 500 | 500 | break; |
| 501 | 501 | case 'HOLIDAY_APPROVE': |
| 502 | 502 | $dir_output = $conf->holiday->dir_output; |
| 503 | 503 | $object_type = 'holiday'; |
| 504 | - $mesg = $outputlangs->transnoentitiesnoconv("EMailTextHolidayApproved",$newref); |
|
| 504 | + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextHolidayApproved", $newref); |
|
| 505 | 505 | break; |
| 506 | 506 | } |
| 507 | 507 | $ref = dol_sanitizeFileName($newref); |
| 508 | 508 | $pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; |
| 509 | - if (! dol_is_file($pdf_path)) |
|
| 509 | + if (!dol_is_file($pdf_path)) |
|
| 510 | 510 | { |
| 511 | 511 | // We can't add PDF as it is not generated yet. |
| 512 | 512 | $filepdf = ''; |
@@ -516,18 +516,18 @@ discard block |
||
| 516 | 516 | $filepdf = $pdf_path; |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - $message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification",$application,$mysoc->name)."\n"; |
|
| 520 | - $message.= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2",$application,$mysoc->name)."\n"; |
|
| 521 | - $message.= "\n"; |
|
| 522 | - $message.= $mesg; |
|
| 523 | - if ($link) $message.= "\n" . $urlwithroot . $link; |
|
| 519 | + $message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name)."\n"; |
|
| 520 | + $message .= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; |
|
| 521 | + $message .= "\n"; |
|
| 522 | + $message .= $mesg; |
|
| 523 | + if ($link) $message .= "\n".$urlwithroot.$link; |
|
| 524 | 524 | |
| 525 | - $parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); |
|
| 526 | - $reshook=$hookmanager->executeHooks('formatNotificationMessage',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 525 | + $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); |
|
| 526 | + $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
| 527 | 527 | if (empty($reshook)) |
| 528 | 528 | { |
| 529 | - if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject']; |
|
| 530 | - if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message']; |
|
| 529 | + if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject']; |
|
| 530 | + if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message']; |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | $mailfile = new CMailFile( |
@@ -548,13 +548,13 @@ discard block |
||
| 548 | 548 | { |
| 549 | 549 | if ($obj->type_target == 'touserid') { |
| 550 | 550 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)"; |
| 551 | - $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; |
|
| 551 | + $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; |
|
| 552 | 552 | } |
| 553 | 553 | else { |
| 554 | 554 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)"; |
| 555 | - $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; |
|
| 555 | + $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; |
|
| 556 | 556 | } |
| 557 | - if (! $this->db->query($sql)) |
|
| 557 | + if (!$this->db->query($sql)) |
|
| 558 | 558 | { |
| 559 | 559 | dol_print_error($this->db); |
| 560 | 560 | } |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | else |
| 563 | 563 | { |
| 564 | 564 | $error++; |
| 565 | - $this->errors[]=$mailfile->error; |
|
| 565 | + $this->errors[] = $mailfile->error; |
|
| 566 | 566 | } |
| 567 | 567 | } |
| 568 | 568 | else |
@@ -580,17 +580,17 @@ discard block |
||
| 580 | 580 | else |
| 581 | 581 | { |
| 582 | 582 | $error++; |
| 583 | - $this->errors[]=$this->db->lasterror(); |
|
| 583 | + $this->errors[] = $this->db->lasterror(); |
|
| 584 | 584 | dol_syslog("Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR); |
| 585 | 585 | return -1; |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | // Check notification using fixed email |
| 589 | - if (! $error) |
|
| 589 | + if (!$error) |
|
| 590 | 590 | { |
| 591 | - foreach($conf->global as $key => $val) |
|
| 591 | + foreach ($conf->global as $key => $val) |
|
| 592 | 592 | { |
| 593 | - if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; |
|
| 593 | + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; |
|
| 594 | 594 | |
| 595 | 595 | $threshold = (float) $reg[1]; |
| 596 | 596 | if (!empty($object->total_ht) && $object->total_ht <= $threshold) |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | continue; |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - $param='NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1]; |
|
| 602 | + $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1]; |
|
| 603 | 603 | |
| 604 | 604 | $sendto = $conf->global->$param; |
| 605 | 605 | $notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid'); |
@@ -609,112 +609,112 @@ discard block |
||
| 609 | 609 | $link = ''; |
| 610 | 610 | $num++; |
| 611 | 611 | |
| 612 | - $subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification").($projtitle?' '.$projtitle:''); |
|
| 612 | + $subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : ''); |
|
| 613 | 613 | |
| 614 | 614 | switch ($notifcode) { |
| 615 | 615 | case 'BILL_VALIDATE': |
| 616 | - $link = '<a href="' . $urlwithroot . '/compta/facture/card.php?facid=' . $object->id . '">' . $newref . '</a>'; |
|
| 616 | + $link = '<a href="'.$urlwithroot.'/compta/facture/card.php?facid='.$object->id.'">'.$newref.'</a>'; |
|
| 617 | 617 | $dir_output = $conf->facture->dir_output; |
| 618 | 618 | $object_type = 'facture'; |
| 619 | - $mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated",$link); |
|
| 619 | + $mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated", $link); |
|
| 620 | 620 | break; |
| 621 | 621 | case 'BILL_PAYED': |
| 622 | - $link ='<a href="' . $urlwithroot . '/compta/facture/card.php?facid='.$object->id . '">' . $newref . '</a>'; |
|
| 622 | + $link = '<a href="'.$urlwithroot.'/compta/facture/card.php?facid='.$object->id.'">'.$newref.'</a>'; |
|
| 623 | 623 | $dir_output = $conf->facture->dir_output; |
| 624 | 624 | $object_type = 'facture'; |
| 625 | - $mesg = $langs->transnoentitiesnoconv("EMailTextInvoicePayed",$link); |
|
| 625 | + $mesg = $langs->transnoentitiesnoconv("EMailTextInvoicePayed", $link); |
|
| 626 | 626 | break; |
| 627 | 627 | case 'ORDER_VALIDATE': |
| 628 | - $link = '<a href="' . $urlwithroot . '/commande/card.php?id='.$object->id . '">' . $newref . '</a>'; |
|
| 628 | + $link = '<a href="'.$urlwithroot.'/commande/card.php?id='.$object->id.'">'.$newref.'</a>'; |
|
| 629 | 629 | $dir_output = $conf->commande->dir_output; |
| 630 | 630 | $object_type = 'order'; |
| 631 | - $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated",$link); |
|
| 631 | + $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated", $link); |
|
| 632 | 632 | break; |
| 633 | 633 | case 'PROPAL_VALIDATE': |
| 634 | - $link = '<a href="' . $urlwithroot . '/comm/propal/card.php?id='.$object->id . '">' . $newref . '</a>'; |
|
| 634 | + $link = '<a href="'.$urlwithroot.'/comm/propal/card.php?id='.$object->id.'">'.$newref.'</a>'; |
|
| 635 | 635 | $dir_output = $conf->propal->multidir_output[$object->entity]; |
| 636 | 636 | $object_type = 'propal'; |
| 637 | - $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$link); |
|
| 637 | + $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated", $link); |
|
| 638 | 638 | break; |
| 639 | 639 | case 'PROPAL_CLOSE_SIGNED': |
| 640 | - $link = '<a href="' . $urlwithroot . '/comm/propal/card.php?id='.$object->id . '">' . $newref . '</a>'; |
|
| 640 | + $link = '<a href="'.$urlwithroot.'/comm/propal/card.php?id='.$object->id.'">'.$newref.'</a>'; |
|
| 641 | 641 | $dir_output = $conf->propal->multidir_output[$object->entity]; |
| 642 | 642 | $object_type = 'propal'; |
| 643 | - $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$link); |
|
| 643 | + $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $link); |
|
| 644 | 644 | break; |
| 645 | 645 | case 'FICHINTER_ADD_CONTACT': |
| 646 | - $link = '<a href="' . $urlwithroot . '/fichinter/card.php?id='.$object->id . '">' . $newref . '</a>'; |
|
| 646 | + $link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'">'.$newref.'</a>'; |
|
| 647 | 647 | $dir_output = $conf->facture->dir_output; |
| 648 | 648 | $object_type = 'ficheinter'; |
| 649 | - $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact",$link); |
|
| 649 | + $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $link); |
|
| 650 | 650 | break; |
| 651 | 651 | case 'FICHINTER_VALIDATE': |
| 652 | - $link = '<a href="' . $urlwithroot . '/fichinter/card.php?id='.$object->id . '">' . $newref . '</a>'; |
|
| 652 | + $link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'">'.$newref.'</a>'; |
|
| 653 | 653 | $dir_output = $conf->facture->dir_output; |
| 654 | 654 | $object_type = 'ficheinter'; |
| 655 | - $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated",$link); |
|
| 655 | + $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated", $link); |
|
| 656 | 656 | break; |
| 657 | 657 | case 'ORDER_SUPPLIER_VALIDATE': |
| 658 | - $link = '<a href="' . $urlwithroot . '/fourn/commande/card.php?id='.$object->id . '">' . $newref . '</a>'; |
|
| 658 | + $link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'">'.$newref.'</a>'; |
|
| 659 | 659 | $dir_output = $conf->fournisseur->commande->dir_output; |
| 660 | 660 | $object_type = 'order_supplier'; |
| 661 | 661 | $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; |
| 662 | - $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy",$link,$user->getFullName($langs)); |
|
| 663 | - $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 662 | + $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $link, $user->getFullName($langs)); |
|
| 663 | + $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 664 | 664 | break; |
| 665 | 665 | case 'ORDER_SUPPLIER_APPROVE': |
| 666 | - $link = '<a href="' . $urlwithroot . '/fourn/commande/card.php?id='.$object->id . '">' . $newref . '</a>'; |
|
| 666 | + $link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'">'.$newref.'</a>'; |
|
| 667 | 667 | $dir_output = $conf->fournisseur->commande->dir_output; |
| 668 | 668 | $object_type = 'order_supplier'; |
| 669 | 669 | $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; |
| 670 | - $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$link,$user->getFullName($langs)); |
|
| 671 | - $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 670 | + $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); |
|
| 671 | + $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 672 | 672 | break; |
| 673 | 673 | case 'ORDER_SUPPLIER_APPROVE2': |
| 674 | - $link = '<a href="' . $urlwithroot . '/fourn/commande/card.php?id='.$object->id . '">' . $newref . '</a>'; |
|
| 674 | + $link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'">'.$newref.'</a>'; |
|
| 675 | 675 | $dir_output = $conf->fournisseur->commande->dir_output; |
| 676 | 676 | $object_type = 'order_supplier'; |
| 677 | 677 | $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; |
| 678 | - $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$link,$user->getFullName($langs)); |
|
| 679 | - $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 678 | + $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); |
|
| 679 | + $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 680 | 680 | break; |
| 681 | 681 | case 'ORDER_SUPPLIER_REFUSE': |
| 682 | - $link = '<a href="' . $urlwithroot . '/fourn/commande/card.php?id='.$object->id . '">' . $newref . '</a>'; |
|
| 682 | + $link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'">'.$newref.'</a>'; |
|
| 683 | 683 | $dir_output = $conf->fournisseur->dir_output.'/commande/'; |
| 684 | 684 | $object_type = 'order_supplier'; |
| 685 | 685 | $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; |
| 686 | - $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy",$link,$user->getFullName($langs)); |
|
| 687 | - $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 686 | + $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $link, $user->getFullName($langs)); |
|
| 687 | + $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; |
|
| 688 | 688 | break; |
| 689 | 689 | case 'SHIPPING_VALIDATE': |
| 690 | 690 | $dir_output = $conf->expedition->dir_output.'/sending/'; |
| 691 | 691 | $object_type = 'order_supplier'; |
| 692 | - $mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated",$newref); |
|
| 692 | + $mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated", $newref); |
|
| 693 | 693 | break; |
| 694 | 694 | case 'EXPENSE_REPORT_VALIDATE': |
| 695 | 695 | $dir_output = $conf->expensereport->dir_output; |
| 696 | 696 | $object_type = 'expensereport'; |
| 697 | - $mesg = $langs->transnoentitiesnoconv("EMailTextExpenseReportValidated",$newref); |
|
| 697 | + $mesg = $langs->transnoentitiesnoconv("EMailTextExpenseReportValidated", $newref); |
|
| 698 | 698 | break; |
| 699 | 699 | case 'EXPENSE_REPORT_APPROVE': |
| 700 | 700 | $dir_output = $conf->expensereport->dir_output; |
| 701 | 701 | $object_type = 'expensereport'; |
| 702 | - $mesg = $langs->transnoentitiesnoconv("EMailTextExpenseReportApproved",$newref); |
|
| 702 | + $mesg = $langs->transnoentitiesnoconv("EMailTextExpenseReportApproved", $newref); |
|
| 703 | 703 | break; |
| 704 | 704 | case 'HOLIDAY_VALIDATE': |
| 705 | 705 | $dir_output = $conf->holiday->dir_output; |
| 706 | 706 | $object_type = 'holiday'; |
| 707 | - $mesg = $langs->transnoentitiesnoconv("EMailTextHolidayValidated",$newref); |
|
| 707 | + $mesg = $langs->transnoentitiesnoconv("EMailTextHolidayValidated", $newref); |
|
| 708 | 708 | break; |
| 709 | 709 | case 'HOLIDAY_APPROVE': |
| 710 | 710 | $dir_output = $conf->holiday->dir_output; |
| 711 | 711 | $object_type = 'holiday'; |
| 712 | - $mesg = $langs->transnoentitiesnoconv("EMailTextHolidayApproved",$newref); |
|
| 712 | + $mesg = $langs->transnoentitiesnoconv("EMailTextHolidayApproved", $newref); |
|
| 713 | 713 | break; |
| 714 | 714 | } |
| 715 | 715 | $ref = dol_sanitizeFileName($newref); |
| 716 | 716 | $pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; |
| 717 | - if (! dol_is_file($pdf_path)) |
|
| 717 | + if (!dol_is_file($pdf_path)) |
|
| 718 | 718 | { |
| 719 | 719 | // We can't add PDF as it is not generated yet. |
| 720 | 720 | $filepdf = ''; |
@@ -724,10 +724,10 @@ discard block |
||
| 724 | 724 | $filepdf = $pdf_path; |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | - $message = $langs->transnoentities("YouReceiveMailBecauseOfNotification",$application,$mysoc->name)."\n"; |
|
| 728 | - $message.= $langs->transnoentities("YouReceiveMailBecauseOfNotification2",$application,$mysoc->name)."\n"; |
|
| 729 | - $message.= "\n"; |
|
| 730 | - $message.= $mesg; |
|
| 727 | + $message = $langs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name)."\n"; |
|
| 728 | + $message .= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; |
|
| 729 | + $message .= "\n"; |
|
| 730 | + $message .= $mesg; |
|
| 731 | 731 | //if ($link) $message.= "\n" . $urlwithroot . $link; // link already added around the ref into the text |
| 732 | 732 | |
| 733 | 733 | $message = nl2br($message); |
@@ -735,28 +735,28 @@ discard block |
||
| 735 | 735 | // Replace keyword __SUPERVISOREMAIL__ |
| 736 | 736 | if (preg_match('/__SUPERVISOREMAIL__/', $sendto)) |
| 737 | 737 | { |
| 738 | - $newval=''; |
|
| 738 | + $newval = ''; |
|
| 739 | 739 | if ($user->fk_user > 0) |
| 740 | 740 | { |
| 741 | - $supervisoruser=new User($this->db); |
|
| 741 | + $supervisoruser = new User($this->db); |
|
| 742 | 742 | $supervisoruser->fetch($user->fk_user); |
| 743 | - if ($supervisoruser->email) $newval=trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>'); |
|
| 743 | + if ($supervisoruser->email) $newval = trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>'); |
|
| 744 | 744 | } |
| 745 | 745 | dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval); |
| 746 | 746 | $sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto); |
| 747 | - $sendto = preg_replace('/,\s*,/', ',', $sendto); // in some case you can have $sendto like "email, __SUPERVISOREMAIL__ , otheremail" then you have "email, , othermail" and it's not valid |
|
| 748 | - $sendto = preg_replace('/^[\s,]+/', '', $sendto); // Clean start of string |
|
| 749 | - $sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string |
|
| 747 | + $sendto = preg_replace('/,\s*,/', ',', $sendto); // in some case you can have $sendto like "email, __SUPERVISOREMAIL__ , otheremail" then you have "email, , othermail" and it's not valid |
|
| 748 | + $sendto = preg_replace('/^[\s,]+/', '', $sendto); // Clean start of string |
|
| 749 | + $sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | if ($sendto) |
| 753 | 753 | { |
| 754 | - $parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); |
|
| 755 | - $reshook=$hookmanager->executeHooks('formatNotificationMessage',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 754 | + $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); |
|
| 755 | + $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
| 756 | 756 | if (empty($reshook)) |
| 757 | 757 | { |
| 758 | - if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject']; |
|
| 759 | - if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message']; |
|
| 758 | + if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject']; |
|
| 759 | + if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message']; |
|
| 760 | 760 | } |
| 761 | 761 | $mailfile = new CMailFile( |
| 762 | 762 | $subject, |
@@ -775,8 +775,8 @@ discard block |
||
| 775 | 775 | if ($mailfile->sendfile()) |
| 776 | 776 | { |
| 777 | 777 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)"; |
| 778 | - $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')"; |
|
| 779 | - if (! $this->db->query($sql)) |
|
| 778 | + $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')"; |
|
| 779 | + if (!$this->db->query($sql)) |
|
| 780 | 780 | { |
| 781 | 781 | dol_print_error($this->db); |
| 782 | 782 | } |
@@ -784,13 +784,13 @@ discard block |
||
| 784 | 784 | else |
| 785 | 785 | { |
| 786 | 786 | $error++; |
| 787 | - $this->errors[]=$mailfile->error; |
|
| 787 | + $this->errors[] = $mailfile->error; |
|
| 788 | 788 | } |
| 789 | 789 | } |
| 790 | 790 | } |
| 791 | 791 | } |
| 792 | 792 | |
| 793 | - if (! $error) return $num; |
|
| 793 | + if (!$error) return $num; |
|
| 794 | 794 | else return -1 * $error; |
| 795 | 795 | } |
| 796 | 796 | } |
@@ -41,42 +41,42 @@ discard block |
||
| 41 | 41 | * @param string $type 'country' or 'city' |
| 42 | 42 | * @param string $datfile Data file |
| 43 | 43 | */ |
| 44 | - function __construct($type,$datfile) |
|
| 44 | + function __construct($type, $datfile) |
|
| 45 | 45 | { |
| 46 | 46 | if ($type == 'country') |
| 47 | 47 | { |
| 48 | 48 | // geoip may have been already included with PEAR |
| 49 | - if (! function_exists('geoip_country_code_by_name')) $res=include_once GEOIP_PATH.'geoip.inc'; |
|
| 49 | + if (!function_exists('geoip_country_code_by_name')) $res = include_once GEOIP_PATH.'geoip.inc'; |
|
| 50 | 50 | } |
| 51 | 51 | else if ($type == 'city') |
| 52 | 52 | { |
| 53 | 53 | // geoip may have been already included with PEAR |
| 54 | - if (! function_exists('geoip_country_code_by_name')) $res=include_once GEOIP_PATH.'geoipcity.inc'; |
|
| 54 | + if (!function_exists('geoip_country_code_by_name')) $res = include_once GEOIP_PATH.'geoipcity.inc'; |
|
| 55 | 55 | } |
| 56 | 56 | else { print 'ErrorBadParameterInConstructor'; return 0; } |
| 57 | 57 | |
| 58 | 58 | // Here, function exists (embedded into PHP or exists because we made include) |
| 59 | 59 | if (empty($type) || empty($datfile)) |
| 60 | 60 | { |
| 61 | - $this->errorlabel='Constructor was called with no datafile parameter'; |
|
| 61 | + $this->errorlabel = 'Constructor was called with no datafile parameter'; |
|
| 62 | 62 | dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR); |
| 63 | 63 | return 0; |
| 64 | 64 | } |
| 65 | - if (! file_exists($datfile) || ! is_readable($datfile)) |
|
| 65 | + if (!file_exists($datfile) || !is_readable($datfile)) |
|
| 66 | 66 | { |
| 67 | - $this->error='ErrorGeoIPClassNotInitialized'; |
|
| 68 | - $this->errorlabel="Datafile ".$datfile." not found"; |
|
| 67 | + $this->error = 'ErrorGeoIPClassNotInitialized'; |
|
| 68 | + $this->errorlabel = "Datafile ".$datfile." not found"; |
|
| 69 | 69 | dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR); |
| 70 | 70 | return 0; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | if (function_exists('geoip_open')) |
| 74 | 74 | { |
| 75 | - $this->gi = geoip_open($datfile,GEOIP_STANDARD); |
|
| 75 | + $this->gi = geoip_open($datfile, GEOIP_STANDARD); |
|
| 76 | 76 | } |
| 77 | 77 | else |
| 78 | 78 | { |
| 79 | - $this->gi = 'NOGI'; // We are using embedded php geoip functions |
|
| 79 | + $this->gi = 'NOGI'; // We are using embedded php geoip functions |
|
| 80 | 80 | //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); |
| 81 | 81 | //print geoip_database_info(); |
| 82 | 82 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | else |
| 103 | 103 | { |
| 104 | - if (! function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); |
|
| 104 | + if (!function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); |
|
| 105 | 105 | return strtolower(geoip_country_code_by_addr($this->gi, $ip)); |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | abstract class Stats |
| 31 | 31 | { |
| 32 | 32 | protected $db; |
| 33 | - var $_lastfetchdate=array(); // Dates of cache file read by methods |
|
| 34 | - var $cachefilesuffix=''; // Suffix to add to name of cache file (to avoid file name conflicts) |
|
| 33 | + var $_lastfetchdate = array(); // Dates of cache file read by methods |
|
| 34 | + var $cachefilesuffix = ''; // Suffix to add to name of cache file (to avoid file name conflicts) |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Return nb of elements by month for several years |
@@ -42,35 +42,35 @@ discard block |
||
| 42 | 42 | * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month |
| 43 | 43 | * @return array Array of values |
| 44 | 44 | */ |
| 45 | - function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay=0, $format=0) |
|
| 45 | + function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) |
|
| 46 | 46 | { |
| 47 | - global $conf,$user,$langs; |
|
| 47 | + global $conf, $user, $langs; |
|
| 48 | 48 | |
| 49 | 49 | if ($startyear > $endyear) return -1; |
| 50 | 50 | |
| 51 | - $datay=array(); |
|
| 51 | + $datay = array(); |
|
| 52 | 52 | |
| 53 | 53 | // Search into cache |
| 54 | - if (! empty($cachedelay)) |
|
| 54 | + if (!empty($cachedelay)) |
|
| 55 | 55 | { |
| 56 | 56 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 57 | 57 | include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix)?'':$this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache'; |
|
| 61 | - $newmask='0644'; |
|
| 60 | + $newpathofdestfile = $conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix) ? '' : $this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache'; |
|
| 61 | + $newmask = '0644'; |
|
| 62 | 62 | |
| 63 | 63 | $nowgmt = dol_now(); |
| 64 | 64 | |
| 65 | - $foundintocache=0; |
|
| 65 | + $foundintocache = 0; |
|
| 66 | 66 | if ($cachedelay > 0) |
| 67 | 67 | { |
| 68 | - $filedate=dol_filemtime($newpathofdestfile); |
|
| 68 | + $filedate = dol_filemtime($newpathofdestfile); |
|
| 69 | 69 | if ($filedate >= ($nowgmt - $cachedelay)) |
| 70 | 70 | { |
| 71 | - $foundintocache=1; |
|
| 71 | + $foundintocache = 1; |
|
| 72 | 72 | |
| 73 | - $this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$filedate; |
|
| 73 | + $this->_lastfetchdate[get_class($this).'_'.__FUNCTION__] = $filedate; |
|
| 74 | 74 | } |
| 75 | 75 | else |
| 76 | 76 | { |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | else |
| 87 | 87 | { |
| 88 | - $year=$startyear; |
|
| 88 | + $year = $startyear; |
|
| 89 | 89 | while ($year <= $endyear) |
| 90 | 90 | { |
| 91 | 91 | $datay[$year] = $this->getNbByMonth($year, $format); |
@@ -94,13 +94,13 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | $data = array(); |
| 96 | 96 | |
| 97 | - for ($i = 0 ; $i < 12 ; $i++) |
|
| 97 | + for ($i = 0; $i < 12; $i++) |
|
| 98 | 98 | { |
| 99 | - $data[$i][]=$datay[$endyear][$i][0]; |
|
| 100 | - $year=$startyear; |
|
| 101 | - while($year <= $endyear) |
|
| 99 | + $data[$i][] = $datay[$endyear][$i][0]; |
|
| 100 | + $year = $startyear; |
|
| 101 | + while ($year <= $endyear) |
|
| 102 | 102 | { |
| 103 | - $data[$i][]=$datay[$year][$i][1]; |
|
| 103 | + $data[$i][] = $datay[$year][$i][1]; |
|
| 104 | 104 | $year++; |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -110,14 +110,14 @@ discard block |
||
| 110 | 110 | if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1)) |
| 111 | 111 | { |
| 112 | 112 | dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk."); |
| 113 | - if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp); |
|
| 113 | + if (!dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp); |
|
| 114 | 114 | $fp = fopen($newpathofdestfile, 'w'); |
| 115 | 115 | fwrite($fp, json_encode($data)); |
| 116 | 116 | fclose($fp); |
| 117 | - if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; |
|
| 117 | + if (!empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK; |
|
| 118 | 118 | @chmod($newpathofdestfile, octdec($newmask)); |
| 119 | 119 | |
| 120 | - $this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$nowgmt; |
|
| 120 | + $this->_lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // return array(array('Month',val1,val2,val3),...) |
@@ -136,35 +136,35 @@ discard block |
||
| 136 | 136 | * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month |
| 137 | 137 | * @return array Array of values |
| 138 | 138 | */ |
| 139 | - function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay=0, $format=0) |
|
| 139 | + function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) |
|
| 140 | 140 | { |
| 141 | - global $conf,$user,$langs; |
|
| 141 | + global $conf, $user, $langs; |
|
| 142 | 142 | |
| 143 | 143 | if ($startyear > $endyear) return -1; |
| 144 | 144 | |
| 145 | - $datay=array(); |
|
| 145 | + $datay = array(); |
|
| 146 | 146 | |
| 147 | 147 | // Search into cache |
| 148 | - if (! empty($cachedelay)) |
|
| 148 | + if (!empty($cachedelay)) |
|
| 149 | 149 | { |
| 150 | 150 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 151 | 151 | include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - $newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix)?'':$this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache'; |
|
| 155 | - $newmask='0644'; |
|
| 154 | + $newpathofdestfile = $conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix) ? '' : $this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache'; |
|
| 155 | + $newmask = '0644'; |
|
| 156 | 156 | |
| 157 | 157 | $nowgmt = dol_now(); |
| 158 | 158 | |
| 159 | - $foundintocache=0; |
|
| 159 | + $foundintocache = 0; |
|
| 160 | 160 | if ($cachedelay > 0) |
| 161 | 161 | { |
| 162 | - $filedate=dol_filemtime($newpathofdestfile); |
|
| 162 | + $filedate = dol_filemtime($newpathofdestfile); |
|
| 163 | 163 | if ($filedate >= ($nowgmt - $cachedelay)) |
| 164 | 164 | { |
| 165 | - $foundintocache=1; |
|
| 165 | + $foundintocache = 1; |
|
| 166 | 166 | |
| 167 | - $this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$filedate; |
|
| 167 | + $this->_lastfetchdate[get_class($this).'_'.__FUNCTION__] = $filedate; |
|
| 168 | 168 | } |
| 169 | 169 | else |
| 170 | 170 | { |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | else |
| 182 | 182 | { |
| 183 | - $year=$startyear; |
|
| 184 | - while($year <= $endyear) |
|
| 183 | + $year = $startyear; |
|
| 184 | + while ($year <= $endyear) |
|
| 185 | 185 | { |
| 186 | 186 | $datay[$year] = $this->getAmountByMonth($year, $format); |
| 187 | 187 | $year++; |
@@ -189,13 +189,13 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | $data = array(); |
| 191 | 191 | // $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...) |
| 192 | - for ($i = 0 ; $i < 12 ; $i++) |
|
| 192 | + for ($i = 0; $i < 12; $i++) |
|
| 193 | 193 | { |
| 194 | - $data[$i][]=$datay[$endyear][$i][0]; // set label |
|
| 195 | - $year=$startyear; |
|
| 196 | - while($year <= $endyear) |
|
| 194 | + $data[$i][] = $datay[$endyear][$i][0]; // set label |
|
| 195 | + $year = $startyear; |
|
| 196 | + while ($year <= $endyear) |
|
| 197 | 197 | { |
| 198 | - $data[$i][]=$datay[$year][$i][1]; // set yval for x=i |
|
| 198 | + $data[$i][] = $datay[$year][$i][1]; // set yval for x=i |
|
| 199 | 199 | $year++; |
| 200 | 200 | } |
| 201 | 201 | } |
@@ -205,17 +205,17 @@ discard block |
||
| 205 | 205 | if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1)) |
| 206 | 206 | { |
| 207 | 207 | dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk."); |
| 208 | - if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp); |
|
| 208 | + if (!dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp); |
|
| 209 | 209 | $fp = fopen($newpathofdestfile, 'w'); |
| 210 | 210 | if ($fp) |
| 211 | 211 | { |
| 212 | 212 | fwrite($fp, json_encode($data)); |
| 213 | 213 | fclose($fp); |
| 214 | - if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; |
|
| 214 | + if (!empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK; |
|
| 215 | 215 | @chmod($newpathofdestfile, octdec($newmask)); |
| 216 | 216 | } |
| 217 | 217 | else dol_syslog("Failed to write cache file", LOG_ERR); |
| 218 | - $this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$nowgmt; |
|
| 218 | + $this->_lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | return $data; |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | * @param int $startyear End year |
| 229 | 229 | * @return array Array of values |
| 230 | 230 | */ |
| 231 | - function getAverageByMonthWithPrevYear($endyear,$startyear) |
|
| 231 | + function getAverageByMonthWithPrevYear($endyear, $startyear) |
|
| 232 | 232 | { |
| 233 | 233 | if ($startyear > $endyear) return -1; |
| 234 | 234 | |
| 235 | - $datay=array(); |
|
| 235 | + $datay = array(); |
|
| 236 | 236 | |
| 237 | - $year=$startyear; |
|
| 238 | - while($year <= $endyear) |
|
| 237 | + $year = $startyear; |
|
| 238 | + while ($year <= $endyear) |
|
| 239 | 239 | { |
| 240 | 240 | $datay[$year] = $this->getAverageByMonth($year); |
| 241 | 241 | $year++; |
@@ -243,13 +243,13 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | $data = array(); |
| 245 | 245 | |
| 246 | - for ($i = 0 ; $i < 12 ; $i++) |
|
| 246 | + for ($i = 0; $i < 12; $i++) |
|
| 247 | 247 | { |
| 248 | - $data[$i][]=$datay[$endyear][$i][0]; |
|
| 249 | - $year=$startyear; |
|
| 250 | - while($year <= $endyear) |
|
| 248 | + $data[$i][] = $datay[$endyear][$i][0]; |
|
| 249 | + $year = $startyear; |
|
| 250 | + while ($year <= $endyear) |
|
| 251 | 251 | { |
| 252 | - $data[$i][]=$datay[$year][$i][1]; |
|
| 252 | + $data[$i][] = $datay[$year][$i][1]; |
|
| 253 | 253 | $year++; |
| 254 | 254 | } |
| 255 | 255 | } |
@@ -264,33 +264,33 @@ discard block |
||
| 264 | 264 | * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) |
| 265 | 265 | * @return array Array of values |
| 266 | 266 | */ |
| 267 | - function getAllByProductEntry($year,$cachedelay=0) |
|
| 267 | + function getAllByProductEntry($year, $cachedelay = 0) |
|
| 268 | 268 | { |
| 269 | - global $conf,$user,$langs; |
|
| 269 | + global $conf, $user, $langs; |
|
| 270 | 270 | |
| 271 | - $datay=array(); |
|
| 271 | + $datay = array(); |
|
| 272 | 272 | |
| 273 | 273 | // Search into cache |
| 274 | - if (! empty($cachedelay)) |
|
| 274 | + if (!empty($cachedelay)) |
|
| 275 | 275 | { |
| 276 | 276 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 277 | 277 | include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - $newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix)?'':$this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache'; |
|
| 281 | - $newmask='0644'; |
|
| 280 | + $newpathofdestfile = $conf->user->dir_temp.'/'.get_class($this).'_'.__FUNCTION__.'_'.(empty($this->cachefilesuffix) ? '' : $this->cachefilesuffix.'_').$langs->defaultlang.'_entity.'.$conf->entity.'_user'.$user->id.'.cache'; |
|
| 281 | + $newmask = '0644'; |
|
| 282 | 282 | |
| 283 | 283 | $nowgmt = dol_now(); |
| 284 | 284 | |
| 285 | - $foundintocache=0; |
|
| 285 | + $foundintocache = 0; |
|
| 286 | 286 | if ($cachedelay > 0) |
| 287 | 287 | { |
| 288 | - $filedate=dol_filemtime($newpathofdestfile); |
|
| 288 | + $filedate = dol_filemtime($newpathofdestfile); |
|
| 289 | 289 | if ($filedate >= ($nowgmt - $cachedelay)) |
| 290 | 290 | { |
| 291 | - $foundintocache=1; |
|
| 291 | + $foundintocache = 1; |
|
| 292 | 292 | |
| 293 | - $this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$filedate; |
|
| 293 | + $this->_lastfetchdate[get_class($this).'_'.__FUNCTION__] = $filedate; |
|
| 294 | 294 | } |
| 295 | 295 | else |
| 296 | 296 | { |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | } |
| 307 | 307 | else |
| 308 | 308 | { |
| 309 | - $data=$this->getAllByProduct($year); |
|
| 309 | + $data = $this->getAllByProduct($year); |
|
| 310 | 310 | // $data[$i][]=$datay[$year][$i][1]; // set yval for x=i |
| 311 | 311 | } |
| 312 | 312 | |
@@ -314,16 +314,16 @@ discard block |
||
| 314 | 314 | if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1)) |
| 315 | 315 | { |
| 316 | 316 | dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk."); |
| 317 | - if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp); |
|
| 317 | + if (!dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp); |
|
| 318 | 318 | $fp = fopen($newpathofdestfile, 'w'); |
| 319 | 319 | if ($fp) |
| 320 | 320 | { |
| 321 | 321 | fwrite($fp, json_encode($data)); |
| 322 | 322 | fclose($fp); |
| 323 | - if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; |
|
| 323 | + if (!empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK; |
|
| 324 | 324 | @chmod($newpathofdestfile, octdec($newmask)); |
| 325 | 325 | } |
| 326 | - $this->_lastfetchdate[get_class($this).'_'.__FUNCTION__]=$nowgmt; |
|
| 326 | + $this->_lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | return $data; |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | $result = array(); |
| 345 | 345 | |
| 346 | 346 | dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); |
| 347 | - $resql=$this->db->query($sql); |
|
| 347 | + $resql = $this->db->query($sql); |
|
| 348 | 348 | if ($resql) |
| 349 | 349 | { |
| 350 | 350 | $num = $this->db->num_rows($resql); |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | $result = array(); |
| 375 | 375 | |
| 376 | 376 | dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); |
| 377 | - $resql=$this->db->query($sql); |
|
| 377 | + $resql = $this->db->query($sql); |
|
| 378 | 378 | if ($resql) |
| 379 | 379 | { |
| 380 | 380 | $num = $this->db->num_rows($resql); |
@@ -384,16 +384,16 @@ discard block |
||
| 384 | 384 | $row = $this->db->fetch_object($resql); |
| 385 | 385 | $result[$i]['year'] = $row->year; |
| 386 | 386 | $result[$i]['nb'] = $row->nb; |
| 387 | - if($i>0 && $row->nb) $result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100; |
|
| 387 | + if ($i > 0 && $row->nb) $result[$i - 1]['nb_diff'] = ($result[$i - 1]['nb'] - $row->nb) / $row->nb * 100; |
|
| 388 | 388 | $result[$i]['total'] = $row->total; |
| 389 | - if($i>0 && $row->total) $result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100; |
|
| 389 | + if ($i > 0 && $row->total) $result[$i - 1]['total_diff'] = ($result[$i - 1]['total'] - $row->total) / $row->total * 100; |
|
| 390 | 390 | $result[$i]['avg'] = $row->avg; |
| 391 | - if($i>0 && $row->avg) $result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100; |
|
| 391 | + if ($i > 0 && $row->avg) $result[$i - 1]['avg_diff'] = ($result[$i - 1]['avg'] - $row->avg) / $row->avg * 100; |
|
| 392 | 392 | // For some $sql only |
| 393 | 393 | if (isset($row->weighted)) |
| 394 | 394 | { |
| 395 | 395 | $result[$i]['weighted'] = $row->weighted; |
| 396 | - if($i>0 && $row->weighted) $result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100; |
|
| 396 | + if ($i > 0 && $row->weighted) $result[$i - 1]['avg_weighted'] = ($result[$i - 1]['weighted'] - $row->weighted) / $row->weighted * 100; |
|
| 397 | 397 | } |
| 398 | 398 | $i++; |
| 399 | 399 | } |
@@ -413,15 +413,15 @@ discard block |
||
| 413 | 413 | * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month |
| 414 | 414 | * @return array Array of nb each month |
| 415 | 415 | */ |
| 416 | - function _getNbByMonth($year, $sql, $format=0) |
|
| 416 | + function _getNbByMonth($year, $sql, $format = 0) |
|
| 417 | 417 | { |
| 418 | 418 | global $langs; |
| 419 | 419 | |
| 420 | - $result=array(); |
|
| 421 | - $res=array(); |
|
| 420 | + $result = array(); |
|
| 421 | + $res = array(); |
|
| 422 | 422 | |
| 423 | 423 | dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); |
| 424 | - $resql=$this->db->query($sql); |
|
| 424 | + $resql = $this->db->query($sql); |
|
| 425 | 425 | if ($resql) |
| 426 | 426 | { |
| 427 | 427 | $num = $this->db->num_rows($resql); |
@@ -440,22 +440,22 @@ discard block |
||
| 440 | 440 | dol_print_error($this->db); |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - for ($i = 1 ; $i < 13 ; $i++) |
|
| 443 | + for ($i = 1; $i < 13; $i++) |
|
| 444 | 444 | { |
| 445 | - $res[$i] = (isset($result[$i])?$result[$i]:0); |
|
| 445 | + $res[$i] = (isset($result[$i]) ? $result[$i] : 0); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | $data = array(); |
| 449 | 449 | |
| 450 | - for ($i = 1 ; $i < 13 ; $i++) |
|
| 450 | + for ($i = 1; $i < 13; $i++) |
|
| 451 | 451 | { |
| 452 | - $month='unknown'; |
|
| 453 | - if ($format == 0) $month=$langs->transnoentitiesnoconv('MonthShort'.sprintf("%02d", $i)); |
|
| 454 | - elseif ($format == 1) $month=$i; |
|
| 455 | - elseif ($format == 2) $month=$langs->transnoentitiesnoconv('MonthVeryShort'.sprintf("%02d", $i)); |
|
| 452 | + $month = 'unknown'; |
|
| 453 | + if ($format == 0) $month = $langs->transnoentitiesnoconv('MonthShort'.sprintf("%02d", $i)); |
|
| 454 | + elseif ($format == 1) $month = $i; |
|
| 455 | + elseif ($format == 2) $month = $langs->transnoentitiesnoconv('MonthVeryShort'.sprintf("%02d", $i)); |
|
| 456 | 456 | //$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b")); |
| 457 | 457 | //$month=dol_substr($month,0,3); |
| 458 | - $data[$i-1] = array($month, $res[$i]); |
|
| 458 | + $data[$i - 1] = array($month, $res[$i]); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | return $data; |
@@ -470,16 +470,16 @@ discard block |
||
| 470 | 470 | * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month |
| 471 | 471 | * @return array |
| 472 | 472 | */ |
| 473 | - function _getAmountByMonth($year, $sql, $format=0) |
|
| 473 | + function _getAmountByMonth($year, $sql, $format = 0) |
|
| 474 | 474 | { |
| 475 | 475 | global $langs; |
| 476 | 476 | |
| 477 | - $result=array(); |
|
| 478 | - $res=array(); |
|
| 477 | + $result = array(); |
|
| 478 | + $res = array(); |
|
| 479 | 479 | |
| 480 | 480 | dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); |
| 481 | 481 | |
| 482 | - $resql=$this->db->query($sql); |
|
| 482 | + $resql = $this->db->query($sql); |
|
| 483 | 483 | if ($resql) |
| 484 | 484 | { |
| 485 | 485 | $num = $this->db->num_rows($resql); |
@@ -495,22 +495,22 @@ discard block |
||
| 495 | 495 | } |
| 496 | 496 | else dol_print_error($this->db); |
| 497 | 497 | |
| 498 | - for ($i = 1 ; $i < 13 ; $i++) |
|
| 498 | + for ($i = 1; $i < 13; $i++) |
|
| 499 | 499 | { |
| 500 | - $res[$i] = (int) round((isset($result[$i])?$result[$i]:0)); |
|
| 500 | + $res[$i] = (int) round((isset($result[$i]) ? $result[$i] : 0)); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | $data = array(); |
| 504 | 504 | |
| 505 | - for ($i = 1 ; $i < 13 ; $i++) |
|
| 505 | + for ($i = 1; $i < 13; $i++) |
|
| 506 | 506 | { |
| 507 | - $month='unknown'; |
|
| 508 | - if ($format == 0) $month=$langs->transnoentitiesnoconv('MonthShort'.sprintf("%02d", $i)); |
|
| 509 | - elseif ($format == 1) $month=$i; |
|
| 510 | - elseif ($format == 2) $month=$langs->transnoentitiesnoconv('MonthVeryShort'.sprintf("%02d", $i)); |
|
| 507 | + $month = 'unknown'; |
|
| 508 | + if ($format == 0) $month = $langs->transnoentitiesnoconv('MonthShort'.sprintf("%02d", $i)); |
|
| 509 | + elseif ($format == 1) $month = $i; |
|
| 510 | + elseif ($format == 2) $month = $langs->transnoentitiesnoconv('MonthVeryShort'.sprintf("%02d", $i)); |
|
| 511 | 511 | //$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b")); |
| 512 | 512 | //$month=dol_substr($month,0,3); |
| 513 | - $data[$i-1] = array($month, $res[$i]); |
|
| 513 | + $data[$i - 1] = array($month, $res[$i]); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | return $data; |
@@ -524,15 +524,15 @@ discard block |
||
| 524 | 524 | * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month |
| 525 | 525 | * @return array |
| 526 | 526 | */ |
| 527 | - function _getAverageByMonth($year, $sql, $format=0) |
|
| 527 | + function _getAverageByMonth($year, $sql, $format = 0) |
|
| 528 | 528 | { |
| 529 | 529 | global $langs; |
| 530 | 530 | |
| 531 | - $result=array(); |
|
| 532 | - $res=array(); |
|
| 531 | + $result = array(); |
|
| 532 | + $res = array(); |
|
| 533 | 533 | |
| 534 | 534 | dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); |
| 535 | - $resql=$this->db->query($sql); |
|
| 535 | + $resql = $this->db->query($sql); |
|
| 536 | 536 | if ($resql) |
| 537 | 537 | { |
| 538 | 538 | $num = $this->db->num_rows($resql); |
@@ -548,22 +548,22 @@ discard block |
||
| 548 | 548 | } |
| 549 | 549 | else dol_print_error($this->db); |
| 550 | 550 | |
| 551 | - for ($i = 1 ; $i < 13 ; $i++) |
|
| 551 | + for ($i = 1; $i < 13; $i++) |
|
| 552 | 552 | { |
| 553 | - $res[$i] = (isset($result[$i])?$result[$i]:0); |
|
| 553 | + $res[$i] = (isset($result[$i]) ? $result[$i] : 0); |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | $data = array(); |
| 557 | 557 | |
| 558 | - for ($i = 1 ; $i < 13 ; $i++) |
|
| 558 | + for ($i = 1; $i < 13; $i++) |
|
| 559 | 559 | { |
| 560 | - $month='unknown'; |
|
| 561 | - if ($format == 0) $month=$langs->transnoentitiesnoconv('MonthShort'.sprintf("%02d", $i)); |
|
| 562 | - elseif ($format == 1) $month=$i; |
|
| 563 | - elseif ($format == 2) $month=$langs->transnoentitiesnoconv('MonthVeryShort'.sprintf("%02d", $i)); |
|
| 560 | + $month = 'unknown'; |
|
| 561 | + if ($format == 0) $month = $langs->transnoentitiesnoconv('MonthShort'.sprintf("%02d", $i)); |
|
| 562 | + elseif ($format == 1) $month = $i; |
|
| 563 | + elseif ($format == 2) $month = $langs->transnoentitiesnoconv('MonthVeryShort'.sprintf("%02d", $i)); |
|
| 564 | 564 | //$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b")); |
| 565 | 565 | //$month=dol_substr($month,0,3); |
| 566 | - $data[$i-1] = array($month, $res[$i]); |
|
| 566 | + $data[$i - 1] = array($month, $res[$i]); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | return $data; |
@@ -577,27 +577,27 @@ discard block |
||
| 577 | 577 | * @param int $limit Limit |
| 578 | 578 | * @return array |
| 579 | 579 | */ |
| 580 | - function _getAllByProduct($sql, $limit=10) |
|
| 580 | + function _getAllByProduct($sql, $limit = 10) |
|
| 581 | 581 | { |
| 582 | 582 | global $langs; |
| 583 | 583 | |
| 584 | - $result=array(); |
|
| 585 | - $res=array(); |
|
| 584 | + $result = array(); |
|
| 585 | + $res = array(); |
|
| 586 | 586 | |
| 587 | 587 | dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); |
| 588 | - $resql=$this->db->query($sql); |
|
| 588 | + $resql = $this->db->query($sql); |
|
| 589 | 589 | if ($resql) |
| 590 | 590 | { |
| 591 | 591 | $num = $this->db->num_rows($resql); |
| 592 | - $i = 0; $other=0; |
|
| 592 | + $i = 0; $other = 0; |
|
| 593 | 593 | while ($i < $num) |
| 594 | 594 | { |
| 595 | 595 | $row = $this->db->fetch_row($resql); |
| 596 | - if ($i < $limit || $num == $limit) $result[$i] = array($row[0],$row[1]); // Ref of product, nb |
|
| 596 | + if ($i < $limit || $num == $limit) $result[$i] = array($row[0], $row[1]); // Ref of product, nb |
|
| 597 | 597 | else $other += $row[1]; |
| 598 | 598 | $i++; |
| 599 | 599 | } |
| 600 | - if ($num > $limit) $result[$i] = array($langs->transnoentitiesnoconv("Other"),$other); |
|
| 600 | + if ($num > $limit) $result[$i] = array($langs->transnoentitiesnoconv("Other"), $other); |
|
| 601 | 601 | $this->db->free($resql); |
| 602 | 602 | } |
| 603 | 603 | else dol_print_error($this->db); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | public $error; |
| 43 | 43 | |
| 44 | 44 | public $numoffiles; |
| 45 | - public $infofiles; // Used to return informations by function getDocumentsLink |
|
| 45 | + public $infofiles; // Used to return informations by function getDocumentsLink |
|
| 46 | 46 | |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | function __construct($db) |
| 54 | 54 | { |
| 55 | 55 | $this->db = $db; |
| 56 | - $this->numoffiles=0; |
|
| 56 | + $this->numoffiles = 0; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
@@ -77,16 +77,16 @@ discard block |
||
| 77 | 77 | * @param string $sectiondir If upload must be done inside a particular directory (is sectiondir defined, sectionid must not be) |
| 78 | 78 | * @return int <0 if KO, >0 if OK |
| 79 | 79 | */ |
| 80 | - function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1, $htmlname='formuserfile', $accept='', $sectiondir='') |
|
| 80 | + function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '') |
|
| 81 | 81 | { |
| 82 | 82 | // phpcs:enable |
| 83 | - global $conf,$langs, $hookmanager; |
|
| 83 | + global $conf, $langs, $hookmanager; |
|
| 84 | 84 | $hookmanager->initHooks(array('formfile')); |
| 85 | 85 | |
| 86 | 86 | |
| 87 | - if (! empty($conf->browser->layout) && $conf->browser->layout != 'classic') $useajax=0; |
|
| 87 | + if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic') $useajax = 0; |
|
| 88 | 88 | |
| 89 | - if ((! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) && $useajax) || ($useajax==2)) |
|
| 89 | + if ((!empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) && $useajax) || ($useajax == 2)) |
|
| 90 | 90 | { |
| 91 | 91 | // TODO: Check this works with 2 forms on same page |
| 92 | 92 | // TODO: Check this works with GED module, otherwise, force useajax to 0 |
@@ -101,12 +101,12 @@ discard block |
||
| 101 | 101 | return 1; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $maxlength=$size; |
|
| 104 | + $maxlength = $size; |
|
| 105 | 105 | |
| 106 | 106 | $out = "\n\n<!-- Start form attach new file -->\n"; |
| 107 | 107 | |
| 108 | - if (empty($title)) $title=$langs->trans("AttachANewFile"); |
|
| 109 | - if ($title != 'none') $out.=load_fiche_titre($title, null, null); |
|
| 108 | + if (empty($title)) $title = $langs->trans("AttachANewFile"); |
|
| 109 | + if ($title != 'none') $out .= load_fiche_titre($title, null, null); |
|
| 110 | 110 | |
| 111 | 111 | $out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">'; |
| 112 | 112 | $out .= '<input type="hidden" id="'.$htmlname.'_section_dir" name="section_dir" value="'.$sectiondir.'">'; |
@@ -116,34 +116,34 @@ discard block |
||
| 116 | 116 | $out .= '<table width="100%" class="nobordernopadding">'; |
| 117 | 117 | $out .= '<tr>'; |
| 118 | 118 | |
| 119 | - if (! empty($options)) $out .= '<td>'.$options.'</td>'; |
|
| 119 | + if (!empty($options)) $out .= '<td>'.$options.'</td>'; |
|
| 120 | 120 | |
| 121 | 121 | $out .= '<td class="valignmiddle nowrap">'; |
| 122 | 122 | |
| 123 | - $max=$conf->global->MAIN_UPLOAD_DOC; // En Kb |
|
| 124 | - $maxphp=@ini_get('upload_max_filesize'); // En inconnu |
|
| 125 | - if (preg_match('/k$/i',$maxphp)) $maxphp=$maxphp*1; |
|
| 126 | - if (preg_match('/m$/i',$maxphp)) $maxphp=$maxphp*1024; |
|
| 127 | - if (preg_match('/g$/i',$maxphp)) $maxphp=$maxphp*1024*1024; |
|
| 128 | - if (preg_match('/t$/i',$maxphp)) $maxphp=$maxphp*1024*1024*1024; |
|
| 123 | + $max = $conf->global->MAIN_UPLOAD_DOC; // En Kb |
|
| 124 | + $maxphp = @ini_get('upload_max_filesize'); // En inconnu |
|
| 125 | + if (preg_match('/k$/i', $maxphp)) $maxphp = $maxphp * 1; |
|
| 126 | + if (preg_match('/m$/i', $maxphp)) $maxphp = $maxphp * 1024; |
|
| 127 | + if (preg_match('/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024; |
|
| 128 | + if (preg_match('/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024; |
|
| 129 | 129 | // Now $max and $maxphp are in Kb |
| 130 | 130 | $maxmin = $max; |
| 131 | - if ($maxphp > 0) $maxmin=min($max,$maxphp); |
|
| 131 | + if ($maxphp > 0) $maxmin = min($max, $maxphp); |
|
| 132 | 132 | |
| 133 | 133 | if ($maxmin > 0) |
| 134 | 134 | { |
| 135 | 135 | // MAX_FILE_SIZE doit précéder le champ input de type file |
| 136 | - $out .= '<input type="hidden" name="max_file_size" value="'.($maxmin*1024).'">'; |
|
| 136 | + $out .= '<input type="hidden" name="max_file_size" value="'.($maxmin * 1024).'">'; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $out .= '<input class="flat minwidth400" type="file"'; |
| 140 | - $out .= ((! empty($conf->global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $conf->browser->layout != 'classic')?' name="userfile"':' name="userfile[]" multiple'); |
|
| 141 | - $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':''); |
|
| 142 | - $out .= (!empty($accept)?' accept="'.$accept.'"':' accept=""'); |
|
| 140 | + $out .= ((!empty($conf->global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $conf->browser->layout != 'classic') ? ' name="userfile"' : ' name="userfile[]" multiple'); |
|
| 141 | + $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ? ' disabled' : ''); |
|
| 142 | + $out .= (!empty($accept) ? ' accept="'.$accept.'"' : ' accept=""'); |
|
| 143 | 143 | $out .= '>'; |
| 144 | 144 | $out .= ' '; |
| 145 | 145 | $out .= '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'"'; |
| 146 | - $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':''); |
|
| 146 | + $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ? ' disabled' : ''); |
|
| 147 | 147 | $out .= '>'; |
| 148 | 148 | |
| 149 | 149 | if ($addcancel) |
@@ -152,13 +152,13 @@ discard block |
||
| 152 | 152 | $out .= '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if (! empty($conf->global->MAIN_UPLOAD_DOC)) |
|
| 155 | + if (!empty($conf->global->MAIN_UPLOAD_DOC)) |
|
| 156 | 156 | { |
| 157 | 157 | if ($perm) |
| 158 | 158 | { |
| 159 | 159 | $langs->load('other'); |
| 160 | 160 | $out .= ' '; |
| 161 | - $out .= info_admin($langs->trans("ThisLimitIsDefinedInSetup",$max,$maxphp),1); |
|
| 161 | + $out .= info_admin($langs->trans("ThisLimitIsDefinedInSetup", $max, $maxphp), 1); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | else |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | if ($savingdocmask) |
| 171 | 171 | { |
| 172 | 172 | $out .= '<tr>'; |
| 173 | - if (! empty($options)) $out .= '<td>'.$options.'</td>'; |
|
| 173 | + if (!empty($options)) $out .= '<td>'.$options.'</td>'; |
|
| 174 | 174 | $out .= '<td valign="middle" class="nowrap">'; |
| 175 | - $out .= '<input type="checkbox" checked class="savingdocmask" name="savingdocmask" value="'.dol_escape_js($savingdocmask).'"> '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/',$langs->transnoentitiesnoconv("OriginFileName"),$savingdocmask), $langs->transnoentitiesnoconv("OriginFileName")); |
|
| 175 | + $out .= '<input type="checkbox" checked class="savingdocmask" name="savingdocmask" value="'.dol_escape_js($savingdocmask).'"> '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/', $langs->transnoentitiesnoconv("OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv("OriginFileName")); |
|
| 176 | 176 | $out .= '</td>'; |
| 177 | 177 | $out .= '</tr>'; |
| 178 | 178 | } |
@@ -197,18 +197,18 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | $out .= '<div class="valignmiddle" >'; |
| 199 | 199 | $out .= '<div class="inline-block" style="padding-right: 10px;">'; |
| 200 | - if (! empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= '<label for="link">'.$langs->trans("URLToLink") . ':</label> '; |
|
| 200 | + if (!empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= '<label for="link">'.$langs->trans("URLToLink").':</label> '; |
|
| 201 | 201 | $out .= '<input type="text" name="link" class="flat minwidth400imp" id="link" placeholder="'.dol_escape_htmltag($langs->trans("URLToLink")).'">'; |
| 202 | 202 | $out .= '</div>'; |
| 203 | 203 | $out .= '<div class="inline-block" style="padding-right: 10px;">'; |
| 204 | - if (! empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= '<label for="label">'.$langs->trans("Label") . ':</label> '; |
|
| 204 | + if (!empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= '<label for="label">'.$langs->trans("Label").':</label> '; |
|
| 205 | 205 | $out .= '<input type="text" class="flat" name="label" id="label" placeholder="'.dol_escape_htmltag($langs->trans("Label")).'">'; |
| 206 | - $out .= '<input type="hidden" name="objecttype" value="' . $object->element . '">'; |
|
| 207 | - $out .= '<input type="hidden" name="objectid" value="' . $object->id . '">'; |
|
| 206 | + $out .= '<input type="hidden" name="objecttype" value="'.$object->element.'">'; |
|
| 207 | + $out .= '<input type="hidden" name="objectid" value="'.$object->id.'">'; |
|
| 208 | 208 | $out .= '</div>'; |
| 209 | 209 | $out .= '<div class="inline-block" style="padding-right: 10px;">'; |
| 210 | 210 | $out .= '<input type="submit" class="button" name="linkit" value="'.$langs->trans("ToLink").'"'; |
| 211 | - $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':''); |
|
| 211 | + $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ? ' disabled' : ''); |
|
| 212 | 212 | $out .= '>'; |
| 213 | 213 | $out .= '</div>'; |
| 214 | 214 | $out .= '</div>'; |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | $out .= "\n<!-- End form link new url -->\n"; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - $parameters = array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''), 'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'url'=>$url, 'perm'=>$perm); |
|
| 222 | - $res = $hookmanager->executeHooks('formattachOptions',$parameters,$object); |
|
| 221 | + $parameters = array('socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'url'=>$url, 'perm'=>$perm); |
|
| 222 | + $res = $hookmanager->executeHooks('formattachOptions', $parameters, $object); |
|
| 223 | 223 | if (empty($res)) |
| 224 | 224 | { |
| 225 | 225 | print '<div class="attacharea attacharea'.$htmlname.'">'; |
@@ -255,11 +255,11 @@ discard block |
||
| 255 | 255 | * @return int <0 if KO, number of shown files if OK |
| 256 | 256 | * @deprecated Use print xxx->showdocuments() instead. |
| 257 | 257 | */ |
| 258 | - function show_documents($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$notused=0,$noform=0,$param='',$title='',$buttonlabel='',$codelang='') |
|
| 258 | + function show_documents($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '') |
|
| 259 | 259 | { |
| 260 | 260 | // phpcs:enable |
| 261 | - $this->numoffiles=0; |
|
| 262 | - print $this->showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed,$modelselected,$allowgenifempty,$forcenomultilang,$iconPDF,$notused,$noform,$param,$title,$buttonlabel,$codelang); |
|
| 261 | + $this->numoffiles = 0; |
|
| 262 | + print $this->showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang); |
|
| 263 | 263 | return $this->numoffiles; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -288,58 +288,58 @@ discard block |
||
| 288 | 288 | * @param int $hideifempty Hide section of generated files if there is no file |
| 289 | 289 | * @return string Output string with HTML array of documents (might be empty string) |
| 290 | 290 | */ |
| 291 | - function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$notused=0,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='',$object=null,$hideifempty=0) |
|
| 291 | + function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '', $morepicto = '', $object = null, $hideifempty = 0) |
|
| 292 | 292 | { |
| 293 | 293 | // Deprecation warning |
| 294 | - if (! empty($iconPDF)) { |
|
| 295 | - dol_syslog(__METHOD__ . ": passing iconPDF parameter is deprecated", LOG_WARNING); |
|
| 294 | + if (!empty($iconPDF)) { |
|
| 295 | + dol_syslog(__METHOD__.": passing iconPDF parameter is deprecated", LOG_WARNING); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | global $langs, $conf, $user, $hookmanager; |
| 299 | 299 | global $form; |
| 300 | 300 | |
| 301 | - if (! is_object($form)) $form=new Form($this->db); |
|
| 301 | + if (!is_object($form)) $form = new Form($this->db); |
|
| 302 | 302 | |
| 303 | 303 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 304 | 304 | |
| 305 | 305 | // For backward compatibility |
| 306 | - if (! empty($iconPDF)) { |
|
| 306 | + if (!empty($iconPDF)) { |
|
| 307 | 307 | return $this->getDocumentsLink($modulepart, $modulesubdir, $filedir); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | // Add entity in $param |
| 311 | - $param.= 'entity='.(!empty($object->entity)?$object->entity:$conf->entity); |
|
| 311 | + $param .= 'entity='.(!empty($object->entity) ? $object->entity : $conf->entity); |
|
| 312 | 312 | |
| 313 | - $printer=0; |
|
| 314 | - if (in_array($modulepart,array('facture','supplier_proposal','propal','proposal','order','commande','expedition', 'commande_fournisseur', 'expensereport','livraison'))) // The direct print feature is implemented only for such elements |
|
| 313 | + $printer = 0; |
|
| 314 | + if (in_array($modulepart, array('facture', 'supplier_proposal', 'propal', 'proposal', 'order', 'commande', 'expedition', 'commande_fournisseur', 'expensereport', 'livraison'))) // The direct print feature is implemented only for such elements |
|
| 315 | 315 | { |
| 316 | - $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false; |
|
| 316 | + $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled)) ?true:false; |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | $hookmanager->initHooks(array('formfile')); |
| 320 | 320 | |
| 321 | 321 | // Get list of files |
| 322 | - $file_list=null; |
|
| 323 | - if (! empty($filedir)) |
|
| 322 | + $file_list = null; |
|
| 323 | + if (!empty($filedir)) |
|
| 324 | 324 | { |
| 325 | - $file_list=dol_dir_list($filedir,'files',0,'','(\.meta|_preview.*.*\.png)$','date',SORT_DESC); |
|
| 325 | + $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC); |
|
| 326 | 326 | } |
| 327 | 327 | if ($hideifempty && empty($file_list)) return ''; |
| 328 | 328 | |
| 329 | - $out=''; |
|
| 330 | - $forname='builddoc'; |
|
| 331 | - $headershown=0; |
|
| 332 | - $showempty=0; |
|
| 333 | - $i=0; |
|
| 329 | + $out = ''; |
|
| 330 | + $forname = 'builddoc'; |
|
| 331 | + $headershown = 0; |
|
| 332 | + $showempty = 0; |
|
| 333 | + $i = 0; |
|
| 334 | 334 | |
| 335 | - $out.= "\n".'<!-- Start show_document -->'."\n"; |
|
| 335 | + $out .= "\n".'<!-- Start show_document -->'."\n"; |
|
| 336 | 336 | //print 'filedir='.$filedir; |
| 337 | 337 | |
| 338 | 338 | if (preg_match('/massfilesarea_/', $modulepart)) |
| 339 | 339 | { |
| 340 | - $out.='<div id="show_files"><br></div>'."\n"; |
|
| 341 | - $title=$langs->trans("MassFilesArea").' <a href="" id="togglemassfilesarea" ref="shown">('.$langs->trans("Hide").')</a>'; |
|
| 342 | - $title.='<script type="text/javascript" language="javascript"> |
|
| 340 | + $out .= '<div id="show_files"><br></div>'."\n"; |
|
| 341 | + $title = $langs->trans("MassFilesArea").' <a href="" id="togglemassfilesarea" ref="shown">('.$langs->trans("Hide").')</a>'; |
|
| 342 | + $title .= '<script type="text/javascript" language="javascript"> |
|
| 343 | 343 | jQuery(document).ready(function() { |
| 344 | 344 | jQuery(\'#togglemassfilesarea\').click(function() { |
| 345 | 345 | if (jQuery(\'#togglemassfilesarea\').attr(\'ref\') == "shown") |
@@ -360,63 +360,63 @@ discard block |
||
| 360 | 360 | </script>'; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - $titletoshow=$langs->trans("Documents"); |
|
| 364 | - if (! empty($title)) $titletoshow=$title; |
|
| 363 | + $titletoshow = $langs->trans("Documents"); |
|
| 364 | + if (!empty($title)) $titletoshow = $title; |
|
| 365 | 365 | |
| 366 | 366 | // Show table |
| 367 | 367 | if ($genallowed) |
| 368 | 368 | { |
| 369 | - $modellist=array(); |
|
| 369 | + $modellist = array(); |
|
| 370 | 370 | |
| 371 | 371 | if ($modulepart == 'company') |
| 372 | 372 | { |
| 373 | - $showempty=1; |
|
| 374 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 373 | + $showempty = 1; |
|
| 374 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 375 | 375 | else |
| 376 | 376 | { |
| 377 | 377 | include_once DOL_DOCUMENT_ROOT.'/core/modules/societe/modules_societe.class.php'; |
| 378 | - $modellist=ModeleThirdPartyDoc::liste_modeles($this->db); |
|
| 378 | + $modellist = ModeleThirdPartyDoc::liste_modeles($this->db); |
|
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | 381 | else if ($modulepart == 'propal') |
| 382 | 382 | { |
| 383 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 383 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 384 | 384 | else |
| 385 | 385 | { |
| 386 | 386 | include_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; |
| 387 | - $modellist=ModelePDFPropales::liste_modeles($this->db); |
|
| 387 | + $modellist = ModelePDFPropales::liste_modeles($this->db); |
|
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | else if ($modulepart == 'supplier_proposal') |
| 391 | 391 | { |
| 392 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 392 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 393 | 393 | else |
| 394 | 394 | { |
| 395 | 395 | include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php'; |
| 396 | - $modellist=ModelePDFSupplierProposal::liste_modeles($this->db); |
|
| 396 | + $modellist = ModelePDFSupplierProposal::liste_modeles($this->db); |
|
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | else if ($modulepart == 'commande') |
| 400 | 400 | { |
| 401 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 401 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 402 | 402 | else |
| 403 | 403 | { |
| 404 | 404 | include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; |
| 405 | - $modellist=ModelePDFCommandes::liste_modeles($this->db); |
|
| 405 | + $modellist = ModelePDFCommandes::liste_modeles($this->db); |
|
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | 408 | elseif ($modulepart == 'expedition') |
| 409 | 409 | { |
| 410 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 410 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 411 | 411 | else |
| 412 | 412 | { |
| 413 | 413 | include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; |
| 414 | - $modellist=ModelePDFExpedition::liste_modeles($this->db); |
|
| 414 | + $modellist = ModelePDFExpedition::liste_modeles($this->db); |
|
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | 417 | elseif ($modulepart == 'reception') |
| 418 | 418 | { |
| 419 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 419 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 420 | 420 | else |
| 421 | 421 | { |
| 422 | 422 | include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php'; |
@@ -425,407 +425,407 @@ discard block |
||
| 425 | 425 | } |
| 426 | 426 | elseif ($modulepart == 'livraison') |
| 427 | 427 | { |
| 428 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 428 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 429 | 429 | else |
| 430 | 430 | { |
| 431 | 431 | include_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php'; |
| 432 | - $modellist=ModelePDFDeliveryOrder::liste_modeles($this->db); |
|
| 432 | + $modellist = ModelePDFDeliveryOrder::liste_modeles($this->db); |
|
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | else if ($modulepart == 'ficheinter') |
| 436 | 436 | { |
| 437 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 437 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 438 | 438 | else |
| 439 | 439 | { |
| 440 | 440 | include_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php'; |
| 441 | - $modellist=ModelePDFFicheinter::liste_modeles($this->db); |
|
| 441 | + $modellist = ModelePDFFicheinter::liste_modeles($this->db); |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | elseif ($modulepart == 'facture') |
| 445 | 445 | { |
| 446 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 446 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 447 | 447 | else |
| 448 | 448 | { |
| 449 | 449 | include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; |
| 450 | - $modellist=ModelePDFFactures::liste_modeles($this->db); |
|
| 450 | + $modellist = ModelePDFFactures::liste_modeles($this->db); |
|
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | 453 | elseif ($modulepart == 'contract') |
| 454 | 454 | { |
| 455 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 455 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 456 | 456 | else |
| 457 | 457 | { |
| 458 | 458 | include_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php'; |
| 459 | - $modellist=ModelePDFContract::liste_modeles($this->db); |
|
| 459 | + $modellist = ModelePDFContract::liste_modeles($this->db); |
|
| 460 | 460 | } |
| 461 | 461 | } |
| 462 | 462 | elseif ($modulepart == 'project') |
| 463 | 463 | { |
| 464 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 464 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 465 | 465 | else |
| 466 | 466 | { |
| 467 | 467 | include_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; |
| 468 | - $modellist=ModelePDFProjects::liste_modeles($this->db); |
|
| 468 | + $modellist = ModelePDFProjects::liste_modeles($this->db); |
|
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | elseif ($modulepart == 'project_task') |
| 472 | 472 | { |
| 473 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 473 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 474 | 474 | else |
| 475 | 475 | { |
| 476 | 476 | include_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; |
| 477 | - $modellist=ModelePDFTask::liste_modeles($this->db); |
|
| 477 | + $modellist = ModelePDFTask::liste_modeles($this->db); |
|
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | elseif ($modulepart == 'product') |
| 481 | 481 | { |
| 482 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 482 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 483 | 483 | else |
| 484 | 484 | { |
| 485 | 485 | include_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.class.php'; |
| 486 | - $modellist=ModelePDFProduct::liste_modeles($this->db); |
|
| 486 | + $modellist = ModelePDFProduct::liste_modeles($this->db); |
|
| 487 | 487 | } |
| 488 | 488 | } |
| 489 | 489 | elseif ($modulepart == 'product_batch') |
| 490 | 490 | { |
| 491 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 491 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 492 | 492 | else |
| 493 | 493 | { |
| 494 | 494 | include_once DOL_DOCUMENT_ROOT.'/core/modules/product_batch/modules_product_batch.class.php'; |
| 495 | - $modellist=ModelePDFProductBatch::liste_modeles($this->db); |
|
| 495 | + $modellist = ModelePDFProductBatch::liste_modeles($this->db); |
|
| 496 | 496 | } |
| 497 | 497 | } |
| 498 | 498 | elseif ($modulepart == 'stock') |
| 499 | 499 | { |
| 500 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 500 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 501 | 501 | else |
| 502 | 502 | { |
| 503 | 503 | include_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_stock.php'; |
| 504 | - $modellist=ModelePDFStock::liste_modeles($this->db); |
|
| 504 | + $modellist = ModelePDFStock::liste_modeles($this->db); |
|
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | 507 | elseif ($modulepart == 'movement') |
| 508 | 508 | { |
| 509 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 509 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 510 | 510 | else |
| 511 | 511 | { |
| 512 | 512 | include_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_movement.php'; |
| 513 | - $modellist=ModelePDFMovement::liste_modeles($this->db); |
|
| 513 | + $modellist = ModelePDFMovement::liste_modeles($this->db); |
|
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | 516 | elseif ($modulepart == 'export') |
| 517 | 517 | { |
| 518 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 518 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 519 | 519 | else |
| 520 | 520 | { |
| 521 | 521 | include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; |
| 522 | - $modellist=ModeleExports::liste_modeles($this->db); |
|
| 522 | + $modellist = ModeleExports::liste_modeles($this->db); |
|
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | else if ($modulepart == 'commande_fournisseur' || $modulepart == 'supplier_order') |
| 526 | 526 | { |
| 527 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 527 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 528 | 528 | else |
| 529 | 529 | { |
| 530 | 530 | include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php'; |
| 531 | - $modellist=ModelePDFSuppliersOrders::liste_modeles($this->db); |
|
| 531 | + $modellist = ModelePDFSuppliersOrders::liste_modeles($this->db); |
|
| 532 | 532 | } |
| 533 | 533 | } |
| 534 | 534 | else if ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice') |
| 535 | 535 | { |
| 536 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 536 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 537 | 537 | else |
| 538 | 538 | { |
| 539 | 539 | include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php'; |
| 540 | - $modellist=ModelePDFSuppliersInvoices::liste_modeles($this->db); |
|
| 540 | + $modellist = ModelePDFSuppliersInvoices::liste_modeles($this->db); |
|
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | 543 | else if ($modulepart == 'supplier_payment') |
| 544 | 544 | { |
| 545 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 545 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 546 | 546 | else |
| 547 | 547 | { |
| 548 | 548 | include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php'; |
| 549 | - $modellist=ModelePDFSuppliersPayments::liste_modeles($this->db); |
|
| 549 | + $modellist = ModelePDFSuppliersPayments::liste_modeles($this->db); |
|
| 550 | 550 | } |
| 551 | 551 | } |
| 552 | 552 | else if ($modulepart == 'remisecheque') |
| 553 | 553 | { |
| 554 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 554 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 555 | 555 | else |
| 556 | 556 | { |
| 557 | 557 | include_once DOL_DOCUMENT_ROOT.'/core/modules/cheque/modules_chequereceipts.php'; |
| 558 | - $modellist=ModeleChequeReceipts::liste_modeles($this->db); |
|
| 558 | + $modellist = ModeleChequeReceipts::liste_modeles($this->db); |
|
| 559 | 559 | } |
| 560 | 560 | } |
| 561 | 561 | elseif ($modulepart == 'donation') |
| 562 | 562 | { |
| 563 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 563 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 564 | 564 | else |
| 565 | 565 | { |
| 566 | 566 | include_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php'; |
| 567 | - $modellist=ModeleDon::liste_modeles($this->db); |
|
| 567 | + $modellist = ModeleDon::liste_modeles($this->db); |
|
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | elseif ($modulepart == 'member') |
| 571 | 571 | { |
| 572 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 572 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 573 | 573 | else |
| 574 | 574 | { |
| 575 | 575 | include_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_cards.php'; |
| 576 | - $modellist=ModelePDFCards::liste_modeles($this->db); |
|
| 576 | + $modellist = ModelePDFCards::liste_modeles($this->db); |
|
| 577 | 577 | } |
| 578 | 578 | } |
| 579 | 579 | elseif ($modulepart == 'agenda' || $modulepart == 'actions') |
| 580 | 580 | { |
| 581 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 581 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 582 | 582 | else |
| 583 | 583 | { |
| 584 | 584 | include_once DOL_DOCUMENT_ROOT.'/core/modules/action/modules_action.php'; |
| 585 | - $modellist=ModeleAction::liste_modeles($this->db); |
|
| 585 | + $modellist = ModeleAction::liste_modeles($this->db); |
|
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | 588 | else if ($modulepart == 'expensereport') |
| 589 | 589 | { |
| 590 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 590 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 591 | 591 | else |
| 592 | 592 | { |
| 593 | 593 | include_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; |
| 594 | - $modellist=ModeleExpenseReport::liste_modeles($this->db); |
|
| 594 | + $modellist = ModeleExpenseReport::liste_modeles($this->db); |
|
| 595 | 595 | } |
| 596 | 596 | } |
| 597 | 597 | else if ($modulepart == 'unpaid') |
| 598 | 598 | { |
| 599 | - $modellist=''; |
|
| 599 | + $modellist = ''; |
|
| 600 | 600 | } |
| 601 | 601 | elseif ($modulepart == 'user') |
| 602 | 602 | { |
| 603 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 603 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 604 | 604 | else |
| 605 | 605 | { |
| 606 | 606 | include_once DOL_DOCUMENT_ROOT.'/core/modules/user/modules_user.class.php'; |
| 607 | - $modellist=ModelePDFUser::liste_modeles($this->db); |
|
| 607 | + $modellist = ModelePDFUser::liste_modeles($this->db); |
|
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | 610 | elseif ($modulepart == 'usergroup') |
| 611 | 611 | { |
| 612 | - if (is_array($genallowed)) $modellist=$genallowed; |
|
| 612 | + if (is_array($genallowed)) $modellist = $genallowed; |
|
| 613 | 613 | else |
| 614 | 614 | { |
| 615 | 615 | include_once DOL_DOCUMENT_ROOT.'/core/modules/usergroup/modules_usergroup.class.php'; |
| 616 | - $modellist=ModelePDFUserGroup::liste_modeles($this->db); |
|
| 616 | + $modellist = ModelePDFUserGroup::liste_modeles($this->db); |
|
| 617 | 617 | } |
| 618 | 618 | } |
| 619 | 619 | else |
| 620 | 620 | { |
| 621 | 621 | // For normalized standard modules |
| 622 | - $file=dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0); |
|
| 622 | + $file = dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php', 0); |
|
| 623 | 623 | if (file_exists($file)) |
| 624 | 624 | { |
| 625 | - $res=include_once $file; |
|
| 625 | + $res = include_once $file; |
|
| 626 | 626 | } |
| 627 | 627 | // For normalized external modules |
| 628 | 628 | else |
| 629 | 629 | { |
| 630 | - $file=dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0); |
|
| 631 | - $res=include_once $file; |
|
| 630 | + $file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php', 0); |
|
| 631 | + $res = include_once $file; |
|
| 632 | 632 | } |
| 633 | - $class='ModelePDF'.ucfirst($modulepart); |
|
| 633 | + $class = 'ModelePDF'.ucfirst($modulepart); |
|
| 634 | 634 | if (class_exists($class)) |
| 635 | 635 | { |
| 636 | - $modellist=call_user_func($class.'::liste_modeles',$this->db); |
|
| 636 | + $modellist = call_user_func($class.'::liste_modeles', $this->db); |
|
| 637 | 637 | } |
| 638 | 638 | else |
| 639 | 639 | { |
| 640 | - dol_print_error($this->db,'Bad value for modulepart'); |
|
| 640 | + dol_print_error($this->db, 'Bad value for modulepart'); |
|
| 641 | 641 | return -1; |
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | // Set headershown to avoid to have table opened a second time later |
| 646 | - $headershown=1; |
|
| 646 | + $headershown = 1; |
|
| 647 | 647 | |
| 648 | - $buttonlabeltoshow=$buttonlabel; |
|
| 649 | - if (empty($buttonlabel)) $buttonlabel=$langs->trans('Generate'); |
|
| 648 | + $buttonlabeltoshow = $buttonlabel; |
|
| 649 | + if (empty($buttonlabel)) $buttonlabel = $langs->trans('Generate'); |
|
| 650 | 650 | |
| 651 | - if ($conf->browser->layout == 'phone') $urlsource.='#'.$forname.'_form'; // So we switch to form after a generation |
|
| 652 | - if (empty($noform)) $out.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" id="'.$forname.'_form" method="post">'; |
|
| 653 | - $out.= '<input type="hidden" name="action" value="builddoc">'; |
|
| 654 | - $out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 651 | + if ($conf->browser->layout == 'phone') $urlsource .= '#'.$forname.'_form'; // So we switch to form after a generation |
|
| 652 | + if (empty($noform)) $out .= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc').'" id="'.$forname.'_form" method="post">'; |
|
| 653 | + $out .= '<input type="hidden" name="action" value="builddoc">'; |
|
| 654 | + $out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 655 | 655 | |
| 656 | - $out.= load_fiche_titre($titletoshow, '', ''); |
|
| 657 | - $out.= '<div class="div-table-responsive-no-min">'; |
|
| 658 | - $out.= '<table class="liste formdoc noborder" summary="listofdocumentstable" width="100%">'; |
|
| 656 | + $out .= load_fiche_titre($titletoshow, '', ''); |
|
| 657 | + $out .= '<div class="div-table-responsive-no-min">'; |
|
| 658 | + $out .= '<table class="liste formdoc noborder" summary="listofdocumentstable" width="100%">'; |
|
| 659 | 659 | |
| 660 | - $out.= '<tr class="liste_titre">'; |
|
| 660 | + $out .= '<tr class="liste_titre">'; |
|
| 661 | 661 | |
| 662 | - $addcolumforpicto=($delallowed || $printer || $morepicto); |
|
| 663 | - $out.= '<th align="center" colspan="'.(3+($addcolumforpicto?1:0)).'" class="formdoc liste_titre maxwidthonsmartphone">'; |
|
| 662 | + $addcolumforpicto = ($delallowed || $printer || $morepicto); |
|
| 663 | + $out .= '<th align="center" colspan="'.(3 + ($addcolumforpicto ? 1 : 0)).'" class="formdoc liste_titre maxwidthonsmartphone">'; |
|
| 664 | 664 | |
| 665 | 665 | // Model |
| 666 | - if (! empty($modellist)) |
|
| 666 | + if (!empty($modellist)) |
|
| 667 | 667 | { |
| 668 | - $out.= '<span class="hideonsmartphone">'.$langs->trans('Model').' </span>'; |
|
| 668 | + $out .= '<span class="hideonsmartphone">'.$langs->trans('Model').' </span>'; |
|
| 669 | 669 | if (is_array($modellist) && count($modellist) == 1) // If there is only one element |
| 670 | 670 | { |
| 671 | - $arraykeys=array_keys($modellist); |
|
| 672 | - $modelselected=$arraykeys[0]; |
|
| 671 | + $arraykeys = array_keys($modellist); |
|
| 672 | + $modelselected = $arraykeys[0]; |
|
| 673 | 673 | } |
| 674 | - $out.= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); |
|
| 674 | + $out .= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); |
|
| 675 | 675 | if ($conf->use_javascript_ajax) |
| 676 | 676 | { |
| 677 | - $out.= ajax_combobox('model'); |
|
| 677 | + $out .= ajax_combobox('model'); |
|
| 678 | 678 | } |
| 679 | 679 | } |
| 680 | 680 | else |
| 681 | 681 | { |
| 682 | - $out.= '<div class="float">'.$langs->trans("Files").'</div>'; |
|
| 682 | + $out .= '<div class="float">'.$langs->trans("Files").'</div>'; |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | // Language code (if multilang) |
| 686 | - if (($allowgenifempty || (is_array($modellist) && count($modellist) > 0)) && $conf->global->MAIN_MULTILANGS && ! $forcenomultilang && (! empty($modellist) || $showempty)) |
|
| 686 | + if (($allowgenifempty || (is_array($modellist) && count($modellist) > 0)) && $conf->global->MAIN_MULTILANGS && !$forcenomultilang && (!empty($modellist) || $showempty)) |
|
| 687 | 687 | { |
| 688 | 688 | include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; |
| 689 | - $formadmin=new FormAdmin($this->db); |
|
| 690 | - $defaultlang=$codelang?$codelang:$langs->getDefaultLang(); |
|
| 691 | - $morecss='maxwidth150'; |
|
| 692 | - if ($conf->browser->layout == 'phone') $morecss='maxwidth100'; |
|
| 693 | - $out.= $formadmin->select_language($defaultlang, 'lang_id', 0, 0, 0, 0, 0, $morecss); |
|
| 689 | + $formadmin = new FormAdmin($this->db); |
|
| 690 | + $defaultlang = $codelang ? $codelang : $langs->getDefaultLang(); |
|
| 691 | + $morecss = 'maxwidth150'; |
|
| 692 | + if ($conf->browser->layout == 'phone') $morecss = 'maxwidth100'; |
|
| 693 | + $out .= $formadmin->select_language($defaultlang, 'lang_id', 0, 0, 0, 0, 0, $morecss); |
|
| 694 | 694 | } |
| 695 | 695 | else |
| 696 | 696 | { |
| 697 | - $out.= ' '; |
|
| 697 | + $out .= ' '; |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | // Button |
| 701 | 701 | $genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"'; |
| 702 | - $genbutton.= ' type="submit" value="'.$buttonlabel.'"'; |
|
| 703 | - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled'; |
|
| 704 | - $genbutton.= '>'; |
|
| 705 | - if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') |
|
| 702 | + $genbutton .= ' type="submit" value="'.$buttonlabel.'"'; |
|
| 703 | + if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) $genbutton .= ' disabled'; |
|
| 704 | + $genbutton .= '>'; |
|
| 705 | + if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') |
|
| 706 | 706 | { |
| 707 | 707 | $langs->load("errors"); |
| 708 | - $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); |
|
| 708 | + $genbutton .= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); |
|
| 709 | 709 | } |
| 710 | - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton=''; |
|
| 711 | - if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton=''; |
|
| 712 | - $out.= $genbutton; |
|
| 713 | - $out.= '</th>'; |
|
| 710 | + if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton = ''; |
|
| 711 | + if (empty($modellist) && !$showempty && $modulepart != 'unpaid') $genbutton = ''; |
|
| 712 | + $out .= $genbutton; |
|
| 713 | + $out .= '</th>'; |
|
| 714 | 714 | |
| 715 | 715 | if (!empty($hookmanager->hooks['formfile'])) |
| 716 | 716 | { |
| 717 | - foreach($hookmanager->hooks['formfile'] as $module) |
|
| 717 | + foreach ($hookmanager->hooks['formfile'] as $module) |
|
| 718 | 718 | { |
| 719 | 719 | if (method_exists($module, 'formBuilddocLineOptions')) $out .= '<th></th>'; |
| 720 | 720 | } |
| 721 | 721 | } |
| 722 | - $out.= '</tr>'; |
|
| 722 | + $out .= '</tr>'; |
|
| 723 | 723 | |
| 724 | 724 | // Execute hooks |
| 725 | - $parameters=array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''),'modulepart'=>$modulepart); |
|
| 725 | + $parameters = array('socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'modulepart'=>$modulepart); |
|
| 726 | 726 | if (is_object($hookmanager)) |
| 727 | 727 | { |
| 728 | - $reshook = $hookmanager->executeHooks('formBuilddocOptions',$parameters,$GLOBALS['object']); |
|
| 729 | - $out.= $hookmanager->resPrint; |
|
| 728 | + $reshook = $hookmanager->executeHooks('formBuilddocOptions', $parameters, $GLOBALS['object']); |
|
| 729 | + $out .= $hookmanager->resPrint; |
|
| 730 | 730 | } |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | // Get list of files |
| 734 | - if (! empty($filedir)) |
|
| 734 | + if (!empty($filedir)) |
|
| 735 | 735 | { |
| 736 | 736 | $link_list = array(); |
| 737 | 737 | if (is_object($object)) |
| 738 | 738 | { |
| 739 | - require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; |
|
| 739 | + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
|
| 740 | 740 | $link = new Link($this->db); |
| 741 | 741 | $sortfield = $sortorder = null; |
| 742 | 742 | $res = $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder); |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | - $out.= '<!-- html.formfile::showdocuments -->'."\n"; |
|
| 745 | + $out .= '<!-- html.formfile::showdocuments -->'."\n"; |
|
| 746 | 746 | |
| 747 | 747 | // Show title of array if not already shown |
| 748 | - if ((! empty($file_list) || ! empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) |
|
| 749 | - && ! $headershown) |
|
| 748 | + if ((!empty($file_list) || !empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) |
|
| 749 | + && !$headershown) |
|
| 750 | 750 | { |
| 751 | - $headershown=1; |
|
| 752 | - $out.= '<div class="titre">'.$titletoshow.'</div>'."\n"; |
|
| 753 | - $out.= '<div class="div-table-responsive-no-min">'; |
|
| 754 | - $out.= '<table class="noborder" summary="listofdocumentstable" id="'.$modulepart.'_table" width="100%">'."\n"; |
|
| 751 | + $headershown = 1; |
|
| 752 | + $out .= '<div class="titre">'.$titletoshow.'</div>'."\n"; |
|
| 753 | + $out .= '<div class="div-table-responsive-no-min">'; |
|
| 754 | + $out .= '<table class="noborder" summary="listofdocumentstable" id="'.$modulepart.'_table" width="100%">'."\n"; |
|
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | // Loop on each file found |
| 758 | 758 | if (is_array($file_list)) |
| 759 | 759 | { |
| 760 | - foreach($file_list as $file) |
|
| 760 | + foreach ($file_list as $file) |
|
| 761 | 761 | { |
| 762 | 762 | // Define relative path for download link (depends on module) |
| 763 | - $relativepath=$file["name"]; // Cas general |
|
| 764 | - if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture... |
|
| 765 | - if ($modulepart == 'export') $relativepath = $file["name"]; // Other case |
|
| 763 | + $relativepath = $file["name"]; // Cas general |
|
| 764 | + if ($modulesubdir) $relativepath = $modulesubdir."/".$file["name"]; // Cas propal, facture... |
|
| 765 | + if ($modulepart == 'export') $relativepath = $file["name"]; // Other case |
|
| 766 | 766 | |
| 767 | - $out.= '<tr class="oddeven">'; |
|
| 767 | + $out .= '<tr class="oddeven">'; |
|
| 768 | 768 | |
| 769 | 769 | $documenturl = DOL_URL_ROOT.'/document.php'; |
| 770 | - if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper |
|
| 770 | + if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl = $conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper |
|
| 771 | 771 | |
| 772 | 772 | // Show file name with link to download |
| 773 | - $out.= '<td class="minwidth200">'; |
|
| 774 | - $out.= '<a class="documentdownload paddingright" href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param?'&'.$param:'').'"'; |
|
| 775 | - $mime=dol_mimetype($relativepath,'',0); |
|
| 776 | - if (preg_match('/text/',$mime)) $out.= ' target="_blank"'; |
|
| 777 | - $out.= ' target="_blank">'; |
|
| 778 | - $out.= img_mime($file["name"],$langs->trans("File").': '.$file["name"]); |
|
| 779 | - $out.= dol_trunc($file["name"], 150); |
|
| 780 | - $out.= '</a>'."\n"; |
|
| 781 | - $out.= $this->showPreview($file,$modulepart,$relativepath,0,$param); |
|
| 782 | - $out.= '</td>'; |
|
| 773 | + $out .= '<td class="minwidth200">'; |
|
| 774 | + $out .= '<a class="documentdownload paddingright" href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param ? '&'.$param : '').'"'; |
|
| 775 | + $mime = dol_mimetype($relativepath, '', 0); |
|
| 776 | + if (preg_match('/text/', $mime)) $out .= ' target="_blank"'; |
|
| 777 | + $out .= ' target="_blank">'; |
|
| 778 | + $out .= img_mime($file["name"], $langs->trans("File").': '.$file["name"]); |
|
| 779 | + $out .= dol_trunc($file["name"], 150); |
|
| 780 | + $out .= '</a>'."\n"; |
|
| 781 | + $out .= $this->showPreview($file, $modulepart, $relativepath, 0, $param); |
|
| 782 | + $out .= '</td>'; |
|
| 783 | 783 | |
| 784 | 784 | // Show file size |
| 785 | - $size=(! empty($file['size'])?$file['size']:dol_filesize($filedir."/".$file["name"])); |
|
| 786 | - $out.= '<td align="right" class="nowrap">'.dol_print_size($size,1,1).'</td>'; |
|
| 785 | + $size = (!empty($file['size']) ? $file['size'] : dol_filesize($filedir."/".$file["name"])); |
|
| 786 | + $out .= '<td align="right" class="nowrap">'.dol_print_size($size, 1, 1).'</td>'; |
|
| 787 | 787 | |
| 788 | 788 | // Show file date |
| 789 | - $date=(! empty($file['date'])?$file['date']:dol_filemtime($filedir."/".$file["name"])); |
|
| 790 | - $out.= '<td align="right" class="nowrap">'.dol_print_date($date, 'dayhour', 'tzuser').'</td>'; |
|
| 789 | + $date = (!empty($file['date']) ? $file['date'] : dol_filemtime($filedir."/".$file["name"])); |
|
| 790 | + $out .= '<td align="right" class="nowrap">'.dol_print_date($date, 'dayhour', 'tzuser').'</td>'; |
|
| 791 | 791 | |
| 792 | 792 | if ($delallowed || $printer || $morepicto) |
| 793 | 793 | { |
| 794 | - $out.= '<td class="right nowraponall">'; |
|
| 794 | + $out .= '<td class="right nowraponall">'; |
|
| 795 | 795 | if ($delallowed) |
| 796 | 796 | { |
| 797 | 797 | $tmpurlsource = preg_replace('/#[a-zA-Z0-9_]*$/', '', $urlsource); |
| 798 | - $out.= '<a href="'.$tmpurlsource.(strpos($tmpurlsource,'?')?'&':'?').'action=remove_file&file='.urlencode($relativepath); |
|
| 799 | - $out.= ($param?'&'.$param:''); |
|
| 798 | + $out .= '<a href="'.$tmpurlsource.(strpos($tmpurlsource, '?') ? '&' : '?').'action=remove_file&file='.urlencode($relativepath); |
|
| 799 | + $out .= ($param ? '&'.$param : ''); |
|
| 800 | 800 | //$out.= '&modulepart='.$modulepart; // TODO obsolete ? |
| 801 | 801 | //$out.= '&urlsource='.urlencode($urlsource); // TODO obsolete ? |
| 802 | - $out.= '">'.img_picto($langs->trans("Delete"), 'delete').'</a>'; |
|
| 802 | + $out .= '">'.img_picto($langs->trans("Delete"), 'delete').'</a>'; |
|
| 803 | 803 | } |
| 804 | 804 | if ($printer) |
| 805 | 805 | { |
| 806 | 806 | //$out.= '<td align="right">'; |
| 807 | - $out.= '<a class="paddingleft" href="'.$urlsource.(strpos($urlsource,'?')?'&':'?').'action=print_file&printer='.$modulepart.'&file='.urlencode($relativepath); |
|
| 808 | - $out.= ($param?'&'.$param:''); |
|
| 809 | - $out.= '">'.img_picto($langs->trans("PrintFile", $relativepath),'printer.png').'</a>'; |
|
| 807 | + $out .= '<a class="paddingleft" href="'.$urlsource.(strpos($urlsource, '?') ? '&' : '?').'action=print_file&printer='.$modulepart.'&file='.urlencode($relativepath); |
|
| 808 | + $out .= ($param ? '&'.$param : ''); |
|
| 809 | + $out .= '">'.img_picto($langs->trans("PrintFile", $relativepath), 'printer.png').'</a>'; |
|
| 810 | 810 | } |
| 811 | 811 | if ($morepicto) |
| 812 | 812 | { |
| 813 | - $morepicto=preg_replace('/__FILENAMEURLENCODED__/',urlencode($relativepath),$morepicto); |
|
| 814 | - $out.=$morepicto; |
|
| 813 | + $morepicto = preg_replace('/__FILENAMEURLENCODED__/', urlencode($relativepath), $morepicto); |
|
| 814 | + $out .= $morepicto; |
|
| 815 | 815 | } |
| 816 | - $out.='</td>'; |
|
| 816 | + $out .= '</td>'; |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | if (is_object($hookmanager)) |
| 820 | 820 | { |
| 821 | - $parameters=array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''),'modulepart'=>$modulepart,'relativepath'=>$relativepath); |
|
| 822 | - $res = $hookmanager->executeHooks('formBuilddocLineOptions',$parameters,$file); |
|
| 821 | + $parameters = array('socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'modulepart'=>$modulepart, 'relativepath'=>$relativepath); |
|
| 822 | + $res = $hookmanager->executeHooks('formBuilddocLineOptions', $parameters, $file); |
|
| 823 | 823 | if (empty($res)) |
| 824 | 824 | { |
| 825 | - $out.= $hookmanager->resPrint; // Complete line |
|
| 826 | - $out.= '</tr>'; |
|
| 825 | + $out .= $hookmanager->resPrint; // Complete line |
|
| 826 | + $out .= '</tr>'; |
|
| 827 | 827 | } |
| 828 | - else $out = $hookmanager->resPrint; // Replace line |
|
| 828 | + else $out = $hookmanager->resPrint; // Replace line |
|
| 829 | 829 | } |
| 830 | 830 | } |
| 831 | 831 | |
@@ -834,42 +834,42 @@ discard block |
||
| 834 | 834 | // Loop on each link found |
| 835 | 835 | if (is_array($link_list)) |
| 836 | 836 | { |
| 837 | - $colspan=2; |
|
| 837 | + $colspan = 2; |
|
| 838 | 838 | |
| 839 | - foreach($link_list as $file) |
|
| 839 | + foreach ($link_list as $file) |
|
| 840 | 840 | { |
| 841 | - $out.='<tr class="oddeven">'; |
|
| 842 | - $out.='<td colspan="'.$colspan.'" class="maxwidhtonsmartphone">'; |
|
| 843 | - $out.='<a data-ajax="false" href="' . $link->url . '" target="_blank">'; |
|
| 844 | - $out.=$file->label; |
|
| 845 | - $out.='</a>'; |
|
| 846 | - $out.='</td>'; |
|
| 847 | - $out.='<td align="right">'; |
|
| 848 | - $out.=dol_print_date($file->datea,'dayhour'); |
|
| 849 | - $out.='</td>'; |
|
| 850 | - if ($delallowed || $printer || $morepicto) $out.='<td></td>'; |
|
| 851 | - $out.='</tr>'."\n"; |
|
| 841 | + $out .= '<tr class="oddeven">'; |
|
| 842 | + $out .= '<td colspan="'.$colspan.'" class="maxwidhtonsmartphone">'; |
|
| 843 | + $out .= '<a data-ajax="false" href="'.$link->url.'" target="_blank">'; |
|
| 844 | + $out .= $file->label; |
|
| 845 | + $out .= '</a>'; |
|
| 846 | + $out .= '</td>'; |
|
| 847 | + $out .= '<td align="right">'; |
|
| 848 | + $out .= dol_print_date($file->datea, 'dayhour'); |
|
| 849 | + $out .= '</td>'; |
|
| 850 | + if ($delallowed || $printer || $morepicto) $out .= '<td></td>'; |
|
| 851 | + $out .= '</tr>'."\n"; |
|
| 852 | 852 | } |
| 853 | 853 | $this->numoffiles++; |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | if (count($file_list) == 0 && count($link_list) == 0 && $headershown) |
| 857 | 857 | { |
| 858 | - $out.='<tr><td colspan="'.(3+($addcolumforpicto?1:0)).'" class="opacitymedium">'.$langs->trans("None").'</td></tr>'."\n"; |
|
| 858 | + $out .= '<tr><td colspan="'.(3 + ($addcolumforpicto ? 1 : 0)).'" class="opacitymedium">'.$langs->trans("None").'</td></tr>'."\n"; |
|
| 859 | 859 | } |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | if ($headershown) |
| 863 | 863 | { |
| 864 | 864 | // Affiche pied du tableau |
| 865 | - $out.= "</table>\n"; |
|
| 866 | - $out.= "</div>\n"; |
|
| 865 | + $out .= "</table>\n"; |
|
| 866 | + $out .= "</div>\n"; |
|
| 867 | 867 | if ($genallowed) |
| 868 | 868 | { |
| 869 | - if (empty($noform)) $out.= '</form>'."\n"; |
|
| 869 | + if (empty($noform)) $out .= '</form>'."\n"; |
|
| 870 | 870 | } |
| 871 | 871 | } |
| 872 | - $out.= '<!-- End show_document -->'."\n"; |
|
| 872 | + $out .= '<!-- End show_document -->'."\n"; |
|
| 873 | 873 | //return ($i?$i:$headershown); |
| 874 | 874 | return $out; |
| 875 | 875 | } |
@@ -885,98 +885,98 @@ discard block |
||
| 885 | 885 | * @param string $filter Filter filenames on this regex string (Example: '\.pdf$') |
| 886 | 886 | * @return string Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles |
| 887 | 887 | */ |
| 888 | - function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter='') |
|
| 888 | + function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '') |
|
| 889 | 889 | { |
| 890 | 890 | global $conf, $langs; |
| 891 | 891 | |
| 892 | 892 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 893 | 893 | |
| 894 | - $out=''; |
|
| 895 | - $this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array()); |
|
| 894 | + $out = ''; |
|
| 895 | + $this->infofiles = array('nboffiles'=>0, 'extensions'=>array(), 'files'=>array()); |
|
| 896 | 896 | |
| 897 | 897 | $entity = 1; // Without multicompany |
| 898 | 898 | |
| 899 | 899 | // Get object entity |
| 900 | - if (! empty($conf->multicompany->enabled)) |
|
| 900 | + if (!empty($conf->multicompany->enabled)) |
|
| 901 | 901 | { |
| 902 | - preg_match('/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir,'/').'$/', $filedir, $regs); |
|
| 903 | - $entity = ((! empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1); // If entity id not found in $filedir this is entity 1 by default |
|
| 902 | + preg_match('/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir, '/').'$/', $filedir, $regs); |
|
| 903 | + $entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1); // If entity id not found in $filedir this is entity 1 by default |
|
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files and get only generated files) |
| 907 | 907 | // @TODO Why not showing by default all files by just removing the '[^\-]+' at end of regex ? |
| 908 | - if (! empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) |
|
| 908 | + if (!empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) |
|
| 909 | 909 | { |
| 910 | - $filterforfilesearch = preg_quote(basename($modulesubdir),'/'); |
|
| 910 | + $filterforfilesearch = preg_quote(basename($modulesubdir), '/'); |
|
| 911 | 911 | } |
| 912 | 912 | else |
| 913 | 913 | { |
| 914 | - $filterforfilesearch = preg_quote(basename($modulesubdir),'/').'[^\-]+'; |
|
| 914 | + $filterforfilesearch = preg_quote(basename($modulesubdir), '/').'[^\-]+'; |
|
| 915 | 915 | } |
| 916 | - $file_list=dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // We also discard .meta and .png preview |
|
| 916 | + $file_list = dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // We also discard .meta and .png preview |
|
| 917 | 917 | |
| 918 | 918 | //var_dump($file_list); |
| 919 | 919 | // For ajax treatment |
| 920 | - $out.= '<!-- html.formfile::getDocumentsLink -->'."\n"; |
|
| 921 | - if (! empty($file_list)) |
|
| 920 | + $out .= '<!-- html.formfile::getDocumentsLink -->'."\n"; |
|
| 921 | + if (!empty($file_list)) |
|
| 922 | 922 | { |
| 923 | - $out='<dl class="dropdown inline-block"> |
|
| 923 | + $out = '<dl class="dropdown inline-block"> |
|
| 924 | 924 | <dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto('', 'listlight', '', 0, 0, 0, '', 'valignmiddle').'</a></dt> |
| 925 | 925 | <dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields" style="display: none;">'; |
| 926 | - $tmpout=''; |
|
| 926 | + $tmpout = ''; |
|
| 927 | 927 | |
| 928 | 928 | // Loop on each file found |
| 929 | - $found=0; |
|
| 930 | - foreach($file_list as $file) |
|
| 929 | + $found = 0; |
|
| 930 | + foreach ($file_list as $file) |
|
| 931 | 931 | { |
| 932 | 932 | $i++; |
| 933 | - if ($filter && ! preg_match('/'.$filter.'/i', $file["name"])) continue; // Discard this. It does not match provided filter. |
|
| 933 | + if ($filter && !preg_match('/'.$filter.'/i', $file["name"])) continue; // Discard this. It does not match provided filter. |
|
| 934 | 934 | |
| 935 | 935 | $found++; |
| 936 | 936 | // Define relative path for download link (depends on module) |
| 937 | - $relativepath=$file["name"]; // Cas general |
|
| 938 | - if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture... |
|
| 937 | + $relativepath = $file["name"]; // Cas general |
|
| 938 | + if ($modulesubdir) $relativepath = $modulesubdir."/".$file["name"]; // Cas propal, facture... |
|
| 939 | 939 | // Autre cas |
| 940 | - if ($modulepart == 'donation') { |
|
| 941 | - $relativepath = get_exdir($modulesubdir,2,0,0,null,'donation').$file["name"]; |
|
| 940 | + if ($modulepart == 'donation') { |
|
| 941 | + $relativepath = get_exdir($modulesubdir, 2, 0, 0, null, 'donation').$file["name"]; |
|
| 942 | 942 | } |
| 943 | - if ($modulepart == 'export') { |
|
| 943 | + if ($modulepart == 'export') { |
|
| 944 | 944 | $relativepath = $file["name"]; |
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | $this->infofiles['nboffiles']++; |
| 948 | - $this->infofiles['files'][]=$file['fullname']; |
|
| 949 | - $ext=pathinfo($file["name"], PATHINFO_EXTENSION); |
|
| 950 | - if (empty($this->infofiles[$ext])) $this->infofiles['extensions'][$ext]=1; |
|
| 948 | + $this->infofiles['files'][] = $file['fullname']; |
|
| 949 | + $ext = pathinfo($file["name"], PATHINFO_EXTENSION); |
|
| 950 | + if (empty($this->infofiles[$ext])) $this->infofiles['extensions'][$ext] = 1; |
|
| 951 | 951 | else $this->infofiles['extensions'][$ext]++; |
| 952 | 952 | |
| 953 | 953 | // Preview |
| 954 | - if (! empty($conf->use_javascript_ajax) && ($conf->browser->layout != 'phone')) |
|
| 954 | + if (!empty($conf->use_javascript_ajax) && ($conf->browser->layout != 'phone')) |
|
| 955 | 955 | { |
| 956 | 956 | $tmparray = getAdvancedPreviewUrl($modulepart, $relativepath, 1, '&entity='.$entity); |
| 957 | 957 | if ($tmparray && $tmparray['url']) |
| 958 | 958 | { |
| 959 | - $tmpout.= '<li><a href="'.$tmparray['url'].'"'.($tmparray['css']?' class="'.$tmparray['css'].'"':'').($tmparray['mime']?' mime="'.$tmparray['mime'].'"':'').($tmparray['target']?' target="'.$tmparray['target'].'"':'').'>'; |
|
| 959 | + $tmpout .= '<li><a href="'.$tmparray['url'].'"'.($tmparray['css'] ? ' class="'.$tmparray['css'].'"' : '').($tmparray['mime'] ? ' mime="'.$tmparray['mime'].'"' : '').($tmparray['target'] ? ' target="'.$tmparray['target'].'"' : '').'>'; |
|
| 960 | 960 | //$tmpout.= img_picto('','detail'); |
| 961 | - $tmpout.= '<i class="fa fa-search-plus paddingright" style="color: gray"></i>'; |
|
| 962 | - $tmpout.= $langs->trans("Preview").' '.$ext.'</a></li>'; |
|
| 961 | + $tmpout .= '<i class="fa fa-search-plus paddingright" style="color: gray"></i>'; |
|
| 962 | + $tmpout .= $langs->trans("Preview").' '.$ext.'</a></li>'; |
|
| 963 | 963 | } |
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | // Download |
| 967 | - $tmpout.= '<li class="nowrap"><a class="pictopreview nowrap" href="'.DOL_URL_ROOT . '/document.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($relativepath).'"'; |
|
| 968 | - $mime=dol_mimetype($relativepath,'',0); |
|
| 969 | - if (preg_match('/text/',$mime)) $tmpout.= ' target="_blank"'; |
|
| 970 | - $tmpout.= '>'; |
|
| 971 | - $tmpout.= img_mime($relativepath, $file["name"]); |
|
| 972 | - $tmpout.= $langs->trans("Download").' '.$ext; |
|
| 973 | - $tmpout.= '</a></li>'."\n"; |
|
| 974 | - } |
|
| 975 | - $out.=$tmpout; |
|
| 976 | - $out.='</ul></div></dd> |
|
| 967 | + $tmpout .= '<li class="nowrap"><a class="pictopreview nowrap" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($relativepath).'"'; |
|
| 968 | + $mime = dol_mimetype($relativepath, '', 0); |
|
| 969 | + if (preg_match('/text/', $mime)) $tmpout .= ' target="_blank"'; |
|
| 970 | + $tmpout .= '>'; |
|
| 971 | + $tmpout .= img_mime($relativepath, $file["name"]); |
|
| 972 | + $tmpout .= $langs->trans("Download").' '.$ext; |
|
| 973 | + $tmpout .= '</a></li>'."\n"; |
|
| 974 | + } |
|
| 975 | + $out .= $tmpout; |
|
| 976 | + $out .= '</ul></div></dd> |
|
| 977 | 977 | </dl>'; |
| 978 | 978 | |
| 979 | - if (! $found) $out=''; |
|
| 979 | + if (!$found) $out = ''; |
|
| 980 | 980 | } |
| 981 | 981 | else |
| 982 | 982 | { |
@@ -1018,7 +1018,7 @@ discard block |
||
| 1018 | 1018 | * @return int <0 if KO, nb of files shown if OK |
| 1019 | 1019 | * @see list_of_autoecmfiles |
| 1020 | 1020 | */ |
| 1021 | - function list_of_documents($filearray,$object,$modulepart,$param='',$forcedownload=0,$relativepath='',$permonobject=1,$useinecm=0,$textifempty='',$maxlength=0,$title='',$url='', $showrelpart=0, $permtoeditline=-1,$upload_dir='',$sortfield='',$sortorder='ASC', $disablemove=1, $addfilterfields=0) |
|
| 1021 | + function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0) |
|
| 1022 | 1022 | { |
| 1023 | 1023 | // phpcs:enable |
| 1024 | 1024 | global $user, $conf, $langs, $hookmanager; |
@@ -1026,37 +1026,37 @@ discard block |
||
| 1026 | 1026 | global $dolibarr_main_url_root; |
| 1027 | 1027 | global $form; |
| 1028 | 1028 | |
| 1029 | - $disablecrop=1; |
|
| 1030 | - if (in_array($modulepart, array('expensereport','holiday','member','project','product','produit','service','societe','tax','ticket','user'))) $disablecrop=0; |
|
| 1029 | + $disablecrop = 1; |
|
| 1030 | + if (in_array($modulepart, array('expensereport', 'holiday', 'member', 'project', 'product', 'produit', 'service', 'societe', 'tax', 'ticket', 'user'))) $disablecrop = 0; |
|
| 1031 | 1031 | |
| 1032 | 1032 | // Define relative path used to store the file |
| 1033 | 1033 | if (empty($relativepath)) |
| 1034 | 1034 | { |
| 1035 | - $relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/'; |
|
| 1036 | - if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id,2,0,0,$object,'invoice_supplier').$relativepath; // TODO Call using a defined value for $relativepath |
|
| 1037 | - if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.'; |
|
| 1035 | + $relativepath = (!empty($object->ref) ?dol_sanitizeFileName($object->ref) : '').'/'; |
|
| 1036 | + if ($object->element == 'invoice_supplier') $relativepath = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$relativepath; // TODO Call using a defined value for $relativepath |
|
| 1037 | + if ($object->element == 'project_task') $relativepath = 'Call_not_supported_._Call_function_using_a_defined_relative_path_.'; |
|
| 1038 | 1038 | } |
| 1039 | 1039 | // For backward compatiblity, we detect file stored into an old path |
| 1040 | - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos') |
|
| 1040 | + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos') |
|
| 1041 | 1041 | { |
| 1042 | - $relativepath=preg_replace('/^.*\/produit\//','',$filearray[0]['path']).'/'; |
|
| 1042 | + $relativepath = preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/'; |
|
| 1043 | 1043 | } |
| 1044 | 1044 | // Defined relative dir to DOL_DATA_ROOT |
| 1045 | 1045 | $relativedir = ''; |
| 1046 | 1046 | if ($upload_dir) |
| 1047 | 1047 | { |
| 1048 | - $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir); |
|
| 1049 | - $relativedir = preg_replace('/^[\\/]/','',$relativedir); |
|
| 1048 | + $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); |
|
| 1049 | + $relativedir = preg_replace('/^[\\/]/', '', $relativedir); |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | $hookmanager->initHooks(array('formfile')); |
| 1053 | - $parameters=array( |
|
| 1053 | + $parameters = array( |
|
| 1054 | 1054 | 'filearray' => $filearray, |
| 1055 | 1055 | 'modulepart'=> $modulepart, |
| 1056 | 1056 | 'param' => $param, |
| 1057 | 1057 | 'forcedownload' => $forcedownload, |
| 1058 | - 'relativepath' => $relativepath, // relative filename to module dir |
|
| 1059 | - 'relativedir' => $relativedir, // relative dirname to DOL_DATA_ROOT |
|
| 1058 | + 'relativepath' => $relativepath, // relative filename to module dir |
|
| 1059 | + 'relativedir' => $relativedir, // relative dirname to DOL_DATA_ROOT |
|
| 1060 | 1060 | 'permtodelete' => $permonobject, |
| 1061 | 1061 | 'useinecm' => $useinecm, |
| 1062 | 1062 | 'textifempty' => $textifempty, |
@@ -1064,7 +1064,7 @@ discard block |
||
| 1064 | 1064 | 'title' => $title, |
| 1065 | 1065 | 'url' => $url |
| 1066 | 1066 | ); |
| 1067 | - $reshook=$hookmanager->executeHooks('showFilesList', $parameters, $object); |
|
| 1067 | + $reshook = $hookmanager->executeHooks('showFilesList', $parameters, $object); |
|
| 1068 | 1068 | |
| 1069 | 1069 | if (isset($reshook) && $reshook != '') // null or '' for bypass |
| 1070 | 1070 | { |
@@ -1072,37 +1072,37 @@ discard block |
||
| 1072 | 1072 | } |
| 1073 | 1073 | else |
| 1074 | 1074 | { |
| 1075 | - if (! is_object($form)) |
|
| 1075 | + if (!is_object($form)) |
|
| 1076 | 1076 | { |
| 1077 | - include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; // The compoent may be included into ajax page that does not include the Form class |
|
| 1078 | - $form=new Form($this->db); |
|
| 1077 | + include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; // The compoent may be included into ajax page that does not include the Form class |
|
| 1078 | + $form = new Form($this->db); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | - if (! preg_match('/&id=/', $param) && isset($object->id)) $param.='&id='.$object->id; |
|
| 1082 | - $relativepathwihtoutslashend=preg_replace('/\/$/', '', $relativepath); |
|
| 1083 | - if ($relativepathwihtoutslashend) $param.= '&file='.urlencode($relativepathwihtoutslashend); |
|
| 1081 | + if (!preg_match('/&id=/', $param) && isset($object->id)) $param .= '&id='.$object->id; |
|
| 1082 | + $relativepathwihtoutslashend = preg_replace('/\/$/', '', $relativepath); |
|
| 1083 | + if ($relativepathwihtoutslashend) $param .= '&file='.urlencode($relativepathwihtoutslashend); |
|
| 1084 | 1084 | |
| 1085 | 1085 | if ($permtoeditline < 0) // Old behaviour for backward compatibility. New feature should call method with value 0 or 1 |
| 1086 | 1086 | { |
| 1087 | - $permtoeditline=0; |
|
| 1088 | - if (in_array($modulepart, array('product','produit','service'))) |
|
| 1087 | + $permtoeditline = 0; |
|
| 1088 | + if (in_array($modulepart, array('product', 'produit', 'service'))) |
|
| 1089 | 1089 | { |
| 1090 | - if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) $permtoeditline=1; |
|
| 1091 | - if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoeditline=1; |
|
| 1090 | + if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) $permtoeditline = 1; |
|
| 1091 | + if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoeditline = 1; |
|
| 1092 | 1092 | } |
| 1093 | 1093 | } |
| 1094 | 1094 | if (empty($conf->global->MAIN_UPLOAD_DOC)) |
| 1095 | 1095 | { |
| 1096 | - $permtoeditline=0; |
|
| 1097 | - $permonobject=0; |
|
| 1096 | + $permtoeditline = 0; |
|
| 1097 | + $permonobject = 0; |
|
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | 1100 | // Show list of existing files |
| 1101 | - if (empty($useinecm) && $title != 'none') print load_fiche_titre($title?$title:$langs->trans("AttachedFiles")); |
|
| 1102 | - if (empty($url)) $url=$_SERVER["PHP_SELF"]; |
|
| 1101 | + if (empty($useinecm) && $title != 'none') print load_fiche_titre($title ? $title : $langs->trans("AttachedFiles")); |
|
| 1102 | + if (empty($url)) $url = $_SERVER["PHP_SELF"]; |
|
| 1103 | 1103 | |
| 1104 | 1104 | print '<!-- html.formfile::list_of_documents -->'."\n"; |
| 1105 | - if (GETPOST('action','aZ09') == 'editfile' && $permtoeditline) |
|
| 1105 | + if (GETPOST('action', 'aZ09') == 'editfile' && $permtoeditline) |
|
| 1106 | 1106 | { |
| 1107 | 1107 | print '<form action="'.$_SERVER["PHP_SELF"].'?'.$param.'" method="POST">'; |
| 1108 | 1108 | print '<input type="hidden" name="action" value="renamefile">'; |
@@ -1111,30 +1111,30 @@ discard block |
||
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | 1113 | print '<div class="div-table-responsive-no-min">'; |
| 1114 | - print '<table width="100%" id="tablelines" class="'.($useinecm?'liste noborder':'liste').'">'."\n"; |
|
| 1114 | + print '<table width="100%" id="tablelines" class="'.($useinecm ? 'liste noborder' : 'liste').'">'."\n"; |
|
| 1115 | 1115 | |
| 1116 | - if (! empty($addfilterfields)) |
|
| 1116 | + if (!empty($addfilterfields)) |
|
| 1117 | 1117 | { |
| 1118 | 1118 | print '<tr class="liste_titre nodrag nodrop">'; |
| 1119 | - print '<td><input type="search_doc_ref" value="'.dol_escape_htmltag(GETPOST('search_doc_ref','alpha')).'"></td>'; |
|
| 1119 | + print '<td><input type="search_doc_ref" value="'.dol_escape_htmltag(GETPOST('search_doc_ref', 'alpha')).'"></td>'; |
|
| 1120 | 1120 | print '<td></td>'; |
| 1121 | 1121 | print '<td></td>'; |
| 1122 | 1122 | if (empty($useinecm)) print '<td></td>'; |
| 1123 | 1123 | print '<td></td>'; |
| 1124 | 1124 | print '<td></td>'; |
| 1125 | - if (! $disablemove) print '<td></td>'; |
|
| 1125 | + if (!$disablemove) print '<td></td>'; |
|
| 1126 | 1126 | print "</tr>\n"; |
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | print '<tr class="liste_titre nodrag nodrop">'; |
| 1130 | 1130 | //print $url.' sortfield='.$sortfield.' sortorder='.$sortorder; |
| 1131 | - print_liste_field_titre('Documents2',$url,"name","",$param,'align="left"',$sortfield,$sortorder); |
|
| 1132 | - print_liste_field_titre('Size',$url,"size","",$param,'align="right"',$sortfield,$sortorder); |
|
| 1133 | - print_liste_field_titre('Date',$url,"date","",$param,'align="center"',$sortfield,$sortorder); |
|
| 1134 | - if (empty($useinecm)) print_liste_field_titre('',$url,"","",$param,'align="center"'); // Preview |
|
| 1131 | + print_liste_field_titre('Documents2', $url, "name", "", $param, 'align="left"', $sortfield, $sortorder); |
|
| 1132 | + print_liste_field_titre('Size', $url, "size", "", $param, 'align="right"', $sortfield, $sortorder); |
|
| 1133 | + print_liste_field_titre('Date', $url, "date", "", $param, 'align="center"', $sortfield, $sortorder); |
|
| 1134 | + if (empty($useinecm)) print_liste_field_titre('', $url, "", "", $param, 'align="center"'); // Preview |
|
| 1135 | 1135 | print_liste_field_titre(''); |
| 1136 | 1136 | print_liste_field_titre(''); |
| 1137 | - if (! $disablemove) print_liste_field_titre(''); |
|
| 1137 | + if (!$disablemove) print_liste_field_titre(''); |
|
| 1138 | 1138 | print "</tr>\n"; |
| 1139 | 1139 | |
| 1140 | 1140 | // Get list of files stored into database for same relative directory |
@@ -1145,29 +1145,29 @@ discard block |
||
| 1145 | 1145 | //var_dump($sortfield.' - '.$sortorder); |
| 1146 | 1146 | if ($sortfield && $sortorder) // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name) |
| 1147 | 1147 | { |
| 1148 | - $filearray=dol_sort_array($filearray, $sortfield, $sortorder); |
|
| 1148 | + $filearray = dol_sort_array($filearray, $sortfield, $sortorder); |
|
| 1149 | 1149 | } |
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | - $nboffiles=count($filearray); |
|
| 1152 | + $nboffiles = count($filearray); |
|
| 1153 | 1153 | if ($nboffiles > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
| 1154 | 1154 | |
| 1155 | - $i=0; $nboflines = 0; $lastrowid=0; |
|
| 1156 | - foreach($filearray as $key => $file) // filearray must be only files here |
|
| 1155 | + $i = 0; $nboflines = 0; $lastrowid = 0; |
|
| 1156 | + foreach ($filearray as $key => $file) // filearray must be only files here |
|
| 1157 | 1157 | { |
| 1158 | 1158 | if ($file['name'] != '.' |
| 1159 | 1159 | && $file['name'] != '..' |
| 1160 | - && ! preg_match('/\.meta$/i',$file['name'])) |
|
| 1160 | + && !preg_match('/\.meta$/i', $file['name'])) |
|
| 1161 | 1161 | { |
| 1162 | 1162 | if ($filearray[$key]['rowid'] > 0) $lastrowid = $filearray[$key]['rowid']; |
| 1163 | - $filepath=$relativepath.$file['name']; |
|
| 1163 | + $filepath = $relativepath.$file['name']; |
|
| 1164 | 1164 | |
| 1165 | - $editline=0; |
|
| 1165 | + $editline = 0; |
|
| 1166 | 1166 | $nboflines++; |
| 1167 | 1167 | print '<!-- Line list_of_documents '.$key.' relativepath = '.$relativepath.' -->'."\n"; |
| 1168 | 1168 | // Do we have entry into database ? |
| 1169 | 1169 | print '<!-- In database: position='.$filearray[$key]['position'].' -->'."\n"; |
| 1170 | - print '<tr class="oddeven" id="row-'.($filearray[$key]['rowid']>0?$filearray[$key]['rowid']:'AFTER'.$lastrowid.'POS'.($i+1)).'">'; |
|
| 1170 | + print '<tr class="oddeven" id="row-'.($filearray[$key]['rowid'] > 0 ? $filearray[$key]['rowid'] : 'AFTER'.$lastrowid.'POS'.($i + 1)).'">'; |
|
| 1171 | 1171 | |
| 1172 | 1172 | // File name |
| 1173 | 1173 | print '<td class="minwith200">'; |
@@ -1176,20 +1176,20 @@ discard block |
||
| 1176 | 1176 | //print "XX".$file['name']; //$file['name'] must be utf8 |
| 1177 | 1177 | print '<a class="paddingright" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart; |
| 1178 | 1178 | if ($forcedownload) print '&attachment=1'; |
| 1179 | - if (! empty($object->entity)) print '&entity='.$object->entity; |
|
| 1179 | + if (!empty($object->entity)) print '&entity='.$object->entity; |
|
| 1180 | 1180 | print '&file='.urlencode($filepath); |
| 1181 | 1181 | print '">'; |
| 1182 | - print img_mime($file['name'], $file['name'].' ('.dol_print_size($file['size'],0,0).')', 'inline-block valignbottom paddingright'); |
|
| 1182 | + print img_mime($file['name'], $file['name'].' ('.dol_print_size($file['size'], 0, 0).')', 'inline-block valignbottom paddingright'); |
|
| 1183 | 1183 | if ($showrelpart == 1) print $relativepath; |
| 1184 | 1184 | //print dol_trunc($file['name'],$maxlength,'middle'); |
| 1185 | - if (GETPOST('action','aZ09') == 'editfile' && $file['name'] == basename(GETPOST('urlfile','alpha'))) |
|
| 1185 | + if (GETPOST('action', 'aZ09') == 'editfile' && $file['name'] == basename(GETPOST('urlfile', 'alpha'))) |
|
| 1186 | 1186 | { |
| 1187 | 1187 | print '</a>'; |
| 1188 | - $section_dir=dirname(GETPOST('urlfile','alpha')); |
|
| 1188 | + $section_dir = dirname(GETPOST('urlfile', 'alpha')); |
|
| 1189 | 1189 | print '<input type="hidden" name="section_dir" value="'.$section_dir.'">'; |
| 1190 | 1190 | print '<input type="hidden" name="renamefilefrom" value="'.dol_escape_htmltag($file['name']).'">'; |
| 1191 | 1191 | print '<input type="text" name="renamefileto" class="quatrevingtpercent" value="'.dol_escape_htmltag($file['name']).'">'; |
| 1192 | - $editline=1; |
|
| 1192 | + $editline = 1; |
|
| 1193 | 1193 | } |
| 1194 | 1194 | else |
| 1195 | 1195 | { |
@@ -1197,15 +1197,15 @@ discard block |
||
| 1197 | 1197 | print '</a>'; |
| 1198 | 1198 | } |
| 1199 | 1199 | // Preview link |
| 1200 | - if (! $editline) print $this->showPreview($file, $modulepart, $filepath); |
|
| 1200 | + if (!$editline) print $this->showPreview($file, $modulepart, $filepath); |
|
| 1201 | 1201 | // Public share link |
| 1202 | 1202 | //if (! $editline && ! empty($filearray[$key]['hashp'])) print pictowithlinktodirectdownload; |
| 1203 | 1203 | |
| 1204 | 1204 | print "</td>\n"; |
| 1205 | 1205 | |
| 1206 | 1206 | // Size |
| 1207 | - $sizetoshow = dol_print_size($file['size'],1,1); |
|
| 1208 | - $sizetoshowbytes = dol_print_size($file['size'],0,1); |
|
| 1207 | + $sizetoshow = dol_print_size($file['size'], 1, 1); |
|
| 1208 | + $sizetoshowbytes = dol_print_size($file['size'], 0, 1); |
|
| 1209 | 1209 | |
| 1210 | 1210 | print '<td align="right" width="80px">'; |
| 1211 | 1211 | if ($sizetoshow == $sizetoshowbytes) print $sizetoshow; |
@@ -1215,7 +1215,7 @@ discard block |
||
| 1215 | 1215 | print '</td>'; |
| 1216 | 1216 | |
| 1217 | 1217 | // Date |
| 1218 | - print '<td align="center" width="140px">'.dol_print_date($file['date'],"dayhour","tzuser").'</td>'; // 140px = width for date with PM format |
|
| 1218 | + print '<td align="center" width="140px">'.dol_print_date($file['date'], "dayhour", "tzuser").'</td>'; // 140px = width for date with PM format |
|
| 1219 | 1219 | |
| 1220 | 1220 | // Preview |
| 1221 | 1221 | if (empty($useinecm)) |
@@ -1224,18 +1224,18 @@ discard block |
||
| 1224 | 1224 | print '<td align="center">'; |
| 1225 | 1225 | if (image_format_supported($file['name']) > 0) |
| 1226 | 1226 | { |
| 1227 | - $minifile=getImageFileNameForSize($file['name'], '_mini'); // For new thumbs using same ext (in lower case howerver) than original |
|
| 1228 | - if (! dol_is_file($file['path'].'/'.$minifile)) $minifile=getImageFileNameForSize($file['name'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension |
|
| 1227 | + $minifile = getImageFileNameForSize($file['name'], '_mini'); // For new thumbs using same ext (in lower case howerver) than original |
|
| 1228 | + if (!dol_is_file($file['path'].'/'.$minifile)) $minifile = getImageFileNameForSize($file['name'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension |
|
| 1229 | 1229 | //print $file['path'].'/'.$minifile.'<br>'; |
| 1230 | 1230 | |
| 1231 | - $urlforhref=getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity)); |
|
| 1231 | + $urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); |
|
| 1232 | 1232 | if (empty($urlforhref)) { |
| 1233 | - $urlforhref=DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); |
|
| 1233 | + $urlforhref = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); |
|
| 1234 | 1234 | print '<a href="'.$urlforhref.'" class="aphoto" target="_blank">'; |
| 1235 | 1235 | } else { |
| 1236 | 1236 | print '<a href="'.$urlforhref['url'].'" class="'.$urlforhref['css'].'" target="'.$urlforhref['target'].'" mime="'.$urlforhref['mime'].'">'; |
| 1237 | 1237 | } |
| 1238 | - print '<img border="0" height="'.$maxheightmini.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.$minifile).'" title="">'; |
|
| 1238 | + print '<img border="0" height="'.$maxheightmini.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).'&file='.urlencode($relativepath.$minifile).'" title="">'; |
|
| 1239 | 1239 | print '</a>'; |
| 1240 | 1240 | } |
| 1241 | 1241 | else print ' '; |
@@ -1249,26 +1249,26 @@ discard block |
||
| 1249 | 1249 | if ($editline) |
| 1250 | 1250 | { |
| 1251 | 1251 | print $langs->trans("FileSharedViaALink").' '; |
| 1252 | - print '<input class="inline-block" type="checkbox" name="shareenabled"'.($file['share']?' checked="checked"':'').' /> '; |
|
| 1252 | + print '<input class="inline-block" type="checkbox" name="shareenabled"'.($file['share'] ? ' checked="checked"' : '').' /> '; |
|
| 1253 | 1253 | } |
| 1254 | 1254 | else |
| 1255 | 1255 | { |
| 1256 | 1256 | if ($file['share']) |
| 1257 | 1257 | { |
| 1258 | 1258 | // Define $urlwithroot |
| 1259 | - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
| 1260 | - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
| 1259 | + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); |
|
| 1260 | + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
| 1261 | 1261 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
| 1262 | 1262 | |
| 1263 | 1263 | //print '<span class="opacitymedium">'.$langs->trans("Hash").' : '.$file['share'].'</span>'; |
| 1264 | - $forcedownload=0; |
|
| 1265 | - $paramlink=''; |
|
| 1266 | - if (! empty($file['share'])) $paramlink.=($paramlink?'&':'').'hashp='.$file['share']; // Hash for public share |
|
| 1267 | - if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1'; |
|
| 1264 | + $forcedownload = 0; |
|
| 1265 | + $paramlink = ''; |
|
| 1266 | + if (!empty($file['share'])) $paramlink .= ($paramlink ? '&' : '').'hashp='.$file['share']; // Hash for public share |
|
| 1267 | + if ($forcedownload) $paramlink .= ($paramlink ? '&' : '').'attachment=1'; |
|
| 1268 | 1268 | |
| 1269 | - $fulllink=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:''); |
|
| 1269 | + $fulllink = $urlwithroot.'/document.php'.($paramlink ? '?'.$paramlink : ''); |
|
| 1270 | 1270 | |
| 1271 | - print img_picto($langs->trans("FileSharedViaALink"),'object_globe.png').' '; |
|
| 1271 | + print img_picto($langs->trans("FileSharedViaALink"), 'object_globe.png').' '; |
|
| 1272 | 1272 | print '<input type="text" class="quatrevingtpercent" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).'">'; |
| 1273 | 1273 | } |
| 1274 | 1274 | else |
@@ -1280,7 +1280,7 @@ discard block |
||
| 1280 | 1280 | print '</td>'; |
| 1281 | 1281 | |
| 1282 | 1282 | // Actions buttons |
| 1283 | - if (! $editline) |
|
| 1283 | + if (!$editline) |
|
| 1284 | 1284 | { |
| 1285 | 1285 | // Delete or view link |
| 1286 | 1286 | // ($param must start with &) |
@@ -1289,33 +1289,33 @@ discard block |
||
| 1289 | 1289 | { |
| 1290 | 1290 | print '<a href="'.DOL_URL_ROOT.'/ecm/file_card.php?urlfile='.urlencode($file['name']).$param.'" class="editfilelink" rel="'.urlencode($file['name']).'">'.img_edit('default', 0, 'class="paddingrightonly"').'</a>'; |
| 1291 | 1291 | } |
| 1292 | - if (! $useinecm || $useinecm == 2) |
|
| 1292 | + if (!$useinecm || $useinecm == 2) |
|
| 1293 | 1293 | { |
| 1294 | - $newmodulepart=$modulepart; |
|
| 1295 | - if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service'; |
|
| 1294 | + $newmodulepart = $modulepart; |
|
| 1295 | + if (in_array($modulepart, array('product', 'produit', 'service'))) $newmodulepart = 'produit|service'; |
|
| 1296 | 1296 | |
| 1297 | - if (! $disablecrop && image_format_supported($file['name']) > 0) |
|
| 1297 | + if (!$disablecrop && image_format_supported($file['name']) > 0) |
|
| 1298 | 1298 | { |
| 1299 | 1299 | if ($permtoeditline) |
| 1300 | 1300 | { |
| 1301 | 1301 | // Link to resize |
| 1302 | - print '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode($newmodulepart).'&id='.$object->id.'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])).'" title="'.dol_escape_htmltag($langs->trans("ResizeOrCrop")).'">'.img_picto($langs->trans("ResizeOrCrop"),'resize','class="paddingrightonly"').'</a>'; |
|
| 1302 | + print '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode($newmodulepart).'&id='.$object->id.'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])).'" title="'.dol_escape_htmltag($langs->trans("ResizeOrCrop")).'">'.img_picto($langs->trans("ResizeOrCrop"), 'resize', 'class="paddingrightonly"').'</a>'; |
|
| 1303 | 1303 | } |
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | 1306 | if ($permtoeditline) |
| 1307 | 1307 | { |
| 1308 | - $paramsectiondir=(in_array($modulepart, array('medias','ecm'))?'§ion_dir='.urlencode($relativepath):''); |
|
| 1309 | - print '<a href="'.(($useinecm == 1)?'#':($url.'?action=editfile&urlfile='.urlencode($filepath).$paramsectiondir.$param)).'" class="editfilelink" rel="'.$filepath.'">'.img_edit('default',0,'class="paddingrightonly"').'</a>'; |
|
| 1308 | + $paramsectiondir = (in_array($modulepart, array('medias', 'ecm')) ? '§ion_dir='.urlencode($relativepath) : ''); |
|
| 1309 | + print '<a href="'.(($useinecm == 1) ? '#' : ($url.'?action=editfile&urlfile='.urlencode($filepath).$paramsectiondir.$param)).'" class="editfilelink" rel="'.$filepath.'">'.img_edit('default', 0, 'class="paddingrightonly"').'</a>'; |
|
| 1310 | 1310 | } |
| 1311 | 1311 | } |
| 1312 | 1312 | if ($permonobject) |
| 1313 | 1313 | { |
| 1314 | - $useajax=1; |
|
| 1315 | - if (! empty($conf->dol_use_jmobile)) $useajax=0; |
|
| 1316 | - if (empty($conf->use_javascript_ajax)) $useajax=0; |
|
| 1317 | - if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; |
|
| 1318 | - print '<a href="'.(($useinecm && $useajax)?'#':($url.'?action=delete&urlfile='.urlencode($filepath).$param)).'" class="deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>'; |
|
| 1314 | + $useajax = 1; |
|
| 1315 | + if (!empty($conf->dol_use_jmobile)) $useajax = 0; |
|
| 1316 | + if (empty($conf->use_javascript_ajax)) $useajax = 0; |
|
| 1317 | + if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax = 0; |
|
| 1318 | + print '<a href="'.(($useinecm && $useajax) ? '#' : ($url.'?action=delete&urlfile='.urlencode($filepath).$param)).'" class="deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>'; |
|
| 1319 | 1319 | } |
| 1320 | 1320 | print "</td>"; |
| 1321 | 1321 | |
@@ -1324,15 +1324,15 @@ discard block |
||
| 1324 | 1324 | if ($nboffiles > 1 && $conf->browser->layout != 'phone') { |
| 1325 | 1325 | print '<td align="center" class="linecolmove tdlineupdown">'; |
| 1326 | 1326 | if ($i > 0) { |
| 1327 | - print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=up&rowid='.$line->id.'">'.img_up('default',0,'imgupforline').'</a>'; |
|
| 1327 | + print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=up&rowid='.$line->id.'">'.img_up('default', 0, 'imgupforline').'</a>'; |
|
| 1328 | 1328 | } |
| 1329 | - if ($i < $nboffiles-1) { |
|
| 1330 | - print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=down&rowid='.$line->id.'">'.img_down('default',0,'imgdownforline').'</a>'; |
|
| 1329 | + if ($i < $nboffiles - 1) { |
|
| 1330 | + print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=down&rowid='.$line->id.'">'.img_down('default', 0, 'imgdownforline').'</a>'; |
|
| 1331 | 1331 | } |
| 1332 | 1332 | print '</td>'; |
| 1333 | 1333 | } |
| 1334 | 1334 | else { |
| 1335 | - print '<td align="center"'.(($conf->browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown"':' class="linecolmove"').'>'; |
|
| 1335 | + print '<td align="center"'.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown"' : ' class="linecolmove"').'>'; |
|
| 1336 | 1336 | print '</td>'; |
| 1337 | 1337 | } |
| 1338 | 1338 | } |
@@ -1353,8 +1353,8 @@ discard block |
||
| 1353 | 1353 | } |
| 1354 | 1354 | if ($nboffiles == 0) |
| 1355 | 1355 | { |
| 1356 | - $colspan=(empty($useinecm)?'6':'6'); |
|
| 1357 | - if (empty($disablemove)) $colspan++; // 6 columns or 7 |
|
| 1356 | + $colspan = (empty($useinecm) ? '6' : '6'); |
|
| 1357 | + if (empty($disablemove)) $colspan++; // 6 columns or 7 |
|
| 1358 | 1358 | print '<tr class="oddeven"><td colspan="'.$colspan.'" class="opacitymedium">'; |
| 1359 | 1359 | if (empty($textifempty)) print $langs->trans("NoFileFound"); |
| 1360 | 1360 | else print $textifempty; |
@@ -1364,15 +1364,15 @@ discard block |
||
| 1364 | 1364 | print '</div>'; |
| 1365 | 1365 | |
| 1366 | 1366 | if ($nboflines > 1 && is_object($object)) { |
| 1367 | - if (! empty($conf->use_javascript_ajax) && $permtoeditline) { |
|
| 1367 | + if (!empty($conf->use_javascript_ajax) && $permtoeditline) { |
|
| 1368 | 1368 | $table_element_line = 'ecm_files'; |
| 1369 | - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; |
|
| 1369 | + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; |
|
| 1370 | 1370 | } |
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | 1373 | print ajax_autoselect('downloadlink'); |
| 1374 | 1374 | |
| 1375 | - if (GETPOST('action','aZ09') == 'editfile' && $permtoeditline) |
|
| 1375 | + if (GETPOST('action', 'aZ09') == 'editfile' && $permtoeditline) |
|
| 1376 | 1376 | { |
| 1377 | 1377 | print '</form>'; |
| 1378 | 1378 | } |
@@ -1401,7 +1401,7 @@ discard block |
||
| 1401 | 1401 | * @return int <0 if KO, nb of files shown if OK |
| 1402 | 1402 | * @see list_of_documents |
| 1403 | 1403 | */ |
| 1404 | - function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload=0, $relativepath='', $permtodelete=1, $useinecm=0, $textifempty='', $maxlength=0, $url='', $addfilterfields=0) |
|
| 1404 | + function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permtodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '', $addfilterfields = 0) |
|
| 1405 | 1405 | { |
| 1406 | 1406 | // phpcs:enable |
| 1407 | 1407 | global $user, $conf, $langs, $form; |
@@ -1412,9 +1412,9 @@ discard block |
||
| 1412 | 1412 | |
| 1413 | 1413 | // Show list of documents |
| 1414 | 1414 | if (empty($useinecm)) print load_fiche_titre($langs->trans("AttachedFiles")); |
| 1415 | - if (empty($url)) $url=$_SERVER["PHP_SELF"]; |
|
| 1415 | + if (empty($url)) $url = $_SERVER["PHP_SELF"]; |
|
| 1416 | 1416 | |
| 1417 | - if (! empty($addfilterfields)) |
|
| 1417 | + if (!empty($addfilterfields)) |
|
| 1418 | 1418 | { |
| 1419 | 1419 | print '<form action="'.$_SERVER['PHP_SELF'].'">'; |
| 1420 | 1420 | print '<input type="hidden" name="module" value="'.$modulepart.'">'; |
@@ -1423,7 +1423,7 @@ discard block |
||
| 1423 | 1423 | print '<div class="div-table-responsive-no-min">'; |
| 1424 | 1424 | print '<table width="100%" class="noborder">'."\n"; |
| 1425 | 1425 | |
| 1426 | - if (! empty($addfilterfields)) |
|
| 1426 | + if (!empty($addfilterfields)) |
|
| 1427 | 1427 | { |
| 1428 | 1428 | print '<tr class="liste_titre nodrag nodrop">'; |
| 1429 | 1429 | print '<td></td>'; |
@@ -1432,135 +1432,135 @@ discard block |
||
| 1432 | 1432 | print '<td></td>'; |
| 1433 | 1433 | // Action column |
| 1434 | 1434 | print '<td class="liste_titre" align="middle">'; |
| 1435 | - $searchpicto=$form->showFilterButtons(); |
|
| 1435 | + $searchpicto = $form->showFilterButtons(); |
|
| 1436 | 1436 | print $searchpicto; |
| 1437 | 1437 | print '</td>'; |
| 1438 | 1438 | print "</tr>\n"; |
| 1439 | 1439 | } |
| 1440 | 1440 | |
| 1441 | 1441 | print '<tr class="liste_titre">'; |
| 1442 | - $sortref="fullname"; |
|
| 1443 | - if ($modulepart == 'invoice_supplier') $sortref='level1name'; |
|
| 1444 | - print_liste_field_titre("Ref",$url,$sortref,"",$param,'align="left"',$sortfield,$sortorder); |
|
| 1445 | - print_liste_field_titre("Documents2",$url,"name","",$param,'align="left"',$sortfield,$sortorder); |
|
| 1446 | - print_liste_field_titre("Size",$url,"size","",$param,'align="right"',$sortfield,$sortorder); |
|
| 1447 | - print_liste_field_titre("Date",$url,"date","",$param,'align="center"',$sortfield,$sortorder); |
|
| 1448 | - print_liste_field_titre('','',''); |
|
| 1442 | + $sortref = "fullname"; |
|
| 1443 | + if ($modulepart == 'invoice_supplier') $sortref = 'level1name'; |
|
| 1444 | + print_liste_field_titre("Ref", $url, $sortref, "", $param, 'align="left"', $sortfield, $sortorder); |
|
| 1445 | + print_liste_field_titre("Documents2", $url, "name", "", $param, 'align="left"', $sortfield, $sortorder); |
|
| 1446 | + print_liste_field_titre("Size", $url, "size", "", $param, 'align="right"', $sortfield, $sortorder); |
|
| 1447 | + print_liste_field_titre("Date", $url, "date", "", $param, 'align="center"', $sortfield, $sortorder); |
|
| 1448 | + print_liste_field_titre('', '', ''); |
|
| 1449 | 1449 | print '</tr>'."\n"; |
| 1450 | 1450 | |
| 1451 | 1451 | // To show ref or specific information according to view to show (defined by $module) |
| 1452 | 1452 | if ($modulepart == 'company') |
| 1453 | 1453 | { |
| 1454 | 1454 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
| 1455 | - $object_instance=new Societe($this->db); |
|
| 1455 | + $object_instance = new Societe($this->db); |
|
| 1456 | 1456 | } |
| 1457 | 1457 | else if ($modulepart == 'invoice') |
| 1458 | 1458 | { |
| 1459 | 1459 | include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
| 1460 | - $object_instance=new Facture($this->db); |
|
| 1460 | + $object_instance = new Facture($this->db); |
|
| 1461 | 1461 | } |
| 1462 | 1462 | else if ($modulepart == 'invoice_supplier') |
| 1463 | 1463 | { |
| 1464 | 1464 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
| 1465 | - $object_instance=new FactureFournisseur($this->db); |
|
| 1465 | + $object_instance = new FactureFournisseur($this->db); |
|
| 1466 | 1466 | } |
| 1467 | 1467 | else if ($modulepart == 'propal') |
| 1468 | 1468 | { |
| 1469 | 1469 | include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
| 1470 | - $object_instance=new Propal($this->db); |
|
| 1470 | + $object_instance = new Propal($this->db); |
|
| 1471 | 1471 | } |
| 1472 | 1472 | else if ($modulepart == 'supplier_proposal') |
| 1473 | 1473 | { |
| 1474 | 1474 | include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; |
| 1475 | - $object_instance=new SupplierProposal($this->db); |
|
| 1475 | + $object_instance = new SupplierProposal($this->db); |
|
| 1476 | 1476 | } |
| 1477 | 1477 | else if ($modulepart == 'order') |
| 1478 | 1478 | { |
| 1479 | 1479 | include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
| 1480 | - $object_instance=new Commande($this->db); |
|
| 1480 | + $object_instance = new Commande($this->db); |
|
| 1481 | 1481 | } |
| 1482 | 1482 | else if ($modulepart == 'order_supplier') |
| 1483 | 1483 | { |
| 1484 | 1484 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
| 1485 | - $object_instance=new CommandeFournisseur($this->db); |
|
| 1485 | + $object_instance = new CommandeFournisseur($this->db); |
|
| 1486 | 1486 | } |
| 1487 | 1487 | else if ($modulepart == 'contract') |
| 1488 | 1488 | { |
| 1489 | 1489 | include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
| 1490 | - $object_instance=new Contrat($this->db); |
|
| 1490 | + $object_instance = new Contrat($this->db); |
|
| 1491 | 1491 | } |
| 1492 | 1492 | else if ($modulepart == 'product') |
| 1493 | 1493 | { |
| 1494 | 1494 | include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
| 1495 | - $object_instance=new Product($this->db); |
|
| 1495 | + $object_instance = new Product($this->db); |
|
| 1496 | 1496 | } |
| 1497 | 1497 | else if ($modulepart == 'tax') |
| 1498 | 1498 | { |
| 1499 | 1499 | include_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; |
| 1500 | - $object_instance=new ChargeSociales($this->db); |
|
| 1500 | + $object_instance = new ChargeSociales($this->db); |
|
| 1501 | 1501 | } |
| 1502 | 1502 | else if ($modulepart == 'project') |
| 1503 | 1503 | { |
| 1504 | 1504 | include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 1505 | - $object_instance=new Project($this->db); |
|
| 1505 | + $object_instance = new Project($this->db); |
|
| 1506 | 1506 | } |
| 1507 | 1507 | else if ($modulepart == 'fichinter') |
| 1508 | 1508 | { |
| 1509 | 1509 | include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; |
| 1510 | - $object_instance=new Fichinter($this->db); |
|
| 1510 | + $object_instance = new Fichinter($this->db); |
|
| 1511 | 1511 | } |
| 1512 | 1512 | else if ($modulepart == 'user') |
| 1513 | 1513 | { |
| 1514 | 1514 | include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; |
| 1515 | - $object_instance=new User($this->db); |
|
| 1515 | + $object_instance = new User($this->db); |
|
| 1516 | 1516 | } |
| 1517 | 1517 | else if ($modulepart == 'expensereport') |
| 1518 | 1518 | { |
| 1519 | 1519 | include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; |
| 1520 | - $object_instance=new ExpenseReport($this->db); |
|
| 1520 | + $object_instance = new ExpenseReport($this->db); |
|
| 1521 | 1521 | } |
| 1522 | 1522 | else if ($modulepart == 'holiday') |
| 1523 | 1523 | { |
| 1524 | 1524 | include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; |
| 1525 | - $object_instance=new Holiday($this->db); |
|
| 1525 | + $object_instance = new Holiday($this->db); |
|
| 1526 | 1526 | } |
| 1527 | 1527 | |
| 1528 | - foreach($filearray as $key => $file) |
|
| 1528 | + foreach ($filearray as $key => $file) |
|
| 1529 | 1529 | { |
| 1530 | 1530 | if (!is_dir($file['name']) |
| 1531 | 1531 | && $file['name'] != '.' |
| 1532 | 1532 | && $file['name'] != '..' |
| 1533 | 1533 | && $file['name'] != 'CVS' |
| 1534 | - && ! preg_match('/\.meta$/i',$file['name'])) |
|
| 1534 | + && !preg_match('/\.meta$/i', $file['name'])) |
|
| 1535 | 1535 | { |
| 1536 | 1536 | // Define relative path used to store the file |
| 1537 | - $relativefile=preg_replace('/'.preg_quote($upload_dir.'/','/').'/','',$file['fullname']); |
|
| 1537 | + $relativefile = preg_replace('/'.preg_quote($upload_dir.'/', '/').'/', '', $file['fullname']); |
|
| 1538 | 1538 | |
| 1539 | 1539 | //var_dump($file); |
| 1540 | - $id=0; $ref=''; $label=''; |
|
| 1540 | + $id = 0; $ref = ''; $label = ''; |
|
| 1541 | 1541 | |
| 1542 | 1542 | // To show ref or specific information according to view to show (defined by $module) |
| 1543 | - if ($modulepart == 'company') { preg_match('/(\d+)\/[^\/]+$/',$relativefile,$reg); $id=(isset($reg[1])?$reg[1]:''); } |
|
| 1544 | - if ($modulepart == 'invoice') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); } |
|
| 1545 | - if ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); if (is_numeric($ref)) { $id=$ref; $ref=''; } } // $ref may be also id with old supplier invoices |
|
| 1546 | - if ($modulepart == 'propal') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); } |
|
| 1547 | - if ($modulepart == 'supplier_proposal') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); } |
|
| 1548 | - if ($modulepart == 'order') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); } |
|
| 1549 | - if ($modulepart == 'order_supplier') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); } |
|
| 1550 | - if ($modulepart == 'contract') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); } |
|
| 1551 | - if ($modulepart == 'product') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); } |
|
| 1552 | - if ($modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/',$relativefile,$reg); $id=(isset($reg[1])?$reg[1]:''); } |
|
| 1553 | - if ($modulepart == 'project') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:'');} |
|
| 1554 | - if ($modulepart == 'fichinter') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:'');} |
|
| 1555 | - if ($modulepart == 'user') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $id=(isset($reg[1])?$reg[1]:'');} |
|
| 1556 | - if ($modulepart == 'expensereport') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:'');} |
|
| 1557 | - if ($modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $id=(isset($reg[1])?$reg[1]:'');} |
|
| 1558 | - |
|
| 1559 | - if (! $id && ! $ref) continue; |
|
| 1560 | - $found=0; |
|
| 1561 | - if (! empty($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) |
|
| 1543 | + if ($modulepart == 'company') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1544 | + if ($modulepart == 'invoice') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1545 | + if ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); if (is_numeric($ref)) { $id = $ref; $ref = ''; } } // $ref may be also id with old supplier invoices |
|
| 1546 | + if ($modulepart == 'propal') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1547 | + if ($modulepart == 'supplier_proposal') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1548 | + if ($modulepart == 'order') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1549 | + if ($modulepart == 'order_supplier') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1550 | + if ($modulepart == 'contract') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1551 | + if ($modulepart == 'product') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1552 | + if ($modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1553 | + if ($modulepart == 'project') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1554 | + if ($modulepart == 'fichinter') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1555 | + if ($modulepart == 'user') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1556 | + if ($modulepart == 'expensereport') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1557 | + if ($modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] : ''); } |
|
| 1558 | + |
|
| 1559 | + if (!$id && !$ref) continue; |
|
| 1560 | + $found = 0; |
|
| 1561 | + if (!empty($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) |
|
| 1562 | 1562 | { |
| 1563 | - $found=1; |
|
| 1563 | + $found = 1; |
|
| 1564 | 1564 | } |
| 1565 | 1565 | else |
| 1566 | 1566 | { |
@@ -1579,24 +1579,24 @@ discard block |
||
| 1579 | 1579 | } |
| 1580 | 1580 | |
| 1581 | 1581 | if ($result > 0) { // Save object into a cache |
| 1582 | - $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = clone $object_instance; |
|
| 1582 | + $found = 1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = clone $object_instance; |
|
| 1583 | 1583 | } |
| 1584 | - if ($result == 0) { $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]='notfound'; unset($filearray[$key]); } |
|
| 1584 | + if ($result == 0) { $found = 1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = 'notfound'; unset($filearray[$key]); } |
|
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | - if (! $found > 0 || ! is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) continue; // We do not show orphelins files |
|
| 1587 | + if (!$found > 0 || !is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) continue; // We do not show orphelins files |
|
| 1588 | 1588 | |
| 1589 | 1589 | print '<!-- Line list_of_autoecmfiles '.$key.' -->'."\n"; |
| 1590 | 1590 | print '<tr class="oddeven">'; |
| 1591 | 1591 | print '<td>'; |
| 1592 | - if ($found > 0 && is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) print $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]->getNomUrl(1,'document'); |
|
| 1593 | - else print $langs->trans("ObjectDeleted",($id?$id:$ref)); |
|
| 1592 | + if ($found > 0 && is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) print $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]->getNomUrl(1, 'document'); |
|
| 1593 | + else print $langs->trans("ObjectDeleted", ($id ? $id : $ref)); |
|
| 1594 | 1594 | |
| 1595 | 1595 | //$modulesubdir=dol_sanitizeFileName($ref); |
| 1596 | - $modulesubdir=dirname($relativefile); |
|
| 1596 | + $modulesubdir = dirname($relativefile); |
|
| 1597 | 1597 | |
| 1598 | 1598 | //$filedir=$conf->$modulepart->dir_output . '/' . dol_sanitizeFileName($obj->ref); |
| 1599 | - $filedir=$file['path']; |
|
| 1599 | + $filedir = $file['path']; |
|
| 1600 | 1600 | //$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; |
| 1601 | 1601 | //print $formfile->getDocumentsLink($modulepart, $filename, $filedir); |
| 1602 | 1602 | |
@@ -1608,16 +1608,16 @@ discard block |
||
| 1608 | 1608 | print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart; |
| 1609 | 1609 | if ($forcedownload) print '&attachment=1'; |
| 1610 | 1610 | print '&file='.urlencode($relativefile).'">'; |
| 1611 | - print img_mime($file['name'],$file['name'].' ('.dol_print_size($file['size'],0,0).')'); |
|
| 1612 | - print dol_trunc($file['name'],$maxlength,'middle'); |
|
| 1611 | + print img_mime($file['name'], $file['name'].' ('.dol_print_size($file['size'], 0, 0).')'); |
|
| 1612 | + print dol_trunc($file['name'], $maxlength, 'middle'); |
|
| 1613 | 1613 | print '</a>'; |
| 1614 | 1614 | |
| 1615 | 1615 | //print $this->getDocumentsLink($modulepart, $modulesubdir, $filedir, '^'.preg_quote($file['name'],'/').'$'); |
| 1616 | 1616 | print $this->showPreview($file, $modulepart, $file['relativename']); |
| 1617 | 1617 | |
| 1618 | 1618 | print "</td>\n"; |
| 1619 | - print '<td align="right">'.dol_print_size($file['size'],1,1).'</td>'; |
|
| 1620 | - print '<td align="center">'.dol_print_date($file['date'],"dayhour").'</td>'; |
|
| 1619 | + print '<td align="right">'.dol_print_size($file['size'], 1, 1).'</td>'; |
|
| 1620 | + print '<td align="center">'.dol_print_date($file['date'], "dayhour").'</td>'; |
|
| 1621 | 1621 | print '<td align="right">'; |
| 1622 | 1622 | //if (! empty($useinecm)) print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart; |
| 1623 | 1623 | //if ($forcedownload) print '&attachment=1'; |
@@ -1639,7 +1639,7 @@ discard block |
||
| 1639 | 1639 | print "</table>"; |
| 1640 | 1640 | print '</div>'; |
| 1641 | 1641 | |
| 1642 | - if (! empty($addfilterfields)) print '</form>'; |
|
| 1642 | + if (!empty($addfilterfields)) print '</form>'; |
|
| 1643 | 1643 | // Fin de zone |
| 1644 | 1644 | } |
| 1645 | 1645 | |
@@ -1665,7 +1665,7 @@ discard block |
||
| 1665 | 1665 | $mul_upload_max_filesize = ($mul_upload_max_filesize == 'M' ? 1048576 : ($mul_upload_max_filesize == 'K' ? 1024 : ($mul_upload_max_filesize == 'G' ? 1073741824 : 1))); |
| 1666 | 1666 | $upload_max_filesize = $mul_upload_max_filesize * (int) $upload_max_filesize; |
| 1667 | 1667 | // Max file size |
| 1668 | - $max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize); |
|
| 1668 | + $max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize); |
|
| 1669 | 1669 | |
| 1670 | 1670 | // Include main |
| 1671 | 1671 | include DOL_DOCUMENT_ROOT.'/core/tpl/ajax/fileupload_main.tpl.php'; |
@@ -1684,14 +1684,14 @@ discard block |
||
| 1684 | 1684 | * @param string $param More param to add into URL |
| 1685 | 1685 | * @return int Number of links |
| 1686 | 1686 | */ |
| 1687 | - public function listOfLinks($object, $permtodelete=1, $action=null, $selected=null, $param='') |
|
| 1687 | + public function listOfLinks($object, $permtodelete = 1, $action = null, $selected = null, $param = '') |
|
| 1688 | 1688 | { |
| 1689 | 1689 | global $user, $conf, $langs, $user; |
| 1690 | 1690 | global $sortfield, $sortorder; |
| 1691 | 1691 | |
| 1692 | 1692 | $langs->load("link"); |
| 1693 | 1693 | |
| 1694 | - require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; |
|
| 1694 | + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
|
| 1695 | 1695 | $link = new Link($this->db); |
| 1696 | 1696 | $links = array(); |
| 1697 | 1697 | if ($sortfield == "name") { |
@@ -1702,12 +1702,12 @@ discard block |
||
| 1702 | 1702 | $sortfield = null; |
| 1703 | 1703 | } |
| 1704 | 1704 | $res = $link->fetchAll($links, $object->element, $object->id, $sortfield, $sortorder); |
| 1705 | - $param .= (isset($object->id)?'&id=' . $object->id : ''); |
|
| 1705 | + $param .= (isset($object->id) ? '&id='.$object->id : ''); |
|
| 1706 | 1706 | |
| 1707 | 1707 | // Show list of associated links |
| 1708 | 1708 | print load_fiche_titre($langs->trans("LinkedFiles")); |
| 1709 | 1709 | |
| 1710 | - print '<form action="' . $_SERVER['PHP_SELF'] . ($param?'?'.$param:'') . '" method="POST">'; |
|
| 1710 | + print '<form action="'.$_SERVER['PHP_SELF'].($param ? '?'.$param : '').'" method="POST">'; |
|
| 1711 | 1711 | |
| 1712 | 1712 | print '<table width="100%" class="liste">'; |
| 1713 | 1713 | print '<tr class="liste_titre">'; |
@@ -1747,7 +1747,7 @@ discard block |
||
| 1747 | 1747 | $param, |
| 1748 | 1748 | 'align="center"' |
| 1749 | 1749 | ); |
| 1750 | - print_liste_field_titre('','',''); |
|
| 1750 | + print_liste_field_titre('', '', ''); |
|
| 1751 | 1751 | print '</tr>'; |
| 1752 | 1752 | $nboflinks = count($links); |
| 1753 | 1753 | if ($nboflinks > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
@@ -1759,36 +1759,36 @@ discard block |
||
| 1759 | 1759 | if ($action == 'update' && $selected === $link->id) |
| 1760 | 1760 | { |
| 1761 | 1761 | print '<td>'; |
| 1762 | - print '<input type="hidden" name="id" value="' . $object->id . '">'; |
|
| 1763 | - print '<input type="hidden" name="linkid" value="' . $link->id . '">'; |
|
| 1762 | + print '<input type="hidden" name="id" value="'.$object->id.'">'; |
|
| 1763 | + print '<input type="hidden" name="linkid" value="'.$link->id.'">'; |
|
| 1764 | 1764 | print '<input type="hidden" name="action" value="confirm_updateline">'; |
| 1765 | - print $langs->trans('Link') . ': <input type="text" name="link" value="' . $link->url . '">'; |
|
| 1765 | + print $langs->trans('Link').': <input type="text" name="link" value="'.$link->url.'">'; |
|
| 1766 | 1766 | print '</td>'; |
| 1767 | 1767 | print '<td>'; |
| 1768 | - print $langs->trans('Label') . ': <input type="text" name="label" value="' . $link->label . '">'; |
|
| 1768 | + print $langs->trans('Label').': <input type="text" name="label" value="'.$link->label.'">'; |
|
| 1769 | 1769 | print '</td>'; |
| 1770 | - print '<td align="center">' . dol_print_date(dol_now(), "dayhour", "tzuser") . '</td>'; |
|
| 1770 | + print '<td align="center">'.dol_print_date(dol_now(), "dayhour", "tzuser").'</td>'; |
|
| 1771 | 1771 | print '<td align="right"></td>'; |
| 1772 | 1772 | print '<td align="right">'; |
| 1773 | - print '<input type="submit" name="save" class="button" value="' . dol_escape_htmltag($langs->trans('Save')) . '">'; |
|
| 1774 | - print '<input type="submit" name="cancel" class="button" value="' . dol_escape_htmltag($langs->trans('Cancel')) . '">'; |
|
| 1773 | + print '<input type="submit" name="save" class="button" value="'.dol_escape_htmltag($langs->trans('Save')).'">'; |
|
| 1774 | + print '<input type="submit" name="cancel" class="button" value="'.dol_escape_htmltag($langs->trans('Cancel')).'">'; |
|
| 1775 | 1775 | print '</td>'; |
| 1776 | 1776 | } |
| 1777 | 1777 | else |
| 1778 | 1778 | { |
| 1779 | 1779 | print '<td>'; |
| 1780 | 1780 | print img_picto('', 'object_globe').' '; |
| 1781 | - print '<a data-ajax="false" href="' . $link->url . '" target="_blank">'; |
|
| 1781 | + print '<a data-ajax="false" href="'.$link->url.'" target="_blank">'; |
|
| 1782 | 1782 | print $link->label; |
| 1783 | 1783 | print '</a>'; |
| 1784 | 1784 | print '</td>'."\n"; |
| 1785 | 1785 | print '<td align="right"></td>'; |
| 1786 | - print '<td align="center">' . dol_print_date($link->datea, "dayhour", "tzuser") . '</td>'; |
|
| 1786 | + print '<td align="center">'.dol_print_date($link->datea, "dayhour", "tzuser").'</td>'; |
|
| 1787 | 1787 | print '<td align="center"></td>'; |
| 1788 | 1788 | print '<td align="right">'; |
| 1789 | - print '<a href="' . $_SERVER['PHP_SELF'] . '?action=update&linkid=' . $link->id . $param . '" class="editfilelink" >' . img_edit() . '</a>'; // id= is included into $param |
|
| 1789 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=update&linkid='.$link->id.$param.'" class="editfilelink" >'.img_edit().'</a>'; // id= is included into $param |
|
| 1790 | 1790 | if ($permtodelete) { |
| 1791 | - print ' <a href="'. $_SERVER['PHP_SELF'] .'?action=delete&linkid=' . $link->id . $param . '" class="deletefilelink">' . img_delete() . '</a>'; // id= is included into $param |
|
| 1791 | + print ' <a href="'.$_SERVER['PHP_SELF'].'?action=delete&linkid='.$link->id.$param.'" class="deletefilelink">'.img_delete().'</a>'; // id= is included into $param |
|
| 1792 | 1792 | } else { |
| 1793 | 1793 | print ' '; |
| 1794 | 1794 | } |
@@ -1820,25 +1820,25 @@ discard block |
||
| 1820 | 1820 | * @param string $param More param on http links |
| 1821 | 1821 | * @return string $out Output string with HTML |
| 1822 | 1822 | */ |
| 1823 | - public function showPreview($file, $modulepart, $relativepath, $ruleforpicto=0, $param='') |
|
| 1823 | + public function showPreview($file, $modulepart, $relativepath, $ruleforpicto = 0, $param = '') |
|
| 1824 | 1824 | { |
| 1825 | 1825 | global $langs, $conf; |
| 1826 | 1826 | |
| 1827 | - $out=''; |
|
| 1828 | - if ($conf->browser->layout != 'phone' && ! empty($conf->use_javascript_ajax)) |
|
| 1827 | + $out = ''; |
|
| 1828 | + if ($conf->browser->layout != 'phone' && !empty($conf->use_javascript_ajax)) |
|
| 1829 | 1829 | { |
| 1830 | - $urladvancedpreview=getAdvancedPreviewUrl($modulepart, $relativepath, 1, $param); // Return if a file is qualified for preview. |
|
| 1830 | + $urladvancedpreview = getAdvancedPreviewUrl($modulepart, $relativepath, 1, $param); // Return if a file is qualified for preview. |
|
| 1831 | 1831 | if (count($urladvancedpreview)) |
| 1832 | 1832 | { |
| 1833 | - $out.= '<a class="pictopreview '.$urladvancedpreview['css'].'" href="'.$urladvancedpreview['url'].'"'.(empty($urladvancedpreview['mime'])?'':' mime="'.$urladvancedpreview['mime'].'"').' '.(empty($urladvancedpreview['target'])?'':' target="'.$urladvancedpreview['target'].'"').'>'; |
|
| 1833 | + $out .= '<a class="pictopreview '.$urladvancedpreview['css'].'" href="'.$urladvancedpreview['url'].'"'.(empty($urladvancedpreview['mime']) ? '' : ' mime="'.$urladvancedpreview['mime'].'"').' '.(empty($urladvancedpreview['target']) ? '' : ' target="'.$urladvancedpreview['target'].'"').'>'; |
|
| 1834 | 1834 | //$out.= '<a class="pictopreview">'; |
| 1835 | 1835 | if (empty($ruleforpicto)) |
| 1836 | 1836 | { |
| 1837 | 1837 | //$out.= img_picto($langs->trans('Preview').' '.$file['name'], 'detail'); |
| 1838 | - $out.='<span class="fa fa-search-plus" style="color: gray"></span>'; |
|
| 1838 | + $out .= '<span class="fa fa-search-plus" style="color: gray"></span>'; |
|
| 1839 | 1839 | } |
| 1840 | - else $out.= img_mime($relativepath, $langs->trans('Preview').' '.$file['name']); |
|
| 1841 | - $out.= '</a>'; |
|
| 1840 | + else $out .= img_mime($relativepath, $langs->trans('Preview').' '.$file['name']); |
|
| 1841 | + $out .= '</a>'; |
|
| 1842 | 1842 | } |
| 1843 | 1843 | } |
| 1844 | 1844 | return $out; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * \ingroup Advanced accountancy |
| 25 | 25 | * \brief File of class with all html predefined components |
| 26 | 26 | */ |
| 27 | -require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; |
|
| 27 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | /** |
| 44 | 44 | * @var string Error code (or message) |
| 45 | 45 | */ |
| 46 | - public $error=''; |
|
| 46 | + public $error = ''; |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Constructor |
@@ -70,29 +70,29 @@ discard block |
||
| 70 | 70 | * @param int $disabledajaxcombo Disable ajax combo box. |
| 71 | 71 | * @return string String with HTML select |
| 72 | 72 | */ |
| 73 | - function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='', $disabledajaxcombo=0) |
|
| 73 | + function select_journal($selectid, $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '', $disabledajaxcombo = 0) |
|
| 74 | 74 | { |
| 75 | 75 | // phpcs:enable |
| 76 | - global $conf,$langs; |
|
| 76 | + global $conf, $langs; |
|
| 77 | 77 | |
| 78 | 78 | $out = ''; |
| 79 | 79 | |
| 80 | 80 | $options = array(); |
| 81 | - if ($usecache && ! empty($this->options_cache[$usecache])) |
|
| 81 | + if ($usecache && !empty($this->options_cache[$usecache])) |
|
| 82 | 82 | { |
| 83 | 83 | $options = $this->options_cache[$usecache]; |
| 84 | - $selected=$selectid; |
|
| 84 | + $selected = $selectid; |
|
| 85 | 85 | } |
| 86 | 86 | else |
| 87 | 87 | { |
| 88 | 88 | $sql = "SELECT rowid, code, label, nature, entity, active"; |
| 89 | - $sql.= " FROM " . MAIN_DB_PREFIX . "accounting_journal"; |
|
| 90 | - $sql.= " WHERE active = 1"; |
|
| 91 | - $sql.= " AND entity = ".$conf->entity; |
|
| 89 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal"; |
|
| 90 | + $sql .= " WHERE active = 1"; |
|
| 91 | + $sql .= " AND entity = ".$conf->entity; |
|
| 92 | 92 | //if ($nature && is_numeric($nature)) $sql .= " AND nature = ".$nature; |
| 93 | - $sql.= " ORDER BY code"; |
|
| 93 | + $sql .= " ORDER BY code"; |
|
| 94 | 94 | |
| 95 | - dol_syslog(get_class($this) . "::select_journal", LOG_DEBUG); |
|
| 95 | + dol_syslog(get_class($this)."::select_journal", LOG_DEBUG); |
|
| 96 | 96 | $resql = $this->db->query($sql); |
| 97 | 97 | |
| 98 | 98 | if (!$resql) { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $langs->load('accountancy'); |
| 106 | 106 | while ($obj = $this->db->fetch_object($resql)) |
| 107 | 107 | { |
| 108 | - $label = $obj->code . ' - ' . $langs->trans($obj->label); |
|
| 108 | + $label = $obj->code.' - '.$langs->trans($obj->label); |
|
| 109 | 109 | |
| 110 | 110 | $select_value_in = $obj->rowid; |
| 111 | 111 | $select_value_out = $obj->rowid; |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, ($disabledajaxcombo?0:1)); |
|
| 136 | + $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, ($disabledajaxcombo ? 0 : 1)); |
|
| 137 | 137 | |
| 138 | 138 | return $out; |
| 139 | 139 | } |
@@ -151,39 +151,39 @@ discard block |
||
| 151 | 151 | * @param int $allcountries All countries |
| 152 | 152 | * @return void |
| 153 | 153 | */ |
| 154 | - function select_accounting_category($selected='',$htmlname='account_category', $useempty=0, $maxlen=0, $help=1, $allcountries=0) |
|
| 154 | + function select_accounting_category($selected = '', $htmlname = 'account_category', $useempty = 0, $maxlen = 0, $help = 1, $allcountries = 0) |
|
| 155 | 155 | { |
| 156 | 156 | // phpcs:enable |
| 157 | - global $db,$langs,$user,$mysoc; |
|
| 157 | + global $db, $langs, $user, $mysoc; |
|
| 158 | 158 | |
| 159 | 159 | if (empty($mysoc->country_id) && empty($mysoc->country_code) && empty($allcountries)) |
| 160 | 160 | { |
| 161 | - dol_print_error('','Call to select_accounting_account with mysoc country not yet defined'); |
|
| 161 | + dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); |
|
| 162 | 162 | exit; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if (! empty($mysoc->country_id)) |
|
| 165 | + if (!empty($mysoc->country_id)) |
|
| 166 | 166 | { |
| 167 | 167 | $sql = "SELECT c.rowid, c.label as type, c.range_account"; |
| 168 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; |
|
| 169 | - $sql.= " WHERE c.active = 1"; |
|
| 170 | - $sql.= " AND c.category_type = 0"; |
|
| 171 | - if (empty($allcountries)) $sql.= " AND c.fk_country = ".$mysoc->country_id; |
|
| 172 | - $sql.= " ORDER BY c.label ASC"; |
|
| 168 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; |
|
| 169 | + $sql .= " WHERE c.active = 1"; |
|
| 170 | + $sql .= " AND c.category_type = 0"; |
|
| 171 | + if (empty($allcountries)) $sql .= " AND c.fk_country = ".$mysoc->country_id; |
|
| 172 | + $sql .= " ORDER BY c.label ASC"; |
|
| 173 | 173 | } |
| 174 | 174 | else |
| 175 | 175 | { |
| 176 | 176 | $sql = "SELECT c.rowid, c.label as type, c.range_account"; |
| 177 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co"; |
|
| 178 | - $sql.= " WHERE c.active = 1"; |
|
| 179 | - $sql.= " AND c.category_type = 0"; |
|
| 180 | - $sql.= " AND c.fk_country = co.rowid"; |
|
| 181 | - if (empty($allcountries)) $sql.= " AND co.code = '".$mysoc->country_code."'"; |
|
| 182 | - $sql.= " ORDER BY c.label ASC"; |
|
| 177 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co"; |
|
| 178 | + $sql .= " WHERE c.active = 1"; |
|
| 179 | + $sql .= " AND c.category_type = 0"; |
|
| 180 | + $sql .= " AND c.fk_country = co.rowid"; |
|
| 181 | + if (empty($allcountries)) $sql .= " AND co.code = '".$mysoc->country_code."'"; |
|
| 182 | + $sql .= " ORDER BY c.label ASC"; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); |
| 186 | - $resql=$db->query($sql); |
|
| 186 | + $resql = $db->query($sql); |
|
| 187 | 187 | if ($resql) |
| 188 | 188 | { |
| 189 | 189 | $num = $db->num_rows($resql); |
@@ -192,27 +192,27 @@ discard block |
||
| 192 | 192 | $out = '<select class="flat minwidth200" id="'.$htmlname.'" name="'.$htmlname.'">'; |
| 193 | 193 | $i = 0; |
| 194 | 194 | |
| 195 | - if ($useempty) $out.= '<option value="0"> </option>'; |
|
| 195 | + if ($useempty) $out .= '<option value="0"> </option>'; |
|
| 196 | 196 | while ($i < $num) |
| 197 | 197 | { |
| 198 | 198 | $obj = $db->fetch_object($resql); |
| 199 | 199 | $out .= '<option value="'.$obj->rowid.'"'; |
| 200 | 200 | if ($obj->rowid == $selected) $out .= ' selected'; |
| 201 | - $out .= '>'.($maxlen ? dol_trunc($obj->type,$maxlen) : $obj->type); |
|
| 201 | + $out .= '>'.($maxlen ? dol_trunc($obj->type, $maxlen) : $obj->type); |
|
| 202 | 202 | $out .= ' ('.$obj->range_account.')'; |
| 203 | 203 | $i++; |
| 204 | 204 | } |
| 205 | - $out .= '</select>'; |
|
| 205 | + $out .= '</select>'; |
|
| 206 | 206 | //if ($user->admin && $help) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
| 207 | 207 | } |
| 208 | 208 | else |
| 209 | 209 | { |
| 210 | - $out .= $langs->trans("ErrorNoAccountingCategoryForThisCountry",$mysoc->country_code); |
|
| 210 | + $out .= $langs->trans("ErrorNoAccountingCategoryForThisCountry", $mysoc->country_code); |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | else |
| 214 | 214 | { |
| 215 | - dol_print_error($db,$db->lasterror()); |
|
| 215 | + dol_print_error($db, $db->lasterror()); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | $out .= ajax_combobox($htmlname, array()); |
@@ -233,17 +233,17 @@ discard block |
||
| 233 | 233 | // phpcs:enable |
| 234 | 234 | $options = array(); |
| 235 | 235 | |
| 236 | - $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; |
|
| 236 | + $sql = 'SELECT DISTINCT import_key from '.MAIN_DB_PREFIX.'accounting_bookkeeping'; |
|
| 237 | 237 | $sql .= " WHERE entity IN (".getEntity('accountancy').")"; |
| 238 | 238 | $sql .= ' ORDER BY import_key DESC'; |
| 239 | 239 | |
| 240 | - dol_syslog(get_class($this) . "::select_bookkeeping_importkey", LOG_DEBUG); |
|
| 240 | + dol_syslog(get_class($this)."::select_bookkeeping_importkey", LOG_DEBUG); |
|
| 241 | 241 | $resql = $this->db->query($sql); |
| 242 | 242 | |
| 243 | 243 | if (!$resql) { |
| 244 | - $this->error = "Error " . $this->db->lasterror(); |
|
| 245 | - dol_syslog(get_class($this) . "::select_bookkeeping_importkey " . $this->error, LOG_ERR); |
|
| 246 | - return - 1; |
|
| 244 | + $this->error = "Error ".$this->db->lasterror(); |
|
| 245 | + dol_syslog(get_class($this)."::select_bookkeeping_importkey ".$this->error, LOG_ERR); |
|
| 246 | + return -1; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | while ($obj = $this->db->fetch_object($resql)) { |
@@ -267,46 +267,46 @@ discard block |
||
| 267 | 267 | * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. |
| 268 | 268 | * @return string String with HTML select |
| 269 | 269 | */ |
| 270 | - function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='') |
|
| 270 | + function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '') |
|
| 271 | 271 | { |
| 272 | 272 | // phpcs:enable |
| 273 | 273 | global $conf, $langs; |
| 274 | 274 | |
| 275 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; |
|
| 275 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
| 276 | 276 | |
| 277 | 277 | $out = ''; |
| 278 | 278 | |
| 279 | 279 | $options = array(); |
| 280 | - if ($usecache && ! empty($this->options_cache[$usecache])) |
|
| 280 | + if ($usecache && !empty($this->options_cache[$usecache])) |
|
| 281 | 281 | { |
| 282 | 282 | $options = $this->options_cache[$usecache]; |
| 283 | - $selected=$selectid; |
|
| 283 | + $selected = $selectid; |
|
| 284 | 284 | } |
| 285 | 285 | else |
| 286 | 286 | { |
| 287 | 287 | $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT) ? 50 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT; |
| 288 | 288 | |
| 289 | 289 | $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version"; |
| 290 | - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; |
|
| 291 | - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; |
|
| 292 | - $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; |
|
| 290 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; |
|
| 291 | + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; |
|
| 292 | + $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; |
|
| 293 | 293 | $sql .= " AND aa.active = 1"; |
| 294 | 294 | $sql .= " AND aa.entity=".$conf->entity; |
| 295 | 295 | $sql .= " ORDER BY aa.account_number"; |
| 296 | 296 | |
| 297 | - dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); |
|
| 297 | + dol_syslog(get_class($this)."::select_account", LOG_DEBUG); |
|
| 298 | 298 | $resql = $this->db->query($sql); |
| 299 | 299 | |
| 300 | 300 | if (!$resql) { |
| 301 | - $this->error = "Error " . $this->db->lasterror(); |
|
| 302 | - dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); |
|
| 301 | + $this->error = "Error ".$this->db->lasterror(); |
|
| 302 | + dol_syslog(get_class($this)."::select_account ".$this->error, LOG_ERR); |
|
| 303 | 303 | return -1; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | $selected = 0; |
| 307 | 307 | while ($obj = $this->db->fetch_object($resql)) |
| 308 | 308 | { |
| 309 | - $label = length_accountg($obj->account_number) . ' - ' . $obj->label; |
|
| 309 | + $label = length_accountg($obj->account_number).' - '.$obj->label; |
|
| 310 | 310 | $label = dol_trunc($label, $trunclength); |
| 311 | 311 | |
| 312 | 312 | $select_value_in = $obj->rowid; |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | * @param string $morecss More css |
| 357 | 357 | * @return string String with HTML select |
| 358 | 358 | */ |
| 359 | - function select_auxaccount($selectid, $htmlname='account_num_aux', $showempty=0, $morecss='maxwidth200') |
|
| 359 | + function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth200') |
|
| 360 | 360 | { |
| 361 | 361 | // phpcs:enable |
| 362 | 362 | |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | // Auxiliary customer account |
| 366 | 366 | $sql = "SELECT DISTINCT code_compta, nom "; |
| 367 | 367 | $sql .= " FROM ".MAIN_DB_PREFIX."societe"; |
| 368 | - $sql .= " WHERE entity IN (" . getEntity('societe') . ")"; |
|
| 368 | + $sql .= " WHERE entity IN (".getEntity('societe').")"; |
|
| 369 | 369 | $sql .= " ORDER BY code_compta"; |
| 370 | 370 | dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); |
| 371 | 371 | $resql = $this->db->query($sql); |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | // Auxiliary supplier account |
| 386 | 386 | $sql = "SELECT DISTINCT code_compta_fournisseur, nom "; |
| 387 | 387 | $sql .= " FROM ".MAIN_DB_PREFIX."societe"; |
| 388 | - $sql .= " WHERE entity IN (" . getEntity('societe') . ")"; |
|
| 388 | + $sql .= " WHERE entity IN (".getEntity('societe').")"; |
|
| 389 | 389 | $sql .= " ORDER BY code_compta_fournisseur"; |
| 390 | 390 | dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); |
| 391 | 391 | $resql = $this->db->query($sql); |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | |
| 428 | 428 | $sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear"; |
| 429 | 429 | $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping"; |
| 430 | - $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")"; |
|
| 430 | + $sql .= " WHERE entity IN (".getEntity('accountancy').")"; |
|
| 431 | 431 | $sql .= " ORDER BY date_format(doc_date,'%Y')"; |
| 432 | 432 | dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); |
| 433 | 433 | $resql = $this->db->query($sql); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | function encode($string) |
| 32 | 32 | { |
| 33 | - return str_replace(";","\;",(dol_quoted_printable_encode(utf8_decode($string)))); |
|
| 33 | + return str_replace(";", "\;", (dol_quoted_printable_encode(utf8_decode($string)))); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | * @param int $line_max Max length of lines |
| 43 | 43 | * @return string Encoded string |
| 44 | 44 | */ |
| 45 | -function dol_quoted_printable_encode($input, $line_max=76) |
|
| 45 | +function dol_quoted_printable_encode($input, $line_max = 76) |
|
| 46 | 46 | { |
| 47 | - $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
| 47 | + $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
| 48 | 48 | $lines = preg_split("/(\?:\r\n|\r|\n)/", $input); |
| 49 | 49 | $eol = "\r\n"; |
| 50 | 50 | $linebreak = "=0D=0A"; |
@@ -57,23 +57,23 @@ discard block |
||
| 57 | 57 | $line = $lines[$j]; |
| 58 | 58 | $linlen = strlen($line); |
| 59 | 59 | $newline = ""; |
| 60 | - for($i = 0; $i < $linlen; $i++) { |
|
| 60 | + for ($i = 0; $i < $linlen; $i++) { |
|
| 61 | 61 | $c = substr($line, $i, 1); |
| 62 | 62 | $dec = ord($c); |
| 63 | - if ( ($dec == 32) && ($i == ($linlen - 1)) ) { // convert space at eol only |
|
| 63 | + if (($dec == 32) && ($i == ($linlen - 1))) { // convert space at eol only |
|
| 64 | 64 | $c = "=20"; |
| 65 | - } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required |
|
| 66 | - $h2 = floor($dec/16); $h1 = floor($dec%16); |
|
| 65 | + } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required |
|
| 66 | + $h2 = floor($dec / 16); $h1 = floor($dec % 16); |
|
| 67 | 67 | $c = $escape.$hex["$h2"].$hex["$h1"]; |
| 68 | 68 | } |
| 69 | - if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted |
|
| 69 | + if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted |
|
| 70 | 70 | $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay |
| 71 | 71 | $newline = " "; |
| 72 | 72 | } |
| 73 | 73 | $newline .= $c; |
| 74 | 74 | } // end of for |
| 75 | 75 | $output .= $newline; |
| 76 | - if ($j<count($lines)-1) $output .= $linebreak; |
|
| 76 | + if ($j < count($lines) - 1) $output .= $linebreak; |
|
| 77 | 77 | } |
| 78 | 78 | return trim($output); |
| 79 | 79 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | var $filename; |
| 89 | 89 | |
| 90 | 90 | //var $encoding="UTF-8"; |
| 91 | - var $encoding="ISO-8859-1;ENCODING=QUOTED-PRINTABLE"; |
|
| 91 | + var $encoding = "ISO-8859-1;ENCODING=QUOTED-PRINTABLE"; |
|
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -98,12 +98,12 @@ discard block |
||
| 98 | 98 | * @param string $type Type |
| 99 | 99 | * @return void |
| 100 | 100 | */ |
| 101 | - function setPhoneNumber($number, $type="") |
|
| 101 | + function setPhoneNumber($number, $type = "") |
|
| 102 | 102 | { |
| 103 | 103 | // type may be PREF | WORK | HOME | VOICE | FAX | MSG | CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO or any senseful combination, e.g. "PREF;WORK;VOICE" |
| 104 | 104 | $key = "TEL"; |
| 105 | - if ($type!="") $key .= ";".$type; |
|
| 106 | - $key.= ";CHARSET=".$this->encoding; |
|
| 105 | + if ($type != "") $key .= ";".$type; |
|
| 106 | + $key .= ";CHARSET=".$this->encoding; |
|
| 107 | 107 | $this->properties[$key] = encode($number); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param string $suffix Suffix |
| 143 | 143 | * @return void |
| 144 | 144 | */ |
| 145 | - function setName($family="", $first="", $additional="", $prefix="", $suffix="") |
|
| 145 | + function setName($family = "", $first = "", $additional = "", $prefix = "", $suffix = "") |
|
| 146 | 146 | { |
| 147 | 147 | $this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); |
| 148 | 148 | $this->filename = "$first%20$family.vcf"; |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | * @param string $type Type |
| 175 | 175 | * @return void |
| 176 | 176 | */ |
| 177 | - function setAddress($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") |
|
| 177 | + function setAddress($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") |
|
| 178 | 178 | { |
| 179 | 179 | // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL" |
| 180 | 180 | $key = "ADR"; |
| 181 | - if ($type!="") $key.= ";$type"; |
|
| 182 | - $key.= ";CHARSET=".$this->encoding; |
|
| 181 | + if ($type != "") $key .= ";$type"; |
|
| 182 | + $key .= ";CHARSET=".$this->encoding; |
|
| 183 | 183 | $this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country); |
| 184 | 184 | |
| 185 | 185 | if ($this->properties["LABEL;$type;CHARSET=".$this->encoding] == "") |
@@ -201,16 +201,16 @@ discard block |
||
| 201 | 201 | * @param string $type Type |
| 202 | 202 | * @return void |
| 203 | 203 | */ |
| 204 | - function setLabel($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") |
|
| 204 | + function setLabel($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") |
|
| 205 | 205 | { |
| 206 | 206 | $label = ""; |
| 207 | - if ($postoffice!="") $label.= "$postoffice\r\n"; |
|
| 208 | - if ($extended!="") $label.= "$extended\r\n"; |
|
| 209 | - if ($street!="") $label.= "$street\r\n"; |
|
| 210 | - if ($zip!="") $label.= "$zip "; |
|
| 211 | - if ($city!="") $label.= "$city\r\n"; |
|
| 212 | - if ($region!="") $label.= "$region\r\n"; |
|
| 213 | - if ($country!="") $country.= "$country\r\n"; |
|
| 207 | + if ($postoffice != "") $label .= "$postoffice\r\n"; |
|
| 208 | + if ($extended != "") $label .= "$extended\r\n"; |
|
| 209 | + if ($street != "") $label .= "$street\r\n"; |
|
| 210 | + if ($zip != "") $label .= "$zip "; |
|
| 211 | + if ($city != "") $label .= "$city\r\n"; |
|
| 212 | + if ($region != "") $label .= "$region\r\n"; |
|
| 213 | + if ($country != "") $country .= "$country\r\n"; |
|
| 214 | 214 | |
| 215 | 215 | $this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label); |
| 216 | 216 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * @param string $type Vcard type |
| 223 | 223 | * @return void |
| 224 | 224 | */ |
| 225 | - function setEmail($address,$type="internet,pref") |
|
| 225 | + function setEmail($address, $type = "internet,pref") |
|
| 226 | 226 | { |
| 227 | 227 | $this->properties["EMAIL;TYPE=".$type] = $address; |
| 228 | 228 | } |
@@ -293,11 +293,11 @@ discard block |
||
| 293 | 293 | * @param string $type Type |
| 294 | 294 | * @return void |
| 295 | 295 | */ |
| 296 | - function setURL($url, $type="") |
|
| 296 | + function setURL($url, $type = "") |
|
| 297 | 297 | { |
| 298 | 298 | // $type may be WORK | HOME |
| 299 | 299 | $key = "URL"; |
| 300 | - if ($type!="") $key.= ";$type"; |
|
| 300 | + if ($type != "") $key .= ";$type"; |
|
| 301 | 301 | $this->properties[$key] = $url; |
| 302 | 302 | } |
| 303 | 303 | |
@@ -309,15 +309,15 @@ discard block |
||
| 309 | 309 | function getVCard() |
| 310 | 310 | { |
| 311 | 311 | $text = "BEGIN:VCARD\r\n"; |
| 312 | - $text.= "VERSION:3.0\r\n"; |
|
| 312 | + $text .= "VERSION:3.0\r\n"; |
|
| 313 | 313 | //$text.= "VERSION:2.1\r\n"; |
| 314 | - foreach($this->properties as $key => $value) |
|
| 314 | + foreach ($this->properties as $key => $value) |
|
| 315 | 315 | { |
| 316 | - $text.= "$key:$value\r\n"; |
|
| 316 | + $text .= "$key:$value\r\n"; |
|
| 317 | 317 | } |
| 318 | - $text.= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n"; |
|
| 319 | - $text.= "MAILER: Dolibarr\r\n"; |
|
| 320 | - $text.= "END:VCARD\r\n"; |
|
| 318 | + $text .= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n"; |
|
| 319 | + $text .= "MAILER: Dolibarr\r\n"; |
|
| 320 | + $text .= "END:VCARD\r\n"; |
|
| 321 | 321 | return $text; |
| 322 | 322 | } |
| 323 | 323 | |