@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | if (($pageid > 0 || $pageref) && $action != 'addcontainer') |
| 126 | 126 | { |
| 127 | 127 | $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref); |
| 128 | - if ($res == 0) |
|
| 129 | - { |
|
| 130 | - $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), null, $pageref); |
|
| 131 | - } |
|
| 128 | + if ($res == 0) |
|
| 129 | + { |
|
| 130 | + $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), null, $pageref); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | // Check if pageid is inside the new website, if not we reset param pageid |
| 134 | 134 | if ($res >= 0 && $object->id > 0) |
@@ -268,28 +268,28 @@ discard block |
||
| 268 | 268 | // Protections |
| 269 | 269 | if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) |
| 270 | 270 | { |
| 271 | - $action = 'preview'; // To avoid to make an action on another page or another site when we click on button to select another site or page. |
|
| 271 | + $action = 'preview'; // To avoid to make an action on another page or another site when we click on button to select another site or page. |
|
| 272 | 272 | } |
| 273 | 273 | if (GETPOST('refreshsite', 'alpha') || GETPOST('refreshsite.x', 'alpha') || GETPOST('refreshsite_x', 'alpha')) // If we change the site, we reset the pageid and cancel addsite action. |
| 274 | 274 | { |
| 275 | - if ($action == 'addsite') $action = 'preview'; |
|
| 276 | - if ($action == 'updatesource') $action = 'preview'; |
|
| 277 | - |
|
| 278 | - $pageid = $object->fk_default_home; |
|
| 279 | - if (empty($pageid)) |
|
| 280 | - { |
|
| 281 | - $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); |
|
| 282 | - if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 283 | - $atleastonepage=(is_array($array) && count($array) > 0); |
|
| 284 | - |
|
| 285 | - $firstpageid=0; $homepageid=0; |
|
| 286 | - foreach($array as $key => $valpage) |
|
| 287 | - { |
|
| 288 | - if (empty($firstpageid)) $firstpageid=$valpage->id; |
|
| 289 | - if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; |
|
| 290 | - } |
|
| 291 | - $pageid=($homepageid?$homepageid:$firstpageid); // We choose home page and if not defined yet, we take first page |
|
| 292 | - } |
|
| 275 | + if ($action == 'addsite') $action = 'preview'; |
|
| 276 | + if ($action == 'updatesource') $action = 'preview'; |
|
| 277 | + |
|
| 278 | + $pageid = $object->fk_default_home; |
|
| 279 | + if (empty($pageid)) |
|
| 280 | + { |
|
| 281 | + $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); |
|
| 282 | + if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 283 | + $atleastonepage=(is_array($array) && count($array) > 0); |
|
| 284 | + |
|
| 285 | + $firstpageid=0; $homepageid=0; |
|
| 286 | + foreach($array as $key => $valpage) |
|
| 287 | + { |
|
| 288 | + if (empty($firstpageid)) $firstpageid=$valpage->id; |
|
| 289 | + if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; |
|
| 290 | + } |
|
| 291 | + $pageid=($homepageid?$homepageid:$firstpageid); // We choose home page and if not defined yet, we take first page |
|
| 292 | + } |
|
| 293 | 293 | } |
| 294 | 294 | if (GETPOST('refreshpage', 'alpha') && ! in_array($action, array('updatecss'))) $action='preview'; |
| 295 | 295 | |
@@ -375,9 +375,9 @@ discard block |
||
| 375 | 375 | $db->begin(); |
| 376 | 376 | |
| 377 | 377 | if (GETPOST('virtualhost', 'alpha') && ! preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) |
| 378 | - { |
|
| 379 | - $error++; |
|
| 380 | - setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); |
|
| 378 | + { |
|
| 379 | + $error++; |
|
| 380 | + setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | if (! $error && ! GETPOST('WEBSITE_REF', 'alpha')) |
@@ -1037,49 +1037,49 @@ discard block |
||
| 1037 | 1037 | |
| 1038 | 1038 | if (GETPOSTISSET('virtualhost')) |
| 1039 | 1039 | { |
| 1040 | - if (GETPOST('virtualhost', 'alpha') && ! preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) |
|
| 1041 | - { |
|
| 1042 | - $error++; |
|
| 1043 | - setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); |
|
| 1044 | - $action='editcss'; |
|
| 1045 | - } |
|
| 1040 | + if (GETPOST('virtualhost', 'alpha') && ! preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) |
|
| 1041 | + { |
|
| 1042 | + $error++; |
|
| 1043 | + setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); |
|
| 1044 | + $action='editcss'; |
|
| 1045 | + } |
|
| 1046 | 1046 | |
| 1047 | - if (! $error) |
|
| 1048 | - { |
|
| 1049 | - $object->virtualhost = GETPOST('virtualhost', 'alpha'); |
|
| 1047 | + if (! $error) |
|
| 1048 | + { |
|
| 1049 | + $object->virtualhost = GETPOST('virtualhost', 'alpha'); |
|
| 1050 | 1050 | |
| 1051 | - $result = $object->update($user); |
|
| 1052 | - if ($result < 0) |
|
| 1053 | - { |
|
| 1054 | - $error++; |
|
| 1055 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
| 1056 | - $action='editcss'; |
|
| 1057 | - } |
|
| 1058 | - } |
|
| 1051 | + $result = $object->update($user); |
|
| 1052 | + if ($result < 0) |
|
| 1053 | + { |
|
| 1054 | + $error++; |
|
| 1055 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 1056 | + $action='editcss'; |
|
| 1057 | + } |
|
| 1058 | + } |
|
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | 1061 | if (! $error) |
| 1062 | 1062 | { |
| 1063 | - // Save master.inc.php file |
|
| 1064 | - $filemaster=$pathofwebsite.'/master.inc.php'; |
|
| 1063 | + // Save master.inc.php file |
|
| 1064 | + $filemaster=$pathofwebsite.'/master.inc.php'; |
|
| 1065 | 1065 | |
| 1066 | - dol_syslog("Save master file ".$filemaster); |
|
| 1066 | + dol_syslog("Save master file ".$filemaster); |
|
| 1067 | 1067 | |
| 1068 | - dol_mkdir($pathofwebsite); |
|
| 1068 | + dol_mkdir($pathofwebsite); |
|
| 1069 | 1069 | |
| 1070 | - // Now generate the master.inc.php page |
|
| 1071 | - $result = dolSaveMasterFile($filemaster); |
|
| 1072 | - if (! $result) |
|
| 1073 | - { |
|
| 1074 | - $error++; |
|
| 1075 | - setEventMessages('Failed to write file '.$filemaster, null, 'errors'); |
|
| 1076 | - } |
|
| 1070 | + // Now generate the master.inc.php page |
|
| 1071 | + $result = dolSaveMasterFile($filemaster); |
|
| 1072 | + if (! $result) |
|
| 1073 | + { |
|
| 1074 | + $error++; |
|
| 1075 | + setEventMessages('Failed to write file '.$filemaster, null, 'errors'); |
|
| 1076 | + } |
|
| 1077 | 1077 | |
| 1078 | 1078 | |
| 1079 | - // Html header file |
|
| 1080 | - $htmlheadercontent =''; |
|
| 1079 | + // Html header file |
|
| 1080 | + $htmlheadercontent =''; |
|
| 1081 | 1081 | |
| 1082 | - /* We disable php code since htmlheader is never executed as an include but only read by fgets_content. |
|
| 1082 | + /* We disable php code since htmlheader is never executed as an include but only read by fgets_content. |
|
| 1083 | 1083 | $htmlheadercontent.= "<?php // BEGIN PHP\n"; |
| 1084 | 1084 | $htmlheadercontent.= '$websitekey=basename(__DIR__);'."\n"; |
| 1085 | 1085 | $htmlheadercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load env if not already loaded"."\n"; |
@@ -1089,84 +1089,84 @@ discard block |
||
| 1089 | 1089 | // $htmlheadercontent.= "header('Content-type: text/html');\n"; // Not required. htmlheader.html is never call as a standalone page |
| 1090 | 1090 | $htmlheadercontent.= "// END PHP ?>\n";*/ |
| 1091 | 1091 | |
| 1092 | - $htmlheadercontent.= preg_replace(array('/<html>\n*/ims','/<\/html>\n*/ims'), array('',''), GETPOST('WEBSITE_HTML_HEADER', 'none')); |
|
| 1092 | + $htmlheadercontent.= preg_replace(array('/<html>\n*/ims','/<\/html>\n*/ims'), array('',''), GETPOST('WEBSITE_HTML_HEADER', 'none')); |
|
| 1093 | 1093 | |
| 1094 | - /*$htmlheadercontent.= "\n".'<?php // BEGIN PHP'."\n"; |
|
| 1094 | + /*$htmlheadercontent.= "\n".'<?php // BEGIN PHP'."\n"; |
|
| 1095 | 1095 | $htmlheadercontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n"; |
| 1096 | 1096 | $htmlheadercontent.= "// END PHP ?>"."\n";*/ |
| 1097 | 1097 | |
| 1098 | - $htmlheadercontent = trim($htmlheadercontent)."\n"; |
|
| 1098 | + $htmlheadercontent = trim($htmlheadercontent)."\n"; |
|
| 1099 | 1099 | |
| 1100 | - $result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); |
|
| 1101 | - if (! $result) |
|
| 1102 | - { |
|
| 1103 | - $error++; |
|
| 1104 | - setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); |
|
| 1105 | - } |
|
| 1100 | + $result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); |
|
| 1101 | + if (! $result) |
|
| 1102 | + { |
|
| 1103 | + $error++; |
|
| 1104 | + setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); |
|
| 1105 | + } |
|
| 1106 | 1106 | |
| 1107 | 1107 | |
| 1108 | - // Css file |
|
| 1109 | - $csscontent =''; |
|
| 1108 | + // Css file |
|
| 1109 | + $csscontent =''; |
|
| 1110 | 1110 | |
| 1111 | - $csscontent.= "<?php // BEGIN PHP\n"; |
|
| 1112 | - $csscontent.= '$websitekey=basename(__DIR__);'."\n"; |
|
| 1113 | - $csscontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. |
|
| 1114 | - $csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
| 1115 | - $csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
| 1116 | - $csscontent.= "ob_start();\n"; |
|
| 1117 | - $csscontent.= "if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n"; |
|
| 1118 | - $csscontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; |
|
| 1119 | - $csscontent.= "header('Content-type: text/css');\n"; |
|
| 1120 | - $csscontent.= "}\n"; |
|
| 1121 | - $csscontent.= "// END PHP ?>\n"; |
|
| 1111 | + $csscontent.= "<?php // BEGIN PHP\n"; |
|
| 1112 | + $csscontent.= '$websitekey=basename(__DIR__);'."\n"; |
|
| 1113 | + $csscontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. |
|
| 1114 | + $csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
| 1115 | + $csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
| 1116 | + $csscontent.= "ob_start();\n"; |
|
| 1117 | + $csscontent.= "if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n"; |
|
| 1118 | + $csscontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; |
|
| 1119 | + $csscontent.= "header('Content-type: text/css');\n"; |
|
| 1120 | + $csscontent.= "}\n"; |
|
| 1121 | + $csscontent.= "// END PHP ?>\n"; |
|
| 1122 | 1122 | |
| 1123 | - $csscontent.= trim(GETPOST('WEBSITE_CSS_INLINE', 'none'))."\n"; |
|
| 1123 | + $csscontent.= trim(GETPOST('WEBSITE_CSS_INLINE', 'none'))."\n"; |
|
| 1124 | 1124 | |
| 1125 | - $csscontent.= '<?php // BEGIN PHP'."\n"; |
|
| 1126 | - $csscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n"; |
|
| 1127 | - $csscontent.= "// END PHP ?>"."\n"; |
|
| 1125 | + $csscontent.= '<?php // BEGIN PHP'."\n"; |
|
| 1126 | + $csscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n"; |
|
| 1127 | + $csscontent.= "// END PHP ?>"."\n"; |
|
| 1128 | 1128 | |
| 1129 | - dol_syslog("Save css content into ".$filecss); |
|
| 1129 | + dol_syslog("Save css content into ".$filecss); |
|
| 1130 | 1130 | |
| 1131 | - $result = dolSaveCssFile($filecss, $csscontent); |
|
| 1132 | - if (! $result) |
|
| 1133 | - { |
|
| 1134 | - $error++; |
|
| 1135 | - setEventMessages('Failed to write file '.$filecss, null, 'errors'); |
|
| 1136 | - } |
|
| 1131 | + $result = dolSaveCssFile($filecss, $csscontent); |
|
| 1132 | + if (! $result) |
|
| 1133 | + { |
|
| 1134 | + $error++; |
|
| 1135 | + setEventMessages('Failed to write file '.$filecss, null, 'errors'); |
|
| 1136 | + } |
|
| 1137 | 1137 | |
| 1138 | 1138 | |
| 1139 | - // Js file |
|
| 1140 | - $jscontent =''; |
|
| 1139 | + // Js file |
|
| 1140 | + $jscontent =''; |
|
| 1141 | 1141 | |
| 1142 | - $jscontent.= "<?php // BEGIN PHP\n"; |
|
| 1143 | - $jscontent.= '$websitekey=basename(__DIR__);'."\n"; |
|
| 1144 | - $jscontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. |
|
| 1145 | - $jscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
| 1146 | - $jscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
| 1147 | - $jscontent.= "ob_start();\n"; |
|
| 1148 | - $jscontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; |
|
| 1149 | - $jscontent.= "header('Content-type: application/javascript');\n"; |
|
| 1150 | - $jscontent.= "// END PHP ?>\n"; |
|
| 1142 | + $jscontent.= "<?php // BEGIN PHP\n"; |
|
| 1143 | + $jscontent.= '$websitekey=basename(__DIR__);'."\n"; |
|
| 1144 | + $jscontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. |
|
| 1145 | + $jscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
| 1146 | + $jscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
| 1147 | + $jscontent.= "ob_start();\n"; |
|
| 1148 | + $jscontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; |
|
| 1149 | + $jscontent.= "header('Content-type: application/javascript');\n"; |
|
| 1150 | + $jscontent.= "// END PHP ?>\n"; |
|
| 1151 | 1151 | |
| 1152 | - $jscontent.= trim(GETPOST('WEBSITE_JS_INLINE', 'none'))."\n"; |
|
| 1152 | + $jscontent.= trim(GETPOST('WEBSITE_JS_INLINE', 'none'))."\n"; |
|
| 1153 | 1153 | |
| 1154 | - $jscontent.= '<?php // BEGIN PHP'."\n"; |
|
| 1155 | - $jscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n"; |
|
| 1156 | - $jscontent.= "// END PHP ?>"."\n"; |
|
| 1154 | + $jscontent.= '<?php // BEGIN PHP'."\n"; |
|
| 1155 | + $jscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n"; |
|
| 1156 | + $jscontent.= "// END PHP ?>"."\n"; |
|
| 1157 | 1157 | |
| 1158 | - $result = dolSaveJsFile($filejs, $jscontent); |
|
| 1159 | - if (! $result) |
|
| 1160 | - { |
|
| 1161 | - $error++; |
|
| 1162 | - setEventMessages('Failed to write file '.$filejs, null, 'errors'); |
|
| 1163 | - } |
|
| 1158 | + $result = dolSaveJsFile($filejs, $jscontent); |
|
| 1159 | + if (! $result) |
|
| 1160 | + { |
|
| 1161 | + $error++; |
|
| 1162 | + setEventMessages('Failed to write file '.$filejs, null, 'errors'); |
|
| 1163 | + } |
|
| 1164 | 1164 | |
| 1165 | 1165 | |
| 1166 | - // Robot file |
|
| 1167 | - $robotcontent =''; |
|
| 1166 | + // Robot file |
|
| 1167 | + $robotcontent =''; |
|
| 1168 | 1168 | |
| 1169 | - /*$robotcontent.= "<?php // BEGIN PHP\n"; |
|
| 1169 | + /*$robotcontent.= "<?php // BEGIN PHP\n"; |
|
| 1170 | 1170 | $robotcontent.= '$websitekey=basename(__DIR__);'."\n"; |
| 1171 | 1171 | $robotcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load env if not already loaded"."\n"; |
| 1172 | 1172 | $robotcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
@@ -1176,63 +1176,63 @@ discard block |
||
| 1176 | 1176 | $robotcontent.= "header('Content-type: text/css');\n"; |
| 1177 | 1177 | $robotcontent.= "// END PHP ?>\n";*/ |
| 1178 | 1178 | |
| 1179 | - $robotcontent.= trim(GETPOST('WEBSITE_ROBOT', 'none'))."\n"; |
|
| 1179 | + $robotcontent.= trim(GETPOST('WEBSITE_ROBOT', 'none'))."\n"; |
|
| 1180 | 1180 | |
| 1181 | - /*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n"; |
|
| 1181 | + /*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n"; |
|
| 1182 | 1182 | $robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "robot");'."\n"; |
| 1183 | 1183 | $robotcontent.= "// END PHP ?>"."\n";*/ |
| 1184 | 1184 | |
| 1185 | - $result = dolSaveRobotFile($filerobot, $robotcontent); |
|
| 1186 | - if (! $result) |
|
| 1187 | - { |
|
| 1188 | - $error++; |
|
| 1189 | - setEventMessages('Failed to write file '.$filerobot, null, 'errors'); |
|
| 1190 | - } |
|
| 1185 | + $result = dolSaveRobotFile($filerobot, $robotcontent); |
|
| 1186 | + if (! $result) |
|
| 1187 | + { |
|
| 1188 | + $error++; |
|
| 1189 | + setEventMessages('Failed to write file '.$filerobot, null, 'errors'); |
|
| 1190 | + } |
|
| 1191 | 1191 | |
| 1192 | 1192 | |
| 1193 | - // Htaccess file |
|
| 1194 | - $htaccesscontent =''; |
|
| 1195 | - $htaccesscontent.= trim(GETPOST('WEBSITE_HTACCESS', 'none'))."\n"; |
|
| 1193 | + // Htaccess file |
|
| 1194 | + $htaccesscontent =''; |
|
| 1195 | + $htaccesscontent.= trim(GETPOST('WEBSITE_HTACCESS', 'none'))."\n"; |
|
| 1196 | 1196 | |
| 1197 | - $result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent); |
|
| 1198 | - if (! $result) |
|
| 1199 | - { |
|
| 1200 | - $error++; |
|
| 1201 | - setEventMessages('Failed to write file '.$filehtaccess, null, 'errors'); |
|
| 1202 | - } |
|
| 1197 | + $result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent); |
|
| 1198 | + if (! $result) |
|
| 1199 | + { |
|
| 1200 | + $error++; |
|
| 1201 | + setEventMessages('Failed to write file '.$filehtaccess, null, 'errors'); |
|
| 1202 | + } |
|
| 1203 | 1203 | |
| 1204 | 1204 | |
| 1205 | - // manifest.json file |
|
| 1206 | - $manifestjsoncontent =''; |
|
| 1205 | + // manifest.json file |
|
| 1206 | + $manifestjsoncontent =''; |
|
| 1207 | 1207 | |
| 1208 | - $manifestjsoncontent.= "<?php // BEGIN PHP\n"; |
|
| 1209 | - $manifestjsoncontent.= '$websitekey=basename(__DIR__);'."\n"; |
|
| 1210 | - $manifestjsoncontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. |
|
| 1211 | - $manifestjsoncontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
| 1212 | - $manifestjsoncontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
| 1213 | - $manifestjsoncontent.= "ob_start();\n"; |
|
| 1214 | - $manifestjsoncontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; |
|
| 1215 | - $manifestjsoncontent.= "header('Content-type: application/manifest+json');\n"; |
|
| 1216 | - $manifestjsoncontent.= "// END PHP ?>\n"; |
|
| 1208 | + $manifestjsoncontent.= "<?php // BEGIN PHP\n"; |
|
| 1209 | + $manifestjsoncontent.= '$websitekey=basename(__DIR__);'."\n"; |
|
| 1210 | + $manifestjsoncontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. |
|
| 1211 | + $manifestjsoncontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
| 1212 | + $manifestjsoncontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
| 1213 | + $manifestjsoncontent.= "ob_start();\n"; |
|
| 1214 | + $manifestjsoncontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; |
|
| 1215 | + $manifestjsoncontent.= "header('Content-type: application/manifest+json');\n"; |
|
| 1216 | + $manifestjsoncontent.= "// END PHP ?>\n"; |
|
| 1217 | 1217 | |
| 1218 | - $manifestjsoncontent.= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n"; |
|
| 1218 | + $manifestjsoncontent.= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n"; |
|
| 1219 | 1219 | |
| 1220 | - $manifestjsoncontent.= '<?php // BEGIN PHP'."\n"; |
|
| 1221 | - $manifestjsoncontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; |
|
| 1222 | - $manifestjsoncontent.= "// END PHP ?>"."\n"; |
|
| 1220 | + $manifestjsoncontent.= '<?php // BEGIN PHP'."\n"; |
|
| 1221 | + $manifestjsoncontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; |
|
| 1222 | + $manifestjsoncontent.= "// END PHP ?>"."\n"; |
|
| 1223 | 1223 | |
| 1224 | - $result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); |
|
| 1225 | - if (! $result) |
|
| 1226 | - { |
|
| 1227 | - $error++; |
|
| 1228 | - setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors'); |
|
| 1229 | - } |
|
| 1224 | + $result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); |
|
| 1225 | + if (! $result) |
|
| 1226 | + { |
|
| 1227 | + $error++; |
|
| 1228 | + setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors'); |
|
| 1229 | + } |
|
| 1230 | 1230 | |
| 1231 | 1231 | |
| 1232 | - // README.md file |
|
| 1233 | - $readmecontent =''; |
|
| 1232 | + // README.md file |
|
| 1233 | + $readmecontent =''; |
|
| 1234 | 1234 | |
| 1235 | - /*$readmecontent.= "<?php // BEGIN PHP\n"; |
|
| 1235 | + /*$readmecontent.= "<?php // BEGIN PHP\n"; |
|
| 1236 | 1236 | $readmecontent.= '$websitekey=basename(__DIR__);'."\n"; |
| 1237 | 1237 | $readmecontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. |
| 1238 | 1238 | $readmecontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
@@ -1242,39 +1242,39 @@ discard block |
||
| 1242 | 1242 | $readmecontent.= "header('Content-type: application/manifest+json');\n"; |
| 1243 | 1243 | $readmecontent.= "// END PHP ?>\n";*/ |
| 1244 | 1244 | |
| 1245 | - $readmecontent.= trim(GETPOST('WEBSITE_README', 'none'))."\n"; |
|
| 1245 | + $readmecontent.= trim(GETPOST('WEBSITE_README', 'none'))."\n"; |
|
| 1246 | 1246 | |
| 1247 | - /*$readmecontent.= '<?php // BEGIN PHP'."\n"; |
|
| 1247 | + /*$readmecontent.= '<?php // BEGIN PHP'."\n"; |
|
| 1248 | 1248 | $readmecontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; |
| 1249 | 1249 | $readmecontent.= "// END PHP ?>"."\n";*/ |
| 1250 | 1250 | |
| 1251 | - $result = dolSaveReadme($filereadme, $readmecontent); |
|
| 1252 | - if (! $result) |
|
| 1253 | - { |
|
| 1254 | - $error++; |
|
| 1255 | - setEventMessages('Failed to write file '.$filereadme, null, 'errors'); |
|
| 1256 | - } |
|
| 1257 | - |
|
| 1258 | - |
|
| 1259 | - // Message if no error |
|
| 1260 | - if (! $error) |
|
| 1261 | - { |
|
| 1262 | - setEventMessages($langs->trans("Saved"), null, 'mesgs'); |
|
| 1263 | - } |
|
| 1264 | - |
|
| 1265 | - if (! GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we don not make the redirect |
|
| 1266 | - { |
|
| 1267 | - $action='preview'; |
|
| 1268 | - if ($backtopage) |
|
| 1269 | - { |
|
| 1270 | - header("Location: ".$backtopage); |
|
| 1271 | - exit; |
|
| 1272 | - } |
|
| 1273 | - } |
|
| 1274 | - else |
|
| 1275 | - { |
|
| 1276 | - $action = 'editcss'; |
|
| 1277 | - } |
|
| 1251 | + $result = dolSaveReadme($filereadme, $readmecontent); |
|
| 1252 | + if (! $result) |
|
| 1253 | + { |
|
| 1254 | + $error++; |
|
| 1255 | + setEventMessages('Failed to write file '.$filereadme, null, 'errors'); |
|
| 1256 | + } |
|
| 1257 | + |
|
| 1258 | + |
|
| 1259 | + // Message if no error |
|
| 1260 | + if (! $error) |
|
| 1261 | + { |
|
| 1262 | + setEventMessages($langs->trans("Saved"), null, 'mesgs'); |
|
| 1263 | + } |
|
| 1264 | + |
|
| 1265 | + if (! GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we don not make the redirect |
|
| 1266 | + { |
|
| 1267 | + $action='preview'; |
|
| 1268 | + if ($backtopage) |
|
| 1269 | + { |
|
| 1270 | + header("Location: ".$backtopage); |
|
| 1271 | + exit; |
|
| 1272 | + } |
|
| 1273 | + } |
|
| 1274 | + else |
|
| 1275 | + { |
|
| 1276 | + $action = 'editcss'; |
|
| 1277 | + } |
|
| 1278 | 1278 | } |
| 1279 | 1279 | } |
| 1280 | 1280 | } |
@@ -1652,35 +1652,35 @@ discard block |
||
| 1652 | 1652 | |
| 1653 | 1653 | $objectpage->content = GETPOST('PAGE_CONTENT', 'none'); |
| 1654 | 1654 | |
| 1655 | - // Security analysis |
|
| 1655 | + // Security analysis |
|
| 1656 | 1656 | $phpfullcodestring = dolKeepOnlyPhpCode($objectpage->content); |
| 1657 | 1657 | //print dol_escape_htmltag($phpfullcodestring);exit; |
| 1658 | - $forbiddenphpcommands=array("exec", "passthru", "system", "shell_exec", "proc_open"); |
|
| 1659 | - if (empty($conf->global->WEBSITE_PHP_ALLOW_WRITE)) // If option is not on, we disallow functions to write files |
|
| 1660 | - { |
|
| 1661 | - $forbiddenphpcommands=array_merge($forbiddenphpcommands, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask")); |
|
| 1662 | - } |
|
| 1663 | - foreach($forbiddenphpcommands as $forbiddenphpcommand) |
|
| 1664 | - { |
|
| 1665 | - if (preg_match('/'.$forbiddenphpcommand.'\s*\(/ms', $phpfullcodestring)) |
|
| 1666 | - { |
|
| 1667 | - $error++; |
|
| 1668 | - setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpcommand), null, 'errors'); |
|
| 1669 | - if ($action == 'updatesource') $action = 'editsource'; |
|
| 1670 | - if ($action == 'updatecontent') $action = 'editcontent'; |
|
| 1671 | - } |
|
| 1672 | - } |
|
| 1673 | - |
|
| 1674 | - if (empty($user->rights->website->writephp)) |
|
| 1675 | - { |
|
| 1676 | - if ($phpfullcodestringold != $phpfullcodestring) |
|
| 1677 | - { |
|
| 1678 | - $error++; |
|
| 1679 | - setEventMessages($langs->trans("NotAllowedToAddDynamicContent"), null, 'errors'); |
|
| 1680 | - if ($action == 'updatesource') $action = 'editsource'; |
|
| 1681 | - if ($action == 'updatecontent') $action = 'editcontent'; |
|
| 1682 | - } |
|
| 1683 | - } |
|
| 1658 | + $forbiddenphpcommands=array("exec", "passthru", "system", "shell_exec", "proc_open"); |
|
| 1659 | + if (empty($conf->global->WEBSITE_PHP_ALLOW_WRITE)) // If option is not on, we disallow functions to write files |
|
| 1660 | + { |
|
| 1661 | + $forbiddenphpcommands=array_merge($forbiddenphpcommands, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask")); |
|
| 1662 | + } |
|
| 1663 | + foreach($forbiddenphpcommands as $forbiddenphpcommand) |
|
| 1664 | + { |
|
| 1665 | + if (preg_match('/'.$forbiddenphpcommand.'\s*\(/ms', $phpfullcodestring)) |
|
| 1666 | + { |
|
| 1667 | + $error++; |
|
| 1668 | + setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpcommand), null, 'errors'); |
|
| 1669 | + if ($action == 'updatesource') $action = 'editsource'; |
|
| 1670 | + if ($action == 'updatecontent') $action = 'editcontent'; |
|
| 1671 | + } |
|
| 1672 | + } |
|
| 1673 | + |
|
| 1674 | + if (empty($user->rights->website->writephp)) |
|
| 1675 | + { |
|
| 1676 | + if ($phpfullcodestringold != $phpfullcodestring) |
|
| 1677 | + { |
|
| 1678 | + $error++; |
|
| 1679 | + setEventMessages($langs->trans("NotAllowedToAddDynamicContent"), null, 'errors'); |
|
| 1680 | + if ($action == 'updatesource') $action = 'editsource'; |
|
| 1681 | + if ($action == 'updatecontent') $action = 'editcontent'; |
|
| 1682 | + } |
|
| 1683 | + } |
|
| 1684 | 1684 | |
| 1685 | 1685 | // Clean data. We remove all the head section. |
| 1686 | 1686 | $objectpage->content = preg_replace('/<head>.*<\/head>/ims', '', $objectpage->content); |
@@ -2108,32 +2108,32 @@ discard block |
||
| 2108 | 2108 | $htmltext = ''; |
| 2109 | 2109 | if (empty($object->fk_default_home)) |
| 2110 | 2110 | { |
| 2111 | - $htmltext.= '<br><span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br><br>'; |
|
| 2111 | + $htmltext.= '<br><span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br><br>'; |
|
| 2112 | 2112 | } |
| 2113 | 2113 | elseif (empty($virtualurl)) |
| 2114 | 2114 | { |
| 2115 | - $htmltext.= '<br><span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>'; |
|
| 2115 | + $htmltext.= '<br><span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>'; |
|
| 2116 | 2116 | } |
| 2117 | 2117 | else |
| 2118 | 2118 | { |
| 2119 | - $htmltext.= '<br><center>'.$langs->trans("GoTo").' <a href="'.$virtualurl.'" target="_website">'.$virtualurl.'</a></center><br>'; |
|
| 2119 | + $htmltext.= '<br><center>'.$langs->trans("GoTo").' <a href="'.$virtualurl.'" target="_website">'.$virtualurl.'</a></center><br>'; |
|
| 2120 | 2120 | } |
| 2121 | 2121 | if (! empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) |
| 2122 | 2122 | { |
| 2123 | - $htmltext.= '<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER); |
|
| 2123 | + $htmltext.= '<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER); |
|
| 2124 | 2124 | } |
| 2125 | 2125 | else |
| 2126 | 2126 | { |
| 2127 | - $htmltext.=$langs->trans("SetHereVirtualHost", $dataroot); |
|
| 2128 | - $htmltext.='<br>'; |
|
| 2129 | - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); |
|
| 2130 | - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); |
|
| 2131 | - $htmltext.='<br>'; |
|
| 2132 | - $htmltext.='<br>'; |
|
| 2133 | - $htmltext.=$langs->trans("YouCanAlsoTestWithPHPS", $dataroot); |
|
| 2134 | - $htmltext.='<br>'; |
|
| 2135 | - $htmltext.='<br>'; |
|
| 2136 | - $htmltext.=$langs->trans("YouCanAlsoDeployToAnotherWHP"); |
|
| 2127 | + $htmltext.=$langs->trans("SetHereVirtualHost", $dataroot); |
|
| 2128 | + $htmltext.='<br>'; |
|
| 2129 | + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); |
|
| 2130 | + $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); |
|
| 2131 | + $htmltext.='<br>'; |
|
| 2132 | + $htmltext.='<br>'; |
|
| 2133 | + $htmltext.=$langs->trans("YouCanAlsoTestWithPHPS", $dataroot); |
|
| 2134 | + $htmltext.='<br>'; |
|
| 2135 | + $htmltext.='<br>'; |
|
| 2136 | + $htmltext.=$langs->trans("YouCanAlsoDeployToAnotherWHP"); |
|
| 2137 | 2137 | } |
| 2138 | 2138 | print $form->textwithpicto($linktotestonwebserver, $htmltext, 1, 'none', 'valignmiddle', 0, 3, 'helpvirtualhost'); |
| 2139 | 2139 | print '</span>'; |
@@ -2441,15 +2441,15 @@ discard block |
||
| 2441 | 2441 | if (GETPOST('editsource', 'alpha') || GETPOST('editcontent', 'alpha')) |
| 2442 | 2442 | { |
| 2443 | 2443 | $htmltext=$langs->transnoentitiesnoconv("YouCanEditHtmlSource").'<br>'; |
| 2444 | - if ($conf->browser->layout == 'phone') |
|
| 2445 | - { |
|
| 2446 | - print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block', 1, 2, 'tooltipsubstitution'); |
|
| 2447 | - } |
|
| 2448 | - else |
|
| 2449 | - { |
|
| 2450 | - //img_help(($tooltiptrigger != '' ? 2 : 1), $alt) |
|
| 2451 | - print $form->textwithpicto($langs->trans("SyntaxHelp").' '.img_help(2, $langs->trans("SyntaxHelp")), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution'); |
|
| 2452 | - } |
|
| 2444 | + if ($conf->browser->layout == 'phone') |
|
| 2445 | + { |
|
| 2446 | + print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block', 1, 2, 'tooltipsubstitution'); |
|
| 2447 | + } |
|
| 2448 | + else |
|
| 2449 | + { |
|
| 2450 | + //img_help(($tooltiptrigger != '' ? 2 : 1), $alt) |
|
| 2451 | + print $form->textwithpicto($langs->trans("SyntaxHelp").' '.img_help(2, $langs->trans("SyntaxHelp")), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution'); |
|
| 2452 | + } |
|
| 2453 | 2453 | } |
| 2454 | 2454 | print '</span>'; // end websitehelp |
| 2455 | 2455 | |
@@ -3080,8 +3080,8 @@ discard block |
||
| 3080 | 3080 | print '</td><td>'; |
| 3081 | 3081 | if ($pageauthorid > 0) |
| 3082 | 3082 | { |
| 3083 | - $fuser->fetch($pageauthorid); |
|
| 3084 | - print $fuser->getNomUrl(1); |
|
| 3083 | + $fuser->fetch($pageauthorid); |
|
| 3084 | + print $fuser->getNomUrl(1); |
|
| 3085 | 3085 | } |
| 3086 | 3086 | print '</td></tr>'; |
| 3087 | 3087 | |
@@ -3094,17 +3094,17 @@ discard block |
||
| 3094 | 3094 | |
| 3095 | 3095 | if ($action != 'createcontainer') |
| 3096 | 3096 | { |
| 3097 | - print '<tr><td>'; |
|
| 3098 | - print $langs->trans('UserModif'); |
|
| 3099 | - print '</td><td>'; |
|
| 3100 | - if ($pageusermodifid > 0) |
|
| 3101 | - { |
|
| 3102 | - $fuser->fetch($pageusermodifid); |
|
| 3103 | - print $fuser->getNomUrl(1); |
|
| 3104 | - } |
|
| 3105 | - print '</td></tr>'; |
|
| 3097 | + print '<tr><td>'; |
|
| 3098 | + print $langs->trans('UserModif'); |
|
| 3099 | + print '</td><td>'; |
|
| 3100 | + if ($pageusermodifid > 0) |
|
| 3101 | + { |
|
| 3102 | + $fuser->fetch($pageusermodifid); |
|
| 3103 | + print $fuser->getNomUrl(1); |
|
| 3104 | + } |
|
| 3105 | + print '</td></tr>'; |
|
| 3106 | 3106 | |
| 3107 | - print '<tr><td>'; |
|
| 3107 | + print '<tr><td>'; |
|
| 3108 | 3108 | print $langs->trans('DateModification'); |
| 3109 | 3109 | print '</td><td>'; |
| 3110 | 3110 | print dol_print_date($pagedatemodification, 'dayhour', 'tzuser'); |
@@ -3462,7 +3462,7 @@ discard block |
||
| 3462 | 3462 | // Change the contenteditable to "true" or "false" when mode Edit Inline is on or off |
| 3463 | 3463 | if (empty($conf->global->WEBSITE_EDITINLINE)) |
| 3464 | 3464 | { |
| 3465 | - // Remove the contenteditable="true" |
|
| 3465 | + // Remove the contenteditable="true" |
|
| 3466 | 3466 | $newcontent = preg_replace('/(div|section)(\s[^\>]*)contenteditable="true"/', '\1\2', $newcontent); |
| 3467 | 3467 | } |
| 3468 | 3468 | else |
@@ -39,53 +39,53 @@ discard block |
||
| 39 | 39 | require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; |
| 40 | 40 | require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; |
| 41 | 41 | |
| 42 | -$langs->loadLangs(array("admin","other","website","errors")); |
|
| 42 | +$langs->loadLangs(array("admin", "other", "website", "errors")); |
|
| 43 | 43 | |
| 44 | -if (! $user->rights->website->read) accessforbidden(); |
|
| 44 | +if (!$user->rights->website->read) accessforbidden(); |
|
| 45 | 45 | |
| 46 | -$conf->dol_hide_leftmenu = 1; // Force hide of left menu. |
|
| 46 | +$conf->dol_hide_leftmenu = 1; // Force hide of left menu. |
|
| 47 | 47 | |
| 48 | -$error=0; |
|
| 49 | -$websiteid=GETPOST('websiteid', 'int'); |
|
| 50 | -$websitekey=GETPOST('website', 'alpha'); |
|
| 51 | -$page=GETPOST('page', 'alpha'); |
|
| 52 | -$pageid=GETPOST('pageid', 'int'); |
|
| 53 | -$pageref=GETPOST('pageref', 'aZ09'); |
|
| 54 | -$action=GETPOST('action', 'aZ09'); |
|
| 55 | -$confirm=GETPOST('confirm', 'alpha'); |
|
| 56 | -$cancel=GETPOST('cancel', 'alpha'); |
|
| 57 | -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'bomlist'; // To manage different context of search |
|
| 58 | -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page |
|
| 59 | -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') |
|
| 48 | +$error = 0; |
|
| 49 | +$websiteid = GETPOST('websiteid', 'int'); |
|
| 50 | +$websitekey = GETPOST('website', 'alpha'); |
|
| 51 | +$page = GETPOST('page', 'alpha'); |
|
| 52 | +$pageid = GETPOST('pageid', 'int'); |
|
| 53 | +$pageref = GETPOST('pageref', 'aZ09'); |
|
| 54 | +$action = GETPOST('action', 'aZ09'); |
|
| 55 | +$confirm = GETPOST('confirm', 'alpha'); |
|
| 56 | +$cancel = GETPOST('cancel', 'alpha'); |
|
| 57 | +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomlist'; // To manage different context of search |
|
| 58 | +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page |
|
| 59 | +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') |
|
| 60 | 60 | |
| 61 | -$type_container=GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'); |
|
| 61 | +$type_container = GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'); |
|
| 62 | 62 | |
| 63 | 63 | $section_dir = GETPOST('section_dir', 'alpha'); |
| 64 | 64 | $file_manager = GETPOST('file_manager', 'alpha'); |
| 65 | 65 | $replacesite = GETPOST('replacesite', 'alpha'); |
| 66 | 66 | |
| 67 | -if (GETPOST('deletesite', 'alpha')) { $action='deletesite'; } |
|
| 68 | -if (GETPOST('delete', 'alpha')) { $action='delete'; } |
|
| 69 | -if (GETPOST('preview', 'alpha')) $action='preview'; |
|
| 70 | -if (GETPOST('createsite', 'alpha')) { $action='createsite'; } |
|
| 71 | -if (GETPOST('createcontainer', 'alpha')) { $action='createcontainer'; } |
|
| 72 | -if (GETPOST('editcss', 'alpha')) { $action='editcss'; } |
|
| 73 | -if (GETPOST('editmenu', 'alpha')) { $action='editmenu'; } |
|
| 74 | -if (GETPOST('setashome', 'alpha')) { $action='setashome'; } |
|
| 75 | -if (GETPOST('editmeta', 'alpha')) { $action='editmeta'; } |
|
| 76 | -if (GETPOST('editsource', 'alpha')) { $action='editsource'; } |
|
| 77 | -if (GETPOST('editcontent', 'alpha')) { $action='editcontent'; } |
|
| 78 | -if (GETPOST('exportsite', 'alpha')) { $action='exportsite'; } |
|
| 79 | -if (GETPOST('importsite', 'alpha')) { $action='importsite'; } |
|
| 80 | -if (GETPOST('createfromclone', 'alpha')) { $action='createfromclone'; } |
|
| 81 | -if (GETPOST('createpagefromclone', 'alpha')) { $action='createpagefromclone'; } |
|
| 82 | -if (empty($action) && $file_manager) $action='file_manager'; |
|
| 83 | -if (empty($action) && $replacesite) $action='replacesite'; |
|
| 67 | +if (GETPOST('deletesite', 'alpha')) { $action = 'deletesite'; } |
|
| 68 | +if (GETPOST('delete', 'alpha')) { $action = 'delete'; } |
|
| 69 | +if (GETPOST('preview', 'alpha')) $action = 'preview'; |
|
| 70 | +if (GETPOST('createsite', 'alpha')) { $action = 'createsite'; } |
|
| 71 | +if (GETPOST('createcontainer', 'alpha')) { $action = 'createcontainer'; } |
|
| 72 | +if (GETPOST('editcss', 'alpha')) { $action = 'editcss'; } |
|
| 73 | +if (GETPOST('editmenu', 'alpha')) { $action = 'editmenu'; } |
|
| 74 | +if (GETPOST('setashome', 'alpha')) { $action = 'setashome'; } |
|
| 75 | +if (GETPOST('editmeta', 'alpha')) { $action = 'editmeta'; } |
|
| 76 | +if (GETPOST('editsource', 'alpha')) { $action = 'editsource'; } |
|
| 77 | +if (GETPOST('editcontent', 'alpha')) { $action = 'editcontent'; } |
|
| 78 | +if (GETPOST('exportsite', 'alpha')) { $action = 'exportsite'; } |
|
| 79 | +if (GETPOST('importsite', 'alpha')) { $action = 'importsite'; } |
|
| 80 | +if (GETPOST('createfromclone', 'alpha')) { $action = 'createfromclone'; } |
|
| 81 | +if (GETPOST('createpagefromclone', 'alpha')) { $action = 'createpagefromclone'; } |
|
| 82 | +if (empty($action) && $file_manager) $action = 'file_manager'; |
|
| 83 | +if (empty($action) && $replacesite) $action = 'replacesite'; |
|
| 84 | 84 | |
| 85 | 85 | if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x')) $pageid = 0; |
| 86 | 86 | |
| 87 | 87 | // Load variable for pagination |
| 88 | -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; |
|
| 88 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
| 89 | 89 | $sortfield = GETPOST("sortfield", 'alpha'); |
| 90 | 90 | $sortorder = GETPOST("sortorder", 'alpha'); |
| 91 | 91 | $page = GETPOST("page", 'int'); |
@@ -96,19 +96,19 @@ discard block |
||
| 96 | 96 | //if (! $sortfield) $sortfield='name'; |
| 97 | 97 | //if (! $sortorder) $sortorder='ASC'; |
| 98 | 98 | |
| 99 | -if (empty($action)) $action='preview'; |
|
| 99 | +if (empty($action)) $action = 'preview'; |
|
| 100 | 100 | |
| 101 | -$object=new Website($db); |
|
| 102 | -$objectpage=new WebsitePage($db); |
|
| 101 | +$object = new Website($db); |
|
| 102 | +$objectpage = new WebsitePage($db); |
|
| 103 | 103 | |
| 104 | -$object->fetchAll(); // Init $object->records with list of websites |
|
| 104 | +$object->fetchAll(); // Init $object->records with list of websites |
|
| 105 | 105 | |
| 106 | 106 | // If website not defined, we take first found |
| 107 | -if (! ($websiteid > 0) && empty($websitekey)) |
|
| 107 | +if (!($websiteid > 0) && empty($websitekey)) |
|
| 108 | 108 | { |
| 109 | - foreach($object->records as $key => $valwebsite) |
|
| 109 | + foreach ($object->records as $key => $valwebsite) |
|
| 110 | 110 | { |
| 111 | - $websitekey=$valwebsite->ref; |
|
| 111 | + $websitekey = $valwebsite->ref; |
|
| 112 | 112 | break; |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -137,15 +137,15 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | if ($object->fk_default_home > 0) |
| 139 | 139 | { |
| 140 | - $res = $objectpage->fetch($object->fk_default_home, $object->id, ''); // We search first page of web site |
|
| 140 | + $res = $objectpage->fetch($object->fk_default_home, $object->id, ''); // We search first page of web site |
|
| 141 | 141 | if ($res > 0) $pageid = $object->fk_default_home; |
| 142 | 142 | } |
| 143 | 143 | else |
| 144 | 144 | { |
| 145 | - $res = $objectpage->fetch(0, $object->id, ''); // We search first page of web site |
|
| 145 | + $res = $objectpage->fetch(0, $object->id, ''); // We search first page of web site |
|
| 146 | 146 | if ($res == 0) // Page was not found, we reset it |
| 147 | 147 | { |
| 148 | - $objectpage=new WebsitePage($db); |
|
| 148 | + $objectpage = new WebsitePage($db); |
|
| 149 | 149 | } |
| 150 | 150 | else // We found a page, we set pageid to it. |
| 151 | 151 | { |
@@ -166,61 +166,61 @@ discard block |
||
| 166 | 166 | $pageid = $object->fk_default_home; |
| 167 | 167 | if (empty($pageid)) |
| 168 | 168 | { |
| 169 | - $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); |
|
| 170 | - if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 171 | - $atleastonepage=(is_array($array) && count($array) > 0); |
|
| 169 | + $array = $objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); |
|
| 170 | + if (!is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 171 | + $atleastonepage = (is_array($array) && count($array) > 0); |
|
| 172 | 172 | |
| 173 | - $firstpageid=0;$homepageid=0; |
|
| 174 | - foreach($array as $key => $valpage) |
|
| 173 | + $firstpageid = 0; $homepageid = 0; |
|
| 174 | + foreach ($array as $key => $valpage) |
|
| 175 | 175 | { |
| 176 | - if (empty($firstpageid)) $firstpageid=$valpage->id; |
|
| 177 | - if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; |
|
| 176 | + if (empty($firstpageid)) $firstpageid = $valpage->id; |
|
| 177 | + if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid = $valpage->id; |
|
| 178 | 178 | } |
| 179 | - $pageid=($homepageid?$homepageid:$firstpageid); // We choose home page and if not defined yet, we take first page |
|
| 179 | + $pageid = ($homepageid ? $homepageid : $firstpageid); // We choose home page and if not defined yet, we take first page |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | |
| 184 | 184 | global $dolibarr_main_data_root; |
| 185 | -$pathofwebsite=$dolibarr_main_data_root.'/website/'.$websitekey; |
|
| 186 | -$filehtmlheader=$pathofwebsite.'/htmlheader.html'; |
|
| 187 | -$filecss=$pathofwebsite.'/styles.css.php'; |
|
| 188 | -$filejs=$pathofwebsite.'/javascript.js.php'; |
|
| 189 | -$filerobot=$pathofwebsite.'/robots.txt'; |
|
| 190 | -$filehtaccess=$pathofwebsite.'/.htaccess'; |
|
| 191 | -$filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; |
|
| 192 | -$fileindex=$pathofwebsite.'/index.php'; |
|
| 193 | -$filewrapper=$pathofwebsite.'/wrapper.php'; |
|
| 194 | -$filemanifestjson=$pathofwebsite.'/manifest.json.php'; |
|
| 195 | -$filereadme=$pathofwebsite.'/README.md'; |
|
| 185 | +$pathofwebsite = $dolibarr_main_data_root.'/website/'.$websitekey; |
|
| 186 | +$filehtmlheader = $pathofwebsite.'/htmlheader.html'; |
|
| 187 | +$filecss = $pathofwebsite.'/styles.css.php'; |
|
| 188 | +$filejs = $pathofwebsite.'/javascript.js.php'; |
|
| 189 | +$filerobot = $pathofwebsite.'/robots.txt'; |
|
| 190 | +$filehtaccess = $pathofwebsite.'/.htaccess'; |
|
| 191 | +$filetpl = $pathofwebsite.'/page'.$pageid.'.tpl.php'; |
|
| 192 | +$fileindex = $pathofwebsite.'/index.php'; |
|
| 193 | +$filewrapper = $pathofwebsite.'/wrapper.php'; |
|
| 194 | +$filemanifestjson = $pathofwebsite.'/manifest.json.php'; |
|
| 195 | +$filereadme = $pathofwebsite.'/README.md'; |
|
| 196 | 196 | |
| 197 | 197 | // Define $urlwithroot |
| 198 | -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); |
|
| 199 | -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
| 198 | +$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); |
|
| 199 | +$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
| 200 | 200 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
| 201 | 201 | |
| 202 | 202 | |
| 203 | 203 | $permtouploadfile = $user->rights->website->write; |
| 204 | 204 | $diroutput = $conf->medias->multidir_output[$conf->entity]; |
| 205 | 205 | |
| 206 | -$relativepath=$section_dir; |
|
| 206 | +$relativepath = $section_dir; |
|
| 207 | 207 | $upload_dir = $diroutput.'/'.$relativepath; |
| 208 | 208 | |
| 209 | 209 | $htmlheadercontentdefault = ''; |
| 210 | -$htmlheadercontentdefault.='<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700" />'."\n"; |
|
| 211 | -$htmlheadercontentdefault.='<link rel="stylesheet" id="font-wasesome-css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />'."\n"; |
|
| 212 | -$htmlheadercontentdefault.='<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>'."\n"; |
|
| 213 | -$htmlheadercontentdefault.='<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>'."\n"; |
|
| 214 | -$htmlheadercontentdefault.='<script src="//cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>'."\n"; |
|
| 215 | -$htmlheadercontentdefault.='<script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.13.0/umd/popper.min.js"></script>'."\n"; |
|
| 216 | -$htmlheadercontentdefault.='<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>'."\n"; |
|
| 217 | -$htmlheadercontentdefault.='<!--'."\n"; |
|
| 218 | -$htmlheadercontentdefault.='<script src="/document.php?modulepart=medias&file=css/myfile.css"></script>'."\n"; |
|
| 219 | -$htmlheadercontentdefault.='<script src="/document.php?modulepart=medias&file=js/myfile.js"></script>'."\n"; |
|
| 220 | -$htmlheadercontentdefault.='-->'."\n"; |
|
| 210 | +$htmlheadercontentdefault .= '<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700" />'."\n"; |
|
| 211 | +$htmlheadercontentdefault .= '<link rel="stylesheet" id="font-wasesome-css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />'."\n"; |
|
| 212 | +$htmlheadercontentdefault .= '<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>'."\n"; |
|
| 213 | +$htmlheadercontentdefault .= '<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>'."\n"; |
|
| 214 | +$htmlheadercontentdefault .= '<script src="//cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>'."\n"; |
|
| 215 | +$htmlheadercontentdefault .= '<script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.13.0/umd/popper.min.js"></script>'."\n"; |
|
| 216 | +$htmlheadercontentdefault .= '<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>'."\n"; |
|
| 217 | +$htmlheadercontentdefault .= '<!--'."\n"; |
|
| 218 | +$htmlheadercontentdefault .= '<script src="/document.php?modulepart=medias&file=css/myfile.css"></script>'."\n"; |
|
| 219 | +$htmlheadercontentdefault .= '<script src="/document.php?modulepart=medias&file=js/myfile.js"></script>'."\n"; |
|
| 220 | +$htmlheadercontentdefault .= '-->'."\n"; |
|
| 221 | 221 | |
| 222 | 222 | $manifestjsoncontentdefault = ''; |
| 223 | -$manifestjsoncontentdefault.= '{ |
|
| 223 | +$manifestjsoncontentdefault .= '{ |
|
| 224 | 224 | "name": "MyWebsite", |
| 225 | 225 | "short_name": "MyWebsite", |
| 226 | 226 | "start_url": "/", |
@@ -266,9 +266,9 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | |
| 268 | 268 | // Protections |
| 269 | -if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) |
|
| 269 | +if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) |
|
| 270 | 270 | { |
| 271 | - $action = 'preview'; // To avoid to make an action on another page or another site when we click on button to select another site or page. |
|
| 271 | + $action = 'preview'; // To avoid to make an action on another page or another site when we click on button to select another site or page. |
|
| 272 | 272 | } |
| 273 | 273 | if (GETPOST('refreshsite', 'alpha') || GETPOST('refreshsite.x', 'alpha') || GETPOST('refreshsite_x', 'alpha')) // If we change the site, we reset the pageid and cancel addsite action. |
| 274 | 274 | { |
@@ -278,20 +278,20 @@ discard block |
||
| 278 | 278 | $pageid = $object->fk_default_home; |
| 279 | 279 | if (empty($pageid)) |
| 280 | 280 | { |
| 281 | - $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); |
|
| 282 | - if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 283 | - $atleastonepage=(is_array($array) && count($array) > 0); |
|
| 281 | + $array = $objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); |
|
| 282 | + if (!is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 283 | + $atleastonepage = (is_array($array) && count($array) > 0); |
|
| 284 | 284 | |
| 285 | - $firstpageid=0; $homepageid=0; |
|
| 286 | - foreach($array as $key => $valpage) |
|
| 285 | + $firstpageid = 0; $homepageid = 0; |
|
| 286 | + foreach ($array as $key => $valpage) |
|
| 287 | 287 | { |
| 288 | - if (empty($firstpageid)) $firstpageid=$valpage->id; |
|
| 289 | - if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; |
|
| 288 | + if (empty($firstpageid)) $firstpageid = $valpage->id; |
|
| 289 | + if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid = $valpage->id; |
|
| 290 | 290 | } |
| 291 | - $pageid=($homepageid?$homepageid:$firstpageid); // We choose home page and if not defined yet, we take first page |
|
| 291 | + $pageid = ($homepageid ? $homepageid : $firstpageid); // We choose home page and if not defined yet, we take first page |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | -if (GETPOST('refreshpage', 'alpha') && ! in_array($action, array('updatecss'))) $action='preview'; |
|
| 294 | +if (GETPOST('refreshpage', 'alpha') && !in_array($action, array('updatecss'))) $action = 'preview'; |
|
| 295 | 295 | |
| 296 | 296 | // Cancel |
| 297 | 297 | if ($cancel) |
@@ -305,17 +305,17 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | $savbacktopage = $backtopage; |
| 308 | -$backtopage = $_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid.(GETPOST('section_dir', 'alpha')?'§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')):''); // used after a confirm_deletefile into actions_linkedfiles.inc.php |
|
| 308 | +$backtopage = $_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid.(GETPOST('section_dir', 'alpha') ? '§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')) : ''); // used after a confirm_deletefile into actions_linkedfiles.inc.php |
|
| 309 | 309 | include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; |
| 310 | 310 | $backtopage = $savbacktopage; |
| 311 | 311 | |
| 312 | -if ($action == 'renamefile') $action='file_manager'; // After actions_linkedfiles, if action were renamefile, we set it to 'file_manager' |
|
| 312 | +if ($action == 'renamefile') $action = 'file_manager'; // After actions_linkedfiles, if action were renamefile, we set it to 'file_manager' |
|
| 313 | 313 | |
| 314 | 314 | if ($action == 'seteditinline') |
| 315 | 315 | { |
| 316 | 316 | dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 1); |
| 317 | 317 | setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'warnings'); |
| 318 | - dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 0); // Force disable of 'Include dynamic content' |
|
| 318 | + dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 0); // Force disable of 'Include dynamic content' |
|
| 319 | 319 | header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int')); |
| 320 | 320 | exit; |
| 321 | 321 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | if ($action == 'setshowsubcontainers') |
| 329 | 329 | { |
| 330 | 330 | dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 1); |
| 331 | - dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 0); // Force disable of edit inline |
|
| 331 | + dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 0); // Force disable of edit inline |
|
| 332 | 332 | header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int')); |
| 333 | 333 | exit; |
| 334 | 334 | } |
@@ -374,28 +374,28 @@ discard block |
||
| 374 | 374 | { |
| 375 | 375 | $db->begin(); |
| 376 | 376 | |
| 377 | - if (GETPOST('virtualhost', 'alpha') && ! preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) |
|
| 377 | + if (GETPOST('virtualhost', 'alpha') && !preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) |
|
| 378 | 378 | { |
| 379 | 379 | $error++; |
| 380 | 380 | setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - if (! $error && ! GETPOST('WEBSITE_REF', 'alpha')) |
|
| 383 | + if (!$error && !GETPOST('WEBSITE_REF', 'alpha')) |
|
| 384 | 384 | { |
| 385 | 385 | $error++; |
| 386 | 386 | $langs->load("errors"); |
| 387 | 387 | setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); |
| 388 | 388 | } |
| 389 | - if (! $error && ! preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST('WEBSITE_REF', 'alpha'))) |
|
| 389 | + if (!$error && !preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST('WEBSITE_REF', 'alpha'))) |
|
| 390 | 390 | { |
| 391 | 391 | $error++; |
| 392 | 392 | $langs->load("errors"); |
| 393 | 393 | setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("Ref")), null, 'errors'); |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - if (! $error) |
|
| 396 | + if (!$error) |
|
| 397 | 397 | { |
| 398 | - $tmpobject=new Website($db); |
|
| 398 | + $tmpobject = new Website($db); |
|
| 399 | 399 | $tmpobject->ref = GETPOST('WEBSITE_REF', 'alpha'); |
| 400 | 400 | $tmpobject->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); |
| 401 | 401 | $tmpobject->virtualhost = GETPOST('virtualhost', 'alpha'); |
@@ -408,11 +408,11 @@ discard block |
||
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if (! $error) |
|
| 411 | + if (!$error) |
|
| 412 | 412 | { |
| 413 | 413 | $db->commit(); |
| 414 | 414 | setEventMessages($langs->trans("SiteAdded", $object->ref), null, 'mesgs'); |
| 415 | - $action=''; |
|
| 415 | + $action = ''; |
|
| 416 | 416 | |
| 417 | 417 | header("Location: ".$_SERVER["PHP_SELF"].'?website='.$tmpobject->ref); |
| 418 | 418 | exit; |
@@ -420,10 +420,10 @@ discard block |
||
| 420 | 420 | else |
| 421 | 421 | { |
| 422 | 422 | $db->rollback(); |
| 423 | - $action='createsite'; |
|
| 423 | + $action = 'createsite'; |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - if (! $error) |
|
| 426 | + if (!$error) |
|
| 427 | 427 | { |
| 428 | 428 | $action = 'preview'; |
| 429 | 429 | $id = $object->id; |
@@ -440,9 +440,9 @@ discard block |
||
| 440 | 440 | $objectpage->fk_website = $object->id; |
| 441 | 441 | if (GETPOSTISSET('fetchexternalurl')) |
| 442 | 442 | { |
| 443 | - $urltograb=GETPOST('externalurl', 'alpha'); |
|
| 444 | - $grabimages=GETPOST('grabimages', 'alpha'); |
|
| 445 | - $grabimagesinto=GETPOST('grabimagesinto', 'alpha'); |
|
| 443 | + $urltograb = GETPOST('externalurl', 'alpha'); |
|
| 444 | + $grabimages = GETPOST('grabimages', 'alpha'); |
|
| 445 | + $grabimagesinto = GETPOST('grabimagesinto', 'alpha'); |
|
| 446 | 446 | //var_dump($grabimages);exit; |
| 447 | 447 | } |
| 448 | 448 | |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors'); |
| 458 | 458 | $action = 'createcontainer'; |
| 459 | 459 | } |
| 460 | - elseif (! preg_match('/^http/', $urltograb)) |
|
| 460 | + elseif (!preg_match('/^http/', $urltograb)) |
|
| 461 | 461 | { |
| 462 | 462 | $error++; |
| 463 | 463 | $langs->load("errors"); |
@@ -465,16 +465,16 @@ discard block |
||
| 465 | 465 | $action = 'createcontainer'; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if (! $error) |
|
| 468 | + if (!$error) |
|
| 469 | 469 | { |
| 470 | 470 | // Clean url to grab, so url can be |
| 471 | 471 | // http://www.example.com/ or http://www.example.com/dir1/ or http://www.example.com/dir1/aaa |
| 472 | 472 | $urltograbwithoutdomainandparam = preg_replace('/^https?:\/\/[^\/]+\/?/i', '', $urltograb); |
| 473 | 473 | //$urltograbwithoutdomainandparam = preg_replace('/^file:\/\/[^\/]+\/?/i', '', $urltograb); |
| 474 | 474 | $urltograbwithoutdomainandparam = preg_replace('/\?.*$/', '', $urltograbwithoutdomainandparam); |
| 475 | - if (empty($urltograbwithoutdomainandparam) && ! preg_match('/\/$/', $urltograb)) |
|
| 475 | + if (empty($urltograbwithoutdomainandparam) && !preg_match('/\/$/', $urltograb)) |
|
| 476 | 476 | { |
| 477 | - $urltograb.='/'; |
|
| 477 | + $urltograb .= '/'; |
|
| 478 | 478 | } |
| 479 | 479 | $pageurl = dol_sanitizeFileName(preg_replace('/[\/\.]/', '-', preg_replace('/\/+$/', '', $urltograbwithoutdomainandparam))); |
| 480 | 480 | |
@@ -493,31 +493,31 @@ discard block |
||
| 493 | 493 | { |
| 494 | 494 | setEventMessages($langs->trans("AliasPageAlreadyExists", $pageurl), null, 'errors'); |
| 495 | 495 | $error++; |
| 496 | - $action='createcontainer'; |
|
| 496 | + $action = 'createcontainer'; |
|
| 497 | 497 | } |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - if (! $error) |
|
| 500 | + if (!$error) |
|
| 501 | 501 | { |
| 502 | 502 | $tmp = getURLContent($urltograb); |
| 503 | 503 | if ($tmp['curl_error_no']) |
| 504 | 504 | { |
| 505 | 505 | $error++; |
| 506 | 506 | setEventMessages('Error getting '.$urltograb.': '.$tmp['curl_error_msg'], null, 'errors'); |
| 507 | - $action='createcontainer'; |
|
| 507 | + $action = 'createcontainer'; |
|
| 508 | 508 | } |
| 509 | 509 | elseif ($tmp['http_code'] != '200') |
| 510 | 510 | { |
| 511 | 511 | $error++; |
| 512 | 512 | setEventMessages('Error getting '.$urltograb.': '.$tmp['http_code'], null, 'errors'); |
| 513 | - $action='createcontainer'; |
|
| 513 | + $action = 'createcontainer'; |
|
| 514 | 514 | } |
| 515 | 515 | else |
| 516 | 516 | { |
| 517 | 517 | // Remove comments |
| 518 | 518 | $tmp['content'] = removeHtmlComment($tmp['content']); |
| 519 | 519 | |
| 520 | - $regs=array(); |
|
| 520 | + $regs = array(); |
|
| 521 | 521 | |
| 522 | 522 | preg_match('/<head>(.*)<\/head>/ims', $tmp['content'], $regs); |
| 523 | 523 | $head = $regs[1]; |
@@ -527,21 +527,21 @@ discard block |
||
| 527 | 527 | if (empty($objectpage->pageurl)) |
| 528 | 528 | { |
| 529 | 529 | $tmpdomain = getDomainFromURL($urltograb); |
| 530 | - $objectpage->pageurl=$tmpdomain.'-home'; |
|
| 530 | + $objectpage->pageurl = $tmpdomain.'-home'; |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | $objectpage->aliasalt = ''; |
| 534 | 534 | |
| 535 | 535 | if (preg_match('/^(\d+)\-/', basename($urltograb), $regs)) $objectpage->aliasalt = $regs[1]; |
| 536 | 536 | |
| 537 | - $regtmp=array(); |
|
| 537 | + $regtmp = array(); |
|
| 538 | 538 | if (preg_match('/<title>(.*)<\/title>/ims', $head, $regtmp)) |
| 539 | 539 | { |
| 540 | 540 | $objectpage->title = $regtmp[1]; |
| 541 | 541 | } |
| 542 | 542 | if (preg_match('/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) |
| 543 | 543 | { |
| 544 | - if (empty($objectpage->title)) $objectpage->title = $regtmp[1]; // If title not found into <title>, we get it from <meta title> |
|
| 544 | + if (empty($objectpage->title)) $objectpage->title = $regtmp[1]; // If title not found into <title>, we get it from <meta title> |
|
| 545 | 545 | } |
| 546 | 546 | if (preg_match('/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) |
| 547 | 547 | { |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | } |
| 554 | 554 | if (preg_match('/<html\s+lang="([^"]+)"/ims', $tmp['content'], $regtmp)) |
| 555 | 555 | { |
| 556 | - $tmplang=explode('-', $regtmp[1]); |
|
| 556 | + $tmplang = explode('-', $regtmp[1]); |
|
| 557 | 557 | $objectpage->lang = $tmplang[0].($tmplang[1] ? '_'.strtoupper($tmplang[1]) : ''); |
| 558 | 558 | } |
| 559 | 559 | |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | $objectpage->content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $objectpage->content); |
| 564 | 564 | $objectpage->content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $objectpage->content); |
| 565 | 565 | |
| 566 | - $absoluteurlinaction=$urltograbdirwithoutslash; |
|
| 566 | + $absoluteurlinaction = $urltograbdirwithoutslash; |
|
| 567 | 567 | // TODO Replace 'action="$urltograbdirwithoutslash' into action="/" |
| 568 | 568 | // TODO Replace 'action="$urltograbdirwithoutslash..."' into action="..." |
| 569 | 569 | // TODO Replace 'a href="$urltograbdirwithoutslash' into a href="/" |
@@ -598,11 +598,11 @@ discard block |
||
| 598 | 598 | $linkwithoutdomain = $regs[2][$key]; |
| 599 | 599 | if (preg_match('/^\//', $regs[2][$key])) |
| 600 | 600 | { |
| 601 | - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
|
| 601 | + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
|
| 602 | 602 | } |
| 603 | 603 | else |
| 604 | 604 | { |
| 605 | - $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file |
|
| 605 | + $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; |
@@ -667,11 +667,11 @@ discard block |
||
| 667 | 667 | $linkwithoutdomain = $regs[2][$key]; |
| 668 | 668 | if (preg_match('/^\//', $regs[2][$key])) |
| 669 | 669 | { |
| 670 | - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
|
| 670 | + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
|
| 671 | 671 | } |
| 672 | 672 | else |
| 673 | 673 | { |
| 674 | - $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file |
|
| 674 | + $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; |
@@ -696,14 +696,14 @@ discard block |
||
| 696 | 696 | $errorforsubresource++; |
| 697 | 697 | setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); |
| 698 | 698 | dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']); |
| 699 | - $action='createcontainer'; |
|
| 699 | + $action = 'createcontainer'; |
|
| 700 | 700 | } |
| 701 | 701 | elseif ($tmpgeturl['http_code'] != '200') |
| 702 | 702 | { |
| 703 | 703 | $errorforsubresource++; |
| 704 | 704 | setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); |
| 705 | 705 | dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']); |
| 706 | - $action='createcontainer'; |
|
| 706 | + $action = 'createcontainer'; |
|
| 707 | 707 | } |
| 708 | 708 | else |
| 709 | 709 | { |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | // @chmod($file, octdec($conf->global->MAIN_UMASK)); |
| 727 | 727 | |
| 728 | 728 | // $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; |
| 729 | - $pagecsscontent.='/* Content of file '.$urltograbbis.' */'."\n"; |
|
| 729 | + $pagecsscontent .= '/* Content of file '.$urltograbbis.' */'."\n"; |
|
| 730 | 730 | |
| 731 | 731 | getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl['content'], $action, 1, $grabimages, $grabimagesinto); |
| 732 | 732 | |
@@ -738,19 +738,19 @@ discard block |
||
| 738 | 738 | $contentforlessc = $lesscobj->compile($contentforlessc); |
| 739 | 739 | //var_dump($contentforlessc); exit; |
| 740 | 740 | |
| 741 | - $pagecsscontent.=$contentforlessc."\n"; |
|
| 741 | + $pagecsscontent .= $contentforlessc."\n"; |
|
| 742 | 742 | //$pagecsscontent.=$tmpgeturl['content']."\n"; |
| 743 | 743 | } catch (exception $e) { |
| 744 | 744 | //echo "failed to compile lessc"; |
| 745 | 745 | dol_syslog("Failed to compile the CSS from URL ".$urltograbbis." with lessc: ".$e->getMessage(), LOG_WARNING); |
| 746 | - $pagecsscontent.=$tmpgeturl['content']."\n"; |
|
| 746 | + $pagecsscontent .= $tmpgeturl['content']."\n"; |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | $objectpage->htmlheader = preg_replace('/'.preg_quote($regs[0][$key], '/').'\n*/ims', '', $objectpage->htmlheader); |
| 750 | 750 | } |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | - $pagecsscontent.='</style>'; |
|
| 753 | + $pagecsscontent .= '</style>'; |
|
| 754 | 754 | //var_dump($pagecsscontent); |
| 755 | 755 | |
| 756 | 756 | //print dol_escape_htmltag($tmp);exit; |
@@ -786,11 +786,11 @@ discard block |
||
| 786 | 786 | $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); |
| 787 | 787 | $objectpage->htmlheader = GETPOST('htmlheader', 'none'); |
| 788 | 788 | |
| 789 | - $substitutionarray=array(); |
|
| 790 | - $substitutionarray['__WEBSITE_CREATE_BY__']=$user->getFullName($langs); |
|
| 789 | + $substitutionarray = array(); |
|
| 790 | + $substitutionarray['__WEBSITE_CREATE_BY__'] = $user->getFullName($langs); |
|
| 791 | 791 | |
| 792 | 792 | $sample = GETPOST('sample', 'alpha'); |
| 793 | - if (empty($sample)) $sample='empty'; |
|
| 793 | + if (empty($sample)) $sample = 'empty'; |
|
| 794 | 794 | |
| 795 | 795 | $pathtosample = DOL_DOCUMENT_ROOT.'/website/samples/page-sample-'.$sample.'.html'; |
| 796 | 796 | |
@@ -798,57 +798,57 @@ discard block |
||
| 798 | 798 | $objectpage->content = make_substitutions(@file_get_contents($pathtosample), $substitutionarray); |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - if (! $error) |
|
| 801 | + if (!$error) |
|
| 802 | 802 | { |
| 803 | 803 | if (empty($objectpage->pageurl)) |
| 804 | 804 | { |
| 805 | 805 | $langs->load("errors"); |
| 806 | 806 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors'); |
| 807 | 807 | $error++; |
| 808 | - $action='createcontainer'; |
|
| 808 | + $action = 'createcontainer'; |
|
| 809 | 809 | } |
| 810 | - elseif (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) |
|
| 810 | + elseif (!preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) |
|
| 811 | 811 | { |
| 812 | 812 | $langs->load("errors"); |
| 813 | 813 | setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); |
| 814 | 814 | $error++; |
| 815 | - $action='createcontainer'; |
|
| 815 | + $action = 'createcontainer'; |
|
| 816 | 816 | } |
| 817 | 817 | if (empty($objectpage->title)) |
| 818 | 818 | { |
| 819 | 819 | $langs->load("errors"); |
| 820 | 820 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE")), null, 'errors'); |
| 821 | 821 | $error++; |
| 822 | - $action='createcontainer'; |
|
| 822 | + $action = 'createcontainer'; |
|
| 823 | 823 | } |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | - if (! $error) |
|
| 826 | + if (!$error) |
|
| 827 | 827 | { |
| 828 | 828 | $res = $objectpage->create($user); |
| 829 | 829 | if ($res <= 0) |
| 830 | 830 | { |
| 831 | 831 | $error++; |
| 832 | 832 | setEventMessages($objectpage->error, $objectpage->errors, 'errors'); |
| 833 | - $action='createcontainer'; |
|
| 833 | + $action = 'createcontainer'; |
|
| 834 | 834 | } |
| 835 | 835 | } |
| 836 | - if (! $error) |
|
| 836 | + if (!$error) |
|
| 837 | 837 | { |
| 838 | - if (! empty($objectpage->content)) |
|
| 838 | + if (!empty($objectpage->content)) |
|
| 839 | 839 | { |
| 840 | - $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; |
|
| 841 | - $filetpl=$pathofwebsite.'/page'.$objectpage->id.'.tpl.php'; |
|
| 840 | + $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; |
|
| 841 | + $filetpl = $pathofwebsite.'/page'.$objectpage->id.'.tpl.php'; |
|
| 842 | 842 | |
| 843 | 843 | // Save page alias |
| 844 | - $result=dolSavePageAlias($filealias, $object, $objectpage); |
|
| 845 | - if (! $result) |
|
| 844 | + $result = dolSavePageAlias($filealias, $object, $objectpage); |
|
| 845 | + if (!$result) |
|
| 846 | 846 | { |
| 847 | 847 | setEventMessages('Failed to write file '.$filealias, null, 'errors'); |
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | // Save page of content |
| 851 | - $result=dolSavePageContent($filetpl, $object, $objectpage); |
|
| 851 | + $result = dolSavePageContent($filetpl, $object, $objectpage); |
|
| 852 | 852 | if ($result) |
| 853 | 853 | { |
| 854 | 854 | setEventMessages($langs->trans("Saved"), null, 'mesgs'); |
@@ -860,75 +860,75 @@ discard block |
||
| 860 | 860 | } |
| 861 | 861 | } |
| 862 | 862 | } |
| 863 | - if (! $error) |
|
| 863 | + if (!$error) |
|
| 864 | 864 | { |
| 865 | 865 | $db->commit(); |
| 866 | 866 | setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs'); |
| 867 | - $action=''; |
|
| 867 | + $action = ''; |
|
| 868 | 868 | } |
| 869 | 869 | else |
| 870 | 870 | { |
| 871 | 871 | $db->rollback(); |
| 872 | 872 | } |
| 873 | 873 | |
| 874 | - if (! $error) |
|
| 874 | + if (!$error) |
|
| 875 | 875 | { |
| 876 | 876 | $pageid = $objectpage->id; |
| 877 | 877 | |
| 878 | 878 | // To generate the CSS, robot and htmlheader file. |
| 879 | 879 | |
| 880 | 880 | // Check symlink to medias and restore it if ko |
| 881 | - $pathtomedias=DOL_DATA_ROOT.'/medias'; |
|
| 882 | - $pathtomediasinwebsite=$pathofwebsite.'/medias'; |
|
| 883 | - if (! is_link(dol_osencode($pathtomediasinwebsite))) |
|
| 881 | + $pathtomedias = DOL_DATA_ROOT.'/medias'; |
|
| 882 | + $pathtomediasinwebsite = $pathofwebsite.'/medias'; |
|
| 883 | + if (!is_link(dol_osencode($pathtomediasinwebsite))) |
|
| 884 | 884 | { |
| 885 | 885 | dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); |
| 886 | - dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists |
|
| 886 | + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists |
|
| 887 | 887 | $result = symlink($pathtomedias, $pathtomediasinwebsite); |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - if (! dol_is_file($filehtmlheader)) |
|
| 890 | + if (!dol_is_file($filehtmlheader)) |
|
| 891 | 891 | { |
| 892 | - $htmlheadercontent ="<html>\n"; |
|
| 893 | - $htmlheadercontent.=$htmlheadercontentdefault; |
|
| 894 | - $htmlheadercontent.="</html>"; |
|
| 895 | - $result=dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); |
|
| 892 | + $htmlheadercontent = "<html>\n"; |
|
| 893 | + $htmlheadercontent .= $htmlheadercontentdefault; |
|
| 894 | + $htmlheadercontent .= "</html>"; |
|
| 895 | + $result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); |
|
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - if (! dol_is_file($filecss)) |
|
| 898 | + if (!dol_is_file($filecss)) |
|
| 899 | 899 | { |
| 900 | 900 | $csscontent = "/* CSS content (all pages) */\nbody.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}"; |
| 901 | - $result=dolSaveCssFile($filecss, $csscontent); |
|
| 901 | + $result = dolSaveCssFile($filecss, $csscontent); |
|
| 902 | 902 | } |
| 903 | 903 | |
| 904 | - if (! dol_is_file($filejs)) |
|
| 904 | + if (!dol_is_file($filejs)) |
|
| 905 | 905 | { |
| 906 | 906 | $jscontent = "/* JS content (all pages) */\n"; |
| 907 | - $result=dolSaveJsFile($filejs, $jscontent); |
|
| 907 | + $result = dolSaveJsFile($filejs, $jscontent); |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | - if (! dol_is_file($filerobot)) |
|
| 910 | + if (!dol_is_file($filerobot)) |
|
| 911 | 911 | { |
| 912 | 912 | $robotcontent = "# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/"; |
| 913 | - $result=dolSaveRobotFile($filerobot, $robotcontent); |
|
| 913 | + $result = dolSaveRobotFile($filerobot, $robotcontent); |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | - if (! dol_is_file($filehtaccess)) |
|
| 916 | + if (!dol_is_file($filehtaccess)) |
|
| 917 | 917 | { |
| 918 | 918 | $htaccesscontent = "# Order allow,deny\n# Deny from all"; |
| 919 | - $result=dolSaveHtaccessFile($filehtaccess, $htaccesscontent); |
|
| 919 | + $result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent); |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | - if (! dol_is_file($filemanifestjson)) |
|
| 922 | + if (!dol_is_file($filemanifestjson)) |
|
| 923 | 923 | { |
| 924 | 924 | $manifestjsoncontent = ""; |
| 925 | - $result=dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); |
|
| 925 | + $result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); |
|
| 926 | 926 | } |
| 927 | 927 | |
| 928 | - if (! dol_is_file($filereadme)) |
|
| 928 | + if (!dol_is_file($filereadme)) |
|
| 929 | 929 | { |
| 930 | 930 | $readmecontent = "Website generated by Dolibarr ERP CRM"; |
| 931 | - $result=dolSaveReadme($filereadme, $readmecontent); |
|
| 931 | + $result = dolSaveReadme($filereadme, $readmecontent); |
|
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | $action = 'preview'; |
@@ -954,23 +954,23 @@ discard block |
||
| 954 | 954 | setEventMessages($object->error, $object->errors, 'errors'); |
| 955 | 955 | } |
| 956 | 956 | } |
| 957 | - if (! $error) |
|
| 957 | + if (!$error) |
|
| 958 | 958 | { |
| 959 | 959 | if (GETPOST('delete_also_js', 'alpha') == 'on') |
| 960 | 960 | { |
| 961 | - $pathofwebsitejs=DOL_DATA_ROOT.'/medias/js/'.$object->ref; |
|
| 961 | + $pathofwebsitejs = DOL_DATA_ROOT.'/medias/js/'.$object->ref; |
|
| 962 | 962 | |
| 963 | 963 | dol_delete_dir_recursive($pathofwebsitejs); |
| 964 | 964 | } |
| 965 | 965 | if (GETPOST('delete_also_medias', 'alpha') == 'on') |
| 966 | 966 | { |
| 967 | - $pathofwebsitemedias=DOL_DATA_ROOT.'/medias/image/'.$object->ref; |
|
| 967 | + $pathofwebsitemedias = DOL_DATA_ROOT.'/medias/image/'.$object->ref; |
|
| 968 | 968 | |
| 969 | 969 | dol_delete_dir_recursive($pathofwebsitemedias); |
| 970 | 970 | } |
| 971 | 971 | } |
| 972 | 972 | |
| 973 | - if (! $error) |
|
| 973 | + if (!$error) |
|
| 974 | 974 | { |
| 975 | 975 | $db->commit(); |
| 976 | 976 | setEventMessages($langs->trans("SiteDeleted", $object->ref), null, 'mesgs'); |
@@ -1007,7 +1007,7 @@ discard block |
||
| 1007 | 1007 | } |
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | - if (! $error) |
|
| 1010 | + if (!$error) |
|
| 1011 | 1011 | { |
| 1012 | 1012 | $db->commit(); |
| 1013 | 1013 | setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $websitekey), null, 'mesgs'); |
@@ -1026,9 +1026,9 @@ discard block |
||
| 1026 | 1026 | if ($action == 'updatecss') |
| 1027 | 1027 | { |
| 1028 | 1028 | // If we tried to reload another site/page, we stay on editcss mode. |
| 1029 | - if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) |
|
| 1029 | + if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) |
|
| 1030 | 1030 | { |
| 1031 | - $action='editcss'; |
|
| 1031 | + $action = 'editcss'; |
|
| 1032 | 1032 | } |
| 1033 | 1033 | else |
| 1034 | 1034 | { |
@@ -1037,14 +1037,14 @@ discard block |
||
| 1037 | 1037 | |
| 1038 | 1038 | if (GETPOSTISSET('virtualhost')) |
| 1039 | 1039 | { |
| 1040 | - if (GETPOST('virtualhost', 'alpha') && ! preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) |
|
| 1040 | + if (GETPOST('virtualhost', 'alpha') && !preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) |
|
| 1041 | 1041 | { |
| 1042 | 1042 | $error++; |
| 1043 | 1043 | setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); |
| 1044 | - $action='editcss'; |
|
| 1044 | + $action = 'editcss'; |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | - if (! $error) |
|
| 1047 | + if (!$error) |
|
| 1048 | 1048 | { |
| 1049 | 1049 | $object->virtualhost = GETPOST('virtualhost', 'alpha'); |
| 1050 | 1050 | |
@@ -1053,15 +1053,15 @@ discard block |
||
| 1053 | 1053 | { |
| 1054 | 1054 | $error++; |
| 1055 | 1055 | setEventMessages($object->error, $object->errors, 'errors'); |
| 1056 | - $action='editcss'; |
|
| 1056 | + $action = 'editcss'; |
|
| 1057 | 1057 | } |
| 1058 | 1058 | } |
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | - if (! $error) |
|
| 1061 | + if (!$error) |
|
| 1062 | 1062 | { |
| 1063 | 1063 | // Save master.inc.php file |
| 1064 | - $filemaster=$pathofwebsite.'/master.inc.php'; |
|
| 1064 | + $filemaster = $pathofwebsite.'/master.inc.php'; |
|
| 1065 | 1065 | |
| 1066 | 1066 | dol_syslog("Save master file ".$filemaster); |
| 1067 | 1067 | |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | |
| 1070 | 1070 | // Now generate the master.inc.php page |
| 1071 | 1071 | $result = dolSaveMasterFile($filemaster); |
| 1072 | - if (! $result) |
|
| 1072 | + if (!$result) |
|
| 1073 | 1073 | { |
| 1074 | 1074 | $error++; |
| 1075 | 1075 | setEventMessages('Failed to write file '.$filemaster, null, 'errors'); |
@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | |
| 1078 | 1078 | |
| 1079 | 1079 | // Html header file |
| 1080 | - $htmlheadercontent =''; |
|
| 1080 | + $htmlheadercontent = ''; |
|
| 1081 | 1081 | |
| 1082 | 1082 | /* We disable php code since htmlheader is never executed as an include but only read by fgets_content. |
| 1083 | 1083 | $htmlheadercontent.= "<?php // BEGIN PHP\n"; |
@@ -1089,7 +1089,7 @@ discard block |
||
| 1089 | 1089 | // $htmlheadercontent.= "header('Content-type: text/html');\n"; // Not required. htmlheader.html is never call as a standalone page |
| 1090 | 1090 | $htmlheadercontent.= "// END PHP ?>\n";*/ |
| 1091 | 1091 | |
| 1092 | - $htmlheadercontent.= preg_replace(array('/<html>\n*/ims','/<\/html>\n*/ims'), array('',''), GETPOST('WEBSITE_HTML_HEADER', 'none')); |
|
| 1092 | + $htmlheadercontent .= preg_replace(array('/<html>\n*/ims', '/<\/html>\n*/ims'), array('', ''), GETPOST('WEBSITE_HTML_HEADER', 'none')); |
|
| 1093 | 1093 | |
| 1094 | 1094 | /*$htmlheadercontent.= "\n".'<?php // BEGIN PHP'."\n"; |
| 1095 | 1095 | $htmlheadercontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n"; |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | $htmlheadercontent = trim($htmlheadercontent)."\n"; |
| 1099 | 1099 | |
| 1100 | 1100 | $result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); |
| 1101 | - if (! $result) |
|
| 1101 | + if (!$result) |
|
| 1102 | 1102 | { |
| 1103 | 1103 | $error++; |
| 1104 | 1104 | setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); |
@@ -1106,30 +1106,30 @@ discard block |
||
| 1106 | 1106 | |
| 1107 | 1107 | |
| 1108 | 1108 | // Css file |
| 1109 | - $csscontent =''; |
|
| 1110 | - |
|
| 1111 | - $csscontent.= "<?php // BEGIN PHP\n"; |
|
| 1112 | - $csscontent.= '$websitekey=basename(__DIR__);'."\n"; |
|
| 1113 | - $csscontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. |
|
| 1114 | - $csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
| 1115 | - $csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
| 1116 | - $csscontent.= "ob_start();\n"; |
|
| 1117 | - $csscontent.= "if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n"; |
|
| 1118 | - $csscontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; |
|
| 1119 | - $csscontent.= "header('Content-type: text/css');\n"; |
|
| 1120 | - $csscontent.= "}\n"; |
|
| 1121 | - $csscontent.= "// END PHP ?>\n"; |
|
| 1122 | - |
|
| 1123 | - $csscontent.= trim(GETPOST('WEBSITE_CSS_INLINE', 'none'))."\n"; |
|
| 1124 | - |
|
| 1125 | - $csscontent.= '<?php // BEGIN PHP'."\n"; |
|
| 1126 | - $csscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n"; |
|
| 1127 | - $csscontent.= "// END PHP ?>"."\n"; |
|
| 1109 | + $csscontent = ''; |
|
| 1110 | + |
|
| 1111 | + $csscontent .= "<?php // BEGIN PHP\n"; |
|
| 1112 | + $csscontent .= '$websitekey=basename(__DIR__);'."\n"; |
|
| 1113 | + $csscontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. |
|
| 1114 | + $csscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
| 1115 | + $csscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
| 1116 | + $csscontent .= "ob_start();\n"; |
|
| 1117 | + $csscontent .= "if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n"; |
|
| 1118 | + $csscontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; |
|
| 1119 | + $csscontent .= "header('Content-type: text/css');\n"; |
|
| 1120 | + $csscontent .= "}\n"; |
|
| 1121 | + $csscontent .= "// END PHP ?>\n"; |
|
| 1122 | + |
|
| 1123 | + $csscontent .= trim(GETPOST('WEBSITE_CSS_INLINE', 'none'))."\n"; |
|
| 1124 | + |
|
| 1125 | + $csscontent .= '<?php // BEGIN PHP'."\n"; |
|
| 1126 | + $csscontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n"; |
|
| 1127 | + $csscontent .= "// END PHP ?>"."\n"; |
|
| 1128 | 1128 | |
| 1129 | 1129 | dol_syslog("Save css content into ".$filecss); |
| 1130 | 1130 | |
| 1131 | 1131 | $result = dolSaveCssFile($filecss, $csscontent); |
| 1132 | - if (! $result) |
|
| 1132 | + if (!$result) |
|
| 1133 | 1133 | { |
| 1134 | 1134 | $error++; |
| 1135 | 1135 | setEventMessages('Failed to write file '.$filecss, null, 'errors'); |
@@ -1137,26 +1137,26 @@ discard block |
||
| 1137 | 1137 | |
| 1138 | 1138 | |
| 1139 | 1139 | // Js file |
| 1140 | - $jscontent =''; |
|
| 1140 | + $jscontent = ''; |
|
| 1141 | 1141 | |
| 1142 | - $jscontent.= "<?php // BEGIN PHP\n"; |
|
| 1143 | - $jscontent.= '$websitekey=basename(__DIR__);'."\n"; |
|
| 1144 | - $jscontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. |
|
| 1145 | - $jscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
| 1146 | - $jscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
| 1147 | - $jscontent.= "ob_start();\n"; |
|
| 1148 | - $jscontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; |
|
| 1149 | - $jscontent.= "header('Content-type: application/javascript');\n"; |
|
| 1150 | - $jscontent.= "// END PHP ?>\n"; |
|
| 1142 | + $jscontent .= "<?php // BEGIN PHP\n"; |
|
| 1143 | + $jscontent .= '$websitekey=basename(__DIR__);'."\n"; |
|
| 1144 | + $jscontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. |
|
| 1145 | + $jscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
| 1146 | + $jscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
| 1147 | + $jscontent .= "ob_start();\n"; |
|
| 1148 | + $jscontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; |
|
| 1149 | + $jscontent .= "header('Content-type: application/javascript');\n"; |
|
| 1150 | + $jscontent .= "// END PHP ?>\n"; |
|
| 1151 | 1151 | |
| 1152 | - $jscontent.= trim(GETPOST('WEBSITE_JS_INLINE', 'none'))."\n"; |
|
| 1152 | + $jscontent .= trim(GETPOST('WEBSITE_JS_INLINE', 'none'))."\n"; |
|
| 1153 | 1153 | |
| 1154 | - $jscontent.= '<?php // BEGIN PHP'."\n"; |
|
| 1155 | - $jscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n"; |
|
| 1156 | - $jscontent.= "// END PHP ?>"."\n"; |
|
| 1154 | + $jscontent .= '<?php // BEGIN PHP'."\n"; |
|
| 1155 | + $jscontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n"; |
|
| 1156 | + $jscontent .= "// END PHP ?>"."\n"; |
|
| 1157 | 1157 | |
| 1158 | 1158 | $result = dolSaveJsFile($filejs, $jscontent); |
| 1159 | - if (! $result) |
|
| 1159 | + if (!$result) |
|
| 1160 | 1160 | { |
| 1161 | 1161 | $error++; |
| 1162 | 1162 | setEventMessages('Failed to write file '.$filejs, null, 'errors'); |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | |
| 1165 | 1165 | |
| 1166 | 1166 | // Robot file |
| 1167 | - $robotcontent =''; |
|
| 1167 | + $robotcontent = ''; |
|
| 1168 | 1168 | |
| 1169 | 1169 | /*$robotcontent.= "<?php // BEGIN PHP\n"; |
| 1170 | 1170 | $robotcontent.= '$websitekey=basename(__DIR__);'."\n"; |
@@ -1176,14 +1176,14 @@ discard block |
||
| 1176 | 1176 | $robotcontent.= "header('Content-type: text/css');\n"; |
| 1177 | 1177 | $robotcontent.= "// END PHP ?>\n";*/ |
| 1178 | 1178 | |
| 1179 | - $robotcontent.= trim(GETPOST('WEBSITE_ROBOT', 'none'))."\n"; |
|
| 1179 | + $robotcontent .= trim(GETPOST('WEBSITE_ROBOT', 'none'))."\n"; |
|
| 1180 | 1180 | |
| 1181 | 1181 | /*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n"; |
| 1182 | 1182 | $robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "robot");'."\n"; |
| 1183 | 1183 | $robotcontent.= "// END PHP ?>"."\n";*/ |
| 1184 | 1184 | |
| 1185 | 1185 | $result = dolSaveRobotFile($filerobot, $robotcontent); |
| 1186 | - if (! $result) |
|
| 1186 | + if (!$result) |
|
| 1187 | 1187 | { |
| 1188 | 1188 | $error++; |
| 1189 | 1189 | setEventMessages('Failed to write file '.$filerobot, null, 'errors'); |
@@ -1191,11 +1191,11 @@ discard block |
||
| 1191 | 1191 | |
| 1192 | 1192 | |
| 1193 | 1193 | // Htaccess file |
| 1194 | - $htaccesscontent =''; |
|
| 1195 | - $htaccesscontent.= trim(GETPOST('WEBSITE_HTACCESS', 'none'))."\n"; |
|
| 1194 | + $htaccesscontent = ''; |
|
| 1195 | + $htaccesscontent .= trim(GETPOST('WEBSITE_HTACCESS', 'none'))."\n"; |
|
| 1196 | 1196 | |
| 1197 | 1197 | $result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent); |
| 1198 | - if (! $result) |
|
| 1198 | + if (!$result) |
|
| 1199 | 1199 | { |
| 1200 | 1200 | $error++; |
| 1201 | 1201 | setEventMessages('Failed to write file '.$filehtaccess, null, 'errors'); |
@@ -1203,26 +1203,26 @@ discard block |
||
| 1203 | 1203 | |
| 1204 | 1204 | |
| 1205 | 1205 | // manifest.json file |
| 1206 | - $manifestjsoncontent =''; |
|
| 1206 | + $manifestjsoncontent = ''; |
|
| 1207 | 1207 | |
| 1208 | - $manifestjsoncontent.= "<?php // BEGIN PHP\n"; |
|
| 1209 | - $manifestjsoncontent.= '$websitekey=basename(__DIR__);'."\n"; |
|
| 1210 | - $manifestjsoncontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. |
|
| 1211 | - $manifestjsoncontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
| 1212 | - $manifestjsoncontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
| 1213 | - $manifestjsoncontent.= "ob_start();\n"; |
|
| 1214 | - $manifestjsoncontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; |
|
| 1215 | - $manifestjsoncontent.= "header('Content-type: application/manifest+json');\n"; |
|
| 1216 | - $manifestjsoncontent.= "// END PHP ?>\n"; |
|
| 1208 | + $manifestjsoncontent .= "<?php // BEGIN PHP\n"; |
|
| 1209 | + $manifestjsoncontent .= '$websitekey=basename(__DIR__);'."\n"; |
|
| 1210 | + $manifestjsoncontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. |
|
| 1211 | + $manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
| 1212 | + $manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
| 1213 | + $manifestjsoncontent .= "ob_start();\n"; |
|
| 1214 | + $manifestjsoncontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; |
|
| 1215 | + $manifestjsoncontent .= "header('Content-type: application/manifest+json');\n"; |
|
| 1216 | + $manifestjsoncontent .= "// END PHP ?>\n"; |
|
| 1217 | 1217 | |
| 1218 | - $manifestjsoncontent.= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n"; |
|
| 1218 | + $manifestjsoncontent .= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n"; |
|
| 1219 | 1219 | |
| 1220 | - $manifestjsoncontent.= '<?php // BEGIN PHP'."\n"; |
|
| 1221 | - $manifestjsoncontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; |
|
| 1222 | - $manifestjsoncontent.= "// END PHP ?>"."\n"; |
|
| 1220 | + $manifestjsoncontent .= '<?php // BEGIN PHP'."\n"; |
|
| 1221 | + $manifestjsoncontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; |
|
| 1222 | + $manifestjsoncontent .= "// END PHP ?>"."\n"; |
|
| 1223 | 1223 | |
| 1224 | 1224 | $result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); |
| 1225 | - if (! $result) |
|
| 1225 | + if (!$result) |
|
| 1226 | 1226 | { |
| 1227 | 1227 | $error++; |
| 1228 | 1228 | setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors'); |
@@ -1230,7 +1230,7 @@ discard block |
||
| 1230 | 1230 | |
| 1231 | 1231 | |
| 1232 | 1232 | // README.md file |
| 1233 | - $readmecontent =''; |
|
| 1233 | + $readmecontent = ''; |
|
| 1234 | 1234 | |
| 1235 | 1235 | /*$readmecontent.= "<?php // BEGIN PHP\n"; |
| 1236 | 1236 | $readmecontent.= '$websitekey=basename(__DIR__);'."\n"; |
@@ -1242,14 +1242,14 @@ discard block |
||
| 1242 | 1242 | $readmecontent.= "header('Content-type: application/manifest+json');\n"; |
| 1243 | 1243 | $readmecontent.= "// END PHP ?>\n";*/ |
| 1244 | 1244 | |
| 1245 | - $readmecontent.= trim(GETPOST('WEBSITE_README', 'none'))."\n"; |
|
| 1245 | + $readmecontent .= trim(GETPOST('WEBSITE_README', 'none'))."\n"; |
|
| 1246 | 1246 | |
| 1247 | 1247 | /*$readmecontent.= '<?php // BEGIN PHP'."\n"; |
| 1248 | 1248 | $readmecontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; |
| 1249 | 1249 | $readmecontent.= "// END PHP ?>"."\n";*/ |
| 1250 | 1250 | |
| 1251 | 1251 | $result = dolSaveReadme($filereadme, $readmecontent); |
| 1252 | - if (! $result) |
|
| 1252 | + if (!$result) |
|
| 1253 | 1253 | { |
| 1254 | 1254 | $error++; |
| 1255 | 1255 | setEventMessages('Failed to write file '.$filereadme, null, 'errors'); |
@@ -1257,14 +1257,14 @@ discard block |
||
| 1257 | 1257 | |
| 1258 | 1258 | |
| 1259 | 1259 | // Message if no error |
| 1260 | - if (! $error) |
|
| 1260 | + if (!$error) |
|
| 1261 | 1261 | { |
| 1262 | 1262 | setEventMessages($langs->trans("Saved"), null, 'mesgs'); |
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | - if (! GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we don not make the redirect |
|
| 1265 | + if (!GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we don not make the redirect |
|
| 1266 | 1266 | { |
| 1267 | - $action='preview'; |
|
| 1267 | + $action = 'preview'; |
|
| 1268 | 1268 | if ($backtopage) |
| 1269 | 1269 | { |
| 1270 | 1270 | header("Location: ".$backtopage); |
@@ -1288,13 +1288,13 @@ discard block |
||
| 1288 | 1288 | |
| 1289 | 1289 | $object->fk_default_home = $pageid; |
| 1290 | 1290 | $res = $object->update($user); |
| 1291 | - if (! $res > 0) |
|
| 1291 | + if (!$res > 0) |
|
| 1292 | 1292 | { |
| 1293 | 1293 | $error++; |
| 1294 | 1294 | setEventMessages($object->error, $object->errors, 'errors'); |
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | - if (! $error) |
|
| 1297 | + if (!$error) |
|
| 1298 | 1298 | { |
| 1299 | 1299 | $db->commit(); |
| 1300 | 1300 | |
@@ -1305,7 +1305,7 @@ discard block |
||
| 1305 | 1305 | if ($result) setEventMessages($langs->trans("Saved"), null, 'mesgs'); |
| 1306 | 1306 | else setEventMessages('Failed to write file '.$fileindex, null, 'errors'); |
| 1307 | 1307 | |
| 1308 | - $action='preview'; |
|
| 1308 | + $action = 'preview'; |
|
| 1309 | 1309 | } |
| 1310 | 1310 | else |
| 1311 | 1311 | { |
@@ -1324,12 +1324,12 @@ discard block |
||
| 1324 | 1324 | $objectpage->fk_website = $object->id; |
| 1325 | 1325 | |
| 1326 | 1326 | // Check parameters |
| 1327 | - if (! preg_match('/^[a-z0-9\-\_]+$/i', GETPOST('WEBSITE_PAGENAME', 'alpha'))) |
|
| 1327 | + if (!preg_match('/^[a-z0-9\-\_]+$/i', GETPOST('WEBSITE_PAGENAME', 'alpha'))) |
|
| 1328 | 1328 | { |
| 1329 | 1329 | $error++; |
| 1330 | 1330 | $langs->load("errors"); |
| 1331 | 1331 | setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); |
| 1332 | - $action='editmeta'; |
|
| 1332 | + $action = 'editmeta'; |
|
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | 1335 | $res = $objectpage->fetch($pageid, $object->id); |
@@ -1340,9 +1340,9 @@ discard block |
||
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | 1342 | // Check alias not exists |
| 1343 | - if (! $error && GETPOST('WEBSITE_PAGENAME', 'alpha')) |
|
| 1343 | + if (!$error && GETPOST('WEBSITE_PAGENAME', 'alpha')) |
|
| 1344 | 1344 | { |
| 1345 | - $websitepagetemp=new WebsitePage($db); |
|
| 1345 | + $websitepagetemp = new WebsitePage($db); |
|
| 1346 | 1346 | $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, GETPOST('WEBSITE_PAGENAME', 'alpha')); |
| 1347 | 1347 | if ($result < 0) |
| 1348 | 1348 | { |
@@ -1359,11 +1359,11 @@ discard block |
||
| 1359 | 1359 | $action = 'editmeta'; |
| 1360 | 1360 | } |
| 1361 | 1361 | } |
| 1362 | - if (! $error && GETPOST('WEBSITE_ALIASALT', 'alpha')) |
|
| 1362 | + if (!$error && GETPOST('WEBSITE_ALIASALT', 'alpha')) |
|
| 1363 | 1363 | { |
| 1364 | - $arrayofaliastotest=explode(',', GETPOST('WEBSITE_ALIASALT', 'alpha')); |
|
| 1365 | - $websitepagetemp=new WebsitePage($db); |
|
| 1366 | - foreach($arrayofaliastotest as $aliastotest) |
|
| 1364 | + $arrayofaliastotest = explode(',', GETPOST('WEBSITE_ALIASALT', 'alpha')); |
|
| 1365 | + $websitepagetemp = new WebsitePage($db); |
|
| 1366 | + foreach ($arrayofaliastotest as $aliastotest) |
|
| 1367 | 1367 | { |
| 1368 | 1368 | $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, $aliastotest); |
| 1369 | 1369 | if ($result < 0) |
@@ -1385,7 +1385,7 @@ discard block |
||
| 1385 | 1385 | } |
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | - if (! $error) |
|
| 1388 | + if (!$error) |
|
| 1389 | 1389 | { |
| 1390 | 1390 | $objectpage->old_object = clone $objectpage; |
| 1391 | 1391 | |
@@ -1400,11 +1400,11 @@ discard block |
||
| 1400 | 1400 | $objectpage->htmlheader = trim(GETPOST('htmlheader', 'none')); |
| 1401 | 1401 | $objectpage->fk_page = GETPOST('pageidfortranslation', 'int'); |
| 1402 | 1402 | |
| 1403 | - $newdatecreation=dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int')); |
|
| 1403 | + $newdatecreation = dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int')); |
|
| 1404 | 1404 | if ($newdatecreation) $objectpage->date_creation = $newdatecreation; |
| 1405 | 1405 | |
| 1406 | 1406 | $res = $objectpage->update($user); |
| 1407 | - if (! ($res > 0)) |
|
| 1407 | + if (!($res > 0)) |
|
| 1408 | 1408 | { |
| 1409 | 1409 | $langs->load("errors"); |
| 1410 | 1410 | if ($db->lasterrno == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
@@ -1424,7 +1424,7 @@ discard block |
||
| 1424 | 1424 | } |
| 1425 | 1425 | } |
| 1426 | 1426 | |
| 1427 | - if (! $error) |
|
| 1427 | + if (!$error) |
|
| 1428 | 1428 | { |
| 1429 | 1429 | $db->commit(); |
| 1430 | 1430 | } |
@@ -1433,32 +1433,32 @@ discard block |
||
| 1433 | 1433 | $db->rollback(); |
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | - if (! $error) |
|
| 1436 | + if (!$error) |
|
| 1437 | 1437 | { |
| 1438 | - $filemaster=$pathofwebsite.'/master.inc.php'; |
|
| 1439 | - $fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; |
|
| 1440 | - $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; |
|
| 1438 | + $filemaster = $pathofwebsite.'/master.inc.php'; |
|
| 1439 | + $fileoldalias = $pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; |
|
| 1440 | + $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; |
|
| 1441 | 1441 | |
| 1442 | 1442 | dol_mkdir($pathofwebsite); |
| 1443 | 1443 | |
| 1444 | 1444 | |
| 1445 | 1445 | // Now generate the master.inc.php page |
| 1446 | 1446 | $result = dolSaveMasterFile($filemaster); |
| 1447 | - if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); |
|
| 1447 | + if (!$result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); |
|
| 1448 | 1448 | |
| 1449 | 1449 | // Now delete the alias.php page |
| 1450 | - if (! empty($fileoldalias)) |
|
| 1450 | + if (!empty($fileoldalias)) |
|
| 1451 | 1451 | { |
| 1452 | 1452 | dol_syslog("We delete old alias page name=".$fileoldalias." to build a new alias page=".$filealias); |
| 1453 | 1453 | dol_delete_file($fileoldalias); |
| 1454 | 1454 | } |
| 1455 | 1455 | // Now delete the alternative alias.php pages |
| 1456 | - if (! empty($objectpage->old_object->aliasalt)) |
|
| 1456 | + if (!empty($objectpage->old_object->aliasalt)) |
|
| 1457 | 1457 | { |
| 1458 | - $tmpaltaliases=explode(',', $objectpage->old_object->aliasalt); |
|
| 1458 | + $tmpaltaliases = explode(',', $objectpage->old_object->aliasalt); |
|
| 1459 | 1459 | if (is_array($tmpaltaliases)) |
| 1460 | 1460 | { |
| 1461 | - foreach($tmpaltaliases as $tmpaliasalt) |
|
| 1461 | + foreach ($tmpaltaliases as $tmpaliasalt) |
|
| 1462 | 1462 | { |
| 1463 | 1463 | dol_syslog("We delete old alt alias pages name=".trim($tmpaliasalt)); |
| 1464 | 1464 | dol_delete_file($pathofwebsite.'/'.trim($tmpaliasalt).'.php'); |
@@ -1467,20 +1467,20 @@ discard block |
||
| 1467 | 1467 | } |
| 1468 | 1468 | |
| 1469 | 1469 | // Save page alias |
| 1470 | - $result=dolSavePageAlias($filealias, $object, $objectpage); |
|
| 1471 | - if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); |
|
| 1470 | + $result = dolSavePageAlias($filealias, $object, $objectpage); |
|
| 1471 | + if (!$result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); |
|
| 1472 | 1472 | // Save alt aliases |
| 1473 | - if (! empty($objectpage->aliasalt)) |
|
| 1473 | + if (!empty($objectpage->aliasalt)) |
|
| 1474 | 1474 | { |
| 1475 | - $tmpaltaliases=explode(',', $objectpage->aliasalt); |
|
| 1475 | + $tmpaltaliases = explode(',', $objectpage->aliasalt); |
|
| 1476 | 1476 | if (is_array($tmpaltaliases)) |
| 1477 | 1477 | { |
| 1478 | - foreach($tmpaltaliases as $tmpaliasalt) |
|
| 1478 | + foreach ($tmpaltaliases as $tmpaliasalt) |
|
| 1479 | 1479 | { |
| 1480 | 1480 | if (trim($tmpaliasalt)) |
| 1481 | 1481 | { |
| 1482 | - $result=dolSavePageAlias($pathofwebsite.'/'.trim($tmpaliasalt).'.php', $object, $objectpage); |
|
| 1483 | - if (! $result) setEventMessages('Failed to write file '.$pathofwebsite.'/'.trim($tmpaliasalt).'.php', null, 'errors'); |
|
| 1482 | + $result = dolSavePageAlias($pathofwebsite.'/'.trim($tmpaliasalt).'.php', $object, $objectpage); |
|
| 1483 | + if (!$result) setEventMessages('Failed to write file '.$pathofwebsite.'/'.trim($tmpaliasalt).'.php', null, 'errors'); |
|
| 1484 | 1484 | } |
| 1485 | 1485 | } |
| 1486 | 1486 | } |
@@ -1488,7 +1488,7 @@ discard block |
||
| 1488 | 1488 | |
| 1489 | 1489 | |
| 1490 | 1490 | // Save page of content |
| 1491 | - $result=dolSavePageContent($filetpl, $object, $objectpage); |
|
| 1491 | + $result = dolSavePageContent($filetpl, $object, $objectpage); |
|
| 1492 | 1492 | if ($result) |
| 1493 | 1493 | { |
| 1494 | 1494 | setEventMessages($langs->trans("Saved"), null, 'mesgs'); |
@@ -1502,7 +1502,7 @@ discard block |
||
| 1502 | 1502 | //exit; |
| 1503 | 1503 | } |
| 1504 | 1504 | |
| 1505 | - $action='preview'; |
|
| 1505 | + $action = 'preview'; |
|
| 1506 | 1506 | } |
| 1507 | 1507 | } |
| 1508 | 1508 | |
@@ -1518,12 +1518,12 @@ discard block |
||
| 1518 | 1518 | $db->begin(); |
| 1519 | 1519 | |
| 1520 | 1520 | $objectnew = new Website($db); |
| 1521 | - $result = $objectnew->createFromClone($user, GETPOST('id', 'int'), GETPOST('siteref', 'aZ09'), (GETPOST('newlang', 'aZ09')?GETPOST('newlang', 'aZ09'):'')); |
|
| 1521 | + $result = $objectnew->createFromClone($user, GETPOST('id', 'int'), GETPOST('siteref', 'aZ09'), (GETPOST('newlang', 'aZ09') ?GETPOST('newlang', 'aZ09') : '')); |
|
| 1522 | 1522 | if ($result < 0) |
| 1523 | 1523 | { |
| 1524 | 1524 | $error++; |
| 1525 | 1525 | setEventMessages($objectnew->error, $objectnew->errors, 'errors'); |
| 1526 | - $action='preview'; |
|
| 1526 | + $action = 'preview'; |
|
| 1527 | 1527 | |
| 1528 | 1528 | $db->rollback(); |
| 1529 | 1529 | } |
@@ -1540,25 +1540,25 @@ discard block |
||
| 1540 | 1540 | |
| 1541 | 1541 | if ($action == 'confirm_createpagefromclone') |
| 1542 | 1542 | { |
| 1543 | - $istranslation=(GETPOST('is_a_translation', 'aZ09')=='on'?1:0); |
|
| 1543 | + $istranslation = (GETPOST('is_a_translation', 'aZ09') == 'on' ? 1 : 0); |
|
| 1544 | 1544 | if ($istranslation) |
| 1545 | 1545 | { |
| 1546 | 1546 | if (GETPOST('newlang', 'aZ09') == $objectpage->lang) |
| 1547 | 1547 | { |
| 1548 | 1548 | $error++; |
| 1549 | 1549 | setEventMessages($langs->trans("LanguageMustNotBeSameThanClonedPage"), null, 'errors'); |
| 1550 | - $action='preview'; |
|
| 1550 | + $action = 'preview'; |
|
| 1551 | 1551 | } |
| 1552 | 1552 | } |
| 1553 | 1553 | |
| 1554 | - if (! $error) |
|
| 1554 | + if (!$error) |
|
| 1555 | 1555 | { |
| 1556 | 1556 | $db->begin(); |
| 1557 | 1557 | |
| 1558 | 1558 | $newwebsiteid = GETPOST('newwebsite', 'int'); |
| 1559 | 1559 | $pathofwebsitenew = $pathofwebsite; |
| 1560 | 1560 | |
| 1561 | - $tmpwebsite=new Website($db); |
|
| 1561 | + $tmpwebsite = new Website($db); |
|
| 1562 | 1562 | if ($newwebsiteid > 0 && $newwebsiteid != $object->id) |
| 1563 | 1563 | { |
| 1564 | 1564 | $tmpwebsite->fetch($newwebsiteid); |
@@ -1570,20 +1570,20 @@ discard block |
||
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | 1572 | $objectpage = new WebsitePage($db); |
| 1573 | - $resultpage = $objectpage->createFromClone($user, $pageid, GETPOST('pageurl', 'aZ09'), (GETPOST('newlang', 'aZ09')?GETPOST('newlang', 'aZ09'):''), $istranslation, $newwebsiteid); |
|
| 1573 | + $resultpage = $objectpage->createFromClone($user, $pageid, GETPOST('pageurl', 'aZ09'), (GETPOST('newlang', 'aZ09') ?GETPOST('newlang', 'aZ09') : ''), $istranslation, $newwebsiteid); |
|
| 1574 | 1574 | if ($resultpage < 0) |
| 1575 | 1575 | { |
| 1576 | 1576 | $error++; |
| 1577 | 1577 | setEventMessages($objectpage->error, $objectpage->errors, 'errors'); |
| 1578 | - $action='createpagefromclone'; |
|
| 1578 | + $action = 'createpagefromclone'; |
|
| 1579 | 1579 | |
| 1580 | 1580 | $db->rollback(); |
| 1581 | 1581 | } |
| 1582 | 1582 | else |
| 1583 | 1583 | { |
| 1584 | - $fileindex=$pathofwebsitenew.'/index.php'; |
|
| 1585 | - $filetpl=$pathofwebsitenew.'/page'.$resultpage->id.'.tpl.php'; |
|
| 1586 | - $filewrapper=$pathofwebsitenew.'/wrapper.php'; |
|
| 1584 | + $fileindex = $pathofwebsitenew.'/index.php'; |
|
| 1585 | + $filetpl = $pathofwebsitenew.'/page'.$resultpage->id.'.tpl.php'; |
|
| 1586 | + $filewrapper = $pathofwebsitenew.'/wrapper.php'; |
|
| 1587 | 1587 | |
| 1588 | 1588 | //var_dump($pathofwebsitenew); |
| 1589 | 1589 | //var_dump($filetpl); |
@@ -1604,15 +1604,15 @@ discard block |
||
| 1604 | 1604 | |
| 1605 | 1605 | $res = 0; |
| 1606 | 1606 | |
| 1607 | - if (! $error) |
|
| 1607 | + if (!$error) |
|
| 1608 | 1608 | { |
| 1609 | 1609 | // Check symlink to medias and restore it if ko |
| 1610 | - $pathtomedias=DOL_DATA_ROOT.'/medias'; |
|
| 1611 | - $pathtomediasinwebsite=$pathofwebsite.'/medias'; |
|
| 1612 | - if (! is_link(dol_osencode($pathtomediasinwebsite))) |
|
| 1610 | + $pathtomedias = DOL_DATA_ROOT.'/medias'; |
|
| 1611 | + $pathtomediasinwebsite = $pathofwebsite.'/medias'; |
|
| 1612 | + if (!is_link(dol_osencode($pathtomediasinwebsite))) |
|
| 1613 | 1613 | { |
| 1614 | 1614 | dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); |
| 1615 | - dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists |
|
| 1615 | + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists |
|
| 1616 | 1616 | $result = symlink($pathtomedias, $pathtomediasinwebsite); |
| 1617 | 1617 | } |
| 1618 | 1618 | |
@@ -1630,19 +1630,19 @@ discard block |
||
| 1630 | 1630 | } |
| 1631 | 1631 | else |
| 1632 | 1632 | { |
| 1633 | - $res=0; |
|
| 1633 | + $res = 0; |
|
| 1634 | 1634 | if ($object->fk_default_home > 0) |
| 1635 | 1635 | { |
| 1636 | 1636 | $res = $objectpage->fetch($object->fk_default_home); |
| 1637 | 1637 | } |
| 1638 | - if (! ($res > 0)) |
|
| 1638 | + if (!($res > 0)) |
|
| 1639 | 1639 | { |
| 1640 | 1640 | $res = $objectpage->fetch(0, $object->id); |
| 1641 | 1641 | } |
| 1642 | 1642 | } |
| 1643 | 1643 | } |
| 1644 | 1644 | |
| 1645 | - if (! $error && $res > 0) |
|
| 1645 | + if (!$error && $res > 0) |
|
| 1646 | 1646 | { |
| 1647 | 1647 | if ($action == 'updatesource' || $action == 'updatecontent') |
| 1648 | 1648 | { |
@@ -1655,12 +1655,12 @@ discard block |
||
| 1655 | 1655 | // Security analysis |
| 1656 | 1656 | $phpfullcodestring = dolKeepOnlyPhpCode($objectpage->content); |
| 1657 | 1657 | //print dol_escape_htmltag($phpfullcodestring);exit; |
| 1658 | - $forbiddenphpcommands=array("exec", "passthru", "system", "shell_exec", "proc_open"); |
|
| 1658 | + $forbiddenphpcommands = array("exec", "passthru", "system", "shell_exec", "proc_open"); |
|
| 1659 | 1659 | if (empty($conf->global->WEBSITE_PHP_ALLOW_WRITE)) // If option is not on, we disallow functions to write files |
| 1660 | 1660 | { |
| 1661 | - $forbiddenphpcommands=array_merge($forbiddenphpcommands, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask")); |
|
| 1661 | + $forbiddenphpcommands = array_merge($forbiddenphpcommands, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask")); |
|
| 1662 | 1662 | } |
| 1663 | - foreach($forbiddenphpcommands as $forbiddenphpcommand) |
|
| 1663 | + foreach ($forbiddenphpcommands as $forbiddenphpcommand) |
|
| 1664 | 1664 | { |
| 1665 | 1665 | if (preg_match('/'.$forbiddenphpcommand.'\s*\(/ms', $phpfullcodestring)) |
| 1666 | 1666 | { |
@@ -1696,13 +1696,13 @@ discard block |
||
| 1696 | 1696 | if ($action == 'updatecontent') $action = 'editcontent'; |
| 1697 | 1697 | } |
| 1698 | 1698 | |
| 1699 | - if (! $error) |
|
| 1699 | + if (!$error) |
|
| 1700 | 1700 | { |
| 1701 | 1701 | $db->commit(); |
| 1702 | 1702 | |
| 1703 | - $filemaster=$pathofwebsite.'/master.inc.php'; |
|
| 1703 | + $filemaster = $pathofwebsite.'/master.inc.php'; |
|
| 1704 | 1704 | //$fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; |
| 1705 | - $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; |
|
| 1705 | + $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; |
|
| 1706 | 1706 | |
| 1707 | 1707 | dol_mkdir($pathofwebsite); |
| 1708 | 1708 | |
@@ -1710,22 +1710,22 @@ discard block |
||
| 1710 | 1710 | // Now generate the master.inc.php page |
| 1711 | 1711 | $result = dolSaveMasterFile($filemaster); |
| 1712 | 1712 | |
| 1713 | - if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); |
|
| 1713 | + if (!$result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); |
|
| 1714 | 1714 | |
| 1715 | 1715 | |
| 1716 | 1716 | // Now generate the alias.php page |
| 1717 | - if (! empty($fileoldalias)) |
|
| 1717 | + if (!empty($fileoldalias)) |
|
| 1718 | 1718 | { |
| 1719 | 1719 | dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias); |
| 1720 | 1720 | dol_delete_file($fileoldalias); |
| 1721 | 1721 | } |
| 1722 | 1722 | |
| 1723 | 1723 | // Save page alias |
| 1724 | - $result=dolSavePageAlias($filealias, $object, $objectpage); |
|
| 1725 | - if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); |
|
| 1724 | + $result = dolSavePageAlias($filealias, $object, $objectpage); |
|
| 1725 | + if (!$result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); |
|
| 1726 | 1726 | |
| 1727 | 1727 | // Save page content |
| 1728 | - $result=dolSavePageContent($filetpl, $object, $objectpage); |
|
| 1728 | + $result = dolSavePageContent($filetpl, $object, $objectpage); |
|
| 1729 | 1729 | if ($result) |
| 1730 | 1730 | { |
| 1731 | 1731 | setEventMessages($langs->trans("Saved"), null, 'mesgs'); |
@@ -1752,7 +1752,7 @@ discard block |
||
| 1752 | 1752 | } |
| 1753 | 1753 | else |
| 1754 | 1754 | { |
| 1755 | - if (! $error) |
|
| 1755 | + if (!$error) |
|
| 1756 | 1756 | { |
| 1757 | 1757 | if (empty($websitekey) || $websitekey == '-1') |
| 1758 | 1758 | { |
@@ -1778,7 +1778,7 @@ discard block |
||
| 1778 | 1778 | |
| 1779 | 1779 | header("Content-Type: application/zip"); |
| 1780 | 1780 | header("Content-Disposition: attachment; filename=".$file_name); |
| 1781 | - header("Content-Length: " . filesize($fileofzip)); |
|
| 1781 | + header("Content-Length: ".filesize($fileofzip)); |
|
| 1782 | 1782 | |
| 1783 | 1783 | readfile($fileofzip); |
| 1784 | 1784 | exit; |
@@ -1793,24 +1793,24 @@ discard block |
||
| 1793 | 1793 | // Import site |
| 1794 | 1794 | if ($action == 'importsiteconfirm') |
| 1795 | 1795 | { |
| 1796 | - if (empty($_FILES) && ! GETPOSTISSET('templateuserfile')) |
|
| 1796 | + if (empty($_FILES) && !GETPOSTISSET('templateuserfile')) |
|
| 1797 | 1797 | { |
| 1798 | 1798 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); |
| 1799 | 1799 | $action = 'importsite'; |
| 1800 | 1800 | } |
| 1801 | 1801 | else |
| 1802 | 1802 | { |
| 1803 | - if (! empty($_FILES) || GETPOSTISSET('templateuserfile')) |
|
| 1803 | + if (!empty($_FILES) || GETPOSTISSET('templateuserfile')) |
|
| 1804 | 1804 | { |
| 1805 | 1805 | // Check symlink to medias and restore it if ko |
| 1806 | - $pathtomedias=DOL_DATA_ROOT.'/medias'; |
|
| 1807 | - $pathtomediasinwebsite=$pathofwebsite.'/medias'; |
|
| 1808 | - if (! is_link(dol_osencode($pathtomediasinwebsite))) |
|
| 1806 | + $pathtomedias = DOL_DATA_ROOT.'/medias'; |
|
| 1807 | + $pathtomediasinwebsite = $pathofwebsite.'/medias'; |
|
| 1808 | + if (!is_link(dol_osencode($pathtomediasinwebsite))) |
|
| 1809 | 1809 | { |
| 1810 | 1810 | dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); |
| 1811 | - dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists |
|
| 1811 | + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists |
|
| 1812 | 1812 | $result = symlink($pathtomedias, $pathtomediasinwebsite); |
| 1813 | - if (! $result) |
|
| 1813 | + if (!$result) |
|
| 1814 | 1814 | { |
| 1815 | 1815 | setEventMessages($langs->trans("ErrorFieldToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias), null, 'errors'); |
| 1816 | 1816 | $action = 'importsite'; |
@@ -1822,17 +1822,17 @@ discard block |
||
| 1822 | 1822 | { |
| 1823 | 1823 | $fileofzip = DOL_DATA_ROOT.'/doctemplates/websites/'.GETPOST('templateuserfile', 'alpha'); |
| 1824 | 1824 | } |
| 1825 | - elseif (! empty($_FILES)) |
|
| 1825 | + elseif (!empty($_FILES)) |
|
| 1826 | 1826 | { |
| 1827 | - if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name']; |
|
| 1828 | - else $userfiles=array($_FILES['userfile']['tmp_name']); |
|
| 1827 | + if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name']; |
|
| 1828 | + else $userfiles = array($_FILES['userfile']['tmp_name']); |
|
| 1829 | 1829 | |
| 1830 | - foreach($userfiles as $key => $userfile) |
|
| 1830 | + foreach ($userfiles as $key => $userfile) |
|
| 1831 | 1831 | { |
| 1832 | 1832 | if (empty($_FILES['userfile']['tmp_name'][$key])) |
| 1833 | 1833 | { |
| 1834 | 1834 | $error++; |
| 1835 | - if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){ |
|
| 1835 | + if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) { |
|
| 1836 | 1836 | setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); |
| 1837 | 1837 | $action = 'importsite'; |
| 1838 | 1838 | } |
@@ -1843,7 +1843,7 @@ discard block |
||
| 1843 | 1843 | } |
| 1844 | 1844 | } |
| 1845 | 1845 | |
| 1846 | - if (! $error) |
|
| 1846 | + if (!$error) |
|
| 1847 | 1847 | { |
| 1848 | 1848 | $upload_dir = $conf->website->dir_temp; |
| 1849 | 1849 | $result = dol_add_file_process($upload_dir, 1, -1, 'userfile', ''); |
@@ -1851,16 +1851,16 @@ discard block |
||
| 1851 | 1851 | |
| 1852 | 1852 | // Get name of file (take last one if several name provided) |
| 1853 | 1853 | $fileofzip = $upload_dir.'/unknown'; |
| 1854 | - foreach($_FILES as $key => $ifile) |
|
| 1854 | + foreach ($_FILES as $key => $ifile) |
|
| 1855 | 1855 | { |
| 1856 | - foreach($ifile['name'] as $key2 => $ifile2) |
|
| 1856 | + foreach ($ifile['name'] as $key2 => $ifile2) |
|
| 1857 | 1857 | { |
| 1858 | - $fileofzip = $upload_dir . '/' .$ifile2; |
|
| 1858 | + $fileofzip = $upload_dir.'/'.$ifile2; |
|
| 1859 | 1859 | } |
| 1860 | 1860 | } |
| 1861 | 1861 | } |
| 1862 | 1862 | |
| 1863 | - if (! $error) |
|
| 1863 | + if (!$error) |
|
| 1864 | 1864 | { |
| 1865 | 1865 | $result = $object->importWebSite($fileofzip); |
| 1866 | 1866 | if ($result < 0) |
@@ -1893,7 +1893,7 @@ discard block |
||
| 1893 | 1893 | $formwebsite = new FormWebsite($db); |
| 1894 | 1894 | $formother = new FormOther($db); |
| 1895 | 1895 | |
| 1896 | -$help_url=''; |
|
| 1896 | +$help_url = ''; |
|
| 1897 | 1897 | |
| 1898 | 1898 | $arrayofjs = array( |
| 1899 | 1899 | '/includes/ace/src/ace.js', |
@@ -1904,16 +1904,16 @@ discard block |
||
| 1904 | 1904 | ); |
| 1905 | 1905 | $arrayofcss = array(); |
| 1906 | 1906 | |
| 1907 | -$moreheadcss=''; |
|
| 1908 | -$moreheadjs=''; |
|
| 1907 | +$moreheadcss = ''; |
|
| 1908 | +$moreheadjs = ''; |
|
| 1909 | 1909 | |
| 1910 | -$arrayofjs[]='includes/jquery/plugins/blockUI/jquery.blockUI.js'; |
|
| 1911 | -$arrayofjs[]='core/js/blockUI.js'; // Used by ecm/tpl/enabledfiletreeajax.tpl.php |
|
| 1912 | -if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $arrayofjs[]="includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; |
|
| 1910 | +$arrayofjs[] = 'includes/jquery/plugins/blockUI/jquery.blockUI.js'; |
|
| 1911 | +$arrayofjs[] = 'core/js/blockUI.js'; // Used by ecm/tpl/enabledfiletreeajax.tpl.php |
|
| 1912 | +if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $arrayofjs[] = "includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; |
|
| 1913 | 1913 | |
| 1914 | -$moreheadjs.='<script type="text/javascript">'."\n"; |
|
| 1915 | -$moreheadjs.='var indicatorBlockUI = \''.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'\';'."\n"; |
|
| 1916 | -$moreheadjs.='</script>'."\n"; |
|
| 1914 | +$moreheadjs .= '<script type="text/javascript">'."\n"; |
|
| 1915 | +$moreheadjs .= 'var indicatorBlockUI = \''.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'\';'."\n"; |
|
| 1916 | +$moreheadjs .= '</script>'."\n"; |
|
| 1917 | 1917 | |
| 1918 | 1918 | llxHeader($moreheadcss.$moreheadjs, $langs->trans("WebsiteSetup"), $help_url, '', 0, 0, $arrayofjs, $arrayofcss, '', '', '<!-- Begin div class="fiche" -->'."\n".'<div class="fichebutwithotherclass">'); |
| 1919 | 1919 | |
@@ -1978,14 +1978,14 @@ discard block |
||
| 1978 | 1978 | print '<div>'; |
| 1979 | 1979 | |
| 1980 | 1980 | // Add a margin under toolbar ? |
| 1981 | -$style=''; |
|
| 1982 | -if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource') $style=' margin-bottom: 5px;'; |
|
| 1981 | +$style = ''; |
|
| 1982 | +if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource') $style = ' margin-bottom: 5px;'; |
|
| 1983 | 1983 | |
| 1984 | 1984 | |
| 1985 | -if (! GETPOST('hide_websitemenu')) |
|
| 1985 | +if (!GETPOST('hide_websitemenu')) |
|
| 1986 | 1986 | { |
| 1987 | - $disabled=''; |
|
| 1988 | - if (empty($user->rights->website->write)) $disabled=' disabled="disabled"'; |
|
| 1987 | + $disabled = ''; |
|
| 1988 | + if (empty($user->rights->website->write)) $disabled = ' disabled="disabled"'; |
|
| 1989 | 1989 | |
| 1990 | 1990 | //var_dump($objectpage);exit; |
| 1991 | 1991 | print '<div class="centpercent websitebar">'; |
@@ -2004,24 +2004,24 @@ discard block |
||
| 2004 | 2004 | |
| 2005 | 2005 | // List of website |
| 2006 | 2006 | print '<span class="websiteselection">'; |
| 2007 | - $out=''; |
|
| 2008 | - $out.='<select name="website" class="minwidth100 maxwidth300" id="website">'; |
|
| 2009 | - if (empty($object->records)) $out.='<option value="-1"> </option>'; |
|
| 2007 | + $out = ''; |
|
| 2008 | + $out .= '<select name="website" class="minwidth100 maxwidth300" id="website">'; |
|
| 2009 | + if (empty($object->records)) $out .= '<option value="-1"> </option>'; |
|
| 2010 | 2010 | // Loop on each sites |
| 2011 | - $i=0; |
|
| 2012 | - foreach($object->records as $key => $valwebsite) |
|
| 2011 | + $i = 0; |
|
| 2012 | + foreach ($object->records as $key => $valwebsite) |
|
| 2013 | 2013 | { |
| 2014 | - if (empty($websitekey)) $websitekey=$valwebsite->ref; |
|
| 2014 | + if (empty($websitekey)) $websitekey = $valwebsite->ref; |
|
| 2015 | 2015 | |
| 2016 | - $out.='<option value="'.$valwebsite->ref.'"'; |
|
| 2017 | - if ($websitekey == $valwebsite->ref) $out.=' selected'; // To preselect a value |
|
| 2018 | - $out.='>'; |
|
| 2019 | - $out.=$valwebsite->ref; |
|
| 2020 | - $out.='</option>'; |
|
| 2016 | + $out .= '<option value="'.$valwebsite->ref.'"'; |
|
| 2017 | + if ($websitekey == $valwebsite->ref) $out .= ' selected'; // To preselect a value |
|
| 2018 | + $out .= '>'; |
|
| 2019 | + $out .= $valwebsite->ref; |
|
| 2020 | + $out .= '</option>'; |
|
| 2021 | 2021 | $i++; |
| 2022 | 2022 | } |
| 2023 | - $out.='</select>'; |
|
| 2024 | - $out.=ajax_combobox('website'); |
|
| 2023 | + $out .= '</select>'; |
|
| 2024 | + $out .= ajax_combobox('website'); |
|
| 2025 | 2025 | print $out; |
| 2026 | 2026 | //print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Load").'">'; |
| 2027 | 2027 | print '<input type="image" class="valignmiddle" src="'.img_picto('', 'refresh', '', 0, 1).'" name="refreshsite" value="'.$langs->trans("Load").'">'; |
@@ -2029,19 +2029,19 @@ discard block |
||
| 2029 | 2029 | |
| 2030 | 2030 | if ($websitekey) |
| 2031 | 2031 | { |
| 2032 | - $virtualurl=''; |
|
| 2033 | - $dataroot=DOL_DATA_ROOT.'/website/'.$websitekey; |
|
| 2034 | - if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost; |
|
| 2032 | + $virtualurl = ''; |
|
| 2033 | + $dataroot = DOL_DATA_ROOT.'/website/'.$websitekey; |
|
| 2034 | + if (!empty($object->virtualhost)) $virtualurl = $object->virtualhost; |
|
| 2035 | 2035 | } |
| 2036 | 2036 | |
| 2037 | - $array=array(); |
|
| 2037 | + $array = array(); |
|
| 2038 | 2038 | if ($object->id > 0) |
| 2039 | 2039 | { |
| 2040 | - $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); |
|
| 2040 | + $array = $objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); |
|
| 2041 | 2041 | $object->lines = $array; |
| 2042 | 2042 | } |
| 2043 | - if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 2044 | - $atleastonepage=(is_array($array) && count($array) > 0); |
|
| 2043 | + if (!is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 2044 | + $atleastonepage = (is_array($array) && count($array) > 0); |
|
| 2045 | 2045 | |
| 2046 | 2046 | if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) |
| 2047 | 2047 | { |
@@ -2062,7 +2062,7 @@ discard block |
||
| 2062 | 2062 | print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("ExportSite")).'" name="exportsite">'; |
| 2063 | 2063 | print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("CloneSite")).'" name="createfromclone">'; |
| 2064 | 2064 | |
| 2065 | - print '<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans("Delete").'"'.($atleastonepage?' disabled="disabled"':'').'>'; |
|
| 2065 | + print '<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans("Delete").'"'.($atleastonepage ? ' disabled="disabled"' : '').'>'; |
|
| 2066 | 2066 | |
| 2067 | 2067 | print ' '; |
| 2068 | 2068 | |
@@ -2098,48 +2098,48 @@ discard block |
||
| 2098 | 2098 | |
| 2099 | 2099 | if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite') |
| 2100 | 2100 | { |
| 2101 | - $urlext=$virtualurl; |
|
| 2102 | - $urlint=$urlwithroot.'/public/website/index.php?website='.$websitekey; |
|
| 2101 | + $urlext = $virtualurl; |
|
| 2102 | + $urlint = $urlwithroot.'/public/website/index.php?website='.$websitekey; |
|
| 2103 | 2103 | |
| 2104 | 2104 | print '<span class="websiteinputurl valignmiddle" id="websiteinputurl">'; |
| 2105 | - $linktotestonwebserver = '<a href="'.($virtualurl?$virtualurl:'#').'" class="valignmiddle">'; |
|
| 2106 | - $linktotestonwebserver.= $langs->trans("TestDeployOnWeb", $virtualurl).' '.img_picto('', 'globe'); |
|
| 2107 | - $linktotestonwebserver.= '</a>'; |
|
| 2105 | + $linktotestonwebserver = '<a href="'.($virtualurl ? $virtualurl : '#').'" class="valignmiddle">'; |
|
| 2106 | + $linktotestonwebserver .= $langs->trans("TestDeployOnWeb", $virtualurl).' '.img_picto('', 'globe'); |
|
| 2107 | + $linktotestonwebserver .= '</a>'; |
|
| 2108 | 2108 | $htmltext = ''; |
| 2109 | 2109 | if (empty($object->fk_default_home)) |
| 2110 | 2110 | { |
| 2111 | - $htmltext.= '<br><span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br><br>'; |
|
| 2111 | + $htmltext .= '<br><span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br><br>'; |
|
| 2112 | 2112 | } |
| 2113 | 2113 | elseif (empty($virtualurl)) |
| 2114 | 2114 | { |
| 2115 | - $htmltext.= '<br><span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>'; |
|
| 2115 | + $htmltext .= '<br><span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>'; |
|
| 2116 | 2116 | } |
| 2117 | 2117 | else |
| 2118 | 2118 | { |
| 2119 | - $htmltext.= '<br><center>'.$langs->trans("GoTo").' <a href="'.$virtualurl.'" target="_website">'.$virtualurl.'</a></center><br>'; |
|
| 2119 | + $htmltext .= '<br><center>'.$langs->trans("GoTo").' <a href="'.$virtualurl.'" target="_website">'.$virtualurl.'</a></center><br>'; |
|
| 2120 | 2120 | } |
| 2121 | - if (! empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) |
|
| 2121 | + if (!empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) |
|
| 2122 | 2122 | { |
| 2123 | - $htmltext.= '<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER); |
|
| 2123 | + $htmltext .= '<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER); |
|
| 2124 | 2124 | } |
| 2125 | 2125 | else |
| 2126 | 2126 | { |
| 2127 | - $htmltext.=$langs->trans("SetHereVirtualHost", $dataroot); |
|
| 2128 | - $htmltext.='<br>'; |
|
| 2129 | - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); |
|
| 2130 | - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); |
|
| 2131 | - $htmltext.='<br>'; |
|
| 2132 | - $htmltext.='<br>'; |
|
| 2133 | - $htmltext.=$langs->trans("YouCanAlsoTestWithPHPS", $dataroot); |
|
| 2134 | - $htmltext.='<br>'; |
|
| 2135 | - $htmltext.='<br>'; |
|
| 2136 | - $htmltext.=$langs->trans("YouCanAlsoDeployToAnotherWHP"); |
|
| 2127 | + $htmltext .= $langs->trans("SetHereVirtualHost", $dataroot); |
|
| 2128 | + $htmltext .= '<br>'; |
|
| 2129 | + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); |
|
| 2130 | + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); |
|
| 2131 | + $htmltext .= '<br>'; |
|
| 2132 | + $htmltext .= '<br>'; |
|
| 2133 | + $htmltext .= $langs->trans("YouCanAlsoTestWithPHPS", $dataroot); |
|
| 2134 | + $htmltext .= '<br>'; |
|
| 2135 | + $htmltext .= '<br>'; |
|
| 2136 | + $htmltext .= $langs->trans("YouCanAlsoDeployToAnotherWHP"); |
|
| 2137 | 2137 | } |
| 2138 | 2138 | print $form->textwithpicto($linktotestonwebserver, $htmltext, 1, 'none', 'valignmiddle', 0, 3, 'helpvirtualhost'); |
| 2139 | 2139 | print '</span>'; |
| 2140 | 2140 | } |
| 2141 | 2141 | |
| 2142 | - if (in_array($action, array('editcss','editmenu','file_manager','replacesite','replacesiteconfirm'))) |
|
| 2142 | + if (in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesite', 'replacesiteconfirm'))) |
|
| 2143 | 2143 | { |
| 2144 | 2144 | if ($action == 'editcss' && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print '<input type="submit" id="savefilean stay" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("SaveAndStay")).'" name="updateandstay">'; |
| 2145 | 2145 | if (preg_match('/^create/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; |
@@ -2152,12 +2152,12 @@ discard block |
||
| 2152 | 2152 | |
| 2153 | 2153 | // Toolbar for pages |
| 2154 | 2154 | |
| 2155 | - if ($websitekey && $websitekey != '-1' && ! in_array($action, array('editcss','editmenu','importsite'))) |
|
| 2155 | + if ($websitekey && $websitekey != '-1' && !in_array($action, array('editcss', 'editmenu', 'importsite'))) |
|
| 2156 | 2156 | { |
| 2157 | - print '</div>'; // Close current websitebar to open a new one |
|
| 2157 | + print '</div>'; // Close current websitebar to open a new one |
|
| 2158 | 2158 | |
| 2159 | 2159 | print '<!-- Bar for websitepage -->'; |
| 2160 | - print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">'; |
|
| 2160 | + print '<div class="centpercent websitebar"'.($style ? ' style="'.$style.'"' : '').'">'; |
|
| 2161 | 2161 | |
| 2162 | 2162 | print '<span class="websiteselection hideonsmartphoneimp minwidth100 tdoverflowmax100">'; |
| 2163 | 2163 | print $langs->trans("PageContainer").': '; |
@@ -2180,12 +2180,12 @@ discard block |
||
| 2180 | 2180 | } |
| 2181 | 2181 | |
| 2182 | 2182 | //print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>'; |
| 2183 | - print '<input type="image" class="valignmiddle" src="'.img_picto('', 'refresh', '', 0, 1).'" name="refreshpage" value="'.$langs->trans("Load").'"'.(($atleastonepage && $action != 'editsource')?'':' disabled="disabled"').'>'; |
|
| 2183 | + print '<input type="image" class="valignmiddle" src="'.img_picto('', 'refresh', '', 0, 1).'" name="refreshpage" value="'.$langs->trans("Load").'"'.(($atleastonepage && $action != 'editsource') ? '' : ' disabled="disabled"').'>'; |
|
| 2184 | 2184 | |
| 2185 | 2185 | |
| 2186 | 2186 | // Print nav arrows |
| 2187 | - $pagepreviousid=0; |
|
| 2188 | - $pagenextid=0; |
|
| 2187 | + $pagepreviousid = 0; |
|
| 2188 | + $pagenextid = 0; |
|
| 2189 | 2189 | if ($pageid) |
| 2190 | 2190 | { |
| 2191 | 2191 | $sql = 'SELECT MAX(rowid) as pagepreviousid FROM '.MAIN_DB_PREFIX.'website_page WHERE rowid < '.$pageid.' AND fk_website = '.$object->id; |
@@ -2225,8 +2225,8 @@ discard block |
||
| 2225 | 2225 | |
| 2226 | 2226 | if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite') |
| 2227 | 2227 | { |
| 2228 | - $disabled=''; |
|
| 2229 | - if (empty($user->rights->website->write)) $disabled=' disabled="disabled"'; |
|
| 2228 | + $disabled = ''; |
|
| 2229 | + if (empty($user->rights->website->write)) $disabled = ' disabled="disabled"'; |
|
| 2230 | 2230 | |
| 2231 | 2231 | // Confirmation delete site |
| 2232 | 2232 | if ($action == 'deletesite') { |
@@ -2238,7 +2238,7 @@ discard block |
||
| 2238 | 2238 | //array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)) |
| 2239 | 2239 | ); |
| 2240 | 2240 | |
| 2241 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id='.$object->id, $langs->trans('DeleteWebsite'), '', 'confirm_deletesite', $formquestion, 0, 1, 200); |
|
| 2241 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteWebsite'), '', 'confirm_deletesite', $formquestion, 0, 1, 200); |
|
| 2242 | 2242 | |
| 2243 | 2243 | print $formconfirm; |
| 2244 | 2244 | } |
@@ -2247,13 +2247,13 @@ discard block |
||
| 2247 | 2247 | if ($action == 'createfromclone') { |
| 2248 | 2248 | // Create an array for form |
| 2249 | 2249 | $formquestion = array( |
| 2250 | - array('type' => 'text', 'name' => 'siteref', 'label'=> $langs->trans("WebSite") ,'value'=> 'copy_of_'.$object->ref), |
|
| 2250 | + array('type' => 'text', 'name' => 'siteref', 'label'=> $langs->trans("WebSite"), 'value'=> 'copy_of_'.$object->ref), |
|
| 2251 | 2251 | //array('type' => 'checkbox', 'name' => 'is_a_translation', 'label' => $langs->trans("SiteIsANewTranslation"), 'value' => 0), |
| 2252 | 2252 | //array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'aZ09')?GETPOST('newlang', 'aZ09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200')), |
| 2253 | 2253 | //array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)) |
| 2254 | 2254 | ); |
| 2255 | 2255 | |
| 2256 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id='.$object->id, $langs->trans('CloneSite'), '', 'confirm_createfromclone', $formquestion, 0, 1, 200); |
|
| 2256 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloneSite'), '', 'confirm_createfromclone', $formquestion, 0, 1, 200); |
|
| 2257 | 2257 | |
| 2258 | 2258 | print $formconfirm; |
| 2259 | 2259 | } |
@@ -2267,12 +2267,12 @@ discard block |
||
| 2267 | 2267 | $formquestion = array( |
| 2268 | 2268 | array('type' => 'hidden', 'name' => 'sourcepageurl', 'value'=> $objectpage->pageurl), |
| 2269 | 2269 | array('type' => 'checkbox', 'tdclass'=>'maxwidth200', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), |
| 2270 | - array('type' => 'other','name' => 'newlang', 'label' => $langs->trans("Language"), 'value' => $formadmin->select_language($preselectedlanguage, 'newlang', 0, null, 1, 0, 0, 'minwidth200', 0, 1)), |
|
| 2271 | - array('type' => 'other','name' => 'newwebsite', 'label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), |
|
| 2270 | + array('type' => 'other', 'name' => 'newlang', 'label' => $langs->trans("Language"), 'value' => $formadmin->select_language($preselectedlanguage, 'newlang', 0, null, 1, 0, 0, 'minwidth200', 0, 1)), |
|
| 2271 | + array('type' => 'other', 'name' => 'newwebsite', 'label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), |
|
| 2272 | 2272 | array('type' => 'text', 'tdclass'=>'maxwidth200 fieldrequired', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME"), 'value'=> 'copy_of_'.$objectpage->pageurl), |
| 2273 | 2273 | ); |
| 2274 | 2274 | |
| 2275 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?website='.$object->ref.'&pageid=' . $pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550); |
|
| 2275 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550); |
|
| 2276 | 2276 | |
| 2277 | 2277 | print $formconfirm; |
| 2278 | 2278 | } |
@@ -2291,7 +2291,7 @@ discard block |
||
| 2291 | 2291 | print '<!-- Code to enabled edit inline ckeditor -->'."\n"; |
| 2292 | 2292 | print '<script type="text/javascript"> |
| 2293 | 2293 | $(document).ready(function() { |
| 2294 | - var isEditingEnabled = '.($conf->global->WEBSITE_EDITINLINE?'true':'false').'; |
|
| 2294 | + var isEditingEnabled = '.($conf->global->WEBSITE_EDITINLINE ? 'true' : 'false').'; |
|
| 2295 | 2295 | if (isEditingEnabled) |
| 2296 | 2296 | { |
| 2297 | 2297 | switchEditorOnline(true); |
@@ -2389,7 +2389,7 @@ discard block |
||
| 2389 | 2389 | print '<a href="'.$_SERVER["PHP_SEFL"].'?action=setashome&website='.$website->ref.'&pageid='.$pageid.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'"><span class="fa fa-home valignmiddle btnTitle-icon"><span></a>'; |
| 2390 | 2390 | } |
| 2391 | 2391 | print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("ClonePage")).'" name="createpagefromclone">'; |
| 2392 | - print '<input type="submit" class="buttonDelete bordertransp" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>'; |
|
| 2392 | + print '<input type="submit" class="buttonDelete bordertransp" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage ? '' : ' disabled="disabled"').'>'; |
|
| 2393 | 2393 | } |
| 2394 | 2394 | } |
| 2395 | 2395 | |
@@ -2399,48 +2399,48 @@ discard block |
||
| 2399 | 2399 | |
| 2400 | 2400 | if (($pageid > 0 && $atleastonepage) && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) |
| 2401 | 2401 | { |
| 2402 | - $realpage=$urlwithroot.'/public/website/index.php?website='.$websitekey.'&pageref='.$websitepage->pageurl; |
|
| 2402 | + $realpage = $urlwithroot.'/public/website/index.php?website='.$websitekey.'&pageref='.$websitepage->pageurl; |
|
| 2403 | 2403 | $pagealias = $websitepage->pageurl; |
| 2404 | 2404 | |
| 2405 | 2405 | $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot); |
| 2406 | - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); |
|
| 2407 | - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); |
|
| 2406 | + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); |
|
| 2407 | + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); |
|
| 2408 | 2408 | |
| 2409 | 2409 | print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$websitekey.'" alt="'.dol_escape_htmltag($htmltext).'">'; |
| 2410 | 2410 | print $form->textwithpicto('', $htmltext, 1, 'preview'); |
| 2411 | - print '</a>'; // View page in new Tab |
|
| 2411 | + print '</a>'; // View page in new Tab |
|
| 2412 | 2412 | |
| 2413 | 2413 | print '<div class="websiteinputurl" id="websiteinputpage">'; |
| 2414 | 2414 | print '<input type="text" id="previewpageurl" class="minwidth200imp" name="previewsite" value="'.$pagealias.'" disabled="disabled">'; |
| 2415 | - $htmltext=$langs->trans("PageNameAliasHelp", $langs->transnoentitiesnoconv("EditPageMeta")); |
|
| 2415 | + $htmltext = $langs->trans("PageNameAliasHelp", $langs->transnoentitiesnoconv("EditPageMeta")); |
|
| 2416 | 2416 | print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helppagealias'); |
| 2417 | 2417 | print '</div>'; |
| 2418 | 2418 | |
| 2419 | - $urlext=$virtualurl.'/'.$pagealias.'.php'; |
|
| 2420 | - $urlint=$urlwithroot.'/public/website/index.php?website='.$websitekey; |
|
| 2419 | + $urlext = $virtualurl.'/'.$pagealias.'.php'; |
|
| 2420 | + $urlint = $urlwithroot.'/public/website/index.php?website='.$websitekey; |
|
| 2421 | 2421 | |
| 2422 | - $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $virtualurl?$urlext:'<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'); |
|
| 2422 | + $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $virtualurl ? $urlext : '<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'); |
|
| 2423 | 2423 | |
| 2424 | - print '<a class="websitebuttonsitepreview'.($virtualurl?'':' websitebuttonsitepreviewdisabled cursornotallowed').'" id="previewpageext" href="'.$urlext.'" target="tab'.$websitekey.'ext" alt="'.dol_escape_htmltag($htmltext).'">'; |
|
| 2424 | + print '<a class="websitebuttonsitepreview'.($virtualurl ? '' : ' websitebuttonsitepreviewdisabled cursornotallowed').'" id="previewpageext" href="'.$urlext.'" target="tab'.$websitekey.'ext" alt="'.dol_escape_htmltag($htmltext).'">'; |
|
| 2425 | 2425 | print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); |
| 2426 | 2426 | print '</a>'; |
| 2427 | 2427 | //print '<input type="submit" class="button" name="previewpage" target="tab'.$websitekey.'"value="'.$langs->trans("ViewPageInNewTab").'">'; |
| 2428 | 2428 | |
| 2429 | 2429 | // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext |
| 2430 | 2430 | } |
| 2431 | - if (! in_array($action, array('editcss','editmenu','file_manager','replacesite','replacesiteconfirm','createsite','createcontainer','createfromclone','createpagefromclone','deletesite'))) |
|
| 2431 | + if (!in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesite', 'replacesiteconfirm', 'createsite', 'createcontainer', 'createfromclone', 'createpagefromclone', 'deletesite'))) |
|
| 2432 | 2432 | { |
| 2433 | 2433 | if (preg_match('/^create/', $action)) print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; |
| 2434 | 2434 | if (preg_match('/^edit/', $action)) print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; |
| 2435 | 2435 | if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">'; |
| 2436 | 2436 | } |
| 2437 | 2437 | |
| 2438 | - print '</span>'; // end websitetools |
|
| 2438 | + print '</span>'; // end websitetools |
|
| 2439 | 2439 | |
| 2440 | 2440 | print '<span class="websitehelp">'; |
| 2441 | 2441 | if (GETPOST('editsource', 'alpha') || GETPOST('editcontent', 'alpha')) |
| 2442 | 2442 | { |
| 2443 | - $htmltext=$langs->transnoentitiesnoconv("YouCanEditHtmlSource").'<br>'; |
|
| 2443 | + $htmltext = $langs->transnoentitiesnoconv("YouCanEditHtmlSource").'<br>'; |
|
| 2444 | 2444 | if ($conf->browser->layout == 'phone') |
| 2445 | 2445 | { |
| 2446 | 2446 | print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block', 1, 2, 'tooltipsubstitution'); |
@@ -2451,14 +2451,14 @@ discard block |
||
| 2451 | 2451 | print $form->textwithpicto($langs->trans("SyntaxHelp").' '.img_help(2, $langs->trans("SyntaxHelp")), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution'); |
| 2452 | 2452 | } |
| 2453 | 2453 | } |
| 2454 | - print '</span>'; // end websitehelp |
|
| 2454 | + print '</span>'; // end websitehelp |
|
| 2455 | 2455 | |
| 2456 | 2456 | |
| 2457 | 2457 | |
| 2458 | 2458 | if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') |
| 2459 | 2459 | { |
| 2460 | 2460 | // Adding jquery code to change on the fly url of preview ext |
| 2461 | - if (! empty($conf->use_javascript_ajax)) |
|
| 2461 | + if (!empty($conf->use_javascript_ajax)) |
|
| 2462 | 2462 | { |
| 2463 | 2463 | print '<script type="text/javascript" language="javascript"> |
| 2464 | 2464 | jQuery(document).ready(function() { |
@@ -2506,7 +2506,7 @@ discard block |
||
| 2506 | 2506 | } |
| 2507 | 2507 | } |
| 2508 | 2508 | |
| 2509 | - print '</div>'; // end current websitebar |
|
| 2509 | + print '</div>'; // end current websitebar |
|
| 2510 | 2510 | } |
| 2511 | 2511 | |
| 2512 | 2512 | |
@@ -2524,7 +2524,7 @@ discard block |
||
| 2524 | 2524 | |
| 2525 | 2525 | print '<br>'; |
| 2526 | 2526 | |
| 2527 | - if (! GETPOSTISSET('WEBSITE_CSS_INLINE')) |
|
| 2527 | + if (!GETPOSTISSET('WEBSITE_CSS_INLINE')) |
|
| 2528 | 2528 | { |
| 2529 | 2529 | $csscontent = @file_get_contents($filecss); |
| 2530 | 2530 | // Clean the php css file to remove php code and get only css part |
@@ -2534,9 +2534,9 @@ discard block |
||
| 2534 | 2534 | { |
| 2535 | 2535 | $csscontent = GETPOST('WEBSITE_CSS_INLINE', 'none'); |
| 2536 | 2536 | } |
| 2537 | - if (! trim($csscontent)) $csscontent='/* CSS content (all pages) */'."\n"."body.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}"; |
|
| 2537 | + if (!trim($csscontent)) $csscontent = '/* CSS content (all pages) */'."\n"."body.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}"; |
|
| 2538 | 2538 | |
| 2539 | - if (! GETPOSTISSET('WEBSITE_JS_INLINE')) |
|
| 2539 | + if (!GETPOSTISSET('WEBSITE_JS_INLINE')) |
|
| 2540 | 2540 | { |
| 2541 | 2541 | $jscontent = @file_get_contents($filejs); |
| 2542 | 2542 | // Clean the php js file to remove php code and get only js part |
@@ -2546,9 +2546,9 @@ discard block |
||
| 2546 | 2546 | { |
| 2547 | 2547 | $jscontent = GETPOST('WEBSITE_JS_INLINE', 'none'); |
| 2548 | 2548 | } |
| 2549 | - if (! trim($jscontent)) $jscontent='/* JS content (all pages) */'."\n"; |
|
| 2549 | + if (!trim($jscontent)) $jscontent = '/* JS content (all pages) */'."\n"; |
|
| 2550 | 2550 | |
| 2551 | - if (! GETPOSTISSET('WEBSITE_HTML_HEADER')) |
|
| 2551 | + if (!GETPOSTISSET('WEBSITE_HTML_HEADER')) |
|
| 2552 | 2552 | { |
| 2553 | 2553 | $htmlheadercontent = @file_get_contents($filehtmlheader); |
| 2554 | 2554 | // Clean the php htmlheader file to remove php code and get only html part |
@@ -2558,20 +2558,20 @@ discard block |
||
| 2558 | 2558 | { |
| 2559 | 2559 | $htmlheadercontent = GETPOST('WEBSITE_HTML_HEADER', 'none'); |
| 2560 | 2560 | } |
| 2561 | - if (! trim($htmlheadercontent)) |
|
| 2561 | + if (!trim($htmlheadercontent)) |
|
| 2562 | 2562 | { |
| 2563 | - $htmlheadercontent ="<html>\n"; |
|
| 2564 | - $htmlheadercontent.=$htmlheadercontentdefault; |
|
| 2565 | - $htmlheadercontent.="</html>"; |
|
| 2563 | + $htmlheadercontent = "<html>\n"; |
|
| 2564 | + $htmlheadercontent .= $htmlheadercontentdefault; |
|
| 2565 | + $htmlheadercontent .= "</html>"; |
|
| 2566 | 2566 | } |
| 2567 | 2567 | else |
| 2568 | 2568 | { |
| 2569 | 2569 | $htmlheadercontent = preg_replace('/^\s*<html>/ims', '', $htmlheadercontent); |
| 2570 | 2570 | $htmlheadercontent = preg_replace('/<\/html>\s*$/ims', '', $htmlheadercontent); |
| 2571 | - $htmlheadercontent='<html>'."\n".trim($htmlheadercontent)."\n".'</html>'; |
|
| 2571 | + $htmlheadercontent = '<html>'."\n".trim($htmlheadercontent)."\n".'</html>'; |
|
| 2572 | 2572 | } |
| 2573 | 2573 | |
| 2574 | - if (! GETPOSTISSET('WEBSITE_ROBOT')) |
|
| 2574 | + if (!GETPOSTISSET('WEBSITE_ROBOT')) |
|
| 2575 | 2575 | { |
| 2576 | 2576 | $robotcontent = @file_get_contents($filerobot); |
| 2577 | 2577 | // Clean the php htmlheader file to remove php code and get only html part |
@@ -2581,15 +2581,15 @@ discard block |
||
| 2581 | 2581 | { |
| 2582 | 2582 | $robotcontent = GETPOST('WEBSITE_ROBOT', 'nothtml'); |
| 2583 | 2583 | } |
| 2584 | - if (! trim($robotcontent)) |
|
| 2584 | + if (!trim($robotcontent)) |
|
| 2585 | 2585 | { |
| 2586 | - $robotcontent.="# Robot file. Generated with ".DOL_APPLICATION_TITLE."\n"; |
|
| 2587 | - $robotcontent.="User-agent: *\n"; |
|
| 2588 | - $robotcontent.="Allow: /public/\n"; |
|
| 2589 | - $robotcontent.="Disallow: /administrator/\n"; |
|
| 2586 | + $robotcontent .= "# Robot file. Generated with ".DOL_APPLICATION_TITLE."\n"; |
|
| 2587 | + $robotcontent .= "User-agent: *\n"; |
|
| 2588 | + $robotcontent .= "Allow: /public/\n"; |
|
| 2589 | + $robotcontent .= "Disallow: /administrator/\n"; |
|
| 2590 | 2590 | } |
| 2591 | 2591 | |
| 2592 | - if (! GETPOSTISSET('WEBSITE_HTACCESS')) |
|
| 2592 | + if (!GETPOSTISSET('WEBSITE_HTACCESS')) |
|
| 2593 | 2593 | { |
| 2594 | 2594 | $htaccesscontent = @file_get_contents($filehtaccess); |
| 2595 | 2595 | // Clean the php htaccesscontent file to remove php code and get only html part |
@@ -2599,14 +2599,14 @@ discard block |
||
| 2599 | 2599 | { |
| 2600 | 2600 | $htaccesscontent = GETPOST('WEBSITE_HTACCESS', 'nohtml'); |
| 2601 | 2601 | } |
| 2602 | - if (! trim($htaccesscontent)) |
|
| 2602 | + if (!trim($htaccesscontent)) |
|
| 2603 | 2603 | { |
| 2604 | - $htaccesscontent.="# Order allow,deny\n"; |
|
| 2605 | - $htaccesscontent.="# Deny from all\n"; |
|
| 2604 | + $htaccesscontent .= "# Order allow,deny\n"; |
|
| 2605 | + $htaccesscontent .= "# Deny from all\n"; |
|
| 2606 | 2606 | } |
| 2607 | 2607 | |
| 2608 | 2608 | |
| 2609 | - if (! GETPOSTISSET('WEBSITE_MANIFEST_JSON')) |
|
| 2609 | + if (!GETPOSTISSET('WEBSITE_MANIFEST_JSON')) |
|
| 2610 | 2610 | { |
| 2611 | 2611 | $manifestjsoncontent = @file_get_contents($filemanifestjson); |
| 2612 | 2612 | // Clean the manifestjson file to remove php code and get only html part |
@@ -2616,12 +2616,12 @@ discard block |
||
| 2616 | 2616 | { |
| 2617 | 2617 | $manifestjsoncontent = GETPOST('WEBSITE_MANIFEST_JSON', 'none'); |
| 2618 | 2618 | } |
| 2619 | - if (! trim($manifestjsoncontent)) |
|
| 2619 | + if (!trim($manifestjsoncontent)) |
|
| 2620 | 2620 | { |
| 2621 | 2621 | //$manifestjsoncontent.=""; |
| 2622 | 2622 | } |
| 2623 | 2623 | |
| 2624 | - if (! GETPOSTISSET('WEBSITE_README')) |
|
| 2624 | + if (!GETPOSTISSET('WEBSITE_README')) |
|
| 2625 | 2625 | { |
| 2626 | 2626 | $readmecontent = @file_get_contents($filereadme); |
| 2627 | 2627 | // Clean the readme file to remove php code and get only html part |
@@ -2631,7 +2631,7 @@ discard block |
||
| 2631 | 2631 | { |
| 2632 | 2632 | $readmecontent = GETPOST('WEBSITE_README', 'none'); |
| 2633 | 2633 | } |
| 2634 | - if (! trim($readmecontent)) |
|
| 2634 | + if (!trim($readmecontent)) |
|
| 2635 | 2635 | { |
| 2636 | 2636 | //$readmecontent.=""; |
| 2637 | 2637 | } |
@@ -2652,9 +2652,9 @@ discard block |
||
| 2652 | 2652 | print '<tr><td class="tdtop">'; |
| 2653 | 2653 | |
| 2654 | 2654 | $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>'.$websitekey.'</i>'); |
| 2655 | - $htmltext.='<br>'; |
|
| 2656 | - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); |
|
| 2657 | - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); |
|
| 2655 | + $htmltext .= '<br>'; |
|
| 2656 | + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); |
|
| 2657 | + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); |
|
| 2658 | 2658 | |
| 2659 | 2659 | print $form->textwithpicto($langs->trans('Virtualhost'), $htmltext, 1, 'help', '', 0, 2, 'virtualhosttooltip'); |
| 2660 | 2660 | print '</td><td>'; |
@@ -2664,11 +2664,11 @@ discard block |
||
| 2664 | 2664 | |
| 2665 | 2665 | // CSS file |
| 2666 | 2666 | print '<tr><td class="tdtop">'; |
| 2667 | - $htmlhelp=$langs->trans("CSSContentTooltipHelp"); |
|
| 2667 | + $htmlhelp = $langs->trans("CSSContentTooltipHelp"); |
|
| 2668 | 2668 | print $form->textwithpicto($langs->trans('WEBSITE_CSS_INLINE'), $htmlhelp, 1, 'help', '', 0, 2, 'csstooltip'); |
| 2669 | 2669 | print '</td><td>'; |
| 2670 | 2670 | |
| 2671 | - $doleditor=new DolEditor('WEBSITE_CSS_INLINE', $csscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2671 | + $doleditor = new DolEditor('WEBSITE_CSS_INLINE', $csscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2672 | 2672 | print $doleditor->Create(1, '', true, 'CSS', 'css'); |
| 2673 | 2673 | |
| 2674 | 2674 | print '</td></tr>'; |
@@ -2678,7 +2678,7 @@ discard block |
||
| 2678 | 2678 | print $langs->trans('WEBSITE_JS_INLINE'); |
| 2679 | 2679 | print '</td><td>'; |
| 2680 | 2680 | |
| 2681 | - $doleditor=new DolEditor('WEBSITE_JS_INLINE', $jscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2681 | + $doleditor = new DolEditor('WEBSITE_JS_INLINE', $jscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2682 | 2682 | print $doleditor->Create(1, '', true, 'JS', 'javascript'); |
| 2683 | 2683 | |
| 2684 | 2684 | print '</td></tr>'; |
@@ -2686,14 +2686,14 @@ discard block |
||
| 2686 | 2686 | // Common HTML header |
| 2687 | 2687 | print '<tr><td class="tdtop">'; |
| 2688 | 2688 | print $langs->trans('WEBSITE_HTML_HEADER'); |
| 2689 | - $htmlhelp=$langs->trans("Example").' :<br>'; |
|
| 2690 | - $htmlhelp.=dol_htmlentitiesbr($htmlheadercontentdefault); |
|
| 2689 | + $htmlhelp = $langs->trans("Example").' :<br>'; |
|
| 2690 | + $htmlhelp .= dol_htmlentitiesbr($htmlheadercontentdefault); |
|
| 2691 | 2691 | $textwithhelp = $form->textwithpicto('', $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip'); |
| 2692 | - $htmlhelp2=$langs->trans("LinkAndScriptsHereAreNotLoadedInEditor").'<br>'; |
|
| 2692 | + $htmlhelp2 = $langs->trans("LinkAndScriptsHereAreNotLoadedInEditor").'<br>'; |
|
| 2693 | 2693 | print $form->textwithpicto($textwithhelp, $htmlhelp2, 1, 'warning', '', 0, 2, 'htmlheadertooltip2'); |
| 2694 | 2694 | print '</td><td>'; |
| 2695 | 2695 | |
| 2696 | - $doleditor=new DolEditor('WEBSITE_HTML_HEADER', $htmlheadercontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2696 | + $doleditor = new DolEditor('WEBSITE_HTML_HEADER', $htmlheadercontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2697 | 2697 | print $doleditor->Create(1, '', true, 'HTML Header', 'html'); |
| 2698 | 2698 | |
| 2699 | 2699 | print '</td></tr>'; |
@@ -2703,7 +2703,7 @@ discard block |
||
| 2703 | 2703 | print $langs->trans('WEBSITE_ROBOT'); |
| 2704 | 2704 | print '</td><td>'; |
| 2705 | 2705 | |
| 2706 | - $doleditor=new DolEditor('WEBSITE_ROBOT', $robotcontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2706 | + $doleditor = new DolEditor('WEBSITE_ROBOT', $robotcontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2707 | 2707 | print $doleditor->Create(1, '', true, 'Robot file', 'text'); |
| 2708 | 2708 | |
| 2709 | 2709 | print '</td></tr>'; |
@@ -2713,30 +2713,30 @@ discard block |
||
| 2713 | 2713 | print $langs->trans('WEBSITE_HTACCESS'); |
| 2714 | 2714 | print '</td><td>'; |
| 2715 | 2715 | |
| 2716 | - $doleditor=new DolEditor('WEBSITE_HTACCESS', $htaccesscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2716 | + $doleditor = new DolEditor('WEBSITE_HTACCESS', $htaccesscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2717 | 2717 | print $doleditor->Create(1, '', true, $langs->trans("File").' .htaccess', 'text'); |
| 2718 | 2718 | |
| 2719 | 2719 | print '</td></tr>'; |
| 2720 | 2720 | |
| 2721 | 2721 | // Manifest.json |
| 2722 | 2722 | print '<tr><td class="tdtop">'; |
| 2723 | - $htmlhelp=$langs->trans("Example").' :<br>'; |
|
| 2724 | - $htmlhelp.=dol_htmlentitiesbr($manifestjsoncontentdefault); |
|
| 2723 | + $htmlhelp = $langs->trans("Example").' :<br>'; |
|
| 2724 | + $htmlhelp .= dol_htmlentitiesbr($manifestjsoncontentdefault); |
|
| 2725 | 2725 | print $form->textwithpicto($langs->trans('WEBSITE_MANIFEST_JSON'), $htmlhelp, 1, 'help', '', 0, 2, 'manifestjsontooltip'); |
| 2726 | 2726 | print '</td><td>'; |
| 2727 | 2727 | |
| 2728 | - $doleditor=new DolEditor('WEBSITE_MANIFEST_JSON', $manifestjsoncontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2728 | + $doleditor = new DolEditor('WEBSITE_MANIFEST_JSON', $manifestjsoncontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2729 | 2729 | print $doleditor->Create(1, '', true, $langs->trans("File").' manifest.json', 'text'); |
| 2730 | 2730 | |
| 2731 | 2731 | print '</td></tr>'; |
| 2732 | 2732 | |
| 2733 | 2733 | // README.md |
| 2734 | 2734 | print '<tr><td class="tdtop">'; |
| 2735 | - $htmlhelp=$langs->trans("EnterHereLicenseInformation"); |
|
| 2735 | + $htmlhelp = $langs->trans("EnterHereLicenseInformation"); |
|
| 2736 | 2736 | print $form->textwithpicto($langs->trans('WEBSITE_README'), $htmlhelp, 1, 'help', '', 0, 2, 'readmetooltip'); |
| 2737 | 2737 | print '</td><td>'; |
| 2738 | 2738 | |
| 2739 | - $doleditor=new DolEditor('WEBSITE_README', $readmecontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2739 | + $doleditor = new DolEditor('WEBSITE_README', $readmecontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); |
|
| 2740 | 2740 | print $doleditor->Create(1, '', true, $langs->trans("File").' README.md', 'text'); |
| 2741 | 2741 | |
| 2742 | 2742 | print '</td></tr>'; |
@@ -2774,8 +2774,8 @@ discard block |
||
| 2774 | 2774 | |
| 2775 | 2775 | print '<table class="border centpercent">'; |
| 2776 | 2776 | |
| 2777 | - if (GETPOST('WEBSITE_REF')) $siteref=GETPOST('WEBSITE_REF', 'alpha'); |
|
| 2778 | - if (GETPOST('WEBSITE_DESCRIPTION')) $sitedesc=GETPOST('WEBSITE_DESCRIPTION', 'alpha'); |
|
| 2777 | + if (GETPOST('WEBSITE_REF')) $siteref = GETPOST('WEBSITE_REF', 'alpha'); |
|
| 2778 | + if (GETPOST('WEBSITE_DESCRIPTION')) $sitedesc = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); |
|
| 2779 | 2779 | |
| 2780 | 2780 | print '<tr><td class="titlefieldcreate fieldrequired">'; |
| 2781 | 2781 | print $langs->trans('Ref'); |
@@ -2792,9 +2792,9 @@ discard block |
||
| 2792 | 2792 | print '<tr><td>'; |
| 2793 | 2793 | |
| 2794 | 2794 | $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>'); |
| 2795 | - $htmltext.='<br>'; |
|
| 2796 | - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); |
|
| 2797 | - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); |
|
| 2795 | + $htmltext .= '<br>'; |
|
| 2796 | + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); |
|
| 2797 | + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); |
|
| 2798 | 2798 | |
| 2799 | 2799 | print $form->textwithpicto($langs->trans('Virtualhost'), $htmltext, 1, 'help', '', 0, 2, 'virtualhosttooltip'); |
| 2800 | 2800 | print '</td><td>'; |
@@ -2882,15 +2882,15 @@ discard block |
||
| 2882 | 2882 | if (GETPOST('radiocreatefrom') == 'checkboxcreatemanually') $hiddenmanuallyafterload = ''; |
| 2883 | 2883 | |
| 2884 | 2884 | if ($action == 'editmeta' || empty($conf->use_javascript_ajax)) { // No autohide/show in such case |
| 2885 | - $hiddenfromfetchingafterload=''; |
|
| 2886 | - $hiddenmanuallyafterload=''; |
|
| 2885 | + $hiddenfromfetchingafterload = ''; |
|
| 2886 | + $hiddenmanuallyafterload = ''; |
|
| 2887 | 2887 | } |
| 2888 | 2888 | |
| 2889 | 2889 | if ($action == 'createcontainer') |
| 2890 | 2890 | { |
| 2891 | 2891 | print '<br>'; |
| 2892 | 2892 | |
| 2893 | - if (! empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching' ? ' checked' : '').'> '; |
|
| 2893 | + if (!empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching' ? ' checked' : '').'> '; |
|
| 2894 | 2894 | print '<label for="checkboxcreatefromfetching"><span class="opacitymedium">'.$langs->trans("CreateByFetchingExternalPage").'</span></label><br>'; |
| 2895 | 2895 | print '<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">'; |
| 2896 | 2896 | print '<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">'; |
@@ -2902,8 +2902,8 @@ discard block |
||
| 2902 | 2902 | print '<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans("GrabImagesInto"); |
| 2903 | 2903 | print ' '; |
| 2904 | 2904 | print $langs->trans("ImagesShouldBeSavedInto").' '; |
| 2905 | - $arraygrabimagesinto=array('root'=>$langs->trans("WebsiteRootOfImages"), 'subpage'=>$langs->trans("SubdirOfPage")); |
|
| 2906 | - print $form->selectarray('grabimagesinto', $arraygrabimagesinto, GETPOSTISSET('grabimagesinto')?GETPOST('grabimagesinto'):'root'); |
|
| 2905 | + $arraygrabimagesinto = array('root'=>$langs->trans("WebsiteRootOfImages"), 'subpage'=>$langs->trans("SubdirOfPage")); |
|
| 2906 | + print $form->selectarray('grabimagesinto', $arraygrabimagesinto, GETPOSTISSET('grabimagesinto') ?GETPOST('grabimagesinto') : 'root'); |
|
| 2907 | 2907 | print '<br>'; |
| 2908 | 2908 | print '<input class="button" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans("FetchAndCreate")).'">'; |
| 2909 | 2909 | print '</td></tr>'; |
@@ -2911,7 +2911,7 @@ discard block |
||
| 2911 | 2911 | |
| 2912 | 2912 | print '<br>'; |
| 2913 | 2913 | |
| 2914 | - if (! empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST('radiocreatefrom') == 'checkboxcreatemanually' ? ' checked' : '').'> '; |
|
| 2914 | + if (!empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST('radiocreatefrom') == 'checkboxcreatemanually' ? ' checked' : '').'> '; |
|
| 2915 | 2915 | print '<label for="checkboxcreatemanually"><span class="opacitymedium">'.$langs->trans("OrEnterPageInfoManually").'</span></label><br>'; |
| 2916 | 2916 | print '<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.'">'; |
| 2917 | 2917 | } |
@@ -2933,35 +2933,35 @@ discard block |
||
| 2933 | 2933 | //if ($objectpage->grabbed_from) print ' - <span class="opacitymedium">'.$langs->trans('InitiallyGrabbedFrom').' '.$objectpage->grabbed_from.'</span>'; |
| 2934 | 2934 | print '</td></tr>'; |
| 2935 | 2935 | |
| 2936 | - $type_container=$objectpage->type_container; |
|
| 2937 | - $pageurl=$objectpage->pageurl; |
|
| 2938 | - $pagealiasalt=$objectpage->aliasalt; |
|
| 2939 | - $pagetitle=$objectpage->title; |
|
| 2940 | - $pagedescription=$objectpage->description; |
|
| 2941 | - $pageimage=$objectpage->image; |
|
| 2942 | - $pagekeywords=$objectpage->keywords; |
|
| 2943 | - $pagelang=$objectpage->lang; |
|
| 2944 | - $pagehtmlheader=$objectpage->htmlheader; |
|
| 2945 | - $pagedatecreation=$objectpage->date_creation; |
|
| 2946 | - $pagedatemodification=$objectpage->date_modification; |
|
| 2947 | - $pageauthorid=$objectpage->fk_user_creat; |
|
| 2948 | - $pageusermodifid=$objectpage->fk_user_modif; |
|
| 2936 | + $type_container = $objectpage->type_container; |
|
| 2937 | + $pageurl = $objectpage->pageurl; |
|
| 2938 | + $pagealiasalt = $objectpage->aliasalt; |
|
| 2939 | + $pagetitle = $objectpage->title; |
|
| 2940 | + $pagedescription = $objectpage->description; |
|
| 2941 | + $pageimage = $objectpage->image; |
|
| 2942 | + $pagekeywords = $objectpage->keywords; |
|
| 2943 | + $pagelang = $objectpage->lang; |
|
| 2944 | + $pagehtmlheader = $objectpage->htmlheader; |
|
| 2945 | + $pagedatecreation = $objectpage->date_creation; |
|
| 2946 | + $pagedatemodification = $objectpage->date_modification; |
|
| 2947 | + $pageauthorid = $objectpage->fk_user_creat; |
|
| 2948 | + $pageusermodifid = $objectpage->fk_user_modif; |
|
| 2949 | 2949 | } |
| 2950 | 2950 | else |
| 2951 | 2951 | { |
| 2952 | 2952 | $type_container = 'page'; |
| 2953 | - $pagedatecreation=dol_now(); |
|
| 2954 | - $pageauthorid=$user->id; |
|
| 2955 | - $pageusermodifid=0; |
|
| 2956 | - } |
|
| 2957 | - if (GETPOST('WEBSITE_TITLE', 'alpha')) $pagetitle=GETPOST('WEBSITE_TITLE', 'alpha'); |
|
| 2958 | - if (GETPOST('WEBSITE_PAGENAME', 'alpha')) $pageurl=GETPOST('WEBSITE_PAGENAME', 'alpha'); |
|
| 2959 | - if (GETPOST('WEBSITE_ALIASALT', 'alpha')) $pagealiasalt=GETPOST('WEBSITE_ALIASALT', 'alpha'); |
|
| 2960 | - if (GETPOST('WEBSITE_DESCRIPTION', 'alpha')) $pagedescription=GETPOST('WEBSITE_DESCRIPTION', 'alpha'); |
|
| 2961 | - if (GETPOST('WEBSITE_IMAGE', 'alpha')) $pageimage=GETPOST('WEBSITE_IMAGE', 'alpha'); |
|
| 2962 | - if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) $pagekeywords=GETPOST('WEBSITE_KEYWORDS', 'alpha'); |
|
| 2963 | - if (GETPOST('WEBSITE_LANG', 'aZ09')) $pagelang=GETPOST('WEBSITE_LANG', 'aZ09'); |
|
| 2964 | - if (GETPOST('htmlheader', 'none')) $pagehtmlheader=GETPOST('htmlheader', 'none'); |
|
| 2953 | + $pagedatecreation = dol_now(); |
|
| 2954 | + $pageauthorid = $user->id; |
|
| 2955 | + $pageusermodifid = 0; |
|
| 2956 | + } |
|
| 2957 | + if (GETPOST('WEBSITE_TITLE', 'alpha')) $pagetitle = GETPOST('WEBSITE_TITLE', 'alpha'); |
|
| 2958 | + if (GETPOST('WEBSITE_PAGENAME', 'alpha')) $pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha'); |
|
| 2959 | + if (GETPOST('WEBSITE_ALIASALT', 'alpha')) $pagealiasalt = GETPOST('WEBSITE_ALIASALT', 'alpha'); |
|
| 2960 | + if (GETPOST('WEBSITE_DESCRIPTION', 'alpha')) $pagedescription = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); |
|
| 2961 | + if (GETPOST('WEBSITE_IMAGE', 'alpha')) $pageimage = GETPOST('WEBSITE_IMAGE', 'alpha'); |
|
| 2962 | + if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) $pagekeywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); |
|
| 2963 | + if (GETPOST('WEBSITE_LANG', 'aZ09')) $pagelang = GETPOST('WEBSITE_LANG', 'aZ09'); |
|
| 2964 | + if (GETPOST('htmlheader', 'none')) $pagehtmlheader = GETPOST('htmlheader', 'none'); |
|
| 2965 | 2965 | |
| 2966 | 2966 | // Title |
| 2967 | 2967 | print '<tr><td class="fieldrequired">'; |
@@ -2981,7 +2981,7 @@ discard block |
||
| 2981 | 2981 | print '<tr><td class="titlefield fieldrequired">'; |
| 2982 | 2982 | print $langs->trans('WEBSITE_TYPE_CONTAINER'); |
| 2983 | 2983 | print '</td><td>'; |
| 2984 | - print $formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha')?GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'):$type_container)); |
|
| 2984 | + print $formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') ?GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') : $type_container)); |
|
| 2985 | 2985 | print '</td></tr>'; |
| 2986 | 2986 | |
| 2987 | 2987 | if ($action == 'createcontainer') |
@@ -2989,7 +2989,7 @@ discard block |
||
| 2989 | 2989 | print '<tr><td class="titlefield fieldrequired">'; |
| 2990 | 2990 | print $langs->trans('WEBSITE_PAGE_EXAMPLE'); |
| 2991 | 2991 | print '</td><td>'; |
| 2992 | - print $formwebsite->selectSampleOfContainer('sample', (GETPOSTISSET('sample')?GETPOST('sample', 'alpha'):'empty')); |
|
| 2992 | + print $formwebsite->selectSampleOfContainer('sample', (GETPOSTISSET('sample') ?GETPOST('sample', 'alpha') : 'empty')); |
|
| 2993 | 2993 | print '</td></tr>'; |
| 2994 | 2994 | } |
| 2995 | 2995 | |
@@ -3000,7 +3000,7 @@ discard block |
||
| 3000 | 3000 | print '</td></tr>'; |
| 3001 | 3001 | |
| 3002 | 3002 | print '<tr><td>'; |
| 3003 | - $htmlhelp=$langs->trans("WEBSITE_IMAGEDesc"); |
|
| 3003 | + $htmlhelp = $langs->trans("WEBSITE_IMAGEDesc"); |
|
| 3004 | 3004 | print $form->textwithpicto($langs->trans('WEBSITE_IMAGE'), $htmlhelp, 1, 'help', '', 0, 2, 'imagetooltip'); |
| 3005 | 3005 | print '</td><td>'; |
| 3006 | 3006 | print '<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).'">'; |
@@ -3015,19 +3015,19 @@ discard block |
||
| 3015 | 3015 | print '<tr><td>'; |
| 3016 | 3016 | print $langs->trans('Language'); |
| 3017 | 3017 | print '</td><td>'; |
| 3018 | - print $formadmin->select_language($pagelang?$pagelang:$langs->defaultlang, 'WEBSITE_LANG', 0, null, '1'); |
|
| 3018 | + print $formadmin->select_language($pagelang ? $pagelang : $langs->defaultlang, 'WEBSITE_LANG', 0, null, '1'); |
|
| 3019 | 3019 | print '</td></tr>'; |
| 3020 | 3020 | |
| 3021 | 3021 | // Translation of |
| 3022 | - $translationof=0; |
|
| 3023 | - $translatedby=0; |
|
| 3022 | + $translationof = 0; |
|
| 3023 | + $translatedby = 0; |
|
| 3024 | 3024 | print '<!-- Translation of --><tr><td>'; |
| 3025 | 3025 | print $langs->trans('TranslationLinks'); |
| 3026 | 3026 | print '</td><td>'; |
| 3027 | 3027 | if ($action != 'createcontainer') |
| 3028 | 3028 | { |
| 3029 | 3029 | // Has translation pages |
| 3030 | - $sql='SELECT rowid, lang from '.MAIN_DB_PREFIX.'website_page where fk_page = '.$objectpage->id; |
|
| 3030 | + $sql = 'SELECT rowid, lang from '.MAIN_DB_PREFIX.'website_page where fk_page = '.$objectpage->id; |
|
| 3031 | 3031 | $resql = $db->query($sql); |
| 3032 | 3032 | if ($resql) |
| 3033 | 3033 | { |
@@ -3035,10 +3035,10 @@ discard block |
||
| 3035 | 3035 | if ($num_rows > 0) |
| 3036 | 3036 | { |
| 3037 | 3037 | print '<span class="opacitymedium">'.$langs->trans('ThisPageHasTranslationPages').':</span><br>'; |
| 3038 | - $i=0; |
|
| 3038 | + $i = 0; |
|
| 3039 | 3039 | while ($obj = $db->fetch_object($resql)) |
| 3040 | 3040 | { |
| 3041 | - $tmppage=new WebsitePage($db); |
|
| 3041 | + $tmppage = new WebsitePage($db); |
|
| 3042 | 3042 | $tmppage->fetch($obj->rowid); |
| 3043 | 3043 | if ($i > 0) print ' - '; |
| 3044 | 3044 | print $tmppage->getNomUrl(1).' ('.$tmppage->lang.')<br>'; |
@@ -3051,7 +3051,7 @@ discard block |
||
| 3051 | 3051 | } |
| 3052 | 3052 | if (empty($translatedby) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)) |
| 3053 | 3053 | { |
| 3054 | - $sourcepage=new WebsitePage($db); |
|
| 3054 | + $sourcepage = new WebsitePage($db); |
|
| 3055 | 3055 | $result = $sourcepage->fetch($objectpage->fk_page); |
| 3056 | 3056 | if ($result == 0) |
| 3057 | 3057 | { |
@@ -3067,13 +3067,13 @@ discard block |
||
| 3067 | 3067 | print '</td></tr>'; |
| 3068 | 3068 | |
| 3069 | 3069 | print '<tr><td class="titlefieldcreate">'; |
| 3070 | - $htmlhelp=$langs->trans("WEBSITE_ALIASALTDesc"); |
|
| 3070 | + $htmlhelp = $langs->trans("WEBSITE_ALIASALTDesc"); |
|
| 3071 | 3071 | print $form->textwithpicto($langs->trans('WEBSITE_ALIASALT'), $htmlhelp, 1, 'help', '', 0, 2, 'aliastooltip'); |
| 3072 | 3072 | print '</td><td>'; |
| 3073 | 3073 | print '<input type="text" class="flat minwidth300" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).'">'; |
| 3074 | 3074 | print '</td></tr>'; |
| 3075 | 3075 | |
| 3076 | - $fuser=new User($db); |
|
| 3076 | + $fuser = new User($db); |
|
| 3077 | 3077 | |
| 3078 | 3078 | print '<tr><td>'; |
| 3079 | 3079 | print $langs->trans('Author'); |
@@ -3112,12 +3112,12 @@ discard block |
||
| 3112 | 3112 | } |
| 3113 | 3113 | |
| 3114 | 3114 | print '<tr><td class="tdhtmlheader tdtop">'; |
| 3115 | - $htmlhelp =$langs->trans("EditTheWebSiteForACommonHeader").'<br><br>'; |
|
| 3116 | - $htmlhelp.=$langs->trans("Example").' :<br>'; |
|
| 3117 | - $htmlhelp.=dol_htmlentitiesbr($htmlheadercontentdefault); |
|
| 3115 | + $htmlhelp = $langs->trans("EditTheWebSiteForACommonHeader").'<br><br>'; |
|
| 3116 | + $htmlhelp .= $langs->trans("Example").' :<br>'; |
|
| 3117 | + $htmlhelp .= dol_htmlentitiesbr($htmlheadercontentdefault); |
|
| 3118 | 3118 | print $form->textwithpicto($langs->trans('HtmlHeaderPage'), $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip'); |
| 3119 | 3119 | print '</td><td>'; |
| 3120 | - $doleditor=new DolEditor('htmlheader', $pagehtmlheader, '', '120', 'ace', 'In', true, false, 'ace', ROWS_3, '100%', ''); |
|
| 3120 | + $doleditor = new DolEditor('htmlheader', $pagehtmlheader, '', '120', 'ace', 'In', true, false, 'ace', ROWS_3, '100%', ''); |
|
| 3121 | 3121 | print $doleditor->Create(1, '', true, 'HTML Header', 'html'); |
| 3122 | 3122 | print '</td></tr>'; |
| 3123 | 3123 | |
@@ -3185,7 +3185,7 @@ discard block |
||
| 3185 | 3185 | //print '<div class="center">'.$langs->trans("FeatureNotYetAvailable").'</center>'; |
| 3186 | 3186 | |
| 3187 | 3187 | $module = 'medias'; |
| 3188 | - if (empty($url)) $url=DOL_URL_ROOT.'/website/index.php'; // Must be an url without param |
|
| 3188 | + if (empty($url)) $url = DOL_URL_ROOT.'/website/index.php'; // Must be an url without param |
|
| 3189 | 3189 | include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php'; |
| 3190 | 3190 | |
| 3191 | 3191 | print '</div>'; |
@@ -3207,15 +3207,15 @@ discard block |
||
| 3207 | 3207 | //$contentforedit.='</style>'."\n"; |
| 3208 | 3208 | $contentforedit .= $objectpage->content; |
| 3209 | 3209 | //var_dump($_SESSION["dol_screenheight"]); |
| 3210 | - $maxheightwin=480; |
|
| 3210 | + $maxheightwin = 480; |
|
| 3211 | 3211 | if (isset($_SESSION["dol_screenheight"])) |
| 3212 | 3212 | { |
| 3213 | - if ($_SESSION["dol_screenheight"] > 680) $maxheightwin = $_SESSION["dol_screenheight"]-400; |
|
| 3214 | - if ($_SESSION["dol_screenheight"] > 800) $maxheightwin = $_SESSION["dol_screenheight"]-490; |
|
| 3213 | + if ($_SESSION["dol_screenheight"] > 680) $maxheightwin = $_SESSION["dol_screenheight"] - 400; |
|
| 3214 | + if ($_SESSION["dol_screenheight"] > 800) $maxheightwin = $_SESSION["dol_screenheight"] - 490; |
|
| 3215 | 3215 | } |
| 3216 | 3216 | //var_dump($_SESSION["dol_screenheight"]); |
| 3217 | 3217 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 3218 | - $doleditor=new DolEditor('PAGE_CONTENT', $contentforedit, '', $maxheightwin, 'Full', '', true, true, 'ace', ROWS_5, '40%'); |
|
| 3218 | + $doleditor = new DolEditor('PAGE_CONTENT', $contentforedit, '', $maxheightwin, 'Full', '', true, true, 'ace', ROWS_5, '40%'); |
|
| 3219 | 3219 | $doleditor->Create(0, '', false, 'HTML Source', 'php'); |
| 3220 | 3220 | } |
| 3221 | 3221 | |
@@ -3262,9 +3262,9 @@ discard block |
||
| 3262 | 3262 | print $langs->trans("SearchReplaceInto"); |
| 3263 | 3263 | print '</div>'; |
| 3264 | 3264 | print '<div class="tagtd">'; |
| 3265 | - print '<input type="checkbox" name="optioncontent" value="content"'.((! GETPOSTISSET('buttonreplacesitesearch') || GETPOST('optioncontent', 'aZ09'))?' checked':'').'> '.$langs->trans("Content"); |
|
| 3266 | - print '<input type="checkbox" class="marginleftonly" name="optionmeta" value="meta"'.(GETPOST('optionmeta', 'aZ09')?' checked':'').'> '.$langs->trans("Title").' | '.$langs->trans("Description").' | '.$langs->trans("Keywords"); |
|
| 3267 | - print '<input type="checkbox" class="marginleftonly" name="optionsitefiles" value="sitefiles"'.(GETPOST('optionsitefiles', 'aZ09')?' checked':'').'> '.$langs->trans("GlobalCSSorJS"); |
|
| 3265 | + print '<input type="checkbox" name="optioncontent" value="content"'.((!GETPOSTISSET('buttonreplacesitesearch') || GETPOST('optioncontent', 'aZ09')) ? ' checked' : '').'> '.$langs->trans("Content"); |
|
| 3266 | + print '<input type="checkbox" class="marginleftonly" name="optionmeta" value="meta"'.(GETPOST('optionmeta', 'aZ09') ? ' checked' : '').'> '.$langs->trans("Title").' | '.$langs->trans("Description").' | '.$langs->trans("Keywords"); |
|
| 3267 | + print '<input type="checkbox" class="marginleftonly" name="optionsitefiles" value="sitefiles"'.(GETPOST('optionsitefiles', 'aZ09') ? ' checked' : '').'> '.$langs->trans("GlobalCSSorJS"); |
|
| 3268 | 3268 | print '</div>'; |
| 3269 | 3269 | print '</div>'; |
| 3270 | 3270 | |
@@ -3286,9 +3286,9 @@ discard block |
||
| 3286 | 3286 | if ($action == 'replacesiteconfirm') |
| 3287 | 3287 | { |
| 3288 | 3288 | $algo = ''; |
| 3289 | - if (GETPOST('optionmeta')) $algo.='meta'; |
|
| 3290 | - if (GETPOST('optioncontent')) $algo.='content'; |
|
| 3291 | - if (GETPOST('optionsitefiles')) $algo.='sitefiles'; |
|
| 3289 | + if (GETPOST('optionmeta')) $algo .= 'meta'; |
|
| 3290 | + if (GETPOST('optioncontent')) $algo .= 'content'; |
|
| 3291 | + if (GETPOST('optionsitefiles')) $algo .= 'sitefiles'; |
|
| 3292 | 3292 | |
| 3293 | 3293 | $listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000); |
| 3294 | 3294 | |
@@ -3322,7 +3322,7 @@ discard block |
||
| 3322 | 3322 | print '<th>'.$langs->trans("Description").'</th>'; |
| 3323 | 3323 | print '</tr>'; |
| 3324 | 3324 | |
| 3325 | - foreach($listofpages['list'] as $answerrecord) |
|
| 3325 | + foreach ($listofpages['list'] as $answerrecord) |
|
| 3326 | 3326 | { |
| 3327 | 3327 | if (get_class($answerrecord) == 'WebsitePage') |
| 3328 | 3328 | { |
@@ -3383,11 +3383,11 @@ discard block |
||
| 3383 | 3383 | { |
| 3384 | 3384 | $out .= "<iframe><body></html>"; |
| 3385 | 3385 | }*/ |
| 3386 | - $out.="\n<html><head>\n"; |
|
| 3387 | - $out.="<!-- htmlheader/style of page from database -->\n"; |
|
| 3388 | - $out.=dolWebsiteReplacementOfLinks($object, $objectpage->htmlheader, 1, 'htmlheader'); |
|
| 3386 | + $out .= "\n<html><head>\n"; |
|
| 3387 | + $out .= "<!-- htmlheader/style of page from database -->\n"; |
|
| 3388 | + $out .= dolWebsiteReplacementOfLinks($object, $objectpage->htmlheader, 1, 'htmlheader'); |
|
| 3389 | 3389 | |
| 3390 | - $out.="<!-- htmlheader/style of website from files -->\n"; |
|
| 3390 | + $out .= "<!-- htmlheader/style of website from files -->\n"; |
|
| 3391 | 3391 | // TODO Keep only the <link> or the <script> tags |
| 3392 | 3392 | /* |
| 3393 | 3393 | $htmlheadercontent = @file_get_contents($filehtmlheader); |
@@ -3405,51 +3405,51 @@ discard block |
||
| 3405 | 3405 | } |
| 3406 | 3406 | */ |
| 3407 | 3407 | |
| 3408 | - $out.="</head>\n"; |
|
| 3409 | - $out.="\n<body>"; |
|
| 3408 | + $out .= "</head>\n"; |
|
| 3409 | + $out .= "\n<body>"; |
|
| 3410 | 3410 | |
| 3411 | 3411 | |
| 3412 | - $out.='<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'."\n"; |
|
| 3412 | + $out .= '<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'."\n"; |
|
| 3413 | 3413 | |
| 3414 | 3414 | // REPLACEMENT OF LINKS When page called by website editor |
| 3415 | 3415 | |
| 3416 | - $out.='<!-- style of website from file -->'."\n"; |
|
| 3417 | - $out.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". No more supported by browsers, snif ! |
|
| 3418 | - $tmpout=''; |
|
| 3419 | - $tmpout.= '/* Include website CSS file */'."\n"; |
|
| 3416 | + $out .= '<!-- style of website from file -->'."\n"; |
|
| 3417 | + $out .= '<style scoped>'."\n"; // "scoped" means "apply to parent element only". No more supported by browsers, snif ! |
|
| 3418 | + $tmpout = ''; |
|
| 3419 | + $tmpout .= '/* Include website CSS file */'."\n"; |
|
| 3420 | 3420 | //$csscontent = @file_get_contents($filecss); |
| 3421 | 3421 | ob_start(); |
| 3422 | 3422 | include $filecss; |
| 3423 | 3423 | $csscontent = ob_get_contents(); |
| 3424 | 3424 | ob_end_clean(); |
| 3425 | - $tmpout.= dolWebsiteReplacementOfLinks($object, $csscontent, 1, 'css'); |
|
| 3426 | - $tmpout.= '/* Include style from the HTML header of page */'."\n"; |
|
| 3425 | + $tmpout .= dolWebsiteReplacementOfLinks($object, $csscontent, 1, 'css'); |
|
| 3426 | + $tmpout .= '/* Include style from the HTML header of page */'."\n"; |
|
| 3427 | 3427 | // Clean the html header of page to get only <style> content |
| 3428 | 3428 | $tmp = preg_split('(<style[^>]*>|</style>)', $objectpage->htmlheader); |
| 3429 | - $tmpstyleinheader =''; |
|
| 3430 | - $i=0; |
|
| 3431 | - foreach($tmp as $valtmp) |
|
| 3429 | + $tmpstyleinheader = ''; |
|
| 3430 | + $i = 0; |
|
| 3431 | + foreach ($tmp as $valtmp) |
|
| 3432 | 3432 | { |
| 3433 | 3433 | $i++; |
| 3434 | - if ($i % 2 == 0) $tmpstyleinheader.=$valtmp."\n"; |
|
| 3434 | + if ($i % 2 == 0) $tmpstyleinheader .= $valtmp."\n"; |
|
| 3435 | 3435 | } |
| 3436 | - $tmpout.= $tmpstyleinheader."\n"; |
|
| 3436 | + $tmpout .= $tmpstyleinheader."\n"; |
|
| 3437 | 3437 | // Clean style that may affect global style of Dolibarr |
| 3438 | - $tmpout=preg_replace('/}[\s\n]*body\s*{[^}]+}/ims', '}', $tmpout); |
|
| 3439 | - $out.=$tmpout; |
|
| 3440 | - $out.='</style>'."\n"; |
|
| 3438 | + $tmpout = preg_replace('/}[\s\n]*body\s*{[^}]+}/ims', '}', $tmpout); |
|
| 3439 | + $out .= $tmpout; |
|
| 3440 | + $out .= '</style>'."\n"; |
|
| 3441 | 3441 | |
| 3442 | 3442 | // Note: <div> or <section> with contenteditable="true" inside this can be edited with inline ckeditor |
| 3443 | 3443 | |
| 3444 | 3444 | // Do not enable the contenteditable when page was grabbed, ckeditor is removing span and adding borders, |
| 3445 | 3445 | // so editable will be available only from container created from scratch |
| 3446 | 3446 | //$out.='<div id="bodywebsite" class="bodywebsite"'.($objectpage->grabbed_from ? ' contenteditable="true"' : '').'>'."\n"; |
| 3447 | - $out.='<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.'">'."\n"; |
|
| 3447 | + $out .= '<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.'">'."\n"; |
|
| 3448 | 3448 | |
| 3449 | 3449 | $newcontent = $objectpage->content; |
| 3450 | 3450 | |
| 3451 | 3451 | // If mode WEBSITE_SUBCONTAINERSINLINE is on |
| 3452 | - if (! empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) |
|
| 3452 | + if (!empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) |
|
| 3453 | 3453 | { |
| 3454 | 3454 | //var_dump($filetpl); |
| 3455 | 3455 | $filephp = $filetpl; |
@@ -3469,12 +3469,12 @@ discard block |
||
| 3469 | 3469 | { |
| 3470 | 3470 | // Keep the contenteditable="true" when mode Edit Inline is on |
| 3471 | 3471 | } |
| 3472 | - $out.=dolWebsiteReplacementOfLinks($object, $newcontent, 0, 'html', $objectpage->id)."\n"; |
|
| 3472 | + $out .= dolWebsiteReplacementOfLinks($object, $newcontent, 0, 'html', $objectpage->id)."\n"; |
|
| 3473 | 3473 | //$out.=$newcontent; |
| 3474 | 3474 | |
| 3475 | - $out.='</div>'; |
|
| 3475 | + $out .= '</div>'; |
|
| 3476 | 3476 | |
| 3477 | - $out.='</div> <!-- End div id=websitecontentundertopmenu -->'; |
|
| 3477 | + $out .= '</div> <!-- End div id=websitecontentundertopmenu -->'; |
|
| 3478 | 3478 | |
| 3479 | 3479 | /*if ($includepageintoaframeoradiv == 'iframe') |
| 3480 | 3480 | { |
@@ -3482,7 +3482,7 @@ discard block |
||
| 3482 | 3482 | }*/ |
| 3483 | 3483 | $out .= "\n</body></html>\n"; |
| 3484 | 3484 | |
| 3485 | - $out.= "\n".'<!-- End page content '.$filetpl.' -->'."\n\n"; |
|
| 3485 | + $out .= "\n".'<!-- End page content '.$filetpl.' -->'."\n\n"; |
|
| 3486 | 3486 | |
| 3487 | 3487 | print $out; |
| 3488 | 3488 | |
@@ -41,7 +41,9 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | $langs->loadLangs(array("admin","other","website","errors")); |
| 43 | 43 | |
| 44 | -if (! $user->rights->website->read) accessforbidden(); |
|
| 44 | +if (! $user->rights->website->read) { |
|
| 45 | + accessforbidden(); |
|
| 46 | +} |
|
| 45 | 47 | |
| 46 | 48 | $conf->dol_hide_leftmenu = 1; // Force hide of left menu. |
| 47 | 49 | |
@@ -66,7 +68,9 @@ discard block |
||
| 66 | 68 | |
| 67 | 69 | if (GETPOST('deletesite', 'alpha')) { $action='deletesite'; } |
| 68 | 70 | if (GETPOST('delete', 'alpha')) { $action='delete'; } |
| 69 | -if (GETPOST('preview', 'alpha')) $action='preview'; |
|
| 71 | +if (GETPOST('preview', 'alpha')) { |
|
| 72 | + $action='preview'; |
|
| 73 | +} |
|
| 70 | 74 | if (GETPOST('createsite', 'alpha')) { $action='createsite'; } |
| 71 | 75 | if (GETPOST('createcontainer', 'alpha')) { $action='createcontainer'; } |
| 72 | 76 | if (GETPOST('editcss', 'alpha')) { $action='editcss'; } |
@@ -79,10 +83,16 @@ discard block |
||
| 79 | 83 | if (GETPOST('importsite', 'alpha')) { $action='importsite'; } |
| 80 | 84 | if (GETPOST('createfromclone', 'alpha')) { $action='createfromclone'; } |
| 81 | 85 | if (GETPOST('createpagefromclone', 'alpha')) { $action='createpagefromclone'; } |
| 82 | -if (empty($action) && $file_manager) $action='file_manager'; |
|
| 83 | -if (empty($action) && $replacesite) $action='replacesite'; |
|
| 86 | +if (empty($action) && $file_manager) { |
|
| 87 | + $action='file_manager'; |
|
| 88 | +} |
|
| 89 | +if (empty($action) && $replacesite) { |
|
| 90 | + $action='replacesite'; |
|
| 91 | +} |
|
| 84 | 92 | |
| 85 | -if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x')) $pageid = 0; |
|
| 93 | +if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x')) { |
|
| 94 | + $pageid = 0; |
|
| 95 | +} |
|
| 86 | 96 | |
| 87 | 97 | // Load variable for pagination |
| 88 | 98 | $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; |
@@ -96,7 +106,9 @@ discard block |
||
| 96 | 106 | //if (! $sortfield) $sortfield='name'; |
| 97 | 107 | //if (! $sortorder) $sortorder='ASC'; |
| 98 | 108 | |
| 99 | -if (empty($action)) $action='preview'; |
|
| 109 | +if (empty($action)) { |
|
| 110 | + $action='preview'; |
|
| 111 | +} |
|
| 100 | 112 | |
| 101 | 113 | $object=new Website($db); |
| 102 | 114 | $objectpage=new WebsitePage($db); |
@@ -121,7 +133,9 @@ discard block |
||
| 121 | 133 | $website = $object; |
| 122 | 134 | |
| 123 | 135 | // Check pageid received as aprameter |
| 124 | -if ($pageid < 0) $pageid = 0; |
|
| 136 | +if ($pageid < 0) { |
|
| 137 | + $pageid = 0; |
|
| 138 | +} |
|
| 125 | 139 | if (($pageid > 0 || $pageref) && $action != 'addcontainer') |
| 126 | 140 | { |
| 127 | 141 | $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref); |
@@ -133,27 +147,31 @@ discard block |
||
| 133 | 147 | // Check if pageid is inside the new website, if not we reset param pageid |
| 134 | 148 | if ($res >= 0 && $object->id > 0) |
| 135 | 149 | { |
| 136 | - if ($objectpage->fk_website != $object->id) // We have a bad page that does not belong to web site |
|
| 150 | + if ($objectpage->fk_website != $object->id) { |
|
| 151 | + // We have a bad page that does not belong to web site |
|
| 137 | 152 | { |
| 138 | 153 | if ($object->fk_default_home > 0) |
| 139 | 154 | { |
| 140 | - $res = $objectpage->fetch($object->fk_default_home, $object->id, ''); // We search first page of web site |
|
| 141 | - if ($res > 0) $pageid = $object->fk_default_home; |
|
| 142 | - } |
|
| 143 | - else |
|
| 155 | + $res = $objectpage->fetch($object->fk_default_home, $object->id, ''); |
|
| 156 | + } |
|
| 157 | + // We search first page of web site |
|
| 158 | + if ($res > 0) { |
|
| 159 | + $pageid = $object->fk_default_home; |
|
| 160 | + } |
|
| 161 | + } else |
|
| 144 | 162 | { |
| 145 | 163 | $res = $objectpage->fetch(0, $object->id, ''); // We search first page of web site |
| 146 | - if ($res == 0) // Page was not found, we reset it |
|
| 164 | + if ($res == 0) { |
|
| 165 | + // Page was not found, we reset it |
|
| 147 | 166 | { |
| 148 | 167 | $objectpage=new WebsitePage($db); |
| 149 | 168 | } |
| 150 | - else // We found a page, we set pageid to it. |
|
| 169 | + } else // We found a page, we set pageid to it. |
|
| 151 | 170 | { |
| 152 | 171 | $pageid = $objectpage->id; |
| 153 | 172 | } |
| 154 | 173 | } |
| 155 | - } |
|
| 156 | - else // We have a valid page. We force pageid for the case we got the page with a fetch on ref. |
|
| 174 | + } else // We have a valid page. We force pageid for the case we got the page with a fetch on ref. |
|
| 157 | 175 | { |
| 158 | 176 | $pageid = $objectpage->id; |
| 159 | 177 | } |
@@ -167,14 +185,20 @@ discard block |
||
| 167 | 185 | if (empty($pageid)) |
| 168 | 186 | { |
| 169 | 187 | $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); |
| 170 | - if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 188 | + if (! is_array($array) && $array < 0) { |
|
| 189 | + dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 190 | + } |
|
| 171 | 191 | $atleastonepage=(is_array($array) && count($array) > 0); |
| 172 | 192 | |
| 173 | 193 | $firstpageid=0;$homepageid=0; |
| 174 | 194 | foreach($array as $key => $valpage) |
| 175 | 195 | { |
| 176 | - if (empty($firstpageid)) $firstpageid=$valpage->id; |
|
| 177 | - if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; |
|
| 196 | + if (empty($firstpageid)) { |
|
| 197 | + $firstpageid=$valpage->id; |
|
| 198 | + } |
|
| 199 | + if ($object->fk_default_home && $key == $object->fk_default_home) { |
|
| 200 | + $homepageid=$valpage->id; |
|
| 201 | + } |
|
| 178 | 202 | } |
| 179 | 203 | $pageid=($homepageid?$homepageid:$firstpageid); // We choose home page and if not defined yet, we take first page |
| 180 | 204 | } |
@@ -270,28 +294,40 @@ discard block |
||
| 270 | 294 | { |
| 271 | 295 | $action = 'preview'; // To avoid to make an action on another page or another site when we click on button to select another site or page. |
| 272 | 296 | } |
| 273 | -if (GETPOST('refreshsite', 'alpha') || GETPOST('refreshsite.x', 'alpha') || GETPOST('refreshsite_x', 'alpha')) // If we change the site, we reset the pageid and cancel addsite action. |
|
| 297 | +if (GETPOST('refreshsite', 'alpha') || GETPOST('refreshsite.x', 'alpha') || GETPOST('refreshsite_x', 'alpha')) { |
|
| 298 | + // If we change the site, we reset the pageid and cancel addsite action. |
|
| 274 | 299 | { |
| 275 | 300 | if ($action == 'addsite') $action = 'preview'; |
| 276 | - if ($action == 'updatesource') $action = 'preview'; |
|
| 301 | +} |
|
| 302 | + if ($action == 'updatesource') { |
|
| 303 | + $action = 'preview'; |
|
| 304 | + } |
|
| 277 | 305 | |
| 278 | 306 | $pageid = $object->fk_default_home; |
| 279 | 307 | if (empty($pageid)) |
| 280 | 308 | { |
| 281 | 309 | $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); |
| 282 | - if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 310 | + if (! is_array($array) && $array < 0) { |
|
| 311 | + dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 312 | + } |
|
| 283 | 313 | $atleastonepage=(is_array($array) && count($array) > 0); |
| 284 | 314 | |
| 285 | 315 | $firstpageid=0; $homepageid=0; |
| 286 | 316 | foreach($array as $key => $valpage) |
| 287 | 317 | { |
| 288 | - if (empty($firstpageid)) $firstpageid=$valpage->id; |
|
| 289 | - if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; |
|
| 318 | + if (empty($firstpageid)) { |
|
| 319 | + $firstpageid=$valpage->id; |
|
| 320 | + } |
|
| 321 | + if ($object->fk_default_home && $key == $object->fk_default_home) { |
|
| 322 | + $homepageid=$valpage->id; |
|
| 323 | + } |
|
| 290 | 324 | } |
| 291 | 325 | $pageid=($homepageid?$homepageid:$firstpageid); // We choose home page and if not defined yet, we take first page |
| 292 | 326 | } |
| 293 | 327 | } |
| 294 | -if (GETPOST('refreshpage', 'alpha') && ! in_array($action, array('updatecss'))) $action='preview'; |
|
| 328 | +if (GETPOST('refreshpage', 'alpha') && ! in_array($action, array('updatecss'))) { |
|
| 329 | + $action='preview'; |
|
| 330 | +} |
|
| 295 | 331 | |
| 296 | 332 | // Cancel |
| 297 | 333 | if ($cancel) |
@@ -309,7 +345,10 @@ discard block |
||
| 309 | 345 | include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; |
| 310 | 346 | $backtopage = $savbacktopage; |
| 311 | 347 | |
| 312 | -if ($action == 'renamefile') $action='file_manager'; // After actions_linkedfiles, if action were renamefile, we set it to 'file_manager' |
|
| 348 | +if ($action == 'renamefile') { |
|
| 349 | + $action='file_manager'; |
|
| 350 | +} |
|
| 351 | +// After actions_linkedfiles, if action were renamefile, we set it to 'file_manager' |
|
| 313 | 352 | |
| 314 | 353 | if ($action == 'seteditinline') |
| 315 | 354 | { |
@@ -416,8 +455,7 @@ discard block |
||
| 416 | 455 | |
| 417 | 456 | header("Location: ".$_SERVER["PHP_SELF"].'?website='.$tmpobject->ref); |
| 418 | 457 | exit; |
| 419 | - } |
|
| 420 | - else |
|
| 458 | + } else |
|
| 421 | 459 | { |
| 422 | 460 | $db->rollback(); |
| 423 | 461 | $action='createsite'; |
@@ -456,8 +494,7 @@ discard block |
||
| 456 | 494 | $langs->load("errors"); |
| 457 | 495 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors'); |
| 458 | 496 | $action = 'createcontainer'; |
| 459 | - } |
|
| 460 | - elseif (! preg_match('/^http/', $urltograb)) |
|
| 497 | + } elseif (! preg_match('/^http/', $urltograb)) |
|
| 461 | 498 | { |
| 462 | 499 | $error++; |
| 463 | 500 | $langs->load("errors"); |
@@ -505,14 +542,12 @@ discard block |
||
| 505 | 542 | $error++; |
| 506 | 543 | setEventMessages('Error getting '.$urltograb.': '.$tmp['curl_error_msg'], null, 'errors'); |
| 507 | 544 | $action='createcontainer'; |
| 508 | - } |
|
| 509 | - elseif ($tmp['http_code'] != '200') |
|
| 545 | + } elseif ($tmp['http_code'] != '200') |
|
| 510 | 546 | { |
| 511 | 547 | $error++; |
| 512 | 548 | setEventMessages('Error getting '.$urltograb.': '.$tmp['http_code'], null, 'errors'); |
| 513 | 549 | $action='createcontainer'; |
| 514 | - } |
|
| 515 | - else |
|
| 550 | + } else |
|
| 516 | 551 | { |
| 517 | 552 | // Remove comments |
| 518 | 553 | $tmp['content'] = removeHtmlComment($tmp['content']); |
@@ -532,7 +567,9 @@ discard block |
||
| 532 | 567 | |
| 533 | 568 | $objectpage->aliasalt = ''; |
| 534 | 569 | |
| 535 | - if (preg_match('/^(\d+)\-/', basename($urltograb), $regs)) $objectpage->aliasalt = $regs[1]; |
|
| 570 | + if (preg_match('/^(\d+)\-/', basename($urltograb), $regs)) { |
|
| 571 | + $objectpage->aliasalt = $regs[1]; |
|
| 572 | + } |
|
| 536 | 573 | |
| 537 | 574 | $regtmp=array(); |
| 538 | 575 | if (preg_match('/<title>(.*)<\/title>/ims', $head, $regtmp)) |
@@ -541,7 +578,10 @@ discard block |
||
| 541 | 578 | } |
| 542 | 579 | if (preg_match('/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) |
| 543 | 580 | { |
| 544 | - if (empty($objectpage->title)) $objectpage->title = $regtmp[1]; // If title not found into <title>, we get it from <meta title> |
|
| 581 | + if (empty($objectpage->title)) { |
|
| 582 | + $objectpage->title = $regtmp[1]; |
|
| 583 | + } |
|
| 584 | + // If title not found into <title>, we get it from <meta title> |
|
| 545 | 585 | } |
| 546 | 586 | if (preg_match('/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) |
| 547 | 587 | { |
@@ -599,8 +639,7 @@ discard block |
||
| 599 | 639 | if (preg_match('/^\//', $regs[2][$key])) |
| 600 | 640 | { |
| 601 | 641 | $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
| 602 | - } |
|
| 603 | - else |
|
| 642 | + } else |
|
| 604 | 643 | { |
| 605 | 644 | $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file |
| 606 | 645 | } |
@@ -619,7 +658,9 @@ discard block |
||
| 619 | 658 | // Test if this is an external URL of grabbed web site. If yes, we do not load resource |
| 620 | 659 | $domaintograb = getDomainFromURL($urltograbdirwithoutslash); |
| 621 | 660 | $domaintograbbis = getDomainFromURL($urltograbbis); |
| 622 | - if ($domaintograb != $domaintograbbis) continue; |
|
| 661 | + if ($domaintograb != $domaintograbbis) { |
|
| 662 | + continue; |
|
| 663 | + } |
|
| 623 | 664 | |
| 624 | 665 | /* |
| 625 | 666 | $tmpgeturl = getURLContent($urltograbbis); |
@@ -668,8 +709,7 @@ discard block |
||
| 668 | 709 | if (preg_match('/^\//', $regs[2][$key])) |
| 669 | 710 | { |
| 670 | 711 | $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
| 671 | - } |
|
| 672 | - else |
|
| 712 | + } else |
|
| 673 | 713 | { |
| 674 | 714 | $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file |
| 675 | 715 | } |
@@ -688,7 +728,9 @@ discard block |
||
| 688 | 728 | // Test if this is an external URL of grabbed web site. If yes, we do not load resource |
| 689 | 729 | $domaintograb = getDomainFromURL($urltograbdirwithoutslash); |
| 690 | 730 | $domaintograbbis = getDomainFromURL($urltograbbis); |
| 691 | - if ($domaintograb != $domaintograbbis) continue; |
|
| 731 | + if ($domaintograb != $domaintograbbis) { |
|
| 732 | + continue; |
|
| 733 | + } |
|
| 692 | 734 | |
| 693 | 735 | $tmpgeturl = getURLContent($urltograbbis); |
| 694 | 736 | if ($tmpgeturl['curl_error_no']) |
@@ -697,15 +739,13 @@ discard block |
||
| 697 | 739 | setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); |
| 698 | 740 | dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']); |
| 699 | 741 | $action='createcontainer'; |
| 700 | - } |
|
| 701 | - elseif ($tmpgeturl['http_code'] != '200') |
|
| 742 | + } elseif ($tmpgeturl['http_code'] != '200') |
|
| 702 | 743 | { |
| 703 | 744 | $errorforsubresource++; |
| 704 | 745 | setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); |
| 705 | 746 | dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']); |
| 706 | 747 | $action='createcontainer'; |
| 707 | - } |
|
| 708 | - else |
|
| 748 | + } else |
|
| 709 | 749 | { |
| 710 | 750 | // Clean some comment |
| 711 | 751 | //$tmpgeturl['content'] = dol_string_is_good_iso($tmpgeturl['content'], 1); |
@@ -773,8 +813,7 @@ discard block |
||
| 773 | 813 | $objectpage->grabbed_from = $urltograb; |
| 774 | 814 | } |
| 775 | 815 | } |
| 776 | - } |
|
| 777 | - else |
|
| 816 | + } else |
|
| 778 | 817 | { |
| 779 | 818 | $objectpage->title = GETPOST('WEBSITE_TITLE', 'alpha'); |
| 780 | 819 | $objectpage->type_container = GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'); |
@@ -790,7 +829,9 @@ discard block |
||
| 790 | 829 | $substitutionarray['__WEBSITE_CREATE_BY__']=$user->getFullName($langs); |
| 791 | 830 | |
| 792 | 831 | $sample = GETPOST('sample', 'alpha'); |
| 793 | - if (empty($sample)) $sample='empty'; |
|
| 832 | + if (empty($sample)) { |
|
| 833 | + $sample='empty'; |
|
| 834 | + } |
|
| 794 | 835 | |
| 795 | 836 | $pathtosample = DOL_DOCUMENT_ROOT.'/website/samples/page-sample-'.$sample.'.html'; |
| 796 | 837 | |
@@ -806,8 +847,7 @@ discard block |
||
| 806 | 847 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors'); |
| 807 | 848 | $error++; |
| 808 | 849 | $action='createcontainer'; |
| 809 | - } |
|
| 810 | - elseif (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) |
|
| 850 | + } elseif (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) |
|
| 811 | 851 | { |
| 812 | 852 | $langs->load("errors"); |
| 813 | 853 | setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); |
@@ -852,8 +892,7 @@ discard block |
||
| 852 | 892 | if ($result) |
| 853 | 893 | { |
| 854 | 894 | setEventMessages($langs->trans("Saved"), null, 'mesgs'); |
| 855 | - } |
|
| 856 | - else |
|
| 895 | + } else |
|
| 857 | 896 | { |
| 858 | 897 | setEventMessages('Failed to write file '.$filetpl, null, 'errors'); |
| 859 | 898 | $action = 'createcontainer'; |
@@ -865,8 +904,7 @@ discard block |
||
| 865 | 904 | $db->commit(); |
| 866 | 905 | setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs'); |
| 867 | 906 | $action=''; |
| 868 | - } |
|
| 869 | - else |
|
| 907 | + } else |
|
| 870 | 908 | { |
| 871 | 909 | $db->rollback(); |
| 872 | 910 | } |
@@ -977,8 +1015,7 @@ discard block |
||
| 977 | 1015 | |
| 978 | 1016 | header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); |
| 979 | 1017 | exit; |
| 980 | - } |
|
| 981 | - else |
|
| 1018 | + } else |
|
| 982 | 1019 | { |
| 983 | 1020 | $db->rollback(); |
| 984 | 1021 | dol_print_error($db); |
@@ -1014,8 +1051,7 @@ discard block |
||
| 1014 | 1051 | |
| 1015 | 1052 | header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey); |
| 1016 | 1053 | exit; |
| 1017 | - } |
|
| 1018 | - else |
|
| 1054 | + } else |
|
| 1019 | 1055 | { |
| 1020 | 1056 | $db->rollback(); |
| 1021 | 1057 | dol_print_error($db); |
@@ -1029,8 +1065,7 @@ discard block |
||
| 1029 | 1065 | if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) |
| 1030 | 1066 | { |
| 1031 | 1067 | $action='editcss'; |
| 1032 | - } |
|
| 1033 | - else |
|
| 1068 | + } else |
|
| 1034 | 1069 | { |
| 1035 | 1070 | $res = $object->fetch(0, $websitekey); |
| 1036 | 1071 | $website = $object; |
@@ -1262,16 +1297,17 @@ discard block |
||
| 1262 | 1297 | setEventMessages($langs->trans("Saved"), null, 'mesgs'); |
| 1263 | 1298 | } |
| 1264 | 1299 | |
| 1265 | - if (! GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we don not make the redirect |
|
| 1300 | + if (! GETPOSTISSET('updateandstay')) { |
|
| 1301 | + // If we click on "Save And Stay", we don not make the redirect |
|
| 1266 | 1302 | { |
| 1267 | 1303 | $action='preview'; |
| 1304 | + } |
|
| 1268 | 1305 | if ($backtopage) |
| 1269 | 1306 | { |
| 1270 | 1307 | header("Location: ".$backtopage); |
| 1271 | 1308 | exit; |
| 1272 | 1309 | } |
| 1273 | - } |
|
| 1274 | - else |
|
| 1310 | + } else |
|
| 1275 | 1311 | { |
| 1276 | 1312 | $action = 'editcss'; |
| 1277 | 1313 | } |
@@ -1302,12 +1338,14 @@ discard block |
||
| 1302 | 1338 | //------------------------------------------------- |
| 1303 | 1339 | $result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper); |
| 1304 | 1340 | |
| 1305 | - if ($result) setEventMessages($langs->trans("Saved"), null, 'mesgs'); |
|
| 1306 | - else setEventMessages('Failed to write file '.$fileindex, null, 'errors'); |
|
| 1341 | + if ($result) { |
|
| 1342 | + setEventMessages($langs->trans("Saved"), null, 'mesgs'); |
|
| 1343 | + } else { |
|
| 1344 | + setEventMessages('Failed to write file '.$fileindex, null, 'errors'); |
|
| 1345 | + } |
|
| 1307 | 1346 | |
| 1308 | 1347 | $action='preview'; |
| 1309 | - } |
|
| 1310 | - else |
|
| 1348 | + } else |
|
| 1311 | 1349 | { |
| 1312 | 1350 | $db->rollback(); |
| 1313 | 1351 | } |
@@ -1401,7 +1439,9 @@ discard block |
||
| 1401 | 1439 | $objectpage->fk_page = GETPOST('pageidfortranslation', 'int'); |
| 1402 | 1440 | |
| 1403 | 1441 | $newdatecreation=dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int')); |
| 1404 | - if ($newdatecreation) $objectpage->date_creation = $newdatecreation; |
|
| 1442 | + if ($newdatecreation) { |
|
| 1443 | + $objectpage->date_creation = $newdatecreation; |
|
| 1444 | + } |
|
| 1405 | 1445 | |
| 1406 | 1446 | $res = $objectpage->update($user); |
| 1407 | 1447 | if (! ($res > 0)) |
@@ -1413,8 +1453,7 @@ discard block |
||
| 1413 | 1453 | $langs->load("errors"); |
| 1414 | 1454 | setEventMessages($langs->trans("ErrorAPageWithThisNameOrAliasAlreadyExists"), null, 'errors'); |
| 1415 | 1455 | $action = 'editmeta'; |
| 1416 | - } |
|
| 1417 | - else |
|
| 1456 | + } else |
|
| 1418 | 1457 | { |
| 1419 | 1458 | $error++; |
| 1420 | 1459 | $langs->load("errors"); |
@@ -1427,8 +1466,7 @@ discard block |
||
| 1427 | 1466 | if (! $error) |
| 1428 | 1467 | { |
| 1429 | 1468 | $db->commit(); |
| 1430 | - } |
|
| 1431 | - else |
|
| 1469 | + } else |
|
| 1432 | 1470 | { |
| 1433 | 1471 | $db->rollback(); |
| 1434 | 1472 | } |
@@ -1444,7 +1482,9 @@ discard block |
||
| 1444 | 1482 | |
| 1445 | 1483 | // Now generate the master.inc.php page |
| 1446 | 1484 | $result = dolSaveMasterFile($filemaster); |
| 1447 | - if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); |
|
| 1485 | + if (! $result) { |
|
| 1486 | + setEventMessages('Failed to write file '.$filemaster, null, 'errors'); |
|
| 1487 | + } |
|
| 1448 | 1488 | |
| 1449 | 1489 | // Now delete the alias.php page |
| 1450 | 1490 | if (! empty($fileoldalias)) |
@@ -1468,7 +1508,9 @@ discard block |
||
| 1468 | 1508 | |
| 1469 | 1509 | // Save page alias |
| 1470 | 1510 | $result=dolSavePageAlias($filealias, $object, $objectpage); |
| 1471 | - if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); |
|
| 1511 | + if (! $result) { |
|
| 1512 | + setEventMessages('Failed to write file '.$filealias, null, 'errors'); |
|
| 1513 | + } |
|
| 1472 | 1514 | // Save alt aliases |
| 1473 | 1515 | if (! empty($objectpage->aliasalt)) |
| 1474 | 1516 | { |
@@ -1480,7 +1522,9 @@ discard block |
||
| 1480 | 1522 | if (trim($tmpaliasalt)) |
| 1481 | 1523 | { |
| 1482 | 1524 | $result=dolSavePageAlias($pathofwebsite.'/'.trim($tmpaliasalt).'.php', $object, $objectpage); |
| 1483 | - if (! $result) setEventMessages('Failed to write file '.$pathofwebsite.'/'.trim($tmpaliasalt).'.php', null, 'errors'); |
|
| 1525 | + if (! $result) { |
|
| 1526 | + setEventMessages('Failed to write file '.$pathofwebsite.'/'.trim($tmpaliasalt).'.php', null, 'errors'); |
|
| 1527 | + } |
|
| 1484 | 1528 | } |
| 1485 | 1529 | } |
| 1486 | 1530 | } |
@@ -1494,8 +1538,7 @@ discard block |
||
| 1494 | 1538 | setEventMessages($langs->trans("Saved"), null, 'mesgs'); |
| 1495 | 1539 | //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); |
| 1496 | 1540 | //exit; |
| 1497 | - } |
|
| 1498 | - else |
|
| 1541 | + } else |
|
| 1499 | 1542 | { |
| 1500 | 1543 | setEventMessages('Failed to write file '.$filetpl, null, 'errors'); |
| 1501 | 1544 | //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); |
@@ -1526,8 +1569,7 @@ discard block |
||
| 1526 | 1569 | $action='preview'; |
| 1527 | 1570 | |
| 1528 | 1571 | $db->rollback(); |
| 1529 | - } |
|
| 1530 | - else |
|
| 1572 | + } else |
|
| 1531 | 1573 | { |
| 1532 | 1574 | $object = $objectnew; |
| 1533 | 1575 | $id = $object->id; |
@@ -1563,8 +1605,7 @@ discard block |
||
| 1563 | 1605 | { |
| 1564 | 1606 | $tmpwebsite->fetch($newwebsiteid); |
| 1565 | 1607 | $pathofwebsitenew = $dolibarr_main_data_root.'/website/'.$tmpwebsite->ref; |
| 1566 | - } |
|
| 1567 | - else |
|
| 1608 | + } else |
|
| 1568 | 1609 | { |
| 1569 | 1610 | $tmpwebsite = $object; |
| 1570 | 1611 | } |
@@ -1578,8 +1619,7 @@ discard block |
||
| 1578 | 1619 | $action='createpagefromclone'; |
| 1579 | 1620 | |
| 1580 | 1621 | $db->rollback(); |
| 1581 | - } |
|
| 1582 | - else |
|
| 1622 | + } else |
|
| 1583 | 1623 | { |
| 1584 | 1624 | $fileindex=$pathofwebsitenew.'/index.php'; |
| 1585 | 1625 | $filetpl=$pathofwebsitenew.'/page'.$resultpage->id.'.tpl.php'; |
@@ -1627,8 +1667,7 @@ discard block |
||
| 1627 | 1667 | if ($pageid > 0) |
| 1628 | 1668 | { |
| 1629 | 1669 | $res = $objectpage->fetch($pageid); |
| 1630 | - } |
|
| 1631 | - else |
|
| 1670 | + } else |
|
| 1632 | 1671 | { |
| 1633 | 1672 | $res=0; |
| 1634 | 1673 | if ($object->fk_default_home > 0) |
@@ -1656,18 +1695,24 @@ discard block |
||
| 1656 | 1695 | $phpfullcodestring = dolKeepOnlyPhpCode($objectpage->content); |
| 1657 | 1696 | //print dol_escape_htmltag($phpfullcodestring);exit; |
| 1658 | 1697 | $forbiddenphpcommands=array("exec", "passthru", "system", "shell_exec", "proc_open"); |
| 1659 | - if (empty($conf->global->WEBSITE_PHP_ALLOW_WRITE)) // If option is not on, we disallow functions to write files |
|
| 1698 | + if (empty($conf->global->WEBSITE_PHP_ALLOW_WRITE)) { |
|
| 1699 | + // If option is not on, we disallow functions to write files |
|
| 1660 | 1700 | { |
| 1661 | 1701 | $forbiddenphpcommands=array_merge($forbiddenphpcommands, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask")); |
| 1662 | 1702 | } |
| 1703 | + } |
|
| 1663 | 1704 | foreach($forbiddenphpcommands as $forbiddenphpcommand) |
| 1664 | 1705 | { |
| 1665 | 1706 | if (preg_match('/'.$forbiddenphpcommand.'\s*\(/ms', $phpfullcodestring)) |
| 1666 | 1707 | { |
| 1667 | 1708 | $error++; |
| 1668 | 1709 | setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpcommand), null, 'errors'); |
| 1669 | - if ($action == 'updatesource') $action = 'editsource'; |
|
| 1670 | - if ($action == 'updatecontent') $action = 'editcontent'; |
|
| 1710 | + if ($action == 'updatesource') { |
|
| 1711 | + $action = 'editsource'; |
|
| 1712 | + } |
|
| 1713 | + if ($action == 'updatecontent') { |
|
| 1714 | + $action = 'editcontent'; |
|
| 1715 | + } |
|
| 1671 | 1716 | } |
| 1672 | 1717 | } |
| 1673 | 1718 | |
@@ -1677,8 +1722,12 @@ discard block |
||
| 1677 | 1722 | { |
| 1678 | 1723 | $error++; |
| 1679 | 1724 | setEventMessages($langs->trans("NotAllowedToAddDynamicContent"), null, 'errors'); |
| 1680 | - if ($action == 'updatesource') $action = 'editsource'; |
|
| 1681 | - if ($action == 'updatecontent') $action = 'editcontent'; |
|
| 1725 | + if ($action == 'updatesource') { |
|
| 1726 | + $action = 'editsource'; |
|
| 1727 | + } |
|
| 1728 | + if ($action == 'updatecontent') { |
|
| 1729 | + $action = 'editcontent'; |
|
| 1730 | + } |
|
| 1682 | 1731 | } |
| 1683 | 1732 | } |
| 1684 | 1733 | |
@@ -1692,8 +1741,12 @@ discard block |
||
| 1692 | 1741 | { |
| 1693 | 1742 | $error++; |
| 1694 | 1743 | setEventMessages($objectpage->error, $objectpage->errors, 'errors'); |
| 1695 | - if ($action == 'updatesource') $action = 'editsource'; |
|
| 1696 | - if ($action == 'updatecontent') $action = 'editcontent'; |
|
| 1744 | + if ($action == 'updatesource') { |
|
| 1745 | + $action = 'editsource'; |
|
| 1746 | + } |
|
| 1747 | + if ($action == 'updatecontent') { |
|
| 1748 | + $action = 'editcontent'; |
|
| 1749 | + } |
|
| 1697 | 1750 | } |
| 1698 | 1751 | |
| 1699 | 1752 | if (! $error) |
@@ -1710,7 +1763,9 @@ discard block |
||
| 1710 | 1763 | // Now generate the master.inc.php page |
| 1711 | 1764 | $result = dolSaveMasterFile($filemaster); |
| 1712 | 1765 | |
| 1713 | - if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); |
|
| 1766 | + if (! $result) { |
|
| 1767 | + setEventMessages('Failed to write file '.$filemaster, null, 'errors'); |
|
| 1768 | + } |
|
| 1714 | 1769 | |
| 1715 | 1770 | |
| 1716 | 1771 | // Now generate the alias.php page |
@@ -1722,7 +1777,9 @@ discard block |
||
| 1722 | 1777 | |
| 1723 | 1778 | // Save page alias |
| 1724 | 1779 | $result=dolSavePageAlias($filealias, $object, $objectpage); |
| 1725 | - if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); |
|
| 1780 | + if (! $result) { |
|
| 1781 | + setEventMessages('Failed to write file '.$filealias, null, 'errors'); |
|
| 1782 | + } |
|
| 1726 | 1783 | |
| 1727 | 1784 | // Save page content |
| 1728 | 1785 | $result=dolSavePageContent($filetpl, $object, $objectpage); |
@@ -1731,34 +1788,29 @@ discard block |
||
| 1731 | 1788 | setEventMessages($langs->trans("Saved"), null, 'mesgs'); |
| 1732 | 1789 | header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); |
| 1733 | 1790 | exit; |
| 1734 | - } |
|
| 1735 | - else |
|
| 1791 | + } else |
|
| 1736 | 1792 | { |
| 1737 | 1793 | setEventMessages('Failed to write file '.$filetpl, null, 'errors'); |
| 1738 | 1794 | header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); |
| 1739 | 1795 | exit; |
| 1740 | 1796 | } |
| 1741 | - } |
|
| 1742 | - else |
|
| 1797 | + } else |
|
| 1743 | 1798 | { |
| 1744 | 1799 | $db->rollback(); |
| 1745 | 1800 | } |
| 1746 | - } |
|
| 1747 | - else |
|
| 1801 | + } else |
|
| 1748 | 1802 | { |
| 1749 | 1803 | header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); |
| 1750 | 1804 | exit; |
| 1751 | 1805 | } |
| 1752 | - } |
|
| 1753 | - else |
|
| 1806 | + } else |
|
| 1754 | 1807 | { |
| 1755 | 1808 | if (! $error) |
| 1756 | 1809 | { |
| 1757 | 1810 | if (empty($websitekey) || $websitekey == '-1') |
| 1758 | 1811 | { |
| 1759 | 1812 | setEventMessages($langs->trans("NoWebSiteCreateOneFirst"), null, 'warnings'); |
| 1760 | - } |
|
| 1761 | - else |
|
| 1813 | + } else |
|
| 1762 | 1814 | { |
| 1763 | 1815 | setEventMessages($langs->trans("NoPageYet"), null, 'warnings'); |
| 1764 | 1816 | setEventMessages($langs->trans("YouCanCreatePageOrImportTemplate"), null, 'warnings'); |
@@ -1782,8 +1834,7 @@ discard block |
||
| 1782 | 1834 | |
| 1783 | 1835 | readfile($fileofzip); |
| 1784 | 1836 | exit; |
| 1785 | - } |
|
| 1786 | - else |
|
| 1837 | + } else |
|
| 1787 | 1838 | { |
| 1788 | 1839 | setEventMessages($object->error, $object->errors, 'errors'); |
| 1789 | 1840 | $action = ''; |
@@ -1797,8 +1848,7 @@ discard block |
||
| 1797 | 1848 | { |
| 1798 | 1849 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); |
| 1799 | 1850 | $action = 'importsite'; |
| 1800 | - } |
|
| 1801 | - else |
|
| 1851 | + } else |
|
| 1802 | 1852 | { |
| 1803 | 1853 | if (! empty($_FILES) || GETPOSTISSET('templateuserfile')) |
| 1804 | 1854 | { |
@@ -1821,11 +1871,13 @@ discard block |
||
| 1821 | 1871 | if (GETPOSTISSET('templateuserfile')) |
| 1822 | 1872 | { |
| 1823 | 1873 | $fileofzip = DOL_DATA_ROOT.'/doctemplates/websites/'.GETPOST('templateuserfile', 'alpha'); |
| 1824 | - } |
|
| 1825 | - elseif (! empty($_FILES)) |
|
| 1874 | + } elseif (! empty($_FILES)) |
|
| 1826 | 1875 | { |
| 1827 | - if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name']; |
|
| 1828 | - else $userfiles=array($_FILES['userfile']['tmp_name']); |
|
| 1876 | + if (is_array($_FILES['userfile']['tmp_name'])) { |
|
| 1877 | + $userfiles=$_FILES['userfile']['tmp_name']; |
|
| 1878 | + } else { |
|
| 1879 | + $userfiles=array($_FILES['userfile']['tmp_name']); |
|
| 1880 | + } |
|
| 1829 | 1881 | |
| 1830 | 1882 | foreach($userfiles as $key => $userfile) |
| 1831 | 1883 | { |
@@ -1835,8 +1887,7 @@ discard block |
||
| 1835 | 1887 | if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){ |
| 1836 | 1888 | setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); |
| 1837 | 1889 | $action = 'importsite'; |
| 1838 | - } |
|
| 1839 | - else { |
|
| 1890 | + } else { |
|
| 1840 | 1891 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); |
| 1841 | 1892 | $action = 'importsite'; |
| 1842 | 1893 | } |
@@ -1867,8 +1918,7 @@ discard block |
||
| 1867 | 1918 | { |
| 1868 | 1919 | setEventMessages($object->error, $object->errors, 'errors'); |
| 1869 | 1920 | $action = 'importsite'; |
| 1870 | - } |
|
| 1871 | - else |
|
| 1921 | + } else |
|
| 1872 | 1922 | { |
| 1873 | 1923 | // Force mode dynamic on |
| 1874 | 1924 | dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 1, 'chaine', 0, '', $conf->entity); |
@@ -1909,7 +1959,9 @@ discard block |
||
| 1909 | 1959 | |
| 1910 | 1960 | $arrayofjs[]='includes/jquery/plugins/blockUI/jquery.blockUI.js'; |
| 1911 | 1961 | $arrayofjs[]='core/js/blockUI.js'; // Used by ecm/tpl/enabledfiletreeajax.tpl.php |
| 1912 | -if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $arrayofjs[]="includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; |
|
| 1962 | +if (empty($conf->global->MAIN_ECM_DISABLE_JS)) { |
|
| 1963 | + $arrayofjs[]="includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; |
|
| 1964 | +} |
|
| 1913 | 1965 | |
| 1914 | 1966 | $moreheadjs.='<script type="text/javascript">'."\n"; |
| 1915 | 1967 | $moreheadjs.='var indicatorBlockUI = \''.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'\';'."\n"; |
@@ -1979,13 +2031,17 @@ discard block |
||
| 1979 | 2031 | |
| 1980 | 2032 | // Add a margin under toolbar ? |
| 1981 | 2033 | $style=''; |
| 1982 | -if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource') $style=' margin-bottom: 5px;'; |
|
| 2034 | +if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource') { |
|
| 2035 | + $style=' margin-bottom: 5px;'; |
|
| 2036 | +} |
|
| 1983 | 2037 | |
| 1984 | 2038 | |
| 1985 | 2039 | if (! GETPOST('hide_websitemenu')) |
| 1986 | 2040 | { |
| 1987 | 2041 | $disabled=''; |
| 1988 | - if (empty($user->rights->website->write)) $disabled=' disabled="disabled"'; |
|
| 2042 | + if (empty($user->rights->website->write)) { |
|
| 2043 | + $disabled=' disabled="disabled"'; |
|
| 2044 | + } |
|
| 1989 | 2045 | |
| 1990 | 2046 | //var_dump($objectpage);exit; |
| 1991 | 2047 | print '<div class="centpercent websitebar">'; |
@@ -2006,15 +2062,22 @@ discard block |
||
| 2006 | 2062 | print '<span class="websiteselection">'; |
| 2007 | 2063 | $out=''; |
| 2008 | 2064 | $out.='<select name="website" class="minwidth100 maxwidth300" id="website">'; |
| 2009 | - if (empty($object->records)) $out.='<option value="-1"> </option>'; |
|
| 2065 | + if (empty($object->records)) { |
|
| 2066 | + $out.='<option value="-1"> </option>'; |
|
| 2067 | + } |
|
| 2010 | 2068 | // Loop on each sites |
| 2011 | 2069 | $i=0; |
| 2012 | 2070 | foreach($object->records as $key => $valwebsite) |
| 2013 | 2071 | { |
| 2014 | - if (empty($websitekey)) $websitekey=$valwebsite->ref; |
|
| 2072 | + if (empty($websitekey)) { |
|
| 2073 | + $websitekey=$valwebsite->ref; |
|
| 2074 | + } |
|
| 2015 | 2075 | |
| 2016 | 2076 | $out.='<option value="'.$valwebsite->ref.'"'; |
| 2017 | - if ($websitekey == $valwebsite->ref) $out.=' selected'; // To preselect a value |
|
| 2077 | + if ($websitekey == $valwebsite->ref) { |
|
| 2078 | + $out.=' selected'; |
|
| 2079 | + } |
|
| 2080 | + // To preselect a value |
|
| 2018 | 2081 | $out.='>'; |
| 2019 | 2082 | $out.=$valwebsite->ref; |
| 2020 | 2083 | $out.='</option>'; |
@@ -2031,7 +2094,9 @@ discard block |
||
| 2031 | 2094 | { |
| 2032 | 2095 | $virtualurl=''; |
| 2033 | 2096 | $dataroot=DOL_DATA_ROOT.'/website/'.$websitekey; |
| 2034 | - if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost; |
|
| 2097 | + if (! empty($object->virtualhost)) { |
|
| 2098 | + $virtualurl=$object->virtualhost; |
|
| 2099 | + } |
|
| 2035 | 2100 | } |
| 2036 | 2101 | |
| 2037 | 2102 | $array=array(); |
@@ -2040,7 +2105,9 @@ discard block |
||
| 2040 | 2105 | $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); |
| 2041 | 2106 | $object->lines = $array; |
| 2042 | 2107 | } |
| 2043 | - if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 2108 | + if (! is_array($array) && $array < 0) { |
|
| 2109 | + dol_print_error('', $objectpage->error, $objectpage->errors); |
|
| 2110 | + } |
|
| 2044 | 2111 | $atleastonepage=(is_array($array) && count($array) > 0); |
| 2045 | 2112 | |
| 2046 | 2113 | if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) |
@@ -2052,8 +2119,7 @@ discard block |
||
| 2052 | 2119 | if ($atleastonepage) |
| 2053 | 2120 | { |
| 2054 | 2121 | print '<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("ImportSite")).'" name="importsite">'; |
| 2055 | - } |
|
| 2056 | - else |
|
| 2122 | + } else |
|
| 2057 | 2123 | { |
| 2058 | 2124 | print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("ImportSite")).'" name="importsite">'; |
| 2059 | 2125 | } |
@@ -2109,20 +2175,17 @@ discard block |
||
| 2109 | 2175 | if (empty($object->fk_default_home)) |
| 2110 | 2176 | { |
| 2111 | 2177 | $htmltext.= '<br><span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br><br>'; |
| 2112 | - } |
|
| 2113 | - elseif (empty($virtualurl)) |
|
| 2178 | + } elseif (empty($virtualurl)) |
|
| 2114 | 2179 | { |
| 2115 | 2180 | $htmltext.= '<br><span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>'; |
| 2116 | - } |
|
| 2117 | - else |
|
| 2181 | + } else |
|
| 2118 | 2182 | { |
| 2119 | 2183 | $htmltext.= '<br><center>'.$langs->trans("GoTo").' <a href="'.$virtualurl.'" target="_website">'.$virtualurl.'</a></center><br>'; |
| 2120 | 2184 | } |
| 2121 | 2185 | if (! empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) |
| 2122 | 2186 | { |
| 2123 | 2187 | $htmltext.= '<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER); |
| 2124 | - } |
|
| 2125 | - else |
|
| 2188 | + } else |
|
| 2126 | 2189 | { |
| 2127 | 2190 | $htmltext.=$langs->trans("SetHereVirtualHost", $dataroot); |
| 2128 | 2191 | $htmltext.='<br>'; |
@@ -2141,10 +2204,18 @@ discard block |
||
| 2141 | 2204 | |
| 2142 | 2205 | if (in_array($action, array('editcss','editmenu','file_manager','replacesite','replacesiteconfirm'))) |
| 2143 | 2206 | { |
| 2144 | - if ($action == 'editcss' && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print '<input type="submit" id="savefilean stay" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("SaveAndStay")).'" name="updateandstay">'; |
|
| 2145 | - if (preg_match('/^create/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; |
|
| 2146 | - if (preg_match('/^edit/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; |
|
| 2147 | - if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="cancel">'; |
|
| 2207 | + if ($action == 'editcss' && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') { |
|
| 2208 | + print '<input type="submit" id="savefilean stay" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("SaveAndStay")).'" name="updateandstay">'; |
|
| 2209 | + } |
|
| 2210 | + if (preg_match('/^create/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') { |
|
| 2211 | + print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; |
|
| 2212 | + } |
|
| 2213 | + if (preg_match('/^edit/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') { |
|
| 2214 | + print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; |
|
| 2215 | + } |
|
| 2216 | + if ($action != 'preview') { |
|
| 2217 | + print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="cancel">'; |
|
| 2218 | + } |
|
| 2148 | 2219 | } |
| 2149 | 2220 | |
| 2150 | 2221 | print '</span>'; |
@@ -2173,8 +2244,7 @@ discard block |
||
| 2173 | 2244 | if ($action != 'addcontainer') |
| 2174 | 2245 | { |
| 2175 | 2246 | print '<span class="websiteselection">'.$formwebsite->selectContainer($website, 'pageid', $pageid, 0, $action).'</span>'; |
| 2176 | - } |
|
| 2177 | - else |
|
| 2247 | + } else |
|
| 2178 | 2248 | { |
| 2179 | 2249 | print $langs->trans("New"); |
| 2180 | 2250 | } |
@@ -2197,8 +2267,9 @@ discard block |
||
| 2197 | 2267 | { |
| 2198 | 2268 | $pagepreviousid = $obj->pagepreviousid; |
| 2199 | 2269 | } |
| 2270 | + } else { |
|
| 2271 | + dol_print_error($db); |
|
| 2200 | 2272 | } |
| 2201 | - else dol_print_error($db); |
|
| 2202 | 2273 | $sql = 'SELECT MIN(rowid) as pagenextid FROM '.MAIN_DB_PREFIX.'website_page WHERE rowid > '.$pageid.' AND fk_website = '.$object->id; |
| 2203 | 2274 | $resql = $db->query($sql); |
| 2204 | 2275 | if ($resql) |
@@ -2208,14 +2279,21 @@ discard block |
||
| 2208 | 2279 | { |
| 2209 | 2280 | $pagenextid = $obj->pagenextid; |
| 2210 | 2281 | } |
| 2282 | + } else { |
|
| 2283 | + dol_print_error($db); |
|
| 2211 | 2284 | } |
| 2212 | - else dol_print_error($db); |
|
| 2213 | 2285 | } |
| 2214 | 2286 | |
| 2215 | - if ($pagepreviousid) print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?website='.urlencode($object->ref).'&pageid='.$pagepreviousid.'&action='.$action.'">'.img_previous($langs->trans("PreviousContainer")).'</a>'; |
|
| 2216 | - else print '<span class="valignmiddle opacitymedium">'.img_previous($langs->trans("PreviousContainer")).'</span>'; |
|
| 2217 | - if ($pagenextid) print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?website='.urlencode($object->ref).'&pageid='.$pagenextid.'&action='.$action.'">'.img_next($langs->trans("NextContainer")).'</a>'; |
|
| 2218 | - else print '<span class="valignmiddle opacitymedium">'.img_next($langs->trans("NextContainer")).'</span>'; |
|
| 2287 | + if ($pagepreviousid) { |
|
| 2288 | + print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?website='.urlencode($object->ref).'&pageid='.$pagepreviousid.'&action='.$action.'">'.img_previous($langs->trans("PreviousContainer")).'</a>'; |
|
| 2289 | + } else { |
|
| 2290 | + print '<span class="valignmiddle opacitymedium">'.img_previous($langs->trans("PreviousContainer")).'</span>'; |
|
| 2291 | + } |
|
| 2292 | + if ($pagenextid) { |
|
| 2293 | + print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?website='.urlencode($object->ref).'&pageid='.$pagenextid.'&action='.$action.'">'.img_next($langs->trans("NextContainer")).'</a>'; |
|
| 2294 | + } else { |
|
| 2295 | + print '<span class="valignmiddle opacitymedium">'.img_next($langs->trans("NextContainer")).'</span>'; |
|
| 2296 | + } |
|
| 2219 | 2297 | |
| 2220 | 2298 | $websitepage = new WebSitePage($db); |
| 2221 | 2299 | if ($pageid > 0 && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone')) |
@@ -2226,7 +2304,9 @@ discard block |
||
| 2226 | 2304 | if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite') |
| 2227 | 2305 | { |
| 2228 | 2306 | $disabled=''; |
| 2229 | - if (empty($user->rights->website->write)) $disabled=' disabled="disabled"'; |
|
| 2307 | + if (empty($user->rights->website->write)) { |
|
| 2308 | + $disabled=' disabled="disabled"'; |
|
| 2309 | + } |
|
| 2230 | 2310 | |
| 2231 | 2311 | // Confirmation delete site |
| 2232 | 2312 | if ($action == 'deletesite') { |
@@ -2258,12 +2338,14 @@ discard block |
||
| 2258 | 2338 | print $formconfirm; |
| 2259 | 2339 | } |
| 2260 | 2340 | |
| 2261 | - if ($pageid > 0 && $atleastonepage) // pageid can be set without pages, if homepage of site is set and all pages were removed |
|
| 2341 | + if ($pageid > 0 && $atleastonepage) { |
|
| 2342 | + // pageid can be set without pages, if homepage of site is set and all pages were removed |
|
| 2262 | 2343 | { |
| 2263 | 2344 | // Confirmation to clone |
| 2264 | 2345 | if ($action == 'createpagefromclone') { |
| 2265 | 2346 | // Create an array for form |
| 2266 | 2347 | $preselectedlanguage = GETPOST('newlang', 'aZ09') ? GETPOST('newlang', 'aZ09') : ($objectpage->lang ? $objectpage->lang : $langs->defaultlang); |
| 2348 | + } |
|
| 2267 | 2349 | $formquestion = array( |
| 2268 | 2350 | array('type' => 'hidden', 'name' => 'sourcepageurl', 'value'=> $objectpage->pageurl), |
| 2269 | 2351 | array('type' => 'checkbox', 'tdclass'=>'maxwidth200', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), |
@@ -2339,15 +2421,13 @@ discard block |
||
| 2339 | 2421 | { |
| 2340 | 2422 | //print '<input type="submit" class="button bordertransp" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'" value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">'; |
| 2341 | 2423 | print '<a class="nobordertransp opacitymedium nohoverborder marginleftonlyshort"'.$disabled.' href="#" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'">'.img_picto($langs->trans("OnlyEditionOfSourceForGrabbedContent"), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>'; |
| 2342 | - } |
|
| 2343 | - else |
|
| 2424 | + } else |
|
| 2344 | 2425 | { |
| 2345 | 2426 | //print '<input type="submit" class="button nobordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">'; |
| 2346 | 2427 | if (empty($conf->global->WEBSITE_EDITINLINE)) |
| 2347 | 2428 | { |
| 2348 | 2429 | print '<a class="nobordertransp nohoverborder marginleftonlyshort"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=seteditinline">'.img_picto($langs->trans("EditInLineOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>'; |
| 2349 | - } |
|
| 2350 | - else |
|
| 2430 | + } else |
|
| 2351 | 2431 | { |
| 2352 | 2432 | print '<a class="nobordertransp nohoverborder marginleftonlyshort"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=unseteditinline">'.img_picto($langs->trans("EditInLineOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').'</a>'; |
| 2353 | 2433 | } |
@@ -2365,8 +2445,7 @@ discard block |
||
| 2365 | 2445 | if (empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) |
| 2366 | 2446 | { |
| 2367 | 2447 | print '<a class="nobordertransp nohoverborder marginleftonlyshort"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=setshowsubcontainers">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>'; |
| 2368 | - } |
|
| 2369 | - else |
|
| 2448 | + } else |
|
| 2370 | 2449 | { |
| 2371 | 2450 | print '<a class="nobordertransp nohoverborder marginleftonlyshort"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=unsetshowsubcontainers">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("On")), 'switch_on', '', false, 0, 0, '', 'nomarginleft').'</a>'; |
| 2372 | 2451 | } |
@@ -2381,8 +2460,7 @@ discard block |
||
| 2381 | 2460 | //print '<span class="button bordertransp disabled"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'"><span class="fa fa-home"></span></span>'; |
| 2382 | 2461 | //print '<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">'; |
| 2383 | 2462 | print '<a href="#" class="button bordertransp disabled" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'"><span class="fa fa-home valignmiddle btnTitle-icon"><span></a>'; |
| 2384 | - } |
|
| 2385 | - else |
|
| 2463 | + } else |
|
| 2386 | 2464 | { |
| 2387 | 2465 | //$disabled=''; |
| 2388 | 2466 | //print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">'; |
@@ -2430,9 +2508,15 @@ discard block |
||
| 2430 | 2508 | } |
| 2431 | 2509 | if (! in_array($action, array('editcss','editmenu','file_manager','replacesite','replacesiteconfirm','createsite','createcontainer','createfromclone','createpagefromclone','deletesite'))) |
| 2432 | 2510 | { |
| 2433 | - if (preg_match('/^create/', $action)) print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; |
|
| 2434 | - if (preg_match('/^edit/', $action)) print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; |
|
| 2435 | - if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">'; |
|
| 2511 | + if (preg_match('/^create/', $action)) { |
|
| 2512 | + print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; |
|
| 2513 | + } |
|
| 2514 | + if (preg_match('/^edit/', $action)) { |
|
| 2515 | + print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; |
|
| 2516 | + } |
|
| 2517 | + if ($action != 'preview') { |
|
| 2518 | + print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">'; |
|
| 2519 | + } |
|
| 2436 | 2520 | } |
| 2437 | 2521 | |
| 2438 | 2522 | print '</span>'; // end websitetools |
@@ -2444,8 +2528,7 @@ discard block |
||
| 2444 | 2528 | if ($conf->browser->layout == 'phone') |
| 2445 | 2529 | { |
| 2446 | 2530 | print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block', 1, 2, 'tooltipsubstitution'); |
| 2447 | - } |
|
| 2448 | - else |
|
| 2531 | + } else |
|
| 2449 | 2532 | { |
| 2450 | 2533 | //img_help(($tooltiptrigger != '' ? 2 : 1), $alt) |
| 2451 | 2534 | print $form->textwithpicto($langs->trans("SyntaxHelp").' '.img_help(2, $langs->trans("SyntaxHelp")), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution'); |
@@ -2529,32 +2612,33 @@ discard block |
||
| 2529 | 2612 | $csscontent = @file_get_contents($filecss); |
| 2530 | 2613 | // Clean the php css file to remove php code and get only css part |
| 2531 | 2614 | $csscontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $csscontent); |
| 2532 | - } |
|
| 2533 | - else |
|
| 2615 | + } else |
|
| 2534 | 2616 | { |
| 2535 | 2617 | $csscontent = GETPOST('WEBSITE_CSS_INLINE', 'none'); |
| 2536 | 2618 | } |
| 2537 | - if (! trim($csscontent)) $csscontent='/* CSS content (all pages) */'."\n"."body.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}"; |
|
| 2619 | + if (! trim($csscontent)) { |
|
| 2620 | + $csscontent='/* CSS content (all pages) */'."\n"."body.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}"; |
|
| 2621 | + } |
|
| 2538 | 2622 | |
| 2539 | 2623 | if (! GETPOSTISSET('WEBSITE_JS_INLINE')) |
| 2540 | 2624 | { |
| 2541 | 2625 | $jscontent = @file_get_contents($filejs); |
| 2542 | 2626 | // Clean the php js file to remove php code and get only js part |
| 2543 | 2627 | $jscontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $jscontent); |
| 2544 | - } |
|
| 2545 | - else |
|
| 2628 | + } else |
|
| 2546 | 2629 | { |
| 2547 | 2630 | $jscontent = GETPOST('WEBSITE_JS_INLINE', 'none'); |
| 2548 | 2631 | } |
| 2549 | - if (! trim($jscontent)) $jscontent='/* JS content (all pages) */'."\n"; |
|
| 2632 | + if (! trim($jscontent)) { |
|
| 2633 | + $jscontent='/* JS content (all pages) */'."\n"; |
|
| 2634 | + } |
|
| 2550 | 2635 | |
| 2551 | 2636 | if (! GETPOSTISSET('WEBSITE_HTML_HEADER')) |
| 2552 | 2637 | { |
| 2553 | 2638 | $htmlheadercontent = @file_get_contents($filehtmlheader); |
| 2554 | 2639 | // Clean the php htmlheader file to remove php code and get only html part |
| 2555 | 2640 | $htmlheadercontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $htmlheadercontent); |
| 2556 | - } |
|
| 2557 | - else |
|
| 2641 | + } else |
|
| 2558 | 2642 | { |
| 2559 | 2643 | $htmlheadercontent = GETPOST('WEBSITE_HTML_HEADER', 'none'); |
| 2560 | 2644 | } |
@@ -2563,8 +2647,7 @@ discard block |
||
| 2563 | 2647 | $htmlheadercontent ="<html>\n"; |
| 2564 | 2648 | $htmlheadercontent.=$htmlheadercontentdefault; |
| 2565 | 2649 | $htmlheadercontent.="</html>"; |
| 2566 | - } |
|
| 2567 | - else |
|
| 2650 | + } else |
|
| 2568 | 2651 | { |
| 2569 | 2652 | $htmlheadercontent = preg_replace('/^\s*<html>/ims', '', $htmlheadercontent); |
| 2570 | 2653 | $htmlheadercontent = preg_replace('/<\/html>\s*$/ims', '', $htmlheadercontent); |
@@ -2576,8 +2659,7 @@ discard block |
||
| 2576 | 2659 | $robotcontent = @file_get_contents($filerobot); |
| 2577 | 2660 | // Clean the php htmlheader file to remove php code and get only html part |
| 2578 | 2661 | $robotcontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $robotcontent); |
| 2579 | - } |
|
| 2580 | - else |
|
| 2662 | + } else |
|
| 2581 | 2663 | { |
| 2582 | 2664 | $robotcontent = GETPOST('WEBSITE_ROBOT', 'nothtml'); |
| 2583 | 2665 | } |
@@ -2594,8 +2676,7 @@ discard block |
||
| 2594 | 2676 | $htaccesscontent = @file_get_contents($filehtaccess); |
| 2595 | 2677 | // Clean the php htaccesscontent file to remove php code and get only html part |
| 2596 | 2678 | $htaccesscontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $htaccesscontent); |
| 2597 | - } |
|
| 2598 | - else |
|
| 2679 | + } else |
|
| 2599 | 2680 | { |
| 2600 | 2681 | $htaccesscontent = GETPOST('WEBSITE_HTACCESS', 'nohtml'); |
| 2601 | 2682 | } |
@@ -2611,8 +2692,7 @@ discard block |
||
| 2611 | 2692 | $manifestjsoncontent = @file_get_contents($filemanifestjson); |
| 2612 | 2693 | // Clean the manifestjson file to remove php code and get only html part |
| 2613 | 2694 | $manifestjsoncontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $manifestjsoncontent); |
| 2614 | - } |
|
| 2615 | - else |
|
| 2695 | + } else |
|
| 2616 | 2696 | { |
| 2617 | 2697 | $manifestjsoncontent = GETPOST('WEBSITE_MANIFEST_JSON', 'none'); |
| 2618 | 2698 | } |
@@ -2626,8 +2706,7 @@ discard block |
||
| 2626 | 2706 | $readmecontent = @file_get_contents($filereadme); |
| 2627 | 2707 | // Clean the readme file to remove php code and get only html part |
| 2628 | 2708 | $readmecontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $readmecontent); |
| 2629 | - } |
|
| 2630 | - else |
|
| 2709 | + } else |
|
| 2631 | 2710 | { |
| 2632 | 2711 | $readmecontent = GETPOST('WEBSITE_README', 'none'); |
| 2633 | 2712 | } |
@@ -2767,15 +2846,21 @@ discard block |
||
| 2767 | 2846 | |
| 2768 | 2847 | dol_fiche_head($head, 'card', $langs->trans("AddSite"), -1, 'globe'); |
| 2769 | 2848 | */ |
| 2770 | - if ($action == 'createcontainer') print load_fiche_titre($langs->trans("AddSite")); |
|
| 2849 | + if ($action == 'createcontainer') { |
|
| 2850 | + print load_fiche_titre($langs->trans("AddSite")); |
|
| 2851 | + } |
|
| 2771 | 2852 | |
| 2772 | 2853 | print '<!-- Add site -->'."\n"; |
| 2773 | 2854 | //print '<div class="fichecenter">'; |
| 2774 | 2855 | |
| 2775 | 2856 | print '<table class="border centpercent">'; |
| 2776 | 2857 | |
| 2777 | - if (GETPOST('WEBSITE_REF')) $siteref=GETPOST('WEBSITE_REF', 'alpha'); |
|
| 2778 | - if (GETPOST('WEBSITE_DESCRIPTION')) $sitedesc=GETPOST('WEBSITE_DESCRIPTION', 'alpha'); |
|
| 2858 | + if (GETPOST('WEBSITE_REF')) { |
|
| 2859 | + $siteref=GETPOST('WEBSITE_REF', 'alpha'); |
|
| 2860 | + } |
|
| 2861 | + if (GETPOST('WEBSITE_DESCRIPTION')) { |
|
| 2862 | + $sitedesc=GETPOST('WEBSITE_DESCRIPTION', 'alpha'); |
|
| 2863 | + } |
|
| 2779 | 2864 | |
| 2780 | 2865 | print '<tr><td class="titlefieldcreate fieldrequired">'; |
| 2781 | 2866 | print $langs->trans('Ref'); |
@@ -2871,15 +2956,21 @@ discard block |
||
| 2871 | 2956 | |
| 2872 | 2957 | dol_fiche_head($head, 'card', $langs->trans("AddPage"), -1, 'globe'); |
| 2873 | 2958 | */ |
| 2874 | - if ($action == 'createcontainer') print load_fiche_titre($langs->trans("AddPage")); |
|
| 2959 | + if ($action == 'createcontainer') { |
|
| 2960 | + print load_fiche_titre($langs->trans("AddPage")); |
|
| 2961 | + } |
|
| 2875 | 2962 | |
| 2876 | 2963 | print '<!-- Edit or create page/container -->'."\n"; |
| 2877 | 2964 | //print '<div class="fichecenter">'; |
| 2878 | 2965 | |
| 2879 | 2966 | $hiddenfromfetchingafterload = ' hideobject'; |
| 2880 | 2967 | $hiddenmanuallyafterload = ' hideobject'; |
| 2881 | - if (GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching') $hiddenfromfetchingafterload = ''; |
|
| 2882 | - if (GETPOST('radiocreatefrom') == 'checkboxcreatemanually') $hiddenmanuallyafterload = ''; |
|
| 2968 | + if (GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching') { |
|
| 2969 | + $hiddenfromfetchingafterload = ''; |
|
| 2970 | + } |
|
| 2971 | + if (GETPOST('radiocreatefrom') == 'checkboxcreatemanually') { |
|
| 2972 | + $hiddenmanuallyafterload = ''; |
|
| 2973 | + } |
|
| 2883 | 2974 | |
| 2884 | 2975 | if ($action == 'editmeta' || empty($conf->use_javascript_ajax)) { // No autohide/show in such case |
| 2885 | 2976 | $hiddenfromfetchingafterload=''; |
@@ -2890,7 +2981,9 @@ discard block |
||
| 2890 | 2981 | { |
| 2891 | 2982 | print '<br>'; |
| 2892 | 2983 | |
| 2893 | - if (! empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching' ? ' checked' : '').'> '; |
|
| 2984 | + if (! empty($conf->use_javascript_ajax)) { |
|
| 2985 | + print '<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching' ? ' checked' : '').'> '; |
|
| 2986 | + } |
|
| 2894 | 2987 | print '<label for="checkboxcreatefromfetching"><span class="opacitymedium">'.$langs->trans("CreateByFetchingExternalPage").'</span></label><br>'; |
| 2895 | 2988 | print '<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">'; |
| 2896 | 2989 | print '<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">'; |
@@ -2911,7 +3004,9 @@ discard block |
||
| 2911 | 3004 | |
| 2912 | 3005 | print '<br>'; |
| 2913 | 3006 | |
| 2914 | - if (! empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST('radiocreatefrom') == 'checkboxcreatemanually' ? ' checked' : '').'> '; |
|
| 3007 | + if (! empty($conf->use_javascript_ajax)) { |
|
| 3008 | + print '<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST('radiocreatefrom') == 'checkboxcreatemanually' ? ' checked' : '').'> '; |
|
| 3009 | + } |
|
| 2915 | 3010 | print '<label for="checkboxcreatemanually"><span class="opacitymedium">'.$langs->trans("OrEnterPageInfoManually").'</span></label><br>'; |
| 2916 | 3011 | print '<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.'">'; |
| 2917 | 3012 | } |
@@ -2946,22 +3041,37 @@ discard block |
||
| 2946 | 3041 | $pagedatemodification=$objectpage->date_modification; |
| 2947 | 3042 | $pageauthorid=$objectpage->fk_user_creat; |
| 2948 | 3043 | $pageusermodifid=$objectpage->fk_user_modif; |
| 2949 | - } |
|
| 2950 | - else |
|
| 3044 | + } else |
|
| 2951 | 3045 | { |
| 2952 | 3046 | $type_container = 'page'; |
| 2953 | 3047 | $pagedatecreation=dol_now(); |
| 2954 | 3048 | $pageauthorid=$user->id; |
| 2955 | 3049 | $pageusermodifid=0; |
| 2956 | 3050 | } |
| 2957 | - if (GETPOST('WEBSITE_TITLE', 'alpha')) $pagetitle=GETPOST('WEBSITE_TITLE', 'alpha'); |
|
| 2958 | - if (GETPOST('WEBSITE_PAGENAME', 'alpha')) $pageurl=GETPOST('WEBSITE_PAGENAME', 'alpha'); |
|
| 2959 | - if (GETPOST('WEBSITE_ALIASALT', 'alpha')) $pagealiasalt=GETPOST('WEBSITE_ALIASALT', 'alpha'); |
|
| 2960 | - if (GETPOST('WEBSITE_DESCRIPTION', 'alpha')) $pagedescription=GETPOST('WEBSITE_DESCRIPTION', 'alpha'); |
|
| 2961 | - if (GETPOST('WEBSITE_IMAGE', 'alpha')) $pageimage=GETPOST('WEBSITE_IMAGE', 'alpha'); |
|
| 2962 | - if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) $pagekeywords=GETPOST('WEBSITE_KEYWORDS', 'alpha'); |
|
| 2963 | - if (GETPOST('WEBSITE_LANG', 'aZ09')) $pagelang=GETPOST('WEBSITE_LANG', 'aZ09'); |
|
| 2964 | - if (GETPOST('htmlheader', 'none')) $pagehtmlheader=GETPOST('htmlheader', 'none'); |
|
| 3051 | + if (GETPOST('WEBSITE_TITLE', 'alpha')) { |
|
| 3052 | + $pagetitle=GETPOST('WEBSITE_TITLE', 'alpha'); |
|
| 3053 | + } |
|
| 3054 | + if (GETPOST('WEBSITE_PAGENAME', 'alpha')) { |
|
| 3055 | + $pageurl=GETPOST('WEBSITE_PAGENAME', 'alpha'); |
|
| 3056 | + } |
|
| 3057 | + if (GETPOST('WEBSITE_ALIASALT', 'alpha')) { |
|
| 3058 | + $pagealiasalt=GETPOST('WEBSITE_ALIASALT', 'alpha'); |
|
| 3059 | + } |
|
| 3060 | + if (GETPOST('WEBSITE_DESCRIPTION', 'alpha')) { |
|
| 3061 | + $pagedescription=GETPOST('WEBSITE_DESCRIPTION', 'alpha'); |
|
| 3062 | + } |
|
| 3063 | + if (GETPOST('WEBSITE_IMAGE', 'alpha')) { |
|
| 3064 | + $pageimage=GETPOST('WEBSITE_IMAGE', 'alpha'); |
|
| 3065 | + } |
|
| 3066 | + if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) { |
|
| 3067 | + $pagekeywords=GETPOST('WEBSITE_KEYWORDS', 'alpha'); |
|
| 3068 | + } |
|
| 3069 | + if (GETPOST('WEBSITE_LANG', 'aZ09')) { |
|
| 3070 | + $pagelang=GETPOST('WEBSITE_LANG', 'aZ09'); |
|
| 3071 | + } |
|
| 3072 | + if (GETPOST('htmlheader', 'none')) { |
|
| 3073 | + $pagehtmlheader=GETPOST('htmlheader', 'none'); |
|
| 3074 | + } |
|
| 2965 | 3075 | |
| 2966 | 3076 | // Title |
| 2967 | 3077 | print '<tr><td class="fieldrequired">'; |
@@ -3040,14 +3150,17 @@ discard block |
||
| 3040 | 3150 | { |
| 3041 | 3151 | $tmppage=new WebsitePage($db); |
| 3042 | 3152 | $tmppage->fetch($obj->rowid); |
| 3043 | - if ($i > 0) print ' - '; |
|
| 3153 | + if ($i > 0) { |
|
| 3154 | + print ' - '; |
|
| 3155 | + } |
|
| 3044 | 3156 | print $tmppage->getNomUrl(1).' ('.$tmppage->lang.')<br>'; |
| 3045 | 3157 | $translatedby++; |
| 3046 | 3158 | $i++; |
| 3047 | 3159 | } |
| 3048 | 3160 | } |
| 3161 | + } else { |
|
| 3162 | + dol_print_error($db); |
|
| 3049 | 3163 | } |
| 3050 | - else dol_print_error($db); |
|
| 3051 | 3164 | } |
| 3052 | 3165 | if (empty($translatedby) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)) |
| 3053 | 3166 | { |
@@ -3056,8 +3169,7 @@ discard block |
||
| 3056 | 3169 | if ($result == 0) |
| 3057 | 3170 | { |
| 3058 | 3171 | // not found, we can reset value to clean database |
| 3059 | - } |
|
| 3060 | - elseif ($result > 0) |
|
| 3172 | + } elseif ($result > 0) |
|
| 3061 | 3173 | { |
| 3062 | 3174 | $translationof = $sourcepage->id; |
| 3063 | 3175 | print '<span class="opacitymedium">'.$langs->trans('ThisPageIsTranslationOf').'</span> '; |
@@ -3185,7 +3297,10 @@ discard block |
||
| 3185 | 3297 | //print '<div class="center">'.$langs->trans("FeatureNotYetAvailable").'</center>'; |
| 3186 | 3298 | |
| 3187 | 3299 | $module = 'medias'; |
| 3188 | - if (empty($url)) $url=DOL_URL_ROOT.'/website/index.php'; // Must be an url without param |
|
| 3300 | + if (empty($url)) { |
|
| 3301 | + $url=DOL_URL_ROOT.'/website/index.php'; |
|
| 3302 | + } |
|
| 3303 | + // Must be an url without param |
|
| 3189 | 3304 | include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php'; |
| 3190 | 3305 | |
| 3191 | 3306 | print '</div>'; |
@@ -3210,8 +3325,12 @@ discard block |
||
| 3210 | 3325 | $maxheightwin=480; |
| 3211 | 3326 | if (isset($_SESSION["dol_screenheight"])) |
| 3212 | 3327 | { |
| 3213 | - if ($_SESSION["dol_screenheight"] > 680) $maxheightwin = $_SESSION["dol_screenheight"]-400; |
|
| 3214 | - if ($_SESSION["dol_screenheight"] > 800) $maxheightwin = $_SESSION["dol_screenheight"]-490; |
|
| 3328 | + if ($_SESSION["dol_screenheight"] > 680) { |
|
| 3329 | + $maxheightwin = $_SESSION["dol_screenheight"]-400; |
|
| 3330 | + } |
|
| 3331 | + if ($_SESSION["dol_screenheight"] > 800) { |
|
| 3332 | + $maxheightwin = $_SESSION["dol_screenheight"]-490; |
|
| 3333 | + } |
|
| 3215 | 3334 | } |
| 3216 | 3335 | //var_dump($_SESSION["dol_screenheight"]); |
| 3217 | 3336 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
@@ -3286,9 +3405,15 @@ discard block |
||
| 3286 | 3405 | if ($action == 'replacesiteconfirm') |
| 3287 | 3406 | { |
| 3288 | 3407 | $algo = ''; |
| 3289 | - if (GETPOST('optionmeta')) $algo.='meta'; |
|
| 3290 | - if (GETPOST('optioncontent')) $algo.='content'; |
|
| 3291 | - if (GETPOST('optionsitefiles')) $algo.='sitefiles'; |
|
| 3408 | + if (GETPOST('optionmeta')) { |
|
| 3409 | + $algo.='meta'; |
|
| 3410 | + } |
|
| 3411 | + if (GETPOST('optioncontent')) { |
|
| 3412 | + $algo.='content'; |
|
| 3413 | + } |
|
| 3414 | + if (GETPOST('optionsitefiles')) { |
|
| 3415 | + $algo.='sitefiles'; |
|
| 3416 | + } |
|
| 3292 | 3417 | |
| 3293 | 3418 | $listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000); |
| 3294 | 3419 | |
@@ -3335,8 +3460,7 @@ discard block |
||
| 3335 | 3460 | print '<td class="tdoverflow100">'.$answerrecord->description; |
| 3336 | 3461 | print '</td>'; |
| 3337 | 3462 | print '</tr>'; |
| 3338 | - } |
|
| 3339 | - else |
|
| 3463 | + } else |
|
| 3340 | 3464 | { |
| 3341 | 3465 | print '<tr>'; |
| 3342 | 3466 | print '<td>'.$answerrecord['type'].'</td>'; |
@@ -3351,8 +3475,7 @@ discard block |
||
| 3351 | 3475 | } |
| 3352 | 3476 | print '</table>'; |
| 3353 | 3477 | print '</div></div>'; |
| 3354 | - } |
|
| 3355 | - else |
|
| 3478 | + } else |
|
| 3356 | 3479 | { |
| 3357 | 3480 | print $listofpages['message']; |
| 3358 | 3481 | } |
@@ -3431,7 +3554,9 @@ discard block |
||
| 3431 | 3554 | foreach($tmp as $valtmp) |
| 3432 | 3555 | { |
| 3433 | 3556 | $i++; |
| 3434 | - if ($i % 2 == 0) $tmpstyleinheader.=$valtmp."\n"; |
|
| 3557 | + if ($i % 2 == 0) { |
|
| 3558 | + $tmpstyleinheader.=$valtmp."\n"; |
|
| 3559 | + } |
|
| 3435 | 3560 | } |
| 3436 | 3561 | $tmpout.= $tmpstyleinheader."\n"; |
| 3437 | 3562 | // Clean style that may affect global style of Dolibarr |
@@ -3464,8 +3589,7 @@ discard block |
||
| 3464 | 3589 | { |
| 3465 | 3590 | // Remove the contenteditable="true" |
| 3466 | 3591 | $newcontent = preg_replace('/(div|section)(\s[^\>]*)contenteditable="true"/', '\1\2', $newcontent); |
| 3467 | - } |
|
| 3468 | - else |
|
| 3592 | + } else |
|
| 3469 | 3593 | { |
| 3470 | 3594 | // Keep the contenteditable="true" when mode Edit Inline is on |
| 3471 | 3595 | } |
@@ -3506,15 +3630,13 @@ discard block |
||
| 3506 | 3630 | |
| 3507 | 3631 | /*print '<iframe class="websiteiframenoborder centpercent" src="'.DOL_URL_ROOT.'/public/website/index.php?website='.$websitekey.'&pageid='.$pageid.'"/>'; |
| 3508 | 3632 | print '</iframe>';*/ |
| 3509 | - } |
|
| 3510 | - else |
|
| 3633 | + } else |
|
| 3511 | 3634 | { |
| 3512 | 3635 | if (empty($websitekey) || $websitekey == '-1') |
| 3513 | 3636 | { |
| 3514 | 3637 | print '<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans("NoWebSiteCreateOneFirst").'</span></div><br><br><br>'; |
| 3515 | 3638 | print '<div class="center"><div class="logo_setup"></div></div>'; |
| 3516 | - } |
|
| 3517 | - else |
|
| 3639 | + } else |
|
| 3518 | 3640 | { |
| 3519 | 3641 | print '<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans("PreviewOfSiteNotYetAvailable", $object->ref).'</span></div><br><br><br>'; |
| 3520 | 3642 | print '<div class="center"><div class="logo_setup"></div></div>'; |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | 25 | // Put here all includes required by your class file |
| 26 | -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; |
|
| 26 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; |
|
| 27 | 27 | //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
| 28 | 28 | //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; |
| 29 | 29 | |
@@ -89,27 +89,27 @@ discard block |
||
| 89 | 89 | /** |
| 90 | 90 | * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. |
| 91 | 91 | */ |
| 92 | - public $fields=array( |
|
| 93 | - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), |
|
| 94 | - 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), |
|
| 95 | - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), |
|
| 96 | - 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1), |
|
| 97 | - 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'), |
|
| 98 | - 'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'), |
|
| 92 | + public $fields = array( |
|
| 93 | + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), |
|
| 94 | + 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), |
|
| 95 | + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), |
|
| 96 | + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1), |
|
| 97 | + 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'), |
|
| 98 | + 'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'), |
|
| 99 | 99 | 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), |
| 100 | 100 | 'fk_project' =>array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1), |
| 101 | - 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60), |
|
| 102 | - 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), |
|
| 103 | - 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), |
|
| 104 | - 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500), |
|
| 105 | - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501), |
|
| 101 | + 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60), |
|
| 102 | + 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), |
|
| 103 | + 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), |
|
| 104 | + 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500), |
|
| 105 | + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501), |
|
| 106 | 106 | //'date_validation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), |
| 107 | - 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid'), |
|
| 108 | - 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), |
|
| 107 | + 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid'), |
|
| 108 | + 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), |
|
| 109 | 109 | //'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), |
| 110 | - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), |
|
| 111 | - 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'notnull'=>-1, 'position'=>1010), |
|
| 112 | - 'status' =>array('type'=>'smallint', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled')), |
|
| 110 | + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), |
|
| 111 | + 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'notnull'=>-1, 'position'=>1010), |
|
| 112 | + 'status' =>array('type'=>'smallint', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled')), |
|
| 113 | 113 | ); |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -214,11 +214,11 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | $this->db = $db; |
| 216 | 216 | |
| 217 | - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; |
|
| 218 | - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; |
|
| 217 | + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; |
|
| 218 | + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; |
|
| 219 | 219 | |
| 220 | 220 | // Unset fields that are disabled |
| 221 | - foreach($this->fields as $key => $val) |
|
| 221 | + foreach ($this->fields as $key => $val) |
|
| 222 | 222 | { |
| 223 | 223 | if (isset($val['enabled']) && empty($val['enabled'])) |
| 224 | 224 | { |
@@ -229,13 +229,13 @@ discard block |
||
| 229 | 229 | // Translate some data of arrayofkeyval |
| 230 | 230 | if (is_object($langs)) |
| 231 | 231 | { |
| 232 | - foreach($this->fields as $key => $val) |
|
| 232 | + foreach ($this->fields as $key => $val) |
|
| 233 | 233 | { |
| 234 | 234 | if (is_array($val['arrayofkeyval'])) |
| 235 | 235 | { |
| 236 | - foreach($val['arrayofkeyval'] as $key2 => $val2) |
|
| 236 | + foreach ($val['arrayofkeyval'] as $key2 => $val2) |
|
| 237 | 237 | { |
| 238 | - $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2); |
|
| 238 | + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); |
|
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | // Load source object |
| 276 | 276 | $result = $object->fetchCommon($fromid); |
| 277 | - if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines(); |
|
| 277 | + if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); |
|
| 278 | 278 | |
| 279 | 279 | // get lines so they will be clone |
| 280 | 280 | //foreach($this->lines as $line) |
@@ -287,18 +287,18 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | |
| 289 | 289 | // Clear fields |
| 290 | - $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref: $this->fields['ref']['default']; |
|
| 291 | - $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; |
|
| 290 | + $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref : $this->fields['ref']['default']; |
|
| 291 | + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; |
|
| 292 | 292 | $object->status = self::STATUS_DRAFT; |
| 293 | 293 | // ... |
| 294 | 294 | // Clear extrafields that are unique |
| 295 | 295 | if (is_array($object->array_options) && count($object->array_options) > 0) |
| 296 | 296 | { |
| 297 | 297 | $extrafields->fetch_name_optionals_label($this->table_element); |
| 298 | - foreach($object->array_options as $key => $option) |
|
| 298 | + foreach ($object->array_options as $key => $option) |
|
| 299 | 299 | { |
| 300 | 300 | $shortkey = preg_replace('/options_/', '', $key); |
| 301 | - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) |
|
| 301 | + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) |
|
| 302 | 302 | { |
| 303 | 303 | //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; |
| 304 | 304 | unset($object->array_options[$key]); |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | $this->errors = $object->errors; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if (! $error) |
|
| 318 | + if (!$error) |
|
| 319 | 319 | { |
| 320 | 320 | // copy internal contacts |
| 321 | 321 | if ($this->copy_linked_contact($object, 'internal') < 0) |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - if (! $error) |
|
| 327 | + if (!$error) |
|
| 328 | 328 | { |
| 329 | 329 | // copy external contacts if same company |
| 330 | 330 | if (property_exists($this, 'socid') && $this->socid == $object->socid) |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | public function fetch($id, $ref = null) |
| 357 | 357 | { |
| 358 | 358 | $result = $this->fetchCommon($id, $ref); |
| 359 | - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); |
|
| 359 | + if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); |
|
| 360 | 360 | return $result; |
| 361 | 361 | } |
| 362 | 362 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | */ |
| 368 | 368 | public function fetchLines() |
| 369 | 369 | { |
| 370 | - $this->lines=array(); |
|
| 370 | + $this->lines = array(); |
|
| 371 | 371 | |
| 372 | 372 | $result = $this->fetchLinesCommon(); |
| 373 | 373 | return $result; |
@@ -391,40 +391,40 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 393 | 393 | |
| 394 | - $records=array(); |
|
| 394 | + $records = array(); |
|
| 395 | 395 | |
| 396 | 396 | $sql = 'SELECT '; |
| 397 | 397 | $sql .= $this->getFieldList(); |
| 398 | - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; |
|
| 398 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; |
|
| 399 | 399 | if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; |
| 400 | 400 | else $sql .= ' WHERE 1 = 1'; |
| 401 | 401 | // Manage filter |
| 402 | 402 | $sqlwhere = array(); |
| 403 | 403 | if (count($filter) > 0) { |
| 404 | 404 | foreach ($filter as $key => $value) { |
| 405 | - if ($key=='t.rowid') { |
|
| 406 | - $sqlwhere[] = $key . '='. $value; |
|
| 405 | + if ($key == 't.rowid') { |
|
| 406 | + $sqlwhere[] = $key.'='.$value; |
|
| 407 | 407 | } |
| 408 | 408 | elseif (strpos($key, 'date') !== false) { |
| 409 | 409 | $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; |
| 410 | 410 | } |
| 411 | - elseif ($key=='customsql') { |
|
| 411 | + elseif ($key == 'customsql') { |
|
| 412 | 412 | $sqlwhere[] = $value; |
| 413 | 413 | } |
| 414 | 414 | else { |
| 415 | - $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; |
|
| 415 | + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; |
|
| 416 | 416 | } |
| 417 | 417 | } |
| 418 | 418 | } |
| 419 | 419 | if (count($sqlwhere) > 0) { |
| 420 | - $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; |
|
| 420 | + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | if (!empty($sortfield)) { |
| 424 | 424 | $sql .= $this->db->order($sortfield, $sortorder); |
| 425 | 425 | } |
| 426 | 426 | if (!empty($limit)) { |
| 427 | - $sql .= ' ' . $this->db->plimit($limit, $offset); |
|
| 427 | + $sql .= ' '.$this->db->plimit($limit, $offset); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | $resql = $this->db->query($sql); |
@@ -446,8 +446,8 @@ discard block |
||
| 446 | 446 | |
| 447 | 447 | return $records; |
| 448 | 448 | } else { |
| 449 | - $this->errors[] = 'Error ' . $this->db->lasterror(); |
|
| 450 | - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); |
|
| 449 | + $this->errors[] = 'Error '.$this->db->lasterror(); |
|
| 450 | + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); |
|
| 451 | 451 | |
| 452 | 452 | return -1; |
| 453 | 453 | } |
@@ -587,51 +587,51 @@ discard block |
||
| 587 | 587 | { |
| 588 | 588 | global $conf, $langs, $hookmanager; |
| 589 | 589 | |
| 590 | - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
| 590 | + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips |
|
| 591 | 591 | |
| 592 | 592 | $result = ''; |
| 593 | 593 | |
| 594 | - $label = '<u>' . $langs->trans("MyObject") . '</u>'; |
|
| 595 | - $label.= '<br>'; |
|
| 596 | - $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; |
|
| 594 | + $label = '<u>'.$langs->trans("MyObject").'</u>'; |
|
| 595 | + $label .= '<br>'; |
|
| 596 | + $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref; |
|
| 597 | 597 | |
| 598 | 598 | $url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id; |
| 599 | 599 | |
| 600 | 600 | if ($option != 'nolink') |
| 601 | 601 | { |
| 602 | 602 | // Add param to save lastsearch_values or not |
| 603 | - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
| 604 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 605 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 603 | + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
|
| 604 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; |
|
| 605 | + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | - $linkclose=''; |
|
| 608 | + $linkclose = ''; |
|
| 609 | 609 | if (empty($notooltip)) |
| 610 | 610 | { |
| 611 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 611 | + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 612 | 612 | { |
| 613 | - $label=$langs->trans("ShowMyObject"); |
|
| 614 | - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 613 | + $label = $langs->trans("ShowMyObject"); |
|
| 614 | + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 615 | 615 | } |
| 616 | - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 617 | - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; |
|
| 616 | + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 617 | + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; |
|
| 618 | 618 | } |
| 619 | - else $linkclose = ($morecss?' class="'.$morecss.'"':''); |
|
| 619 | + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
| 620 | 620 | |
| 621 | 621 | $linkstart = '<a href="'.$url.'"'; |
| 622 | - $linkstart.=$linkclose.'>'; |
|
| 623 | - $linkend='</a>'; |
|
| 622 | + $linkstart .= $linkclose.'>'; |
|
| 623 | + $linkend = '</a>'; |
|
| 624 | 624 | |
| 625 | 625 | $result .= $linkstart; |
| 626 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
| 627 | - if ($withpicto != 2) $result.= $this->ref; |
|
| 626 | + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
| 627 | + if ($withpicto != 2) $result .= $this->ref; |
|
| 628 | 628 | $result .= $linkend; |
| 629 | 629 | //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); |
| 630 | 630 | |
| 631 | - global $action,$hookmanager; |
|
| 631 | + global $action, $hookmanager; |
|
| 632 | 632 | $hookmanager->initHooks(array('myobjectdao')); |
| 633 | - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); |
|
| 634 | - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 633 | + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); |
|
| 634 | + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 635 | 635 | if ($reshook > 0) $result = $hookmanager->resPrint; |
| 636 | 636 | else $result .= $hookmanager->resPrint; |
| 637 | 637 | |
@@ -687,10 +687,10 @@ discard block |
||
| 687 | 687 | public function info($id) |
| 688 | 688 | { |
| 689 | 689 | $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; |
| 690 | - $sql.= ' fk_user_creat, fk_user_modif'; |
|
| 691 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; |
|
| 692 | - $sql.= ' WHERE t.rowid = '.$id; |
|
| 693 | - $result=$this->db->query($sql); |
|
| 690 | + $sql .= ' fk_user_creat, fk_user_modif'; |
|
| 691 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; |
|
| 692 | + $sql .= ' WHERE t.rowid = '.$id; |
|
| 693 | + $result = $this->db->query($sql); |
|
| 694 | 694 | if ($result) |
| 695 | 695 | { |
| 696 | 696 | if ($this->db->num_rows($result)) |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | { |
| 702 | 702 | $cuser = new User($this->db); |
| 703 | 703 | $cuser->fetch($obj->fk_user_author); |
| 704 | - $this->user_creation = $cuser; |
|
| 704 | + $this->user_creation = $cuser; |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | if ($obj->fk_user_valid) |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | { |
| 716 | 716 | $cluser = new User($this->db); |
| 717 | 717 | $cluser->fetch($obj->fk_user_cloture); |
| 718 | - $this->user_cloture = $cluser; |
|
| 718 | + $this->user_cloture = $cluser; |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | $this->date_creation = $this->db->jdate($obj->datec); |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | */ |
| 750 | 750 | public function getLinesArray() |
| 751 | 751 | { |
| 752 | - $this->lines=array(); |
|
| 752 | + $this->lines = array(); |
|
| 753 | 753 | |
| 754 | 754 | $objectline = new MyObjectLine($this->db); |
| 755 | 755 | $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_myobject = '.$this->id)); |
@@ -780,16 +780,16 @@ discard block |
||
| 780 | 780 | */ |
| 781 | 781 | public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) |
| 782 | 782 | { |
| 783 | - global $conf,$langs; |
|
| 783 | + global $conf, $langs; |
|
| 784 | 784 | |
| 785 | 785 | $langs->load("mymodule@mymodule"); |
| 786 | 786 | |
| 787 | - if (! dol_strlen($modele)) { |
|
| 787 | + if (!dol_strlen($modele)) { |
|
| 788 | 788 | $modele = 'standard'; |
| 789 | 789 | |
| 790 | 790 | if ($this->modelpdf) { |
| 791 | 791 | $modele = $this->modelpdf; |
| 792 | - } elseif (! empty($conf->global->MYOBJECT_ADDON_PDF)) { |
|
| 792 | + } elseif (!empty($conf->global->MYOBJECT_ADDON_PDF)) { |
|
| 793 | 793 | $modele = $conf->global->MYOBJECT_ADDON_PDF; |
| 794 | 794 | } |
| 795 | 795 | } |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | |
| 815 | 815 | $error = 0; |
| 816 | 816 | $this->output = ''; |
| 817 | - $this->error=''; |
|
| 817 | + $this->error = ''; |
|
| 818 | 818 | |
| 819 | 819 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 820 | 820 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> |
|
| 2 | +if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> |
|
| 3 | 3 | /* <style type="text/css" > */ |
| 4 | 4 | |
| 5 | 5 | |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | .button, .buttonDelete, .butAction, .butActionDelete, .butActionRefused, .butActionNewRefused { |
| 27 | 27 | border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25); |
| 28 | 28 | display: inline-block; |
| 29 | - padding: 0.4em <?php echo ($dol_optimize_smallscreen?'0.4':'0.7'); ?>em; |
|
| 30 | - margin: 0em <?php echo ($dol_optimize_smallscreen?'0.7':'0.9'); ?>em; |
|
| 29 | + padding: 0.4em <?php echo ($dol_optimize_smallscreen ? '0.4' : '0.7'); ?>em; |
|
| 30 | + margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.7' : '0.9'); ?>em; |
|
| 31 | 31 | line-height: 20px; |
| 32 | 32 | text-align: center; |
| 33 | 33 | vertical-align: middle; |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | text-decoration: none; |
| 56 | 56 | /* border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25); */ |
| 57 | 57 | display: inline-block; |
| 58 | - padding: 0.2em <?php echo ($dol_optimize_smallscreen?'0.4':'0.7'); ?>em; |
|
| 59 | - margin: 0em <?php echo ($dol_optimize_smallscreen?'0.7':'0.9'); ?>em; |
|
| 58 | + padding: 0.2em <?php echo ($dol_optimize_smallscreen ? '0.4' : '0.7'); ?>em; |
|
| 59 | + margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.7' : '0.9'); ?>em; |
|
| 60 | 60 | line-height: 20px; |
| 61 | 61 | /* text-align: center; New button are on right of screen */ |
| 62 | 62 | vertical-align: middle; |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | |
| 245 | 245 | |
| 246 | -<?php if (! empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (! $user->admin)) { ?> |
|
| 246 | +<?php if (!empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (!$user->admin)) { ?> |
|
| 247 | 247 | .butActionRefused, .butActionNewRefused, .btnTitle.refused { |
| 248 | 248 | display: none !important; |
| 249 | 249 | } |
@@ -30,44 +30,44 @@ discard block |
||
| 30 | 30 | // $backtopage may be defined |
| 31 | 31 | // $triggermodname may be defined |
| 32 | 32 | |
| 33 | -if (! empty($permissionedit) && empty($permissiontoadd)) $permissiontoadd = $permissionedit; // For backward compatibility |
|
| 33 | +if (!empty($permissionedit) && empty($permissiontoadd)) $permissiontoadd = $permissionedit; // For backward compatibility |
|
| 34 | 34 | |
| 35 | 35 | if ($cancel) |
| 36 | 36 | { |
| 37 | 37 | /*var_dump($cancel); |
| 38 | 38 | var_dump($backtopage);exit;*/ |
| 39 | - if (! empty($backtopage)) |
|
| 39 | + if (!empty($backtopage)) |
|
| 40 | 40 | { |
| 41 | 41 | header("Location: ".$backtopage); |
| 42 | 42 | exit; |
| 43 | 43 | } |
| 44 | - $action=''; |
|
| 44 | + $action = ''; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Action to add record |
| 48 | -if ($action == 'add' && ! empty($permissiontoadd)) |
|
| 48 | +if ($action == 'add' && !empty($permissiontoadd)) |
|
| 49 | 49 | { |
| 50 | 50 | foreach ($object->fields as $key => $val) |
| 51 | 51 | { |
| 52 | - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields |
|
| 52 | + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields |
|
| 53 | 53 | |
| 54 | 54 | // Set value to insert |
| 55 | 55 | if (in_array($object->fields[$key]['type'], array('text', 'html'))) { |
| 56 | 56 | $value = GETPOST($key, 'none'); |
| 57 | - } elseif ($object->fields[$key]['type']=='date') { |
|
| 57 | + } elseif ($object->fields[$key]['type'] == 'date') { |
|
| 58 | 58 | $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); |
| 59 | - } elseif ($object->fields[$key]['type']=='datetime') { |
|
| 59 | + } elseif ($object->fields[$key]['type'] == 'datetime') { |
|
| 60 | 60 | $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); |
| 61 | 61 | } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) { |
| 62 | - $value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup |
|
| 62 | + $value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup |
|
| 63 | 63 | } else { |
| 64 | 64 | $value = GETPOST($key, 'alpha'); |
| 65 | 65 | } |
| 66 | - if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field |
|
| 67 | - if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field |
|
| 66 | + if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field |
|
| 67 | + if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field |
|
| 68 | 68 | |
| 69 | - $object->$key=$value; |
|
| 70 | - if ($val['notnull'] > 0 && $object->$key == '' && ! is_null($val['default']) && $val['default'] == '(PROV)') |
|
| 69 | + $object->$key = $value; |
|
| 70 | + if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)') |
|
| 71 | 71 | { |
| 72 | 72 | $object->$key = '(PROV)'; |
| 73 | 73 | } |
@@ -78,54 +78,54 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if (! $error) |
|
| 81 | + if (!$error) |
|
| 82 | 82 | { |
| 83 | - $result=$object->create($user); |
|
| 83 | + $result = $object->create($user); |
|
| 84 | 84 | if ($result > 0) |
| 85 | 85 | { |
| 86 | 86 | // Creation OK |
| 87 | 87 | $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; |
| 88 | - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation |
|
| 88 | + $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation |
|
| 89 | 89 | header("Location: ".$urltogo); |
| 90 | 90 | exit; |
| 91 | 91 | } |
| 92 | 92 | else |
| 93 | 93 | { |
| 94 | 94 | // Creation KO |
| 95 | - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); |
|
| 95 | + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); |
|
| 96 | 96 | else setEventMessages($object->error, null, 'errors'); |
| 97 | - $action='create'; |
|
| 97 | + $action = 'create'; |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | else |
| 101 | 101 | { |
| 102 | - $action='create'; |
|
| 102 | + $action = 'create'; |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // Action to update record |
| 107 | -if ($action == 'update' && ! empty($permissiontoadd)) |
|
| 107 | +if ($action == 'update' && !empty($permissiontoadd)) |
|
| 108 | 108 | { |
| 109 | 109 | foreach ($object->fields as $key => $val) |
| 110 | 110 | { |
| 111 | - if (! GETPOSTISSET($key)) continue; // The field was not submited to be edited |
|
| 112 | - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields |
|
| 111 | + if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited |
|
| 112 | + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields |
|
| 113 | 113 | // Set value to update |
| 114 | 114 | if (in_array($object->fields[$key]['type'], array('text', 'html'))) { |
| 115 | 115 | $value = GETPOST($key, 'none'); |
| 116 | - } elseif ($object->fields[$key]['type']=='date') { |
|
| 116 | + } elseif ($object->fields[$key]['type'] == 'date') { |
|
| 117 | 117 | $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); |
| 118 | - } elseif ($object->fields[$key]['type']=='datetime') { |
|
| 118 | + } elseif ($object->fields[$key]['type'] == 'datetime') { |
|
| 119 | 119 | $value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); |
| 120 | 120 | } elseif (in_array($object->fields[$key]['type'], array('price', 'real'))) { |
| 121 | 121 | $value = price2num(GETPOST($key)); |
| 122 | 122 | } else { |
| 123 | 123 | $value = GETPOST($key, 'alpha'); |
| 124 | 124 | } |
| 125 | - if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field |
|
| 126 | - if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field |
|
| 125 | + if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field |
|
| 126 | + if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field |
|
| 127 | 127 | |
| 128 | - $object->$key=$value; |
|
| 128 | + $object->$key = $value; |
|
| 129 | 129 | if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) |
| 130 | 130 | { |
| 131 | 131 | $error++; |
@@ -133,28 +133,28 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if (! $error) |
|
| 136 | + if (!$error) |
|
| 137 | 137 | { |
| 138 | - $result=$object->update($user); |
|
| 138 | + $result = $object->update($user); |
|
| 139 | 139 | if ($result > 0) |
| 140 | 140 | { |
| 141 | - $action='view'; |
|
| 141 | + $action = 'view'; |
|
| 142 | 142 | } |
| 143 | 143 | else |
| 144 | 144 | { |
| 145 | 145 | // Creation KO |
| 146 | 146 | setEventMessages($object->error, $object->errors, 'errors'); |
| 147 | - $action='edit'; |
|
| 147 | + $action = 'edit'; |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | else |
| 151 | 151 | { |
| 152 | - $action='edit'; |
|
| 152 | + $action = 'edit'; |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // Action to update one extrafield |
| 157 | -if ($action == "update_extras" && ! empty($permissiontoadd)) |
|
| 157 | +if ($action == "update_extras" && !empty($permissiontoadd)) |
|
| 158 | 158 | { |
| 159 | 159 | $object->fetch(GETPOST('id', 'int')); |
| 160 | 160 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $attributekeylong = 'options_'.$attributekey; |
| 163 | 163 | $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, ' alpha'); |
| 164 | 164 | |
| 165 | - $result = $object->insertExtraFields(empty($triggermodname)?'':$triggermodname, $user); |
|
| 165 | + $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); |
|
| 166 | 166 | if ($result > 0) |
| 167 | 167 | { |
| 168 | 168 | setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); |
@@ -176,15 +176,15 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // Action to delete |
| 179 | -if ($action == 'confirm_delete' && ! empty($permissiontodelete)) |
|
| 179 | +if ($action == 'confirm_delete' && !empty($permissiontodelete)) |
|
| 180 | 180 | { |
| 181 | - if (! ($object->id > 0)) |
|
| 181 | + if (!($object->id > 0)) |
|
| 182 | 182 | { |
| 183 | 183 | dol_print_error('', 'Error, object must be fetched before being deleted'); |
| 184 | 184 | exit; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - $result=$object->delete($user); |
|
| 187 | + $result = $object->delete($user); |
|
| 188 | 188 | if ($result > 0) |
| 189 | 189 | { |
| 190 | 190 | // Delete OK |
@@ -194,13 +194,13 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | else |
| 196 | 196 | { |
| 197 | - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); |
|
| 197 | + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); |
|
| 198 | 198 | else setEventMessages($object->error, null, 'errors'); |
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | // Remove a line |
| 203 | -if ($action == 'confirm_deleteline' && $confirm == 'yes' && ! empty($permissiontoadd)) |
|
| 203 | +if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) |
|
| 204 | 204 | { |
| 205 | 205 | $result = $object->deleteline($user, $lineid); |
| 206 | 206 | if ($result > 0) |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | { |
| 217 | 217 | $newlang = $object->thirdparty->default_lang; |
| 218 | 218 | } |
| 219 | - if (! empty($newlang)) { |
|
| 219 | + if (!empty($newlang)) { |
|
| 220 | 220 | $outputlangs = new Translate("", $conf); |
| 221 | 221 | $outputlangs->setDefaultLang($newlang); |
| 222 | 222 | } |
@@ -248,11 +248,11 @@ discard block |
||
| 248 | 248 | $newlang = ''; |
| 249 | 249 | if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
| 250 | 250 | if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
| 251 | - if (! empty($newlang)) { |
|
| 251 | + if (!empty($newlang)) { |
|
| 252 | 252 | $outputlangs = new Translate("", $conf); |
| 253 | 253 | $outputlangs->setDefaultLang($newlang); |
| 254 | 254 | } |
| 255 | - $model=$object->modelpdf; |
|
| 255 | + $model = $object->modelpdf; |
|
| 256 | 256 | $ret = $object->fetch($id); // Reload to get new records |
| 257 | 257 | |
| 258 | 258 | $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | $newlang = ''; |
| 278 | 278 | if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
| 279 | 279 | if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
| 280 | - if (! empty($newlang)) { |
|
| 280 | + if (!empty($newlang)) { |
|
| 281 | 281 | $outputlangs = new Translate("", $conf); |
| 282 | 282 | $outputlangs->setDefaultLang($newlang); |
| 283 | 283 | } |
| 284 | - $model=$object->modelpdf; |
|
| 284 | + $model = $object->modelpdf; |
|
| 285 | 285 | $ret = $object->fetch($id); // Reload to get new records |
| 286 | 286 | |
| 287 | 287 | $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
@@ -320,11 +320,11 @@ discard block |
||
| 320 | 320 | $newlang = ''; |
| 321 | 321 | if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
| 322 | 322 | if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
| 323 | - if (! empty($newlang)) { |
|
| 323 | + if (!empty($newlang)) { |
|
| 324 | 324 | $outputlangs = new Translate("", $conf); |
| 325 | 325 | $outputlangs->setDefaultLang($newlang); |
| 326 | 326 | } |
| 327 | - $model=$object->modelpdf; |
|
| 327 | + $model = $object->modelpdf; |
|
| 328 | 328 | $ret = $object->fetch($id); // Reload to get new records |
| 329 | 329 | |
| 330 | 330 | $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
@@ -337,30 +337,30 @@ discard block |
||
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | // Action clone object |
| 340 | -if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd)) |
|
| 340 | +if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) |
|
| 341 | 341 | { |
| 342 | - if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) |
|
| 342 | + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) |
|
| 343 | 343 | { |
| 344 | 344 | setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); |
| 345 | 345 | } |
| 346 | 346 | else |
| 347 | 347 | { |
| 348 | - $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. |
|
| 348 | + $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. |
|
| 349 | 349 | //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); |
| 350 | 350 | // ... |
| 351 | - $result=$objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); |
|
| 351 | + $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); |
|
| 352 | 352 | if (is_object($result) || $result > 0) |
| 353 | 353 | { |
| 354 | 354 | $newid = 0; |
| 355 | 355 | if (is_object($result)) $newid = $result->id; |
| 356 | 356 | else $newid = $result; |
| 357 | - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object |
|
| 357 | + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object |
|
| 358 | 358 | exit; |
| 359 | 359 | } |
| 360 | 360 | else |
| 361 | 361 | { |
| 362 | 362 | setEventMessages($objectutil->error, $objectutil->errors, 'errors'); |
| 363 | - $action=''; |
|
| 363 | + $action = ''; |
|
| 364 | 364 | } |
| 365 | 365 | } |
| 366 | 366 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | /** |
| 61 | 61 | * @var string[] Array of error strings |
| 62 | 62 | */ |
| 63 | - public $errors=array(); |
|
| 63 | + public $errors = array(); |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * @var string ID to identify managed object |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | /** |
| 76 | 76 | * @var int Name of subtable line |
| 77 | 77 | */ |
| 78 | - public $table_element_line=''; |
|
| 78 | + public $table_element_line = ''; |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * @var string Key value used to track if data is coming from import wizard |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * @var mixed Contains data to manage extrafields |
| 87 | 87 | */ |
| 88 | - public $array_options=array(); |
|
| 88 | + public $array_options = array(); |
|
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * @var int[][] Array of linked objects ids. Loaded by ->fetchObjectLinked |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | /** |
| 115 | 115 | * @var array<string,mixed> Can be used to pass information when only object is provided to method |
| 116 | 116 | */ |
| 117 | - public $context=array(); |
|
| 117 | + public $context = array(); |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * @var string Contains canvas name if record is an alternative canvas record |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | * @var mixed Contains comments |
| 381 | 381 | * @see fetchComments() |
| 382 | 382 | */ |
| 383 | - public $comments=array(); |
|
| 383 | + public $comments = array(); |
|
| 384 | 384 | |
| 385 | 385 | /** |
| 386 | 386 | * @var int |
@@ -427,8 +427,8 @@ discard block |
||
| 427 | 427 | public $date_creation; |
| 428 | 428 | |
| 429 | 429 | |
| 430 | - public $date_validation; // Date validation |
|
| 431 | - public $date_modification; // Date last change (tms field) |
|
| 430 | + public $date_validation; // Date validation |
|
| 431 | + public $date_modification; // Date last change (tms field) |
|
| 432 | 432 | |
| 433 | 433 | public $next_prev_filter; |
| 434 | 434 | |
@@ -448,27 +448,27 @@ discard block |
||
| 448 | 448 | */ |
| 449 | 449 | public static function isExistingObject($element, $id, $ref = '', $ref_ext = '') |
| 450 | 450 | { |
| 451 | - global $db,$conf; |
|
| 451 | + global $db, $conf; |
|
| 452 | 452 | |
| 453 | 453 | $sql = "SELECT rowid, ref, ref_ext"; |
| 454 | - $sql.= " FROM ".MAIN_DB_PREFIX.$element; |
|
| 455 | - $sql.= " WHERE entity IN (".getEntity($element).")" ; |
|
| 454 | + $sql .= " FROM ".MAIN_DB_PREFIX.$element; |
|
| 455 | + $sql .= " WHERE entity IN (".getEntity($element).")"; |
|
| 456 | 456 | |
| 457 | - if ($id > 0) $sql.= " AND rowid = ".$db->escape($id); |
|
| 458 | - elseif ($ref) $sql.= " AND ref = '".$db->escape($ref)."'"; |
|
| 459 | - elseif ($ref_ext) $sql.= " AND ref_ext = '".$db->escape($ref_ext)."'"; |
|
| 457 | + if ($id > 0) $sql .= " AND rowid = ".$db->escape($id); |
|
| 458 | + elseif ($ref) $sql .= " AND ref = '".$db->escape($ref)."'"; |
|
| 459 | + elseif ($ref_ext) $sql .= " AND ref_ext = '".$db->escape($ref_ext)."'"; |
|
| 460 | 460 | else { |
| 461 | - $error='ErrorWrongParameters'; |
|
| 461 | + $error = 'ErrorWrongParameters'; |
|
| 462 | 462 | dol_print_error(get_class()."::isExistingObject ".$error, LOG_ERR); |
| 463 | 463 | return -1; |
| 464 | 464 | } |
| 465 | - if ($ref || $ref_ext) $sql.= " AND entity = ".$conf->entity; |
|
| 465 | + if ($ref || $ref_ext) $sql .= " AND entity = ".$conf->entity; |
|
| 466 | 466 | |
| 467 | 467 | dol_syslog(get_class()."::isExistingObject", LOG_DEBUG); |
| 468 | 468 | $resql = $db->query($sql); |
| 469 | 469 | if ($resql) |
| 470 | 470 | { |
| 471 | - $num=$db->num_rows($resql); |
|
| 471 | + $num = $db->num_rows($resql); |
|
| 472 | 472 | if ($num > 0) return 1; |
| 473 | 473 | else return 0; |
| 474 | 474 | } |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | */ |
| 483 | 483 | public function errorsToString() |
| 484 | 484 | { |
| 485 | - return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ', $this->errors)):''); |
|
| 485 | + return $this->error.(is_array($this->errors) ? (($this->error != '' ? ', ' : '').join(', ', $this->errors)) : ''); |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | /** |
@@ -495,14 +495,14 @@ discard block |
||
| 495 | 495 | { |
| 496 | 496 | global $hookmanager; |
| 497 | 497 | |
| 498 | - $parameters=array('objref'=>$objref); |
|
| 499 | - $action=''; |
|
| 498 | + $parameters = array('objref'=>$objref); |
|
| 499 | + $action = ''; |
|
| 500 | 500 | $reshook = $hookmanager->executeHooks('getFormatedCustomerRef', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
| 501 | 501 | if ($reshook > 0) |
| 502 | 502 | { |
| 503 | 503 | return $hookmanager->resArray['objref']; |
| 504 | 504 | } |
| 505 | - return $objref.(isset($hookmanager->resArray['objref'])?$hookmanager->resArray['objref']:''); |
|
| 505 | + return $objref.(isset($hookmanager->resArray['objref']) ? $hookmanager->resArray['objref'] : ''); |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | /** |
@@ -515,14 +515,14 @@ discard block |
||
| 515 | 515 | { |
| 516 | 516 | global $hookmanager; |
| 517 | 517 | |
| 518 | - $parameters=array('objref'=>$objref); |
|
| 519 | - $action=''; |
|
| 518 | + $parameters = array('objref'=>$objref); |
|
| 519 | + $action = ''; |
|
| 520 | 520 | $reshook = $hookmanager->executeHooks('getFormatedSupplierRef', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
| 521 | 521 | if ($reshook > 0) |
| 522 | 522 | { |
| 523 | 523 | return $hookmanager->resArray['objref']; |
| 524 | 524 | } |
| 525 | - return $objref.(isset($hookmanager->resArray['objref'])?$hookmanager->resArray['objref']:''); |
|
| 525 | + return $objref.(isset($hookmanager->resArray['objref']) ? $hookmanager->resArray['objref'] : ''); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | /** |
@@ -537,18 +537,18 @@ discard block |
||
| 537 | 537 | public function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0) |
| 538 | 538 | { |
| 539 | 539 | //print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."<br>\n"; |
| 540 | - $lastname=$this->lastname; |
|
| 541 | - $firstname=$this->firstname; |
|
| 542 | - if (empty($lastname)) $lastname=(isset($this->lastname)?$this->lastname:(isset($this->name)?$this->name:(isset($this->nom)?$this->nom:(isset($this->societe)?$this->societe:(isset($this->company)?$this->company:''))))); |
|
| 540 | + $lastname = $this->lastname; |
|
| 541 | + $firstname = $this->firstname; |
|
| 542 | + if (empty($lastname)) $lastname = (isset($this->lastname) ? $this->lastname : (isset($this->name) ? $this->name : (isset($this->nom) ? $this->nom : (isset($this->societe) ? $this->societe : (isset($this->company) ? $this->company : ''))))); |
|
| 543 | 543 | |
| 544 | - $ret=''; |
|
| 544 | + $ret = ''; |
|
| 545 | 545 | if ($option && $this->civility_id) |
| 546 | 546 | { |
| 547 | - if ($langs->transnoentitiesnoconv("Civility".$this->civility_id)!="Civility".$this->civility_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civility_id).' '; |
|
| 548 | - else $ret.=$this->civility_id.' '; |
|
| 547 | + if ($langs->transnoentitiesnoconv("Civility".$this->civility_id) != "Civility".$this->civility_id) $ret .= $langs->transnoentitiesnoconv("Civility".$this->civility_id).' '; |
|
| 548 | + else $ret .= $this->civility_id.' '; |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - $ret.=dolGetFirstLastname($firstname, $lastname, $nameorder); |
|
| 551 | + $ret .= dolGetFirstLastname($firstname, $lastname, $nameorder); |
|
| 552 | 552 | |
| 553 | 553 | return dol_trunc($ret, $maxlen); |
| 554 | 554 | } |
@@ -565,20 +565,20 @@ discard block |
||
| 565 | 565 | { |
| 566 | 566 | if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country))) |
| 567 | 567 | { |
| 568 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/company.lib.php'; |
|
| 569 | - $tmparray=getCountry($this->country_id, 'all'); |
|
| 570 | - $this->country_code=$tmparray['code']; |
|
| 571 | - $this->country =$tmparray['label']; |
|
| 568 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
|
| 569 | + $tmparray = getCountry($this->country_id, 'all'); |
|
| 570 | + $this->country_code = $tmparray['code']; |
|
| 571 | + $this->country = $tmparray['label']; |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | if ($withregion && $this->state_id && (empty($this->state_code) || empty($this->state) || empty($this->region) || empty($this->region_cpde))) |
| 575 | 575 | { |
| 576 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/company.lib.php'; |
|
| 577 | - $tmparray=getState($this->state_id, 'all', 0, 1); |
|
| 578 | - $this->state_code =$tmparray['code']; |
|
| 579 | - $this->state =$tmparray['label']; |
|
| 580 | - $this->region_code =$tmparray['region_code']; |
|
| 581 | - $this->region =$tmparray['region']; |
|
| 576 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
|
| 577 | + $tmparray = getState($this->state_id, 'all', 0, 1); |
|
| 578 | + $this->state_code = $tmparray['code']; |
|
| 579 | + $this->state = $tmparray['label']; |
|
| 580 | + $this->region_code = $tmparray['region_code']; |
|
| 581 | + $this->region = $tmparray['region']; |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | return dol_format_address($this, $withcountry, $sep); |
@@ -596,123 +596,123 @@ discard block |
||
| 596 | 596 | { |
| 597 | 597 | global $conf, $langs; |
| 598 | 598 | |
| 599 | - $countriesusingstate=array('AU','US','IN','GB','ES','UK','TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS |
|
| 599 | + $countriesusingstate = array('AU', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS |
|
| 600 | 600 | |
| 601 | - $contactid=0; |
|
| 602 | - $thirdpartyid=0; |
|
| 601 | + $contactid = 0; |
|
| 602 | + $thirdpartyid = 0; |
|
| 603 | 603 | if ($this->element == 'societe') |
| 604 | 604 | { |
| 605 | - $thirdpartyid=$this->id; |
|
| 605 | + $thirdpartyid = $this->id; |
|
| 606 | 606 | } |
| 607 | 607 | if ($this->element == 'contact') |
| 608 | 608 | { |
| 609 | - $contactid=$this->id; |
|
| 610 | - $thirdpartyid=$object->fk_soc; |
|
| 609 | + $contactid = $this->id; |
|
| 610 | + $thirdpartyid = $object->fk_soc; |
|
| 611 | 611 | } |
| 612 | 612 | if ($this->element == 'user') |
| 613 | 613 | { |
| 614 | - $contactid=$this->contact_id; |
|
| 615 | - $thirdpartyid=$object->fk_soc; |
|
| 614 | + $contactid = $this->contact_id; |
|
| 615 | + $thirdpartyid = $object->fk_soc; |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - $out='<!-- BEGIN part to show address block -->'; |
|
| 618 | + $out = '<!-- BEGIN part to show address block -->'; |
|
| 619 | 619 | |
| 620 | - $outdone=0; |
|
| 620 | + $outdone = 0; |
|
| 621 | 621 | $coords = $this->getFullAddress(1, ', ', $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT); |
| 622 | 622 | if ($coords) |
| 623 | 623 | { |
| 624 | - if (! empty($conf->use_javascript_ajax)) |
|
| 624 | + if (!empty($conf->use_javascript_ajax)) |
|
| 625 | 625 | { |
| 626 | 626 | $namecoords = ''; |
| 627 | - if ( $this->element == 'contact' && ! empty($conf->global->MAIN_SHOW_COMPANY_NAME_IN_BANNER_ADDRESS)) |
|
| 627 | + if ($this->element == 'contact' && !empty($conf->global->MAIN_SHOW_COMPANY_NAME_IN_BANNER_ADDRESS)) |
|
| 628 | 628 | { |
| 629 | - $namecoords.= $object->name.'<br>'; |
|
| 629 | + $namecoords .= $object->name.'<br>'; |
|
| 630 | 630 | } |
| 631 | - $namecoords.= $this->getFullName($langs, 1).'<br>'.$coords; |
|
| 631 | + $namecoords .= $this->getFullName($langs, 1).'<br>'.$coords; |
|
| 632 | 632 | // hideonsmatphone because copyToClipboard call jquery dialog that does not work with jmobile |
| 633 | - $out.='<a href="#" class="hideonsmartphone" onclick="return copyToClipboard(\''.dol_escape_js($namecoords).'\',\''.dol_escape_js($langs->trans("HelpCopyToClipboard")).'\');">'; |
|
| 634 | - $out.=img_picto($langs->trans("Address"), 'object_address.png'); |
|
| 635 | - $out.='</a> '; |
|
| 633 | + $out .= '<a href="#" class="hideonsmartphone" onclick="return copyToClipboard(\''.dol_escape_js($namecoords).'\',\''.dol_escape_js($langs->trans("HelpCopyToClipboard")).'\');">'; |
|
| 634 | + $out .= img_picto($langs->trans("Address"), 'object_address.png'); |
|
| 635 | + $out .= '</a> '; |
|
| 636 | 636 | } |
| 637 | - $out.=dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', '); $outdone++; |
|
| 637 | + $out .= dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', '); $outdone++; |
|
| 638 | 638 | $outdone++; |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - if (! in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress |
|
| 641 | + if (!in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress |
|
| 642 | 642 | && empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) |
| 643 | 643 | { |
| 644 | 644 | if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) { |
| 645 | - $out.=($outdone?' - ':'').$this->region.' - '.$this->state; |
|
| 645 | + $out .= ($outdone ? ' - ' : '').$this->region.' - '.$this->state; |
|
| 646 | 646 | } |
| 647 | 647 | else { |
| 648 | - $out.=($outdone?' - ':'').$this->state; |
|
| 648 | + $out .= ($outdone ? ' - ' : '').$this->state; |
|
| 649 | 649 | } |
| 650 | 650 | $outdone++; |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - if (! empty($this->phone) || ! empty($this->phone_pro) || ! empty($this->phone_mobile) || ! empty($this->phone_perso) || ! empty($this->fax) || ! empty($this->office_phone) || ! empty($this->user_mobile) || ! empty($this->office_fax)) $out.=($outdone?'<br>':''); |
|
| 654 | - if (! empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone |
|
| 655 | - $out.=dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; |
|
| 653 | + if (!empty($this->phone) || !empty($this->phone_pro) || !empty($this->phone_mobile) || !empty($this->phone_perso) || !empty($this->fax) || !empty($this->office_phone) || !empty($this->user_mobile) || !empty($this->office_fax)) $out .= ($outdone ? '<br>' : ''); |
|
| 654 | + if (!empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone |
|
| 655 | + $out .= dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; |
|
| 656 | 656 | } |
| 657 | - if (! empty($this->phone_pro)) { |
|
| 658 | - $out.=dol_print_phone($this->phone_pro, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; |
|
| 657 | + if (!empty($this->phone_pro)) { |
|
| 658 | + $out .= dol_print_phone($this->phone_pro, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; |
|
| 659 | 659 | } |
| 660 | - if (! empty($this->phone_mobile)) { |
|
| 661 | - $out.=dol_print_phone($this->phone_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++; |
|
| 660 | + if (!empty($this->phone_mobile)) { |
|
| 661 | + $out .= dol_print_phone($this->phone_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++; |
|
| 662 | 662 | } |
| 663 | - if (! empty($this->phone_perso)) { |
|
| 664 | - $out.=dol_print_phone($this->phone_perso, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePerso")); $outdone++; |
|
| 663 | + if (!empty($this->phone_perso)) { |
|
| 664 | + $out .= dol_print_phone($this->phone_perso, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePerso")); $outdone++; |
|
| 665 | 665 | } |
| 666 | - if (! empty($this->office_phone)) { |
|
| 667 | - $out.=dol_print_phone($this->office_phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; |
|
| 666 | + if (!empty($this->office_phone)) { |
|
| 667 | + $out .= dol_print_phone($this->office_phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; |
|
| 668 | 668 | } |
| 669 | - if (! empty($this->user_mobile)) { |
|
| 670 | - $out.=dol_print_phone($this->user_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++; |
|
| 669 | + if (!empty($this->user_mobile)) { |
|
| 670 | + $out .= dol_print_phone($this->user_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++; |
|
| 671 | 671 | } |
| 672 | - if (! empty($this->fax)) { |
|
| 673 | - $out.=dol_print_phone($this->fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; |
|
| 672 | + if (!empty($this->fax)) { |
|
| 673 | + $out .= dol_print_phone($this->fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; |
|
| 674 | 674 | } |
| 675 | - if (! empty($this->office_fax)) { |
|
| 676 | - $out.=dol_print_phone($this->office_fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; |
|
| 675 | + if (!empty($this->office_fax)) { |
|
| 676 | + $out .= dol_print_phone($this->office_fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - $out.='<div style="clear: both;"></div>'; |
|
| 680 | - $outdone=0; |
|
| 681 | - if (! empty($this->email)) |
|
| 679 | + $out .= '<div style="clear: both;"></div>'; |
|
| 680 | + $outdone = 0; |
|
| 681 | + if (!empty($this->email)) |
|
| 682 | 682 | { |
| 683 | - $out.=dol_print_email($this->email, $this->id, $object->id, 'AC_EMAIL', 0, 0, 1); |
|
| 683 | + $out .= dol_print_email($this->email, $this->id, $object->id, 'AC_EMAIL', 0, 0, 1); |
|
| 684 | 684 | $outdone++; |
| 685 | 685 | } |
| 686 | - if (! empty($this->url)) |
|
| 686 | + if (!empty($this->url)) |
|
| 687 | 687 | { |
| 688 | 688 | //$out.=dol_print_url($this->url,'_goout',0,1);//steve changed to blank |
| 689 | - $out.=dol_print_url($this->url, '_blank', 0, 1); |
|
| 689 | + $out .= dol_print_url($this->url, '_blank', 0, 1); |
|
| 690 | 690 | $outdone++; |
| 691 | 691 | } |
| 692 | - $out.='<div style="clear: both;">'; |
|
| 693 | - if (! empty($conf->socialnetworks->enabled)) |
|
| 692 | + $out .= '<div style="clear: both;">'; |
|
| 693 | + if (!empty($conf->socialnetworks->enabled)) |
|
| 694 | 694 | { |
| 695 | - if (is_array($this->socialnetworks) && count($this->socialnetworks)>0) { |
|
| 695 | + if (is_array($this->socialnetworks) && count($this->socialnetworks) > 0) { |
|
| 696 | 696 | foreach ($this->socialnetworks as $key => $value) { |
| 697 | - $out.=dol_print_socialnetworks($value, $this->id, $object->id, $key); |
|
| 697 | + $out .= dol_print_socialnetworks($value, $this->id, $object->id, $key); |
|
| 698 | 698 | $outdone++; |
| 699 | 699 | } |
| 700 | 700 | } else { |
| 701 | - if ($this->skype) $out.=dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); |
|
| 701 | + if ($this->skype) $out .= dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); |
|
| 702 | 702 | $outdone++; |
| 703 | - if ($this->jabberid) $out.=dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); |
|
| 703 | + if ($this->jabberid) $out .= dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); |
|
| 704 | 704 | $outdone++; |
| 705 | - if ($this->twitter) $out.=dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); |
|
| 705 | + if ($this->twitter) $out .= dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); |
|
| 706 | 706 | $outdone++; |
| 707 | - if ($this->facebook) $out.=dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); |
|
| 707 | + if ($this->facebook) $out .= dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); |
|
| 708 | 708 | $outdone++; |
| 709 | - if ($this->linkedin) $out.=dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); |
|
| 709 | + if ($this->linkedin) $out .= dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); |
|
| 710 | 710 | $outdone++; |
| 711 | 711 | } |
| 712 | 712 | } |
| 713 | - $out.='</div>'; |
|
| 713 | + $out .= '</div>'; |
|
| 714 | 714 | |
| 715 | - $out.='<!-- END Part to show address block -->'; |
|
| 715 | + $out .= '<!-- END Part to show address block -->'; |
|
| 716 | 716 | |
| 717 | 717 | return $out; |
| 718 | 718 | } |
@@ -731,11 +731,11 @@ discard block |
||
| 731 | 731 | |
| 732 | 732 | if (empty($this->last_main_doc)) |
| 733 | 733 | { |
| 734 | - return ''; // No way to known which document name to use |
|
| 734 | + return ''; // No way to known which document name to use |
|
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
| 738 | - $ecmfile=new EcmFiles($this->db); |
|
| 738 | + $ecmfile = new EcmFiles($this->db); |
|
| 739 | 739 | $result = $ecmfile->fetch(0, '', $this->last_main_doc); |
| 740 | 740 | if ($result < 0) |
| 741 | 741 | { |
@@ -782,29 +782,29 @@ discard block |
||
| 782 | 782 | else return ''; |
| 783 | 783 | } |
| 784 | 784 | // Define $urlwithroot |
| 785 | - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); |
|
| 785 | + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); |
|
| 786 | 786 | // This is to use external domain name found into config file |
| 787 | 787 | //if (DOL_URL_ROOT && ! preg_match('/\/$/', $urlwithouturlroot) && ! preg_match('/^\//', DOL_URL_ROOT)) $urlwithroot=$urlwithouturlroot.'/'.DOL_URL_ROOT; |
| 788 | 788 | //else |
| 789 | - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; |
|
| 789 | + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; |
|
| 790 | 790 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
| 791 | 791 | |
| 792 | - $forcedownload=0; |
|
| 792 | + $forcedownload = 0; |
|
| 793 | 793 | |
| 794 | - $paramlink=''; |
|
| 794 | + $paramlink = ''; |
|
| 795 | 795 | //if (! empty($modulepart)) $paramlink.=($paramlink?'&':'').'modulepart='.$modulepart; // For sharing with hash (so public files), modulepart is not required. |
| 796 | 796 | //if (! empty($ecmfile->entity)) $paramlink.='&entity='.$ecmfile->entity; // For sharing with hash (so public files), entity is not required. |
| 797 | 797 | //$paramlink.=($paramlink?'&':'').'file='.urlencode($filepath); // No need of name of file for public link, we will use the hash |
| 798 | - if (! empty($ecmfile->share)) $paramlink.=($paramlink?'&':'').'hashp='.$ecmfile->share; // Hash for public share |
|
| 799 | - if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1'; |
|
| 798 | + if (!empty($ecmfile->share)) $paramlink .= ($paramlink ? '&' : '').'hashp='.$ecmfile->share; // Hash for public share |
|
| 799 | + if ($forcedownload) $paramlink .= ($paramlink ? '&' : '').'attachment=1'; |
|
| 800 | 800 | |
| 801 | 801 | if ($relativelink) |
| 802 | 802 | { |
| 803 | - $linktoreturn='document.php'.($paramlink?'?'.$paramlink:''); |
|
| 803 | + $linktoreturn = 'document.php'.($paramlink ? '?'.$paramlink : ''); |
|
| 804 | 804 | } |
| 805 | 805 | else |
| 806 | 806 | { |
| 807 | - $linktoreturn=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:''); |
|
| 807 | + $linktoreturn = $urlwithroot.'/document.php'.($paramlink ? '?'.$paramlink : ''); |
|
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | // Here $ecmfile->share is defined |
@@ -825,7 +825,7 @@ discard block |
||
| 825 | 825 | public function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0) |
| 826 | 826 | { |
| 827 | 827 | // phpcs:enable |
| 828 | - global $user,$langs; |
|
| 828 | + global $user, $langs; |
|
| 829 | 829 | |
| 830 | 830 | |
| 831 | 831 | dol_syslog(get_class($this)."::add_contact $fk_socpeople, $type_contact, $source, $notrigger"); |
@@ -834,43 +834,43 @@ discard block |
||
| 834 | 834 | if ($fk_socpeople <= 0) |
| 835 | 835 | { |
| 836 | 836 | $langs->load("errors"); |
| 837 | - $this->error=$langs->trans("ErrorWrongValueForParameterX", "1"); |
|
| 837 | + $this->error = $langs->trans("ErrorWrongValueForParameterX", "1"); |
|
| 838 | 838 | dol_syslog(get_class($this)."::add_contact ".$this->error, LOG_ERR); |
| 839 | 839 | return -1; |
| 840 | 840 | } |
| 841 | - if (! $type_contact) |
|
| 841 | + if (!$type_contact) |
|
| 842 | 842 | { |
| 843 | 843 | $langs->load("errors"); |
| 844 | - $this->error=$langs->trans("ErrorWrongValueForParameterX", "2"); |
|
| 844 | + $this->error = $langs->trans("ErrorWrongValueForParameterX", "2"); |
|
| 845 | 845 | dol_syslog(get_class($this)."::add_contact ".$this->error, LOG_ERR); |
| 846 | 846 | return -2; |
| 847 | 847 | } |
| 848 | 848 | |
| 849 | - $id_type_contact=0; |
|
| 849 | + $id_type_contact = 0; |
|
| 850 | 850 | if (is_numeric($type_contact)) |
| 851 | 851 | { |
| 852 | - $id_type_contact=$type_contact; |
|
| 852 | + $id_type_contact = $type_contact; |
|
| 853 | 853 | } |
| 854 | 854 | else |
| 855 | 855 | { |
| 856 | 856 | // We look for id type_contact |
| 857 | 857 | $sql = "SELECT tc.rowid"; |
| 858 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 859 | - $sql.= " WHERE tc.element='".$this->db->escape($this->element)."'"; |
|
| 860 | - $sql.= " AND tc.source='".$this->db->escape($source)."'"; |
|
| 861 | - $sql.= " AND tc.code='".$this->db->escape($type_contact)."' AND tc.active=1"; |
|
| 858 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 859 | + $sql .= " WHERE tc.element='".$this->db->escape($this->element)."'"; |
|
| 860 | + $sql .= " AND tc.source='".$this->db->escape($source)."'"; |
|
| 861 | + $sql .= " AND tc.code='".$this->db->escape($type_contact)."' AND tc.active=1"; |
|
| 862 | 862 | //print $sql; |
| 863 | - $resql=$this->db->query($sql); |
|
| 863 | + $resql = $this->db->query($sql); |
|
| 864 | 864 | if ($resql) |
| 865 | 865 | { |
| 866 | 866 | $obj = $this->db->fetch_object($resql); |
| 867 | - if ($obj) $id_type_contact=$obj->rowid; |
|
| 867 | + if ($obj) $id_type_contact = $obj->rowid; |
|
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | if ($id_type_contact == 0) |
| 872 | 872 | { |
| 873 | - $this->error='CODE_NOT_VALID_FOR_THIS_ELEMENT'; |
|
| 873 | + $this->error = 'CODE_NOT_VALID_FOR_THIS_ELEMENT'; |
|
| 874 | 874 | dol_syslog("CODE_NOT_VALID_FOR_THIS_ELEMENT: Code type of contact '".$type_contact."' does not exists or is not active for element ".$this->element.", we can ignore it"); |
| 875 | 875 | return -3; |
| 876 | 876 | } |
@@ -878,34 +878,34 @@ discard block |
||
| 878 | 878 | $datecreate = dol_now(); |
| 879 | 879 | |
| 880 | 880 | // Socpeople must have already been added by some trigger, then we have to check it to avoid DB_ERROR_RECORD_ALREADY_EXISTS error |
| 881 | - $TListeContacts=$this->liste_contact(-1, $source); |
|
| 882 | - $already_added=false; |
|
| 883 | - if (is_array($TListeContacts) && ! empty($TListeContacts)) { |
|
| 884 | - foreach($TListeContacts as $array_contact) { |
|
| 881 | + $TListeContacts = $this->liste_contact(-1, $source); |
|
| 882 | + $already_added = false; |
|
| 883 | + if (is_array($TListeContacts) && !empty($TListeContacts)) { |
|
| 884 | + foreach ($TListeContacts as $array_contact) { |
|
| 885 | 885 | if ($array_contact['status'] == 4 && $array_contact['id'] == $fk_socpeople && $array_contact['fk_c_type_contact'] == $id_type_contact) { |
| 886 | - $already_added=true; |
|
| 886 | + $already_added = true; |
|
| 887 | 887 | break; |
| 888 | 888 | } |
| 889 | 889 | } |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - if(!$already_added) { |
|
| 892 | + if (!$already_added) { |
|
| 893 | 893 | $this->db->begin(); |
| 894 | 894 | |
| 895 | 895 | // Insert into database |
| 896 | 896 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; |
| 897 | - $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; |
|
| 898 | - $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ; |
|
| 899 | - $sql.= "'".$this->db->idate($datecreate)."'"; |
|
| 900 | - $sql.= ", 4, ". $id_type_contact; |
|
| 901 | - $sql.= ")"; |
|
| 897 | + $sql .= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; |
|
| 898 | + $sql .= " VALUES (".$this->id.", ".$fk_socpeople." , "; |
|
| 899 | + $sql .= "'".$this->db->idate($datecreate)."'"; |
|
| 900 | + $sql .= ", 4, ".$id_type_contact; |
|
| 901 | + $sql .= ")"; |
|
| 902 | 902 | |
| 903 | - $resql=$this->db->query($sql); |
|
| 903 | + $resql = $this->db->query($sql); |
|
| 904 | 904 | if ($resql) |
| 905 | 905 | { |
| 906 | - if (! $notrigger) |
|
| 906 | + if (!$notrigger) |
|
| 907 | 907 | { |
| 908 | - $result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user); |
|
| 908 | + $result = $this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user); |
|
| 909 | 909 | if ($result < 0) |
| 910 | 910 | { |
| 911 | 911 | $this->db->rollback(); |
@@ -920,14 +920,14 @@ discard block |
||
| 920 | 920 | { |
| 921 | 921 | if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
| 922 | 922 | { |
| 923 | - $this->error=$this->db->errno(); |
|
| 923 | + $this->error = $this->db->errno(); |
|
| 924 | 924 | $this->db->rollback(); |
| 925 | 925 | echo 'err rollback'; |
| 926 | 926 | return -2; |
| 927 | 927 | } |
| 928 | 928 | else |
| 929 | 929 | { |
| 930 | - $this->error=$this->db->error(); |
|
| 930 | + $this->error = $this->db->error(); |
|
| 931 | 931 | $this->db->rollback(); |
| 932 | 932 | return -1; |
| 933 | 933 | } |
@@ -947,11 +947,11 @@ discard block |
||
| 947 | 947 | { |
| 948 | 948 | // phpcs:enable |
| 949 | 949 | $contacts = $objFrom->liste_contact(-1, $source); |
| 950 | - foreach($contacts as $contact) |
|
| 950 | + foreach ($contacts as $contact) |
|
| 951 | 951 | { |
| 952 | 952 | if ($this->add_contact($contact['id'], $contact['fk_c_type_contact'], $contact['source']) < 0) |
| 953 | 953 | { |
| 954 | - $this->error=$this->db->lasterror(); |
|
| 954 | + $this->error = $this->db->lasterror(); |
|
| 955 | 955 | return -1; |
| 956 | 956 | } |
| 957 | 957 | } |
@@ -973,18 +973,18 @@ discard block |
||
| 973 | 973 | // phpcs:enable |
| 974 | 974 | // Insert into database |
| 975 | 975 | $sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set"; |
| 976 | - $sql.= " statut = ".$statut; |
|
| 977 | - if ($type_contact_id) $sql.= ", fk_c_type_contact = '".$type_contact_id ."'"; |
|
| 978 | - if ($fk_socpeople) $sql.= ", fk_socpeople = '".$fk_socpeople ."'"; |
|
| 979 | - $sql.= " where rowid = ".$rowid; |
|
| 980 | - $resql=$this->db->query($sql); |
|
| 976 | + $sql .= " statut = ".$statut; |
|
| 977 | + if ($type_contact_id) $sql .= ", fk_c_type_contact = '".$type_contact_id."'"; |
|
| 978 | + if ($fk_socpeople) $sql .= ", fk_socpeople = '".$fk_socpeople."'"; |
|
| 979 | + $sql .= " where rowid = ".$rowid; |
|
| 980 | + $resql = $this->db->query($sql); |
|
| 981 | 981 | if ($resql) |
| 982 | 982 | { |
| 983 | 983 | return 0; |
| 984 | 984 | } |
| 985 | 985 | else |
| 986 | 986 | { |
| 987 | - $this->error=$this->db->lasterror(); |
|
| 987 | + $this->error = $this->db->lasterror(); |
|
| 988 | 988 | return -1; |
| 989 | 989 | } |
| 990 | 990 | } |
@@ -1006,14 +1006,14 @@ discard block |
||
| 1006 | 1006 | $this->db->begin(); |
| 1007 | 1007 | |
| 1008 | 1008 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; |
| 1009 | - $sql.= " WHERE rowid =".$rowid; |
|
| 1009 | + $sql .= " WHERE rowid =".$rowid; |
|
| 1010 | 1010 | |
| 1011 | 1011 | dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG); |
| 1012 | 1012 | if ($this->db->query($sql)) |
| 1013 | 1013 | { |
| 1014 | - if (! $notrigger) |
|
| 1014 | + if (!$notrigger) |
|
| 1015 | 1015 | { |
| 1016 | - $result=$this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user); |
|
| 1016 | + $result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user); |
|
| 1017 | 1017 | if ($result < 0) { $this->db->rollback(); return -1; } |
| 1018 | 1018 | } |
| 1019 | 1019 | |
@@ -1022,7 +1022,7 @@ discard block |
||
| 1022 | 1022 | } |
| 1023 | 1023 | else |
| 1024 | 1024 | { |
| 1025 | - $this->error=$this->db->lasterror(); |
|
| 1025 | + $this->error = $this->db->lasterror(); |
|
| 1026 | 1026 | $this->db->rollback(); |
| 1027 | 1027 | return -1; |
| 1028 | 1028 | } |
@@ -1042,16 +1042,16 @@ discard block |
||
| 1042 | 1042 | $temp = array(); |
| 1043 | 1043 | $typeContact = $this->liste_type_contact($source, '', 0, 0, $code); |
| 1044 | 1044 | |
| 1045 | - foreach($typeContact as $key => $value) |
|
| 1045 | + foreach ($typeContact as $key => $value) |
|
| 1046 | 1046 | { |
| 1047 | 1047 | array_push($temp, $key); |
| 1048 | 1048 | } |
| 1049 | 1049 | $listId = implode(",", $temp); |
| 1050 | 1050 | |
| 1051 | 1051 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; |
| 1052 | - $sql.= " WHERE element_id = ".$this->id; |
|
| 1052 | + $sql .= " WHERE element_id = ".$this->id; |
|
| 1053 | 1053 | if ($listId) |
| 1054 | - $sql.= " AND fk_c_type_contact IN (".$listId.")"; |
|
| 1054 | + $sql .= " AND fk_c_type_contact IN (".$listId.")"; |
|
| 1055 | 1055 | |
| 1056 | 1056 | dol_syslog(get_class($this)."::delete_linked_contact", LOG_DEBUG); |
| 1057 | 1057 | if ($this->db->query($sql)) |
@@ -1060,7 +1060,7 @@ discard block |
||
| 1060 | 1060 | } |
| 1061 | 1061 | else |
| 1062 | 1062 | { |
| 1063 | - $this->error=$this->db->lasterror(); |
|
| 1063 | + $this->error = $this->db->lasterror(); |
|
| 1064 | 1064 | return -1; |
| 1065 | 1065 | } |
| 1066 | 1066 | } |
@@ -1080,49 +1080,49 @@ discard block |
||
| 1080 | 1080 | // phpcs:enable |
| 1081 | 1081 | global $langs; |
| 1082 | 1082 | |
| 1083 | - $tab=array(); |
|
| 1084 | - |
|
| 1085 | - $sql = "SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact"; // This field contains id of llx_socpeople or id of llx_user |
|
| 1086 | - if ($source == 'internal') $sql.=", '-1' as socid, t.statut as statuscontact, t.login, t.photo"; |
|
| 1087 | - if ($source == 'external' || $source == 'thirdparty') $sql.=", t.fk_soc as socid, t.statut as statuscontact"; |
|
| 1088 | - $sql.= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email"; |
|
| 1089 | - $sql.= ", tc.source, tc.element, tc.code, tc.libelle"; |
|
| 1090 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; |
|
| 1091 | - $sql.= ", ".MAIN_DB_PREFIX."element_contact ec"; |
|
| 1092 | - if ($source == 'internal') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid"; |
|
| 1093 | - if ($source == 'external'|| $source == 'thirdparty') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid"; |
|
| 1094 | - $sql.= " WHERE ec.element_id =".$this->id; |
|
| 1095 | - $sql.= " AND ec.fk_c_type_contact=tc.rowid"; |
|
| 1096 | - $sql.= " AND tc.element='".$this->db->escape($this->element)."'"; |
|
| 1097 | - if ($code) $sql.= " AND tc.code = '".$this->db->escape($code)."'"; |
|
| 1098 | - if ($source == 'internal') $sql.= " AND tc.source = 'internal'"; |
|
| 1099 | - if ($source == 'external' || $source == 'thirdparty') $sql.= " AND tc.source = 'external'"; |
|
| 1100 | - $sql.= " AND tc.active=1"; |
|
| 1101 | - if ($status >= 0) $sql.= " AND ec.statut = ".$status; |
|
| 1102 | - $sql.=" ORDER BY t.lastname ASC"; |
|
| 1083 | + $tab = array(); |
|
| 1084 | + |
|
| 1085 | + $sql = "SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact"; // This field contains id of llx_socpeople or id of llx_user |
|
| 1086 | + if ($source == 'internal') $sql .= ", '-1' as socid, t.statut as statuscontact, t.login, t.photo"; |
|
| 1087 | + if ($source == 'external' || $source == 'thirdparty') $sql .= ", t.fk_soc as socid, t.statut as statuscontact"; |
|
| 1088 | + $sql .= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email"; |
|
| 1089 | + $sql .= ", tc.source, tc.element, tc.code, tc.libelle"; |
|
| 1090 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; |
|
| 1091 | + $sql .= ", ".MAIN_DB_PREFIX."element_contact ec"; |
|
| 1092 | + if ($source == 'internal') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid"; |
|
| 1093 | + if ($source == 'external' || $source == 'thirdparty') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid"; |
|
| 1094 | + $sql .= " WHERE ec.element_id =".$this->id; |
|
| 1095 | + $sql .= " AND ec.fk_c_type_contact=tc.rowid"; |
|
| 1096 | + $sql .= " AND tc.element='".$this->db->escape($this->element)."'"; |
|
| 1097 | + if ($code) $sql .= " AND tc.code = '".$this->db->escape($code)."'"; |
|
| 1098 | + if ($source == 'internal') $sql .= " AND tc.source = 'internal'"; |
|
| 1099 | + if ($source == 'external' || $source == 'thirdparty') $sql .= " AND tc.source = 'external'"; |
|
| 1100 | + $sql .= " AND tc.active=1"; |
|
| 1101 | + if ($status >= 0) $sql .= " AND ec.statut = ".$status; |
|
| 1102 | + $sql .= " ORDER BY t.lastname ASC"; |
|
| 1103 | 1103 | |
| 1104 | 1104 | dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG); |
| 1105 | - $resql=$this->db->query($sql); |
|
| 1105 | + $resql = $this->db->query($sql); |
|
| 1106 | 1106 | if ($resql) |
| 1107 | 1107 | { |
| 1108 | - $num=$this->db->num_rows($resql); |
|
| 1109 | - $i=0; |
|
| 1108 | + $num = $this->db->num_rows($resql); |
|
| 1109 | + $i = 0; |
|
| 1110 | 1110 | while ($i < $num) |
| 1111 | 1111 | { |
| 1112 | 1112 | $obj = $this->db->fetch_object($resql); |
| 1113 | 1113 | |
| 1114 | - if (! $list) |
|
| 1114 | + if (!$list) |
|
| 1115 | 1115 | { |
| 1116 | - $transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code; |
|
| 1117 | - $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); |
|
| 1118 | - $tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id, |
|
| 1119 | - 'nom'=>$obj->lastname, // For backward compatibility |
|
| 1116 | + $transkey = "TypeContact_".$obj->element."_".$obj->source."_".$obj->code; |
|
| 1117 | + $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); |
|
| 1118 | + $tab[$i] = array('source'=>$obj->source, 'socid'=>$obj->socid, 'id'=>$obj->id, |
|
| 1119 | + 'nom'=>$obj->lastname, // For backward compatibility |
|
| 1120 | 1120 | 'civility'=>$obj->civility, 'lastname'=>$obj->lastname, 'firstname'=>$obj->firstname, 'email'=>$obj->email, 'login'=>$obj->login, 'photo'=>$obj->photo, 'statuscontact'=>$obj->statuscontact, |
| 1121 | 1121 | 'rowid'=>$obj->rowid, 'code'=>$obj->code, 'libelle'=>$libelle_type, 'status'=>$obj->statuslink, 'fk_c_type_contact'=>$obj->fk_c_type_contact); |
| 1122 | 1122 | } |
| 1123 | 1123 | else |
| 1124 | 1124 | { |
| 1125 | - $tab[$i]=$obj->id; |
|
| 1125 | + $tab[$i] = $obj->id; |
|
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | $i++; |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | } |
| 1133 | 1133 | else |
| 1134 | 1134 | { |
| 1135 | - $this->error=$this->db->lasterror(); |
|
| 1135 | + $this->error = $this->db->lasterror(); |
|
| 1136 | 1136 | dol_print_error($this->db); |
| 1137 | 1137 | return -1; |
| 1138 | 1138 | } |
@@ -1148,16 +1148,16 @@ discard block |
||
| 1148 | 1148 | public function swapContactStatus($rowid) |
| 1149 | 1149 | { |
| 1150 | 1150 | $sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,"; |
| 1151 | - $sql.= " tc.code, tc.libelle"; |
|
| 1151 | + $sql .= " tc.code, tc.libelle"; |
|
| 1152 | 1152 | //$sql.= ", s.fk_soc"; |
| 1153 | - $sql.= " FROM (".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc)"; |
|
| 1153 | + $sql .= " FROM (".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc)"; |
|
| 1154 | 1154 | //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as s ON ec.fk_socpeople=s.rowid"; // Si contact de type external, alors il est lie a une societe |
| 1155 | - $sql.= " WHERE ec.rowid =".$rowid; |
|
| 1156 | - $sql.= " AND ec.fk_c_type_contact=tc.rowid"; |
|
| 1157 | - $sql.= " AND tc.element = '".$this->db->escape($this->element)."'"; |
|
| 1155 | + $sql .= " WHERE ec.rowid =".$rowid; |
|
| 1156 | + $sql .= " AND ec.fk_c_type_contact=tc.rowid"; |
|
| 1157 | + $sql .= " AND tc.element = '".$this->db->escape($this->element)."'"; |
|
| 1158 | 1158 | |
| 1159 | 1159 | dol_syslog(get_class($this)."::swapContactStatus", LOG_DEBUG); |
| 1160 | - $resql=$this->db->query($sql); |
|
| 1160 | + $resql = $this->db->query($sql); |
|
| 1161 | 1161 | if ($resql) |
| 1162 | 1162 | { |
| 1163 | 1163 | $obj = $this->db->fetch_object($resql); |
@@ -1168,7 +1168,7 @@ discard block |
||
| 1168 | 1168 | } |
| 1169 | 1169 | else |
| 1170 | 1170 | { |
| 1171 | - $this->error=$this->db->error(); |
|
| 1171 | + $this->error = $this->db->error(); |
|
| 1172 | 1172 | dol_print_error($this->db); |
| 1173 | 1173 | return -1; |
| 1174 | 1174 | } |
@@ -1190,39 +1190,39 @@ discard block |
||
| 1190 | 1190 | // phpcs:enable |
| 1191 | 1191 | global $langs; |
| 1192 | 1192 | |
| 1193 | - if (empty($order)) $order='position'; |
|
| 1194 | - if ($order == 'position') $order.=',code'; |
|
| 1193 | + if (empty($order)) $order = 'position'; |
|
| 1194 | + if ($order == 'position') $order .= ',code'; |
|
| 1195 | 1195 | |
| 1196 | 1196 | $tab = array(); |
| 1197 | 1197 | $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position"; |
| 1198 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 1199 | - $sql.= " WHERE tc.element='".$this->db->escape($this->element)."'"; |
|
| 1200 | - if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active types |
|
| 1201 | - if (! empty($source) && $source != 'all') $sql.= " AND tc.source='".$this->db->escape($source)."'"; |
|
| 1202 | - if (! empty($code)) $sql.= " AND tc.code='".$this->db->escape($code)."'"; |
|
| 1203 | - $sql.= $this->db->order($order, 'ASC'); |
|
| 1198 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 1199 | + $sql .= " WHERE tc.element='".$this->db->escape($this->element)."'"; |
|
| 1200 | + if ($activeonly == 1) $sql .= " AND tc.active=1"; // only the active types |
|
| 1201 | + if (!empty($source) && $source != 'all') $sql .= " AND tc.source='".$this->db->escape($source)."'"; |
|
| 1202 | + if (!empty($code)) $sql .= " AND tc.code='".$this->db->escape($code)."'"; |
|
| 1203 | + $sql .= $this->db->order($order, 'ASC'); |
|
| 1204 | 1204 | |
| 1205 | 1205 | //print "sql=".$sql; |
| 1206 | - $resql=$this->db->query($sql); |
|
| 1206 | + $resql = $this->db->query($sql); |
|
| 1207 | 1207 | if ($resql) |
| 1208 | 1208 | { |
| 1209 | - $num=$this->db->num_rows($resql); |
|
| 1210 | - $i=0; |
|
| 1209 | + $num = $this->db->num_rows($resql); |
|
| 1210 | + $i = 0; |
|
| 1211 | 1211 | while ($i < $num) |
| 1212 | 1212 | { |
| 1213 | 1213 | $obj = $this->db->fetch_object($resql); |
| 1214 | 1214 | |
| 1215 | - $transkey="TypeContact_".$this->element."_".$source."_".$obj->code; |
|
| 1216 | - $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); |
|
| 1217 | - if (empty($option)) $tab[$obj->rowid]=$libelle_type; |
|
| 1218 | - else $tab[$obj->code]=$libelle_type; |
|
| 1215 | + $transkey = "TypeContact_".$this->element."_".$source."_".$obj->code; |
|
| 1216 | + $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); |
|
| 1217 | + if (empty($option)) $tab[$obj->rowid] = $libelle_type; |
|
| 1218 | + else $tab[$obj->code] = $libelle_type; |
|
| 1219 | 1219 | $i++; |
| 1220 | 1220 | } |
| 1221 | 1221 | return $tab; |
| 1222 | 1222 | } |
| 1223 | 1223 | else |
| 1224 | 1224 | { |
| 1225 | - $this->error=$this->db->lasterror(); |
|
| 1225 | + $this->error = $this->db->lasterror(); |
|
| 1226 | 1226 | //dol_print_error($this->db); |
| 1227 | 1227 | return null; |
| 1228 | 1228 | } |
@@ -1247,51 +1247,51 @@ discard block |
||
| 1247 | 1247 | $tab = array(); |
| 1248 | 1248 | |
| 1249 | 1249 | $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position, tc.element"; |
| 1250 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 1250 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 1251 | 1251 | |
| 1252 | - $sqlWhere=array(); |
|
| 1252 | + $sqlWhere = array(); |
|
| 1253 | 1253 | if (!empty($element)) |
| 1254 | - $sqlWhere[]=" tc.element='".$this->db->escape($element)."'"; |
|
| 1254 | + $sqlWhere[] = " tc.element='".$this->db->escape($element)."'"; |
|
| 1255 | 1255 | |
| 1256 | 1256 | if ($activeonly == 1) |
| 1257 | - $sqlWhere[]=" tc.active=1"; // only the active types |
|
| 1257 | + $sqlWhere[] = " tc.active=1"; // only the active types |
|
| 1258 | 1258 | |
| 1259 | - if (! empty($source) && $source != 'all') |
|
| 1260 | - $sqlWhere[]=" tc.source='".$this->db->escape($source)."'"; |
|
| 1259 | + if (!empty($source) && $source != 'all') |
|
| 1260 | + $sqlWhere[] = " tc.source='".$this->db->escape($source)."'"; |
|
| 1261 | 1261 | |
| 1262 | - if (! empty($code)) |
|
| 1263 | - $sqlWhere[]=" tc.code='".$this->db->escape($code)."'"; |
|
| 1262 | + if (!empty($code)) |
|
| 1263 | + $sqlWhere[] = " tc.code='".$this->db->escape($code)."'"; |
|
| 1264 | 1264 | |
| 1265 | - if (count($sqlWhere)>0) { |
|
| 1266 | - $sql .= " WHERE ". implode(' AND ', $sqlWhere); |
|
| 1265 | + if (count($sqlWhere) > 0) { |
|
| 1266 | + $sql .= " WHERE ".implode(' AND ', $sqlWhere); |
|
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | - $sql.= $this->db->order('tc.element, tc.position', 'ASC'); |
|
| 1269 | + $sql .= $this->db->order('tc.element, tc.position', 'ASC'); |
|
| 1270 | 1270 | |
| 1271 | 1271 | dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); |
| 1272 | - $resql=$this->db->query($sql); |
|
| 1272 | + $resql = $this->db->query($sql); |
|
| 1273 | 1273 | if ($resql) { |
| 1274 | 1274 | $num = $this->db->num_rows($resql); |
| 1275 | 1275 | if ($num > 0) { |
| 1276 | 1276 | while ($obj = $this->db->fetch_object($resql)) { |
| 1277 | - if (strpos($obj->element, 'project')!==false) { |
|
| 1278 | - $element='projet'; |
|
| 1279 | - } elseif($obj->element=='contrat') { |
|
| 1280 | - $element='contract'; |
|
| 1281 | - } elseif(strpos($obj->element, 'supplier')!==false && $obj->element!='supplier_proposal') { |
|
| 1282 | - $element='fournisseur'; |
|
| 1283 | - } elseif(strpos($obj->element, 'supplier')!==false && $obj->element!='supplier_proposal') { |
|
| 1284 | - $element='fournisseur'; |
|
| 1277 | + if (strpos($obj->element, 'project') !== false) { |
|
| 1278 | + $element = 'projet'; |
|
| 1279 | + } elseif ($obj->element == 'contrat') { |
|
| 1280 | + $element = 'contract'; |
|
| 1281 | + } elseif (strpos($obj->element, 'supplier') !== false && $obj->element != 'supplier_proposal') { |
|
| 1282 | + $element = 'fournisseur'; |
|
| 1283 | + } elseif (strpos($obj->element, 'supplier') !== false && $obj->element != 'supplier_proposal') { |
|
| 1284 | + $element = 'fournisseur'; |
|
| 1285 | 1285 | } else { |
| 1286 | - $element=$obj->element; |
|
| 1286 | + $element = $obj->element; |
|
| 1287 | 1287 | } |
| 1288 | 1288 | if ($conf->{$element}->enabled) { |
| 1289 | - $libelle_element = $langs->trans('ContactDefault_' . $obj->element); |
|
| 1290 | - $transkey = "TypeContact_" . $this->element . "_" . $source . "_" . $obj->code; |
|
| 1289 | + $libelle_element = $langs->trans('ContactDefault_'.$obj->element); |
|
| 1290 | + $transkey = "TypeContact_".$this->element."_".$source."_".$obj->code; |
|
| 1291 | 1291 | $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); |
| 1292 | 1292 | if (empty($option)) |
| 1293 | - $tab[$obj->rowid] = $libelle_element . ' - ' . $libelle_type; |
|
| 1294 | - else $tab[$obj->rowid] = $libelle_element . ' - ' . $libelle_type; |
|
| 1293 | + $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; |
|
| 1294 | + else $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type; |
|
| 1295 | 1295 | } |
| 1296 | 1296 | } |
| 1297 | 1297 | } |
@@ -1299,7 +1299,7 @@ discard block |
||
| 1299 | 1299 | } |
| 1300 | 1300 | else |
| 1301 | 1301 | { |
| 1302 | - $this->error=$this->db->lasterror(); |
|
| 1302 | + $this->error = $this->db->lasterror(); |
|
| 1303 | 1303 | return null; |
| 1304 | 1304 | } |
| 1305 | 1305 | } |
@@ -1319,49 +1319,49 @@ discard block |
||
| 1319 | 1319 | { |
| 1320 | 1320 | global $conf; |
| 1321 | 1321 | |
| 1322 | - $result=array(); |
|
| 1323 | - $i=0; |
|
| 1322 | + $result = array(); |
|
| 1323 | + $i = 0; |
|
| 1324 | 1324 | //cas particulier pour les expeditions |
| 1325 | - if ($this->element=='shipping' && $this->origin_id != 0) { |
|
| 1326 | - $id=$this->origin_id; |
|
| 1327 | - $element='commande'; |
|
| 1328 | - } elseif ($this->element=='reception' && $this->origin_id != 0) { |
|
| 1329 | - $id=$this->origin_id; |
|
| 1330 | - $element='order_supplier'; |
|
| 1325 | + if ($this->element == 'shipping' && $this->origin_id != 0) { |
|
| 1326 | + $id = $this->origin_id; |
|
| 1327 | + $element = 'commande'; |
|
| 1328 | + } elseif ($this->element == 'reception' && $this->origin_id != 0) { |
|
| 1329 | + $id = $this->origin_id; |
|
| 1330 | + $element = 'order_supplier'; |
|
| 1331 | 1331 | } else { |
| 1332 | - $id=$this->id; |
|
| 1333 | - $element=$this->element; |
|
| 1332 | + $id = $this->id; |
|
| 1333 | + $element = $this->element; |
|
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 | $sql = "SELECT ec.fk_socpeople"; |
| 1337 | - $sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec,"; |
|
| 1338 | - if ($source == 'internal') $sql.= " ".MAIN_DB_PREFIX."user as c,"; |
|
| 1339 | - if ($source == 'external') $sql.= " ".MAIN_DB_PREFIX."socpeople as c,"; |
|
| 1340 | - $sql.= " ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 1341 | - $sql.= " WHERE ec.element_id = ".$id; |
|
| 1342 | - $sql.= " AND ec.fk_socpeople = c.rowid"; |
|
| 1343 | - if ($source == 'internal') $sql.= " AND c.entity IN (".getEntity('user').")"; |
|
| 1344 | - if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('societe').")"; |
|
| 1345 | - $sql.= " AND ec.fk_c_type_contact = tc.rowid"; |
|
| 1346 | - $sql.= " AND tc.element = '".$element."'"; |
|
| 1347 | - $sql.= " AND tc.source = '".$source."'"; |
|
| 1348 | - if ($code) $sql.= " AND tc.code = '".$code."'"; |
|
| 1349 | - $sql.= " AND tc.active = 1"; |
|
| 1350 | - if ($status) $sql.= " AND ec.statut = ".$status; |
|
| 1337 | + $sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec,"; |
|
| 1338 | + if ($source == 'internal') $sql .= " ".MAIN_DB_PREFIX."user as c,"; |
|
| 1339 | + if ($source == 'external') $sql .= " ".MAIN_DB_PREFIX."socpeople as c,"; |
|
| 1340 | + $sql .= " ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 1341 | + $sql .= " WHERE ec.element_id = ".$id; |
|
| 1342 | + $sql .= " AND ec.fk_socpeople = c.rowid"; |
|
| 1343 | + if ($source == 'internal') $sql .= " AND c.entity IN (".getEntity('user').")"; |
|
| 1344 | + if ($source == 'external') $sql .= " AND c.entity IN (".getEntity('societe').")"; |
|
| 1345 | + $sql .= " AND ec.fk_c_type_contact = tc.rowid"; |
|
| 1346 | + $sql .= " AND tc.element = '".$element."'"; |
|
| 1347 | + $sql .= " AND tc.source = '".$source."'"; |
|
| 1348 | + if ($code) $sql .= " AND tc.code = '".$code."'"; |
|
| 1349 | + $sql .= " AND tc.active = 1"; |
|
| 1350 | + if ($status) $sql .= " AND ec.statut = ".$status; |
|
| 1351 | 1351 | |
| 1352 | 1352 | dol_syslog(get_class($this)."::getIdContact", LOG_DEBUG); |
| 1353 | - $resql=$this->db->query($sql); |
|
| 1353 | + $resql = $this->db->query($sql); |
|
| 1354 | 1354 | if ($resql) |
| 1355 | 1355 | { |
| 1356 | 1356 | while ($obj = $this->db->fetch_object($resql)) |
| 1357 | 1357 | { |
| 1358 | - $result[$i]=$obj->fk_socpeople; |
|
| 1358 | + $result[$i] = $obj->fk_socpeople; |
|
| 1359 | 1359 | $i++; |
| 1360 | 1360 | } |
| 1361 | 1361 | } |
| 1362 | 1362 | else |
| 1363 | 1363 | { |
| 1364 | - $this->error=$this->db->error(); |
|
| 1364 | + $this->error = $this->db->error(); |
|
| 1365 | 1365 | return null; |
| 1366 | 1366 | } |
| 1367 | 1367 | |
@@ -1378,13 +1378,13 @@ discard block |
||
| 1378 | 1378 | public function fetch_contact($contactid = null) |
| 1379 | 1379 | { |
| 1380 | 1380 | // phpcs:enable |
| 1381 | - if (empty($contactid)) $contactid=$this->contactid; |
|
| 1381 | + if (empty($contactid)) $contactid = $this->contactid; |
|
| 1382 | 1382 | |
| 1383 | 1383 | if (empty($contactid)) return 0; |
| 1384 | 1384 | |
| 1385 | 1385 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
| 1386 | 1386 | $contact = new Contact($this->db); |
| 1387 | - $result=$contact->fetch($contactid); |
|
| 1387 | + $result = $contact->fetch($contactid); |
|
| 1388 | 1388 | $this->contact = $contact; |
| 1389 | 1389 | return $result; |
| 1390 | 1390 | } |
@@ -1404,7 +1404,7 @@ discard block |
||
| 1404 | 1404 | if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) |
| 1405 | 1405 | return 0; |
| 1406 | 1406 | |
| 1407 | - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
|
| 1407 | + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
| 1408 | 1408 | |
| 1409 | 1409 | $idtofetch = isset($this->socid) ? $this->socid : (isset($this->fk_soc) ? $this->fk_soc : $this->fk_thirdparty); |
| 1410 | 1410 | if ($force_thirdparty_id) |
@@ -1467,7 +1467,7 @@ discard block |
||
| 1467 | 1467 | |
| 1468 | 1468 | dol_syslog(get_class($this).'::fetch_barcode this->element='.$this->element.' this->barcode_type='.$this->barcode_type); |
| 1469 | 1469 | |
| 1470 | - $idtype=$this->barcode_type; |
|
| 1470 | + $idtype = $this->barcode_type; |
|
| 1471 | 1471 | if (empty($idtype) && $idtype != '0') // If type of barcode no set, we try to guess. If set to '0' it means we forced to have type remain not defined |
| 1472 | 1472 | { |
| 1473 | 1473 | if ($this->element == 'product') $idtype = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
@@ -1480,8 +1480,8 @@ discard block |
||
| 1480 | 1480 | if (empty($this->barcode_type) || empty($this->barcode_type_code) || empty($this->barcode_type_label) || empty($this->barcode_type_coder)) // If data not already loaded |
| 1481 | 1481 | { |
| 1482 | 1482 | $sql = "SELECT rowid, code, libelle as label, coder"; |
| 1483 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; |
|
| 1484 | - $sql.= " WHERE rowid = ".$idtype; |
|
| 1483 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; |
|
| 1484 | + $sql .= " WHERE rowid = ".$idtype; |
|
| 1485 | 1485 | dol_syslog(get_class($this).'::fetch_barcode', LOG_DEBUG); |
| 1486 | 1486 | $resql = $this->db->query($sql); |
| 1487 | 1487 | if ($resql) |
@@ -1514,13 +1514,13 @@ discard block |
||
| 1514 | 1514 | // phpcs:enable |
| 1515 | 1515 | include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 1516 | 1516 | |
| 1517 | - if (empty($this->fk_project) && ! empty($this->fk_projet)) $this->fk_project = $this->fk_projet; // For backward compatibility |
|
| 1517 | + if (empty($this->fk_project) && !empty($this->fk_projet)) $this->fk_project = $this->fk_projet; // For backward compatibility |
|
| 1518 | 1518 | if (empty($this->fk_project)) return 0; |
| 1519 | 1519 | |
| 1520 | 1520 | $project = new Project($this->db); |
| 1521 | 1521 | $result = $project->fetch($this->fk_project); |
| 1522 | 1522 | |
| 1523 | - $this->projet = $project; // deprecated |
|
| 1523 | + $this->projet = $project; // deprecated |
|
| 1524 | 1524 | $this->project = $project; |
| 1525 | 1525 | return $result; |
| 1526 | 1526 | } |
@@ -1556,7 +1556,7 @@ discard block |
||
| 1556 | 1556 | { |
| 1557 | 1557 | // phpcs:enable |
| 1558 | 1558 | $user = new User($this->db); |
| 1559 | - $result=$user->fetch($userid); |
|
| 1559 | + $result = $user->fetch($userid); |
|
| 1560 | 1560 | $this->user = $user; |
| 1561 | 1561 | return $result; |
| 1562 | 1562 | } |
@@ -1594,14 +1594,14 @@ discard block |
||
| 1594 | 1594 | { |
| 1595 | 1595 | global $conf; |
| 1596 | 1596 | |
| 1597 | - $result=false; |
|
| 1597 | + $result = false; |
|
| 1598 | 1598 | |
| 1599 | 1599 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$table; |
| 1600 | - $sql.= " WHERE ".$field." = '".$key."'"; |
|
| 1601 | - if (! empty($element)) { |
|
| 1602 | - $sql.= " AND entity IN (".getEntity($element).")"; |
|
| 1600 | + $sql .= " WHERE ".$field." = '".$key."'"; |
|
| 1601 | + if (!empty($element)) { |
|
| 1602 | + $sql .= " AND entity IN (".getEntity($element).")"; |
|
| 1603 | 1603 | } else { |
| 1604 | - $sql.= " AND entity = ".$conf->entity; |
|
| 1604 | + $sql .= " AND entity = ".$conf->entity; |
|
| 1605 | 1605 | } |
| 1606 | 1606 | |
| 1607 | 1607 | dol_syslog(get_class($this).'::fetchObjectFrom', LOG_DEBUG); |
@@ -1628,10 +1628,10 @@ discard block |
||
| 1628 | 1628 | */ |
| 1629 | 1629 | public function getValueFrom($table, $id, $field) |
| 1630 | 1630 | { |
| 1631 | - $result=false; |
|
| 1631 | + $result = false; |
|
| 1632 | 1632 | if (!empty($id) && !empty($field) && !empty($table)) { |
| 1633 | 1633 | $sql = "SELECT ".$field." FROM ".MAIN_DB_PREFIX.$table; |
| 1634 | - $sql.= " WHERE rowid = ".$id; |
|
| 1634 | + $sql .= " WHERE rowid = ".$id; |
|
| 1635 | 1635 | |
| 1636 | 1636 | dol_syslog(get_class($this).'::getValueFrom', LOG_DEBUG); |
| 1637 | 1637 | $resql = $this->db->query($sql); |
@@ -1662,34 +1662,34 @@ discard block |
||
| 1662 | 1662 | */ |
| 1663 | 1663 | public function setValueFrom($field, $value, $table = '', $id = null, $format = '', $id_field = '', $fuser = null, $trigkey = '', $fk_user_field = 'fk_user_modif') |
| 1664 | 1664 | { |
| 1665 | - global $user,$langs,$conf; |
|
| 1665 | + global $user, $langs, $conf; |
|
| 1666 | 1666 | |
| 1667 | - if (empty($table)) $table=$this->table_element; |
|
| 1668 | - if (empty($id)) $id=$this->id; |
|
| 1669 | - if (empty($format)) $format='text'; |
|
| 1670 | - if (empty($id_field)) $id_field='rowid'; |
|
| 1667 | + if (empty($table)) $table = $this->table_element; |
|
| 1668 | + if (empty($id)) $id = $this->id; |
|
| 1669 | + if (empty($format)) $format = 'text'; |
|
| 1670 | + if (empty($id_field)) $id_field = 'rowid'; |
|
| 1671 | 1671 | |
| 1672 | - $error=0; |
|
| 1672 | + $error = 0; |
|
| 1673 | 1673 | |
| 1674 | 1674 | $this->db->begin(); |
| 1675 | 1675 | |
| 1676 | 1676 | // Special case |
| 1677 | - if ($table == 'product' && $field == 'note_private') $field='note'; |
|
| 1677 | + if ($table == 'product' && $field == 'note_private') $field = 'note'; |
|
| 1678 | 1678 | if (in_array($table, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) $fk_user_field = 'fk_user_mod'; |
| 1679 | 1679 | |
| 1680 | 1680 | $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; |
| 1681 | 1681 | |
| 1682 | - if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; |
|
| 1683 | - elseif ($format == 'int') $sql.= $field." = ".$this->db->escape($value); |
|
| 1684 | - elseif ($format == 'date') $sql.= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); |
|
| 1682 | + if ($format == 'text') $sql .= $field." = '".$this->db->escape($value)."'"; |
|
| 1683 | + elseif ($format == 'int') $sql .= $field." = ".$this->db->escape($value); |
|
| 1684 | + elseif ($format == 'date') $sql .= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); |
|
| 1685 | 1685 | |
| 1686 | 1686 | if ($fk_user_field) |
| 1687 | 1687 | { |
| 1688 | - if (! empty($fuser) && is_object($fuser)) $sql.=", ".$fk_user_field." = ".$fuser->id; |
|
| 1689 | - elseif (empty($fuser) || $fuser != 'none') $sql.=", ".$fk_user_field." = ".$user->id; |
|
| 1688 | + if (!empty($fuser) && is_object($fuser)) $sql .= ", ".$fk_user_field." = ".$fuser->id; |
|
| 1689 | + elseif (empty($fuser) || $fuser != 'none') $sql .= ", ".$fk_user_field." = ".$user->id; |
|
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | - $sql.= " WHERE ".$id_field." = ".$id; |
|
| 1692 | + $sql .= " WHERE ".$id_field." = ".$id; |
|
| 1693 | 1693 | |
| 1694 | 1694 | dol_syslog(get_class($this)."::".__FUNCTION__."", LOG_DEBUG); |
| 1695 | 1695 | $resql = $this->db->query($sql); |
@@ -1706,11 +1706,11 @@ discard block |
||
| 1706 | 1706 | { |
| 1707 | 1707 | $result = $this->fetchCommon($id); |
| 1708 | 1708 | } |
| 1709 | - if ($result >= 0) $result=$this->call_trigger($trigkey, (! empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors |
|
| 1709 | + if ($result >= 0) $result = $this->call_trigger($trigkey, (!empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors |
|
| 1710 | 1710 | if ($result < 0) $error++; |
| 1711 | 1711 | } |
| 1712 | 1712 | |
| 1713 | - if (! $error) |
|
| 1713 | + if (!$error) |
|
| 1714 | 1714 | { |
| 1715 | 1715 | if (property_exists($this, $field)) $this->$field = $value; |
| 1716 | 1716 | $this->db->commit(); |
@@ -1724,7 +1724,7 @@ discard block |
||
| 1724 | 1724 | } |
| 1725 | 1725 | else |
| 1726 | 1726 | { |
| 1727 | - $this->error=$this->db->lasterror(); |
|
| 1727 | + $this->error = $this->db->lasterror(); |
|
| 1728 | 1728 | $this->db->rollback(); |
| 1729 | 1729 | return -1; |
| 1730 | 1730 | } |
@@ -1744,7 +1744,7 @@ discard block |
||
| 1744 | 1744 | // phpcs:enable |
| 1745 | 1745 | global $conf, $user; |
| 1746 | 1746 | |
| 1747 | - if (! $this->table_element) |
|
| 1747 | + if (!$this->table_element) |
|
| 1748 | 1748 | { |
| 1749 | 1749 | dol_print_error('', get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined"); |
| 1750 | 1750 | return -1; |
@@ -1761,45 +1761,45 @@ discard block |
||
| 1761 | 1761 | if ($this->element == 'societe') $alias = 'te'; |
| 1762 | 1762 | |
| 1763 | 1763 | $sql = "SELECT MAX(te.".$fieldid.")"; |
| 1764 | - $sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te"; |
|
| 1765 | - if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
|
| 1766 | - $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; |
|
| 1767 | - } |
|
| 1768 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity |
|
| 1769 | - elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid |
|
| 1770 | - elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid |
|
| 1771 | - if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; |
|
| 1772 | - $sql.= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) |
|
| 1773 | - if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id; |
|
| 1774 | - if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND (sc.fk_user = " .$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1775 | - if (! empty($filter)) |
|
| 1776 | - { |
|
| 1777 | - if (! preg_match('/^\s*AND/i', $filter)) $sql.=" AND "; // For backward compatibility |
|
| 1778 | - $sql.=$filter; |
|
| 1779 | - } |
|
| 1780 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity |
|
| 1781 | - elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid |
|
| 1764 | + $sql .= " FROM ".(empty($nodbprefix) ?MAIN_DB_PREFIX:'').$this->table_element." as te"; |
|
| 1765 | + if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
|
| 1766 | + $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; |
|
| 1767 | + } |
|
| 1768 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity |
|
| 1769 | + elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid |
|
| 1770 | + elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid |
|
| 1771 | + if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; |
|
| 1772 | + $sql .= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) |
|
| 1773 | + if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; |
|
| 1774 | + if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1775 | + if (!empty($filter)) |
|
| 1776 | + { |
|
| 1777 | + if (!preg_match('/^\s*AND/i', $filter)) $sql .= " AND "; // For backward compatibility |
|
| 1778 | + $sql .= $filter; |
|
| 1779 | + } |
|
| 1780 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity |
|
| 1781 | + elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid |
|
| 1782 | 1782 | if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { |
| 1783 | - if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
|
| 1784 | - if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) { |
|
| 1785 | - $sql.= " AND te.entity IS NOT NULL"; // Show all users |
|
| 1783 | + if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
|
| 1784 | + if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) { |
|
| 1785 | + $sql .= " AND te.entity IS NOT NULL"; // Show all users |
|
| 1786 | 1786 | } else { |
| 1787 | - $sql.= " AND ug.fk_user = te.rowid"; |
|
| 1788 | - $sql.= " AND ug.entity IN (".getEntity($this->element).")"; |
|
| 1787 | + $sql .= " AND ug.fk_user = te.rowid"; |
|
| 1788 | + $sql .= " AND ug.entity IN (".getEntity($this->element).")"; |
|
| 1789 | 1789 | } |
| 1790 | 1790 | } else { |
| 1791 | - $sql.= ' AND te.entity IN ('.getEntity($this->element).')'; |
|
| 1791 | + $sql .= ' AND te.entity IN ('.getEntity($this->element).')'; |
|
| 1792 | 1792 | } |
| 1793 | 1793 | } |
| 1794 | - if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql.= ' AND te.fk_soc = ' . $socid; |
|
| 1795 | - if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)'; |
|
| 1796 | - if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql.= ' AND te.rowid = ' . $socid; |
|
| 1794 | + if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql .= ' AND te.fk_soc = '.$socid; |
|
| 1795 | + if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)'; |
|
| 1796 | + if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql .= ' AND te.rowid = '.$socid; |
|
| 1797 | 1797 | //print 'socid='.$socid.' restrictiononfksoc='.$this->restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>"; |
| 1798 | 1798 | |
| 1799 | 1799 | $result = $this->db->query($sql); |
| 1800 | - if (! $result) |
|
| 1800 | + if (!$result) |
|
| 1801 | 1801 | { |
| 1802 | - $this->error=$this->db->lasterror(); |
|
| 1802 | + $this->error = $this->db->lasterror(); |
|
| 1803 | 1803 | return -1; |
| 1804 | 1804 | } |
| 1805 | 1805 | $row = $this->db->fetch_row($result); |
@@ -1807,46 +1807,46 @@ discard block |
||
| 1807 | 1807 | |
| 1808 | 1808 | |
| 1809 | 1809 | $sql = "SELECT MIN(te.".$fieldid.")"; |
| 1810 | - $sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te"; |
|
| 1811 | - if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
|
| 1812 | - $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; |
|
| 1813 | - } |
|
| 1814 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity |
|
| 1815 | - elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid |
|
| 1816 | - elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid |
|
| 1817 | - if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; |
|
| 1818 | - $sql.= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) |
|
| 1819 | - if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id; |
|
| 1820 | - if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND (sc.fk_user = " .$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1821 | - if (! empty($filter)) |
|
| 1822 | - { |
|
| 1823 | - if (! preg_match('/^\s*AND/i', $filter)) $sql.=" AND "; // For backward compatibility |
|
| 1824 | - $sql.=$filter; |
|
| 1825 | - } |
|
| 1826 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity |
|
| 1827 | - elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid |
|
| 1810 | + $sql .= " FROM ".(empty($nodbprefix) ?MAIN_DB_PREFIX:'').$this->table_element." as te"; |
|
| 1811 | + if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
|
| 1812 | + $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; |
|
| 1813 | + } |
|
| 1814 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity |
|
| 1815 | + elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid |
|
| 1816 | + elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid |
|
| 1817 | + if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; |
|
| 1818 | + $sql .= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) |
|
| 1819 | + if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; |
|
| 1820 | + if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1821 | + if (!empty($filter)) |
|
| 1822 | + { |
|
| 1823 | + if (!preg_match('/^\s*AND/i', $filter)) $sql .= " AND "; // For backward compatibility |
|
| 1824 | + $sql .= $filter; |
|
| 1825 | + } |
|
| 1826 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity |
|
| 1827 | + elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid |
|
| 1828 | 1828 | if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { |
| 1829 | - if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
|
| 1830 | - if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) { |
|
| 1831 | - $sql.= " AND te.entity IS NOT NULL"; // Show all users |
|
| 1829 | + if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
|
| 1830 | + if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) { |
|
| 1831 | + $sql .= " AND te.entity IS NOT NULL"; // Show all users |
|
| 1832 | 1832 | } else { |
| 1833 | - $sql.= " AND ug.fk_user = te.rowid"; |
|
| 1834 | - $sql.= " AND ug.entity IN (".getEntity($this->element).")"; |
|
| 1833 | + $sql .= " AND ug.fk_user = te.rowid"; |
|
| 1834 | + $sql .= " AND ug.entity IN (".getEntity($this->element).")"; |
|
| 1835 | 1835 | } |
| 1836 | 1836 | } else { |
| 1837 | - $sql.= ' AND te.entity IN ('.getEntity($this->element).')'; |
|
| 1837 | + $sql .= ' AND te.entity IN ('.getEntity($this->element).')'; |
|
| 1838 | 1838 | } |
| 1839 | 1839 | } |
| 1840 | - if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql.= ' AND te.fk_soc = ' . $socid; |
|
| 1841 | - if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)'; |
|
| 1842 | - if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql.= ' AND te.rowid = ' . $socid; |
|
| 1840 | + if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql .= ' AND te.fk_soc = '.$socid; |
|
| 1841 | + if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)'; |
|
| 1842 | + if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql .= ' AND te.rowid = '.$socid; |
|
| 1843 | 1843 | //print 'socid='.$socid.' restrictiononfksoc='.$this->restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>"; |
| 1844 | 1844 | // Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null |
| 1845 | 1845 | |
| 1846 | 1846 | $result = $this->db->query($sql); |
| 1847 | - if (! $result) |
|
| 1847 | + if (!$result) |
|
| 1848 | 1848 | { |
| 1849 | - $this->error=$this->db->lasterror(); |
|
| 1849 | + $this->error = $this->db->lasterror(); |
|
| 1850 | 1850 | return -2; |
| 1851 | 1851 | } |
| 1852 | 1852 | $row = $this->db->fetch_row($result); |
@@ -1867,7 +1867,7 @@ discard block |
||
| 1867 | 1867 | { |
| 1868 | 1868 | $contactAlreadySelected = array(); |
| 1869 | 1869 | $tab = $this->liste_contact(-1, $source); |
| 1870 | - $num=count($tab); |
|
| 1870 | + $num = count($tab); |
|
| 1871 | 1871 | $i = 0; |
| 1872 | 1872 | while ($i < $num) |
| 1873 | 1873 | { |
@@ -1887,30 +1887,30 @@ discard block |
||
| 1887 | 1887 | */ |
| 1888 | 1888 | public function setProject($projectid) |
| 1889 | 1889 | { |
| 1890 | - if (! $this->table_element) |
|
| 1890 | + if (!$this->table_element) |
|
| 1891 | 1891 | { |
| 1892 | 1892 | dol_syslog(get_class($this)."::setProject was called on objet with property table_element not defined", LOG_ERR); |
| 1893 | 1893 | return -1; |
| 1894 | 1894 | } |
| 1895 | 1895 | |
| 1896 | 1896 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 1897 | - if (! empty($this->fields['fk_project'])) // Common case |
|
| 1897 | + if (!empty($this->fields['fk_project'])) // Common case |
|
| 1898 | 1898 | { |
| 1899 | - if ($projectid) $sql.= ' SET fk_project = '.$projectid; |
|
| 1900 | - else $sql.= ' SET fk_project = NULL'; |
|
| 1901 | - $sql.= ' WHERE rowid = '.$this->id; |
|
| 1899 | + if ($projectid) $sql .= ' SET fk_project = '.$projectid; |
|
| 1900 | + else $sql .= ' SET fk_project = NULL'; |
|
| 1901 | + $sql .= ' WHERE rowid = '.$this->id; |
|
| 1902 | 1902 | } |
| 1903 | 1903 | elseif ($this->table_element == 'actioncomm') // Special case for actioncomm |
| 1904 | 1904 | { |
| 1905 | - if ($projectid) $sql.= ' SET fk_project = '.$projectid; |
|
| 1906 | - else $sql.= ' SET fk_project = NULL'; |
|
| 1907 | - $sql.= ' WHERE id = '.$this->id; |
|
| 1905 | + if ($projectid) $sql .= ' SET fk_project = '.$projectid; |
|
| 1906 | + else $sql .= ' SET fk_project = NULL'; |
|
| 1907 | + $sql .= ' WHERE id = '.$this->id; |
|
| 1908 | 1908 | } |
| 1909 | 1909 | else // Special case for old architecture objects |
| 1910 | 1910 | { |
| 1911 | - if ($projectid) $sql.= ' SET fk_projet = '.$projectid; |
|
| 1912 | - else $sql.= ' SET fk_projet = NULL'; |
|
| 1913 | - $sql.= ' WHERE rowid = '.$this->id; |
|
| 1911 | + if ($projectid) $sql .= ' SET fk_projet = '.$projectid; |
|
| 1912 | + else $sql .= ' SET fk_projet = NULL'; |
|
| 1913 | + $sql .= ' WHERE rowid = '.$this->id; |
|
| 1914 | 1914 | } |
| 1915 | 1915 | |
| 1916 | 1916 | dol_syslog(get_class($this)."::setProject", LOG_DEBUG); |
@@ -1956,14 +1956,14 @@ discard block |
||
| 1956 | 1956 | else |
| 1957 | 1957 | { |
| 1958 | 1958 | dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error()); |
| 1959 | - $this->error=$this->db->error(); |
|
| 1959 | + $this->error = $this->db->error(); |
|
| 1960 | 1960 | return -1; |
| 1961 | 1961 | } |
| 1962 | 1962 | } |
| 1963 | 1963 | else |
| 1964 | 1964 | { |
| 1965 | 1965 | dol_syslog(get_class($this).'::setPaymentMethods, status of the object is incompatible'); |
| 1966 | - $this->error='Status of the object is incompatible '.$this->statut; |
|
| 1966 | + $this->error = 'Status of the object is incompatible '.$this->statut; |
|
| 1967 | 1967 | return -2; |
| 1968 | 1968 | } |
| 1969 | 1969 | } |
@@ -1997,14 +1997,14 @@ discard block |
||
| 1997 | 1997 | else |
| 1998 | 1998 | { |
| 1999 | 1999 | dol_syslog(get_class($this).'::setMulticurrencyCode Erreur '.$sql.' - '.$this->db->error()); |
| 2000 | - $this->error=$this->db->error(); |
|
| 2000 | + $this->error = $this->db->error(); |
|
| 2001 | 2001 | return -1; |
| 2002 | 2002 | } |
| 2003 | 2003 | } |
| 2004 | 2004 | else |
| 2005 | 2005 | { |
| 2006 | 2006 | dol_syslog(get_class($this).'::setMulticurrencyCode, status of the object is incompatible'); |
| 2007 | - $this->error='Status of the object is incompatible '.$this->statut; |
|
| 2007 | + $this->error = 'Status of the object is incompatible '.$this->statut; |
|
| 2008 | 2008 | return -2; |
| 2009 | 2009 | } |
| 2010 | 2010 | } |
@@ -2037,12 +2037,12 @@ discard block |
||
| 2037 | 2037 | foreach ($this->lines as &$line) |
| 2038 | 2038 | { |
| 2039 | 2039 | // Amounts in company currency will be recalculated |
| 2040 | - if($mode == 1) { |
|
| 2040 | + if ($mode == 1) { |
|
| 2041 | 2041 | $line->subprice = 0; |
| 2042 | 2042 | } |
| 2043 | 2043 | |
| 2044 | 2044 | // Amounts in foreign currency will be recalculated |
| 2045 | - if($mode == 2) { |
|
| 2045 | + if ($mode == 2) { |
|
| 2046 | 2046 | $line->multicurrency_subprice = 0; |
| 2047 | 2047 | } |
| 2048 | 2048 | |
@@ -2050,14 +2050,14 @@ discard block |
||
| 2050 | 2050 | case 'propal': |
| 2051 | 2051 | $this->updateline( |
| 2052 | 2052 | $line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, |
| 2053 | - ($line->description?$line->description:$line->desc), 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, |
|
| 2053 | + ($line->description ? $line->description : $line->desc), 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, |
|
| 2054 | 2054 | $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, |
| 2055 | 2055 | $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice |
| 2056 | 2056 | ); |
| 2057 | 2057 | break; |
| 2058 | 2058 | case 'commande': |
| 2059 | 2059 | $this->updateline( |
| 2060 | - $line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->qty, $line->remise_percent, |
|
| 2060 | + $line->id, ($line->description ? $line->description : $line->desc), $line->subprice, $line->qty, $line->remise_percent, |
|
| 2061 | 2061 | $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, |
| 2062 | 2062 | $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, |
| 2063 | 2063 | $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice |
@@ -2065,7 +2065,7 @@ discard block |
||
| 2065 | 2065 | break; |
| 2066 | 2066 | case 'facture': |
| 2067 | 2067 | $this->updateline( |
| 2068 | - $line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->qty, $line->remise_percent, |
|
| 2068 | + $line->id, ($line->description ? $line->description : $line->desc), $line->subprice, $line->qty, $line->remise_percent, |
|
| 2069 | 2069 | $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, |
| 2070 | 2070 | $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, |
| 2071 | 2071 | $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice |
@@ -2074,21 +2074,21 @@ discard block |
||
| 2074 | 2074 | case 'supplier_proposal': |
| 2075 | 2075 | $this->updateline( |
| 2076 | 2076 | $line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, |
| 2077 | - ($line->description?$line->description:$line->desc), 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, |
|
| 2077 | + ($line->description ? $line->description : $line->desc), 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, |
|
| 2078 | 2078 | $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, |
| 2079 | 2079 | $line->ref_fourn, $line->multicurrency_subprice |
| 2080 | 2080 | ); |
| 2081 | 2081 | break; |
| 2082 | 2082 | case 'order_supplier': |
| 2083 | 2083 | $this->updateline( |
| 2084 | - $line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->qty, $line->remise_percent, |
|
| 2084 | + $line->id, ($line->description ? $line->description : $line->desc), $line->subprice, $line->qty, $line->remise_percent, |
|
| 2085 | 2085 | $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, false, |
| 2086 | 2086 | $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice |
| 2087 | 2087 | ); |
| 2088 | 2088 | break; |
| 2089 | 2089 | case 'invoice_supplier': |
| 2090 | 2090 | $this->updateline( |
| 2091 | - $line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->tva_tx, $line->localtax1_tx, |
|
| 2091 | + $line->id, ($line->description ? $line->description : $line->desc), $line->subprice, $line->tva_tx, $line->localtax1_tx, |
|
| 2092 | 2092 | $line->localtax2_tx, $line->qty, 0, 'HT', $line->info_bits, $line->product_type, $line->remise_percent, false, |
| 2093 | 2093 | $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice |
| 2094 | 2094 | ); |
@@ -2105,14 +2105,14 @@ discard block |
||
| 2105 | 2105 | else |
| 2106 | 2106 | { |
| 2107 | 2107 | dol_syslog(get_class($this).'::setMulticurrencyRate Erreur '.$sql.' - '.$this->db->error()); |
| 2108 | - $this->error=$this->db->error(); |
|
| 2108 | + $this->error = $this->db->error(); |
|
| 2109 | 2109 | return -1; |
| 2110 | 2110 | } |
| 2111 | 2111 | } |
| 2112 | 2112 | else |
| 2113 | 2113 | { |
| 2114 | 2114 | dol_syslog(get_class($this).'::setMulticurrencyRate, status of the object is incompatible'); |
| 2115 | - $this->error='Status of the object is incompatible '.$this->statut; |
|
| 2115 | + $this->error = 'Status of the object is incompatible '.$this->statut; |
|
| 2116 | 2116 | return -2; |
| 2117 | 2117 | } |
| 2118 | 2118 | } |
@@ -2142,20 +2142,20 @@ discard block |
||
| 2142 | 2142 | $this->cond_reglement_id = $id; |
| 2143 | 2143 | // for supplier |
| 2144 | 2144 | if (get_class($this) == 'Fournisseur') $this->cond_reglement_supplier_id = $id; |
| 2145 | - $this->cond_reglement = $id; // for compatibility |
|
| 2145 | + $this->cond_reglement = $id; // for compatibility |
|
| 2146 | 2146 | return 1; |
| 2147 | 2147 | } |
| 2148 | 2148 | else |
| 2149 | 2149 | { |
| 2150 | 2150 | dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error()); |
| 2151 | - $this->error=$this->db->error(); |
|
| 2151 | + $this->error = $this->db->error(); |
|
| 2152 | 2152 | return -1; |
| 2153 | 2153 | } |
| 2154 | 2154 | } |
| 2155 | 2155 | else |
| 2156 | 2156 | { |
| 2157 | 2157 | dol_syslog(get_class($this).'::setPaymentTerms, status of the object is incompatible'); |
| 2158 | - $this->error='Status of the object is incompatible '.$this->statut; |
|
| 2158 | + $this->error = 'Status of the object is incompatible '.$this->statut; |
|
| 2159 | 2159 | return -2; |
| 2160 | 2160 | } |
| 2161 | 2161 | } |
@@ -2186,14 +2186,14 @@ discard block |
||
| 2186 | 2186 | else |
| 2187 | 2187 | { |
| 2188 | 2188 | dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms Erreur '.$sql.' - '.$this->db->error()); |
| 2189 | - $this->error=$this->db->error(); |
|
| 2189 | + $this->error = $this->db->error(); |
|
| 2190 | 2190 | return -1; |
| 2191 | 2191 | } |
| 2192 | 2192 | } |
| 2193 | 2193 | else |
| 2194 | 2194 | { |
| 2195 | 2195 | dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms, status of the object is incompatible'); |
| 2196 | - $this->error='Status of the object is incompatible '.$this->statut; |
|
| 2196 | + $this->error = 'Status of the object is incompatible '.$this->statut; |
|
| 2197 | 2197 | return -2; |
| 2198 | 2198 | } |
| 2199 | 2199 | } |
@@ -2211,7 +2211,7 @@ discard block |
||
| 2211 | 2211 | if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address'; |
| 2212 | 2212 | |
| 2213 | 2213 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".$id; |
| 2214 | - $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; |
|
| 2214 | + $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; |
|
| 2215 | 2215 | |
| 2216 | 2216 | if ($this->db->query($sql)) |
| 2217 | 2217 | { |
@@ -2220,7 +2220,7 @@ discard block |
||
| 2220 | 2220 | } |
| 2221 | 2221 | else |
| 2222 | 2222 | { |
| 2223 | - $this->error=$this->db->error(); |
|
| 2223 | + $this->error = $this->db->error(); |
|
| 2224 | 2224 | dol_syslog(get_class($this).'::setDeliveryAddress Erreur '.$sql.' - '.$this->error); |
| 2225 | 2225 | return -1; |
| 2226 | 2226 | } |
@@ -2240,25 +2240,25 @@ discard block |
||
| 2240 | 2240 | { |
| 2241 | 2241 | global $user; |
| 2242 | 2242 | |
| 2243 | - if (empty($userused)) $userused=$user; |
|
| 2243 | + if (empty($userused)) $userused = $user; |
|
| 2244 | 2244 | |
| 2245 | 2245 | $error = 0; |
| 2246 | 2246 | |
| 2247 | - if (! $this->table_element) { |
|
| 2247 | + if (!$this->table_element) { |
|
| 2248 | 2248 | dol_syslog(get_class($this)."::setShippingMethod was called on objet with property table_element not defined", LOG_ERR); |
| 2249 | 2249 | return -1; |
| 2250 | 2250 | } |
| 2251 | 2251 | |
| 2252 | 2252 | $this->db->begin(); |
| 2253 | 2253 | |
| 2254 | - if ($shipping_method_id<0) $shipping_method_id='NULL'; |
|
| 2254 | + if ($shipping_method_id < 0) $shipping_method_id = 'NULL'; |
|
| 2255 | 2255 | dol_syslog(get_class($this).'::setShippingMethod('.$shipping_method_id.')'); |
| 2256 | 2256 | |
| 2257 | 2257 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
| 2258 | - $sql.= " SET fk_shipping_method = ".$shipping_method_id; |
|
| 2259 | - $sql.= " WHERE rowid=".$this->id; |
|
| 2258 | + $sql .= " SET fk_shipping_method = ".$shipping_method_id; |
|
| 2259 | + $sql .= " WHERE rowid=".$this->id; |
|
| 2260 | 2260 | $resql = $this->db->query($sql); |
| 2261 | - if (! $resql) { |
|
| 2261 | + if (!$resql) { |
|
| 2262 | 2262 | dol_syslog(get_class($this).'::setShippingMethod Error ', LOG_DEBUG); |
| 2263 | 2263 | $this->error = $this->db->lasterror(); |
| 2264 | 2264 | $error++; |
@@ -2266,8 +2266,8 @@ discard block |
||
| 2266 | 2266 | if (!$notrigger) |
| 2267 | 2267 | { |
| 2268 | 2268 | // Call trigger |
| 2269 | - $this->context=array('shippingmethodupdate'=>1); |
|
| 2270 | - $result = $this->call_trigger(strtoupper(get_class($this)) . '_MODIFY', $userused); |
|
| 2269 | + $this->context = array('shippingmethodupdate'=>1); |
|
| 2270 | + $result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $userused); |
|
| 2271 | 2271 | if ($result < 0) $error++; |
| 2272 | 2272 | // End call trigger |
| 2273 | 2273 | } |
@@ -2277,7 +2277,7 @@ discard block |
||
| 2277 | 2277 | $this->db->rollback(); |
| 2278 | 2278 | return -1; |
| 2279 | 2279 | } else { |
| 2280 | - $this->shipping_method_id = ($shipping_method_id=='NULL')?null:$shipping_method_id; |
|
| 2280 | + $this->shipping_method_id = ($shipping_method_id == 'NULL') ?null:$shipping_method_id; |
|
| 2281 | 2281 | $this->db->commit(); |
| 2282 | 2282 | return 1; |
| 2283 | 2283 | } |
@@ -2292,23 +2292,23 @@ discard block |
||
| 2292 | 2292 | */ |
| 2293 | 2293 | public function setWarehouse($warehouse_id) |
| 2294 | 2294 | { |
| 2295 | - if (! $this->table_element) { |
|
| 2295 | + if (!$this->table_element) { |
|
| 2296 | 2296 | dol_syslog(get_class($this)."::setWarehouse was called on objet with property table_element not defined", LOG_ERR); |
| 2297 | 2297 | return -1; |
| 2298 | 2298 | } |
| 2299 | - if ($warehouse_id<0) $warehouse_id='NULL'; |
|
| 2299 | + if ($warehouse_id < 0) $warehouse_id = 'NULL'; |
|
| 2300 | 2300 | dol_syslog(get_class($this).'::setWarehouse('.$warehouse_id.')'); |
| 2301 | 2301 | |
| 2302 | 2302 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
| 2303 | - $sql.= " SET fk_warehouse = ".$warehouse_id; |
|
| 2304 | - $sql.= " WHERE rowid=".$this->id; |
|
| 2303 | + $sql .= " SET fk_warehouse = ".$warehouse_id; |
|
| 2304 | + $sql .= " WHERE rowid=".$this->id; |
|
| 2305 | 2305 | |
| 2306 | 2306 | if ($this->db->query($sql)) { |
| 2307 | - $this->warehouse_id = ($warehouse_id=='NULL')?null:$warehouse_id; |
|
| 2307 | + $this->warehouse_id = ($warehouse_id == 'NULL') ?null:$warehouse_id; |
|
| 2308 | 2308 | return 1; |
| 2309 | 2309 | } else { |
| 2310 | 2310 | dol_syslog(get_class($this).'::setWarehouse Error ', LOG_DEBUG); |
| 2311 | - $this->error=$this->db->error(); |
|
| 2311 | + $this->error = $this->db->error(); |
|
| 2312 | 2312 | return 0; |
| 2313 | 2313 | } |
| 2314 | 2314 | } |
@@ -2323,25 +2323,25 @@ discard block |
||
| 2323 | 2323 | */ |
| 2324 | 2324 | public function setDocModel($user, $modelpdf) |
| 2325 | 2325 | { |
| 2326 | - if (! $this->table_element) |
|
| 2326 | + if (!$this->table_element) |
|
| 2327 | 2327 | { |
| 2328 | 2328 | dol_syslog(get_class($this)."::setDocModel was called on objet with property table_element not defined", LOG_ERR); |
| 2329 | 2329 | return -1; |
| 2330 | 2330 | } |
| 2331 | 2331 | |
| 2332 | - $newmodelpdf=dol_trunc($modelpdf, 255); |
|
| 2332 | + $newmodelpdf = dol_trunc($modelpdf, 255); |
|
| 2333 | 2333 | |
| 2334 | 2334 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
| 2335 | - $sql.= " SET model_pdf = '".$this->db->escape($newmodelpdf)."'"; |
|
| 2336 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 2335 | + $sql .= " SET model_pdf = '".$this->db->escape($newmodelpdf)."'"; |
|
| 2336 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 2337 | 2337 | // if ($this->element == 'facture') $sql.= " AND fk_statut < 2"; |
| 2338 | 2338 | // if ($this->element == 'propal') $sql.= " AND fk_statut = 0"; |
| 2339 | 2339 | |
| 2340 | 2340 | dol_syslog(get_class($this)."::setDocModel", LOG_DEBUG); |
| 2341 | - $resql=$this->db->query($sql); |
|
| 2341 | + $resql = $this->db->query($sql); |
|
| 2342 | 2342 | if ($resql) |
| 2343 | 2343 | { |
| 2344 | - $this->modelpdf=$modelpdf; |
|
| 2344 | + $this->modelpdf = $modelpdf; |
|
| 2345 | 2345 | return 1; |
| 2346 | 2346 | } |
| 2347 | 2347 | else |
@@ -2364,25 +2364,25 @@ discard block |
||
| 2364 | 2364 | { |
| 2365 | 2365 | global $user; |
| 2366 | 2366 | |
| 2367 | - if (empty($userused)) $userused=$user; |
|
| 2367 | + if (empty($userused)) $userused = $user; |
|
| 2368 | 2368 | |
| 2369 | 2369 | $error = 0; |
| 2370 | 2370 | |
| 2371 | - if (! $this->table_element) { |
|
| 2371 | + if (!$this->table_element) { |
|
| 2372 | 2372 | dol_syslog(get_class($this)."::setBankAccount was called on objet with property table_element not defined", LOG_ERR); |
| 2373 | 2373 | return -1; |
| 2374 | 2374 | } |
| 2375 | 2375 | $this->db->begin(); |
| 2376 | 2376 | |
| 2377 | - if ($fk_account<0) $fk_account='NULL'; |
|
| 2377 | + if ($fk_account < 0) $fk_account = 'NULL'; |
|
| 2378 | 2378 | dol_syslog(get_class($this).'::setBankAccount('.$fk_account.')'); |
| 2379 | 2379 | |
| 2380 | 2380 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
| 2381 | - $sql.= " SET fk_account = ".$fk_account; |
|
| 2382 | - $sql.= " WHERE rowid=".$this->id; |
|
| 2381 | + $sql .= " SET fk_account = ".$fk_account; |
|
| 2382 | + $sql .= " WHERE rowid=".$this->id; |
|
| 2383 | 2383 | |
| 2384 | 2384 | $resql = $this->db->query($sql); |
| 2385 | - if (! $resql) |
|
| 2385 | + if (!$resql) |
|
| 2386 | 2386 | { |
| 2387 | 2387 | dol_syslog(get_class($this).'::setBankAccount Error '.$sql.' - '.$this->db->error()); |
| 2388 | 2388 | $this->error = $this->db->lasterror(); |
@@ -2393,8 +2393,8 @@ discard block |
||
| 2393 | 2393 | if (!$notrigger) |
| 2394 | 2394 | { |
| 2395 | 2395 | // Call trigger |
| 2396 | - $this->context=array('bankaccountupdate'=>1); |
|
| 2397 | - $result = $this->call_trigger(strtoupper(get_class($this)) . '_MODIFY', $userused); |
|
| 2396 | + $this->context = array('bankaccountupdate'=>1); |
|
| 2397 | + $result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $userused); |
|
| 2398 | 2398 | if ($result < 0) $error++; |
| 2399 | 2399 | // End call trigger |
| 2400 | 2400 | } |
@@ -2406,7 +2406,7 @@ discard block |
||
| 2406 | 2406 | } |
| 2407 | 2407 | else |
| 2408 | 2408 | { |
| 2409 | - $this->fk_account = ($fk_account=='NULL')?null:$fk_account; |
|
| 2409 | + $this->fk_account = ($fk_account == 'NULL') ?null:$fk_account; |
|
| 2410 | 2410 | $this->db->commit(); |
| 2411 | 2411 | return 1; |
| 2412 | 2412 | } |
@@ -2428,23 +2428,23 @@ discard block |
||
| 2428 | 2428 | public function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line = true) |
| 2429 | 2429 | { |
| 2430 | 2430 | // phpcs:enable |
| 2431 | - if (! $this->table_element_line) |
|
| 2431 | + if (!$this->table_element_line) |
|
| 2432 | 2432 | { |
| 2433 | 2433 | dol_syslog(get_class($this)."::line_order was called on objet with property table_element_line not defined", LOG_ERR); |
| 2434 | 2434 | return -1; |
| 2435 | 2435 | } |
| 2436 | - if (! $this->fk_element) |
|
| 2436 | + if (!$this->fk_element) |
|
| 2437 | 2437 | { |
| 2438 | 2438 | dol_syslog(get_class($this)."::line_order was called on objet with property fk_element not defined", LOG_ERR); |
| 2439 | 2439 | return -1; |
| 2440 | 2440 | } |
| 2441 | 2441 | |
| 2442 | 2442 | // Count number of lines to reorder (according to choice $renum) |
| 2443 | - $nl=0; |
|
| 2443 | + $nl = 0; |
|
| 2444 | 2444 | $sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2445 | - $sql.= ' WHERE '.$this->fk_element.'='.$this->id; |
|
| 2446 | - if (! $renum) $sql.= ' AND rang = 0'; |
|
| 2447 | - if ($renum) $sql.= ' AND rang <> 0'; |
|
| 2445 | + $sql .= ' WHERE '.$this->fk_element.'='.$this->id; |
|
| 2446 | + if (!$renum) $sql .= ' AND rang = 0'; |
|
| 2447 | + if ($renum) $sql .= ' AND rang <> 0'; |
|
| 2448 | 2448 | |
| 2449 | 2449 | dol_syslog(get_class($this)."::line_order", LOG_DEBUG); |
| 2450 | 2450 | $resql = $this->db->query($sql); |
@@ -2458,28 +2458,28 @@ discard block |
||
| 2458 | 2458 | { |
| 2459 | 2459 | // The goal of this part is to reorder all lines, with all children lines sharing the same |
| 2460 | 2460 | // counter that parents. |
| 2461 | - $rows=array(); |
|
| 2461 | + $rows = array(); |
|
| 2462 | 2462 | |
| 2463 | 2463 | // We first search all lines that are parent lines (for multilevel details lines) |
| 2464 | 2464 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2465 | - $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2466 | - if ($fk_parent_line) $sql.= ' AND fk_parent_line IS NULL'; |
|
| 2467 | - $sql.= ' ORDER BY rang ASC, rowid '.$rowidorder; |
|
| 2465 | + $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2466 | + if ($fk_parent_line) $sql .= ' AND fk_parent_line IS NULL'; |
|
| 2467 | + $sql .= ' ORDER BY rang ASC, rowid '.$rowidorder; |
|
| 2468 | 2468 | |
| 2469 | 2469 | dol_syslog(get_class($this)."::line_order search all parent lines", LOG_DEBUG); |
| 2470 | 2470 | $resql = $this->db->query($sql); |
| 2471 | 2471 | if ($resql) |
| 2472 | 2472 | { |
| 2473 | - $i=0; |
|
| 2473 | + $i = 0; |
|
| 2474 | 2474 | $num = $this->db->num_rows($resql); |
| 2475 | 2475 | while ($i < $num) |
| 2476 | 2476 | { |
| 2477 | 2477 | $row = $this->db->fetch_row($resql); |
| 2478 | - $rows[] = $row[0]; // Add parent line into array rows |
|
| 2478 | + $rows[] = $row[0]; // Add parent line into array rows |
|
| 2479 | 2479 | $childrens = $this->getChildrenOfLine($row[0]); |
| 2480 | - if (! empty($childrens)) |
|
| 2480 | + if (!empty($childrens)) |
|
| 2481 | 2481 | { |
| 2482 | - foreach($childrens as $child) |
|
| 2482 | + foreach ($childrens as $child) |
|
| 2483 | 2483 | { |
| 2484 | 2484 | array_push($rows, $child); |
| 2485 | 2485 | } |
@@ -2488,11 +2488,11 @@ discard block |
||
| 2488 | 2488 | } |
| 2489 | 2489 | |
| 2490 | 2490 | // Now we set a new number for each lines (parent and children with children included into parent tree) |
| 2491 | - if (! empty($rows)) |
|
| 2491 | + if (!empty($rows)) |
|
| 2492 | 2492 | { |
| 2493 | - foreach($rows as $key => $row) |
|
| 2493 | + foreach ($rows as $key => $row) |
|
| 2494 | 2494 | { |
| 2495 | - $this->updateRangOfLine($row, ($key+1)); |
|
| 2495 | + $this->updateRangOfLine($row, ($key + 1)); |
|
| 2496 | 2496 | } |
| 2497 | 2497 | } |
| 2498 | 2498 | } |
@@ -2512,18 +2512,18 @@ discard block |
||
| 2512 | 2512 | */ |
| 2513 | 2513 | public function getChildrenOfLine($id) |
| 2514 | 2514 | { |
| 2515 | - $rows=array(); |
|
| 2515 | + $rows = array(); |
|
| 2516 | 2516 | |
| 2517 | 2517 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2518 | - $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2519 | - $sql.= ' AND fk_parent_line = '.$id; |
|
| 2520 | - $sql.= ' ORDER BY rang ASC'; |
|
| 2518 | + $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2519 | + $sql .= ' AND fk_parent_line = '.$id; |
|
| 2520 | + $sql .= ' ORDER BY rang ASC'; |
|
| 2521 | 2521 | |
| 2522 | 2522 | dol_syslog(get_class($this)."::getChildrenOfLine search children lines for line ".$id."", LOG_DEBUG); |
| 2523 | 2523 | $resql = $this->db->query($sql); |
| 2524 | 2524 | if ($resql) |
| 2525 | 2525 | { |
| 2526 | - $i=0; |
|
| 2526 | + $i = 0; |
|
| 2527 | 2527 | $num = $this->db->num_rows($resql); |
| 2528 | 2528 | while ($i < $num) |
| 2529 | 2529 | { |
@@ -2588,14 +2588,14 @@ discard block |
||
| 2588 | 2588 | */ |
| 2589 | 2589 | public function updateRangOfLine($rowid, $rang) |
| 2590 | 2590 | { |
| 2591 | - $fieldposition = 'rang'; // @TODO Rename 'rang' into 'position' |
|
| 2591 | + $fieldposition = 'rang'; // @TODO Rename 'rang' into 'position' |
|
| 2592 | 2592 | if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; |
| 2593 | 2593 | |
| 2594 | 2594 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; |
| 2595 | - $sql.= ' WHERE rowid = '.$rowid; |
|
| 2595 | + $sql .= ' WHERE rowid = '.$rowid; |
|
| 2596 | 2596 | |
| 2597 | 2597 | dol_syslog(get_class($this)."::updateRangOfLine", LOG_DEBUG); |
| 2598 | - if (! $this->db->query($sql)) |
|
| 2598 | + if (!$this->db->query($sql)) |
|
| 2599 | 2599 | { |
| 2600 | 2600 | dol_print_error($this->db); |
| 2601 | 2601 | } |
@@ -2612,9 +2612,9 @@ discard block |
||
| 2612 | 2612 | { |
| 2613 | 2613 | // phpcs:enable |
| 2614 | 2614 | $num = count($rows); |
| 2615 | - for ($i = 0 ; $i < $num ; $i++) |
|
| 2615 | + for ($i = 0; $i < $num; $i++) |
|
| 2616 | 2616 | { |
| 2617 | - $this->updateRangOfLine($rows[$i], ($i+1)); |
|
| 2617 | + $this->updateRangOfLine($rows[$i], ($i + 1)); |
|
| 2618 | 2618 | } |
| 2619 | 2619 | } |
| 2620 | 2620 | |
@@ -2632,14 +2632,14 @@ discard block |
||
| 2632 | 2632 | $fieldposition = 'rang'; |
| 2633 | 2633 | if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; |
| 2634 | 2634 | |
| 2635 | - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang ; |
|
| 2636 | - $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2637 | - $sql.= ' AND rang = '.($rang - 1); |
|
| 2638 | - if ($this->db->query($sql) ) |
|
| 2635 | + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; |
|
| 2636 | + $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2637 | + $sql .= ' AND rang = '.($rang - 1); |
|
| 2638 | + if ($this->db->query($sql)) |
|
| 2639 | 2639 | { |
| 2640 | 2640 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang - 1); |
| 2641 | - $sql.= ' WHERE rowid = '.$rowid; |
|
| 2642 | - if (! $this->db->query($sql) ) |
|
| 2641 | + $sql .= ' WHERE rowid = '.$rowid; |
|
| 2642 | + if (!$this->db->query($sql)) |
|
| 2643 | 2643 | { |
| 2644 | 2644 | dol_print_error($this->db); |
| 2645 | 2645 | } |
@@ -2667,13 +2667,13 @@ discard block |
||
| 2667 | 2667 | if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; |
| 2668 | 2668 | |
| 2669 | 2669 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; |
| 2670 | - $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2671 | - $sql.= ' AND rang = '.($rang+1); |
|
| 2672 | - if ($this->db->query($sql) ) |
|
| 2670 | + $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2671 | + $sql .= ' AND rang = '.($rang + 1); |
|
| 2672 | + if ($this->db->query($sql)) |
|
| 2673 | 2673 | { |
| 2674 | - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang+1); |
|
| 2675 | - $sql.= ' WHERE rowid = '.$rowid; |
|
| 2676 | - if (! $this->db->query($sql) ) |
|
| 2674 | + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang + 1); |
|
| 2675 | + $sql .= ' WHERE rowid = '.$rowid; |
|
| 2676 | + if (!$this->db->query($sql)) |
|
| 2677 | 2677 | { |
| 2678 | 2678 | dol_print_error($this->db); |
| 2679 | 2679 | } |
@@ -2694,7 +2694,7 @@ discard block |
||
| 2694 | 2694 | public function getRangOfLine($rowid) |
| 2695 | 2695 | { |
| 2696 | 2696 | $sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2697 | - $sql.= ' WHERE rowid ='.$rowid; |
|
| 2697 | + $sql .= ' WHERE rowid ='.$rowid; |
|
| 2698 | 2698 | |
| 2699 | 2699 | dol_syslog(get_class($this)."::getRangOfLine", LOG_DEBUG); |
| 2700 | 2700 | $resql = $this->db->query($sql); |
@@ -2714,8 +2714,8 @@ discard block |
||
| 2714 | 2714 | public function getIdOfLine($rang) |
| 2715 | 2715 | { |
| 2716 | 2716 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2717 | - $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2718 | - $sql.= ' AND rang = '.$rang; |
|
| 2717 | + $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2718 | + $sql .= ' AND rang = '.$rang; |
|
| 2719 | 2719 | $resql = $this->db->query($sql); |
| 2720 | 2720 | if ($resql) |
| 2721 | 2721 | { |
@@ -2738,15 +2738,15 @@ discard block |
||
| 2738 | 2738 | if ($fk_parent_line) |
| 2739 | 2739 | { |
| 2740 | 2740 | $sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2741 | - $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2742 | - $sql.= ' AND fk_parent_line = '.$fk_parent_line; |
|
| 2741 | + $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2742 | + $sql .= ' AND fk_parent_line = '.$fk_parent_line; |
|
| 2743 | 2743 | |
| 2744 | 2744 | dol_syslog(get_class($this)."::line_max", LOG_DEBUG); |
| 2745 | 2745 | $resql = $this->db->query($sql); |
| 2746 | 2746 | if ($resql) |
| 2747 | 2747 | { |
| 2748 | 2748 | $row = $this->db->fetch_row($resql); |
| 2749 | - if (! empty($row[0])) |
|
| 2749 | + if (!empty($row[0])) |
|
| 2750 | 2750 | { |
| 2751 | 2751 | return $row[0]; |
| 2752 | 2752 | } |
@@ -2760,7 +2760,7 @@ discard block |
||
| 2760 | 2760 | else |
| 2761 | 2761 | { |
| 2762 | 2762 | $sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2763 | - $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2763 | + $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2764 | 2764 | |
| 2765 | 2765 | dol_syslog(get_class($this)."::line_max", LOG_DEBUG); |
| 2766 | 2766 | $resql = $this->db->query($sql); |
@@ -2782,15 +2782,15 @@ discard block |
||
| 2782 | 2782 | public function update_ref_ext($ref_ext) |
| 2783 | 2783 | { |
| 2784 | 2784 | // phpcs:enable |
| 2785 | - if (! $this->table_element) |
|
| 2785 | + if (!$this->table_element) |
|
| 2786 | 2786 | { |
| 2787 | 2787 | dol_syslog(get_class($this)."::update_ref_ext was called on objet with property table_element not defined", LOG_ERR); |
| 2788 | 2788 | return -1; |
| 2789 | 2789 | } |
| 2790 | 2790 | |
| 2791 | 2791 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 2792 | - $sql.= " SET ref_ext = '".$this->db->escape($ref_ext)."'"; |
|
| 2793 | - $sql.= " WHERE ".(isset($this->table_rowid)?$this->table_rowid:'rowid')." = ". $this->id; |
|
| 2792 | + $sql .= " SET ref_ext = '".$this->db->escape($ref_ext)."'"; |
|
| 2793 | + $sql .= " WHERE ".(isset($this->table_rowid) ? $this->table_rowid : 'rowid')." = ".$this->id; |
|
| 2794 | 2794 | |
| 2795 | 2795 | dol_syslog(get_class($this)."::update_ref_ext", LOG_DEBUG); |
| 2796 | 2796 | if ($this->db->query($sql)) |
@@ -2800,7 +2800,7 @@ discard block |
||
| 2800 | 2800 | } |
| 2801 | 2801 | else |
| 2802 | 2802 | { |
| 2803 | - $this->error=$this->db->error(); |
|
| 2803 | + $this->error = $this->db->error(); |
|
| 2804 | 2804 | return -1; |
| 2805 | 2805 | } |
| 2806 | 2806 | } |
@@ -2818,26 +2818,26 @@ discard block |
||
| 2818 | 2818 | // phpcs:enable |
| 2819 | 2819 | global $user; |
| 2820 | 2820 | |
| 2821 | - if (! $this->table_element) |
|
| 2821 | + if (!$this->table_element) |
|
| 2822 | 2822 | { |
| 2823 | - $this->error='update_note was called on objet with property table_element not defined'; |
|
| 2823 | + $this->error = 'update_note was called on objet with property table_element not defined'; |
|
| 2824 | 2824 | dol_syslog(get_class($this)."::update_note was called on objet with property table_element not defined", LOG_ERR); |
| 2825 | 2825 | return -1; |
| 2826 | 2826 | } |
| 2827 | - if (! in_array($suffix, array('','_public','_private'))) |
|
| 2827 | + if (!in_array($suffix, array('', '_public', '_private'))) |
|
| 2828 | 2828 | { |
| 2829 | - $this->error='update_note Parameter suffix must be empty, \'_private\' or \'_public\''; |
|
| 2829 | + $this->error = 'update_note Parameter suffix must be empty, \'_private\' or \'_public\''; |
|
| 2830 | 2830 | dol_syslog(get_class($this)."::update_note Parameter suffix must be empty, '_private' or '_public'", LOG_ERR); |
| 2831 | 2831 | return -2; |
| 2832 | 2832 | } |
| 2833 | 2833 | // Special cas |
| 2834 | 2834 | //var_dump($this->table_element);exit; |
| 2835 | - if ($this->table_element == 'product') $suffix=''; |
|
| 2835 | + if ($this->table_element == 'product') $suffix = ''; |
|
| 2836 | 2836 | |
| 2837 | 2837 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 2838 | - $sql.= " SET note".$suffix." = ".(!empty($note)?("'".$this->db->escape($note)."'"):"NULL"); |
|
| 2839 | - $sql.= " ,".(in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))?"fk_user_mod":"fk_user_modif")." = ".$user->id; |
|
| 2840 | - $sql.= " WHERE rowid =". $this->id; |
|
| 2838 | + $sql .= " SET note".$suffix." = ".(!empty($note) ? ("'".$this->db->escape($note)."'") : "NULL"); |
|
| 2839 | + $sql .= " ,".(in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment')) ? "fk_user_mod" : "fk_user_modif")." = ".$user->id; |
|
| 2840 | + $sql .= " WHERE rowid =".$this->id; |
|
| 2841 | 2841 | |
| 2842 | 2842 | dol_syslog(get_class($this)."::update_note", LOG_DEBUG); |
| 2843 | 2843 | if ($this->db->query($sql)) |
@@ -2846,14 +2846,14 @@ discard block |
||
| 2846 | 2846 | elseif ($suffix == '_private') $this->note_private = $note; |
| 2847 | 2847 | else |
| 2848 | 2848 | { |
| 2849 | - $this->note = $note; // deprecated |
|
| 2849 | + $this->note = $note; // deprecated |
|
| 2850 | 2850 | $this->note_private = $note; |
| 2851 | 2851 | } |
| 2852 | 2852 | return 1; |
| 2853 | 2853 | } |
| 2854 | 2854 | else |
| 2855 | 2855 | { |
| 2856 | - $this->error=$this->db->lasterror(); |
|
| 2856 | + $this->error = $this->db->lasterror(); |
|
| 2857 | 2857 | return -1; |
| 2858 | 2858 | } |
| 2859 | 2859 | } |
@@ -2904,8 +2904,8 @@ discard block |
||
| 2904 | 2904 | elseif ($this->element == 'supplier_proposal') |
| 2905 | 2905 | $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_PROPOSAL"; |
| 2906 | 2906 | |
| 2907 | - if (! empty($MODULE)) { |
|
| 2908 | - if (! empty($conf->global->$MODULE)) { |
|
| 2907 | + if (!empty($MODULE)) { |
|
| 2908 | + if (!empty($conf->global->$MODULE)) { |
|
| 2909 | 2909 | $modsactivated = explode(',', $conf->global->$MODULE); |
| 2910 | 2910 | foreach ($modsactivated as $mod) { |
| 2911 | 2911 | if ($conf->$mod->enabled) |
@@ -2916,44 +2916,44 @@ discard block |
||
| 2916 | 2916 | |
| 2917 | 2917 | include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; |
| 2918 | 2918 | |
| 2919 | - if ($roundingadjust == '-1') $roundingadjust='auto'; // For backward compatibility |
|
| 2919 | + if ($roundingadjust == '-1') $roundingadjust = 'auto'; // For backward compatibility |
|
| 2920 | 2920 | |
| 2921 | - $forcedroundingmode=$roundingadjust; |
|
| 2922 | - if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) $forcedroundingmode=$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND; |
|
| 2923 | - elseif ($forcedroundingmode == 'auto') $forcedroundingmode='0'; |
|
| 2921 | + $forcedroundingmode = $roundingadjust; |
|
| 2922 | + if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) $forcedroundingmode = $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND; |
|
| 2923 | + elseif ($forcedroundingmode == 'auto') $forcedroundingmode = '0'; |
|
| 2924 | 2924 | |
| 2925 | - $error=0; |
|
| 2925 | + $error = 0; |
|
| 2926 | 2926 | |
| 2927 | 2927 | $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1; |
| 2928 | 2928 | |
| 2929 | 2929 | // Define constants to find lines to sum |
| 2930 | - $fieldtva='total_tva'; |
|
| 2931 | - $fieldlocaltax1='total_localtax1'; |
|
| 2932 | - $fieldlocaltax2='total_localtax2'; |
|
| 2933 | - $fieldup='subprice'; |
|
| 2930 | + $fieldtva = 'total_tva'; |
|
| 2931 | + $fieldlocaltax1 = 'total_localtax1'; |
|
| 2932 | + $fieldlocaltax2 = 'total_localtax2'; |
|
| 2933 | + $fieldup = 'subprice'; |
|
| 2934 | 2934 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
| 2935 | 2935 | { |
| 2936 | - $fieldtva='tva'; |
|
| 2937 | - $fieldup='pu_ht'; |
|
| 2936 | + $fieldtva = 'tva'; |
|
| 2937 | + $fieldup = 'pu_ht'; |
|
| 2938 | 2938 | } |
| 2939 | 2939 | if ($this->element == 'expensereport') |
| 2940 | 2940 | { |
| 2941 | - $fieldup='value_unit'; |
|
| 2941 | + $fieldup = 'value_unit'; |
|
| 2942 | 2942 | } |
| 2943 | 2943 | |
| 2944 | 2944 | $sql = 'SELECT rowid, qty, '.$fieldup.' as up, remise_percent, total_ht, '.$fieldtva.' as total_tva, total_ttc, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2,'; |
| 2945 | - $sql.= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type'; |
|
| 2946 | - if ($this->table_element_line == 'facturedet') $sql.= ', situation_percent'; |
|
| 2947 | - $sql.= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; |
|
| 2948 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
|
| 2949 | - $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2945 | + $sql .= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type'; |
|
| 2946 | + if ($this->table_element_line == 'facturedet') $sql .= ', situation_percent'; |
|
| 2947 | + $sql .= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; |
|
| 2948 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
|
| 2949 | + $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; |
|
| 2950 | 2950 | if ($exclspec) |
| 2951 | 2951 | { |
| 2952 | - $product_field='product_type'; |
|
| 2953 | - if ($this->table_element_line == 'contratdet') $product_field=''; // contratdet table has no product_type field |
|
| 2954 | - if ($product_field) $sql.= ' AND '.$product_field.' <> 9'; |
|
| 2952 | + $product_field = 'product_type'; |
|
| 2953 | + if ($this->table_element_line == 'contratdet') $product_field = ''; // contratdet table has no product_type field |
|
| 2954 | + if ($product_field) $sql .= ' AND '.$product_field.' <> 9'; |
|
| 2955 | 2955 | } |
| 2956 | - $sql.= ' ORDER by rowid'; // We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used |
|
| 2956 | + $sql .= ' ORDER by rowid'; // We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used |
|
| 2957 | 2957 | |
| 2958 | 2958 | dol_syslog(get_class($this)."::update_price", LOG_DEBUG); |
| 2959 | 2959 | $resql = $this->db->query($sql); |
@@ -2967,7 +2967,7 @@ discard block |
||
| 2967 | 2967 | $total_ht_by_vats = array(); |
| 2968 | 2968 | $total_tva_by_vats = array(); |
| 2969 | 2969 | $total_ttc_by_vats = array(); |
| 2970 | - $this->multicurrency_total_ht = 0; |
|
| 2970 | + $this->multicurrency_total_ht = 0; |
|
| 2971 | 2971 | $this->multicurrency_total_tva = 0; |
| 2972 | 2972 | $this->multicurrency_total_ttc = 0; |
| 2973 | 2973 | |
@@ -2978,54 +2978,54 @@ discard block |
||
| 2978 | 2978 | $obj = $this->db->fetch_object($resql); |
| 2979 | 2979 | |
| 2980 | 2980 | // Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none' |
| 2981 | - $parameters=array('fk_element' => $obj->rowid); |
|
| 2981 | + $parameters = array('fk_element' => $obj->rowid); |
|
| 2982 | 2982 | $reshook = $hookmanager->executeHooks('changeRoundingMode', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
| 2983 | 2983 | |
| 2984 | 2984 | if (empty($reshook) && $forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' |
| 2985 | 2985 | { |
| 2986 | - $localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx); |
|
| 2987 | - $tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx); |
|
| 2988 | - $diff=price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); |
|
| 2986 | + $localtax_array = array($obj->localtax1_type, $obj->localtax1_tx, $obj->localtax2_type, $obj->localtax2_tx); |
|
| 2987 | + $tmpcal = calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx); |
|
| 2988 | + $diff = price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); |
|
| 2989 | 2989 | if ($diff) |
| 2990 | 2990 | { |
| 2991 | - $sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid; |
|
| 2991 | + $sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid; |
|
| 2992 | 2992 | dol_syslog('We found unconsistent data into detailed line (difference of '.$diff.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); |
| 2993 | - $resqlfix=$this->db->query($sqlfix); |
|
| 2994 | - if (! $resqlfix) dol_print_error($this->db, 'Failed to update line'); |
|
| 2993 | + $resqlfix = $this->db->query($sqlfix); |
|
| 2994 | + if (!$resqlfix) dol_print_error($this->db, 'Failed to update line'); |
|
| 2995 | 2995 | $obj->total_tva = $tmpcal[1]; |
| 2996 | 2996 | $obj->total_ttc = $tmpcal[2]; |
| 2997 | 2997 | // |
| 2998 | 2998 | } |
| 2999 | 2999 | } |
| 3000 | 3000 | |
| 3001 | - $this->total_ht += $obj->total_ht; // The field visible at end of line detail |
|
| 3001 | + $this->total_ht += $obj->total_ht; // The field visible at end of line detail |
|
| 3002 | 3002 | $this->total_tva += $obj->total_tva; |
| 3003 | 3003 | $this->total_localtax1 += $obj->total_localtax1; |
| 3004 | 3004 | $this->total_localtax2 += $obj->total_localtax2; |
| 3005 | 3005 | $this->total_ttc += $obj->total_ttc; |
| 3006 | - $this->multicurrency_total_ht += $obj->multicurrency_total_ht; // The field visible at end of line detail |
|
| 3006 | + $this->multicurrency_total_ht += $obj->multicurrency_total_ht; // The field visible at end of line detail |
|
| 3007 | 3007 | $this->multicurrency_total_tva += $obj->multicurrency_total_tva; |
| 3008 | 3008 | $this->multicurrency_total_ttc += $obj->multicurrency_total_ttc; |
| 3009 | 3009 | |
| 3010 | - if (! isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate]=0; |
|
| 3011 | - if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0; |
|
| 3012 | - if (! isset($total_ttc_by_vats[$obj->vatrate])) $total_ttc_by_vats[$obj->vatrate]=0; |
|
| 3010 | + if (!isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate] = 0; |
|
| 3011 | + if (!isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate] = 0; |
|
| 3012 | + if (!isset($total_ttc_by_vats[$obj->vatrate])) $total_ttc_by_vats[$obj->vatrate] = 0; |
|
| 3013 | 3013 | $total_ht_by_vats[$obj->vatrate] += $obj->total_ht; |
| 3014 | 3014 | $total_tva_by_vats[$obj->vatrate] += $obj->total_tva; |
| 3015 | 3015 | $total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc; |
| 3016 | 3016 | |
| 3017 | 3017 | if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency |
| 3018 | 3018 | { |
| 3019 | - $tmpvat=price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); |
|
| 3020 | - $diff=price2num($total_tva_by_vats[$obj->vatrate]-$tmpvat, 'MT', 1); |
|
| 3019 | + $tmpvat = price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); |
|
| 3020 | + $diff = price2num($total_tva_by_vats[$obj->vatrate] - $tmpvat, 'MT', 1); |
|
| 3021 | 3021 | //print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")."<br>\n"; |
| 3022 | 3022 | if ($diff) |
| 3023 | 3023 | { |
| 3024 | 3024 | if (abs($diff) > 0.1) { dol_syslog('A rounding difference was detected into TOTAL but is too high to be corrected', LOG_WARNING); exit; } |
| 3025 | - $sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".($obj->total_tva - $diff).", total_ttc = ".($obj->total_ttc - $diff)." WHERE rowid = ".$obj->rowid; |
|
| 3025 | + $sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".($obj->total_tva - $diff).", total_ttc = ".($obj->total_ttc - $diff)." WHERE rowid = ".$obj->rowid; |
|
| 3026 | 3026 | dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); |
| 3027 | - $resqlfix=$this->db->query($sqlfix); |
|
| 3028 | - if (! $resqlfix) dol_print_error($this->db, 'Failed to update line'); |
|
| 3027 | + $resqlfix = $this->db->query($sqlfix); |
|
| 3028 | + if (!$resqlfix) dol_print_error($this->db, 'Failed to update line'); |
|
| 3029 | 3029 | $this->total_tva -= $diff; |
| 3030 | 3030 | $this->total_ttc -= $diff; |
| 3031 | 3031 | $total_tva_by_vats[$obj->vatrate] -= $diff; |
@@ -3037,11 +3037,11 @@ discard block |
||
| 3037 | 3037 | } |
| 3038 | 3038 | |
| 3039 | 3039 | // Add revenue stamp to total |
| 3040 | - $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0; |
|
| 3041 | - $this->multicurrency_total_ttc += isset($this->revenuestamp)?($this->revenuestamp * $multicurrency_tx):0; |
|
| 3040 | + $this->total_ttc += isset($this->revenuestamp) ? $this->revenuestamp : 0; |
|
| 3041 | + $this->multicurrency_total_ttc += isset($this->revenuestamp) ? ($this->revenuestamp * $multicurrency_tx) : 0; |
|
| 3042 | 3042 | |
| 3043 | 3043 | // Situations totals |
| 3044 | - if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits') && $this->type != $this::TYPE_CREDIT_NOTE ) |
|
| 3044 | + if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits') && $this->type != $this::TYPE_CREDIT_NOTE) |
|
| 3045 | 3045 | { |
| 3046 | 3046 | $prev_sits = $this->get_prev_sits(); |
| 3047 | 3047 | |
@@ -3060,17 +3060,17 @@ discard block |
||
| 3060 | 3060 | $this->db->free($resql); |
| 3061 | 3061 | |
| 3062 | 3062 | // Now update global field total_ht, total_ttc and tva |
| 3063 | - $fieldht='total_ht'; |
|
| 3064 | - $fieldtva='tva'; |
|
| 3065 | - $fieldlocaltax1='localtax1'; |
|
| 3066 | - $fieldlocaltax2='localtax2'; |
|
| 3067 | - $fieldttc='total_ttc'; |
|
| 3063 | + $fieldht = 'total_ht'; |
|
| 3064 | + $fieldtva = 'tva'; |
|
| 3065 | + $fieldlocaltax1 = 'localtax1'; |
|
| 3066 | + $fieldlocaltax2 = 'localtax2'; |
|
| 3067 | + $fieldttc = 'total_ttc'; |
|
| 3068 | 3068 | // Specific code for backward compatibility with old field names |
| 3069 | - if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht='total'; |
|
| 3070 | - if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva'; |
|
| 3071 | - if ($this->element == 'propal') $fieldttc='total'; |
|
| 3072 | - if ($this->element == 'expensereport') $fieldtva='total_tva'; |
|
| 3073 | - if ($this->element == 'supplier_proposal') $fieldttc='total'; |
|
| 3069 | + if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht = 'total'; |
|
| 3070 | + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva = 'total_tva'; |
|
| 3071 | + if ($this->element == 'propal') $fieldttc = 'total'; |
|
| 3072 | + if ($this->element == 'expensereport') $fieldtva = 'total_tva'; |
|
| 3073 | + if ($this->element == 'supplier_proposal') $fieldttc = 'total'; |
|
| 3074 | 3074 | |
| 3075 | 3075 | if (empty($nodatabaseupdate)) |
| 3076 | 3076 | { |
@@ -3087,16 +3087,16 @@ discard block |
||
| 3087 | 3087 | |
| 3088 | 3088 | |
| 3089 | 3089 | dol_syslog(get_class($this)."::update_price", LOG_DEBUG); |
| 3090 | - $resql=$this->db->query($sql); |
|
| 3091 | - if (! $resql) |
|
| 3090 | + $resql = $this->db->query($sql); |
|
| 3091 | + if (!$resql) |
|
| 3092 | 3092 | { |
| 3093 | 3093 | $error++; |
| 3094 | - $this->error=$this->db->lasterror(); |
|
| 3095 | - $this->errors[]=$this->db->lasterror(); |
|
| 3094 | + $this->error = $this->db->lasterror(); |
|
| 3095 | + $this->errors[] = $this->db->lasterror(); |
|
| 3096 | 3096 | } |
| 3097 | 3097 | } |
| 3098 | 3098 | |
| 3099 | - if (! $error) |
|
| 3099 | + if (!$error) |
|
| 3100 | 3100 | { |
| 3101 | 3101 | return 1; |
| 3102 | 3102 | } |
@@ -3124,27 +3124,27 @@ discard block |
||
| 3124 | 3124 | public function add_object_linked($origin = null, $origin_id = null) |
| 3125 | 3125 | { |
| 3126 | 3126 | // phpcs:enable |
| 3127 | - $origin = (! empty($origin) ? $origin : $this->origin); |
|
| 3128 | - $origin_id = (! empty($origin_id) ? $origin_id : $this->origin_id); |
|
| 3127 | + $origin = (!empty($origin) ? $origin : $this->origin); |
|
| 3128 | + $origin_id = (!empty($origin_id) ? $origin_id : $this->origin_id); |
|
| 3129 | 3129 | |
| 3130 | 3130 | // Special case |
| 3131 | - if ($origin == 'order') $origin='commande'; |
|
| 3132 | - if ($origin == 'invoice') $origin='facture'; |
|
| 3133 | - if ($origin == 'invoice_template') $origin='facturerec'; |
|
| 3134 | - if ($origin == 'supplierorder') $origin='order_supplier'; |
|
| 3131 | + if ($origin == 'order') $origin = 'commande'; |
|
| 3132 | + if ($origin == 'invoice') $origin = 'facture'; |
|
| 3133 | + if ($origin == 'invoice_template') $origin = 'facturerec'; |
|
| 3134 | + if ($origin == 'supplierorder') $origin = 'order_supplier'; |
|
| 3135 | 3135 | $this->db->begin(); |
| 3136 | 3136 | |
| 3137 | 3137 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; |
| 3138 | - $sql.= "fk_source"; |
|
| 3139 | - $sql.= ", sourcetype"; |
|
| 3140 | - $sql.= ", fk_target"; |
|
| 3141 | - $sql.= ", targettype"; |
|
| 3142 | - $sql.= ") VALUES ("; |
|
| 3143 | - $sql.= $origin_id; |
|
| 3144 | - $sql.= ", '".$this->db->escape($origin)."'"; |
|
| 3145 | - $sql.= ", ".$this->id; |
|
| 3146 | - $sql.= ", '".$this->db->escape($this->element)."'"; |
|
| 3147 | - $sql.= ")"; |
|
| 3138 | + $sql .= "fk_source"; |
|
| 3139 | + $sql .= ", sourcetype"; |
|
| 3140 | + $sql .= ", fk_target"; |
|
| 3141 | + $sql .= ", targettype"; |
|
| 3142 | + $sql .= ") VALUES ("; |
|
| 3143 | + $sql .= $origin_id; |
|
| 3144 | + $sql .= ", '".$this->db->escape($origin)."'"; |
|
| 3145 | + $sql .= ", ".$this->id; |
|
| 3146 | + $sql .= ", '".$this->db->escape($this->element)."'"; |
|
| 3147 | + $sql .= ")"; |
|
| 3148 | 3148 | |
| 3149 | 3149 | dol_syslog(get_class($this)."::add_object_linked", LOG_DEBUG); |
| 3150 | 3150 | if ($this->db->query($sql)) |
@@ -3154,7 +3154,7 @@ discard block |
||
| 3154 | 3154 | } |
| 3155 | 3155 | else |
| 3156 | 3156 | { |
| 3157 | - $this->error=$this->db->lasterror(); |
|
| 3157 | + $this->error = $this->db->lasterror(); |
|
| 3158 | 3158 | $this->db->rollback(); |
| 3159 | 3159 | return 0; |
| 3160 | 3160 | } |
@@ -3186,29 +3186,29 @@ discard block |
||
| 3186 | 3186 | { |
| 3187 | 3187 | global $conf; |
| 3188 | 3188 | |
| 3189 | - $this->linkedObjectsIds=array(); |
|
| 3190 | - $this->linkedObjects=array(); |
|
| 3189 | + $this->linkedObjectsIds = array(); |
|
| 3190 | + $this->linkedObjects = array(); |
|
| 3191 | 3191 | |
| 3192 | - $justsource=false; |
|
| 3193 | - $justtarget=false; |
|
| 3194 | - $withtargettype=false; |
|
| 3195 | - $withsourcetype=false; |
|
| 3192 | + $justsource = false; |
|
| 3193 | + $justtarget = false; |
|
| 3194 | + $withtargettype = false; |
|
| 3195 | + $withsourcetype = false; |
|
| 3196 | 3196 | |
| 3197 | - if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid)) |
|
| 3197 | + if (!empty($sourceid) && !empty($sourcetype) && empty($targetid)) |
|
| 3198 | 3198 | { |
| 3199 | - $justsource=true; // the source (id and type) is a search criteria |
|
| 3200 | - if (! empty($targettype)) $withtargettype=true; |
|
| 3199 | + $justsource = true; // the source (id and type) is a search criteria |
|
| 3200 | + if (!empty($targettype)) $withtargettype = true; |
|
| 3201 | 3201 | } |
| 3202 | - if (! empty($targetid) && ! empty($targettype) && empty($sourceid)) |
|
| 3202 | + if (!empty($targetid) && !empty($targettype) && empty($sourceid)) |
|
| 3203 | 3203 | { |
| 3204 | - $justtarget=true; // the target (id and type) is a search criteria |
|
| 3205 | - if (! empty($sourcetype)) $withsourcetype=true; |
|
| 3204 | + $justtarget = true; // the target (id and type) is a search criteria |
|
| 3205 | + if (!empty($sourcetype)) $withsourcetype = true; |
|
| 3206 | 3206 | } |
| 3207 | 3207 | |
| 3208 | - $sourceid = (! empty($sourceid) ? $sourceid : $this->id); |
|
| 3209 | - $targetid = (! empty($targetid) ? $targetid : $this->id); |
|
| 3210 | - $sourcetype = (! empty($sourcetype) ? $sourcetype : $this->element); |
|
| 3211 | - $targettype = (! empty($targettype) ? $targettype : $this->element); |
|
| 3208 | + $sourceid = (!empty($sourceid) ? $sourceid : $this->id); |
|
| 3209 | + $targetid = (!empty($targetid) ? $targetid : $this->id); |
|
| 3210 | + $sourcetype = (!empty($sourcetype) ? $sourcetype : $this->element); |
|
| 3211 | + $targettype = (!empty($targettype) ? $targettype : $this->element); |
|
| 3212 | 3212 | |
| 3213 | 3213 | /*if (empty($sourceid) && empty($targetid)) |
| 3214 | 3214 | { |
@@ -3218,25 +3218,25 @@ discard block |
||
| 3218 | 3218 | |
| 3219 | 3219 | // Links between objects are stored in table element_element |
| 3220 | 3220 | $sql = 'SELECT rowid, fk_source, sourcetype, fk_target, targettype'; |
| 3221 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'element_element'; |
|
| 3222 | - $sql.= " WHERE "; |
|
| 3221 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'element_element'; |
|
| 3222 | + $sql .= " WHERE "; |
|
| 3223 | 3223 | if ($justsource || $justtarget) |
| 3224 | 3224 | { |
| 3225 | 3225 | if ($justsource) |
| 3226 | 3226 | { |
| 3227 | - $sql.= "fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."'"; |
|
| 3228 | - if ($withtargettype) $sql.= " AND targettype = '".$targettype."'"; |
|
| 3227 | + $sql .= "fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."'"; |
|
| 3228 | + if ($withtargettype) $sql .= " AND targettype = '".$targettype."'"; |
|
| 3229 | 3229 | } |
| 3230 | 3230 | elseif ($justtarget) |
| 3231 | 3231 | { |
| 3232 | - $sql.= "fk_target = ".$targetid." AND targettype = '".$targettype."'"; |
|
| 3233 | - if ($withsourcetype) $sql.= " AND sourcetype = '".$sourcetype."'"; |
|
| 3232 | + $sql .= "fk_target = ".$targetid." AND targettype = '".$targettype."'"; |
|
| 3233 | + if ($withsourcetype) $sql .= " AND sourcetype = '".$sourcetype."'"; |
|
| 3234 | 3234 | } |
| 3235 | 3235 | } |
| 3236 | 3236 | else |
| 3237 | 3237 | { |
| 3238 | - $sql.= "(fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."')"; |
|
| 3239 | - $sql.= " ".$clause." (fk_target = ".$targetid." AND targettype = '".$targettype."')"; |
|
| 3238 | + $sql .= "(fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."')"; |
|
| 3239 | + $sql .= " ".$clause." (fk_target = ".$targetid." AND targettype = '".$targettype."')"; |
|
| 3240 | 3240 | } |
| 3241 | 3241 | $sql .= ' ORDER BY '.$orderby; |
| 3242 | 3242 | |
@@ -3253,31 +3253,31 @@ discard block |
||
| 3253 | 3253 | { |
| 3254 | 3254 | if ($justsource) |
| 3255 | 3255 | { |
| 3256 | - $this->linkedObjectsIds[$obj->targettype][$obj->rowid]=$obj->fk_target; |
|
| 3256 | + $this->linkedObjectsIds[$obj->targettype][$obj->rowid] = $obj->fk_target; |
|
| 3257 | 3257 | } |
| 3258 | 3258 | elseif ($justtarget) |
| 3259 | 3259 | { |
| 3260 | - $this->linkedObjectsIds[$obj->sourcetype][$obj->rowid]=$obj->fk_source; |
|
| 3260 | + $this->linkedObjectsIds[$obj->sourcetype][$obj->rowid] = $obj->fk_source; |
|
| 3261 | 3261 | } |
| 3262 | 3262 | } |
| 3263 | 3263 | else |
| 3264 | 3264 | { |
| 3265 | 3265 | if ($obj->fk_source == $sourceid && $obj->sourcetype == $sourcetype) |
| 3266 | 3266 | { |
| 3267 | - $this->linkedObjectsIds[$obj->targettype][$obj->rowid]=$obj->fk_target; |
|
| 3267 | + $this->linkedObjectsIds[$obj->targettype][$obj->rowid] = $obj->fk_target; |
|
| 3268 | 3268 | } |
| 3269 | 3269 | if ($obj->fk_target == $targetid && $obj->targettype == $targettype) |
| 3270 | 3270 | { |
| 3271 | - $this->linkedObjectsIds[$obj->sourcetype][$obj->rowid]=$obj->fk_source; |
|
| 3271 | + $this->linkedObjectsIds[$obj->sourcetype][$obj->rowid] = $obj->fk_source; |
|
| 3272 | 3272 | } |
| 3273 | 3273 | } |
| 3274 | 3274 | $i++; |
| 3275 | 3275 | } |
| 3276 | 3276 | |
| 3277 | - if (! empty($this->linkedObjectsIds)) |
|
| 3277 | + if (!empty($this->linkedObjectsIds)) |
|
| 3278 | 3278 | { |
| 3279 | 3279 | $tmparray = $this->linkedObjectsIds; |
| 3280 | - foreach($tmparray as $objecttype => $objectids) // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...) |
|
| 3280 | + foreach ($tmparray as $objecttype => $objectids) // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...) |
|
| 3281 | 3281 | { |
| 3282 | 3282 | // Parse element/subelement (ex: project_task, cabinetmed_consultation, ...) |
| 3283 | 3283 | $module = $element = $subelement = $objecttype; |
@@ -3290,31 +3290,31 @@ discard block |
||
| 3290 | 3290 | |
| 3291 | 3291 | $classpath = $element.'/class'; |
| 3292 | 3292 | // To work with non standard classpath or module name |
| 3293 | - if ($objecttype == 'facture') { |
|
| 3293 | + if ($objecttype == 'facture') { |
|
| 3294 | 3294 | $classpath = 'compta/facture/class'; |
| 3295 | 3295 | } |
| 3296 | - elseif ($objecttype == 'facturerec') { |
|
| 3296 | + elseif ($objecttype == 'facturerec') { |
|
| 3297 | 3297 | $classpath = 'compta/facture/class'; $module = 'facture'; |
| 3298 | 3298 | } |
| 3299 | - elseif ($objecttype == 'propal') { |
|
| 3299 | + elseif ($objecttype == 'propal') { |
|
| 3300 | 3300 | $classpath = 'comm/propal/class'; |
| 3301 | 3301 | } |
| 3302 | - elseif ($objecttype == 'supplier_proposal') { |
|
| 3302 | + elseif ($objecttype == 'supplier_proposal') { |
|
| 3303 | 3303 | $classpath = 'supplier_proposal/class'; |
| 3304 | 3304 | } |
| 3305 | - elseif ($objecttype == 'shipping') { |
|
| 3305 | + elseif ($objecttype == 'shipping') { |
|
| 3306 | 3306 | $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; |
| 3307 | 3307 | } |
| 3308 | - elseif ($objecttype == 'delivery') { |
|
| 3308 | + elseif ($objecttype == 'delivery') { |
|
| 3309 | 3309 | $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; |
| 3310 | 3310 | } |
| 3311 | - elseif ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier') { |
|
| 3311 | + elseif ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier') { |
|
| 3312 | 3312 | $classpath = 'fourn/class'; $module = 'fournisseur'; |
| 3313 | 3313 | } |
| 3314 | - elseif ($objecttype == 'fichinter') { |
|
| 3314 | + elseif ($objecttype == 'fichinter') { |
|
| 3315 | 3315 | $classpath = 'fichinter/class'; $subelement = 'fichinter'; $module = 'ficheinter'; |
| 3316 | 3316 | } |
| 3317 | - elseif ($objecttype == 'subscription') { |
|
| 3317 | + elseif ($objecttype == 'subscription') { |
|
| 3318 | 3318 | $classpath = 'adherents/class'; $module = 'adherent'; |
| 3319 | 3319 | } |
| 3320 | 3320 | |
@@ -3327,16 +3327,16 @@ discard block |
||
| 3327 | 3327 | elseif ($objecttype == 'invoice_supplier') { |
| 3328 | 3328 | $classfile = 'fournisseur.facture'; $classname = 'FactureFournisseur'; |
| 3329 | 3329 | } |
| 3330 | - elseif ($objecttype == 'order_supplier') { |
|
| 3330 | + elseif ($objecttype == 'order_supplier') { |
|
| 3331 | 3331 | $classfile = 'fournisseur.commande'; $classname = 'CommandeFournisseur'; |
| 3332 | 3332 | } |
| 3333 | - elseif ($objecttype == 'supplier_proposal') { |
|
| 3333 | + elseif ($objecttype == 'supplier_proposal') { |
|
| 3334 | 3334 | $classfile = 'supplier_proposal'; $classname = 'SupplierProposal'; |
| 3335 | 3335 | } |
| 3336 | - elseif ($objecttype == 'facturerec') { |
|
| 3336 | + elseif ($objecttype == 'facturerec') { |
|
| 3337 | 3337 | $classfile = 'facture-rec'; $classname = 'FactureRec'; |
| 3338 | 3338 | } |
| 3339 | - elseif ($objecttype == 'subscription') { |
|
| 3339 | + elseif ($objecttype == 'subscription') { |
|
| 3340 | 3340 | $classfile = 'subscription'; $classname = 'Subscription'; |
| 3341 | 3341 | } |
| 3342 | 3342 | |
@@ -3349,7 +3349,7 @@ discard block |
||
| 3349 | 3349 | //print '/'.$classpath.'/'.$classfile.'.class.php '.class_exists($classname); |
| 3350 | 3350 | if (class_exists($classname)) |
| 3351 | 3351 | { |
| 3352 | - foreach($objectids as $i => $objectid) // $i is rowid into llx_element_element |
|
| 3352 | + foreach ($objectids as $i => $objectid) // $i is rowid into llx_element_element |
|
| 3353 | 3353 | { |
| 3354 | 3354 | $object = new $classname($this->db); |
| 3355 | 3355 | $ret = $object->fetch($objectid); |
@@ -3388,26 +3388,26 @@ discard block |
||
| 3388 | 3388 | */ |
| 3389 | 3389 | public function updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '') |
| 3390 | 3390 | { |
| 3391 | - $updatesource=false; |
|
| 3392 | - $updatetarget=false; |
|
| 3391 | + $updatesource = false; |
|
| 3392 | + $updatetarget = false; |
|
| 3393 | 3393 | |
| 3394 | - if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $updatesource=true; |
|
| 3395 | - elseif (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $updatetarget=true; |
|
| 3394 | + if (!empty($sourceid) && !empty($sourcetype) && empty($targetid) && empty($targettype)) $updatesource = true; |
|
| 3395 | + elseif (empty($sourceid) && empty($sourcetype) && !empty($targetid) && !empty($targettype)) $updatetarget = true; |
|
| 3396 | 3396 | |
| 3397 | 3397 | $sql = "UPDATE ".MAIN_DB_PREFIX."element_element SET "; |
| 3398 | 3398 | if ($updatesource) |
| 3399 | 3399 | { |
| 3400 | - $sql.= "fk_source = ".$sourceid; |
|
| 3401 | - $sql.= ", sourcetype = '".$this->db->escape($sourcetype)."'"; |
|
| 3402 | - $sql.= " WHERE fk_target = ".$this->id; |
|
| 3403 | - $sql.= " AND targettype = '".$this->db->escape($this->element)."'"; |
|
| 3400 | + $sql .= "fk_source = ".$sourceid; |
|
| 3401 | + $sql .= ", sourcetype = '".$this->db->escape($sourcetype)."'"; |
|
| 3402 | + $sql .= " WHERE fk_target = ".$this->id; |
|
| 3403 | + $sql .= " AND targettype = '".$this->db->escape($this->element)."'"; |
|
| 3404 | 3404 | } |
| 3405 | 3405 | elseif ($updatetarget) |
| 3406 | 3406 | { |
| 3407 | - $sql.= "fk_target = ".$targetid; |
|
| 3408 | - $sql.= ", targettype = '".$this->db->escape($targettype)."'"; |
|
| 3409 | - $sql.= " WHERE fk_source = ".$this->id; |
|
| 3410 | - $sql.= " AND sourcetype = '".$this->db->escape($this->element)."'"; |
|
| 3407 | + $sql .= "fk_target = ".$targetid; |
|
| 3408 | + $sql .= ", targettype = '".$this->db->escape($targettype)."'"; |
|
| 3409 | + $sql .= " WHERE fk_source = ".$this->id; |
|
| 3410 | + $sql .= " AND sourcetype = '".$this->db->escape($this->element)."'"; |
|
| 3411 | 3411 | } |
| 3412 | 3412 | |
| 3413 | 3413 | dol_syslog(get_class($this)."::updateObjectLinked", LOG_DEBUG); |
@@ -3417,7 +3417,7 @@ discard block |
||
| 3417 | 3417 | } |
| 3418 | 3418 | else |
| 3419 | 3419 | { |
| 3420 | - $this->error=$this->db->lasterror(); |
|
| 3420 | + $this->error = $this->db->lasterror(); |
|
| 3421 | 3421 | return -1; |
| 3422 | 3422 | } |
| 3423 | 3423 | } |
@@ -3435,40 +3435,40 @@ discard block |
||
| 3435 | 3435 | */ |
| 3436 | 3436 | public function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '') |
| 3437 | 3437 | { |
| 3438 | - $deletesource=false; |
|
| 3439 | - $deletetarget=false; |
|
| 3438 | + $deletesource = false; |
|
| 3439 | + $deletetarget = false; |
|
| 3440 | 3440 | |
| 3441 | - if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $deletesource=true; |
|
| 3442 | - elseif (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $deletetarget=true; |
|
| 3441 | + if (!empty($sourceid) && !empty($sourcetype) && empty($targetid) && empty($targettype)) $deletesource = true; |
|
| 3442 | + elseif (empty($sourceid) && empty($sourcetype) && !empty($targetid) && !empty($targettype)) $deletetarget = true; |
|
| 3443 | 3443 | |
| 3444 | - $sourceid = (! empty($sourceid) ? $sourceid : $this->id); |
|
| 3445 | - $sourcetype = (! empty($sourcetype) ? $sourcetype : $this->element); |
|
| 3446 | - $targetid = (! empty($targetid) ? $targetid : $this->id); |
|
| 3447 | - $targettype = (! empty($targettype) ? $targettype : $this->element); |
|
| 3444 | + $sourceid = (!empty($sourceid) ? $sourceid : $this->id); |
|
| 3445 | + $sourcetype = (!empty($sourcetype) ? $sourcetype : $this->element); |
|
| 3446 | + $targetid = (!empty($targetid) ? $targetid : $this->id); |
|
| 3447 | + $targettype = (!empty($targettype) ? $targettype : $this->element); |
|
| 3448 | 3448 | |
| 3449 | 3449 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element"; |
| 3450 | - $sql.= " WHERE"; |
|
| 3450 | + $sql .= " WHERE"; |
|
| 3451 | 3451 | if ($rowid > 0) |
| 3452 | 3452 | { |
| 3453 | - $sql.=" rowid = ".$rowid; |
|
| 3453 | + $sql .= " rowid = ".$rowid; |
|
| 3454 | 3454 | } |
| 3455 | 3455 | else |
| 3456 | 3456 | { |
| 3457 | 3457 | if ($deletesource) |
| 3458 | 3458 | { |
| 3459 | - $sql.= " fk_source = ".$sourceid." AND sourcetype = '".$this->db->escape($sourcetype)."'"; |
|
| 3460 | - $sql.= " AND fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."'"; |
|
| 3459 | + $sql .= " fk_source = ".$sourceid." AND sourcetype = '".$this->db->escape($sourcetype)."'"; |
|
| 3460 | + $sql .= " AND fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."'"; |
|
| 3461 | 3461 | } |
| 3462 | 3462 | elseif ($deletetarget) |
| 3463 | 3463 | { |
| 3464 | - $sql.= " fk_target = ".$targetid." AND targettype = '".$this->db->escape($targettype)."'"; |
|
| 3465 | - $sql.= " AND fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."'"; |
|
| 3464 | + $sql .= " fk_target = ".$targetid." AND targettype = '".$this->db->escape($targettype)."'"; |
|
| 3465 | + $sql .= " AND fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."'"; |
|
| 3466 | 3466 | } |
| 3467 | 3467 | else |
| 3468 | 3468 | { |
| 3469 | - $sql.= " (fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."')"; |
|
| 3470 | - $sql.= " OR"; |
|
| 3471 | - $sql.= " (fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."')"; |
|
| 3469 | + $sql .= " (fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."')"; |
|
| 3470 | + $sql .= " OR"; |
|
| 3471 | + $sql .= " (fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."')"; |
|
| 3472 | 3472 | } |
| 3473 | 3473 | } |
| 3474 | 3474 | |
@@ -3479,8 +3479,8 @@ discard block |
||
| 3479 | 3479 | } |
| 3480 | 3480 | else |
| 3481 | 3481 | { |
| 3482 | - $this->error=$this->db->lasterror(); |
|
| 3483 | - $this->errors[]=$this->error; |
|
| 3482 | + $this->error = $this->db->lasterror(); |
|
| 3483 | + $this->errors[] = $this->error; |
|
| 3484 | 3484 | return -1; |
| 3485 | 3485 | } |
| 3486 | 3486 | } |
@@ -3496,28 +3496,28 @@ discard block |
||
| 3496 | 3496 | */ |
| 3497 | 3497 | public function setStatut($status, $elementId = null, $elementType = '', $trigkey = '') |
| 3498 | 3498 | { |
| 3499 | - global $user,$langs,$conf; |
|
| 3499 | + global $user, $langs, $conf; |
|
| 3500 | 3500 | |
| 3501 | - $savElementId=$elementId; // To be used later to know if we were using the method using the id of this or not. |
|
| 3501 | + $savElementId = $elementId; // To be used later to know if we were using the method using the id of this or not. |
|
| 3502 | 3502 | |
| 3503 | - $elementId = (!empty($elementId)?$elementId:$this->id); |
|
| 3504 | - $elementTable = (!empty($elementType)?$elementType:$this->table_element); |
|
| 3503 | + $elementId = (!empty($elementId) ? $elementId : $this->id); |
|
| 3504 | + $elementTable = (!empty($elementType) ? $elementType : $this->table_element); |
|
| 3505 | 3505 | |
| 3506 | 3506 | $this->db->begin(); |
| 3507 | 3507 | |
| 3508 | - $fieldstatus="fk_statut"; |
|
| 3509 | - if ($elementTable == 'facture_rec') $fieldstatus="suspended"; |
|
| 3510 | - if ($elementTable == 'mailing') $fieldstatus="statut"; |
|
| 3511 | - if ($elementTable == 'cronjob') $fieldstatus="status"; |
|
| 3512 | - if ($elementTable == 'user') $fieldstatus="statut"; |
|
| 3513 | - if ($elementTable == 'expensereport') $fieldstatus="fk_statut"; |
|
| 3514 | - if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus="status"; |
|
| 3508 | + $fieldstatus = "fk_statut"; |
|
| 3509 | + if ($elementTable == 'facture_rec') $fieldstatus = "suspended"; |
|
| 3510 | + if ($elementTable == 'mailing') $fieldstatus = "statut"; |
|
| 3511 | + if ($elementTable == 'cronjob') $fieldstatus = "status"; |
|
| 3512 | + if ($elementTable == 'user') $fieldstatus = "statut"; |
|
| 3513 | + if ($elementTable == 'expensereport') $fieldstatus = "fk_statut"; |
|
| 3514 | + if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus = "status"; |
|
| 3515 | 3515 | |
| 3516 | 3516 | $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; |
| 3517 | - $sql.= " SET ".$fieldstatus." = ".$status; |
|
| 3517 | + $sql .= " SET ".$fieldstatus." = ".$status; |
|
| 3518 | 3518 | // If status = 1 = validated, update also fk_user_valid |
| 3519 | - if ($status == 1 && $elementTable == 'expensereport') $sql.=", fk_user_valid = ".$user->id; |
|
| 3520 | - $sql.= " WHERE rowid=".$elementId; |
|
| 3519 | + if ($status == 1 && $elementTable == 'expensereport') $sql .= ", fk_user_valid = ".$user->id; |
|
| 3520 | + $sql .= " WHERE rowid=".$elementId; |
|
| 3521 | 3521 | |
| 3522 | 3522 | dol_syslog(get_class($this)."::setStatut", LOG_DEBUG); |
| 3523 | 3523 | if ($this->db->query($sql)) |
@@ -3527,27 +3527,27 @@ discard block |
||
| 3527 | 3527 | // Try autoset of trigkey |
| 3528 | 3528 | if (empty($trigkey)) |
| 3529 | 3529 | { |
| 3530 | - if ($this->element == 'supplier_proposal' && $status == 2) $trigkey='SUPPLIER_PROPOSAL_SIGN'; // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class |
|
| 3531 | - if ($this->element == 'supplier_proposal' && $status == 3) $trigkey='SUPPLIER_PROPOSAL_REFUSE'; // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class |
|
| 3532 | - if ($this->element == 'supplier_proposal' && $status == 4) $trigkey='SUPPLIER_PROPOSAL_CLOSE'; // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class |
|
| 3533 | - if ($this->element == 'fichinter' && $status == 3) $trigkey='FICHINTER_CLASSIFY_DONE'; |
|
| 3534 | - if ($this->element == 'fichinter' && $status == 2) $trigkey='FICHINTER_CLASSIFY_BILLED'; |
|
| 3535 | - if ($this->element == 'fichinter' && $status == 1) $trigkey='FICHINTER_CLASSIFY_UNBILLED'; |
|
| 3530 | + if ($this->element == 'supplier_proposal' && $status == 2) $trigkey = 'SUPPLIER_PROPOSAL_SIGN'; // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class |
|
| 3531 | + if ($this->element == 'supplier_proposal' && $status == 3) $trigkey = 'SUPPLIER_PROPOSAL_REFUSE'; // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class |
|
| 3532 | + if ($this->element == 'supplier_proposal' && $status == 4) $trigkey = 'SUPPLIER_PROPOSAL_CLOSE'; // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class |
|
| 3533 | + if ($this->element == 'fichinter' && $status == 3) $trigkey = 'FICHINTER_CLASSIFY_DONE'; |
|
| 3534 | + if ($this->element == 'fichinter' && $status == 2) $trigkey = 'FICHINTER_CLASSIFY_BILLED'; |
|
| 3535 | + if ($this->element == 'fichinter' && $status == 1) $trigkey = 'FICHINTER_CLASSIFY_UNBILLED'; |
|
| 3536 | 3536 | } |
| 3537 | 3537 | |
| 3538 | 3538 | if ($trigkey) |
| 3539 | 3539 | { |
| 3540 | 3540 | // Appel des triggers |
| 3541 | - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
| 3542 | - $interface=new Interfaces($this->db); |
|
| 3543 | - $result=$interface->run_triggers($trigkey, $this, $user, $langs, $conf); |
|
| 3541 | + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; |
|
| 3542 | + $interface = new Interfaces($this->db); |
|
| 3543 | + $result = $interface->run_triggers($trigkey, $this, $user, $langs, $conf); |
|
| 3544 | 3544 | if ($result < 0) { |
| 3545 | - $error++; $this->errors=$interface->errors; |
|
| 3545 | + $error++; $this->errors = $interface->errors; |
|
| 3546 | 3546 | } |
| 3547 | 3547 | // Fin appel triggers |
| 3548 | 3548 | } |
| 3549 | 3549 | |
| 3550 | - if (! $error) |
|
| 3550 | + if (!$error) |
|
| 3551 | 3551 | { |
| 3552 | 3552 | $this->db->commit(); |
| 3553 | 3553 | |
@@ -3568,7 +3568,7 @@ discard block |
||
| 3568 | 3568 | } |
| 3569 | 3569 | else |
| 3570 | 3570 | { |
| 3571 | - $this->error=$this->db->lasterror(); |
|
| 3571 | + $this->error = $this->db->lasterror(); |
|
| 3572 | 3572 | $this->db->rollback(); |
| 3573 | 3573 | return -1; |
| 3574 | 3574 | } |
@@ -3587,16 +3587,16 @@ discard block |
||
| 3587 | 3587 | global $conf; |
| 3588 | 3588 | |
| 3589 | 3589 | if (empty($id) && empty($ref)) return 0; |
| 3590 | - if (! empty($conf->global->MAIN_DISABLE_CANVAS)) return 0; // To increase speed. Not enabled by default. |
|
| 3590 | + if (!empty($conf->global->MAIN_DISABLE_CANVAS)) return 0; // To increase speed. Not enabled by default. |
|
| 3591 | 3591 | |
| 3592 | 3592 | // Clean parameters |
| 3593 | 3593 | $ref = trim($ref); |
| 3594 | 3594 | |
| 3595 | 3595 | $sql = "SELECT rowid, canvas"; |
| 3596 | - $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element; |
|
| 3597 | - $sql.= " WHERE entity IN (".getEntity($this->element).")"; |
|
| 3598 | - if (! empty($id)) $sql.= " AND rowid = ".$id; |
|
| 3599 | - if (! empty($ref)) $sql.= " AND ref = '".$this->db->escape($ref)."'"; |
|
| 3596 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; |
|
| 3597 | + $sql .= " WHERE entity IN (".getEntity($this->element).")"; |
|
| 3598 | + if (!empty($id)) $sql .= " AND rowid = ".$id; |
|
| 3599 | + if (!empty($ref)) $sql .= " AND ref = '".$this->db->escape($ref)."'"; |
|
| 3600 | 3600 | |
| 3601 | 3601 | $resql = $this->db->query($sql); |
| 3602 | 3602 | if ($resql) |
@@ -3604,7 +3604,7 @@ discard block |
||
| 3604 | 3604 | $obj = $this->db->fetch_object($resql); |
| 3605 | 3605 | if ($obj) |
| 3606 | 3606 | { |
| 3607 | - $this->canvas = $obj->canvas; |
|
| 3607 | + $this->canvas = $obj->canvas; |
|
| 3608 | 3608 | return 1; |
| 3609 | 3609 | } |
| 3610 | 3610 | else return 0; |
@@ -3626,7 +3626,7 @@ discard block |
||
| 3626 | 3626 | public function getSpecialCode($lineid) |
| 3627 | 3627 | { |
| 3628 | 3628 | $sql = 'SELECT special_code FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 3629 | - $sql.= ' WHERE rowid = '.$lineid; |
|
| 3629 | + $sql .= ' WHERE rowid = '.$lineid; |
|
| 3630 | 3630 | $resql = $this->db->query($sql); |
| 3631 | 3631 | if ($resql) |
| 3632 | 3632 | { |
@@ -3646,10 +3646,10 @@ discard block |
||
| 3646 | 3646 | { |
| 3647 | 3647 | global $langs; |
| 3648 | 3648 | |
| 3649 | - if (empty($id)) $id=$this->id; |
|
| 3649 | + if (empty($id)) $id = $this->id; |
|
| 3650 | 3650 | |
| 3651 | 3651 | // Check parameters |
| 3652 | - if (! isset($this->childtables) || ! is_array($this->childtables) || count($this->childtables) == 0) |
|
| 3652 | + if (!isset($this->childtables) || !is_array($this->childtables) || count($this->childtables) == 0) |
|
| 3653 | 3653 | { |
| 3654 | 3654 | dol_print_error('Called isObjectUsed on a class with property this->childtables not defined'); |
| 3655 | 3655 | return -1; |
@@ -3657,24 +3657,24 @@ discard block |
||
| 3657 | 3657 | |
| 3658 | 3658 | $arraytoscan = $this->childtables; |
| 3659 | 3659 | // For backward compatibility, we check if array is old format array('table1', 'table2', ...) |
| 3660 | - $tmparray=array_keys($this->childtables); |
|
| 3660 | + $tmparray = array_keys($this->childtables); |
|
| 3661 | 3661 | if (is_numeric($tmparray[0])) |
| 3662 | 3662 | { |
| 3663 | 3663 | $arraytoscan = array_flip($this->childtables); |
| 3664 | 3664 | } |
| 3665 | 3665 | |
| 3666 | 3666 | // Test if child exists |
| 3667 | - $haschild=0; |
|
| 3668 | - foreach($arraytoscan as $table => $elementname) |
|
| 3667 | + $haschild = 0; |
|
| 3668 | + foreach ($arraytoscan as $table => $elementname) |
|
| 3669 | 3669 | { |
| 3670 | 3670 | //print $id.'-'.$table.'-'.$elementname.'<br>'; |
| 3671 | 3671 | // Check if third party can be deleted |
| 3672 | 3672 | $sql = "SELECT COUNT(*) as nb from ".MAIN_DB_PREFIX.$table; |
| 3673 | - $sql.= " WHERE ".$this->fk_element." = ".$id; |
|
| 3674 | - $resql=$this->db->query($sql); |
|
| 3673 | + $sql .= " WHERE ".$this->fk_element." = ".$id; |
|
| 3674 | + $resql = $this->db->query($sql); |
|
| 3675 | 3675 | if ($resql) |
| 3676 | 3676 | { |
| 3677 | - $obj=$this->db->fetch_object($resql); |
|
| 3677 | + $obj = $this->db->fetch_object($resql); |
|
| 3678 | 3678 | if ($obj->nb > 0) |
| 3679 | 3679 | { |
| 3680 | 3680 | $langs->load("errors"); |
@@ -3682,24 +3682,24 @@ discard block |
||
| 3682 | 3682 | $haschild += $obj->nb; |
| 3683 | 3683 | if (is_numeric($elementname)) // old usage |
| 3684 | 3684 | { |
| 3685 | - $this->errors[]=$langs->trans("ErrorRecordHasAtLeastOneChildOfType", $table); |
|
| 3685 | + $this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", $table); |
|
| 3686 | 3686 | } |
| 3687 | 3687 | else // new usage: $elementname=Translation key |
| 3688 | 3688 | { |
| 3689 | - $this->errors[]=$langs->trans("ErrorRecordHasAtLeastOneChildOfType", $langs->transnoentitiesnoconv($elementname)); |
|
| 3689 | + $this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", $langs->transnoentitiesnoconv($elementname)); |
|
| 3690 | 3690 | } |
| 3691 | - break; // We found at least one, we stop here |
|
| 3691 | + break; // We found at least one, we stop here |
|
| 3692 | 3692 | } |
| 3693 | 3693 | } |
| 3694 | 3694 | else |
| 3695 | 3695 | { |
| 3696 | - $this->errors[]=$this->db->lasterror(); |
|
| 3696 | + $this->errors[] = $this->db->lasterror(); |
|
| 3697 | 3697 | return -1; |
| 3698 | 3698 | } |
| 3699 | 3699 | } |
| 3700 | 3700 | if ($haschild > 0) |
| 3701 | 3701 | { |
| 3702 | - $this->errors[]="ErrorRecordHasChildren"; |
|
| 3702 | + $this->errors[] = "ErrorRecordHasChildren"; |
|
| 3703 | 3703 | return $haschild; |
| 3704 | 3704 | } |
| 3705 | 3705 | else return 0; |
@@ -3713,16 +3713,16 @@ discard block |
||
| 3713 | 3713 | */ |
| 3714 | 3714 | public function hasProductsOrServices($predefined = -1) |
| 3715 | 3715 | { |
| 3716 | - $nb=0; |
|
| 3716 | + $nb = 0; |
|
| 3717 | 3717 | |
| 3718 | - foreach($this->lines as $key => $val) |
|
| 3718 | + foreach ($this->lines as $key => $val) |
|
| 3719 | 3719 | { |
| 3720 | - $qualified=0; |
|
| 3721 | - if ($predefined == -1) $qualified=1; |
|
| 3722 | - if ($predefined == 1 && $val->fk_product > 0) $qualified=1; |
|
| 3723 | - if ($predefined == 0 && $val->fk_product <= 0) $qualified=1; |
|
| 3724 | - if ($predefined == 2 && $val->fk_product > 0 && $val->product_type==0) $qualified=1; |
|
| 3725 | - if ($predefined == 3 && $val->fk_product > 0 && $val->product_type==1) $qualified=1; |
|
| 3720 | + $qualified = 0; |
|
| 3721 | + if ($predefined == -1) $qualified = 1; |
|
| 3722 | + if ($predefined == 1 && $val->fk_product > 0) $qualified = 1; |
|
| 3723 | + if ($predefined == 0 && $val->fk_product <= 0) $qualified = 1; |
|
| 3724 | + if ($predefined == 2 && $val->fk_product > 0 && $val->product_type == 0) $qualified = 1; |
|
| 3725 | + if ($predefined == 3 && $val->fk_product > 0 && $val->product_type == 1) $qualified = 1; |
|
| 3726 | 3726 | if ($qualified) $nb++; |
| 3727 | 3727 | } |
| 3728 | 3728 | dol_syslog(get_class($this).'::hasProductsOrServices we found '.$nb.' qualified lines of products/servcies'); |
@@ -3736,24 +3736,24 @@ discard block |
||
| 3736 | 3736 | */ |
| 3737 | 3737 | public function getTotalDiscount() |
| 3738 | 3738 | { |
| 3739 | - $total_discount=0.00; |
|
| 3739 | + $total_discount = 0.00; |
|
| 3740 | 3740 | |
| 3741 | 3741 | $sql = "SELECT subprice as pu_ht, qty, remise_percent, total_ht"; |
| 3742 | - $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element."det"; |
|
| 3743 | - $sql.= " WHERE ".$this->fk_element." = ".$this->id; |
|
| 3742 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element."det"; |
|
| 3743 | + $sql .= " WHERE ".$this->fk_element." = ".$this->id; |
|
| 3744 | 3744 | |
| 3745 | 3745 | dol_syslog(get_class($this).'::getTotalDiscount', LOG_DEBUG); |
| 3746 | 3746 | $resql = $this->db->query($sql); |
| 3747 | 3747 | if ($resql) |
| 3748 | 3748 | { |
| 3749 | - $num=$this->db->num_rows($resql); |
|
| 3750 | - $i=0; |
|
| 3749 | + $num = $this->db->num_rows($resql); |
|
| 3750 | + $i = 0; |
|
| 3751 | 3751 | while ($i < $num) |
| 3752 | 3752 | { |
| 3753 | 3753 | $obj = $this->db->fetch_object($resql); |
| 3754 | 3754 | |
| 3755 | 3755 | $pu_ht = $obj->pu_ht; |
| 3756 | - $qty= $obj->qty; |
|
| 3756 | + $qty = $obj->qty; |
|
| 3757 | 3757 | $total_ht = $obj->total_ht; |
| 3758 | 3758 | |
| 3759 | 3759 | $total_discount_line = floatval(price2num(($pu_ht * $qty) - $total_ht, 'MT')); |
@@ -3787,18 +3787,18 @@ discard block |
||
| 3787 | 3787 | { |
| 3788 | 3788 | if (isset($line->qty_asked)) |
| 3789 | 3789 | { |
| 3790 | - if (empty($totalOrdered)) $totalOrdered=0; // Avoid warning because $totalOrdered is '' |
|
| 3791 | - $totalOrdered+=$line->qty_asked; // defined for shipment only |
|
| 3790 | + if (empty($totalOrdered)) $totalOrdered = 0; // Avoid warning because $totalOrdered is '' |
|
| 3791 | + $totalOrdered += $line->qty_asked; // defined for shipment only |
|
| 3792 | 3792 | } |
| 3793 | 3793 | if (isset($line->qty_shipped)) |
| 3794 | 3794 | { |
| 3795 | - if (empty($totalToShip)) $totalToShip=0; // Avoid warning because $totalToShip is '' |
|
| 3796 | - $totalToShip+=$line->qty_shipped; // defined for shipment only |
|
| 3795 | + if (empty($totalToShip)) $totalToShip = 0; // Avoid warning because $totalToShip is '' |
|
| 3796 | + $totalToShip += $line->qty_shipped; // defined for shipment only |
|
| 3797 | 3797 | } |
| 3798 | 3798 | elseif ($line->element == 'commandefournisseurdispatch' && isset($line->qty)) |
| 3799 | 3799 | { |
| 3800 | - if (empty($totalToShip)) $totalToShip=0; |
|
| 3801 | - $totalToShip+=$line->qty; // defined for reception only |
|
| 3800 | + if (empty($totalToShip)) $totalToShip = 0; |
|
| 3801 | + $totalToShip += $line->qty; // defined for reception only |
|
| 3802 | 3802 | } |
| 3803 | 3803 | |
| 3804 | 3804 | // Define qty, weight, volume, weight_units, volume_units |
@@ -3811,27 +3811,27 @@ discard block |
||
| 3811 | 3811 | } |
| 3812 | 3812 | |
| 3813 | 3813 | $weight = $line->weight ? $line->weight : 0; |
| 3814 | - ($weight==0 && !empty($line->product->weight))? $weight=$line->product->weight: 0; |
|
| 3814 | + ($weight == 0 && !empty($line->product->weight)) ? $weight = $line->product->weight : 0; |
|
| 3815 | 3815 | $volume = $line->volume ? $line->volume : 0; |
| 3816 | - ($volume==0 && !empty($line->product->volume))? $volume=$line->product->volume: 0; |
|
| 3816 | + ($volume == 0 && !empty($line->product->volume)) ? $volume = $line->product->volume : 0; |
|
| 3817 | 3817 | |
| 3818 | - $weight_units=$line->weight_units; |
|
| 3819 | - ($weight_units==0 && !empty($line->product->weight_units))? $weight_units=$line->product->weight_units: 0; |
|
| 3820 | - $volume_units=$line->volume_units; |
|
| 3821 | - ($volume_units==0 && !empty($line->product->volume_units))? $volume_units=$line->product->volume_units: 0; |
|
| 3818 | + $weight_units = $line->weight_units; |
|
| 3819 | + ($weight_units == 0 && !empty($line->product->weight_units)) ? $weight_units = $line->product->weight_units : 0; |
|
| 3820 | + $volume_units = $line->volume_units; |
|
| 3821 | + ($volume_units == 0 && !empty($line->product->volume_units)) ? $volume_units = $line->product->volume_units : 0; |
|
| 3822 | 3822 | |
| 3823 | - $weightUnit=0; |
|
| 3824 | - $volumeUnit=0; |
|
| 3825 | - if (! empty($weight_units)) $weightUnit = $weight_units; |
|
| 3826 | - if (! empty($volume_units)) $volumeUnit = $volume_units; |
|
| 3823 | + $weightUnit = 0; |
|
| 3824 | + $volumeUnit = 0; |
|
| 3825 | + if (!empty($weight_units)) $weightUnit = $weight_units; |
|
| 3826 | + if (!empty($volume_units)) $volumeUnit = $volume_units; |
|
| 3827 | 3827 | |
| 3828 | - if (empty($totalWeight)) $totalWeight=0; // Avoid warning because $totalWeight is '' |
|
| 3829 | - if (empty($totalVolume)) $totalVolume=0; // Avoid warning because $totalVolume is '' |
|
| 3828 | + if (empty($totalWeight)) $totalWeight = 0; // Avoid warning because $totalWeight is '' |
|
| 3829 | + if (empty($totalVolume)) $totalVolume = 0; // Avoid warning because $totalVolume is '' |
|
| 3830 | 3830 | |
| 3831 | 3831 | //var_dump($line->volume_units); |
| 3832 | 3832 | if ($weight_units < 50) // < 50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
| 3833 | 3833 | { |
| 3834 | - $trueWeightUnit=pow(10, $weightUnit); |
|
| 3834 | + $trueWeightUnit = pow(10, $weightUnit); |
|
| 3835 | 3835 | $totalWeight += $weight * $qty * $trueWeightUnit; |
| 3836 | 3836 | } |
| 3837 | 3837 | else { |
@@ -3845,19 +3845,19 @@ discard block |
||
| 3845 | 3845 | $totalWeight += $weight * $qty * $trueWeightUnit; |
| 3846 | 3846 | } |
| 3847 | 3847 | else { |
| 3848 | - $totalWeight += $weight * $qty; // This may be wrong if we mix different units |
|
| 3848 | + $totalWeight += $weight * $qty; // This may be wrong if we mix different units |
|
| 3849 | 3849 | } |
| 3850 | 3850 | } |
| 3851 | 3851 | if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
| 3852 | 3852 | { |
| 3853 | 3853 | //print $line->volume."x".$line->volume_units."x".($line->volume_units < 50)."x".$volumeUnit; |
| 3854 | - $trueVolumeUnit=pow(10, $volumeUnit); |
|
| 3854 | + $trueVolumeUnit = pow(10, $volumeUnit); |
|
| 3855 | 3855 | //print $line->volume; |
| 3856 | 3856 | $totalVolume += $volume * $qty * $trueVolumeUnit; |
| 3857 | 3857 | } |
| 3858 | 3858 | else |
| 3859 | 3859 | { |
| 3860 | - $totalVolume += $volume * $qty; // This may be wrong if we mix different units |
|
| 3860 | + $totalVolume += $volume * $qty; // This may be wrong if we mix different units |
|
| 3861 | 3861 | } |
| 3862 | 3862 | } |
| 3863 | 3863 | |
@@ -3874,17 +3874,17 @@ discard block |
||
| 3874 | 3874 | { |
| 3875 | 3875 | $this->db->begin(); |
| 3876 | 3876 | |
| 3877 | - $extraparams = (! empty($this->extraparams) ? json_encode($this->extraparams) : null); |
|
| 3877 | + $extraparams = (!empty($this->extraparams) ? json_encode($this->extraparams) : null); |
|
| 3878 | 3878 | |
| 3879 | 3879 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
| 3880 | - $sql.= " SET extraparams = ".(! empty($extraparams) ? "'".$this->db->escape($extraparams)."'" : "null"); |
|
| 3881 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 3880 | + $sql .= " SET extraparams = ".(!empty($extraparams) ? "'".$this->db->escape($extraparams)."'" : "null"); |
|
| 3881 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 3882 | 3882 | |
| 3883 | 3883 | dol_syslog(get_class($this)."::setExtraParameters", LOG_DEBUG); |
| 3884 | 3884 | $resql = $this->db->query($sql); |
| 3885 | - if (! $resql) |
|
| 3885 | + if (!$resql) |
|
| 3886 | 3886 | { |
| 3887 | - $this->error=$this->db->lasterror(); |
|
| 3887 | + $this->error = $this->db->lasterror(); |
|
| 3888 | 3888 | $this->db->rollback(); |
| 3889 | 3889 | return -1; |
| 3890 | 3890 | } |
@@ -3919,7 +3919,7 @@ discard block |
||
| 3919 | 3919 | } |
| 3920 | 3920 | } |
| 3921 | 3921 | |
| 3922 | - $out .= (($res->code && $this->location_incoterms)?' - ':'').$this->location_incoterms; |
|
| 3922 | + $out .= (($res->code && $this->location_incoterms) ? ' - ' : '').$this->location_incoterms; |
|
| 3923 | 3923 | |
| 3924 | 3924 | return $out; |
| 3925 | 3925 | } |
@@ -3965,11 +3965,11 @@ discard block |
||
| 3965 | 3965 | if ($this->id && $this->table_element) |
| 3966 | 3966 | { |
| 3967 | 3967 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
| 3968 | - $sql.= " SET fk_incoterms = ".($id_incoterm > 0 ? $id_incoterm : "null"); |
|
| 3969 | - $sql.= ", location_incoterms = ".($id_incoterm > 0 ? "'".$this->db->escape($location)."'" : "null"); |
|
| 3970 | - $sql.= " WHERE rowid = " . $this->id; |
|
| 3968 | + $sql .= " SET fk_incoterms = ".($id_incoterm > 0 ? $id_incoterm : "null"); |
|
| 3969 | + $sql .= ", location_incoterms = ".($id_incoterm > 0 ? "'".$this->db->escape($location)."'" : "null"); |
|
| 3970 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 3971 | 3971 | dol_syslog(get_class($this).'::setIncoterms', LOG_DEBUG); |
| 3972 | - $resql=$this->db->query($sql); |
|
| 3972 | + $resql = $this->db->query($sql); |
|
| 3973 | 3973 | if ($resql) |
| 3974 | 3974 | { |
| 3975 | 3975 | $this->fk_incoterms = $id_incoterm; |
@@ -4011,11 +4011,11 @@ discard block |
||
| 4011 | 4011 | */ |
| 4012 | 4012 | public function formAddObjectLine($dateSelector, $seller, $buyer, $defaulttpldir = '/core/tpl') |
| 4013 | 4013 | { |
| 4014 | - global $conf,$user,$langs,$object,$hookmanager,$extrafields; |
|
| 4015 | - global $form,$bcnd,$var; |
|
| 4014 | + global $conf, $user, $langs, $object, $hookmanager, $extrafields; |
|
| 4015 | + global $form, $bcnd, $var; |
|
| 4016 | 4016 | |
| 4017 | 4017 | // Line extrafield |
| 4018 | - if (! is_object($extrafields)) |
|
| 4018 | + if (!is_object($extrafields)) |
|
| 4019 | 4019 | { |
| 4020 | 4020 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
| 4021 | 4021 | $extrafields = new ExtraFields($this->db); |
@@ -4024,8 +4024,8 @@ discard block |
||
| 4024 | 4024 | |
| 4025 | 4025 | // Output template part (modules that overwrite templates must declare this into descriptor) |
| 4026 | 4026 | // Use global variables + $dateSelector + $seller and $buyer |
| 4027 | - $dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
|
| 4028 | - foreach($dirtpls as $module => $reldir) |
|
| 4027 | + $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
|
| 4028 | + foreach ($dirtpls as $module => $reldir) |
|
| 4029 | 4029 | { |
| 4030 | 4030 | if (!empty($module)) |
| 4031 | 4031 | { |
@@ -4037,9 +4037,9 @@ discard block |
||
| 4037 | 4037 | } |
| 4038 | 4038 | |
| 4039 | 4039 | if (empty($conf->file->strict_mode)) { |
| 4040 | - $res=@include $tpl; |
|
| 4040 | + $res = @include $tpl; |
|
| 4041 | 4041 | } else { |
| 4042 | - $res=include $tpl; // for debug |
|
| 4042 | + $res = include $tpl; // for debug |
|
| 4043 | 4043 | } |
| 4044 | 4044 | if ($res) break; |
| 4045 | 4045 | } |
@@ -4071,13 +4071,13 @@ discard block |
||
| 4071 | 4071 | global $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $disableremove, $outputalsopricetotalwithtax; |
| 4072 | 4072 | |
| 4073 | 4073 | // Define usemargins |
| 4074 | - $usemargins=0; |
|
| 4075 | - if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element, array('facture','facturerec','propal','commande'))) $usemargins=1; |
|
| 4074 | + $usemargins = 0; |
|
| 4075 | + if (!empty($conf->margin->enabled) && !empty($this->element) && in_array($this->element, array('facture', 'facturerec', 'propal', 'commande'))) $usemargins = 1; |
|
| 4076 | 4076 | |
| 4077 | 4077 | $num = count($this->lines); |
| 4078 | 4078 | |
| 4079 | 4079 | // Line extrafield |
| 4080 | - if (! is_object($extrafields)) |
|
| 4080 | + if (!is_object($extrafields)) |
|
| 4081 | 4081 | { |
| 4082 | 4082 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
| 4083 | 4083 | $extrafields = new ExtraFields($this->db); |
@@ -4090,8 +4090,8 @@ discard block |
||
| 4090 | 4090 | { |
| 4091 | 4091 | // Output template part (modules that overwrite templates must declare this into descriptor) |
| 4092 | 4092 | // Use global variables + $dateSelector + $seller and $buyer |
| 4093 | - $dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
|
| 4094 | - foreach($dirtpls as $module => $reldir) |
|
| 4093 | + $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
|
| 4094 | + foreach ($dirtpls as $module => $reldir) |
|
| 4095 | 4095 | { |
| 4096 | 4096 | if (!empty($module)) |
| 4097 | 4097 | { |
@@ -4102,16 +4102,16 @@ discard block |
||
| 4102 | 4102 | $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_title.tpl.php'; |
| 4103 | 4103 | } |
| 4104 | 4104 | if (empty($conf->file->strict_mode)) { |
| 4105 | - $res=@include $tpl; |
|
| 4105 | + $res = @include $tpl; |
|
| 4106 | 4106 | } else { |
| 4107 | - $res=include $tpl; // for debug |
|
| 4107 | + $res = include $tpl; // for debug |
|
| 4108 | 4108 | } |
| 4109 | 4109 | if ($res) break; |
| 4110 | 4110 | } |
| 4111 | 4111 | } |
| 4112 | 4112 | |
| 4113 | 4113 | $var = true; |
| 4114 | - $i = 0; |
|
| 4114 | + $i = 0; |
|
| 4115 | 4115 | |
| 4116 | 4116 | print "<tbody>\n"; |
| 4117 | 4117 | foreach ($this->lines as $line) |
@@ -4124,13 +4124,13 @@ discard block |
||
| 4124 | 4124 | { |
| 4125 | 4125 | if (empty($line->fk_parent_line)) |
| 4126 | 4126 | { |
| 4127 | - $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'table_element_line'=>$line->table_element); |
|
| 4128 | - $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 4127 | + $parameters = array('line'=>$line, 'var'=>$var, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element); |
|
| 4128 | + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 4129 | 4129 | } |
| 4130 | 4130 | else |
| 4131 | 4131 | { |
| 4132 | - $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line); |
|
| 4133 | - $reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 4132 | + $parameters = array('line'=>$line, 'var'=>$var, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line); |
|
| 4133 | + $reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 4134 | 4134 | } |
| 4135 | 4135 | } |
| 4136 | 4136 | if (empty($reshook)) |
@@ -4162,21 +4162,21 @@ discard block |
||
| 4162 | 4162 | */ |
| 4163 | 4163 | public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields = null, $defaulttpldir = '/core/tpl') |
| 4164 | 4164 | { |
| 4165 | - global $conf,$langs,$user,$object,$hookmanager; |
|
| 4166 | - global $form,$bc,$bcdd; |
|
| 4167 | - global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this ! |
|
| 4165 | + global $conf, $langs, $user, $object, $hookmanager; |
|
| 4166 | + global $form, $bc, $bcdd; |
|
| 4167 | + global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this ! |
|
| 4168 | 4168 | |
| 4169 | 4169 | $object_rights = $this->getRights(); |
| 4170 | 4170 | |
| 4171 | - $element=$this->element; |
|
| 4171 | + $element = $this->element; |
|
| 4172 | 4172 | |
| 4173 | - $text=''; $description=''; $type=0; |
|
| 4173 | + $text = ''; $description = ''; $type = 0; |
|
| 4174 | 4174 | |
| 4175 | 4175 | // Show product and description |
| 4176 | - $type=(! empty($line->product_type)?$line->product_type:$line->fk_product_type); |
|
| 4176 | + $type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type); |
|
| 4177 | 4177 | // Try to enhance type detection using date_start and date_end for free lines where type was not saved. |
| 4178 | - if (! empty($line->date_start)) $type=1; // deprecated |
|
| 4179 | - if (! empty($line->date_end)) $type=1; // deprecated |
|
| 4178 | + if (!empty($line->date_start)) $type = 1; // deprecated |
|
| 4179 | + if (!empty($line->date_end)) $type = 1; // deprecated |
|
| 4180 | 4180 | |
| 4181 | 4181 | // Ligne en mode visu |
| 4182 | 4182 | if ($action != 'editline' || $selected != $line->id) |
@@ -4189,12 +4189,12 @@ discard block |
||
| 4189 | 4189 | |
| 4190 | 4190 | $product_static->ref = $line->ref; //can change ref in hook |
| 4191 | 4191 | $product_static->label = $line->label; //can change label in hook |
| 4192 | - $text=$product_static->getNomUrl(1); |
|
| 4192 | + $text = $product_static->getNomUrl(1); |
|
| 4193 | 4193 | |
| 4194 | 4194 | // Define output language and label |
| 4195 | - if (! empty($conf->global->MAIN_MULTILANGS)) |
|
| 4195 | + if (!empty($conf->global->MAIN_MULTILANGS)) |
|
| 4196 | 4196 | { |
| 4197 | - if (property_exists($this, 'socid') && ! is_object($this->thirdparty)) |
|
| 4197 | + if (property_exists($this, 'socid') && !is_object($this->thirdparty)) |
|
| 4198 | 4198 | { |
| 4199 | 4199 | dol_print_error('', 'Error: Method printObjectLine was called on an object and object->fetch_thirdparty was not done before'); |
| 4200 | 4200 | return; |
@@ -4204,32 +4204,32 @@ discard block |
||
| 4204 | 4204 | $prod->fetch($line->fk_product); |
| 4205 | 4205 | |
| 4206 | 4206 | $outputlangs = $langs; |
| 4207 | - $newlang=''; |
|
| 4208 | - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); |
|
| 4209 | - if (! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && empty($newlang) && is_object($this->thirdparty)) $newlang=$this->thirdparty->default_lang; // To use language of customer |
|
| 4210 | - if (! empty($newlang)) |
|
| 4207 | + $newlang = ''; |
|
| 4208 | + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
|
| 4209 | + if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && empty($newlang) && is_object($this->thirdparty)) $newlang = $this->thirdparty->default_lang; // To use language of customer |
|
| 4210 | + if (!empty($newlang)) |
|
| 4211 | 4211 | { |
| 4212 | 4212 | $outputlangs = new Translate("", $conf); |
| 4213 | 4213 | $outputlangs->setDefaultLang($newlang); |
| 4214 | 4214 | } |
| 4215 | 4215 | |
| 4216 | - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $line->product_label; |
|
| 4216 | + $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $line->product_label; |
|
| 4217 | 4217 | } |
| 4218 | 4218 | else |
| 4219 | 4219 | { |
| 4220 | 4220 | $label = $line->product_label; |
| 4221 | 4221 | } |
| 4222 | 4222 | |
| 4223 | - $text.= ' - '.(! empty($line->label)?$line->label:$label); |
|
| 4224 | - $description.=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($line->description)); // Description is what to show on popup. We shown nothing if already into desc. |
|
| 4223 | + $text .= ' - '.(!empty($line->label) ? $line->label : $label); |
|
| 4224 | + $description .= (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($line->description)); // Description is what to show on popup. We shown nothing if already into desc. |
|
| 4225 | 4225 | } |
| 4226 | 4226 | |
| 4227 | - $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU'); |
|
| 4227 | + $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx / 100)), 'MU'); |
|
| 4228 | 4228 | |
| 4229 | 4229 | // Output template part (modules that overwrite templates must declare this into descriptor) |
| 4230 | 4230 | // Use global variables + $dateSelector + $seller and $buyer |
| 4231 | - $dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
|
| 4232 | - foreach($dirtpls as $module => $reldir) |
|
| 4231 | + $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
|
| 4232 | + foreach ($dirtpls as $module => $reldir) |
|
| 4233 | 4233 | { |
| 4234 | 4234 | if (!empty($module)) |
| 4235 | 4235 | { |
@@ -4241,9 +4241,9 @@ discard block |
||
| 4241 | 4241 | } |
| 4242 | 4242 | |
| 4243 | 4243 | if (empty($conf->file->strict_mode)) { |
| 4244 | - $res=@include $tpl; |
|
| 4244 | + $res = @include $tpl; |
|
| 4245 | 4245 | } else { |
| 4246 | - $res=include $tpl; // for debug |
|
| 4246 | + $res = include $tpl; // for debug |
|
| 4247 | 4247 | } |
| 4248 | 4248 | if ($res) break; |
| 4249 | 4249 | } |
@@ -4252,15 +4252,15 @@ discard block |
||
| 4252 | 4252 | // Line in update mode |
| 4253 | 4253 | if ($this->statut == 0 && $action == 'editline' && $selected == $line->id) |
| 4254 | 4254 | { |
| 4255 | - $label = (! empty($line->label) ? $line->label : (($line->fk_product > 0) ? $line->product_label : '')); |
|
| 4256 | - $placeholder=' placeholder="'.$langs->trans("Label").'"'; |
|
| 4255 | + $label = (!empty($line->label) ? $line->label : (($line->fk_product > 0) ? $line->product_label : '')); |
|
| 4256 | + $placeholder = ' placeholder="'.$langs->trans("Label").'"'; |
|
| 4257 | 4257 | |
| 4258 | - $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU'); |
|
| 4258 | + $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx / 100)), 'MU'); |
|
| 4259 | 4259 | |
| 4260 | 4260 | // Output template part (modules that overwrite templates must declare this into descriptor) |
| 4261 | 4261 | // Use global variables + $dateSelector + $seller and $buyer |
| 4262 | - $dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
|
| 4263 | - foreach($dirtpls as $module => $reldir) |
|
| 4262 | + $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
|
| 4263 | + foreach ($dirtpls as $module => $reldir) |
|
| 4264 | 4264 | { |
| 4265 | 4265 | if (!empty($module)) |
| 4266 | 4266 | { |
@@ -4272,9 +4272,9 @@ discard block |
||
| 4272 | 4272 | } |
| 4273 | 4273 | |
| 4274 | 4274 | if (empty($conf->file->strict_mode)) { |
| 4275 | - $res=@include $tpl; |
|
| 4275 | + $res = @include $tpl; |
|
| 4276 | 4276 | } else { |
| 4277 | - $res=include $tpl; // for debug |
|
| 4277 | + $res = include $tpl; // for debug |
|
| 4278 | 4278 | } |
| 4279 | 4279 | if ($res) break; |
| 4280 | 4280 | } |
@@ -4306,7 +4306,7 @@ discard block |
||
| 4306 | 4306 | print '<td class="right">'.$langs->trans('PriceUHT').'</td>'; |
| 4307 | 4307 | if (!empty($conf->multicurrency->enabled)) print '<td class="right">'.$langs->trans('PriceUHTCurrency').'</td>'; |
| 4308 | 4308 | print '<td class="right">'.$langs->trans('Qty').'</td>'; |
| 4309 | - if($conf->global->PRODUCT_USE_UNITS) |
|
| 4309 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
| 4310 | 4310 | { |
| 4311 | 4311 | print '<td class="left">'.$langs->trans('Unit').'</td>'; |
| 4312 | 4312 | } |
@@ -4314,19 +4314,19 @@ discard block |
||
| 4314 | 4314 | print '<td class="center">'.$form->showCheckAddButtons('checkforselect', 1).'</td>'; |
| 4315 | 4315 | print '</tr>'; |
| 4316 | 4316 | $var = true; |
| 4317 | - $i = 0; |
|
| 4317 | + $i = 0; |
|
| 4318 | 4318 | |
| 4319 | - if (! empty($this->lines)) |
|
| 4319 | + if (!empty($this->lines)) |
|
| 4320 | 4320 | { |
| 4321 | 4321 | foreach ($this->lines as $line) |
| 4322 | 4322 | { |
| 4323 | - if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) |
|
| 4323 | + if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) |
|
| 4324 | 4324 | { |
| 4325 | 4325 | if (empty($line->fk_parent_line)) |
| 4326 | 4326 | { |
| 4327 | - $parameters=array('line'=>$line,'var'=>$var,'i'=>$i); |
|
| 4328 | - $action=''; |
|
| 4329 | - $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 4327 | + $parameters = array('line'=>$line, 'var'=>$var, 'i'=>$i); |
|
| 4328 | + $action = ''; |
|
| 4329 | + $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 4330 | 4330 | } |
| 4331 | 4331 | } |
| 4332 | 4332 | else |
@@ -4359,35 +4359,35 @@ discard block |
||
| 4359 | 4359 | //var_dump($line); |
| 4360 | 4360 | if (!empty($line->date_start)) |
| 4361 | 4361 | { |
| 4362 | - $date_start=$line->date_start; |
|
| 4362 | + $date_start = $line->date_start; |
|
| 4363 | 4363 | } |
| 4364 | 4364 | else |
| 4365 | 4365 | { |
| 4366 | - $date_start=$line->date_debut_prevue; |
|
| 4367 | - if ($line->date_debut_reel) $date_start=$line->date_debut_reel; |
|
| 4366 | + $date_start = $line->date_debut_prevue; |
|
| 4367 | + if ($line->date_debut_reel) $date_start = $line->date_debut_reel; |
|
| 4368 | 4368 | } |
| 4369 | 4369 | if (!empty($line->date_end)) |
| 4370 | 4370 | { |
| 4371 | - $date_end=$line->date_end; |
|
| 4371 | + $date_end = $line->date_end; |
|
| 4372 | 4372 | } |
| 4373 | 4373 | else |
| 4374 | 4374 | { |
| 4375 | - $date_end=$line->date_fin_prevue; |
|
| 4376 | - if ($line->date_fin_reel) $date_end=$line->date_fin_reel; |
|
| 4375 | + $date_end = $line->date_fin_prevue; |
|
| 4376 | + if ($line->date_fin_reel) $date_end = $line->date_fin_reel; |
|
| 4377 | 4377 | } |
| 4378 | 4378 | |
| 4379 | 4379 | $this->tpl['id'] = $line->id; |
| 4380 | 4380 | |
| 4381 | 4381 | $this->tpl['label'] = ''; |
| 4382 | - if (! empty($line->fk_parent_line)) $this->tpl['label'].= img_picto('', 'rightarrow'); |
|
| 4382 | + if (!empty($line->fk_parent_line)) $this->tpl['label'] .= img_picto('', 'rightarrow'); |
|
| 4383 | 4383 | |
| 4384 | 4384 | if (($line->info_bits & 2) == 2) // TODO Not sure this is used for source object |
| 4385 | 4385 | { |
| 4386 | - $discount=new DiscountAbsolute($this->db); |
|
| 4386 | + $discount = new DiscountAbsolute($this->db); |
|
| 4387 | 4387 | $discount->fk_soc = $this->socid; |
| 4388 | - $this->tpl['label'].= $discount->getNomUrl(0, 'discount'); |
|
| 4388 | + $this->tpl['label'] .= $discount->getNomUrl(0, 'discount'); |
|
| 4389 | 4389 | } |
| 4390 | - elseif (! empty($line->fk_product)) |
|
| 4390 | + elseif (!empty($line->fk_product)) |
|
| 4391 | 4391 | { |
| 4392 | 4392 | $productstatic = new Product($this->db); |
| 4393 | 4393 | $productstatic->id = $line->fk_product; |
@@ -4398,53 +4398,53 @@ discard block |
||
| 4398 | 4398 | $productstatic = $line->product; |
| 4399 | 4399 | } |
| 4400 | 4400 | |
| 4401 | - $this->tpl['label'].= $productstatic->getNomUrl(1); |
|
| 4402 | - $this->tpl['label'].= ' - '.(! empty($line->label)?$line->label:$line->product_label); |
|
| 4401 | + $this->tpl['label'] .= $productstatic->getNomUrl(1); |
|
| 4402 | + $this->tpl['label'] .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); |
|
| 4403 | 4403 | // Dates |
| 4404 | 4404 | if ($line->product_type == 1 && ($date_start || $date_end)) |
| 4405 | 4405 | { |
| 4406 | - $this->tpl['label'].= get_date_range($date_start, $date_end); |
|
| 4406 | + $this->tpl['label'] .= get_date_range($date_start, $date_end); |
|
| 4407 | 4407 | } |
| 4408 | 4408 | } |
| 4409 | 4409 | else |
| 4410 | 4410 | { |
| 4411 | - $this->tpl['label'].= ($line->product_type == -1 ? ' ' : ($line->product_type == 1 ? img_object($langs->trans(''), 'service') : img_object($langs->trans(''), 'product'))); |
|
| 4411 | + $this->tpl['label'] .= ($line->product_type == -1 ? ' ' : ($line->product_type == 1 ? img_object($langs->trans(''), 'service') : img_object($langs->trans(''), 'product'))); |
|
| 4412 | 4412 | if (!empty($line->desc)) { |
| 4413 | - $this->tpl['label'].=$line->desc; |
|
| 4414 | - }else { |
|
| 4415 | - $this->tpl['label'].= ($line->label ? ' '.$line->label : ''); |
|
| 4413 | + $this->tpl['label'] .= $line->desc; |
|
| 4414 | + } else { |
|
| 4415 | + $this->tpl['label'] .= ($line->label ? ' '.$line->label : ''); |
|
| 4416 | 4416 | } |
| 4417 | 4417 | |
| 4418 | 4418 | // Dates |
| 4419 | 4419 | if ($line->product_type == 1 && ($date_start || $date_end)) |
| 4420 | 4420 | { |
| 4421 | - $this->tpl['label'].= get_date_range($date_start, $date_end); |
|
| 4421 | + $this->tpl['label'] .= get_date_range($date_start, $date_end); |
|
| 4422 | 4422 | } |
| 4423 | 4423 | } |
| 4424 | 4424 | |
| 4425 | - if (! empty($line->desc)) |
|
| 4425 | + if (!empty($line->desc)) |
|
| 4426 | 4426 | { |
| 4427 | 4427 | if ($line->desc == '(CREDIT_NOTE)') // TODO Not sure this is used for source object |
| 4428 | 4428 | { |
| 4429 | - $discount=new DiscountAbsolute($this->db); |
|
| 4429 | + $discount = new DiscountAbsolute($this->db); |
|
| 4430 | 4430 | $discount->fetch($line->fk_remise_except); |
| 4431 | 4431 | $this->tpl['description'] = $langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); |
| 4432 | 4432 | } |
| 4433 | 4433 | elseif ($line->desc == '(DEPOSIT)') // TODO Not sure this is used for source object |
| 4434 | 4434 | { |
| 4435 | - $discount=new DiscountAbsolute($this->db); |
|
| 4435 | + $discount = new DiscountAbsolute($this->db); |
|
| 4436 | 4436 | $discount->fetch($line->fk_remise_except); |
| 4437 | 4437 | $this->tpl['description'] = $langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); |
| 4438 | 4438 | } |
| 4439 | 4439 | elseif ($line->desc == '(EXCESS RECEIVED)') |
| 4440 | 4440 | { |
| 4441 | - $discount=new DiscountAbsolute($this->db); |
|
| 4441 | + $discount = new DiscountAbsolute($this->db); |
|
| 4442 | 4442 | $discount->fetch($line->fk_remise_except); |
| 4443 | 4443 | $this->tpl['description'] = $langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); |
| 4444 | 4444 | } |
| 4445 | 4445 | elseif ($line->desc == '(EXCESS PAID)') |
| 4446 | 4446 | { |
| 4447 | - $discount=new DiscountAbsolute($this->db); |
|
| 4447 | + $discount = new DiscountAbsolute($this->db); |
|
| 4448 | 4448 | $discount->fetch($line->fk_remise_except); |
| 4449 | 4449 | $this->tpl['description'] = $langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); |
| 4450 | 4450 | } |
@@ -4461,7 +4461,7 @@ discard block |
||
| 4461 | 4461 | // VAT Rate |
| 4462 | 4462 | $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); |
| 4463 | 4463 | $this->tpl['vat_rate'] .= (($line->info_bits & 1) == 1) ? '*' : ''; |
| 4464 | - if (! empty($line->vat_src_code) && ! preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'].=' ('.$line->vat_src_code.')'; |
|
| 4464 | + if (!empty($line->vat_src_code) && !preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'] .= ' ('.$line->vat_src_code.')'; |
|
| 4465 | 4465 | |
| 4466 | 4466 | $this->tpl['price'] = price($line->subprice); |
| 4467 | 4467 | $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); |
@@ -4470,13 +4470,13 @@ discard block |
||
| 4470 | 4470 | $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' '; |
| 4471 | 4471 | |
| 4472 | 4472 | // Is the line strike or not |
| 4473 | - $this->tpl['strike']=0; |
|
| 4474 | - if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) $this->tpl['strike']=1; |
|
| 4473 | + $this->tpl['strike'] = 0; |
|
| 4474 | + if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) $this->tpl['strike'] = 1; |
|
| 4475 | 4475 | |
| 4476 | 4476 | // Output template part (modules that overwrite templates must declare this into descriptor) |
| 4477 | 4477 | // Use global variables + $dateSelector + $seller and $buyer |
| 4478 | - $dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
|
| 4479 | - foreach($dirtpls as $module => $reldir) |
|
| 4478 | + $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
|
| 4479 | + foreach ($dirtpls as $module => $reldir) |
|
| 4480 | 4480 | { |
| 4481 | 4481 | if (!empty($module)) |
| 4482 | 4482 | { |
@@ -4488,9 +4488,9 @@ discard block |
||
| 4488 | 4488 | } |
| 4489 | 4489 | |
| 4490 | 4490 | if (empty($conf->file->strict_mode)) { |
| 4491 | - $res=@include $tpl; |
|
| 4491 | + $res = @include $tpl; |
|
| 4492 | 4492 | } else { |
| 4493 | - $res=include $tpl; // for debug |
|
| 4493 | + $res = include $tpl; // for debug |
|
| 4494 | 4494 | } |
| 4495 | 4495 | if ($res) break; |
| 4496 | 4496 | } |
@@ -4514,20 +4514,20 @@ discard block |
||
| 4514 | 4514 | $this->db->begin(); |
| 4515 | 4515 | |
| 4516 | 4516 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_resources ("; |
| 4517 | - $sql.= "resource_id"; |
|
| 4518 | - $sql.= ", resource_type"; |
|
| 4519 | - $sql.= ", element_id"; |
|
| 4520 | - $sql.= ", element_type"; |
|
| 4521 | - $sql.= ", busy"; |
|
| 4522 | - $sql.= ", mandatory"; |
|
| 4523 | - $sql.= ") VALUES ("; |
|
| 4524 | - $sql.= $resource_id; |
|
| 4525 | - $sql.= ", '".$this->db->escape($resource_type)."'"; |
|
| 4526 | - $sql.= ", '".$this->db->escape($this->id)."'"; |
|
| 4527 | - $sql.= ", '".$this->db->escape($this->element)."'"; |
|
| 4528 | - $sql.= ", '".$this->db->escape($busy)."'"; |
|
| 4529 | - $sql.= ", '".$this->db->escape($mandatory)."'"; |
|
| 4530 | - $sql.= ")"; |
|
| 4517 | + $sql .= "resource_id"; |
|
| 4518 | + $sql .= ", resource_type"; |
|
| 4519 | + $sql .= ", element_id"; |
|
| 4520 | + $sql .= ", element_type"; |
|
| 4521 | + $sql .= ", busy"; |
|
| 4522 | + $sql .= ", mandatory"; |
|
| 4523 | + $sql .= ") VALUES ("; |
|
| 4524 | + $sql .= $resource_id; |
|
| 4525 | + $sql .= ", '".$this->db->escape($resource_type)."'"; |
|
| 4526 | + $sql .= ", '".$this->db->escape($this->id)."'"; |
|
| 4527 | + $sql .= ", '".$this->db->escape($this->element)."'"; |
|
| 4528 | + $sql .= ", '".$this->db->escape($busy)."'"; |
|
| 4529 | + $sql .= ", '".$this->db->escape($mandatory)."'"; |
|
| 4530 | + $sql .= ")"; |
|
| 4531 | 4531 | |
| 4532 | 4532 | dol_syslog(get_class($this)."::add_element_resource", LOG_DEBUG); |
| 4533 | 4533 | if ($this->db->query($sql)) |
@@ -4537,7 +4537,7 @@ discard block |
||
| 4537 | 4537 | } |
| 4538 | 4538 | else |
| 4539 | 4539 | { |
| 4540 | - $this->error=$this->db->lasterror(); |
|
| 4540 | + $this->error = $this->db->lasterror(); |
|
| 4541 | 4541 | $this->db->rollback(); |
| 4542 | 4542 | return 0; |
| 4543 | 4543 | } |
@@ -4560,22 +4560,22 @@ discard block |
||
| 4560 | 4560 | $this->db->begin(); |
| 4561 | 4561 | |
| 4562 | 4562 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources"; |
| 4563 | - $sql.= " WHERE rowid=".$rowid; |
|
| 4563 | + $sql .= " WHERE rowid=".$rowid; |
|
| 4564 | 4564 | |
| 4565 | 4565 | dol_syslog(get_class($this)."::delete_resource", LOG_DEBUG); |
| 4566 | 4566 | |
| 4567 | - $resql=$this->db->query($sql); |
|
| 4568 | - if (! $resql) |
|
| 4567 | + $resql = $this->db->query($sql); |
|
| 4568 | + if (!$resql) |
|
| 4569 | 4569 | { |
| 4570 | - $this->error=$this->db->lasterror(); |
|
| 4570 | + $this->error = $this->db->lasterror(); |
|
| 4571 | 4571 | $this->db->rollback(); |
| 4572 | 4572 | return -1; |
| 4573 | 4573 | } |
| 4574 | 4574 | else |
| 4575 | 4575 | { |
| 4576 | - if (! $notrigger) |
|
| 4576 | + if (!$notrigger) |
|
| 4577 | 4577 | { |
| 4578 | - $result=$this->call_trigger(strtoupper($element).'_DELETE_RESOURCE', $user); |
|
| 4578 | + $result = $this->call_trigger(strtoupper($element).'_DELETE_RESOURCE', $user); |
|
| 4579 | 4579 | if ($result < 0) { $this->db->rollback(); return -1; } |
| 4580 | 4580 | } |
| 4581 | 4581 | $this->db->commit(); |
@@ -4594,8 +4594,8 @@ discard block |
||
| 4594 | 4594 | // Force a copy of this->lines, otherwise it will point to same object. |
| 4595 | 4595 | if (isset($this->lines) && is_array($this->lines)) |
| 4596 | 4596 | { |
| 4597 | - $nboflines=count($this->lines); |
|
| 4598 | - for($i=0; $i < $nboflines; $i++) |
|
| 4597 | + $nboflines = count($this->lines); |
|
| 4598 | + for ($i = 0; $i < $nboflines; $i++) |
|
| 4599 | 4599 | { |
| 4600 | 4600 | $this->lines[$i] = clone $this->lines[$i]; |
| 4601 | 4601 | } |
@@ -4619,48 +4619,48 @@ discard block |
||
| 4619 | 4619 | { |
| 4620 | 4620 | global $conf, $langs, $user, $hookmanager, $action; |
| 4621 | 4621 | |
| 4622 | - $srctemplatepath=''; |
|
| 4622 | + $srctemplatepath = ''; |
|
| 4623 | 4623 | |
| 4624 | - $parameters = array('modelspath'=>$modelspath,'modele'=>$modele,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'hidedesc'=>$hidedesc,'hideref'=>$hideref, 'moreparams'=>$moreparams); |
|
| 4624 | + $parameters = array('modelspath'=>$modelspath, 'modele'=>$modele, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'hidedesc'=>$hidedesc, 'hideref'=>$hideref, 'moreparams'=>$moreparams); |
|
| 4625 | 4625 | $reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
| 4626 | 4626 | |
| 4627 | 4627 | if (empty($reshook)) |
| 4628 | 4628 | { |
| 4629 | - dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null')); |
|
| 4629 | + dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); |
|
| 4630 | 4630 | |
| 4631 | 4631 | // Increase limit for PDF build |
| 4632 | - $err=error_reporting(); |
|
| 4632 | + $err = error_reporting(); |
|
| 4633 | 4633 | error_reporting(0); |
| 4634 | 4634 | @set_time_limit(120); |
| 4635 | 4635 | error_reporting($err); |
| 4636 | 4636 | |
| 4637 | 4637 | // If selected model is a filename template (then $modele="modelname" or "modelname:filename") |
| 4638 | - $tmp=explode(':', $modele, 2); |
|
| 4639 | - if (! empty($tmp[1])) |
|
| 4638 | + $tmp = explode(':', $modele, 2); |
|
| 4639 | + if (!empty($tmp[1])) |
|
| 4640 | 4640 | { |
| 4641 | - $modele=$tmp[0]; |
|
| 4642 | - $srctemplatepath=$tmp[1]; |
|
| 4641 | + $modele = $tmp[0]; |
|
| 4642 | + $srctemplatepath = $tmp[1]; |
|
| 4643 | 4643 | } |
| 4644 | 4644 | |
| 4645 | 4645 | // Search template files |
| 4646 | - $file=''; |
|
| 4647 | - $classname=''; |
|
| 4648 | - $filefound=0; |
|
| 4649 | - $dirmodels=array('/'); |
|
| 4650 | - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']); |
|
| 4651 | - foreach($dirmodels as $reldir) |
|
| 4646 | + $file = ''; |
|
| 4647 | + $classname = ''; |
|
| 4648 | + $filefound = 0; |
|
| 4649 | + $dirmodels = array('/'); |
|
| 4650 | + if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); |
|
| 4651 | + foreach ($dirmodels as $reldir) |
|
| 4652 | 4652 | { |
| 4653 | - foreach(array('doc','pdf') as $prefix) |
|
| 4653 | + foreach (array('doc', 'pdf') as $prefix) |
|
| 4654 | 4654 | { |
| 4655 | - if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php |
|
| 4655 | + if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php |
|
| 4656 | 4656 | else $file = $prefix."_".$modele.".modules.php"; |
| 4657 | 4657 | |
| 4658 | 4658 | // On verifie l'emplacement du modele |
| 4659 | - $file=dol_buildpath($reldir.$modelspath.$file, 0); |
|
| 4659 | + $file = dol_buildpath($reldir.$modelspath.$file, 0); |
|
| 4660 | 4660 | if (file_exists($file)) |
| 4661 | 4661 | { |
| 4662 | - $filefound=1; |
|
| 4663 | - $classname=$prefix.'_'.$modele; |
|
| 4662 | + $filefound = 1; |
|
| 4663 | + $classname = $prefix.'_'.$modele; |
|
| 4664 | 4664 | break; |
| 4665 | 4665 | } |
| 4666 | 4666 | } |
@@ -4670,7 +4670,7 @@ discard block |
||
| 4670 | 4670 | // If generator was found |
| 4671 | 4671 | if ($filefound) |
| 4672 | 4672 | { |
| 4673 | - global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. |
|
| 4673 | + global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. |
|
| 4674 | 4674 | |
| 4675 | 4675 | require_once $file; |
| 4676 | 4676 | |
@@ -4679,32 +4679,32 @@ discard block |
||
| 4679 | 4679 | // If generator is ODT, we must have srctemplatepath defined, if not we set it. |
| 4680 | 4680 | if ($obj->type == 'odt' && empty($srctemplatepath)) |
| 4681 | 4681 | { |
| 4682 | - $varfortemplatedir=$obj->scandir; |
|
| 4683 | - if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir)) |
|
| 4682 | + $varfortemplatedir = $obj->scandir; |
|
| 4683 | + if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir)) |
|
| 4684 | 4684 | { |
| 4685 | - $dirtoscan=$conf->global->$varfortemplatedir; |
|
| 4685 | + $dirtoscan = $conf->global->$varfortemplatedir; |
|
| 4686 | 4686 | |
| 4687 | - $listoffiles=array(); |
|
| 4687 | + $listoffiles = array(); |
|
| 4688 | 4688 | |
| 4689 | 4689 | // Now we add first model found in directories scanned |
| 4690 | - $listofdir=explode(',', $dirtoscan); |
|
| 4691 | - foreach($listofdir as $key => $tmpdir) |
|
| 4690 | + $listofdir = explode(',', $dirtoscan); |
|
| 4691 | + foreach ($listofdir as $key => $tmpdir) |
|
| 4692 | 4692 | { |
| 4693 | - $tmpdir=trim($tmpdir); |
|
| 4694 | - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); |
|
| 4695 | - if (! $tmpdir) { unset($listofdir[$key]); continue; } |
|
| 4693 | + $tmpdir = trim($tmpdir); |
|
| 4694 | + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); |
|
| 4695 | + if (!$tmpdir) { unset($listofdir[$key]); continue; } |
|
| 4696 | 4696 | if (is_dir($tmpdir)) |
| 4697 | 4697 | { |
| 4698 | - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); |
|
| 4699 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); |
|
| 4698 | + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); |
|
| 4699 | + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); |
|
| 4700 | 4700 | } |
| 4701 | 4701 | } |
| 4702 | 4702 | |
| 4703 | 4703 | if (count($listoffiles)) |
| 4704 | 4704 | { |
| 4705 | - foreach($listoffiles as $record) |
|
| 4705 | + foreach ($listoffiles as $record) |
|
| 4706 | 4706 | { |
| 4707 | - $srctemplatepath=$record['fullname']; |
|
| 4707 | + $srctemplatepath = $record['fullname']; |
|
| 4708 | 4708 | break; |
| 4709 | 4709 | } |
| 4710 | 4710 | } |
@@ -4712,27 +4712,27 @@ discard block |
||
| 4712 | 4712 | |
| 4713 | 4713 | if (empty($srctemplatepath)) |
| 4714 | 4714 | { |
| 4715 | - $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; |
|
| 4715 | + $this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; |
|
| 4716 | 4716 | return -1; |
| 4717 | 4717 | } |
| 4718 | 4718 | } |
| 4719 | 4719 | |
| 4720 | - if ($obj->type == 'odt' && ! empty($srctemplatepath)) |
|
| 4720 | + if ($obj->type == 'odt' && !empty($srctemplatepath)) |
|
| 4721 | 4721 | { |
| 4722 | - if (! dol_is_file($srctemplatepath)) |
|
| 4722 | + if (!dol_is_file($srctemplatepath)) |
|
| 4723 | 4723 | { |
| 4724 | - $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; |
|
| 4724 | + $this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; |
|
| 4725 | 4725 | return -1; |
| 4726 | 4726 | } |
| 4727 | 4727 | } |
| 4728 | 4728 | |
| 4729 | 4729 | // We save charset_output to restore it because write_file can change it if needed for |
| 4730 | 4730 | // output format that does not support UTF8. |
| 4731 | - $sav_charset_output=$outputlangs->charset_output; |
|
| 4731 | + $sav_charset_output = $outputlangs->charset_output; |
|
| 4732 | 4732 | |
| 4733 | 4733 | if (in_array(get_class($this), array('Adherent'))) |
| 4734 | 4734 | { |
| 4735 | - $arrayofrecords = array(); // The write_file of templates of adherent class need this var |
|
| 4735 | + $arrayofrecords = array(); // The write_file of templates of adherent class need this var |
|
| 4736 | 4736 | $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); |
| 4737 | 4737 | } |
| 4738 | 4738 | else |
@@ -4743,46 +4743,46 @@ discard block |
||
| 4743 | 4743 | |
| 4744 | 4744 | if ($resultwritefile > 0) |
| 4745 | 4745 | { |
| 4746 | - $outputlangs->charset_output=$sav_charset_output; |
|
| 4746 | + $outputlangs->charset_output = $sav_charset_output; |
|
| 4747 | 4747 | |
| 4748 | 4748 | // We delete old preview |
| 4749 | 4749 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 4750 | 4750 | dol_delete_preview($this); |
| 4751 | 4751 | |
| 4752 | 4752 | // Index file in database |
| 4753 | - if (! empty($obj->result['fullpath'])) |
|
| 4753 | + if (!empty($obj->result['fullpath'])) |
|
| 4754 | 4754 | { |
| 4755 | 4755 | $destfull = $obj->result['fullpath']; |
| 4756 | 4756 | $upload_dir = dirname($destfull); |
| 4757 | 4757 | $destfile = basename($destfull); |
| 4758 | 4758 | $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); |
| 4759 | 4759 | |
| 4760 | - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir |
|
| 4760 | + if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir |
|
| 4761 | 4761 | { |
| 4762 | 4762 | $filename = basename($destfile); |
| 4763 | 4763 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
| 4764 | 4764 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
| 4765 | 4765 | |
| 4766 | 4766 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
| 4767 | - $ecmfile=new EcmFiles($this->db); |
|
| 4768 | - $result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename); |
|
| 4767 | + $ecmfile = new EcmFiles($this->db); |
|
| 4768 | + $result = $ecmfile->fetch(0, '', ($rel_dir ? $rel_dir.'/' : '').$filename); |
|
| 4769 | 4769 | |
| 4770 | 4770 | // Set the public "share" key |
| 4771 | 4771 | $setsharekey = false; |
| 4772 | 4772 | if ($this->element == 'propal') |
| 4773 | 4773 | { |
| 4774 | - $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok |
|
| 4775 | - if ($useonlinesignature) $setsharekey=true; |
|
| 4776 | - if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; |
|
| 4774 | + $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok |
|
| 4775 | + if ($useonlinesignature) $setsharekey = true; |
|
| 4776 | + if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey = true; |
|
| 4777 | 4777 | } |
| 4778 | - if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { |
|
| 4779 | - $setsharekey=true; |
|
| 4778 | + if ($this->element == 'commande' && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { |
|
| 4779 | + $setsharekey = true; |
|
| 4780 | 4780 | } |
| 4781 | - if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { |
|
| 4782 | - $setsharekey=true; |
|
| 4781 | + if ($this->element == 'facture' && !empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { |
|
| 4782 | + $setsharekey = true; |
|
| 4783 | 4783 | } |
| 4784 | - if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { |
|
| 4785 | - $setsharekey=true; |
|
| 4784 | + if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { |
|
| 4785 | + $setsharekey = true; |
|
| 4786 | 4786 | } |
| 4787 | 4787 | |
| 4788 | 4788 | if ($setsharekey) { |
@@ -4795,11 +4795,11 @@ discard block |
||
| 4795 | 4795 | |
| 4796 | 4796 | if ($result > 0) |
| 4797 | 4797 | { |
| 4798 | - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content |
|
| 4798 | + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content |
|
| 4799 | 4799 | $ecmfile->fullpath_orig = ''; |
| 4800 | 4800 | $ecmfile->gen_or_uploaded = 'generated'; |
| 4801 | - $ecmfile->description = ''; // indexed content |
|
| 4802 | - $ecmfile->keyword = ''; // keyword content |
|
| 4801 | + $ecmfile->description = ''; // indexed content |
|
| 4802 | + $ecmfile->keyword = ''; // keyword content |
|
| 4803 | 4803 | $result = $ecmfile->update($user); |
| 4804 | 4804 | if ($result < 0) { |
| 4805 | 4805 | setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
@@ -4810,11 +4810,11 @@ discard block |
||
| 4810 | 4810 | $ecmfile->entity = $conf->entity; |
| 4811 | 4811 | $ecmfile->filepath = $rel_dir; |
| 4812 | 4812 | $ecmfile->filename = $filename; |
| 4813 | - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content |
|
| 4813 | + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content |
|
| 4814 | 4814 | $ecmfile->fullpath_orig = ''; |
| 4815 | 4815 | $ecmfile->gen_or_uploaded = 'generated'; |
| 4816 | - $ecmfile->description = ''; // indexed content |
|
| 4817 | - $ecmfile->keyword = ''; // keyword content |
|
| 4816 | + $ecmfile->description = ''; // indexed content |
|
| 4817 | + $ecmfile->keyword = ''; // keyword content |
|
| 4818 | 4818 | $ecmfile->src_object_type = $this->table_element; |
| 4819 | 4819 | $ecmfile->src_object_id = $this->id; |
| 4820 | 4820 | |
@@ -4830,15 +4830,15 @@ discard block |
||
| 4830 | 4830 | //var_dump($obj->update_main_doc_field);exit; |
| 4831 | 4831 | |
| 4832 | 4832 | // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) |
| 4833 | - $update_main_doc_field=0; |
|
| 4834 | - if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1; |
|
| 4835 | - if ($update_main_doc_field && ! empty($this->table_element)) |
|
| 4833 | + $update_main_doc_field = 0; |
|
| 4834 | + if (!empty($obj->update_main_doc_field)) $update_main_doc_field = 1; |
|
| 4835 | + if ($update_main_doc_field && !empty($this->table_element)) |
|
| 4836 | 4836 | { |
| 4837 | 4837 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; |
| 4838 | - $sql.= ' WHERE rowid = '.$this->id; |
|
| 4838 | + $sql .= ' WHERE rowid = '.$this->id; |
|
| 4839 | 4839 | |
| 4840 | 4840 | $resql = $this->db->query($sql); |
| 4841 | - if (! $resql) { |
|
| 4841 | + if (!$resql) { |
|
| 4842 | 4842 | dol_print_error($this->db); |
| 4843 | 4843 | } else { |
| 4844 | 4844 | $this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; |
@@ -4858,14 +4858,14 @@ discard block |
||
| 4858 | 4858 | } |
| 4859 | 4859 | else |
| 4860 | 4860 | { |
| 4861 | - $outputlangs->charset_output=$sav_charset_output; |
|
| 4861 | + $outputlangs->charset_output = $sav_charset_output; |
|
| 4862 | 4862 | dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); |
| 4863 | 4863 | return -1; |
| 4864 | 4864 | } |
| 4865 | 4865 | } |
| 4866 | 4866 | else |
| 4867 | 4867 | { |
| 4868 | - $this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file); |
|
| 4868 | + $this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file); |
|
| 4869 | 4869 | dol_print_error('', $this->error); |
| 4870 | 4870 | return -1; |
| 4871 | 4871 | } |
@@ -4884,9 +4884,9 @@ discard block |
||
| 4884 | 4884 | { |
| 4885 | 4885 | global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; |
| 4886 | 4886 | |
| 4887 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ... |
|
| 4887 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ... |
|
| 4888 | 4888 | |
| 4889 | - $file_osencoded=dol_osencode($file); |
|
| 4889 | + $file_osencoded = dol_osencode($file); |
|
| 4890 | 4890 | if (file_exists($file_osencoded)) |
| 4891 | 4891 | { |
| 4892 | 4892 | // Create small thumbs for company (Ratio is near 16/9) |
@@ -4925,16 +4925,16 @@ discard block |
||
| 4925 | 4925 | |
| 4926 | 4926 | if (isset($alternatevalue)) return $alternatevalue; |
| 4927 | 4927 | |
| 4928 | - $newelement=$this->element; |
|
| 4929 | - if ($newelement == 'facture') $newelement='invoice'; |
|
| 4930 | - if ($newelement == 'commande') $newelement='order'; |
|
| 4928 | + $newelement = $this->element; |
|
| 4929 | + if ($newelement == 'facture') $newelement = 'invoice'; |
|
| 4930 | + if ($newelement == 'commande') $newelement = 'order'; |
|
| 4931 | 4931 | if (empty($newelement)) |
| 4932 | 4932 | { |
| 4933 | 4933 | dol_syslog("Ask a default value using common method getDefaultCreateValueForField on an object with no property ->element defined. Return empty string.", LOG_WARNING); |
| 4934 | 4934 | return ''; |
| 4935 | 4935 | } |
| 4936 | 4936 | |
| 4937 | - $keyforfieldname=strtoupper($newelement.'_DEFAULT_'.$fieldname); |
|
| 4937 | + $keyforfieldname = strtoupper($newelement.'_DEFAULT_'.$fieldname); |
|
| 4938 | 4938 | //var_dump($keyforfieldname); |
| 4939 | 4939 | if (isset($conf->global->$keyforfieldname)) return $conf->global->$keyforfieldname; |
| 4940 | 4940 | |
@@ -4959,26 +4959,26 @@ discard block |
||
| 4959 | 4959 | public function call_trigger($trigger_name, $user) |
| 4960 | 4960 | { |
| 4961 | 4961 | // phpcs:enable |
| 4962 | - global $langs,$conf; |
|
| 4962 | + global $langs, $conf; |
|
| 4963 | 4963 | |
| 4964 | - if (! is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers. |
|
| 4964 | + if (!is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers. |
|
| 4965 | 4965 | include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; |
| 4966 | 4966 | $langs = new Translate('', $conf); |
| 4967 | 4967 | } |
| 4968 | 4968 | |
| 4969 | - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
| 4970 | - $interface=new Interfaces($this->db); |
|
| 4971 | - $result=$interface->run_triggers($trigger_name, $this, $user, $langs, $conf); |
|
| 4969 | + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; |
|
| 4970 | + $interface = new Interfaces($this->db); |
|
| 4971 | + $result = $interface->run_triggers($trigger_name, $this, $user, $langs, $conf); |
|
| 4972 | 4972 | |
| 4973 | 4973 | if ($result < 0) |
| 4974 | 4974 | { |
| 4975 | 4975 | if (!empty($this->errors)) |
| 4976 | 4976 | { |
| 4977 | - $this->errors=array_unique(array_merge($this->errors, $interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice. |
|
| 4977 | + $this->errors = array_unique(array_merge($this->errors, $interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice. |
|
| 4978 | 4978 | } |
| 4979 | 4979 | else |
| 4980 | 4980 | { |
| 4981 | - $this->errors=$interface->errors; |
|
| 4981 | + $this->errors = $interface->errors; |
|
| 4982 | 4982 | } |
| 4983 | 4983 | } |
| 4984 | 4984 | return $result; |
@@ -5002,19 +5002,19 @@ discard block |
||
| 5002 | 5002 | // phpcs:enable |
| 5003 | 5003 | global $extrafields; |
| 5004 | 5004 | |
| 5005 | - if (empty($rowid)) $rowid=$this->id; |
|
| 5005 | + if (empty($rowid)) $rowid = $this->id; |
|
| 5006 | 5006 | |
| 5007 | 5007 | // To avoid SQL errors. Probably not the better solution though |
| 5008 | 5008 | if (!$this->table_element) { |
| 5009 | 5009 | return 0; |
| 5010 | 5010 | } |
| 5011 | 5011 | |
| 5012 | - $this->array_options=array(); |
|
| 5012 | + $this->array_options = array(); |
|
| 5013 | 5013 | |
| 5014 | - if (! is_array($optionsArray)) |
|
| 5014 | + if (!is_array($optionsArray)) |
|
| 5015 | 5015 | { |
| 5016 | 5016 | // If $extrafields is not a known object, we initialize it. Best practice is to have $extrafields defined into card.php or list.php page. |
| 5017 | - if (! isset($extrafields) || ! is_object($extrafields)) |
|
| 5017 | + if (!isset($extrafields) || !is_object($extrafields)) |
|
| 5018 | 5018 | { |
| 5019 | 5019 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
| 5020 | 5020 | $extrafields = new ExtraFields($this->db); |
@@ -5025,7 +5025,7 @@ discard block |
||
| 5025 | 5025 | { |
| 5026 | 5026 | $extrafields->fetch_name_optionals_label($this->table_element); |
| 5027 | 5027 | } |
| 5028 | - $optionsArray = (! empty($extrafields->attributes[$this->table_element]['label'])?$extrafields->attributes[$this->table_element]['label']:null); |
|
| 5028 | + $optionsArray = (!empty($extrafields->attributes[$this->table_element]['label']) ? $extrafields->attributes[$this->table_element]['label'] : null); |
|
| 5029 | 5029 | } |
| 5030 | 5030 | else |
| 5031 | 5031 | { |
@@ -5044,18 +5044,18 @@ discard block |
||
| 5044 | 5044 | { |
| 5045 | 5045 | if (empty($extrafields->attributes[$this->table_element]['type'][$name]) || $extrafields->attributes[$this->table_element]['type'][$name] != 'separate') |
| 5046 | 5046 | { |
| 5047 | - $sql.= ", ".$name; |
|
| 5047 | + $sql .= ", ".$name; |
|
| 5048 | 5048 | } |
| 5049 | 5049 | } |
| 5050 | - $sql.= " FROM ".MAIN_DB_PREFIX.$table_element."_extrafields"; |
|
| 5051 | - $sql.= " WHERE fk_object = ".$rowid; |
|
| 5050 | + $sql .= " FROM ".MAIN_DB_PREFIX.$table_element."_extrafields"; |
|
| 5051 | + $sql .= " WHERE fk_object = ".$rowid; |
|
| 5052 | 5052 | |
| 5053 | 5053 | //dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); // Too verbose |
| 5054 | - $resql=$this->db->query($sql); |
|
| 5054 | + $resql = $this->db->query($sql); |
|
| 5055 | 5055 | if ($resql) |
| 5056 | 5056 | { |
| 5057 | 5057 | $this->array_options = array(); |
| 5058 | - $numrows=$this->db->num_rows($resql); |
|
| 5058 | + $numrows = $this->db->num_rows($resql); |
|
| 5059 | 5059 | if ($numrows) |
| 5060 | 5060 | { |
| 5061 | 5061 | $tab = $this->db->fetch_array($resql); |
@@ -5063,17 +5063,17 @@ discard block |
||
| 5063 | 5063 | foreach ($tab as $key => $value) |
| 5064 | 5064 | { |
| 5065 | 5065 | // Test fetch_array ! is_int($key) because fetch_array result is a mix table with Key as alpha and Key as int (depend db engine) |
| 5066 | - if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key)) |
|
| 5066 | + if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && !is_int($key)) |
|
| 5067 | 5067 | { |
| 5068 | 5068 | // we can add this attribute to object |
| 5069 | - if (! empty($extrafields) && in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date','datetime'))) |
|
| 5069 | + if (!empty($extrafields) && in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime'))) |
|
| 5070 | 5070 | { |
| 5071 | 5071 | //var_dump($extrafields->attributes[$this->table_element]['type'][$key]); |
| 5072 | - $this->array_options["options_".$key]=$this->db->jdate($value); |
|
| 5072 | + $this->array_options["options_".$key] = $this->db->jdate($value); |
|
| 5073 | 5073 | } |
| 5074 | 5074 | else |
| 5075 | 5075 | { |
| 5076 | - $this->array_options["options_".$key]=$value; |
|
| 5076 | + $this->array_options["options_".$key] = $value; |
|
| 5077 | 5077 | } |
| 5078 | 5078 | |
| 5079 | 5079 | //var_dump('key '.$key.' '.$value.' type='.$extrafields->attributes[$this->table_element]['type'][$key].' '.$this->array_options["options_".$key]); |
@@ -5082,7 +5082,7 @@ discard block |
||
| 5082 | 5082 | |
| 5083 | 5083 | // If field is a computed field, value must become result of compute |
| 5084 | 5084 | foreach ($tab as $key => $value) { |
| 5085 | - if (! empty($extrafields) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) |
|
| 5085 | + if (!empty($extrafields) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) |
|
| 5086 | 5086 | { |
| 5087 | 5087 | $this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0); |
| 5088 | 5088 | } |
@@ -5117,10 +5117,10 @@ discard block |
||
| 5117 | 5117 | |
| 5118 | 5118 | $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id; |
| 5119 | 5119 | dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG); |
| 5120 | - $resql=$this->db->query($sql_del); |
|
| 5121 | - if (! $resql) |
|
| 5120 | + $resql = $this->db->query($sql_del); |
|
| 5121 | + if (!$resql) |
|
| 5122 | 5122 | { |
| 5123 | - $this->error=$this->db->lasterror(); |
|
| 5123 | + $this->error = $this->db->lasterror(); |
|
| 5124 | 5124 | $this->db->rollback(); |
| 5125 | 5125 | return -1; |
| 5126 | 5126 | } |
@@ -5143,24 +5143,24 @@ discard block |
||
| 5143 | 5143 | */ |
| 5144 | 5144 | public function insertExtraFields($trigger = '', $userused = null) |
| 5145 | 5145 | { |
| 5146 | - global $conf,$langs,$user; |
|
| 5146 | + global $conf, $langs, $user; |
|
| 5147 | 5147 | |
| 5148 | - if (empty($userused)) $userused=$user; |
|
| 5148 | + if (empty($userused)) $userused = $user; |
|
| 5149 | 5149 | |
| 5150 | - $error=0; |
|
| 5150 | + $error = 0; |
|
| 5151 | 5151 | |
| 5152 | - if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used |
|
| 5152 | + if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used |
|
| 5153 | 5153 | |
| 5154 | - if (! empty($this->array_options)) |
|
| 5154 | + if (!empty($this->array_options)) |
|
| 5155 | 5155 | { |
| 5156 | 5156 | // Check parameters |
| 5157 | 5157 | $langs->load('admin'); |
| 5158 | 5158 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
| 5159 | 5159 | $extrafields = new ExtraFields($this->db); |
| 5160 | - $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); |
|
| 5160 | + $target_extrafields = $extrafields->fetch_name_optionals_label($this->table_element); |
|
| 5161 | 5161 | |
| 5162 | 5162 | //Eliminate copied source object extra_fields that do not exist in target object |
| 5163 | - $new_array_options=array(); |
|
| 5163 | + $new_array_options = array(); |
|
| 5164 | 5164 | foreach ($this->array_options as $key => $value) { |
| 5165 | 5165 | if (in_array(substr($key, 8), array_keys($target_extrafields))) // We remove the 'options_' from $key for test |
| 5166 | 5166 | $new_array_options[$key] = $value; |
@@ -5168,9 +5168,9 @@ discard block |
||
| 5168 | 5168 | $new_array_options['options_'.$key] = $value; |
| 5169 | 5169 | } |
| 5170 | 5170 | |
| 5171 | - foreach($new_array_options as $key => $value) |
|
| 5171 | + foreach ($new_array_options as $key => $value) |
|
| 5172 | 5172 | { |
| 5173 | - $attributeKey = substr($key, 8); // Remove 'options_' prefix |
|
| 5173 | + $attributeKey = substr($key, 8); // Remove 'options_' prefix |
|
| 5174 | 5174 | $attributeType = $extrafields->attributes[$this->table_element]['type'][$attributeKey]; |
| 5175 | 5175 | $attributeLabel = $extrafields->attributes[$this->table_element]['label'][$attributeKey]; |
| 5176 | 5176 | $attributeParam = $extrafields->attributes[$this->table_element]['param'][$attributeKey]; |
@@ -5180,13 +5180,13 @@ discard block |
||
| 5180 | 5180 | |
| 5181 | 5181 | if ($attributeRequired) |
| 5182 | 5182 | { |
| 5183 | - $mandatorypb=false; |
|
| 5184 | - if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb=true; |
|
| 5185 | - if ($this->array_options[$key] === '') $mandatorypb=true; |
|
| 5183 | + $mandatorypb = false; |
|
| 5184 | + if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb = true; |
|
| 5185 | + if ($this->array_options[$key] === '') $mandatorypb = true; |
|
| 5186 | 5186 | if ($mandatorypb) |
| 5187 | 5187 | { |
| 5188 | 5188 | dol_syslog("Mandatory extra field ".$key." is empty"); |
| 5189 | - $this->errors[]=$langs->trans('ErrorFieldRequired', $attributeLabel); |
|
| 5189 | + $this->errors[] = $langs->trans('ErrorFieldRequired', $attributeLabel); |
|
| 5190 | 5190 | return -1; |
| 5191 | 5191 | } |
| 5192 | 5192 | } |
@@ -5212,25 +5212,25 @@ discard block |
||
| 5212 | 5212 | switch ($attributeType) |
| 5213 | 5213 | { |
| 5214 | 5214 | case 'int': |
| 5215 | - if (!is_numeric($value) && $value!='') |
|
| 5215 | + if (!is_numeric($value) && $value != '') |
|
| 5216 | 5216 | { |
| 5217 | - $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel); |
|
| 5217 | + $this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel); |
|
| 5218 | 5218 | return -1; |
| 5219 | 5219 | } |
| 5220 | - elseif ($value=='') |
|
| 5220 | + elseif ($value == '') |
|
| 5221 | 5221 | { |
| 5222 | 5222 | $new_array_options[$key] = null; |
| 5223 | 5223 | } |
| 5224 | 5224 | break; |
| 5225 | 5225 | case 'double': |
| 5226 | 5226 | $value = price2num($value); |
| 5227 | - if (!is_numeric($value) && $value!='') |
|
| 5227 | + if (!is_numeric($value) && $value != '') |
|
| 5228 | 5228 | { |
| 5229 | 5229 | dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG); |
| 5230 | - $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel); |
|
| 5230 | + $this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel); |
|
| 5231 | 5231 | return -1; |
| 5232 | 5232 | } |
| 5233 | - elseif ($value=='') |
|
| 5233 | + elseif ($value == '') |
|
| 5234 | 5234 | { |
| 5235 | 5235 | $new_array_options[$key] = null; |
| 5236 | 5236 | } |
@@ -5244,12 +5244,12 @@ discard block |
||
| 5244 | 5244 | } |
| 5245 | 5245 | break;*/ |
| 5246 | 5246 | case 'password': |
| 5247 | - $algo=''; |
|
| 5247 | + $algo = ''; |
|
| 5248 | 5248 | if ($this->array_options[$key] != '' && is_array($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])) |
| 5249 | 5249 | { |
| 5250 | 5250 | // If there is an encryption choice, we use it to crypt data before insert |
| 5251 | 5251 | $tmparrays = array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options']); |
| 5252 | - $algo=reset($tmparrays); |
|
| 5252 | + $algo = reset($tmparrays); |
|
| 5253 | 5253 | if ($algo != '') |
| 5254 | 5254 | { |
| 5255 | 5255 | //global $action; // $action may be 'create', 'update', 'update_extras'... |
@@ -5260,7 +5260,7 @@ discard block |
||
| 5260 | 5260 | //var_dump($this->oldcopy->array_options[$key]); var_dump($this->array_options[$key]); |
| 5261 | 5261 | if ($this->array_options[$key] == $this->oldcopy->array_options[$key]) // If old value crypted in database is same than submited new value, it means we don't change it, so we don't update. |
| 5262 | 5262 | { |
| 5263 | - $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
|
| 5263 | + $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
|
| 5264 | 5264 | } |
| 5265 | 5265 | else |
| 5266 | 5266 | { |
@@ -5271,7 +5271,7 @@ discard block |
||
| 5271 | 5271 | } |
| 5272 | 5272 | else |
| 5273 | 5273 | { |
| 5274 | - $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
|
| 5274 | + $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
|
| 5275 | 5275 | } |
| 5276 | 5276 | } |
| 5277 | 5277 | } |
@@ -5286,13 +5286,13 @@ discard block |
||
| 5286 | 5286 | case 'date': |
| 5287 | 5287 | case 'datetime': |
| 5288 | 5288 | // If data is a string instead of a timestamp, we convert it |
| 5289 | - if (! is_int($this->array_options[$key])) { |
|
| 5289 | + if (!is_int($this->array_options[$key])) { |
|
| 5290 | 5290 | $this->array_options[$key] = strtotime($this->array_options[$key]); |
| 5291 | 5291 | } |
| 5292 | 5292 | $new_array_options[$key] = $this->db->idate($this->array_options[$key]); |
| 5293 | 5293 | break; |
| 5294 | 5294 | case 'link': |
| 5295 | - $param_list=array_keys($attributeParam['options']); |
|
| 5295 | + $param_list = array_keys($attributeParam['options']); |
|
| 5296 | 5296 | // 0 : ObjectName |
| 5297 | 5297 | // 1 : classPath |
| 5298 | 5298 | $InfoFieldList = explode(":", $param_list[0]); |
@@ -5301,18 +5301,18 @@ discard block |
||
| 5301 | 5301 | { |
| 5302 | 5302 | if ($value == '-1') // -1 is key for no defined in combo list of objects |
| 5303 | 5303 | { |
| 5304 | - $new_array_options[$key]=''; |
|
| 5304 | + $new_array_options[$key] = ''; |
|
| 5305 | 5305 | } |
| 5306 | 5306 | elseif ($value) |
| 5307 | 5307 | { |
| 5308 | 5308 | $object = new $InfoFieldList[0]($this->db); |
| 5309 | - if (is_numeric($value)) $res=$object->fetch($value); |
|
| 5310 | - else $res=$object->fetch('', $value); |
|
| 5309 | + if (is_numeric($value)) $res = $object->fetch($value); |
|
| 5310 | + else $res = $object->fetch('', $value); |
|
| 5311 | 5311 | |
| 5312 | - if ($res > 0) $new_array_options[$key]=$object->id; |
|
| 5312 | + if ($res > 0) $new_array_options[$key] = $object->id; |
|
| 5313 | 5313 | else |
| 5314 | 5314 | { |
| 5315 | - $this->error="Id/Ref '".$value."' for object '".$object->element."' not found"; |
|
| 5315 | + $this->error = "Id/Ref '".$value."' for object '".$object->element."' not found"; |
|
| 5316 | 5316 | $this->db->rollback(); |
| 5317 | 5317 | return -1; |
| 5318 | 5318 | } |
@@ -5337,70 +5337,70 @@ discard block |
||
| 5337 | 5337 | $this->db->query($sql_del); |
| 5338 | 5338 | |
| 5339 | 5339 | $sql = "INSERT INTO ".MAIN_DB_PREFIX.$table_element."_extrafields (fk_object"; |
| 5340 | - foreach($new_array_options as $key => $value) |
|
| 5340 | + foreach ($new_array_options as $key => $value) |
|
| 5341 | 5341 | { |
| 5342 | - $attributeKey = substr($key, 8); // Remove 'options_' prefix |
|
| 5342 | + $attributeKey = substr($key, 8); // Remove 'options_' prefix |
|
| 5343 | 5343 | // Add field of attribut |
| 5344 | 5344 | if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator |
| 5345 | - $sql.=",".$attributeKey; |
|
| 5345 | + $sql .= ",".$attributeKey; |
|
| 5346 | 5346 | } |
| 5347 | 5347 | // We must insert a default value for fields for other entities that are mandatory to avoid not null error |
| 5348 | 5348 | if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) |
| 5349 | 5349 | { |
| 5350 | - foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) |
|
| 5350 | + foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) |
|
| 5351 | 5351 | { |
| 5352 | - if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously |
|
| 5352 | + if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously |
|
| 5353 | 5353 | { |
| 5354 | - $sql.=",".$tmpkey; |
|
| 5354 | + $sql .= ",".$tmpkey; |
|
| 5355 | 5355 | } |
| 5356 | 5356 | } |
| 5357 | 5357 | } |
| 5358 | 5358 | $sql .= ") VALUES (".$this->id; |
| 5359 | 5359 | |
| 5360 | - foreach($new_array_options as $key => $value) |
|
| 5360 | + foreach ($new_array_options as $key => $value) |
|
| 5361 | 5361 | { |
| 5362 | - $attributeKey = substr($key, 8); // Remove 'options_' prefix |
|
| 5362 | + $attributeKey = substr($key, 8); // Remove 'options_' prefix |
|
| 5363 | 5363 | // Add field of attribute |
| 5364 | 5364 | if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator) |
| 5365 | 5365 | { |
| 5366 | 5366 | if ($new_array_options[$key] != '') |
| 5367 | 5367 | { |
| 5368 | - $sql.=",'".$this->db->escape($new_array_options[$key])."'"; |
|
| 5368 | + $sql .= ",'".$this->db->escape($new_array_options[$key])."'"; |
|
| 5369 | 5369 | } |
| 5370 | 5370 | else |
| 5371 | 5371 | { |
| 5372 | - $sql.=",null"; |
|
| 5372 | + $sql .= ",null"; |
|
| 5373 | 5373 | } |
| 5374 | 5374 | } |
| 5375 | 5375 | } |
| 5376 | 5376 | // We must insert a default value for fields for other entities that are mandatory to avoid not null error |
| 5377 | 5377 | if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) |
| 5378 | 5378 | { |
| 5379 | - foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) |
|
| 5379 | + foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) |
|
| 5380 | 5380 | { |
| 5381 | - if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously |
|
| 5381 | + if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously |
|
| 5382 | 5382 | { |
| 5383 | - if (in_array($tmpval, array('int', 'double'))) $sql.=", 0"; |
|
| 5384 | - else $sql.=", ''"; |
|
| 5383 | + if (in_array($tmpval, array('int', 'double'))) $sql .= ", 0"; |
|
| 5384 | + else $sql .= ", ''"; |
|
| 5385 | 5385 | } |
| 5386 | 5386 | } |
| 5387 | 5387 | } |
| 5388 | 5388 | |
| 5389 | - $sql.=")"; |
|
| 5389 | + $sql .= ")"; |
|
| 5390 | 5390 | |
| 5391 | 5391 | $resql = $this->db->query($sql); |
| 5392 | 5392 | |
| 5393 | - if (! $resql) |
|
| 5393 | + if (!$resql) |
|
| 5394 | 5394 | { |
| 5395 | - $this->error=$this->db->lasterror(); |
|
| 5395 | + $this->error = $this->db->lasterror(); |
|
| 5396 | 5396 | $error++; |
| 5397 | 5397 | } |
| 5398 | 5398 | |
| 5399 | - if (! $error && $trigger) |
|
| 5399 | + if (!$error && $trigger) |
|
| 5400 | 5400 | { |
| 5401 | 5401 | // Call trigger |
| 5402 | - $this->context=array('extrafieldaddupdate'=>1); |
|
| 5403 | - $result=$this->call_trigger($trigger, $userused); |
|
| 5402 | + $this->context = array('extrafieldaddupdate'=>1); |
|
| 5403 | + $result = $this->call_trigger($trigger, $userused); |
|
| 5404 | 5404 | if ($result < 0) $error++; |
| 5405 | 5405 | // End call trigger |
| 5406 | 5406 | } |
@@ -5431,23 +5431,23 @@ discard block |
||
| 5431 | 5431 | */ |
| 5432 | 5432 | public function updateExtraField($key, $trigger = null, $userused = null) |
| 5433 | 5433 | { |
| 5434 | - global $conf,$langs,$user; |
|
| 5434 | + global $conf, $langs, $user; |
|
| 5435 | 5435 | |
| 5436 | - if (empty($userused)) $userused=$user; |
|
| 5436 | + if (empty($userused)) $userused = $user; |
|
| 5437 | 5437 | |
| 5438 | - $error=0; |
|
| 5438 | + $error = 0; |
|
| 5439 | 5439 | |
| 5440 | - if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used |
|
| 5440 | + if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used |
|
| 5441 | 5441 | |
| 5442 | - if (! empty($this->array_options) && isset($this->array_options["options_".$key])) |
|
| 5442 | + if (!empty($this->array_options) && isset($this->array_options["options_".$key])) |
|
| 5443 | 5443 | { |
| 5444 | 5444 | // Check parameters |
| 5445 | 5445 | $langs->load('admin'); |
| 5446 | 5446 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
| 5447 | 5447 | $extrafields = new ExtraFields($this->db); |
| 5448 | - $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); |
|
| 5448 | + $target_extrafields = $extrafields->fetch_name_optionals_label($this->table_element); |
|
| 5449 | 5449 | |
| 5450 | - $value=$this->array_options["options_".$key]; |
|
| 5450 | + $value = $this->array_options["options_".$key]; |
|
| 5451 | 5451 | |
| 5452 | 5452 | $attributeType = $extrafields->attributes[$this->table_element]['type'][$key]; |
| 5453 | 5453 | $attributeLabel = $extrafields->attributes[$this->table_element]['label'][$key]; |
@@ -5460,25 +5460,25 @@ discard block |
||
| 5460 | 5460 | switch ($attributeType) |
| 5461 | 5461 | { |
| 5462 | 5462 | case 'int': |
| 5463 | - if (!is_numeric($value) && $value!='') |
|
| 5463 | + if (!is_numeric($value) && $value != '') |
|
| 5464 | 5464 | { |
| 5465 | - $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel); |
|
| 5465 | + $this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel); |
|
| 5466 | 5466 | return -1; |
| 5467 | 5467 | } |
| 5468 | - elseif ($value=='') |
|
| 5468 | + elseif ($value == '') |
|
| 5469 | 5469 | { |
| 5470 | 5470 | $this->array_options["options_".$key] = null; |
| 5471 | 5471 | } |
| 5472 | 5472 | break; |
| 5473 | 5473 | case 'double': |
| 5474 | 5474 | $value = price2num($value); |
| 5475 | - if (!is_numeric($value) && $value!='') |
|
| 5475 | + if (!is_numeric($value) && $value != '') |
|
| 5476 | 5476 | { |
| 5477 | 5477 | dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG); |
| 5478 | - $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel); |
|
| 5478 | + $this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel); |
|
| 5479 | 5479 | return -1; |
| 5480 | 5480 | } |
| 5481 | - elseif ($value=='') |
|
| 5481 | + elseif ($value == '') |
|
| 5482 | 5482 | { |
| 5483 | 5483 | $this->array_options["options_".$key] = null; |
| 5484 | 5484 | } |
@@ -5495,13 +5495,13 @@ discard block |
||
| 5495 | 5495 | $this->array_options["options_".$key] = price2num($this->array_options["options_".$key]); |
| 5496 | 5496 | break; |
| 5497 | 5497 | case 'date': |
| 5498 | - $this->array_options["options_".$key]=$this->db->idate($this->array_options["options_".$key]); |
|
| 5498 | + $this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]); |
|
| 5499 | 5499 | break; |
| 5500 | 5500 | case 'datetime': |
| 5501 | - $this->array_options["options_".$key]=$this->db->idate($this->array_options["options_".$key]); |
|
| 5501 | + $this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]); |
|
| 5502 | 5502 | break; |
| 5503 | 5503 | case 'link': |
| 5504 | - $param_list=array_keys($attributeParam['options']); |
|
| 5504 | + $param_list = array_keys($attributeParam['options']); |
|
| 5505 | 5505 | // 0 : ObjectName |
| 5506 | 5506 | // 1 : classPath |
| 5507 | 5507 | $InfoFieldList = explode(":", $param_list[0]); |
@@ -5510,7 +5510,7 @@ discard block |
||
| 5510 | 5510 | { |
| 5511 | 5511 | $object = new $InfoFieldList[0]($this->db); |
| 5512 | 5512 | $object->fetch(0, $value); |
| 5513 | - $this->array_options["options_".$key]=$object->id; |
|
| 5513 | + $this->array_options["options_".$key] = $object->id; |
|
| 5514 | 5514 | } |
| 5515 | 5515 | break; |
| 5516 | 5516 | } |
@@ -5519,24 +5519,24 @@ discard block |
||
| 5519 | 5519 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key."='".$this->db->escape($this->array_options["options_".$key])."'"; |
| 5520 | 5520 | $sql .= " WHERE fk_object = ".$this->id; |
| 5521 | 5521 | $resql = $this->db->query($sql); |
| 5522 | - if (! $resql) |
|
| 5522 | + if (!$resql) |
|
| 5523 | 5523 | { |
| 5524 | 5524 | $error++; |
| 5525 | - $this->error=$this->db->lasterror(); |
|
| 5525 | + $this->error = $this->db->lasterror(); |
|
| 5526 | 5526 | } |
| 5527 | 5527 | |
| 5528 | - if (! $error && $trigger) |
|
| 5528 | + if (!$error && $trigger) |
|
| 5529 | 5529 | { |
| 5530 | 5530 | // Call trigger |
| 5531 | - $this->context=array('extrafieldupdate'=>1); |
|
| 5532 | - $result=$this->call_trigger($trigger, $userused); |
|
| 5531 | + $this->context = array('extrafieldupdate'=>1); |
|
| 5532 | + $result = $this->call_trigger($trigger, $userused); |
|
| 5533 | 5533 | if ($result < 0) $error++; |
| 5534 | 5534 | // End call trigger |
| 5535 | 5535 | } |
| 5536 | 5536 | |
| 5537 | 5537 | if ($error) |
| 5538 | 5538 | { |
| 5539 | - dol_syslog(get_class($this) . "::".__METHOD__ . $this->error, LOG_ERR); |
|
| 5539 | + dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR); |
|
| 5540 | 5540 | $this->db->rollback(); |
| 5541 | 5541 | return -1; |
| 5542 | 5542 | } |
@@ -5565,73 +5565,73 @@ discard block |
||
| 5565 | 5565 | */ |
| 5566 | 5566 | public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0) |
| 5567 | 5567 | { |
| 5568 | - global $conf,$langs,$form; |
|
| 5568 | + global $conf, $langs, $form; |
|
| 5569 | 5569 | |
| 5570 | - if (! is_object($form)) |
|
| 5570 | + if (!is_object($form)) |
|
| 5571 | 5571 | { |
| 5572 | 5572 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
| 5573 | - $form=new Form($this->db); |
|
| 5573 | + $form = new Form($this->db); |
|
| 5574 | 5574 | } |
| 5575 | 5575 | |
| 5576 | - $val=$this->fields[$key]; |
|
| 5576 | + $val = $this->fields[$key]; |
|
| 5577 | 5577 | |
| 5578 | - $out=''; |
|
| 5579 | - $type=''; |
|
| 5578 | + $out = ''; |
|
| 5579 | + $type = ''; |
|
| 5580 | 5580 | $param = array(); |
| 5581 | - $param['options']=array(); |
|
| 5582 | - $reg=array(); |
|
| 5581 | + $param['options'] = array(); |
|
| 5582 | + $reg = array(); |
|
| 5583 | 5583 | $size = $this->fields[$key]['size']; |
| 5584 | 5584 | // Because we work on extrafields |
| 5585 | - if (preg_match('/^(integer|link):(.*):(.*):(.*):(.*)/i', $val['type'], $reg)){ |
|
| 5586 | - $param['options']=array($reg[2].':'.$reg[3].':'.$reg[4].':'.$reg[5] => 'N'); |
|
| 5587 | - $type ='link'; |
|
| 5588 | - } elseif (preg_match('/^(integer|link):(.*):(.*):(.*)/i', $val['type'], $reg)){ |
|
| 5589 | - $param['options']=array($reg[2].':'.$reg[3].':'.$reg[4] => 'N'); |
|
| 5590 | - $type ='link'; |
|
| 5591 | - } elseif (preg_match('/^(integer|link):(.*):(.*)/i', $val['type'], $reg)){ |
|
| 5592 | - $param['options']=array($reg[2].':'.$reg[3] => 'N'); |
|
| 5593 | - $type ='link'; |
|
| 5594 | - } elseif(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { |
|
| 5595 | - $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4] => 'N'); |
|
| 5596 | - $type ='sellist'; |
|
| 5597 | - } elseif(preg_match('/varchar\((\d+)\)/', $val['type'], $reg)) { |
|
| 5598 | - $param['options']=array(); |
|
| 5599 | - $type ='varchar'; |
|
| 5600 | - $size=$reg[1]; |
|
| 5601 | - } elseif(preg_match('/varchar/', $val['type'])) { |
|
| 5602 | - $param['options']=array(); |
|
| 5603 | - $type ='varchar'; |
|
| 5604 | - } elseif(is_array($this->fields[$key]['arrayofkeyval'])) { |
|
| 5605 | - $param['options']=$this->fields[$key]['arrayofkeyval']; |
|
| 5606 | - $type ='select'; |
|
| 5585 | + if (preg_match('/^(integer|link):(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { |
|
| 5586 | + $param['options'] = array($reg[2].':'.$reg[3].':'.$reg[4].':'.$reg[5] => 'N'); |
|
| 5587 | + $type = 'link'; |
|
| 5588 | + } elseif (preg_match('/^(integer|link):(.*):(.*):(.*)/i', $val['type'], $reg)) { |
|
| 5589 | + $param['options'] = array($reg[2].':'.$reg[3].':'.$reg[4] => 'N'); |
|
| 5590 | + $type = 'link'; |
|
| 5591 | + } elseif (preg_match('/^(integer|link):(.*):(.*)/i', $val['type'], $reg)) { |
|
| 5592 | + $param['options'] = array($reg[2].':'.$reg[3] => 'N'); |
|
| 5593 | + $type = 'link'; |
|
| 5594 | + } elseif (preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { |
|
| 5595 | + $param['options'] = array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4] => 'N'); |
|
| 5596 | + $type = 'sellist'; |
|
| 5597 | + } elseif (preg_match('/varchar\((\d+)\)/', $val['type'], $reg)) { |
|
| 5598 | + $param['options'] = array(); |
|
| 5599 | + $type = 'varchar'; |
|
| 5600 | + $size = $reg[1]; |
|
| 5601 | + } elseif (preg_match('/varchar/', $val['type'])) { |
|
| 5602 | + $param['options'] = array(); |
|
| 5603 | + $type = 'varchar'; |
|
| 5604 | + } elseif (is_array($this->fields[$key]['arrayofkeyval'])) { |
|
| 5605 | + $param['options'] = $this->fields[$key]['arrayofkeyval']; |
|
| 5606 | + $type = 'select'; |
|
| 5607 | 5607 | } else { |
| 5608 | - $param['options']=array(); |
|
| 5609 | - $type =$this->fields[$key]['type']; |
|
| 5608 | + $param['options'] = array(); |
|
| 5609 | + $type = $this->fields[$key]['type']; |
|
| 5610 | 5610 | } |
| 5611 | 5611 | |
| 5612 | - $label=$this->fields[$key]['label']; |
|
| 5612 | + $label = $this->fields[$key]['label']; |
|
| 5613 | 5613 | //$elementtype=$this->fields[$key]['elementtype']; // Seems not used |
| 5614 | - $default=$this->fields[$key]['default']; |
|
| 5615 | - $computed=$this->fields[$key]['computed']; |
|
| 5616 | - $unique=$this->fields[$key]['unique']; |
|
| 5617 | - $required=$this->fields[$key]['required']; |
|
| 5614 | + $default = $this->fields[$key]['default']; |
|
| 5615 | + $computed = $this->fields[$key]['computed']; |
|
| 5616 | + $unique = $this->fields[$key]['unique']; |
|
| 5617 | + $required = $this->fields[$key]['required']; |
|
| 5618 | 5618 | |
| 5619 | - $langfile=$this->fields[$key]['langfile']; |
|
| 5620 | - $list=$this->fields[$key]['list']; |
|
| 5621 | - $hidden=(in_array(abs($this->fields[$key]['visible']), array(0,2)) ? 1 : 0); |
|
| 5619 | + $langfile = $this->fields[$key]['langfile']; |
|
| 5620 | + $list = $this->fields[$key]['list']; |
|
| 5621 | + $hidden = (in_array(abs($this->fields[$key]['visible']), array(0, 2)) ? 1 : 0); |
|
| 5622 | 5622 | |
| 5623 | 5623 | $objectid = $this->id; |
| 5624 | 5624 | |
| 5625 | 5625 | |
| 5626 | 5626 | if ($computed) |
| 5627 | 5627 | { |
| 5628 | - if (! preg_match('/^search_/', $keyprefix)) return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>'; |
|
| 5628 | + if (!preg_match('/^search_/', $keyprefix)) return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>'; |
|
| 5629 | 5629 | else return ''; |
| 5630 | 5630 | } |
| 5631 | 5631 | |
| 5632 | 5632 | |
| 5633 | 5633 | // Set value of $morecss. For this, we use in priority showsize from parameters, then $val['css'] then autodefine |
| 5634 | - if (empty($morecss) && ! empty($val['css'])) |
|
| 5634 | + if (empty($morecss) && !empty($val['css'])) |
|
| 5635 | 5635 | { |
| 5636 | 5636 | $morecss = $val['css']; |
| 5637 | 5637 | } |
@@ -5645,15 +5645,15 @@ discard block |
||
| 5645 | 5645 | { |
| 5646 | 5646 | $morecss = 'minwidth200imp'; |
| 5647 | 5647 | } |
| 5648 | - elseif (in_array($type, array('int','integer','price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type)) |
|
| 5648 | + elseif (in_array($type, array('int', 'integer', 'price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type)) |
|
| 5649 | 5649 | { |
| 5650 | 5650 | $morecss = 'maxwidth75'; |
| 5651 | 5651 | } elseif ($type == 'url') { |
| 5652 | - $morecss='minwidth400'; |
|
| 5652 | + $morecss = 'minwidth400'; |
|
| 5653 | 5653 | } |
| 5654 | 5654 | elseif ($type == 'boolean') |
| 5655 | 5655 | { |
| 5656 | - $morecss=''; |
|
| 5656 | + $morecss = ''; |
|
| 5657 | 5657 | } |
| 5658 | 5658 | else |
| 5659 | 5659 | { |
@@ -5672,10 +5672,10 @@ discard block |
||
| 5672 | 5672 | } |
| 5673 | 5673 | } |
| 5674 | 5674 | |
| 5675 | - if (in_array($type, array('date','datetime'))) |
|
| 5675 | + if (in_array($type, array('date', 'datetime'))) |
|
| 5676 | 5676 | { |
| 5677 | - $tmp=explode(',', $size); |
|
| 5678 | - $newsize=$tmp[0]; |
|
| 5677 | + $tmp = explode(',', $size); |
|
| 5678 | + $newsize = $tmp[0]; |
|
| 5679 | 5679 | |
| 5680 | 5680 | $showtime = in_array($type, array('datetime')) ? 1 : 0; |
| 5681 | 5681 | |
@@ -5685,193 +5685,193 @@ discard block |
||
| 5685 | 5685 | // TODO Must also support $moreparam |
| 5686 | 5686 | $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); |
| 5687 | 5687 | } |
| 5688 | - elseif (in_array($type, array('int','integer'))) |
|
| 5688 | + elseif (in_array($type, array('int', 'integer'))) |
|
| 5689 | 5689 | { |
| 5690 | - $tmp=explode(',', $size); |
|
| 5691 | - $newsize=$tmp[0]; |
|
| 5692 | - $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>'; |
|
| 5690 | + $tmp = explode(',', $size); |
|
| 5691 | + $newsize = $tmp[0]; |
|
| 5692 | + $out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').'>'; |
|
| 5693 | 5693 | } |
| 5694 | 5694 | elseif (in_array($type, array('real'))) |
| 5695 | 5695 | { |
| 5696 | - $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>'; |
|
| 5696 | + $out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').'>'; |
|
| 5697 | 5697 | } |
| 5698 | 5698 | elseif (preg_match('/varchar/', $type)) |
| 5699 | 5699 | { |
| 5700 | - $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>'; |
|
| 5700 | + $out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').'>'; |
|
| 5701 | 5701 | } |
| 5702 | 5702 | elseif (in_array($type, array('mail', 'phone', 'url'))) |
| 5703 | 5703 | { |
| 5704 | - $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>'; |
|
| 5704 | + $out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').'>'; |
|
| 5705 | 5705 | } |
| 5706 | 5706 | elseif ($type == 'text') |
| 5707 | 5707 | { |
| 5708 | - if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 5708 | + if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 5709 | 5709 | { |
| 5710 | 5710 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 5711 | - $doleditor=new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); |
|
| 5712 | - $out=$doleditor->Create(1); |
|
| 5711 | + $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); |
|
| 5712 | + $out = $doleditor->Create(1); |
|
| 5713 | 5713 | } |
| 5714 | 5714 | else |
| 5715 | 5715 | { |
| 5716 | - $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>'; |
|
| 5716 | + $out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').'>'; |
|
| 5717 | 5717 | } |
| 5718 | 5718 | } |
| 5719 | 5719 | elseif ($type == 'html') |
| 5720 | 5720 | { |
| 5721 | - if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 5721 | + if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 5722 | 5722 | { |
| 5723 | 5723 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 5724 | - $doleditor=new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, ! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); |
|
| 5725 | - $out=$doleditor->Create(1); |
|
| 5724 | + $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, !empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); |
|
| 5725 | + $out = $doleditor->Create(1); |
|
| 5726 | 5726 | } |
| 5727 | 5727 | else |
| 5728 | 5728 | { |
| 5729 | - $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>'; |
|
| 5729 | + $out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').'>'; |
|
| 5730 | 5730 | } |
| 5731 | 5731 | } |
| 5732 | 5732 | elseif ($type == 'boolean') |
| 5733 | 5733 | { |
| 5734 | - $checked=''; |
|
| 5734 | + $checked = ''; |
|
| 5735 | 5735 | if (!empty($value)) { |
| 5736 | - $checked=' checked value="1" '; |
|
| 5736 | + $checked = ' checked value="1" '; |
|
| 5737 | 5737 | } else { |
| 5738 | - $checked=' value="1" '; |
|
| 5738 | + $checked = ' value="1" '; |
|
| 5739 | 5739 | } |
| 5740 | - $out='<input type="checkbox" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam?$moreparam:'').'>'; |
|
| 5740 | + $out = '<input type="checkbox" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam ? $moreparam : '').'>'; |
|
| 5741 | 5741 | } |
| 5742 | 5742 | elseif ($type == 'price') |
| 5743 | 5743 | { |
| 5744 | 5744 | if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. |
| 5745 | - $value=price($value); |
|
| 5745 | + $value = price($value); |
|
| 5746 | 5746 | } |
| 5747 | - $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency); |
|
| 5747 | + $out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam ? $moreparam : '').'> '.$langs->getCurrencySymbol($conf->currency); |
|
| 5748 | 5748 | } |
| 5749 | 5749 | elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type)) |
| 5750 | 5750 | { |
| 5751 | 5751 | if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. |
| 5752 | - $value=price($value); |
|
| 5752 | + $value = price($value); |
|
| 5753 | 5753 | } |
| 5754 | - $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '; |
|
| 5754 | + $out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam ? $moreparam : '').'> '; |
|
| 5755 | 5755 | } |
| 5756 | 5756 | elseif ($type == 'select') |
| 5757 | 5757 | { |
| 5758 | 5758 | $out = ''; |
| 5759 | - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) |
|
| 5759 | + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) |
|
| 5760 | 5760 | { |
| 5761 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 5762 | - $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); |
|
| 5761 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
| 5762 | + $out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); |
|
| 5763 | 5763 | } |
| 5764 | 5764 | |
| 5765 | - $out.='<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>'; |
|
| 5766 | - if((! isset($this->fields[$key]['default'])) ||($this->fields[$key]['notnull']!=1))$out.='<option value="0"> </option>'; |
|
| 5765 | + $out .= '<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam ? $moreparam : '').'>'; |
|
| 5766 | + if ((!isset($this->fields[$key]['default'])) || ($this->fields[$key]['notnull'] != 1))$out .= '<option value="0"> </option>'; |
|
| 5767 | 5767 | foreach ($param['options'] as $key => $val) |
| 5768 | 5768 | { |
| 5769 | 5769 | if ((string) $key == '') continue; |
| 5770 | 5770 | list($val, $parent) = explode('|', $val); |
| 5771 | - $out.='<option value="'.$key.'"'; |
|
| 5772 | - $out.= (((string) $value == (string) $key)?' selected':''); |
|
| 5773 | - $out.= (!empty($parent)?' parent="'.$parent.'"':''); |
|
| 5774 | - $out.='>'.$val.'</option>'; |
|
| 5771 | + $out .= '<option value="'.$key.'"'; |
|
| 5772 | + $out .= (((string) $value == (string) $key) ? ' selected' : ''); |
|
| 5773 | + $out .= (!empty($parent) ? ' parent="'.$parent.'"' : ''); |
|
| 5774 | + $out .= '>'.$val.'</option>'; |
|
| 5775 | 5775 | } |
| 5776 | - $out.='</select>'; |
|
| 5776 | + $out .= '</select>'; |
|
| 5777 | 5777 | } |
| 5778 | 5778 | elseif ($type == 'sellist') |
| 5779 | 5779 | { |
| 5780 | 5780 | $out = ''; |
| 5781 | - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) |
|
| 5781 | + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) |
|
| 5782 | 5782 | { |
| 5783 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 5784 | - $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); |
|
| 5783 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
| 5784 | + $out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); |
|
| 5785 | 5785 | } |
| 5786 | 5786 | |
| 5787 | - $out.='<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>'; |
|
| 5787 | + $out .= '<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam ? $moreparam : '').'>'; |
|
| 5788 | 5788 | if (is_array($param['options'])) |
| 5789 | 5789 | { |
| 5790 | - $param_list=array_keys($param['options']); |
|
| 5790 | + $param_list = array_keys($param['options']); |
|
| 5791 | 5791 | $InfoFieldList = explode(":", $param_list[0]); |
| 5792 | - $parentName=''; |
|
| 5793 | - $parentField=''; |
|
| 5792 | + $parentName = ''; |
|
| 5793 | + $parentField = ''; |
|
| 5794 | 5794 | // 0 : tableName |
| 5795 | 5795 | // 1 : label field name |
| 5796 | 5796 | // 2 : key fields name (if differ of rowid) |
| 5797 | 5797 | // 3 : key field parent (for dependent lists) |
| 5798 | 5798 | // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value |
| 5799 | - $keyList=(empty($InfoFieldList[2])?'rowid':$InfoFieldList[2].' as rowid'); |
|
| 5799 | + $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid'); |
|
| 5800 | 5800 | |
| 5801 | 5801 | |
| 5802 | - if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4])) |
|
| 5802 | + if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) |
|
| 5803 | 5803 | { |
| 5804 | 5804 | if (strpos($InfoFieldList[4], 'extra.') !== false) |
| 5805 | 5805 | { |
| 5806 | - $keyList='main.'.$InfoFieldList[2].' as rowid'; |
|
| 5806 | + $keyList = 'main.'.$InfoFieldList[2].' as rowid'; |
|
| 5807 | 5807 | } else { |
| 5808 | - $keyList=$InfoFieldList[2].' as rowid'; |
|
| 5808 | + $keyList = $InfoFieldList[2].' as rowid'; |
|
| 5809 | 5809 | } |
| 5810 | 5810 | } |
| 5811 | - if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3])) |
|
| 5811 | + if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) |
|
| 5812 | 5812 | { |
| 5813 | 5813 | list($parentName, $parentField) = explode('|', $InfoFieldList[3]); |
| 5814 | - $keyList.= ', '.$parentField; |
|
| 5814 | + $keyList .= ', '.$parentField; |
|
| 5815 | 5815 | } |
| 5816 | 5816 | |
| 5817 | 5817 | $fields_label = explode('|', $InfoFieldList[1]); |
| 5818 | 5818 | if (is_array($fields_label)) |
| 5819 | 5819 | { |
| 5820 | - $keyList .=', '; |
|
| 5820 | + $keyList .= ', '; |
|
| 5821 | 5821 | $keyList .= implode(', ', $fields_label); |
| 5822 | 5822 | } |
| 5823 | 5823 | |
| 5824 | - $sqlwhere=''; |
|
| 5824 | + $sqlwhere = ''; |
|
| 5825 | 5825 | $sql = 'SELECT '.$keyList; |
| 5826 | - $sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[0]; |
|
| 5826 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; |
|
| 5827 | 5827 | if (!empty($InfoFieldList[4])) |
| 5828 | 5828 | { |
| 5829 | 5829 | // can use SELECT request |
| 5830 | - if (strpos($InfoFieldList[4], '$SEL$')!==false) { |
|
| 5831 | - $InfoFieldList[4]=str_replace('$SEL$', 'SELECT', $InfoFieldList[4]); |
|
| 5830 | + if (strpos($InfoFieldList[4], '$SEL$') !== false) { |
|
| 5831 | + $InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]); |
|
| 5832 | 5832 | } |
| 5833 | 5833 | |
| 5834 | 5834 | // current object id can be use into filter |
| 5835 | - if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) { |
|
| 5836 | - $InfoFieldList[4]=str_replace('$ID$', $objectid, $InfoFieldList[4]); |
|
| 5835 | + if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) { |
|
| 5836 | + $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]); |
|
| 5837 | 5837 | } else { |
| 5838 | - $InfoFieldList[4]=str_replace('$ID$', '0', $InfoFieldList[4]); |
|
| 5838 | + $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); |
|
| 5839 | 5839 | } |
| 5840 | 5840 | //We have to join on extrafield table |
| 5841 | - if (strpos($InfoFieldList[4], 'extra')!==false) |
|
| 5841 | + if (strpos($InfoFieldList[4], 'extra') !== false) |
|
| 5842 | 5842 | { |
| 5843 | - $sql.= ' as main, '.MAIN_DB_PREFIX .$InfoFieldList[0].'_extrafields as extra'; |
|
| 5844 | - $sqlwhere.= ' WHERE extra.fk_object=main.'.$InfoFieldList[2]. ' AND '.$InfoFieldList[4]; |
|
| 5843 | + $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra'; |
|
| 5844 | + $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4]; |
|
| 5845 | 5845 | } |
| 5846 | 5846 | else |
| 5847 | 5847 | { |
| 5848 | - $sqlwhere.= ' WHERE '.$InfoFieldList[4]; |
|
| 5848 | + $sqlwhere .= ' WHERE '.$InfoFieldList[4]; |
|
| 5849 | 5849 | } |
| 5850 | 5850 | } |
| 5851 | 5851 | else |
| 5852 | 5852 | { |
| 5853 | - $sqlwhere.= ' WHERE 1=1'; |
|
| 5853 | + $sqlwhere .= ' WHERE 1=1'; |
|
| 5854 | 5854 | } |
| 5855 | 5855 | // Some tables may have field, some other not. For the moment we disable it. |
| 5856 | 5856 | if (in_array($InfoFieldList[0], array('tablewithentity'))) |
| 5857 | 5857 | { |
| 5858 | - $sqlwhere.= ' AND entity = '.$conf->entity; |
|
| 5858 | + $sqlwhere .= ' AND entity = '.$conf->entity; |
|
| 5859 | 5859 | } |
| 5860 | - $sql.=$sqlwhere; |
|
| 5860 | + $sql .= $sqlwhere; |
|
| 5861 | 5861 | //print $sql; |
| 5862 | 5862 | |
| 5863 | - $sql .= ' ORDER BY ' . implode(', ', $fields_label); |
|
| 5863 | + $sql .= ' ORDER BY '.implode(', ', $fields_label); |
|
| 5864 | 5864 | |
| 5865 | 5865 | dol_syslog(get_class($this).'::showInputField type=sellist', LOG_DEBUG); |
| 5866 | 5866 | $resql = $this->db->query($sql); |
| 5867 | 5867 | if ($resql) |
| 5868 | 5868 | { |
| 5869 | - $out.='<option value="0"> </option>'; |
|
| 5869 | + $out .= '<option value="0"> </option>'; |
|
| 5870 | 5870 | $num = $this->db->num_rows($resql); |
| 5871 | 5871 | $i = 0; |
| 5872 | 5872 | while ($i < $num) |
| 5873 | 5873 | { |
| 5874 | - $labeltoshow=''; |
|
| 5874 | + $labeltoshow = ''; |
|
| 5875 | 5875 | $obj = $this->db->fetch_object($resql); |
| 5876 | 5876 | |
| 5877 | 5877 | // Several field into label (eq table:code|libelle:rowid) |
@@ -5882,44 +5882,44 @@ discard block |
||
| 5882 | 5882 | $notrans = true; |
| 5883 | 5883 | foreach ($fields_label as $field_toshow) |
| 5884 | 5884 | { |
| 5885 | - $labeltoshow.= $obj->$field_toshow.' '; |
|
| 5885 | + $labeltoshow .= $obj->$field_toshow.' '; |
|
| 5886 | 5886 | } |
| 5887 | 5887 | } |
| 5888 | 5888 | else |
| 5889 | 5889 | { |
| 5890 | - $labeltoshow=$obj->{$InfoFieldList[1]}; |
|
| 5890 | + $labeltoshow = $obj->{$InfoFieldList[1]}; |
|
| 5891 | 5891 | } |
| 5892 | - $labeltoshow=dol_trunc($labeltoshow, 45); |
|
| 5892 | + $labeltoshow = dol_trunc($labeltoshow, 45); |
|
| 5893 | 5893 | |
| 5894 | 5894 | if ($value == $obj->rowid) |
| 5895 | 5895 | { |
| 5896 | 5896 | foreach ($fields_label as $field_toshow) |
| 5897 | 5897 | { |
| 5898 | - $translabel=$langs->trans($obj->$field_toshow); |
|
| 5899 | - if ($translabel!=$obj->$field_toshow) { |
|
| 5900 | - $labeltoshow=dol_trunc($translabel, 18).' '; |
|
| 5901 | - }else { |
|
| 5902 | - $labeltoshow=dol_trunc($obj->$field_toshow, 18).' '; |
|
| 5898 | + $translabel = $langs->trans($obj->$field_toshow); |
|
| 5899 | + if ($translabel != $obj->$field_toshow) { |
|
| 5900 | + $labeltoshow = dol_trunc($translabel, 18).' '; |
|
| 5901 | + } else { |
|
| 5902 | + $labeltoshow = dol_trunc($obj->$field_toshow, 18).' '; |
|
| 5903 | 5903 | } |
| 5904 | 5904 | } |
| 5905 | - $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
| 5905 | + $out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
| 5906 | 5906 | } |
| 5907 | 5907 | else |
| 5908 | 5908 | { |
| 5909 | - if (! $notrans) |
|
| 5909 | + if (!$notrans) |
|
| 5910 | 5910 | { |
| 5911 | - $translabel=$langs->trans($obj->{$InfoFieldList[1]}); |
|
| 5912 | - if ($translabel!=$obj->{$InfoFieldList[1]}) { |
|
| 5913 | - $labeltoshow=dol_trunc($translabel, 18); |
|
| 5911 | + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); |
|
| 5912 | + if ($translabel != $obj->{$InfoFieldList[1]}) { |
|
| 5913 | + $labeltoshow = dol_trunc($translabel, 18); |
|
| 5914 | 5914 | } |
| 5915 | 5915 | else { |
| 5916 | - $labeltoshow=dol_trunc($obj->{$InfoFieldList[1]}, 18); |
|
| 5916 | + $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18); |
|
| 5917 | 5917 | } |
| 5918 | 5918 | } |
| 5919 | - if (empty($labeltoshow)) $labeltoshow='(not defined)'; |
|
| 5920 | - if ($value==$obj->rowid) |
|
| 5919 | + if (empty($labeltoshow)) $labeltoshow = '(not defined)'; |
|
| 5920 | + if ($value == $obj->rowid) |
|
| 5921 | 5921 | { |
| 5922 | - $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
| 5922 | + $out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
| 5923 | 5923 | } |
| 5924 | 5924 | |
| 5925 | 5925 | if (!empty($InfoFieldList[3]) && $parentField) |
@@ -5927,10 +5927,10 @@ discard block |
||
| 5927 | 5927 | $parent = $parentName.':'.$obj->{$parentField}; |
| 5928 | 5928 | } |
| 5929 | 5929 | |
| 5930 | - $out.='<option value="'.$obj->rowid.'"'; |
|
| 5931 | - $out.= ($value==$obj->rowid?' selected':''); |
|
| 5932 | - $out.= (!empty($parent)?' parent="'.$parent.'"':''); |
|
| 5933 | - $out.='>'.$labeltoshow.'</option>'; |
|
| 5930 | + $out .= '<option value="'.$obj->rowid.'"'; |
|
| 5931 | + $out .= ($value == $obj->rowid ? ' selected' : ''); |
|
| 5932 | + $out .= (!empty($parent) ? ' parent="'.$parent.'"' : ''); |
|
| 5933 | + $out .= '>'.$labeltoshow.'</option>'; |
|
| 5934 | 5934 | } |
| 5935 | 5935 | |
| 5936 | 5936 | $i++; |
@@ -5941,23 +5941,23 @@ discard block |
||
| 5941 | 5941 | print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>'; |
| 5942 | 5942 | } |
| 5943 | 5943 | } |
| 5944 | - $out.='</select>'; |
|
| 5944 | + $out .= '</select>'; |
|
| 5945 | 5945 | } |
| 5946 | 5946 | elseif ($type == 'checkbox') |
| 5947 | 5947 | { |
| 5948 | - $value_arr=explode(',', $value); |
|
| 5949 | - $out=$form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); |
|
| 5948 | + $value_arr = explode(',', $value); |
|
| 5949 | + $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); |
|
| 5950 | 5950 | } |
| 5951 | 5951 | elseif ($type == 'radio') |
| 5952 | 5952 | { |
| 5953 | - $out=''; |
|
| 5953 | + $out = ''; |
|
| 5954 | 5954 | foreach ($param['options'] as $keyopt => $val) |
| 5955 | 5955 | { |
| 5956 | - $out.='<input class="flat '.$morecss.'" type="radio" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:''); |
|
| 5957 | - $out.=' value="'.$keyopt.'"'; |
|
| 5958 | - $out.=' id="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'"'; |
|
| 5959 | - $out.= ($value==$keyopt?'checked':''); |
|
| 5960 | - $out.='/><label for="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'">'.$val.'</label><br>'; |
|
| 5956 | + $out .= '<input class="flat '.$morecss.'" type="radio" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam ? $moreparam : ''); |
|
| 5957 | + $out .= ' value="'.$keyopt.'"'; |
|
| 5958 | + $out .= ' id="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'"'; |
|
| 5959 | + $out .= ($value == $keyopt ? 'checked' : ''); |
|
| 5960 | + $out .= '/><label for="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'">'.$val.'</label><br>'; |
|
| 5961 | 5961 | } |
| 5962 | 5962 | } |
| 5963 | 5963 | elseif ($type == 'chkbxlst') |
@@ -5972,24 +5972,24 @@ discard block |
||
| 5972 | 5972 | if (is_array($param['options'])) { |
| 5973 | 5973 | $param_list = array_keys($param['options']); |
| 5974 | 5974 | $InfoFieldList = explode(":", $param_list[0]); |
| 5975 | - $parentName=''; |
|
| 5976 | - $parentField=''; |
|
| 5975 | + $parentName = ''; |
|
| 5976 | + $parentField = ''; |
|
| 5977 | 5977 | // 0 : tableName |
| 5978 | 5978 | // 1 : label field name |
| 5979 | 5979 | // 2 : key fields name (if differ of rowid) |
| 5980 | 5980 | // 3 : key field parent (for dependent lists) |
| 5981 | 5981 | // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value |
| 5982 | - $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2] . ' as rowid'); |
|
| 5982 | + $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid'); |
|
| 5983 | 5983 | |
| 5984 | - if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3])) { |
|
| 5985 | - list ( $parentName, $parentField ) = explode('|', $InfoFieldList[3]); |
|
| 5986 | - $keyList .= ', ' . $parentField; |
|
| 5984 | + if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) { |
|
| 5985 | + list ($parentName, $parentField) = explode('|', $InfoFieldList[3]); |
|
| 5986 | + $keyList .= ', '.$parentField; |
|
| 5987 | 5987 | } |
| 5988 | - if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4])) { |
|
| 5988 | + if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) { |
|
| 5989 | 5989 | if (strpos($InfoFieldList[4], 'extra.') !== false) { |
| 5990 | - $keyList = 'main.' . $InfoFieldList[2] . ' as rowid'; |
|
| 5990 | + $keyList = 'main.'.$InfoFieldList[2].' as rowid'; |
|
| 5991 | 5991 | } else { |
| 5992 | - $keyList = $InfoFieldList[2] . ' as rowid'; |
|
| 5992 | + $keyList = $InfoFieldList[2].' as rowid'; |
|
| 5993 | 5993 | } |
| 5994 | 5994 | } |
| 5995 | 5995 | |
@@ -6000,49 +6000,49 @@ discard block |
||
| 6000 | 6000 | } |
| 6001 | 6001 | |
| 6002 | 6002 | $sqlwhere = ''; |
| 6003 | - $sql = 'SELECT ' . $keyList; |
|
| 6004 | - $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; |
|
| 6005 | - if (! empty($InfoFieldList[4])) { |
|
| 6003 | + $sql = 'SELECT '.$keyList; |
|
| 6004 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; |
|
| 6005 | + if (!empty($InfoFieldList[4])) { |
|
| 6006 | 6006 | // can use SELECT request |
| 6007 | - if (strpos($InfoFieldList[4], '$SEL$')!==false) { |
|
| 6008 | - $InfoFieldList[4]=str_replace('$SEL$', 'SELECT', $InfoFieldList[4]); |
|
| 6007 | + if (strpos($InfoFieldList[4], '$SEL$') !== false) { |
|
| 6008 | + $InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]); |
|
| 6009 | 6009 | } |
| 6010 | 6010 | |
| 6011 | 6011 | // current object id can be use into filter |
| 6012 | - if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) { |
|
| 6013 | - $InfoFieldList[4]=str_replace('$ID$', $objectid, $InfoFieldList[4]); |
|
| 6012 | + if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) { |
|
| 6013 | + $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]); |
|
| 6014 | 6014 | } else { |
| 6015 | - $InfoFieldList[4]=str_replace('$ID$', '0', $InfoFieldList[4]); |
|
| 6015 | + $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); |
|
| 6016 | 6016 | } |
| 6017 | 6017 | |
| 6018 | 6018 | // We have to join on extrafield table |
| 6019 | 6019 | if (strpos($InfoFieldList[4], 'extra') !== false) { |
| 6020 | - $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra'; |
|
| 6021 | - $sqlwhere .= ' WHERE extra.fk_object=main.' . $InfoFieldList[2] . ' AND ' . $InfoFieldList[4]; |
|
| 6020 | + $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra'; |
|
| 6021 | + $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4]; |
|
| 6022 | 6022 | } else { |
| 6023 | - $sqlwhere .= ' WHERE ' . $InfoFieldList[4]; |
|
| 6023 | + $sqlwhere .= ' WHERE '.$InfoFieldList[4]; |
|
| 6024 | 6024 | } |
| 6025 | 6025 | } else { |
| 6026 | 6026 | $sqlwhere .= ' WHERE 1=1'; |
| 6027 | 6027 | } |
| 6028 | 6028 | // Some tables may have field, some other not. For the moment we disable it. |
| 6029 | - if (in_array($InfoFieldList[0], array ('tablewithentity'))) |
|
| 6029 | + if (in_array($InfoFieldList[0], array('tablewithentity'))) |
|
| 6030 | 6030 | { |
| 6031 | - $sqlwhere .= ' AND entity = ' . $conf->entity; |
|
| 6031 | + $sqlwhere .= ' AND entity = '.$conf->entity; |
|
| 6032 | 6032 | } |
| 6033 | 6033 | // $sql.=preg_replace('/^ AND /','',$sqlwhere); |
| 6034 | 6034 | // print $sql; |
| 6035 | 6035 | |
| 6036 | 6036 | $sql .= $sqlwhere; |
| 6037 | - dol_syslog(get_class($this) . '::showInputField type=chkbxlst', LOG_DEBUG); |
|
| 6037 | + dol_syslog(get_class($this).'::showInputField type=chkbxlst', LOG_DEBUG); |
|
| 6038 | 6038 | $resql = $this->db->query($sql); |
| 6039 | 6039 | if ($resql) { |
| 6040 | 6040 | $num = $this->db->num_rows($resql); |
| 6041 | 6041 | $i = 0; |
| 6042 | 6042 | |
| 6043 | - $data=array(); |
|
| 6043 | + $data = array(); |
|
| 6044 | 6044 | |
| 6045 | - while ( $i < $num ) { |
|
| 6045 | + while ($i < $num) { |
|
| 6046 | 6046 | $labeltoshow = ''; |
| 6047 | 6047 | $obj = $this->db->fetch_object($resql); |
| 6048 | 6048 | |
@@ -6052,7 +6052,7 @@ discard block |
||
| 6052 | 6052 | if (is_array($fields_label)) { |
| 6053 | 6053 | $notrans = true; |
| 6054 | 6054 | foreach ($fields_label as $field_toshow) { |
| 6055 | - $labeltoshow .= $obj->$field_toshow . ' '; |
|
| 6055 | + $labeltoshow .= $obj->$field_toshow.' '; |
|
| 6056 | 6056 | } |
| 6057 | 6057 | } else { |
| 6058 | 6058 | $labeltoshow = $obj->{$InfoFieldList[1]}; |
@@ -6063,15 +6063,15 @@ discard block |
||
| 6063 | 6063 | foreach ($fields_label as $field_toshow) { |
| 6064 | 6064 | $translabel = $langs->trans($obj->$field_toshow); |
| 6065 | 6065 | if ($translabel != $obj->$field_toshow) { |
| 6066 | - $labeltoshow = dol_trunc($translabel, 18) . ' '; |
|
| 6066 | + $labeltoshow = dol_trunc($translabel, 18).' '; |
|
| 6067 | 6067 | } else { |
| 6068 | - $labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' '; |
|
| 6068 | + $labeltoshow = dol_trunc($obj->$field_toshow, 18).' '; |
|
| 6069 | 6069 | } |
| 6070 | 6070 | } |
| 6071 | 6071 | |
| 6072 | - $data[$obj->rowid]=$labeltoshow; |
|
| 6072 | + $data[$obj->rowid] = $labeltoshow; |
|
| 6073 | 6073 | } else { |
| 6074 | - if (! $notrans) { |
|
| 6074 | + if (!$notrans) { |
|
| 6075 | 6075 | $translabel = $langs->trans($obj->{$InfoFieldList[1]}); |
| 6076 | 6076 | if ($translabel != $obj->{$InfoFieldList[1]}) { |
| 6077 | 6077 | $labeltoshow = dol_trunc($translabel, 18); |
@@ -6084,77 +6084,77 @@ discard block |
||
| 6084 | 6084 | } |
| 6085 | 6085 | |
| 6086 | 6086 | if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { |
| 6087 | - $data[$obj->rowid]=$labeltoshow; |
|
| 6087 | + $data[$obj->rowid] = $labeltoshow; |
|
| 6088 | 6088 | } |
| 6089 | 6089 | |
| 6090 | - if (! empty($InfoFieldList[3]) && $parentField) { |
|
| 6091 | - $parent = $parentName . ':' . $obj->{$parentField}; |
|
| 6090 | + if (!empty($InfoFieldList[3]) && $parentField) { |
|
| 6091 | + $parent = $parentName.':'.$obj->{$parentField}; |
|
| 6092 | 6092 | } |
| 6093 | 6093 | |
| 6094 | - $data[$obj->rowid]=$labeltoshow; |
|
| 6094 | + $data[$obj->rowid] = $labeltoshow; |
|
| 6095 | 6095 | } |
| 6096 | 6096 | |
| 6097 | - $i ++; |
|
| 6097 | + $i++; |
|
| 6098 | 6098 | } |
| 6099 | 6099 | $this->db->free($resql); |
| 6100 | 6100 | |
| 6101 | - $out=$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); |
|
| 6101 | + $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); |
|
| 6102 | 6102 | } else { |
| 6103 | - print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>'; |
|
| 6103 | + print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>'; |
|
| 6104 | 6104 | } |
| 6105 | 6105 | } |
| 6106 | 6106 | } |
| 6107 | 6107 | elseif ($type == 'link') |
| 6108 | 6108 | { |
| 6109 | - $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]' |
|
| 6109 | + $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]' |
|
| 6110 | 6110 | $param_list_array = explode(':', $param_list[0]); |
| 6111 | - $showempty=(($required && $default != '')?0:1); |
|
| 6111 | + $showempty = (($required && $default != '') ? 0 : 1); |
|
| 6112 | 6112 | |
| 6113 | - $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, '', 0, empty($val['disabled'])?0:1); |
|
| 6113 | + $out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, '', 0, empty($val['disabled']) ? 0 : 1); |
|
| 6114 | 6114 | |
| 6115 | - if (! empty($param_list_array[2])) // If we set to add a create button |
|
| 6115 | + if (!empty($param_list_array[2])) // If we set to add a create button |
|
| 6116 | 6116 | { |
| 6117 | - if (! GETPOSTISSET('backtopage') && empty($val['disabled'])) // To avoid to open several infinitely the 'Create Object' button and to avoid to have button if field is protected by a "disabled". |
|
| 6117 | + if (!GETPOSTISSET('backtopage') && empty($val['disabled'])) // To avoid to open several infinitely the 'Create Object' button and to avoid to have button if field is protected by a "disabled". |
|
| 6118 | 6118 | { |
| 6119 | - list($class,$classfile)=explode(':', $param_list[0]); |
|
| 6120 | - if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); |
|
| 6121 | - else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1); |
|
| 6119 | + list($class, $classfile) = explode(':', $param_list[0]); |
|
| 6120 | + if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path = dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); |
|
| 6121 | + else $url_path = dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1); |
|
| 6122 | 6122 | $paramforthenewlink = ''; |
| 6123 | - $paramforthenewlink .= (GETPOSTISSET('action')?'&action='.GETPOST('action', 'aZ09'):''); |
|
| 6124 | - $paramforthenewlink .= (GETPOSTISSET('id')?'&id='.GETPOST('id', 'int'):''); |
|
| 6123 | + $paramforthenewlink .= (GETPOSTISSET('action') ? '&action='.GETPOST('action', 'aZ09') : ''); |
|
| 6124 | + $paramforthenewlink .= (GETPOSTISSET('id') ? '&id='.GETPOST('id', 'int') : ''); |
|
| 6125 | 6125 | $paramforthenewlink .= '&fk_'.strtolower($class).'=--IDFORBACKTOPAGE--'; |
| 6126 | 6126 | // TODO Add Javascript code to add input fields already filled into $paramforthenewlink so we won't loose them when going back to main page |
| 6127 | - $out.='<a class="butActionNew" title="'.$langs->trans("New").'" href="'.$url_path.'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].($paramforthenewlink ? '?'.$paramforthenewlink : '')).'"><span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
| 6127 | + $out .= '<a class="butActionNew" title="'.$langs->trans("New").'" href="'.$url_path.'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].($paramforthenewlink ? '?'.$paramforthenewlink : '')).'"><span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
| 6128 | 6128 | } |
| 6129 | 6129 | } |
| 6130 | 6130 | } |
| 6131 | 6131 | elseif ($type == 'password') |
| 6132 | 6132 | { |
| 6133 | 6133 | // If prefix is 'search_', field is used as a filter, we use a common text field. |
| 6134 | - $out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>'; |
|
| 6134 | + $out = '<input type="'.($keyprefix == 'search_' ? 'text' : 'password').'" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam ? $moreparam : '').'>'; |
|
| 6135 | 6135 | } |
| 6136 | 6136 | elseif ($type == 'array') |
| 6137 | 6137 | { |
| 6138 | 6138 | $newval = $val; |
| 6139 | 6139 | $newval['type'] = 'varchar(256)'; |
| 6140 | 6140 | |
| 6141 | - $out=''; |
|
| 6141 | + $out = ''; |
|
| 6142 | 6142 | |
| 6143 | 6143 | $inputs = array(); |
| 6144 | - if(! empty($value)) { |
|
| 6145 | - foreach($value as $option) { |
|
| 6146 | - $out.= '<span><a class="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_del" href="javascript:;"><span class="fa fa-minus-circle valignmiddle"></span></a> '; |
|
| 6147 | - $out.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $morecss).'<br></span>'; |
|
| 6144 | + if (!empty($value)) { |
|
| 6145 | + foreach ($value as $option) { |
|
| 6146 | + $out .= '<span><a class="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_del" href="javascript:;"><span class="fa fa-minus-circle valignmiddle"></span></a> '; |
|
| 6147 | + $out .= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $morecss).'<br></span>'; |
|
| 6148 | 6148 | } |
| 6149 | 6149 | } |
| 6150 | 6150 | |
| 6151 | - $out.= '<a id="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_add" href="javascript:;"><span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
| 6151 | + $out .= '<a id="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_add" href="javascript:;"><span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
| 6152 | 6152 | |
| 6153 | 6153 | $newInput = '<span><a class="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_del" href="javascript:;"><span class="fa fa-minus-circle valignmiddle"></span></a> '; |
| 6154 | - $newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $morecss).'<br></span>'; |
|
| 6154 | + $newInput .= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $morecss).'<br></span>'; |
|
| 6155 | 6155 | |
| 6156 | - if(! empty($conf->use_javascript_ajax)) { |
|
| 6157 | - $out.= ' |
|
| 6156 | + if (!empty($conf->use_javascript_ajax)) { |
|
| 6157 | + $out .= ' |
|
| 6158 | 6158 | <script> |
| 6159 | 6159 | $(document).ready(function() { |
| 6160 | 6160 | $("a#'.dol_escape_js($keyprefix.$key.$keysuffix).'_add").click(function() { |
@@ -6169,7 +6169,7 @@ discard block |
||
| 6169 | 6169 | } |
| 6170 | 6170 | } |
| 6171 | 6171 | if (!empty($hidden)) { |
| 6172 | - $out='<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>'; |
|
| 6172 | + $out = '<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>'; |
|
| 6173 | 6173 | } |
| 6174 | 6174 | /* Add comments |
| 6175 | 6175 | if ($type == 'date') $out.=' (YYYY-MM-DD)'; |
@@ -6193,12 +6193,12 @@ discard block |
||
| 6193 | 6193 | */ |
| 6194 | 6194 | public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '') |
| 6195 | 6195 | { |
| 6196 | - global $conf,$langs,$form; |
|
| 6196 | + global $conf, $langs, $form; |
|
| 6197 | 6197 | |
| 6198 | - if (! is_object($form)) |
|
| 6198 | + if (!is_object($form)) |
|
| 6199 | 6199 | { |
| 6200 | 6200 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
| 6201 | - $form=new Form($this->db); |
|
| 6201 | + $form = new Form($this->db); |
|
| 6202 | 6202 | } |
| 6203 | 6203 | |
| 6204 | 6204 | $objectid = $this->id; |
@@ -6210,36 +6210,36 @@ discard block |
||
| 6210 | 6210 | // Convert var to be able to share same code than showOutputField of extrafields |
| 6211 | 6211 | if (preg_match('/varchar\((\d+)\)/', $type, $reg)) |
| 6212 | 6212 | { |
| 6213 | - $type = 'varchar'; // convert varchar(xx) int varchar |
|
| 6213 | + $type = 'varchar'; // convert varchar(xx) int varchar |
|
| 6214 | 6214 | $size = $reg[1]; |
| 6215 | 6215 | } |
| 6216 | - elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar |
|
| 6217 | - if (is_array($val['arrayofkeyval'])) $type='select'; |
|
| 6218 | - if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type='link'; |
|
| 6216 | + elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar |
|
| 6217 | + if (is_array($val['arrayofkeyval'])) $type = 'select'; |
|
| 6218 | + if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type = 'link'; |
|
| 6219 | 6219 | |
| 6220 | - $default=$val['default']; |
|
| 6221 | - $computed=$val['computed']; |
|
| 6222 | - $unique=$val['unique']; |
|
| 6223 | - $required=$val['required']; |
|
| 6224 | - $param=array(); |
|
| 6225 | - $param['options']=array(); |
|
| 6220 | + $default = $val['default']; |
|
| 6221 | + $computed = $val['computed']; |
|
| 6222 | + $unique = $val['unique']; |
|
| 6223 | + $required = $val['required']; |
|
| 6224 | + $param = array(); |
|
| 6225 | + $param['options'] = array(); |
|
| 6226 | 6226 | |
| 6227 | 6227 | if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; |
| 6228 | 6228 | if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) |
| 6229 | 6229 | { |
| 6230 | - $type='link'; |
|
| 6231 | - $param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]); |
|
| 6230 | + $type = 'link'; |
|
| 6231 | + $param['options'] = array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]); |
|
| 6232 | 6232 | } |
| 6233 | - elseif(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { |
|
| 6234 | - $param['options'] = array($reg[1] . ':' . $reg[2] . ':' . $reg[3] . ':' . $reg[4] => 'N'); |
|
| 6233 | + elseif (preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { |
|
| 6234 | + $param['options'] = array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4] => 'N'); |
|
| 6235 | 6235 | $type = 'sellist'; |
| 6236 | 6236 | } |
| 6237 | 6237 | |
| 6238 | 6238 | |
| 6239 | - $langfile=$val['langfile']; |
|
| 6240 | - $list=$val['list']; |
|
| 6241 | - $help=$val['help']; |
|
| 6242 | - $hidden=(($val['visible'] == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) |
|
| 6239 | + $langfile = $val['langfile']; |
|
| 6240 | + $list = $val['list']; |
|
| 6241 | + $help = $val['help']; |
|
| 6242 | + $hidden = (($val['visible'] == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) |
|
| 6243 | 6243 | |
| 6244 | 6244 | if ($hidden) return ''; |
| 6245 | 6245 | |
@@ -6261,17 +6261,17 @@ discard block |
||
| 6261 | 6261 | { |
| 6262 | 6262 | $morecss = 'minwidth200imp'; |
| 6263 | 6263 | } |
| 6264 | - elseif (in_array($type, array('int','double','price'))) |
|
| 6264 | + elseif (in_array($type, array('int', 'double', 'price'))) |
|
| 6265 | 6265 | { |
| 6266 | 6266 | $morecss = 'maxwidth75'; |
| 6267 | 6267 | } |
| 6268 | 6268 | elseif ($type == 'url') |
| 6269 | 6269 | { |
| 6270 | - $morecss='minwidth400'; |
|
| 6270 | + $morecss = 'minwidth400'; |
|
| 6271 | 6271 | } |
| 6272 | 6272 | elseif ($type == 'boolean') |
| 6273 | 6273 | { |
| 6274 | - $morecss=''; |
|
| 6274 | + $morecss = ''; |
|
| 6275 | 6275 | } |
| 6276 | 6276 | else |
| 6277 | 6277 | { |
@@ -6291,90 +6291,90 @@ discard block |
||
| 6291 | 6291 | } |
| 6292 | 6292 | |
| 6293 | 6293 | // Format output value differently according to properties of field |
| 6294 | - if ($key == 'ref' && method_exists($this, 'getNomUrl')) $value=$this->getNomUrl(1, '', 0, '', 1); |
|
| 6295 | - elseif ($key == 'status' && method_exists($this, 'getLibStatut')) $value=$this->getLibStatut(3); |
|
| 6294 | + if ($key == 'ref' && method_exists($this, 'getNomUrl')) $value = $this->getNomUrl(1, '', 0, '', 1); |
|
| 6295 | + elseif ($key == 'status' && method_exists($this, 'getLibStatut')) $value = $this->getLibStatut(3); |
|
| 6296 | 6296 | elseif ($type == 'date') |
| 6297 | 6297 | { |
| 6298 | - if(! empty($value)) { |
|
| 6299 | - $value=dol_print_date($value, 'day'); |
|
| 6298 | + if (!empty($value)) { |
|
| 6299 | + $value = dol_print_date($value, 'day'); |
|
| 6300 | 6300 | } else { |
| 6301 | - $value=''; |
|
| 6301 | + $value = ''; |
|
| 6302 | 6302 | } |
| 6303 | 6303 | } |
| 6304 | 6304 | elseif ($type == 'datetime' || $type == 'timestamp') |
| 6305 | 6305 | { |
| 6306 | - if(! empty($value)) { |
|
| 6307 | - $value=dol_print_date($value, 'dayhour'); |
|
| 6306 | + if (!empty($value)) { |
|
| 6307 | + $value = dol_print_date($value, 'dayhour'); |
|
| 6308 | 6308 | } else { |
| 6309 | - $value=''; |
|
| 6309 | + $value = ''; |
|
| 6310 | 6310 | } |
| 6311 | 6311 | } |
| 6312 | 6312 | elseif ($type == 'double' || $type == 'real') |
| 6313 | 6313 | { |
| 6314 | 6314 | if (!empty($value)) { |
| 6315 | - $value=price($value); |
|
| 6315 | + $value = price($value); |
|
| 6316 | 6316 | } |
| 6317 | 6317 | } |
| 6318 | 6318 | elseif ($type == 'boolean') |
| 6319 | 6319 | { |
| 6320 | - $checked=''; |
|
| 6320 | + $checked = ''; |
|
| 6321 | 6321 | if (!empty($value)) { |
| 6322 | - $checked=' checked '; |
|
| 6322 | + $checked = ' checked '; |
|
| 6323 | 6323 | } |
| 6324 | - $value='<input type="checkbox" '.$checked.' '.($moreparam?$moreparam:'').' readonly disabled>'; |
|
| 6324 | + $value = '<input type="checkbox" '.$checked.' '.($moreparam ? $moreparam : '').' readonly disabled>'; |
|
| 6325 | 6325 | } |
| 6326 | 6326 | elseif ($type == 'mail') |
| 6327 | 6327 | { |
| 6328 | - $value=dol_print_email($value, 0, 0, 0, 64, 1, 1); |
|
| 6328 | + $value = dol_print_email($value, 0, 0, 0, 64, 1, 1); |
|
| 6329 | 6329 | } |
| 6330 | 6330 | elseif ($type == 'url') |
| 6331 | 6331 | { |
| 6332 | - $value=dol_print_url($value, '_blank', 32, 1); |
|
| 6332 | + $value = dol_print_url($value, '_blank', 32, 1); |
|
| 6333 | 6333 | } |
| 6334 | 6334 | elseif ($type == 'phone') |
| 6335 | 6335 | { |
| 6336 | - $value=dol_print_phone($value, '', 0, 0, '', ' ', 1); |
|
| 6336 | + $value = dol_print_phone($value, '', 0, 0, '', ' ', 1); |
|
| 6337 | 6337 | } |
| 6338 | 6338 | elseif ($type == 'price') |
| 6339 | 6339 | { |
| 6340 | - $value=price($value, 0, $langs, 0, 0, -1, $conf->currency); |
|
| 6340 | + $value = price($value, 0, $langs, 0, 0, -1, $conf->currency); |
|
| 6341 | 6341 | } |
| 6342 | 6342 | elseif ($type == 'select') |
| 6343 | 6343 | { |
| 6344 | - $value=$param['options'][$value]; |
|
| 6344 | + $value = $param['options'][$value]; |
|
| 6345 | 6345 | } |
| 6346 | 6346 | elseif ($type == 'sellist') |
| 6347 | 6347 | { |
| 6348 | - $param_list=array_keys($param['options']); |
|
| 6348 | + $param_list = array_keys($param['options']); |
|
| 6349 | 6349 | $InfoFieldList = explode(":", $param_list[0]); |
| 6350 | 6350 | |
| 6351 | - $selectkey="rowid"; |
|
| 6352 | - $keyList='rowid'; |
|
| 6351 | + $selectkey = "rowid"; |
|
| 6352 | + $keyList = 'rowid'; |
|
| 6353 | 6353 | |
| 6354 | - if (count($InfoFieldList)>=3) |
|
| 6354 | + if (count($InfoFieldList) >= 3) |
|
| 6355 | 6355 | { |
| 6356 | 6356 | $selectkey = $InfoFieldList[2]; |
| 6357 | - $keyList=$InfoFieldList[2].' as rowid'; |
|
| 6357 | + $keyList = $InfoFieldList[2].' as rowid'; |
|
| 6358 | 6358 | } |
| 6359 | 6359 | |
| 6360 | 6360 | $fields_label = explode('|', $InfoFieldList[1]); |
| 6361 | - if(is_array($fields_label)) { |
|
| 6362 | - $keyList .=', '; |
|
| 6361 | + if (is_array($fields_label)) { |
|
| 6362 | + $keyList .= ', '; |
|
| 6363 | 6363 | $keyList .= implode(', ', $fields_label); |
| 6364 | 6364 | } |
| 6365 | 6365 | |
| 6366 | 6366 | $sql = 'SELECT '.$keyList; |
| 6367 | - $sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[0]; |
|
| 6368 | - if (strpos($InfoFieldList[4], 'extra')!==false) |
|
| 6367 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; |
|
| 6368 | + if (strpos($InfoFieldList[4], 'extra') !== false) |
|
| 6369 | 6369 | { |
| 6370 | - $sql.= ' as main'; |
|
| 6370 | + $sql .= ' as main'; |
|
| 6371 | 6371 | } |
| 6372 | - if ($selectkey=='rowid' && empty($value)) { |
|
| 6373 | - $sql.= " WHERE ".$selectkey."=0"; |
|
| 6374 | - } elseif ($selectkey=='rowid') { |
|
| 6375 | - $sql.= " WHERE ".$selectkey."=".$this->db->escape($value); |
|
| 6376 | - }else { |
|
| 6377 | - $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; |
|
| 6372 | + if ($selectkey == 'rowid' && empty($value)) { |
|
| 6373 | + $sql .= " WHERE ".$selectkey."=0"; |
|
| 6374 | + } elseif ($selectkey == 'rowid') { |
|
| 6375 | + $sql .= " WHERE ".$selectkey."=".$this->db->escape($value); |
|
| 6376 | + } else { |
|
| 6377 | + $sql .= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; |
|
| 6378 | 6378 | } |
| 6379 | 6379 | |
| 6380 | 6380 | //$sql.= ' AND entity = '.$conf->entity; |
@@ -6383,38 +6383,38 @@ discard block |
||
| 6383 | 6383 | $resql = $this->db->query($sql); |
| 6384 | 6384 | if ($resql) |
| 6385 | 6385 | { |
| 6386 | - $value=''; // value was used, so now we reste it to use it to build final output |
|
| 6386 | + $value = ''; // value was used, so now we reste it to use it to build final output |
|
| 6387 | 6387 | |
| 6388 | 6388 | $obj = $this->db->fetch_object($resql); |
| 6389 | 6389 | |
| 6390 | 6390 | // Several field into label (eq table:code|libelle:rowid) |
| 6391 | 6391 | $fields_label = explode('|', $InfoFieldList[1]); |
| 6392 | 6392 | |
| 6393 | - if(is_array($fields_label) && count($fields_label)>1) |
|
| 6393 | + if (is_array($fields_label) && count($fields_label) > 1) |
|
| 6394 | 6394 | { |
| 6395 | 6395 | foreach ($fields_label as $field_toshow) |
| 6396 | 6396 | { |
| 6397 | - $translabel=''; |
|
| 6397 | + $translabel = ''; |
|
| 6398 | 6398 | if (!empty($obj->$field_toshow)) { |
| 6399 | - $translabel=$langs->trans($obj->$field_toshow); |
|
| 6399 | + $translabel = $langs->trans($obj->$field_toshow); |
|
| 6400 | 6400 | } |
| 6401 | - if ($translabel!=$field_toshow) { |
|
| 6402 | - $value.=dol_trunc($translabel, 18).' '; |
|
| 6403 | - }else { |
|
| 6404 | - $value.=$obj->$field_toshow.' '; |
|
| 6401 | + if ($translabel != $field_toshow) { |
|
| 6402 | + $value .= dol_trunc($translabel, 18).' '; |
|
| 6403 | + } else { |
|
| 6404 | + $value .= $obj->$field_toshow.' '; |
|
| 6405 | 6405 | } |
| 6406 | 6406 | } |
| 6407 | 6407 | } |
| 6408 | 6408 | else |
| 6409 | 6409 | { |
| 6410 | - $translabel=''; |
|
| 6410 | + $translabel = ''; |
|
| 6411 | 6411 | if (!empty($obj->{$InfoFieldList[1]})) { |
| 6412 | - $translabel=$langs->trans($obj->{$InfoFieldList[1]}); |
|
| 6412 | + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); |
|
| 6413 | 6413 | } |
| 6414 | - if ($translabel!=$obj->{$InfoFieldList[1]}) { |
|
| 6415 | - $value=dol_trunc($translabel, 18); |
|
| 6416 | - }else { |
|
| 6417 | - $value=$obj->{$InfoFieldList[1]}; |
|
| 6414 | + if ($translabel != $obj->{$InfoFieldList[1]}) { |
|
| 6415 | + $value = dol_trunc($translabel, 18); |
|
| 6416 | + } else { |
|
| 6417 | + $value = $obj->{$InfoFieldList[1]}; |
|
| 6418 | 6418 | } |
| 6419 | 6419 | } |
| 6420 | 6420 | } |
@@ -6422,19 +6422,19 @@ discard block |
||
| 6422 | 6422 | } |
| 6423 | 6423 | elseif ($type == 'radio') |
| 6424 | 6424 | { |
| 6425 | - $value=$param['options'][$value]; |
|
| 6425 | + $value = $param['options'][$value]; |
|
| 6426 | 6426 | } |
| 6427 | 6427 | elseif ($type == 'checkbox') |
| 6428 | 6428 | { |
| 6429 | - $value_arr=explode(',', $value); |
|
| 6430 | - $value=''; |
|
| 6431 | - if (is_array($value_arr) && count($value_arr)>0) |
|
| 6429 | + $value_arr = explode(',', $value); |
|
| 6430 | + $value = ''; |
|
| 6431 | + if (is_array($value_arr) && count($value_arr) > 0) |
|
| 6432 | 6432 | { |
| 6433 | - $toprint=array(); |
|
| 6433 | + $toprint = array(); |
|
| 6434 | 6434 | foreach ($value_arr as $keyval=>$valueval) { |
| 6435 | - $toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$param['options'][$valueval].'</li>'; |
|
| 6435 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$param['options'][$valueval].'</li>'; |
|
| 6436 | 6436 | } |
| 6437 | - $value='<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>'; |
|
| 6437 | + $value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>'; |
|
| 6438 | 6438 | } |
| 6439 | 6439 | } |
| 6440 | 6440 | elseif ($type == 'chkbxlst') |
@@ -6449,7 +6449,7 @@ discard block |
||
| 6449 | 6449 | |
| 6450 | 6450 | if (count($InfoFieldList) >= 3) { |
| 6451 | 6451 | $selectkey = $InfoFieldList[2]; |
| 6452 | - $keyList = $InfoFieldList[2] . ' as rowid'; |
|
| 6452 | + $keyList = $InfoFieldList[2].' as rowid'; |
|
| 6453 | 6453 | } |
| 6454 | 6454 | |
| 6455 | 6455 | $fields_label = explode('|', $InfoFieldList[1]); |
@@ -6458,74 +6458,74 @@ discard block |
||
| 6458 | 6458 | $keyList .= implode(', ', $fields_label); |
| 6459 | 6459 | } |
| 6460 | 6460 | |
| 6461 | - $sql = 'SELECT ' . $keyList; |
|
| 6462 | - $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; |
|
| 6461 | + $sql = 'SELECT '.$keyList; |
|
| 6462 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; |
|
| 6463 | 6463 | if (strpos($InfoFieldList[4], 'extra') !== false) { |
| 6464 | 6464 | $sql .= ' as main'; |
| 6465 | 6465 | } |
| 6466 | 6466 | // $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; |
| 6467 | 6467 | // $sql.= ' AND entity = '.$conf->entity; |
| 6468 | 6468 | |
| 6469 | - dol_syslog(get_class($this) . ':showOutputField:$type=chkbxlst', LOG_DEBUG); |
|
| 6469 | + dol_syslog(get_class($this).':showOutputField:$type=chkbxlst', LOG_DEBUG); |
|
| 6470 | 6470 | $resql = $this->db->query($sql); |
| 6471 | 6471 | if ($resql) { |
| 6472 | 6472 | $value = ''; // value was used, so now we reste it to use it to build final output |
| 6473 | - $toprint=array(); |
|
| 6474 | - while ( $obj = $this->db->fetch_object($resql) ) { |
|
| 6473 | + $toprint = array(); |
|
| 6474 | + while ($obj = $this->db->fetch_object($resql)) { |
|
| 6475 | 6475 | // Several field into label (eq table:code|libelle:rowid) |
| 6476 | 6476 | $fields_label = explode('|', $InfoFieldList[1]); |
| 6477 | 6477 | if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { |
| 6478 | 6478 | if (is_array($fields_label) && count($fields_label) > 1) { |
| 6479 | 6479 | foreach ($fields_label as $field_toshow) { |
| 6480 | 6480 | $translabel = ''; |
| 6481 | - if (! empty($obj->$field_toshow)) { |
|
| 6481 | + if (!empty($obj->$field_toshow)) { |
|
| 6482 | 6482 | $translabel = $langs->trans($obj->$field_toshow); |
| 6483 | 6483 | } |
| 6484 | 6484 | if ($translabel != $field_toshow) { |
| 6485 | - $toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.dol_trunc($translabel, 18).'</li>'; |
|
| 6485 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.dol_trunc($translabel, 18).'</li>'; |
|
| 6486 | 6486 | } else { |
| 6487 | - $toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$obj->$field_toshow.'</li>'; |
|
| 6487 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$obj->$field_toshow.'</li>'; |
|
| 6488 | 6488 | } |
| 6489 | 6489 | } |
| 6490 | 6490 | } else { |
| 6491 | 6491 | $translabel = ''; |
| 6492 | - if (! empty($obj->{$InfoFieldList[1]})) { |
|
| 6492 | + if (!empty($obj->{$InfoFieldList[1]})) { |
|
| 6493 | 6493 | $translabel = $langs->trans($obj->{$InfoFieldList[1]}); |
| 6494 | 6494 | } |
| 6495 | 6495 | if ($translabel != $obj->{$InfoFieldList[1]}) { |
| 6496 | - $toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.dol_trunc($translabel, 18).'</li>'; |
|
| 6496 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.dol_trunc($translabel, 18).'</li>'; |
|
| 6497 | 6497 | } else { |
| 6498 | - $toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$obj->{$InfoFieldList[1]}.'</li>'; |
|
| 6498 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$obj->{$InfoFieldList[1]}.'</li>'; |
|
| 6499 | 6499 | } |
| 6500 | 6500 | } |
| 6501 | 6501 | } |
| 6502 | 6502 | } |
| 6503 | - $value='<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>'; |
|
| 6503 | + $value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>'; |
|
| 6504 | 6504 | } else { |
| 6505 | - dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING); |
|
| 6505 | + dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); |
|
| 6506 | 6506 | } |
| 6507 | 6507 | } |
| 6508 | 6508 | elseif ($type == 'link') |
| 6509 | 6509 | { |
| 6510 | - $out=''; |
|
| 6510 | + $out = ''; |
|
| 6511 | 6511 | |
| 6512 | 6512 | // only if something to display (perf) |
| 6513 | 6513 | if ($value) |
| 6514 | 6514 | { |
| 6515 | - $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' |
|
| 6515 | + $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' |
|
| 6516 | 6516 | |
| 6517 | 6517 | $InfoFieldList = explode(":", $param_list[0]); |
| 6518 | - $classname=$InfoFieldList[0]; |
|
| 6519 | - $classpath=$InfoFieldList[1]; |
|
| 6520 | - $getnomurlparam=(empty($InfoFieldList[2]) ? 3 : $InfoFieldList[2]); |
|
| 6521 | - if (! empty($classpath)) |
|
| 6518 | + $classname = $InfoFieldList[0]; |
|
| 6519 | + $classpath = $InfoFieldList[1]; |
|
| 6520 | + $getnomurlparam = (empty($InfoFieldList[2]) ? 3 : $InfoFieldList[2]); |
|
| 6521 | + if (!empty($classpath)) |
|
| 6522 | 6522 | { |
| 6523 | 6523 | dol_include_once($InfoFieldList[1]); |
| 6524 | 6524 | if ($classname && class_exists($classname)) |
| 6525 | 6525 | { |
| 6526 | 6526 | $object = new $classname($this->db); |
| 6527 | 6527 | $object->fetch($value); |
| 6528 | - $value=$object->getNomUrl($getnomurlparam); |
|
| 6528 | + $value = $object->getNomUrl($getnomurlparam); |
|
| 6529 | 6529 | } |
| 6530 | 6530 | } |
| 6531 | 6531 | else |
@@ -6534,15 +6534,15 @@ discard block |
||
| 6534 | 6534 | return 'Error bad setup of extrafield'; |
| 6535 | 6535 | } |
| 6536 | 6536 | } |
| 6537 | - else $value=''; |
|
| 6537 | + else $value = ''; |
|
| 6538 | 6538 | } |
| 6539 | 6539 | elseif ($type == 'text' || $type == 'html') |
| 6540 | 6540 | { |
| 6541 | - $value=dol_htmlentitiesbr($value); |
|
| 6541 | + $value = dol_htmlentitiesbr($value); |
|
| 6542 | 6542 | } |
| 6543 | 6543 | elseif ($type == 'password') |
| 6544 | 6544 | { |
| 6545 | - $value=preg_replace('/./i', '*', $value); |
|
| 6545 | + $value = preg_replace('/./i', '*', $value); |
|
| 6546 | 6546 | } |
| 6547 | 6547 | elseif ($type == 'array') |
| 6548 | 6548 | { |
@@ -6550,7 +6550,7 @@ discard block |
||
| 6550 | 6550 | } |
| 6551 | 6551 | |
| 6552 | 6552 | //print $type.'-'.$size; |
| 6553 | - $out=$value; |
|
| 6553 | + $out = $value; |
|
| 6554 | 6554 | |
| 6555 | 6555 | return $out; |
| 6556 | 6556 | } |
@@ -6571,7 +6571,7 @@ discard block |
||
| 6571 | 6571 | { |
| 6572 | 6572 | global $db, $conf, $langs, $action, $form; |
| 6573 | 6573 | |
| 6574 | - if (! is_object($form)) $form=new Form($db); |
|
| 6574 | + if (!is_object($form)) $form = new Form($db); |
|
| 6575 | 6575 | |
| 6576 | 6576 | $out = ''; |
| 6577 | 6577 | |
@@ -6583,7 +6583,7 @@ discard block |
||
| 6583 | 6583 | |
| 6584 | 6584 | $extrafields_collapse_num = ''; |
| 6585 | 6585 | $e = 0; |
| 6586 | - foreach($extrafields->attributes[$this->table_element]['label'] as $key=>$label) |
|
| 6586 | + foreach ($extrafields->attributes[$this->table_element]['label'] as $key=>$label) |
|
| 6587 | 6587 | { |
| 6588 | 6588 | // Show only the key field in params |
| 6589 | 6589 | if (is_array($params) && array_key_exists('onlykey', $params) && $key != $params['onlykey']) continue; |
@@ -6603,26 +6603,26 @@ discard block |
||
| 6603 | 6603 | $perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1); |
| 6604 | 6604 | } |
| 6605 | 6605 | |
| 6606 | - if (($mode == 'create' || $mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list |
|
| 6607 | - elseif($mode == 'view' && empty($visibility)) continue; |
|
| 6606 | + if (($mode == 'create' || $mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list |
|
| 6607 | + elseif ($mode == 'view' && empty($visibility)) continue; |
|
| 6608 | 6608 | if (empty($perms)) continue; |
| 6609 | 6609 | |
| 6610 | 6610 | // Load language if required |
| 6611 | - if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); |
|
| 6611 | + if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); |
|
| 6612 | 6612 | |
| 6613 | - $colspan='3'; |
|
| 6614 | - if (is_array($params) && count($params)>0) { |
|
| 6613 | + $colspan = '3'; |
|
| 6614 | + if (is_array($params) && count($params) > 0) { |
|
| 6615 | 6615 | if (array_key_exists('colspan', $params)) { |
| 6616 | - $colspan=$params['colspan']; |
|
| 6616 | + $colspan = $params['colspan']; |
|
| 6617 | 6617 | } |
| 6618 | 6618 | } |
| 6619 | 6619 | |
| 6620 | - switch($mode) { |
|
| 6620 | + switch ($mode) { |
|
| 6621 | 6621 | case "view": |
| 6622 | - $value=$this->array_options["options_".$key.$keysuffix]; |
|
| 6622 | + $value = $this->array_options["options_".$key.$keysuffix]; |
|
| 6623 | 6623 | break; |
| 6624 | 6624 | case "edit": |
| 6625 | - $getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none'); // GETPOST can get value from GET, POST or setup of default values. |
|
| 6625 | + $getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none'); // GETPOST can get value from GET, POST or setup of default values. |
|
| 6626 | 6626 | // GETPOST("options_" . $key) can be 'abc' or array(0=>'abc') |
| 6627 | 6627 | if (is_array($getposttemp) || $getposttemp != '' || GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) |
| 6628 | 6628 | { |
@@ -6633,7 +6633,7 @@ discard block |
||
| 6633 | 6633 | $value = $getposttemp; |
| 6634 | 6634 | } |
| 6635 | 6635 | } else { |
| 6636 | - $value = $this->array_options["options_" . $key]; // No GET, no POST, no default value, so we take value of object. |
|
| 6636 | + $value = $this->array_options["options_".$key]; // No GET, no POST, no default value, so we take value of object. |
|
| 6637 | 6637 | } |
| 6638 | 6638 | //var_dump($keyprefix.' - '.$key.' - '.$keysuffix.' - '.$keyprefix.'options_'.$key.$keysuffix.' - '.$this->array_options["options_".$key.$keysuffix].' - '.$getposttemp.' - '.$value); |
| 6639 | 6639 | break; |
@@ -6646,10 +6646,10 @@ discard block |
||
| 6646 | 6646 | if (!empty($extrafield_param) && is_array($extrafield_param)) { |
| 6647 | 6647 | $extrafield_param_list = array_keys($extrafield_param['options']); |
| 6648 | 6648 | |
| 6649 | - if (count($extrafield_param_list)>0) { |
|
| 6649 | + if (count($extrafield_param_list) > 0) { |
|
| 6650 | 6650 | $extrafield_collapse_display_value = intval($extrafield_param_list[0]); |
| 6651 | 6651 | |
| 6652 | - if ($extrafield_collapse_display_value==1 || $extrafield_collapse_display_value==2) { |
|
| 6652 | + if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) { |
|
| 6653 | 6653 | $extrafields_collapse_num = $extrafields->attributes[$this->table_element]['pos'][$key]; |
| 6654 | 6654 | } |
| 6655 | 6655 | } |
@@ -6659,14 +6659,14 @@ discard block |
||
| 6659 | 6659 | } |
| 6660 | 6660 | else |
| 6661 | 6661 | { |
| 6662 | - $class=(!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : ''); |
|
| 6663 | - $csstyle=''; |
|
| 6664 | - if (is_array($params) && count($params)>0) { |
|
| 6662 | + $class = (!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : ''); |
|
| 6663 | + $csstyle = ''; |
|
| 6664 | + if (is_array($params) && count($params) > 0) { |
|
| 6665 | 6665 | if (array_key_exists('class', $params)) { |
| 6666 | - $class.=$params['class'].' '; |
|
| 6666 | + $class .= $params['class'].' '; |
|
| 6667 | 6667 | } |
| 6668 | 6668 | if (array_key_exists('style', $params)) { |
| 6669 | - $csstyle=$params['style']; |
|
| 6669 | + $csstyle = $params['style']; |
|
| 6670 | 6670 | } |
| 6671 | 6671 | } |
| 6672 | 6672 | |
@@ -6679,24 +6679,24 @@ discard block |
||
| 6679 | 6679 | |
| 6680 | 6680 | $out .= '<tr id="'.$html_id.'" '.$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.'" '.$domData.' >'; |
| 6681 | 6681 | |
| 6682 | - if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan='0'; } |
|
| 6682 | + if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan = '0'; } |
|
| 6683 | 6683 | |
| 6684 | 6684 | if ($action == 'selectlines') { $colspan++; } |
| 6685 | 6685 | |
| 6686 | 6686 | // Convert date into timestamp format (value in memory must be a timestamp) |
| 6687 | - if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date','datetime'))) |
|
| 6687 | + if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime'))) |
|
| 6688 | 6688 | { |
| 6689 | - $datenotinstring = $this->array_options['options_' . $key]; |
|
| 6690 | - if (! is_numeric($this->array_options['options_' . $key])) // For backward compatibility |
|
| 6689 | + $datenotinstring = $this->array_options['options_'.$key]; |
|
| 6690 | + if (!is_numeric($this->array_options['options_'.$key])) // For backward compatibility |
|
| 6691 | 6691 | { |
| 6692 | 6692 | $datenotinstring = $this->db->jdate($datenotinstring); |
| 6693 | 6693 | } |
| 6694 | - $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)):$datenotinstring; |
|
| 6694 | + $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring; |
|
| 6695 | 6695 | } |
| 6696 | 6696 | // Convert float submited string into real php numeric (value in memory must be a php numeric) |
| 6697 | - if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price','double'))) |
|
| 6697 | + if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price', 'double'))) |
|
| 6698 | 6698 | { |
| 6699 | - $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix, 'alpha', 3)):$this->array_options['options_'.$key]; |
|
| 6699 | + $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix, 'alpha', 3)) : $this->array_options['options_'.$key]; |
|
| 6700 | 6700 | } |
| 6701 | 6701 | |
| 6702 | 6702 | $labeltoshow = $langs->trans($label); |
@@ -6706,25 +6706,25 @@ discard block |
||
| 6706 | 6706 | //if (GETPOST('action', 'none') == 'create') $out.='create'; |
| 6707 | 6707 | // BUG #11554 : For public page, use red dot for required fields, instead of bold label |
| 6708 | 6708 | $tpl_context = isset($params["tpl_context"]) ? $params["tpl_context"] : "none"; |
| 6709 | - if ($tpl_context=="public") { // Public page : red dot instead of fieldrequired characters |
|
| 6709 | + if ($tpl_context == "public") { // Public page : red dot instead of fieldrequired characters |
|
| 6710 | 6710 | $out .= '">'; |
| 6711 | - if (! empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]); |
|
| 6711 | + if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]); |
|
| 6712 | 6712 | else $out .= $labeltoshow; |
| 6713 | - if ($mode != 'view' && ! empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' <font color="red">*</font>'; |
|
| 6713 | + if ($mode != 'view' && !empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' <font color="red">*</font>'; |
|
| 6714 | 6714 | } else { |
| 6715 | - if ($mode != 'view' && ! empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' fieldrequired'; |
|
| 6715 | + if ($mode != 'view' && !empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' fieldrequired'; |
|
| 6716 | 6716 | $out .= '">'; |
| 6717 | - if (! empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]); |
|
| 6717 | + if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]); |
|
| 6718 | 6718 | else $out .= $labeltoshow; |
| 6719 | 6719 | } |
| 6720 | 6720 | $out .= '</td>'; |
| 6721 | 6721 | |
| 6722 | 6722 | $html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : ''; |
| 6723 | 6723 | |
| 6724 | - $out .='<td id="'.$html_id.'" class="'.$this->element.'_extras_'.$key.'" '.($colspan?' colspan="'.$colspan.'"':'').'>'; |
|
| 6724 | + $out .= '<td id="'.$html_id.'" class="'.$this->element.'_extras_'.$key.'" '.($colspan ? ' colspan="'.$colspan.'"' : '').'>'; |
|
| 6725 | 6725 | //$out .='<td id="'.$html_id.'" class="'.$this->element.'_extras_'.$key.'">'; |
| 6726 | 6726 | |
| 6727 | - switch($mode) { |
|
| 6727 | + switch ($mode) { |
|
| 6728 | 6728 | case "view": |
| 6729 | 6729 | $out .= $extrafields->showOutputField($key, $value); |
| 6730 | 6730 | break; |
@@ -6740,14 +6740,14 @@ discard block |
||
| 6740 | 6740 | $out .='<td class="'.$this->element.'_extras_'.$key.'"></td>'; |
| 6741 | 6741 | }*/ |
| 6742 | 6742 | |
| 6743 | - if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>'; |
|
| 6743 | + if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>'; |
|
| 6744 | 6744 | else $out .= '</tr>'; |
| 6745 | 6745 | $e++; |
| 6746 | 6746 | } |
| 6747 | 6747 | } |
| 6748 | 6748 | $out .= "\n"; |
| 6749 | 6749 | // Add code to manage list depending on others |
| 6750 | - if (! empty($conf->use_javascript_ajax)) { |
|
| 6750 | + if (!empty($conf->use_javascript_ajax)) { |
|
| 6751 | 6751 | $out .= ' |
| 6752 | 6752 | <script> |
| 6753 | 6753 | jQuery(document).ready(function() { |
@@ -6793,7 +6793,7 @@ discard block |
||
| 6793 | 6793 | global $user; |
| 6794 | 6794 | |
| 6795 | 6795 | $element = $this->element; |
| 6796 | - if ($element == 'facturerec') $element='facture'; |
|
| 6796 | + if ($element == 'facturerec') $element = 'facture'; |
|
| 6797 | 6797 | |
| 6798 | 6798 | return $user->rights->{$element}; |
| 6799 | 6799 | } |
@@ -6816,9 +6816,9 @@ discard block |
||
| 6816 | 6816 | { |
| 6817 | 6817 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_soc = '.$dest_id.' WHERE fk_soc = '.$origin_id; |
| 6818 | 6818 | |
| 6819 | - if (! $db->query($sql)) |
|
| 6819 | + if (!$db->query($sql)) |
|
| 6820 | 6820 | { |
| 6821 | - if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. |
|
| 6821 | + if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. |
|
| 6822 | 6822 | //$this->errors = $db->lasterror(); |
| 6823 | 6823 | return false; |
| 6824 | 6824 | } |
@@ -6852,7 +6852,7 @@ discard block |
||
| 6852 | 6852 | else |
| 6853 | 6853 | { |
| 6854 | 6854 | // Get cost price for margin calculation |
| 6855 | - if (! empty($fk_product)) |
|
| 6855 | + if (!empty($fk_product)) |
|
| 6856 | 6856 | { |
| 6857 | 6857 | if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'costprice') |
| 6858 | 6858 | { |
@@ -6889,7 +6889,7 @@ discard block |
||
| 6889 | 6889 | } |
| 6890 | 6890 | } |
| 6891 | 6891 | |
| 6892 | - if (empty($buyPrice) && isset($conf->global->MARGIN_TYPE) && in_array($conf->global->MARGIN_TYPE, array('1','pmp','costprice'))) |
|
| 6892 | + if (empty($buyPrice) && isset($conf->global->MARGIN_TYPE) && in_array($conf->global->MARGIN_TYPE, array('1', 'pmp', 'costprice'))) |
|
| 6893 | 6893 | { |
| 6894 | 6894 | require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; |
| 6895 | 6895 | $productFournisseur = new ProductFournisseur($this->db); |
@@ -6929,25 +6929,25 @@ discard block |
||
| 6929 | 6929 | public function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $notitle = 0, $usesharelink = 0) |
| 6930 | 6930 | { |
| 6931 | 6931 | // phpcs:enable |
| 6932 | - global $conf,$user,$langs; |
|
| 6932 | + global $conf, $user, $langs; |
|
| 6933 | 6933 | |
| 6934 | - include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; |
|
| 6935 | - include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; |
|
| 6934 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 6935 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
|
| 6936 | 6936 | |
| 6937 | - $sortfield='position_name'; |
|
| 6938 | - $sortorder='asc'; |
|
| 6937 | + $sortfield = 'position_name'; |
|
| 6938 | + $sortorder = 'asc'; |
|
| 6939 | 6939 | |
| 6940 | - $dir = $sdir . '/'; |
|
| 6940 | + $dir = $sdir.'/'; |
|
| 6941 | 6941 | $pdir = '/'; |
| 6942 | 6942 | |
| 6943 | 6943 | $dir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->ref.'/'; |
| 6944 | 6944 | $pdir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->ref.'/'; |
| 6945 | 6945 | |
| 6946 | 6946 | // For backward compatibility |
| 6947 | - if ($modulepart == 'product' && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) |
|
| 6947 | + if ($modulepart == 'product' && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) |
|
| 6948 | 6948 | { |
| 6949 | - $dir = $sdir . '/'. get_exdir($this->id, 2, 0, 0, $this, $modulepart) . $this->id ."/photos/"; |
|
| 6950 | - $pdir = '/' . get_exdir($this->id, 2, 0, 0, $this, $modulepart) . $this->id ."/photos/"; |
|
| 6949 | + $dir = $sdir.'/'.get_exdir($this->id, 2, 0, 0, $this, $modulepart).$this->id."/photos/"; |
|
| 6950 | + $pdir = '/'.get_exdir($this->id, 2, 0, 0, $this, $modulepart).$this->id."/photos/"; |
|
| 6951 | 6951 | } |
| 6952 | 6952 | |
| 6953 | 6953 | // Defined relative dir to DOL_DATA_ROOT |
@@ -6962,10 +6962,10 @@ discard block |
||
| 6962 | 6962 | $dirthumb = $dir.'thumbs/'; |
| 6963 | 6963 | $pdirthumb = $pdir.'thumbs/'; |
| 6964 | 6964 | |
| 6965 | - $return ='<!-- Photo -->'."\n"; |
|
| 6966 | - $nbphoto=0; |
|
| 6965 | + $return = '<!-- Photo -->'."\n"; |
|
| 6966 | + $nbphoto = 0; |
|
| 6967 | 6967 | |
| 6968 | - $filearray=dol_dir_list($dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); |
|
| 6968 | + $filearray = dol_dir_list($dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); |
|
| 6969 | 6969 | |
| 6970 | 6970 | /*if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs |
| 6971 | 6971 | { |
@@ -6979,12 +6979,12 @@ discard block |
||
| 6979 | 6979 | { |
| 6980 | 6980 | if ($sortfield && $sortorder) |
| 6981 | 6981 | { |
| 6982 | - $filearray=dol_sort_array($filearray, $sortfield, $sortorder); |
|
| 6982 | + $filearray = dol_sort_array($filearray, $sortfield, $sortorder); |
|
| 6983 | 6983 | } |
| 6984 | 6984 | |
| 6985 | - foreach($filearray as $key => $val) |
|
| 6985 | + foreach ($filearray as $key => $val) |
|
| 6986 | 6986 | { |
| 6987 | - $photo=''; |
|
| 6987 | + $photo = ''; |
|
| 6988 | 6988 | $file = $val['name']; |
| 6989 | 6989 | |
| 6990 | 6990 | //if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory |
@@ -6998,36 +6998,36 @@ discard block |
||
| 6998 | 6998 | |
| 6999 | 6999 | if ($size == 1 || $size == 'small') { // Format vignette |
| 7000 | 7000 | // Find name of thumb file |
| 7001 | - $photo_vignette=basename(getImageFileNameForSize($dir.$file, '_small')); |
|
| 7002 | - if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette=''; |
|
| 7001 | + $photo_vignette = basename(getImageFileNameForSize($dir.$file, '_small')); |
|
| 7002 | + if (!dol_is_file($dirthumb.$photo_vignette)) $photo_vignette = ''; |
|
| 7003 | 7003 | |
| 7004 | 7004 | // Get filesize of original file |
| 7005 | - $imgarray=dol_getImageSize($dir.$photo); |
|
| 7005 | + $imgarray = dol_getImageSize($dir.$photo); |
|
| 7006 | 7006 | |
| 7007 | 7007 | if ($nbbyrow > 0) |
| 7008 | 7008 | { |
| 7009 | - if ($nbphoto == 1) $return.= '<table class="valigntop center centpercent" style="border: 0; padding: 2; border-spacing: 2px; border-collapse: separate;">'; |
|
| 7009 | + if ($nbphoto == 1) $return .= '<table class="valigntop center centpercent" style="border: 0; padding: 2; border-spacing: 2px; border-collapse: separate;">'; |
|
| 7010 | 7010 | |
| 7011 | - if ($nbphoto % $nbbyrow == 1) $return.= '<tr class="center valignmiddle" style="border: 1px">'; |
|
| 7012 | - $return.= '<td style="width: '.ceil(100/$nbbyrow).'%" class="photo">'; |
|
| 7011 | + if ($nbphoto % $nbbyrow == 1) $return .= '<tr class="center valignmiddle" style="border: 1px">'; |
|
| 7012 | + $return .= '<td style="width: '.ceil(100 / $nbbyrow).'%" class="photo">'; |
|
| 7013 | 7013 | } |
| 7014 | 7014 | elseif ($nbbyrow < 0) $return .= '<div class="inline-block">'; |
| 7015 | 7015 | |
| 7016 | - $return.= "\n"; |
|
| 7016 | + $return .= "\n"; |
|
| 7017 | 7017 | |
| 7018 | - $relativefile=preg_replace('/^\//', '', $pdir.$photo); |
|
| 7018 | + $relativefile = preg_replace('/^\//', '', $pdir.$photo); |
|
| 7019 | 7019 | if (empty($nolink)) |
| 7020 | 7020 | { |
| 7021 | - $urladvanced=getAdvancedPreviewUrl($modulepart, $relativefile, 0, 'entity='.$this->entity); |
|
| 7022 | - if ($urladvanced) $return.='<a href="'.$urladvanced.'">'; |
|
| 7023 | - else $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">'; |
|
| 7021 | + $urladvanced = getAdvancedPreviewUrl($modulepart, $relativefile, 0, 'entity='.$this->entity); |
|
| 7022 | + if ($urladvanced) $return .= '<a href="'.$urladvanced.'">'; |
|
| 7023 | + else $return .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">'; |
|
| 7024 | 7024 | } |
| 7025 | 7025 | |
| 7026 | 7026 | // Show image (width height=$maxHeight) |
| 7027 | 7027 | // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine |
| 7028 | - $alt=$langs->transnoentitiesnoconv('File').': '.$relativefile; |
|
| 7029 | - $alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; |
|
| 7030 | - if ($notitle) $alt=''; |
|
| 7028 | + $alt = $langs->transnoentitiesnoconv('File').': '.$relativefile; |
|
| 7029 | + $alt .= ' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; |
|
| 7030 | + if ($notitle) $alt = ''; |
|
| 7031 | 7031 | |
| 7032 | 7032 | if ($usesharelink) |
| 7033 | 7033 | { |
@@ -7035,81 +7035,81 @@ discard block |
||
| 7035 | 7035 | { |
| 7036 | 7036 | if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) |
| 7037 | 7037 | { |
| 7038 | - $return.= '<!-- Show original file (thumb not yet available with shared links) -->'; |
|
| 7039 | - $return.= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">'; |
|
| 7038 | + $return .= '<!-- Show original file (thumb not yet available with shared links) -->'; |
|
| 7039 | + $return .= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">'; |
|
| 7040 | 7040 | } |
| 7041 | 7041 | else { |
| 7042 | - $return.= '<!-- Show original file -->'; |
|
| 7043 | - $return.= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">'; |
|
| 7042 | + $return .= '<!-- Show original file -->'; |
|
| 7043 | + $return .= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">'; |
|
| 7044 | 7044 | } |
| 7045 | 7045 | } |
| 7046 | 7046 | else |
| 7047 | 7047 | { |
| 7048 | - $return.= '<!-- Show nophoto file (because file is not shared) -->'; |
|
| 7049 | - $return.= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png" title="'.dol_escape_htmltag($alt).'">'; |
|
| 7048 | + $return .= '<!-- Show nophoto file (because file is not shared) -->'; |
|
| 7049 | + $return .= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png" title="'.dol_escape_htmltag($alt).'">'; |
|
| 7050 | 7050 | } |
| 7051 | 7051 | } |
| 7052 | 7052 | else |
| 7053 | 7053 | { |
| 7054 | 7054 | if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) |
| 7055 | 7055 | { |
| 7056 | - $return.= '<!-- Show thumb -->'; |
|
| 7057 | - $return.= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; |
|
| 7056 | + $return .= '<!-- Show thumb -->'; |
|
| 7057 | + $return .= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; |
|
| 7058 | 7058 | } |
| 7059 | 7059 | else { |
| 7060 | - $return.= '<!-- Show original file -->'; |
|
| 7061 | - $return.= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; |
|
| 7060 | + $return .= '<!-- Show original file -->'; |
|
| 7061 | + $return .= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; |
|
| 7062 | 7062 | } |
| 7063 | 7063 | } |
| 7064 | 7064 | |
| 7065 | - if (empty($nolink)) $return.= '</a>'; |
|
| 7066 | - $return.="\n"; |
|
| 7065 | + if (empty($nolink)) $return .= '</a>'; |
|
| 7066 | + $return .= "\n"; |
|
| 7067 | 7067 | |
| 7068 | - if ($showfilename) $return.= '<br>'.$viewfilename; |
|
| 7068 | + if ($showfilename) $return .= '<br>'.$viewfilename; |
|
| 7069 | 7069 | if ($showaction) |
| 7070 | 7070 | { |
| 7071 | - $return.= '<br>'; |
|
| 7071 | + $return .= '<br>'; |
|
| 7072 | 7072 | // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites |
| 7073 | 7073 | if ($photo_vignette && (image_format_supported($photo) > 0) && ($this->imgWidth > $maxWidth || $this->imgHeight > $maxHeight)) |
| 7074 | 7074 | { |
| 7075 | - $return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=addthumb&file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'), 'refresh').' </a>'; |
|
| 7075 | + $return .= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=addthumb&file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'), 'refresh').' </a>'; |
|
| 7076 | 7076 | } |
| 7077 | 7077 | // Special cas for product |
| 7078 | 7078 | if ($modulepart == 'product' && ($user->rights->produit->creer || $user->rights->service->creer)) |
| 7079 | 7079 | { |
| 7080 | 7080 | // Link to resize |
| 7081 | - $return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"), 'resize', '').'</a> '; |
|
| 7081 | + $return .= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"), 'resize', '').'</a> '; |
|
| 7082 | 7082 | |
| 7083 | 7083 | // Link to delete |
| 7084 | - $return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=delete&file='.urlencode($pdir.$viewfilename).'">'; |
|
| 7085 | - $return.= img_delete().'</a>'; |
|
| 7084 | + $return .= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=delete&file='.urlencode($pdir.$viewfilename).'">'; |
|
| 7085 | + $return .= img_delete().'</a>'; |
|
| 7086 | 7086 | } |
| 7087 | 7087 | } |
| 7088 | - $return.= "\n"; |
|
| 7088 | + $return .= "\n"; |
|
| 7089 | 7089 | |
| 7090 | 7090 | if ($nbbyrow > 0) |
| 7091 | 7091 | { |
| 7092 | - $return.= '</td>'; |
|
| 7093 | - if (($nbphoto % $nbbyrow) == 0) $return.= '</tr>'; |
|
| 7092 | + $return .= '</td>'; |
|
| 7093 | + if (($nbphoto % $nbbyrow) == 0) $return .= '</tr>'; |
|
| 7094 | 7094 | } |
| 7095 | - elseif ($nbbyrow < 0) $return.='</div>'; |
|
| 7095 | + elseif ($nbbyrow < 0) $return .= '</div>'; |
|
| 7096 | 7096 | } |
| 7097 | 7097 | |
| 7098 | 7098 | if (empty($size)) { // Format origine |
| 7099 | - $return.= '<img class="photo photowithmargin" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">'; |
|
| 7099 | + $return .= '<img class="photo photowithmargin" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">'; |
|
| 7100 | 7100 | |
| 7101 | - if ($showfilename) $return.= '<br>'.$viewfilename; |
|
| 7101 | + if ($showfilename) $return .= '<br>'.$viewfilename; |
|
| 7102 | 7102 | if ($showaction) |
| 7103 | 7103 | { |
| 7104 | 7104 | // Special case for product |
| 7105 | 7105 | if ($modulepart == 'product' && ($user->rights->produit->creer || $user->rights->service->creer)) |
| 7106 | 7106 | { |
| 7107 | 7107 | // Link to resize |
| 7108 | - $return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"), 'resize', '').'</a> '; |
|
| 7108 | + $return .= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"), 'resize', '').'</a> '; |
|
| 7109 | 7109 | |
| 7110 | 7110 | // Link to delete |
| 7111 | - $return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=delete&file='.urlencode($pdir.$viewfilename).'">'; |
|
| 7112 | - $return.= img_delete().'</a>'; |
|
| 7111 | + $return .= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=delete&file='.urlencode($pdir.$viewfilename).'">'; |
|
| 7112 | + $return .= img_delete().'</a>'; |
|
| 7113 | 7113 | } |
| 7114 | 7114 | } |
| 7115 | 7115 | } |
@@ -7119,18 +7119,18 @@ discard block |
||
| 7119 | 7119 | } |
| 7120 | 7120 | } |
| 7121 | 7121 | |
| 7122 | - if ($size==1 || $size=='small') |
|
| 7122 | + if ($size == 1 || $size == 'small') |
|
| 7123 | 7123 | { |
| 7124 | 7124 | if ($nbbyrow > 0) |
| 7125 | 7125 | { |
| 7126 | 7126 | // Ferme tableau |
| 7127 | 7127 | while ($nbphoto % $nbbyrow) |
| 7128 | 7128 | { |
| 7129 | - $return.= '<td style="width: '.ceil(100/$nbbyrow).'%"> </td>'; |
|
| 7129 | + $return .= '<td style="width: '.ceil(100 / $nbbyrow).'%"> </td>'; |
|
| 7130 | 7130 | $nbphoto++; |
| 7131 | 7131 | } |
| 7132 | 7132 | |
| 7133 | - if ($nbphoto) $return.= '</table>'; |
|
| 7133 | + if ($nbphoto) $return .= '</table>'; |
|
| 7134 | 7134 | } |
| 7135 | 7135 | } |
| 7136 | 7136 | } |
@@ -7151,7 +7151,7 @@ discard block |
||
| 7151 | 7151 | { |
| 7152 | 7152 | if (is_array($info)) |
| 7153 | 7153 | { |
| 7154 | - if(isset($info['type']) && $info['type']=='array') return true; |
|
| 7154 | + if (isset($info['type']) && $info['type'] == 'array') return true; |
|
| 7155 | 7155 | else return false; |
| 7156 | 7156 | } |
| 7157 | 7157 | return false; |
@@ -7165,7 +7165,7 @@ discard block |
||
| 7165 | 7165 | */ |
| 7166 | 7166 | public function isDate($info) |
| 7167 | 7167 | { |
| 7168 | - if (isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true; |
|
| 7168 | + if (isset($info['type']) && ($info['type'] == 'date' || $info['type'] == 'datetime' || $info['type'] == 'timestamp')) return true; |
|
| 7169 | 7169 | return false; |
| 7170 | 7170 | } |
| 7171 | 7171 | |
@@ -7177,9 +7177,9 @@ discard block |
||
| 7177 | 7177 | */ |
| 7178 | 7178 | public function isInt($info) |
| 7179 | 7179 | { |
| 7180 | - if(is_array($info)) |
|
| 7180 | + if (is_array($info)) |
|
| 7181 | 7181 | { |
| 7182 | - if (isset($info['type']) && ($info['type']=='int' || preg_match('/^integer/i', $info['type']))) return true; |
|
| 7182 | + if (isset($info['type']) && ($info['type'] == 'int' || preg_match('/^integer/i', $info['type']))) return true; |
|
| 7183 | 7183 | else return false; |
| 7184 | 7184 | } |
| 7185 | 7185 | else return false; |
@@ -7211,7 +7211,7 @@ discard block |
||
| 7211 | 7211 | { |
| 7212 | 7212 | if (is_array($info)) |
| 7213 | 7213 | { |
| 7214 | - if(isset($info['type']) && $info['type']=='text') return true; |
|
| 7214 | + if (isset($info['type']) && $info['type'] == 'text') return true; |
|
| 7215 | 7215 | else return false; |
| 7216 | 7216 | } |
| 7217 | 7217 | return false; |
@@ -7227,7 +7227,7 @@ discard block |
||
| 7227 | 7227 | { |
| 7228 | 7228 | if (is_array($info)) |
| 7229 | 7229 | { |
| 7230 | - if(isset($info['notnull']) && $info['notnull']!='1') return true; |
|
| 7230 | + if (isset($info['notnull']) && $info['notnull'] != '1') return true; |
|
| 7231 | 7231 | else return false; |
| 7232 | 7232 | } |
| 7233 | 7233 | return true; |
@@ -7243,7 +7243,7 @@ discard block |
||
| 7243 | 7243 | { |
| 7244 | 7244 | if (is_array($info)) |
| 7245 | 7245 | { |
| 7246 | - if(isset($info['notnull']) && $info['notnull']=='-1') return true; |
|
| 7246 | + if (isset($info['notnull']) && $info['notnull'] == '-1') return true; |
|
| 7247 | 7247 | else return false; |
| 7248 | 7248 | } |
| 7249 | 7249 | return false; |
@@ -7259,7 +7259,7 @@ discard block |
||
| 7259 | 7259 | { |
| 7260 | 7260 | if (is_array($info)) |
| 7261 | 7261 | { |
| 7262 | - if(isset($info['index']) && $info['index']==true) return true; |
|
| 7262 | + if (isset($info['index']) && $info['index'] == true) return true; |
|
| 7263 | 7263 | else return false; |
| 7264 | 7264 | } |
| 7265 | 7265 | return false; |
@@ -7277,13 +7277,13 @@ discard block |
||
| 7277 | 7277 | { |
| 7278 | 7278 | global $conf; |
| 7279 | 7279 | |
| 7280 | - $queryarray=array(); |
|
| 7280 | + $queryarray = array(); |
|
| 7281 | 7281 | foreach ($this->fields as $field=>$info) // Loop on definition of fields |
| 7282 | 7282 | { |
| 7283 | 7283 | // Depending on field type ('datetime', ...) |
| 7284 | - if($this->isDate($info)) |
|
| 7284 | + if ($this->isDate($info)) |
|
| 7285 | 7285 | { |
| 7286 | - if(empty($this->{$field})) |
|
| 7286 | + if (empty($this->{$field})) |
|
| 7287 | 7287 | { |
| 7288 | 7288 | $queryarray[$field] = null; |
| 7289 | 7289 | } |
@@ -7292,10 +7292,10 @@ discard block |
||
| 7292 | 7292 | $queryarray[$field] = $this->db->idate($this->{$field}); |
| 7293 | 7293 | } |
| 7294 | 7294 | } |
| 7295 | - elseif($this->isArray($info)) |
|
| 7295 | + elseif ($this->isArray($info)) |
|
| 7296 | 7296 | { |
| 7297 | - if(! empty($this->{$field})) { |
|
| 7298 | - if(! is_array($this->{$field})) { |
|
| 7297 | + if (!empty($this->{$field})) { |
|
| 7298 | + if (!is_array($this->{$field})) { |
|
| 7299 | 7299 | $this->{$field} = array($this->{$field}); |
| 7300 | 7300 | } |
| 7301 | 7301 | $queryarray[$field] = serialize($this->{$field}); |
@@ -7303,19 +7303,19 @@ discard block |
||
| 7303 | 7303 | $queryarray[$field] = null; |
| 7304 | 7304 | } |
| 7305 | 7305 | } |
| 7306 | - elseif($this->isInt($info)) |
|
| 7306 | + elseif ($this->isInt($info)) |
|
| 7307 | 7307 | { |
| 7308 | - if ($field == 'entity' && is_null($this->{$field})) $queryarray[$field]=$conf->entity; |
|
| 7308 | + if ($field == 'entity' && is_null($this->{$field})) $queryarray[$field] = $conf->entity; |
|
| 7309 | 7309 | else |
| 7310 | 7310 | { |
| 7311 | 7311 | $queryarray[$field] = (int) $this->{$field}; |
| 7312 | - if (empty($queryarray[$field])) $queryarray[$field]=0; // May be reset to null later if property 'notnull' is -1 for this field. |
|
| 7312 | + if (empty($queryarray[$field])) $queryarray[$field] = 0; // May be reset to null later if property 'notnull' is -1 for this field. |
|
| 7313 | 7313 | } |
| 7314 | 7314 | } |
| 7315 | - elseif($this->isFloat($info)) |
|
| 7315 | + elseif ($this->isFloat($info)) |
|
| 7316 | 7316 | { |
| 7317 | 7317 | $queryarray[$field] = (double) $this->{$field}; |
| 7318 | - if (empty($queryarray[$field])) $queryarray[$field]=0; |
|
| 7318 | + if (empty($queryarray[$field])) $queryarray[$field] = 0; |
|
| 7319 | 7319 | } |
| 7320 | 7320 | else |
| 7321 | 7321 | { |
@@ -7323,7 +7323,7 @@ discard block |
||
| 7323 | 7323 | } |
| 7324 | 7324 | |
| 7325 | 7325 | if ($info['type'] == 'timestamp' && empty($queryarray[$field])) unset($queryarray[$field]); |
| 7326 | - if (! empty($info['notnull']) && $info['notnull'] == -1 && empty($queryarray[$field])) $queryarray[$field] = null; |
|
| 7326 | + if (!empty($info['notnull']) && $info['notnull'] == -1 && empty($queryarray[$field])) $queryarray[$field] = null; |
|
| 7327 | 7327 | } |
| 7328 | 7328 | |
| 7329 | 7329 | return $queryarray; |
@@ -7339,22 +7339,22 @@ discard block |
||
| 7339 | 7339 | { |
| 7340 | 7340 | foreach ($this->fields as $field => $info) |
| 7341 | 7341 | { |
| 7342 | - if($this->isDate($info)) |
|
| 7342 | + if ($this->isDate($info)) |
|
| 7343 | 7343 | { |
| 7344 | - if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; |
|
| 7344 | + if (empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; |
|
| 7345 | 7345 | else $this->{$field} = strtotime($obj->{$field}); |
| 7346 | 7346 | } |
| 7347 | - elseif($this->isArray($info)) |
|
| 7347 | + elseif ($this->isArray($info)) |
|
| 7348 | 7348 | { |
| 7349 | - if(! empty($obj->{$field})) { |
|
| 7349 | + if (!empty($obj->{$field})) { |
|
| 7350 | 7350 | $this->{$field} = @unserialize($obj->{$field}); |
| 7351 | 7351 | // Hack for data not in UTF8 |
| 7352 | - if($this->{$field } === false) @unserialize(utf8_decode($obj->{$field})); |
|
| 7352 | + if ($this->{$field } === false) @unserialize(utf8_decode($obj->{$field})); |
|
| 7353 | 7353 | } else { |
| 7354 | 7354 | $this->{$field} = array(); |
| 7355 | 7355 | } |
| 7356 | 7356 | } |
| 7357 | - elseif($this->isInt($info)) |
|
| 7357 | + elseif ($this->isInt($info)) |
|
| 7358 | 7358 | { |
| 7359 | 7359 | if ($field == 'rowid') $this->id = (int) $obj->{$field}; |
| 7360 | 7360 | else |
@@ -7370,7 +7370,7 @@ discard block |
||
| 7370 | 7370 | } |
| 7371 | 7371 | } |
| 7372 | 7372 | } |
| 7373 | - elseif($this->isFloat($info)) |
|
| 7373 | + elseif ($this->isFloat($info)) |
|
| 7374 | 7374 | { |
| 7375 | 7375 | if ($this->isForcedToNullIfZero($info)) |
| 7376 | 7376 | { |
@@ -7389,7 +7389,7 @@ discard block |
||
| 7389 | 7389 | } |
| 7390 | 7390 | |
| 7391 | 7391 | // If there is no 'ref' field, we force property ->ref to ->id for a better compatibility with common functions. |
| 7392 | - if (! isset($this->fields['ref']) && isset($this->id)) $this->ref = $this->id; |
|
| 7392 | + if (!isset($this->fields['ref']) && isset($this->id)) $this->ref = $this->id; |
|
| 7393 | 7393 | } |
| 7394 | 7394 | |
| 7395 | 7395 | /** |
@@ -7431,13 +7431,13 @@ discard block |
||
| 7431 | 7431 | |
| 7432 | 7432 | $error = 0; |
| 7433 | 7433 | |
| 7434 | - $now=dol_now(); |
|
| 7434 | + $now = dol_now(); |
|
| 7435 | 7435 | |
| 7436 | 7436 | $fieldvalues = $this->setSaveQuery(); |
| 7437 | - if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation']=$this->db->idate($now); |
|
| 7438 | - if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id; |
|
| 7439 | - unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. |
|
| 7440 | - if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref']=dol_string_nospecial($fieldvalues['ref']); // If field is a ref,we sanitize data |
|
| 7437 | + if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now); |
|
| 7438 | + if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id; |
|
| 7439 | + unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. |
|
| 7440 | + if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref,we sanitize data |
|
| 7441 | 7441 | |
| 7442 | 7442 | $keys = array(); |
| 7443 | 7443 | $values = array(); |
@@ -7448,55 +7448,55 @@ discard block |
||
| 7448 | 7448 | } |
| 7449 | 7449 | |
| 7450 | 7450 | // Clean and check mandatory |
| 7451 | - foreach($keys as $key) |
|
| 7451 | + foreach ($keys as $key) |
|
| 7452 | 7452 | { |
| 7453 | 7453 | // If field is an implicit foreign key field |
| 7454 | - if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key]=''; |
|
| 7455 | - if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]=''; |
|
| 7454 | + if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = ''; |
|
| 7455 | + if (!empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key] = ''; |
|
| 7456 | 7456 | |
| 7457 | 7457 | //var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1)); |
| 7458 | - if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && ! isset($values[$key]) && is_null($val['default'])) |
|
| 7458 | + if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && !isset($values[$key]) && is_null($val['default'])) |
|
| 7459 | 7459 | { |
| 7460 | 7460 | $error++; |
| 7461 | - $this->errors[]=$langs->trans("ErrorFieldRequired", $this->fields[$key]['label']); |
|
| 7461 | + $this->errors[] = $langs->trans("ErrorFieldRequired", $this->fields[$key]['label']); |
|
| 7462 | 7462 | } |
| 7463 | 7463 | |
| 7464 | 7464 | // If field is an implicit foreign key field |
| 7465 | - if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) $values[$key]='null'; |
|
| 7466 | - if (! empty($this->fields[$key]['foreignkey']) && empty($values[$key])) $values[$key]='null'; |
|
| 7465 | + if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) $values[$key] = 'null'; |
|
| 7466 | + if (!empty($this->fields[$key]['foreignkey']) && empty($values[$key])) $values[$key] = 'null'; |
|
| 7467 | 7467 | } |
| 7468 | 7468 | |
| 7469 | 7469 | if ($error) return -1; |
| 7470 | 7470 | |
| 7471 | 7471 | $this->db->begin(); |
| 7472 | 7472 | |
| 7473 | - if (! $error) |
|
| 7473 | + if (!$error) |
|
| 7474 | 7474 | { |
| 7475 | 7475 | $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element; |
| 7476 | - $sql.= ' ('.implode(", ", $keys).')'; |
|
| 7477 | - $sql.= ' VALUES ('.implode(", ", $values).')'; |
|
| 7476 | + $sql .= ' ('.implode(", ", $keys).')'; |
|
| 7477 | + $sql .= ' VALUES ('.implode(", ", $values).')'; |
|
| 7478 | 7478 | |
| 7479 | 7479 | $res = $this->db->query($sql); |
| 7480 | - if ($res===false) { |
|
| 7480 | + if ($res === false) { |
|
| 7481 | 7481 | $error++; |
| 7482 | 7482 | $this->errors[] = $this->db->lasterror(); |
| 7483 | 7483 | } |
| 7484 | 7484 | } |
| 7485 | 7485 | |
| 7486 | - if (! $error) |
|
| 7486 | + if (!$error) |
|
| 7487 | 7487 | { |
| 7488 | - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); |
|
| 7488 | + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); |
|
| 7489 | 7489 | } |
| 7490 | 7490 | |
| 7491 | 7491 | // If we have a field ref with a default value of (PROV) |
| 7492 | - if (! $error) |
|
| 7492 | + if (!$error) |
|
| 7493 | 7493 | { |
| 7494 | - if (key_exists('ref', $this->fields) && $this->fields['ref']['notnull'] > 0 && ! is_null($this->fields['ref']['default']) && $this->fields['ref']['default'] == '(PROV)') |
|
| 7494 | + if (key_exists('ref', $this->fields) && $this->fields['ref']['notnull'] > 0 && !is_null($this->fields['ref']['default']) && $this->fields['ref']['default'] == '(PROV)') |
|
| 7495 | 7495 | { |
| 7496 | - $sql="UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".$this->id.")' WHERE ref = '(PROV)' AND rowid = ".$this->id; |
|
| 7496 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".$this->id.")' WHERE ref = '(PROV)' AND rowid = ".$this->id; |
|
| 7497 | 7497 | $resqlupdate = $this->db->query($sql); |
| 7498 | 7498 | |
| 7499 | - if ($resqlupdate===false) |
|
| 7499 | + if ($resqlupdate === false) |
|
| 7500 | 7500 | { |
| 7501 | 7501 | $error++; |
| 7502 | 7502 | $this->errors[] = $this->db->lasterror(); |
@@ -7505,16 +7505,16 @@ discard block |
||
| 7505 | 7505 | } |
| 7506 | 7506 | |
| 7507 | 7507 | // Create extrafields |
| 7508 | - if (! $error) |
|
| 7508 | + if (!$error) |
|
| 7509 | 7509 | { |
| 7510 | - $result=$this->insertExtraFields(); |
|
| 7510 | + $result = $this->insertExtraFields(); |
|
| 7511 | 7511 | if ($result < 0) $error++; |
| 7512 | 7512 | } |
| 7513 | 7513 | |
| 7514 | 7514 | // Create lines |
| 7515 | - if (! empty($this->table_element_line) && ! empty($this->fk_element)) |
|
| 7515 | + if (!empty($this->table_element_line) && !empty($this->fk_element)) |
|
| 7516 | 7516 | { |
| 7517 | - $num=(is_array($this->lines) ? count($this->lines) : 0); |
|
| 7517 | + $num = (is_array($this->lines) ? count($this->lines) : 0); |
|
| 7518 | 7518 | for ($i = 0; $i < $num; $i++) |
| 7519 | 7519 | { |
| 7520 | 7520 | $line = $this->lines[$i]; |
@@ -7524,12 +7524,12 @@ discard block |
||
| 7524 | 7524 | |
| 7525 | 7525 | // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array |
| 7526 | 7526 | //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. |
| 7527 | - if (! is_object($line)) $line = (object) $line; |
|
| 7527 | + if (!is_object($line)) $line = (object) $line; |
|
| 7528 | 7528 | |
| 7529 | 7529 | $result = $line->create($user, 1); |
| 7530 | 7530 | if ($result < 0) |
| 7531 | 7531 | { |
| 7532 | - $this->error=$this->db->lasterror(); |
|
| 7532 | + $this->error = $this->db->lasterror(); |
|
| 7533 | 7533 | $this->db->rollback(); |
| 7534 | 7534 | return -1; |
| 7535 | 7535 | } |
@@ -7537,10 +7537,10 @@ discard block |
||
| 7537 | 7537 | } |
| 7538 | 7538 | |
| 7539 | 7539 | // Triggers |
| 7540 | - if (! $error && ! $notrigger) |
|
| 7540 | + if (!$error && !$notrigger) |
|
| 7541 | 7541 | { |
| 7542 | 7542 | // Call triggers |
| 7543 | - $result=$this->call_trigger(strtoupper(get_class($this)).'_CREATE', $user); |
|
| 7543 | + $result = $this->call_trigger(strtoupper(get_class($this)).'_CREATE', $user); |
|
| 7544 | 7544 | if ($result < 0) { $error++; } |
| 7545 | 7545 | // End call triggers |
| 7546 | 7546 | } |
@@ -7569,14 +7569,14 @@ discard block |
||
| 7569 | 7569 | if (empty($id) && empty($ref) && empty($morewhere)) return -1; |
| 7570 | 7570 | |
| 7571 | 7571 | $sql = 'SELECT '.$this->getFieldList(); |
| 7572 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
| 7572 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
| 7573 | 7573 | |
| 7574 | - if (!empty($id)) $sql.= ' WHERE rowid = '.$id; |
|
| 7575 | - elseif (!empty($ref)) $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); |
|
| 7576 | - else $sql.=' WHERE 1 = 1'; // usage with empty id and empty ref is very rare |
|
| 7577 | - if (empty($id) && isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.=' AND entity IN ('.getEntity($this->table_element).')'; |
|
| 7578 | - if ($morewhere) $sql.= $morewhere; |
|
| 7579 | - $sql.=' LIMIT 1'; // This is a fetch, to be sure to get only one record |
|
| 7574 | + if (!empty($id)) $sql .= ' WHERE rowid = '.$id; |
|
| 7575 | + elseif (!empty($ref)) $sql .= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); |
|
| 7576 | + else $sql .= ' WHERE 1 = 1'; // usage with empty id and empty ref is very rare |
|
| 7577 | + if (empty($id) && isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' AND entity IN ('.getEntity($this->table_element).')'; |
|
| 7578 | + if ($morewhere) $sql .= $morewhere; |
|
| 7579 | + $sql .= ' LIMIT 1'; // This is a fetch, to be sure to get only one record |
|
| 7580 | 7580 | |
| 7581 | 7581 | $res = $this->db->query($sql); |
| 7582 | 7582 | if ($res) |
@@ -7609,7 +7609,7 @@ discard block |
||
| 7609 | 7609 | public function fetchLinesCommon($morewhere = '') |
| 7610 | 7610 | { |
| 7611 | 7611 | $objectlineclassname = get_class($this).'Line'; |
| 7612 | - if (! class_exists($objectlineclassname)) |
|
| 7612 | + if (!class_exists($objectlineclassname)) |
|
| 7613 | 7613 | { |
| 7614 | 7614 | $this->error = 'Error, class '.$objectlineclassname.' not found during call of fetchLinesCommon'; |
| 7615 | 7615 | return -1; |
@@ -7618,9 +7618,9 @@ discard block |
||
| 7618 | 7618 | $objectline = new $objectlineclassname($this->db); |
| 7619 | 7619 | |
| 7620 | 7620 | $sql = 'SELECT '.$objectline->getFieldList(); |
| 7621 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$objectline->table_element; |
|
| 7622 | - $sql.=' WHERE fk_'.$this->element.' = '.$this->id; |
|
| 7623 | - if ($morewhere) $sql.= $morewhere; |
|
| 7621 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$objectline->table_element; |
|
| 7622 | + $sql .= ' WHERE fk_'.$this->element.' = '.$this->id; |
|
| 7623 | + if ($morewhere) $sql .= $morewhere; |
|
| 7624 | 7624 | |
| 7625 | 7625 | $resql = $this->db->query($sql); |
| 7626 | 7626 | if ($resql) |
@@ -7663,12 +7663,12 @@ discard block |
||
| 7663 | 7663 | |
| 7664 | 7664 | $error = 0; |
| 7665 | 7665 | |
| 7666 | - $now=dol_now(); |
|
| 7666 | + $now = dol_now(); |
|
| 7667 | 7667 | |
| 7668 | 7668 | $fieldvalues = $this->setSaveQuery(); |
| 7669 | - if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification']=$this->db->idate($now); |
|
| 7670 | - if (array_key_exists('fk_user_modif', $fieldvalues) && ! ($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif']=$user->id; |
|
| 7671 | - unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update. |
|
| 7669 | + if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification'] = $this->db->idate($now); |
|
| 7670 | + if (array_key_exists('fk_user_modif', $fieldvalues) && !($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif'] = $user->id; |
|
| 7671 | + unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update. |
|
| 7672 | 7672 | |
| 7673 | 7673 | $keys = array(); |
| 7674 | 7674 | $values = array(); |
@@ -7681,10 +7681,10 @@ discard block |
||
| 7681 | 7681 | } |
| 7682 | 7682 | |
| 7683 | 7683 | // Clean and check mandatory |
| 7684 | - foreach($keys as $key) |
|
| 7684 | + foreach ($keys as $key) |
|
| 7685 | 7685 | { |
| 7686 | - if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key]=''; // This is an implicit foreign key field |
|
| 7687 | - if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]=''; // This is an explicit foreign key field |
|
| 7686 | + if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = ''; // This is an implicit foreign key field |
|
| 7687 | + if (!empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key] = ''; // This is an explicit foreign key field |
|
| 7688 | 7688 | |
| 7689 | 7689 | //var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1)); |
| 7690 | 7690 | /* |
@@ -7695,13 +7695,13 @@ discard block |
||
| 7695 | 7695 | }*/ |
| 7696 | 7696 | } |
| 7697 | 7697 | |
| 7698 | - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode(',', $tmp).' WHERE rowid='.$this->id ; |
|
| 7698 | + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode(',', $tmp).' WHERE rowid='.$this->id; |
|
| 7699 | 7699 | |
| 7700 | 7700 | $this->db->begin(); |
| 7701 | - if (! $error) |
|
| 7701 | + if (!$error) |
|
| 7702 | 7702 | { |
| 7703 | 7703 | $res = $this->db->query($sql); |
| 7704 | - if ($res===false) |
|
| 7704 | + if ($res === false) |
|
| 7705 | 7705 | { |
| 7706 | 7706 | $error++; |
| 7707 | 7707 | $this->errors[] = $this->db->lasterror(); |
@@ -7709,9 +7709,9 @@ discard block |
||
| 7709 | 7709 | } |
| 7710 | 7710 | |
| 7711 | 7711 | // Update extrafield |
| 7712 | - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) |
|
| 7712 | + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) |
|
| 7713 | 7713 | { |
| 7714 | - $result=$this->insertExtraFields(); |
|
| 7714 | + $result = $this->insertExtraFields(); |
|
| 7715 | 7715 | if ($result < 0) |
| 7716 | 7716 | { |
| 7717 | 7717 | $error++; |
@@ -7719,10 +7719,10 @@ discard block |
||
| 7719 | 7719 | } |
| 7720 | 7720 | |
| 7721 | 7721 | // Triggers |
| 7722 | - if (! $error && ! $notrigger) |
|
| 7722 | + if (!$error && !$notrigger) |
|
| 7723 | 7723 | { |
| 7724 | 7724 | // Call triggers |
| 7725 | - $result=$this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $user); |
|
| 7725 | + $result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $user); |
|
| 7726 | 7726 | if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail |
| 7727 | 7727 | // End call triggers |
| 7728 | 7728 | } |
@@ -7747,82 +7747,82 @@ discard block |
||
| 7747 | 7747 | */ |
| 7748 | 7748 | public function deleteCommon(User $user, $notrigger = false, $forcechilddeletion = 0) |
| 7749 | 7749 | { |
| 7750 | - $error=0; |
|
| 7750 | + $error = 0; |
|
| 7751 | 7751 | |
| 7752 | 7752 | $this->db->begin(); |
| 7753 | 7753 | |
| 7754 | 7754 | if ($forcechilddeletion) // Force also delete of childtables that should lock deletion in standard case when option force is off |
| 7755 | 7755 | { |
| 7756 | - foreach($this->childtables as $table) |
|
| 7756 | + foreach ($this->childtables as $table) |
|
| 7757 | 7757 | { |
| 7758 | 7758 | $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id; |
| 7759 | 7759 | $resql = $this->db->query($sql); |
| 7760 | - if (! $resql) |
|
| 7760 | + if (!$resql) |
|
| 7761 | 7761 | { |
| 7762 | - $this->error=$this->db->lasterror(); |
|
| 7763 | - $this->errors[]=$this->error; |
|
| 7762 | + $this->error = $this->db->lasterror(); |
|
| 7763 | + $this->errors[] = $this->error; |
|
| 7764 | 7764 | $this->db->rollback(); |
| 7765 | 7765 | return -1; |
| 7766 | 7766 | } |
| 7767 | 7767 | } |
| 7768 | 7768 | } |
| 7769 | - elseif (! empty($this->fk_element) && ! empty($this->childtables)) // If object has childs linked with a foreign key field, we check all child tables. |
|
| 7769 | + elseif (!empty($this->fk_element) && !empty($this->childtables)) // If object has childs linked with a foreign key field, we check all child tables. |
|
| 7770 | 7770 | { |
| 7771 | 7771 | $objectisused = $this->isObjectUsed($this->id); |
| 7772 | - if (! empty($objectisused)) |
|
| 7772 | + if (!empty($objectisused)) |
|
| 7773 | 7773 | { |
| 7774 | 7774 | dol_syslog(get_class($this)."::deleteCommon Can't delete record as it has some child", LOG_WARNING); |
| 7775 | - $this->error='ErrorRecordHasChildren'; |
|
| 7776 | - $this->errors[]=$this->error; |
|
| 7775 | + $this->error = 'ErrorRecordHasChildren'; |
|
| 7776 | + $this->errors[] = $this->error; |
|
| 7777 | 7777 | $this->db->rollback(); |
| 7778 | 7778 | return 0; |
| 7779 | 7779 | } |
| 7780 | 7780 | } |
| 7781 | 7781 | |
| 7782 | 7782 | // Delete cascade first |
| 7783 | - if (! empty($this->childtablesoncascade)) { |
|
| 7784 | - foreach($this->childtablesoncascade as $table) |
|
| 7783 | + if (!empty($this->childtablesoncascade)) { |
|
| 7784 | + foreach ($this->childtablesoncascade as $table) |
|
| 7785 | 7785 | { |
| 7786 | 7786 | $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id; |
| 7787 | 7787 | $resql = $this->db->query($sql); |
| 7788 | - if (! $resql) |
|
| 7788 | + if (!$resql) |
|
| 7789 | 7789 | { |
| 7790 | - $this->error=$this->db->lasterror(); |
|
| 7791 | - $this->errors[]=$this->error; |
|
| 7790 | + $this->error = $this->db->lasterror(); |
|
| 7791 | + $this->errors[] = $this->error; |
|
| 7792 | 7792 | $this->db->rollback(); |
| 7793 | 7793 | return -1; |
| 7794 | 7794 | } |
| 7795 | 7795 | } |
| 7796 | 7796 | } |
| 7797 | 7797 | |
| 7798 | - if (! $error) { |
|
| 7799 | - if (! $notrigger) { |
|
| 7798 | + if (!$error) { |
|
| 7799 | + if (!$notrigger) { |
|
| 7800 | 7800 | // Call triggers |
| 7801 | - $result=$this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user); |
|
| 7801 | + $result = $this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user); |
|
| 7802 | 7802 | if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail |
| 7803 | 7803 | // End call triggers |
| 7804 | 7804 | } |
| 7805 | 7805 | } |
| 7806 | 7806 | |
| 7807 | - if (! $error && ! empty($this->isextrafieldmanaged)) |
|
| 7807 | + if (!$error && !empty($this->isextrafieldmanaged)) |
|
| 7808 | 7808 | { |
| 7809 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . $this->table_element."_extrafields"; |
|
| 7810 | - $sql.= " WHERE fk_object=" . $this->id; |
|
| 7809 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields"; |
|
| 7810 | + $sql .= " WHERE fk_object=".$this->id; |
|
| 7811 | 7811 | |
| 7812 | 7812 | $resql = $this->db->query($sql); |
| 7813 | - if (! $resql) |
|
| 7813 | + if (!$resql) |
|
| 7814 | 7814 | { |
| 7815 | 7815 | $this->errors[] = $this->db->lasterror(); |
| 7816 | 7816 | $error++; |
| 7817 | 7817 | } |
| 7818 | 7818 | } |
| 7819 | 7819 | |
| 7820 | - if (! $error) |
|
| 7820 | + if (!$error) |
|
| 7821 | 7821 | { |
| 7822 | 7822 | $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; |
| 7823 | 7823 | |
| 7824 | 7824 | $res = $this->db->query($sql); |
| 7825 | - if($res===false) { |
|
| 7825 | + if ($res === false) { |
|
| 7826 | 7826 | $error++; |
| 7827 | 7827 | $this->errors[] = $this->db->lasterror(); |
| 7828 | 7828 | } |
@@ -7850,26 +7850,26 @@ discard block |
||
| 7850 | 7850 | { |
| 7851 | 7851 | global $conf; |
| 7852 | 7852 | |
| 7853 | - $error=0; |
|
| 7853 | + $error = 0; |
|
| 7854 | 7854 | |
| 7855 | 7855 | $tmpforobjectclass = get_class($this); |
| 7856 | 7856 | $tmpforobjectlineclass = ucfirst($tmpforobjectclass).'Line'; |
| 7857 | 7857 | |
| 7858 | 7858 | // Call trigger |
| 7859 | - $result=$this->call_trigger('LINE'.strtoupper($tmpforobjectclass).'_DELETE', $user); |
|
| 7859 | + $result = $this->call_trigger('LINE'.strtoupper($tmpforobjectclass).'_DELETE', $user); |
|
| 7860 | 7860 | if ($result < 0) return -1; |
| 7861 | 7861 | // End call triggers |
| 7862 | 7862 | |
| 7863 | 7863 | $this->db->begin(); |
| 7864 | 7864 | |
| 7865 | 7865 | $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element_line; |
| 7866 | - $sql.= " WHERE rowid=".$idline; |
|
| 7866 | + $sql .= " WHERE rowid=".$idline; |
|
| 7867 | 7867 | |
| 7868 | 7868 | dol_syslog(get_class($this)."::deleteLineCommon", LOG_DEBUG); |
| 7869 | 7869 | $resql = $this->db->query($sql); |
| 7870 | - if (! $resql) |
|
| 7870 | + if (!$resql) |
|
| 7871 | 7871 | { |
| 7872 | - $this->error="Error ".$this->db->lasterror(); |
|
| 7872 | + $this->error = "Error ".$this->db->lasterror(); |
|
| 7873 | 7873 | $error++; |
| 7874 | 7874 | } |
| 7875 | 7875 | |
@@ -7878,12 +7878,12 @@ discard block |
||
| 7878 | 7878 | if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
| 7879 | 7879 | { |
| 7880 | 7880 | $tmpobjectline = new $tmpforobjectlineclass($this->db); |
| 7881 | - $tmpobjectline->id= $idline; |
|
| 7882 | - $result=$tmpobjectline->deleteExtraFields(); |
|
| 7881 | + $tmpobjectline->id = $idline; |
|
| 7882 | + $result = $tmpobjectline->deleteExtraFields(); |
|
| 7883 | 7883 | if ($result < 0) |
| 7884 | 7884 | { |
| 7885 | 7885 | $error++; |
| 7886 | - $this->error="Error ".get_class($this)."::deleteLineCommon deleteExtraFields error -4 ".$tmpobjectline->error; |
|
| 7886 | + $this->error = "Error ".get_class($this)."::deleteLineCommon deleteExtraFields error -4 ".$tmpobjectline->error; |
|
| 7887 | 7887 | } |
| 7888 | 7888 | } |
| 7889 | 7889 | } |
@@ -7910,24 +7910,24 @@ discard block |
||
| 7910 | 7910 | */ |
| 7911 | 7911 | public function setStatusCommon($user, $status, $notrigger = 0, $triggercode = '') |
| 7912 | 7912 | { |
| 7913 | - $error=0; |
|
| 7913 | + $error = 0; |
|
| 7914 | 7914 | |
| 7915 | 7915 | $this->db->begin(); |
| 7916 | 7916 | |
| 7917 | 7917 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
| 7918 | - $sql.= " SET status = ".$status; |
|
| 7919 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 7918 | + $sql .= " SET status = ".$status; |
|
| 7919 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 7920 | 7920 | |
| 7921 | 7921 | if ($this->db->query($sql)) |
| 7922 | 7922 | { |
| 7923 | - if (! $error) |
|
| 7923 | + if (!$error) |
|
| 7924 | 7924 | { |
| 7925 | - $this->oldcopy= clone $this; |
|
| 7925 | + $this->oldcopy = clone $this; |
|
| 7926 | 7926 | } |
| 7927 | 7927 | |
| 7928 | - if (! $error && ! $notrigger) { |
|
| 7928 | + if (!$error && !$notrigger) { |
|
| 7929 | 7929 | // Call trigger |
| 7930 | - $result=$this->call_trigger($triggercode, $user); |
|
| 7930 | + $result = $this->call_trigger($triggercode, $user); |
|
| 7931 | 7931 | if ($result < 0) $error++; |
| 7932 | 7932 | } |
| 7933 | 7933 | |
@@ -7942,7 +7942,7 @@ discard block |
||
| 7942 | 7942 | } |
| 7943 | 7943 | else |
| 7944 | 7944 | { |
| 7945 | - $this->error=$this->db->error(); |
|
| 7945 | + $this->error = $this->db->error(); |
|
| 7946 | 7946 | $this->db->rollback(); |
| 7947 | 7947 | return -1; |
| 7948 | 7948 | } |
@@ -7960,14 +7960,14 @@ discard block |
||
| 7960 | 7960 | global $user; |
| 7961 | 7961 | |
| 7962 | 7962 | $this->id = 0; |
| 7963 | - if (array_key_exists('label', $this->fields)) $this->label='This is label'; |
|
| 7964 | - if (array_key_exists('note_public', $this->fields)) $this->note_public='Public note'; |
|
| 7965 | - if (array_key_exists('note_private', $this->fields)) $this->note_private='Private note'; |
|
| 7966 | - if (array_key_exists('date_creation', $this->fields)) $this->date_creation=(dol_now()-3600*24); |
|
| 7967 | - if (array_key_exists('date_modification', $this->fields)) $this->date_modification=(dol_now()-3600*24); |
|
| 7968 | - if (array_key_exists('fk_user_creat', $this->fields)) $this->fk_user_creat=$user->id; |
|
| 7969 | - if (array_key_exists('fk_user_modif', $this->fields)) $this->fk_user_modif=$user->id; |
|
| 7970 | - if (array_key_exists('date', $this->fields)) $this->date=dol_now(); |
|
| 7963 | + if (array_key_exists('label', $this->fields)) $this->label = 'This is label'; |
|
| 7964 | + if (array_key_exists('note_public', $this->fields)) $this->note_public = 'Public note'; |
|
| 7965 | + if (array_key_exists('note_private', $this->fields)) $this->note_private = 'Private note'; |
|
| 7966 | + if (array_key_exists('date_creation', $this->fields)) $this->date_creation = (dol_now() - 3600 * 24); |
|
| 7967 | + if (array_key_exists('date_modification', $this->fields)) $this->date_modification = (dol_now() - 3600 * 24); |
|
| 7968 | + if (array_key_exists('fk_user_creat', $this->fields)) $this->fk_user_creat = $user->id; |
|
| 7969 | + if (array_key_exists('fk_user_modif', $this->fields)) $this->fk_user_modif = $user->id; |
|
| 7970 | + if (array_key_exists('date', $this->fields)) $this->date = dol_now(); |
|
| 7971 | 7971 | // ... |
| 7972 | 7972 | } |
| 7973 | 7973 | |
@@ -7983,9 +7983,9 @@ discard block |
||
| 7983 | 7983 | require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php'; |
| 7984 | 7984 | |
| 7985 | 7985 | $comment = new Comment($this->db); |
| 7986 | - $result=$comment->fetchAllFor($this->element, $this->id); |
|
| 7987 | - if ($result<0) { |
|
| 7988 | - $this->errors=array_merge($this->errors, $comment->errors); |
|
| 7986 | + $result = $comment->fetchAllFor($this->element, $this->id); |
|
| 7987 | + if ($result < 0) { |
|
| 7988 | + $this->errors = array_merge($this->errors, $comment->errors); |
|
| 7989 | 7989 | return -1; |
| 7990 | 7990 | } else { |
| 7991 | 7991 | $this->comments = $comment->comments; |
@@ -8036,11 +8036,11 @@ discard block |
||
| 8036 | 8036 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
| 8037 | 8037 | $categorystatic = new Categorie($this->db); |
| 8038 | 8038 | |
| 8039 | - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_" . $categorystatic->MAP_CAT_TABLE[$type] . " (fk_categorie, fk_product)"; |
|
| 8040 | - $sql.= " SELECT fk_categorie, $toId FROM ".MAIN_DB_PREFIX."categorie_" . $categorystatic->MAP_CAT_TABLE[$type]; |
|
| 8041 | - $sql.= " WHERE fk_product = '".$fromId."'"; |
|
| 8039 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$categorystatic->MAP_CAT_TABLE[$type]." (fk_categorie, fk_product)"; |
|
| 8040 | + $sql .= " SELECT fk_categorie, $toId FROM ".MAIN_DB_PREFIX."categorie_".$categorystatic->MAP_CAT_TABLE[$type]; |
|
| 8041 | + $sql .= " WHERE fk_product = '".$fromId."'"; |
|
| 8042 | 8042 | |
| 8043 | - if (! $this->db->query($sql)) |
|
| 8043 | + if (!$this->db->query($sql)) |
|
| 8044 | 8044 | { |
| 8045 | 8045 | $this->error = $this->db->lasterror(); |
| 8046 | 8046 | $this->db->rollback(); |
@@ -454,23 +454,31 @@ discard block |
||
| 454 | 454 | $sql.= " FROM ".MAIN_DB_PREFIX.$element; |
| 455 | 455 | $sql.= " WHERE entity IN (".getEntity($element).")" ; |
| 456 | 456 | |
| 457 | - if ($id > 0) $sql.= " AND rowid = ".$db->escape($id); |
|
| 458 | - elseif ($ref) $sql.= " AND ref = '".$db->escape($ref)."'"; |
|
| 459 | - elseif ($ref_ext) $sql.= " AND ref_ext = '".$db->escape($ref_ext)."'"; |
|
| 460 | - else { |
|
| 457 | + if ($id > 0) { |
|
| 458 | + $sql.= " AND rowid = ".$db->escape($id); |
|
| 459 | + } elseif ($ref) { |
|
| 460 | + $sql.= " AND ref = '".$db->escape($ref)."'"; |
|
| 461 | + } elseif ($ref_ext) { |
|
| 462 | + $sql.= " AND ref_ext = '".$db->escape($ref_ext)."'"; |
|
| 463 | + } else { |
|
| 461 | 464 | $error='ErrorWrongParameters'; |
| 462 | 465 | dol_print_error(get_class()."::isExistingObject ".$error, LOG_ERR); |
| 463 | 466 | return -1; |
| 464 | 467 | } |
| 465 | - if ($ref || $ref_ext) $sql.= " AND entity = ".$conf->entity; |
|
| 468 | + if ($ref || $ref_ext) { |
|
| 469 | + $sql.= " AND entity = ".$conf->entity; |
|
| 470 | + } |
|
| 466 | 471 | |
| 467 | 472 | dol_syslog(get_class()."::isExistingObject", LOG_DEBUG); |
| 468 | 473 | $resql = $db->query($sql); |
| 469 | 474 | if ($resql) |
| 470 | 475 | { |
| 471 | 476 | $num=$db->num_rows($resql); |
| 472 | - if ($num > 0) return 1; |
|
| 473 | - else return 0; |
|
| 477 | + if ($num > 0) { |
|
| 478 | + return 1; |
|
| 479 | + } else { |
|
| 480 | + return 0; |
|
| 481 | + } |
|
| 474 | 482 | } |
| 475 | 483 | return -1; |
| 476 | 484 | } |
@@ -539,13 +547,18 @@ discard block |
||
| 539 | 547 | //print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."<br>\n"; |
| 540 | 548 | $lastname=$this->lastname; |
| 541 | 549 | $firstname=$this->firstname; |
| 542 | - if (empty($lastname)) $lastname=(isset($this->lastname)?$this->lastname:(isset($this->name)?$this->name:(isset($this->nom)?$this->nom:(isset($this->societe)?$this->societe:(isset($this->company)?$this->company:''))))); |
|
| 550 | + if (empty($lastname)) { |
|
| 551 | + $lastname=(isset($this->lastname)?$this->lastname:(isset($this->name)?$this->name:(isset($this->nom)?$this->nom:(isset($this->societe)?$this->societe:(isset($this->company)?$this->company:''))))); |
|
| 552 | + } |
|
| 543 | 553 | |
| 544 | 554 | $ret=''; |
| 545 | 555 | if ($option && $this->civility_id) |
| 546 | 556 | { |
| 547 | - if ($langs->transnoentitiesnoconv("Civility".$this->civility_id)!="Civility".$this->civility_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civility_id).' '; |
|
| 548 | - else $ret.=$this->civility_id.' '; |
|
| 557 | + if ($langs->transnoentitiesnoconv("Civility".$this->civility_id)!="Civility".$this->civility_id) { |
|
| 558 | + $ret.=$langs->transnoentitiesnoconv("Civility".$this->civility_id).' '; |
|
| 559 | + } else { |
|
| 560 | + $ret.=$this->civility_id.' '; |
|
| 561 | + } |
|
| 549 | 562 | } |
| 550 | 563 | |
| 551 | 564 | $ret.=dolGetFirstLastname($firstname, $lastname, $nameorder); |
@@ -643,14 +656,15 @@ discard block |
||
| 643 | 656 | { |
| 644 | 657 | if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) { |
| 645 | 658 | $out.=($outdone?' - ':'').$this->region.' - '.$this->state; |
| 646 | - } |
|
| 647 | - else { |
|
| 659 | + } else { |
|
| 648 | 660 | $out.=($outdone?' - ':'').$this->state; |
| 649 | 661 | } |
| 650 | 662 | $outdone++; |
| 651 | 663 | } |
| 652 | 664 | |
| 653 | - if (! empty($this->phone) || ! empty($this->phone_pro) || ! empty($this->phone_mobile) || ! empty($this->phone_perso) || ! empty($this->fax) || ! empty($this->office_phone) || ! empty($this->user_mobile) || ! empty($this->office_fax)) $out.=($outdone?'<br>':''); |
|
| 665 | + if (! empty($this->phone) || ! empty($this->phone_pro) || ! empty($this->phone_mobile) || ! empty($this->phone_perso) || ! empty($this->fax) || ! empty($this->office_phone) || ! empty($this->user_mobile) || ! empty($this->office_fax)) { |
|
| 666 | + $out.=($outdone?'<br>':''); |
|
| 667 | + } |
|
| 654 | 668 | if (! empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone |
| 655 | 669 | $out.=dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; |
| 656 | 670 | } |
@@ -698,15 +712,25 @@ discard block |
||
| 698 | 712 | $outdone++; |
| 699 | 713 | } |
| 700 | 714 | } else { |
| 701 | - if ($this->skype) $out.=dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); |
|
| 715 | + if ($this->skype) { |
|
| 716 | + $out.=dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); |
|
| 717 | + } |
|
| 702 | 718 | $outdone++; |
| 703 | - if ($this->jabberid) $out.=dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); |
|
| 719 | + if ($this->jabberid) { |
|
| 720 | + $out.=dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); |
|
| 721 | + } |
|
| 704 | 722 | $outdone++; |
| 705 | - if ($this->twitter) $out.=dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); |
|
| 723 | + if ($this->twitter) { |
|
| 724 | + $out.=dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); |
|
| 725 | + } |
|
| 706 | 726 | $outdone++; |
| 707 | - if ($this->facebook) $out.=dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); |
|
| 727 | + if ($this->facebook) { |
|
| 728 | + $out.=dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); |
|
| 729 | + } |
|
| 708 | 730 | $outdone++; |
| 709 | - if ($this->linkedin) $out.=dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); |
|
| 731 | + if ($this->linkedin) { |
|
| 732 | + $out.=dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); |
|
| 733 | + } |
|
| 710 | 734 | $outdone++; |
| 711 | 735 | } |
| 712 | 736 | } |
@@ -767,10 +791,10 @@ discard block |
||
| 767 | 791 | $this->errors = $ecmfile->errors; |
| 768 | 792 | } |
| 769 | 793 | */ |
| 794 | + } else { |
|
| 795 | + return ''; |
|
| 770 | 796 | } |
| 771 | - else return ''; |
|
| 772 | - } |
|
| 773 | - elseif (empty($ecmfile->share)) |
|
| 797 | + } elseif (empty($ecmfile->share)) |
|
| 774 | 798 | { |
| 775 | 799 | // Add entry into index |
| 776 | 800 | if ($initsharekey) |
@@ -778,8 +802,9 @@ discard block |
||
| 778 | 802 | require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; |
| 779 | 803 | $ecmfile->share = getRandomPassword(true); |
| 780 | 804 | $ecmfile->update($user); |
| 805 | + } else { |
|
| 806 | + return ''; |
|
| 781 | 807 | } |
| 782 | - else return ''; |
|
| 783 | 808 | } |
| 784 | 809 | // Define $urlwithroot |
| 785 | 810 | $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); |
@@ -795,14 +820,18 @@ discard block |
||
| 795 | 820 | //if (! empty($modulepart)) $paramlink.=($paramlink?'&':'').'modulepart='.$modulepart; // For sharing with hash (so public files), modulepart is not required. |
| 796 | 821 | //if (! empty($ecmfile->entity)) $paramlink.='&entity='.$ecmfile->entity; // For sharing with hash (so public files), entity is not required. |
| 797 | 822 | //$paramlink.=($paramlink?'&':'').'file='.urlencode($filepath); // No need of name of file for public link, we will use the hash |
| 798 | - if (! empty($ecmfile->share)) $paramlink.=($paramlink?'&':'').'hashp='.$ecmfile->share; // Hash for public share |
|
| 799 | - if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1'; |
|
| 823 | + if (! empty($ecmfile->share)) { |
|
| 824 | + $paramlink.=($paramlink?'&':'').'hashp='.$ecmfile->share; |
|
| 825 | + } |
|
| 826 | + // Hash for public share |
|
| 827 | + if ($forcedownload) { |
|
| 828 | + $paramlink.=($paramlink?'&':'').'attachment=1'; |
|
| 829 | + } |
|
| 800 | 830 | |
| 801 | 831 | if ($relativelink) |
| 802 | 832 | { |
| 803 | 833 | $linktoreturn='document.php'.($paramlink?'?'.$paramlink:''); |
| 804 | - } |
|
| 805 | - else |
|
| 834 | + } else |
|
| 806 | 835 | { |
| 807 | 836 | $linktoreturn=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:''); |
| 808 | 837 | } |
@@ -850,8 +879,7 @@ discard block |
||
| 850 | 879 | if (is_numeric($type_contact)) |
| 851 | 880 | { |
| 852 | 881 | $id_type_contact=$type_contact; |
| 853 | - } |
|
| 854 | - else |
|
| 882 | + } else |
|
| 855 | 883 | { |
| 856 | 884 | // We look for id type_contact |
| 857 | 885 | $sql = "SELECT tc.rowid"; |
@@ -864,7 +892,9 @@ discard block |
||
| 864 | 892 | if ($resql) |
| 865 | 893 | { |
| 866 | 894 | $obj = $this->db->fetch_object($resql); |
| 867 | - if ($obj) $id_type_contact=$obj->rowid; |
|
| 895 | + if ($obj) { |
|
| 896 | + $id_type_contact=$obj->rowid; |
|
| 897 | + } |
|
| 868 | 898 | } |
| 869 | 899 | } |
| 870 | 900 | |
@@ -915,8 +945,7 @@ discard block |
||
| 915 | 945 | |
| 916 | 946 | $this->db->commit(); |
| 917 | 947 | return 1; |
| 918 | - } |
|
| 919 | - else |
|
| 948 | + } else |
|
| 920 | 949 | { |
| 921 | 950 | if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
| 922 | 951 | { |
@@ -924,15 +953,16 @@ discard block |
||
| 924 | 953 | $this->db->rollback(); |
| 925 | 954 | echo 'err rollback'; |
| 926 | 955 | return -2; |
| 927 | - } |
|
| 928 | - else |
|
| 956 | + } else |
|
| 929 | 957 | { |
| 930 | 958 | $this->error=$this->db->error(); |
| 931 | 959 | $this->db->rollback(); |
| 932 | 960 | return -1; |
| 933 | 961 | } |
| 934 | 962 | } |
| 935 | - } else return 0; |
|
| 963 | + } else { |
|
| 964 | + return 0; |
|
| 965 | + } |
|
| 936 | 966 | } |
| 937 | 967 | |
| 938 | 968 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
@@ -974,15 +1004,18 @@ discard block |
||
| 974 | 1004 | // Insert into database |
| 975 | 1005 | $sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set"; |
| 976 | 1006 | $sql.= " statut = ".$statut; |
| 977 | - if ($type_contact_id) $sql.= ", fk_c_type_contact = '".$type_contact_id ."'"; |
|
| 978 | - if ($fk_socpeople) $sql.= ", fk_socpeople = '".$fk_socpeople ."'"; |
|
| 1007 | + if ($type_contact_id) { |
|
| 1008 | + $sql.= ", fk_c_type_contact = '".$type_contact_id ."'"; |
|
| 1009 | + } |
|
| 1010 | + if ($fk_socpeople) { |
|
| 1011 | + $sql.= ", fk_socpeople = '".$fk_socpeople ."'"; |
|
| 1012 | + } |
|
| 979 | 1013 | $sql.= " where rowid = ".$rowid; |
| 980 | 1014 | $resql=$this->db->query($sql); |
| 981 | 1015 | if ($resql) |
| 982 | 1016 | { |
| 983 | 1017 | return 0; |
| 984 | - } |
|
| 985 | - else |
|
| 1018 | + } else |
|
| 986 | 1019 | { |
| 987 | 1020 | $this->error=$this->db->lasterror(); |
| 988 | 1021 | return -1; |
@@ -1019,8 +1052,7 @@ discard block |
||
| 1019 | 1052 | |
| 1020 | 1053 | $this->db->commit(); |
| 1021 | 1054 | return 1; |
| 1022 | - } |
|
| 1023 | - else |
|
| 1055 | + } else |
|
| 1024 | 1056 | { |
| 1025 | 1057 | $this->error=$this->db->lasterror(); |
| 1026 | 1058 | $this->db->rollback(); |
@@ -1050,15 +1082,15 @@ discard block |
||
| 1050 | 1082 | |
| 1051 | 1083 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; |
| 1052 | 1084 | $sql.= " WHERE element_id = ".$this->id; |
| 1053 | - if ($listId) |
|
| 1054 | - $sql.= " AND fk_c_type_contact IN (".$listId.")"; |
|
| 1085 | + if ($listId) { |
|
| 1086 | + $sql.= " AND fk_c_type_contact IN (".$listId.")"; |
|
| 1087 | + } |
|
| 1055 | 1088 | |
| 1056 | 1089 | dol_syslog(get_class($this)."::delete_linked_contact", LOG_DEBUG); |
| 1057 | 1090 | if ($this->db->query($sql)) |
| 1058 | 1091 | { |
| 1059 | 1092 | return 1; |
| 1060 | - } |
|
| 1061 | - else |
|
| 1093 | + } else |
|
| 1062 | 1094 | { |
| 1063 | 1095 | $this->error=$this->db->lasterror(); |
| 1064 | 1096 | return -1; |
@@ -1083,22 +1115,38 @@ discard block |
||
| 1083 | 1115 | $tab=array(); |
| 1084 | 1116 | |
| 1085 | 1117 | $sql = "SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact"; // This field contains id of llx_socpeople or id of llx_user |
| 1086 | - if ($source == 'internal') $sql.=", '-1' as socid, t.statut as statuscontact, t.login, t.photo"; |
|
| 1087 | - if ($source == 'external' || $source == 'thirdparty') $sql.=", t.fk_soc as socid, t.statut as statuscontact"; |
|
| 1118 | + if ($source == 'internal') { |
|
| 1119 | + $sql.=", '-1' as socid, t.statut as statuscontact, t.login, t.photo"; |
|
| 1120 | + } |
|
| 1121 | + if ($source == 'external' || $source == 'thirdparty') { |
|
| 1122 | + $sql.=", t.fk_soc as socid, t.statut as statuscontact"; |
|
| 1123 | + } |
|
| 1088 | 1124 | $sql.= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email"; |
| 1089 | 1125 | $sql.= ", tc.source, tc.element, tc.code, tc.libelle"; |
| 1090 | 1126 | $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; |
| 1091 | 1127 | $sql.= ", ".MAIN_DB_PREFIX."element_contact ec"; |
| 1092 | - if ($source == 'internal') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid"; |
|
| 1093 | - if ($source == 'external'|| $source == 'thirdparty') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid"; |
|
| 1128 | + if ($source == 'internal') { |
|
| 1129 | + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid"; |
|
| 1130 | + } |
|
| 1131 | + if ($source == 'external'|| $source == 'thirdparty') { |
|
| 1132 | + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid"; |
|
| 1133 | + } |
|
| 1094 | 1134 | $sql.= " WHERE ec.element_id =".$this->id; |
| 1095 | 1135 | $sql.= " AND ec.fk_c_type_contact=tc.rowid"; |
| 1096 | 1136 | $sql.= " AND tc.element='".$this->db->escape($this->element)."'"; |
| 1097 | - if ($code) $sql.= " AND tc.code = '".$this->db->escape($code)."'"; |
|
| 1098 | - if ($source == 'internal') $sql.= " AND tc.source = 'internal'"; |
|
| 1099 | - if ($source == 'external' || $source == 'thirdparty') $sql.= " AND tc.source = 'external'"; |
|
| 1137 | + if ($code) { |
|
| 1138 | + $sql.= " AND tc.code = '".$this->db->escape($code)."'"; |
|
| 1139 | + } |
|
| 1140 | + if ($source == 'internal') { |
|
| 1141 | + $sql.= " AND tc.source = 'internal'"; |
|
| 1142 | + } |
|
| 1143 | + if ($source == 'external' || $source == 'thirdparty') { |
|
| 1144 | + $sql.= " AND tc.source = 'external'"; |
|
| 1145 | + } |
|
| 1100 | 1146 | $sql.= " AND tc.active=1"; |
| 1101 | - if ($status >= 0) $sql.= " AND ec.statut = ".$status; |
|
| 1147 | + if ($status >= 0) { |
|
| 1148 | + $sql.= " AND ec.statut = ".$status; |
|
| 1149 | + } |
|
| 1102 | 1150 | $sql.=" ORDER BY t.lastname ASC"; |
| 1103 | 1151 | |
| 1104 | 1152 | dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG); |
@@ -1119,8 +1167,7 @@ discard block |
||
| 1119 | 1167 | 'nom'=>$obj->lastname, // For backward compatibility |
| 1120 | 1168 | 'civility'=>$obj->civility, 'lastname'=>$obj->lastname, 'firstname'=>$obj->firstname, 'email'=>$obj->email, 'login'=>$obj->login, 'photo'=>$obj->photo, 'statuscontact'=>$obj->statuscontact, |
| 1121 | 1169 | 'rowid'=>$obj->rowid, 'code'=>$obj->code, 'libelle'=>$libelle_type, 'status'=>$obj->statuslink, 'fk_c_type_contact'=>$obj->fk_c_type_contact); |
| 1122 | - } |
|
| 1123 | - else |
|
| 1170 | + } else |
|
| 1124 | 1171 | { |
| 1125 | 1172 | $tab[$i]=$obj->id; |
| 1126 | 1173 | } |
@@ -1129,8 +1176,7 @@ discard block |
||
| 1129 | 1176 | } |
| 1130 | 1177 | |
| 1131 | 1178 | return $tab; |
| 1132 | - } |
|
| 1133 | - else |
|
| 1179 | + } else |
|
| 1134 | 1180 | { |
| 1135 | 1181 | $this->error=$this->db->lasterror(); |
| 1136 | 1182 | dol_print_error($this->db); |
@@ -1165,8 +1211,7 @@ discard block |
||
| 1165 | 1211 | $result = $this->update_contact($rowid, $newstatut); |
| 1166 | 1212 | $this->db->free($resql); |
| 1167 | 1213 | return $result; |
| 1168 | - } |
|
| 1169 | - else |
|
| 1214 | + } else |
|
| 1170 | 1215 | { |
| 1171 | 1216 | $this->error=$this->db->error(); |
| 1172 | 1217 | dol_print_error($this->db); |
@@ -1190,16 +1235,27 @@ discard block |
||
| 1190 | 1235 | // phpcs:enable |
| 1191 | 1236 | global $langs; |
| 1192 | 1237 | |
| 1193 | - if (empty($order)) $order='position'; |
|
| 1194 | - if ($order == 'position') $order.=',code'; |
|
| 1238 | + if (empty($order)) { |
|
| 1239 | + $order='position'; |
|
| 1240 | + } |
|
| 1241 | + if ($order == 'position') { |
|
| 1242 | + $order.=',code'; |
|
| 1243 | + } |
|
| 1195 | 1244 | |
| 1196 | 1245 | $tab = array(); |
| 1197 | 1246 | $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position"; |
| 1198 | 1247 | $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; |
| 1199 | 1248 | $sql.= " WHERE tc.element='".$this->db->escape($this->element)."'"; |
| 1200 | - if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active types |
|
| 1201 | - if (! empty($source) && $source != 'all') $sql.= " AND tc.source='".$this->db->escape($source)."'"; |
|
| 1202 | - if (! empty($code)) $sql.= " AND tc.code='".$this->db->escape($code)."'"; |
|
| 1249 | + if ($activeonly == 1) { |
|
| 1250 | + $sql.= " AND tc.active=1"; |
|
| 1251 | + } |
|
| 1252 | + // only the active types |
|
| 1253 | + if (! empty($source) && $source != 'all') { |
|
| 1254 | + $sql.= " AND tc.source='".$this->db->escape($source)."'"; |
|
| 1255 | + } |
|
| 1256 | + if (! empty($code)) { |
|
| 1257 | + $sql.= " AND tc.code='".$this->db->escape($code)."'"; |
|
| 1258 | + } |
|
| 1203 | 1259 | $sql.= $this->db->order($order, 'ASC'); |
| 1204 | 1260 | |
| 1205 | 1261 | //print "sql=".$sql; |
@@ -1214,13 +1270,15 @@ discard block |
||
| 1214 | 1270 | |
| 1215 | 1271 | $transkey="TypeContact_".$this->element."_".$source."_".$obj->code; |
| 1216 | 1272 | $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); |
| 1217 | - if (empty($option)) $tab[$obj->rowid]=$libelle_type; |
|
| 1218 | - else $tab[$obj->code]=$libelle_type; |
|
| 1273 | + if (empty($option)) { |
|
| 1274 | + $tab[$obj->rowid]=$libelle_type; |
|
| 1275 | + } else { |
|
| 1276 | + $tab[$obj->code]=$libelle_type; |
|
| 1277 | + } |
|
| 1219 | 1278 | $i++; |
| 1220 | 1279 | } |
| 1221 | 1280 | return $tab; |
| 1222 | - } |
|
| 1223 | - else |
|
| 1281 | + } else |
|
| 1224 | 1282 | { |
| 1225 | 1283 | $this->error=$this->db->lasterror(); |
| 1226 | 1284 | //dol_print_error($this->db); |
@@ -1250,17 +1308,22 @@ discard block |
||
| 1250 | 1308 | $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; |
| 1251 | 1309 | |
| 1252 | 1310 | $sqlWhere=array(); |
| 1253 | - if (!empty($element)) |
|
| 1254 | - $sqlWhere[]=" tc.element='".$this->db->escape($element)."'"; |
|
| 1311 | + if (!empty($element)) { |
|
| 1312 | + $sqlWhere[]=" tc.element='".$this->db->escape($element)."'"; |
|
| 1313 | + } |
|
| 1255 | 1314 | |
| 1256 | - if ($activeonly == 1) |
|
| 1257 | - $sqlWhere[]=" tc.active=1"; // only the active types |
|
| 1315 | + if ($activeonly == 1) { |
|
| 1316 | + $sqlWhere[]=" tc.active=1"; |
|
| 1317 | + } |
|
| 1318 | + // only the active types |
|
| 1258 | 1319 | |
| 1259 | - if (! empty($source) && $source != 'all') |
|
| 1260 | - $sqlWhere[]=" tc.source='".$this->db->escape($source)."'"; |
|
| 1320 | + if (! empty($source) && $source != 'all') { |
|
| 1321 | + $sqlWhere[]=" tc.source='".$this->db->escape($source)."'"; |
|
| 1322 | + } |
|
| 1261 | 1323 | |
| 1262 | - if (! empty($code)) |
|
| 1263 | - $sqlWhere[]=" tc.code='".$this->db->escape($code)."'"; |
|
| 1324 | + if (! empty($code)) { |
|
| 1325 | + $sqlWhere[]=" tc.code='".$this->db->escape($code)."'"; |
|
| 1326 | + } |
|
| 1264 | 1327 | |
| 1265 | 1328 | if (count($sqlWhere)>0) { |
| 1266 | 1329 | $sql .= " WHERE ". implode(' AND ', $sqlWhere); |
@@ -1289,15 +1352,16 @@ discard block |
||
| 1289 | 1352 | $libelle_element = $langs->trans('ContactDefault_' . $obj->element); |
| 1290 | 1353 | $transkey = "TypeContact_" . $this->element . "_" . $source . "_" . $obj->code; |
| 1291 | 1354 | $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); |
| 1292 | - if (empty($option)) |
|
| 1355 | + if (empty($option)) { |
|
| 1356 | + $tab[$obj->rowid] = $libelle_element . ' - ' . $libelle_type; |
|
| 1357 | + } else { |
|
| 1293 | 1358 | $tab[$obj->rowid] = $libelle_element . ' - ' . $libelle_type; |
| 1294 | - else $tab[$obj->rowid] = $libelle_element . ' - ' . $libelle_type; |
|
| 1359 | + } |
|
| 1295 | 1360 | } |
| 1296 | 1361 | } |
| 1297 | 1362 | } |
| 1298 | 1363 | return $tab; |
| 1299 | - } |
|
| 1300 | - else |
|
| 1364 | + } else |
|
| 1301 | 1365 | { |
| 1302 | 1366 | $this->error=$this->db->lasterror(); |
| 1303 | 1367 | return null; |
@@ -1335,19 +1399,31 @@ discard block |
||
| 1335 | 1399 | |
| 1336 | 1400 | $sql = "SELECT ec.fk_socpeople"; |
| 1337 | 1401 | $sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec,"; |
| 1338 | - if ($source == 'internal') $sql.= " ".MAIN_DB_PREFIX."user as c,"; |
|
| 1339 | - if ($source == 'external') $sql.= " ".MAIN_DB_PREFIX."socpeople as c,"; |
|
| 1402 | + if ($source == 'internal') { |
|
| 1403 | + $sql.= " ".MAIN_DB_PREFIX."user as c,"; |
|
| 1404 | + } |
|
| 1405 | + if ($source == 'external') { |
|
| 1406 | + $sql.= " ".MAIN_DB_PREFIX."socpeople as c,"; |
|
| 1407 | + } |
|
| 1340 | 1408 | $sql.= " ".MAIN_DB_PREFIX."c_type_contact as tc"; |
| 1341 | 1409 | $sql.= " WHERE ec.element_id = ".$id; |
| 1342 | 1410 | $sql.= " AND ec.fk_socpeople = c.rowid"; |
| 1343 | - if ($source == 'internal') $sql.= " AND c.entity IN (".getEntity('user').")"; |
|
| 1344 | - if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('societe').")"; |
|
| 1411 | + if ($source == 'internal') { |
|
| 1412 | + $sql.= " AND c.entity IN (".getEntity('user').")"; |
|
| 1413 | + } |
|
| 1414 | + if ($source == 'external') { |
|
| 1415 | + $sql.= " AND c.entity IN (".getEntity('societe').")"; |
|
| 1416 | + } |
|
| 1345 | 1417 | $sql.= " AND ec.fk_c_type_contact = tc.rowid"; |
| 1346 | 1418 | $sql.= " AND tc.element = '".$element."'"; |
| 1347 | 1419 | $sql.= " AND tc.source = '".$source."'"; |
| 1348 | - if ($code) $sql.= " AND tc.code = '".$code."'"; |
|
| 1420 | + if ($code) { |
|
| 1421 | + $sql.= " AND tc.code = '".$code."'"; |
|
| 1422 | + } |
|
| 1349 | 1423 | $sql.= " AND tc.active = 1"; |
| 1350 | - if ($status) $sql.= " AND ec.statut = ".$status; |
|
| 1424 | + if ($status) { |
|
| 1425 | + $sql.= " AND ec.statut = ".$status; |
|
| 1426 | + } |
|
| 1351 | 1427 | |
| 1352 | 1428 | dol_syslog(get_class($this)."::getIdContact", LOG_DEBUG); |
| 1353 | 1429 | $resql=$this->db->query($sql); |
@@ -1358,8 +1434,7 @@ discard block |
||
| 1358 | 1434 | $result[$i]=$obj->fk_socpeople; |
| 1359 | 1435 | $i++; |
| 1360 | 1436 | } |
| 1361 | - } |
|
| 1362 | - else |
|
| 1437 | + } else |
|
| 1363 | 1438 | { |
| 1364 | 1439 | $this->error=$this->db->error(); |
| 1365 | 1440 | return null; |
@@ -1378,9 +1453,13 @@ discard block |
||
| 1378 | 1453 | public function fetch_contact($contactid = null) |
| 1379 | 1454 | { |
| 1380 | 1455 | // phpcs:enable |
| 1381 | - if (empty($contactid)) $contactid=$this->contactid; |
|
| 1456 | + if (empty($contactid)) { |
|
| 1457 | + $contactid=$this->contactid; |
|
| 1458 | + } |
|
| 1382 | 1459 | |
| 1383 | - if (empty($contactid)) return 0; |
|
| 1460 | + if (empty($contactid)) { |
|
| 1461 | + return 0; |
|
| 1462 | + } |
|
| 1384 | 1463 | |
| 1385 | 1464 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
| 1386 | 1465 | $contact = new Contact($this->db); |
@@ -1401,14 +1480,16 @@ discard block |
||
| 1401 | 1480 | // phpcs:enable |
| 1402 | 1481 | global $conf; |
| 1403 | 1482 | |
| 1404 | - if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) |
|
| 1405 | - return 0; |
|
| 1483 | + if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) { |
|
| 1484 | + return 0; |
|
| 1485 | + } |
|
| 1406 | 1486 | |
| 1407 | 1487 | require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
| 1408 | 1488 | |
| 1409 | 1489 | $idtofetch = isset($this->socid) ? $this->socid : (isset($this->fk_soc) ? $this->fk_soc : $this->fk_thirdparty); |
| 1410 | - if ($force_thirdparty_id) |
|
| 1411 | - $idtofetch = $force_thirdparty_id; |
|
| 1490 | + if ($force_thirdparty_id) { |
|
| 1491 | + $idtofetch = $force_thirdparty_id; |
|
| 1492 | + } |
|
| 1412 | 1493 | |
| 1413 | 1494 | if ($idtofetch) { |
| 1414 | 1495 | $thirdparty = new Societe($this->db); |
@@ -1421,8 +1502,9 @@ discard block |
||
| 1421 | 1502 | } |
| 1422 | 1503 | |
| 1423 | 1504 | return $result; |
| 1424 | - } else |
|
| 1425 | - return -1; |
|
| 1505 | + } else { |
|
| 1506 | + return -1; |
|
| 1507 | + } |
|
| 1426 | 1508 | } |
| 1427 | 1509 | |
| 1428 | 1510 | |
@@ -1468,18 +1550,24 @@ discard block |
||
| 1468 | 1550 | dol_syslog(get_class($this).'::fetch_barcode this->element='.$this->element.' this->barcode_type='.$this->barcode_type); |
| 1469 | 1551 | |
| 1470 | 1552 | $idtype=$this->barcode_type; |
| 1471 | - if (empty($idtype) && $idtype != '0') // If type of barcode no set, we try to guess. If set to '0' it means we forced to have type remain not defined |
|
| 1553 | + if (empty($idtype) && $idtype != '0') { |
|
| 1554 | + // If type of barcode no set, we try to guess. If set to '0' it means we forced to have type remain not defined |
|
| 1472 | 1555 | { |
| 1473 | 1556 | if ($this->element == 'product') $idtype = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
| 1474 | - elseif ($this->element == 'societe') $idtype = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY; |
|
| 1475 | - else dol_syslog('Call fetch_barcode with barcode_type not defined and cant be guessed', LOG_WARNING); |
|
| 1557 | + } elseif ($this->element == 'societe') { |
|
| 1558 | + $idtype = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY; |
|
| 1559 | + } else { |
|
| 1560 | + dol_syslog('Call fetch_barcode with barcode_type not defined and cant be guessed', LOG_WARNING); |
|
| 1561 | + } |
|
| 1476 | 1562 | } |
| 1477 | 1563 | |
| 1478 | 1564 | if ($idtype > 0) |
| 1479 | 1565 | { |
| 1480 | - if (empty($this->barcode_type) || empty($this->barcode_type_code) || empty($this->barcode_type_label) || empty($this->barcode_type_coder)) // If data not already loaded |
|
| 1566 | + if (empty($this->barcode_type) || empty($this->barcode_type_code) || empty($this->barcode_type_label) || empty($this->barcode_type_coder)) { |
|
| 1567 | + // If data not already loaded |
|
| 1481 | 1568 | { |
| 1482 | 1569 | $sql = "SELECT rowid, code, libelle as label, coder"; |
| 1570 | + } |
|
| 1483 | 1571 | $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; |
| 1484 | 1572 | $sql.= " WHERE rowid = ".$idtype; |
| 1485 | 1573 | dol_syslog(get_class($this).'::fetch_barcode', LOG_DEBUG); |
@@ -1492,8 +1580,7 @@ discard block |
||
| 1492 | 1580 | $this->barcode_type_label = $obj->label; |
| 1493 | 1581 | $this->barcode_type_coder = $obj->coder; |
| 1494 | 1582 | return 1; |
| 1495 | - } |
|
| 1496 | - else |
|
| 1583 | + } else |
|
| 1497 | 1584 | { |
| 1498 | 1585 | dol_print_error($this->db); |
| 1499 | 1586 | return -1; |
@@ -1514,8 +1601,13 @@ discard block |
||
| 1514 | 1601 | // phpcs:enable |
| 1515 | 1602 | include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 1516 | 1603 | |
| 1517 | - if (empty($this->fk_project) && ! empty($this->fk_projet)) $this->fk_project = $this->fk_projet; // For backward compatibility |
|
| 1518 | - if (empty($this->fk_project)) return 0; |
|
| 1604 | + if (empty($this->fk_project) && ! empty($this->fk_projet)) { |
|
| 1605 | + $this->fk_project = $this->fk_projet; |
|
| 1606 | + } |
|
| 1607 | + // For backward compatibility |
|
| 1608 | + if (empty($this->fk_project)) { |
|
| 1609 | + return 0; |
|
| 1610 | + } |
|
| 1519 | 1611 | |
| 1520 | 1612 | $project = new Project($this->db); |
| 1521 | 1613 | $result = $project->fetch($this->fk_project); |
@@ -1536,7 +1628,9 @@ discard block |
||
| 1536 | 1628 | // phpcs:enable |
| 1537 | 1629 | include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
| 1538 | 1630 | |
| 1539 | - if (empty($this->fk_product)) return 0; |
|
| 1631 | + if (empty($this->fk_product)) { |
|
| 1632 | + return 0; |
|
| 1633 | + } |
|
| 1540 | 1634 | |
| 1541 | 1635 | $product = new Product($this->db); |
| 1542 | 1636 | $result = $product->fetch($this->fk_product); |
@@ -1570,9 +1664,15 @@ discard block |
||
| 1570 | 1664 | public function fetch_origin() |
| 1571 | 1665 | { |
| 1572 | 1666 | // phpcs:enable |
| 1573 | - if ($this->origin == 'shipping') $this->origin = 'expedition'; |
|
| 1574 | - if ($this->origin == 'delivery') $this->origin = 'livraison'; |
|
| 1575 | - if ($this->origin == 'order_supplier') $this->origin = 'commandeFournisseur'; |
|
| 1667 | + if ($this->origin == 'shipping') { |
|
| 1668 | + $this->origin = 'expedition'; |
|
| 1669 | + } |
|
| 1670 | + if ($this->origin == 'delivery') { |
|
| 1671 | + $this->origin = 'livraison'; |
|
| 1672 | + } |
|
| 1673 | + if ($this->origin == 'order_supplier') { |
|
| 1674 | + $this->origin = 'commandeFournisseur'; |
|
| 1675 | + } |
|
| 1576 | 1676 | |
| 1577 | 1677 | $origin = $this->origin; |
| 1578 | 1678 | |
@@ -1664,29 +1764,48 @@ discard block |
||
| 1664 | 1764 | { |
| 1665 | 1765 | global $user,$langs,$conf; |
| 1666 | 1766 | |
| 1667 | - if (empty($table)) $table=$this->table_element; |
|
| 1668 | - if (empty($id)) $id=$this->id; |
|
| 1669 | - if (empty($format)) $format='text'; |
|
| 1670 | - if (empty($id_field)) $id_field='rowid'; |
|
| 1767 | + if (empty($table)) { |
|
| 1768 | + $table=$this->table_element; |
|
| 1769 | + } |
|
| 1770 | + if (empty($id)) { |
|
| 1771 | + $id=$this->id; |
|
| 1772 | + } |
|
| 1773 | + if (empty($format)) { |
|
| 1774 | + $format='text'; |
|
| 1775 | + } |
|
| 1776 | + if (empty($id_field)) { |
|
| 1777 | + $id_field='rowid'; |
|
| 1778 | + } |
|
| 1671 | 1779 | |
| 1672 | 1780 | $error=0; |
| 1673 | 1781 | |
| 1674 | 1782 | $this->db->begin(); |
| 1675 | 1783 | |
| 1676 | 1784 | // Special case |
| 1677 | - if ($table == 'product' && $field == 'note_private') $field='note'; |
|
| 1678 | - if (in_array($table, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) $fk_user_field = 'fk_user_mod'; |
|
| 1785 | + if ($table == 'product' && $field == 'note_private') { |
|
| 1786 | + $field='note'; |
|
| 1787 | + } |
|
| 1788 | + if (in_array($table, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) { |
|
| 1789 | + $fk_user_field = 'fk_user_mod'; |
|
| 1790 | + } |
|
| 1679 | 1791 | |
| 1680 | 1792 | $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; |
| 1681 | 1793 | |
| 1682 | - if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; |
|
| 1683 | - elseif ($format == 'int') $sql.= $field." = ".$this->db->escape($value); |
|
| 1684 | - elseif ($format == 'date') $sql.= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); |
|
| 1794 | + if ($format == 'text') { |
|
| 1795 | + $sql.= $field." = '".$this->db->escape($value)."'"; |
|
| 1796 | + } elseif ($format == 'int') { |
|
| 1797 | + $sql.= $field." = ".$this->db->escape($value); |
|
| 1798 | + } elseif ($format == 'date') { |
|
| 1799 | + $sql.= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); |
|
| 1800 | + } |
|
| 1685 | 1801 | |
| 1686 | 1802 | if ($fk_user_field) |
| 1687 | 1803 | { |
| 1688 | - if (! empty($fuser) && is_object($fuser)) $sql.=", ".$fk_user_field." = ".$fuser->id; |
|
| 1689 | - elseif (empty($fuser) || $fuser != 'none') $sql.=", ".$fk_user_field." = ".$user->id; |
|
| 1804 | + if (! empty($fuser) && is_object($fuser)) { |
|
| 1805 | + $sql.=", ".$fk_user_field." = ".$fuser->id; |
|
| 1806 | + } elseif (empty($fuser) || $fuser != 'none') { |
|
| 1807 | + $sql.=", ".$fk_user_field." = ".$user->id; |
|
| 1808 | + } |
|
| 1690 | 1809 | } |
| 1691 | 1810 | |
| 1692 | 1811 | $sql.= " WHERE ".$id_field." = ".$id; |
@@ -1701,28 +1820,32 @@ discard block |
||
| 1701 | 1820 | if (empty($this->fields) && method_exists($this, 'fetch')) |
| 1702 | 1821 | { |
| 1703 | 1822 | $result = $this->fetch($id); |
| 1704 | - } |
|
| 1705 | - else |
|
| 1823 | + } else |
|
| 1706 | 1824 | { |
| 1707 | 1825 | $result = $this->fetchCommon($id); |
| 1708 | 1826 | } |
| 1709 | - if ($result >= 0) $result=$this->call_trigger($trigkey, (! empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors |
|
| 1710 | - if ($result < 0) $error++; |
|
| 1827 | + if ($result >= 0) { |
|
| 1828 | + $result=$this->call_trigger($trigkey, (! empty($fuser) && is_object($fuser)) ? $fuser : $user); |
|
| 1829 | + } |
|
| 1830 | + // This may set this->errors |
|
| 1831 | + if ($result < 0) { |
|
| 1832 | + $error++; |
|
| 1833 | + } |
|
| 1711 | 1834 | } |
| 1712 | 1835 | |
| 1713 | 1836 | if (! $error) |
| 1714 | 1837 | { |
| 1715 | - if (property_exists($this, $field)) $this->$field = $value; |
|
| 1838 | + if (property_exists($this, $field)) { |
|
| 1839 | + $this->$field = $value; |
|
| 1840 | + } |
|
| 1716 | 1841 | $this->db->commit(); |
| 1717 | 1842 | return 1; |
| 1718 | - } |
|
| 1719 | - else |
|
| 1843 | + } else |
|
| 1720 | 1844 | { |
| 1721 | 1845 | $this->db->rollback(); |
| 1722 | 1846 | return -2; |
| 1723 | 1847 | } |
| 1724 | - } |
|
| 1725 | - else |
|
| 1848 | + } else |
|
| 1726 | 1849 | { |
| 1727 | 1850 | $this->error=$this->db->lasterror(); |
| 1728 | 1851 | $this->db->rollback(); |
@@ -1749,36 +1872,66 @@ discard block |
||
| 1749 | 1872 | dol_print_error('', get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined"); |
| 1750 | 1873 | return -1; |
| 1751 | 1874 | } |
| 1752 | - if ($fieldid == 'none') return 1; |
|
| 1875 | + if ($fieldid == 'none') { |
|
| 1876 | + return 1; |
|
| 1877 | + } |
|
| 1753 | 1878 | |
| 1754 | 1879 | // Security on socid |
| 1755 | 1880 | $socid = 0; |
| 1756 | - if ($user->socid > 0) $socid = $user->socid; |
|
| 1881 | + if ($user->socid > 0) { |
|
| 1882 | + $socid = $user->socid; |
|
| 1883 | + } |
|
| 1757 | 1884 | |
| 1758 | 1885 | // this->ismultientitymanaged contains |
| 1759 | 1886 | // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
| 1760 | 1887 | $alias = 's'; |
| 1761 | - if ($this->element == 'societe') $alias = 'te'; |
|
| 1888 | + if ($this->element == 'societe') { |
|
| 1889 | + $alias = 'te'; |
|
| 1890 | + } |
|
| 1762 | 1891 | |
| 1763 | 1892 | $sql = "SELECT MAX(te.".$fieldid.")"; |
| 1764 | 1893 | $sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te"; |
| 1765 | 1894 | if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
| 1766 | 1895 | $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; |
| 1767 | 1896 | } |
| 1768 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity |
|
| 1769 | - elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid |
|
| 1770 | - elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid |
|
| 1771 | - if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; |
|
| 1897 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) { |
|
| 1898 | + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 1899 | + } |
|
| 1900 | + // If we need to link to societe to limit select to entity |
|
| 1901 | + elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 1902 | + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 1903 | + } |
|
| 1904 | + // If we need to link to societe to limit select to socid |
|
| 1905 | + elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 1906 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; |
|
| 1907 | + } |
|
| 1908 | + // If we need to link to societe to limit select to socid |
|
| 1909 | + if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) { |
|
| 1910 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; |
|
| 1911 | + } |
|
| 1772 | 1912 | $sql.= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) |
| 1773 | - if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id; |
|
| 1774 | - if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND (sc.fk_user = " .$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1913 | + if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) { |
|
| 1914 | + $sql.= " AND sc.fk_user = " .$user->id; |
|
| 1915 | + } |
|
| 1916 | + if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) { |
|
| 1917 | + $sql.= " AND (sc.fk_user = " .$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1918 | + } |
|
| 1775 | 1919 | if (! empty($filter)) |
| 1776 | 1920 | { |
| 1777 | - if (! preg_match('/^\s*AND/i', $filter)) $sql.=" AND "; // For backward compatibility |
|
| 1921 | + if (! preg_match('/^\s*AND/i', $filter)) { |
|
| 1922 | + $sql.=" AND "; |
|
| 1923 | + } |
|
| 1924 | + // For backward compatibility |
|
| 1778 | 1925 | $sql.=$filter; |
| 1779 | 1926 | } |
| 1780 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity |
|
| 1781 | - elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid |
|
| 1927 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) { |
|
| 1928 | + $sql.= ' AND te.fk_soc = s.rowid'; |
|
| 1929 | + } |
|
| 1930 | + // If we need to link to societe to limit select to entity |
|
| 1931 | + elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 1932 | + $sql.= ' AND te.fk_soc = s.rowid'; |
|
| 1933 | + } |
|
| 1934 | + // If we need to link to societe to limit select to socid |
|
| 1782 | 1935 | if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { |
| 1783 | 1936 | if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
| 1784 | 1937 | if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) { |
@@ -1791,9 +1944,15 @@ discard block |
||
| 1791 | 1944 | $sql.= ' AND te.entity IN ('.getEntity($this->element).')'; |
| 1792 | 1945 | } |
| 1793 | 1946 | } |
| 1794 | - if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql.= ' AND te.fk_soc = ' . $socid; |
|
| 1795 | - if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)'; |
|
| 1796 | - if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql.= ' AND te.rowid = ' . $socid; |
|
| 1947 | + if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') { |
|
| 1948 | + $sql.= ' AND te.fk_soc = ' . $socid; |
|
| 1949 | + } |
|
| 1950 | + if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') { |
|
| 1951 | + $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)'; |
|
| 1952 | + } |
|
| 1953 | + if ($this->restrictiononfksoc && $socid && $this->element == 'societe') { |
|
| 1954 | + $sql.= ' AND te.rowid = ' . $socid; |
|
| 1955 | + } |
|
| 1797 | 1956 | //print 'socid='.$socid.' restrictiononfksoc='.$this->restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>"; |
| 1798 | 1957 | |
| 1799 | 1958 | $result = $this->db->query($sql); |
@@ -1811,20 +1970,44 @@ discard block |
||
| 1811 | 1970 | if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
| 1812 | 1971 | $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; |
| 1813 | 1972 | } |
| 1814 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity |
|
| 1815 | - elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid |
|
| 1816 | - elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid |
|
| 1817 | - if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; |
|
| 1973 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) { |
|
| 1974 | + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 1975 | + } |
|
| 1976 | + // If we need to link to societe to limit select to entity |
|
| 1977 | + elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 1978 | + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 1979 | + } |
|
| 1980 | + // If we need to link to societe to limit select to socid |
|
| 1981 | + elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 1982 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; |
|
| 1983 | + } |
|
| 1984 | + // If we need to link to societe to limit select to socid |
|
| 1985 | + if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) { |
|
| 1986 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; |
|
| 1987 | + } |
|
| 1818 | 1988 | $sql.= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) |
| 1819 | - if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id; |
|
| 1820 | - if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND (sc.fk_user = " .$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1989 | + if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) { |
|
| 1990 | + $sql.= " AND sc.fk_user = " .$user->id; |
|
| 1991 | + } |
|
| 1992 | + if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) { |
|
| 1993 | + $sql.= " AND (sc.fk_user = " .$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1994 | + } |
|
| 1821 | 1995 | if (! empty($filter)) |
| 1822 | 1996 | { |
| 1823 | - if (! preg_match('/^\s*AND/i', $filter)) $sql.=" AND "; // For backward compatibility |
|
| 1997 | + if (! preg_match('/^\s*AND/i', $filter)) { |
|
| 1998 | + $sql.=" AND "; |
|
| 1999 | + } |
|
| 2000 | + // For backward compatibility |
|
| 1824 | 2001 | $sql.=$filter; |
| 1825 | 2002 | } |
| 1826 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity |
|
| 1827 | - elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid |
|
| 2003 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) { |
|
| 2004 | + $sql.= ' AND te.fk_soc = s.rowid'; |
|
| 2005 | + } |
|
| 2006 | + // If we need to link to societe to limit select to entity |
|
| 2007 | + elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 2008 | + $sql.= ' AND te.fk_soc = s.rowid'; |
|
| 2009 | + } |
|
| 2010 | + // If we need to link to societe to limit select to socid |
|
| 1828 | 2011 | if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { |
| 1829 | 2012 | if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
| 1830 | 2013 | if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) { |
@@ -1837,9 +2020,15 @@ discard block |
||
| 1837 | 2020 | $sql.= ' AND te.entity IN ('.getEntity($this->element).')'; |
| 1838 | 2021 | } |
| 1839 | 2022 | } |
| 1840 | - if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql.= ' AND te.fk_soc = ' . $socid; |
|
| 1841 | - if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)'; |
|
| 1842 | - if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql.= ' AND te.rowid = ' . $socid; |
|
| 2023 | + if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') { |
|
| 2024 | + $sql.= ' AND te.fk_soc = ' . $socid; |
|
| 2025 | + } |
|
| 2026 | + if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') { |
|
| 2027 | + $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)'; |
|
| 2028 | + } |
|
| 2029 | + if ($this->restrictiononfksoc && $socid && $this->element == 'societe') { |
|
| 2030 | + $sql.= ' AND te.rowid = ' . $socid; |
|
| 2031 | + } |
|
| 1843 | 2032 | //print 'socid='.$socid.' restrictiononfksoc='.$this->restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>"; |
| 1844 | 2033 | // Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null |
| 1845 | 2034 | |
@@ -1871,8 +2060,11 @@ discard block |
||
| 1871 | 2060 | $i = 0; |
| 1872 | 2061 | while ($i < $num) |
| 1873 | 2062 | { |
| 1874 | - if ($source == 'thirdparty') $contactAlreadySelected[$i] = $tab[$i]['socid']; |
|
| 1875 | - else $contactAlreadySelected[$i] = $tab[$i]['id']; |
|
| 2063 | + if ($source == 'thirdparty') { |
|
| 2064 | + $contactAlreadySelected[$i] = $tab[$i]['socid']; |
|
| 2065 | + } else { |
|
| 2066 | + $contactAlreadySelected[$i] = $tab[$i]['id']; |
|
| 2067 | + } |
|
| 1876 | 2068 | $i++; |
| 1877 | 2069 | } |
| 1878 | 2070 | return $contactAlreadySelected; |
@@ -1894,22 +2086,29 @@ discard block |
||
| 1894 | 2086 | } |
| 1895 | 2087 | |
| 1896 | 2088 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 1897 | - if (! empty($this->fields['fk_project'])) // Common case |
|
| 2089 | + if (! empty($this->fields['fk_project'])) { |
|
| 2090 | + // Common case |
|
| 1898 | 2091 | { |
| 1899 | 2092 | if ($projectid) $sql.= ' SET fk_project = '.$projectid; |
| 1900 | - else $sql.= ' SET fk_project = NULL'; |
|
| 2093 | + } else { |
|
| 2094 | + $sql.= ' SET fk_project = NULL'; |
|
| 2095 | + } |
|
| 1901 | 2096 | $sql.= ' WHERE rowid = '.$this->id; |
| 1902 | - } |
|
| 1903 | - elseif ($this->table_element == 'actioncomm') // Special case for actioncomm |
|
| 2097 | + } elseif ($this->table_element == 'actioncomm') { |
|
| 2098 | + // Special case for actioncomm |
|
| 1904 | 2099 | { |
| 1905 | 2100 | if ($projectid) $sql.= ' SET fk_project = '.$projectid; |
| 1906 | - else $sql.= ' SET fk_project = NULL'; |
|
| 2101 | + } else { |
|
| 2102 | + $sql.= ' SET fk_project = NULL'; |
|
| 2103 | + } |
|
| 1907 | 2104 | $sql.= ' WHERE id = '.$this->id; |
| 1908 | - } |
|
| 1909 | - else // Special case for old architecture objects |
|
| 2105 | + } else // Special case for old architecture objects |
|
| 1910 | 2106 | { |
| 1911 | - if ($projectid) $sql.= ' SET fk_projet = '.$projectid; |
|
| 1912 | - else $sql.= ' SET fk_projet = NULL'; |
|
| 2107 | + if ($projectid) { |
|
| 2108 | + $sql.= ' SET fk_projet = '.$projectid; |
|
| 2109 | + } else { |
|
| 2110 | + $sql.= ' SET fk_projet = NULL'; |
|
| 2111 | + } |
|
| 1913 | 2112 | $sql.= ' WHERE rowid = '.$this->id; |
| 1914 | 2113 | } |
| 1915 | 2114 | |
@@ -1918,8 +2117,7 @@ discard block |
||
| 1918 | 2117 | { |
| 1919 | 2118 | $this->fk_project = $projectid; |
| 1920 | 2119 | return 1; |
| 1921 | - } |
|
| 1922 | - else |
|
| 2120 | + } else |
|
| 1923 | 2121 | { |
| 1924 | 2122 | dol_print_error($this->db); |
| 1925 | 2123 | return -1; |
@@ -1939,8 +2137,12 @@ discard block |
||
| 1939 | 2137 | { |
| 1940 | 2138 | // TODO uniformize field name |
| 1941 | 2139 | $fieldname = 'fk_mode_reglement'; |
| 1942 | - if ($this->element == 'societe') $fieldname = 'mode_reglement'; |
|
| 1943 | - if (get_class($this) == 'Fournisseur') $fieldname = 'mode_reglement_supplier'; |
|
| 2140 | + if ($this->element == 'societe') { |
|
| 2141 | + $fieldname = 'mode_reglement'; |
|
| 2142 | + } |
|
| 2143 | + if (get_class($this) == 'Fournisseur') { |
|
| 2144 | + $fieldname = 'mode_reglement_supplier'; |
|
| 2145 | + } |
|
| 1944 | 2146 | |
| 1945 | 2147 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 1946 | 2148 | $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); |
@@ -1950,17 +2152,17 @@ discard block |
||
| 1950 | 2152 | { |
| 1951 | 2153 | $this->mode_reglement_id = $id; |
| 1952 | 2154 | // for supplier |
| 1953 | - if (get_class($this) == 'Fournisseur') $this->mode_reglement_supplier_id = $id; |
|
| 2155 | + if (get_class($this) == 'Fournisseur') { |
|
| 2156 | + $this->mode_reglement_supplier_id = $id; |
|
| 2157 | + } |
|
| 1954 | 2158 | return 1; |
| 1955 | - } |
|
| 1956 | - else |
|
| 2159 | + } else |
|
| 1957 | 2160 | { |
| 1958 | 2161 | dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error()); |
| 1959 | 2162 | $this->error=$this->db->error(); |
| 1960 | 2163 | return -1; |
| 1961 | 2164 | } |
| 1962 | - } |
|
| 1963 | - else |
|
| 2165 | + } else |
|
| 1964 | 2166 | { |
| 1965 | 2167 | dol_syslog(get_class($this).'::setPaymentMethods, status of the object is incompatible'); |
| 1966 | 2168 | $this->error='Status of the object is incompatible '.$this->statut; |
@@ -1990,18 +2192,18 @@ discard block |
||
| 1990 | 2192 | $this->multicurrency_code = $code; |
| 1991 | 2193 | |
| 1992 | 2194 | list($fk_multicurrency, $rate) = MultiCurrency::getIdAndTxFromCode($this->db, $code); |
| 1993 | - if ($rate) $this->setMulticurrencyRate($rate, 2); |
|
| 2195 | + if ($rate) { |
|
| 2196 | + $this->setMulticurrencyRate($rate, 2); |
|
| 2197 | + } |
|
| 1994 | 2198 | |
| 1995 | 2199 | return 1; |
| 1996 | - } |
|
| 1997 | - else |
|
| 2200 | + } else |
|
| 1998 | 2201 | { |
| 1999 | 2202 | dol_syslog(get_class($this).'::setMulticurrencyCode Erreur '.$sql.' - '.$this->db->error()); |
| 2000 | 2203 | $this->error=$this->db->error(); |
| 2001 | 2204 | return -1; |
| 2002 | 2205 | } |
| 2003 | - } |
|
| 2004 | - else |
|
| 2206 | + } else |
|
| 2005 | 2207 | { |
| 2006 | 2208 | dol_syslog(get_class($this).'::setMulticurrencyCode, status of the object is incompatible'); |
| 2007 | 2209 | $this->error='Status of the object is incompatible '.$this->statut; |
@@ -2101,15 +2303,13 @@ discard block |
||
| 2101 | 2303 | } |
| 2102 | 2304 | |
| 2103 | 2305 | return 1; |
| 2104 | - } |
|
| 2105 | - else |
|
| 2306 | + } else |
|
| 2106 | 2307 | { |
| 2107 | 2308 | dol_syslog(get_class($this).'::setMulticurrencyRate Erreur '.$sql.' - '.$this->db->error()); |
| 2108 | 2309 | $this->error=$this->db->error(); |
| 2109 | 2310 | return -1; |
| 2110 | 2311 | } |
| 2111 | - } |
|
| 2112 | - else |
|
| 2312 | + } else |
|
| 2113 | 2313 | { |
| 2114 | 2314 | dol_syslog(get_class($this).'::setMulticurrencyRate, status of the object is incompatible'); |
| 2115 | 2315 | $this->error='Status of the object is incompatible '.$this->statut; |
@@ -2130,8 +2330,12 @@ discard block |
||
| 2130 | 2330 | { |
| 2131 | 2331 | // TODO uniformize field name |
| 2132 | 2332 | $fieldname = 'fk_cond_reglement'; |
| 2133 | - if ($this->element == 'societe') $fieldname = 'cond_reglement'; |
|
| 2134 | - if (get_class($this) == 'Fournisseur') $fieldname = 'cond_reglement_supplier'; |
|
| 2333 | + if ($this->element == 'societe') { |
|
| 2334 | + $fieldname = 'cond_reglement'; |
|
| 2335 | + } |
|
| 2336 | + if (get_class($this) == 'Fournisseur') { |
|
| 2337 | + $fieldname = 'cond_reglement_supplier'; |
|
| 2338 | + } |
|
| 2135 | 2339 | |
| 2136 | 2340 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 2137 | 2341 | $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); |
@@ -2141,18 +2345,18 @@ discard block |
||
| 2141 | 2345 | { |
| 2142 | 2346 | $this->cond_reglement_id = $id; |
| 2143 | 2347 | // for supplier |
| 2144 | - if (get_class($this) == 'Fournisseur') $this->cond_reglement_supplier_id = $id; |
|
| 2348 | + if (get_class($this) == 'Fournisseur') { |
|
| 2349 | + $this->cond_reglement_supplier_id = $id; |
|
| 2350 | + } |
|
| 2145 | 2351 | $this->cond_reglement = $id; // for compatibility |
| 2146 | 2352 | return 1; |
| 2147 | - } |
|
| 2148 | - else |
|
| 2353 | + } else |
|
| 2149 | 2354 | { |
| 2150 | 2355 | dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error()); |
| 2151 | 2356 | $this->error=$this->db->error(); |
| 2152 | 2357 | return -1; |
| 2153 | 2358 | } |
| 2154 | - } |
|
| 2155 | - else |
|
| 2359 | + } else |
|
| 2156 | 2360 | { |
| 2157 | 2361 | dol_syslog(get_class($this).'::setPaymentTerms, status of the object is incompatible'); |
| 2158 | 2362 | $this->error='Status of the object is incompatible '.$this->statut; |
@@ -2182,15 +2386,13 @@ discard block |
||
| 2182 | 2386 | { |
| 2183 | 2387 | $this->retained_warranty_fk_cond_reglement = $id; |
| 2184 | 2388 | return 1; |
| 2185 | - } |
|
| 2186 | - else |
|
| 2389 | + } else |
|
| 2187 | 2390 | { |
| 2188 | 2391 | dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms Erreur '.$sql.' - '.$this->db->error()); |
| 2189 | 2392 | $this->error=$this->db->error(); |
| 2190 | 2393 | return -1; |
| 2191 | 2394 | } |
| 2192 | - } |
|
| 2193 | - else |
|
| 2395 | + } else |
|
| 2194 | 2396 | { |
| 2195 | 2397 | dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms, status of the object is incompatible'); |
| 2196 | 2398 | $this->error='Status of the object is incompatible '.$this->statut; |
@@ -2208,7 +2410,9 @@ discard block |
||
| 2208 | 2410 | public function setDeliveryAddress($id) |
| 2209 | 2411 | { |
| 2210 | 2412 | $fieldname = 'fk_delivery_address'; |
| 2211 | - if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address'; |
|
| 2413 | + if ($this->element == 'delivery' || $this->element == 'shipping') { |
|
| 2414 | + $fieldname = 'fk_address'; |
|
| 2415 | + } |
|
| 2212 | 2416 | |
| 2213 | 2417 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".$id; |
| 2214 | 2418 | $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; |
@@ -2217,8 +2421,7 @@ discard block |
||
| 2217 | 2421 | { |
| 2218 | 2422 | $this->fk_delivery_address = $id; |
| 2219 | 2423 | return 1; |
| 2220 | - } |
|
| 2221 | - else |
|
| 2424 | + } else |
|
| 2222 | 2425 | { |
| 2223 | 2426 | $this->error=$this->db->error(); |
| 2224 | 2427 | dol_syslog(get_class($this).'::setDeliveryAddress Erreur '.$sql.' - '.$this->error); |
@@ -2240,7 +2443,9 @@ discard block |
||
| 2240 | 2443 | { |
| 2241 | 2444 | global $user; |
| 2242 | 2445 | |
| 2243 | - if (empty($userused)) $userused=$user; |
|
| 2446 | + if (empty($userused)) { |
|
| 2447 | + $userused=$user; |
|
| 2448 | + } |
|
| 2244 | 2449 | |
| 2245 | 2450 | $error = 0; |
| 2246 | 2451 | |
@@ -2251,7 +2456,9 @@ discard block |
||
| 2251 | 2456 | |
| 2252 | 2457 | $this->db->begin(); |
| 2253 | 2458 | |
| 2254 | - if ($shipping_method_id<0) $shipping_method_id='NULL'; |
|
| 2459 | + if ($shipping_method_id<0) { |
|
| 2460 | + $shipping_method_id='NULL'; |
|
| 2461 | + } |
|
| 2255 | 2462 | dol_syslog(get_class($this).'::setShippingMethod('.$shipping_method_id.')'); |
| 2256 | 2463 | |
| 2257 | 2464 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
@@ -2268,7 +2475,9 @@ discard block |
||
| 2268 | 2475 | // Call trigger |
| 2269 | 2476 | $this->context=array('shippingmethodupdate'=>1); |
| 2270 | 2477 | $result = $this->call_trigger(strtoupper(get_class($this)) . '_MODIFY', $userused); |
| 2271 | - if ($result < 0) $error++; |
|
| 2478 | + if ($result < 0) { |
|
| 2479 | + $error++; |
|
| 2480 | + } |
|
| 2272 | 2481 | // End call trigger |
| 2273 | 2482 | } |
| 2274 | 2483 | } |
@@ -2296,7 +2505,9 @@ discard block |
||
| 2296 | 2505 | dol_syslog(get_class($this)."::setWarehouse was called on objet with property table_element not defined", LOG_ERR); |
| 2297 | 2506 | return -1; |
| 2298 | 2507 | } |
| 2299 | - if ($warehouse_id<0) $warehouse_id='NULL'; |
|
| 2508 | + if ($warehouse_id<0) { |
|
| 2509 | + $warehouse_id='NULL'; |
|
| 2510 | + } |
|
| 2300 | 2511 | dol_syslog(get_class($this).'::setWarehouse('.$warehouse_id.')'); |
| 2301 | 2512 | |
| 2302 | 2513 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
@@ -2343,8 +2554,7 @@ discard block |
||
| 2343 | 2554 | { |
| 2344 | 2555 | $this->modelpdf=$modelpdf; |
| 2345 | 2556 | return 1; |
| 2346 | - } |
|
| 2347 | - else |
|
| 2557 | + } else |
|
| 2348 | 2558 | { |
| 2349 | 2559 | dol_print_error($this->db); |
| 2350 | 2560 | return 0; |
@@ -2364,7 +2574,9 @@ discard block |
||
| 2364 | 2574 | { |
| 2365 | 2575 | global $user; |
| 2366 | 2576 | |
| 2367 | - if (empty($userused)) $userused=$user; |
|
| 2577 | + if (empty($userused)) { |
|
| 2578 | + $userused=$user; |
|
| 2579 | + } |
|
| 2368 | 2580 | |
| 2369 | 2581 | $error = 0; |
| 2370 | 2582 | |
@@ -2374,7 +2586,9 @@ discard block |
||
| 2374 | 2586 | } |
| 2375 | 2587 | $this->db->begin(); |
| 2376 | 2588 | |
| 2377 | - if ($fk_account<0) $fk_account='NULL'; |
|
| 2589 | + if ($fk_account<0) { |
|
| 2590 | + $fk_account='NULL'; |
|
| 2591 | + } |
|
| 2378 | 2592 | dol_syslog(get_class($this).'::setBankAccount('.$fk_account.')'); |
| 2379 | 2593 | |
| 2380 | 2594 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
@@ -2387,15 +2601,16 @@ discard block |
||
| 2387 | 2601 | dol_syslog(get_class($this).'::setBankAccount Error '.$sql.' - '.$this->db->error()); |
| 2388 | 2602 | $this->error = $this->db->lasterror(); |
| 2389 | 2603 | $error++; |
| 2390 | - } |
|
| 2391 | - else |
|
| 2604 | + } else |
|
| 2392 | 2605 | { |
| 2393 | 2606 | if (!$notrigger) |
| 2394 | 2607 | { |
| 2395 | 2608 | // Call trigger |
| 2396 | 2609 | $this->context=array('bankaccountupdate'=>1); |
| 2397 | 2610 | $result = $this->call_trigger(strtoupper(get_class($this)) . '_MODIFY', $userused); |
| 2398 | - if ($result < 0) $error++; |
|
| 2611 | + if ($result < 0) { |
|
| 2612 | + $error++; |
|
| 2613 | + } |
|
| 2399 | 2614 | // End call trigger |
| 2400 | 2615 | } |
| 2401 | 2616 | } |
@@ -2403,8 +2618,7 @@ discard block |
||
| 2403 | 2618 | { |
| 2404 | 2619 | $this->db->rollback(); |
| 2405 | 2620 | return -1; |
| 2406 | - } |
|
| 2407 | - else |
|
| 2621 | + } else |
|
| 2408 | 2622 | { |
| 2409 | 2623 | $this->fk_account = ($fk_account=='NULL')?null:$fk_account; |
| 2410 | 2624 | $this->db->commit(); |
@@ -2443,8 +2657,12 @@ discard block |
||
| 2443 | 2657 | $nl=0; |
| 2444 | 2658 | $sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2445 | 2659 | $sql.= ' WHERE '.$this->fk_element.'='.$this->id; |
| 2446 | - if (! $renum) $sql.= ' AND rang = 0'; |
|
| 2447 | - if ($renum) $sql.= ' AND rang <> 0'; |
|
| 2660 | + if (! $renum) { |
|
| 2661 | + $sql.= ' AND rang = 0'; |
|
| 2662 | + } |
|
| 2663 | + if ($renum) { |
|
| 2664 | + $sql.= ' AND rang <> 0'; |
|
| 2665 | + } |
|
| 2448 | 2666 | |
| 2449 | 2667 | dol_syslog(get_class($this)."::line_order", LOG_DEBUG); |
| 2450 | 2668 | $resql = $this->db->query($sql); |
@@ -2452,8 +2670,9 @@ discard block |
||
| 2452 | 2670 | { |
| 2453 | 2671 | $row = $this->db->fetch_row($resql); |
| 2454 | 2672 | $nl = $row[0]; |
| 2673 | + } else { |
|
| 2674 | + dol_print_error($this->db); |
|
| 2455 | 2675 | } |
| 2456 | - else dol_print_error($this->db); |
|
| 2457 | 2676 | if ($nl > 0) |
| 2458 | 2677 | { |
| 2459 | 2678 | // The goal of this part is to reorder all lines, with all children lines sharing the same |
@@ -2463,7 +2682,9 @@ discard block |
||
| 2463 | 2682 | // We first search all lines that are parent lines (for multilevel details lines) |
| 2464 | 2683 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2465 | 2684 | $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
| 2466 | - if ($fk_parent_line) $sql.= ' AND fk_parent_line IS NULL'; |
|
| 2685 | + if ($fk_parent_line) { |
|
| 2686 | + $sql.= ' AND fk_parent_line IS NULL'; |
|
| 2687 | + } |
|
| 2467 | 2688 | $sql.= ' ORDER BY rang ASC, rowid '.$rowidorder; |
| 2468 | 2689 | |
| 2469 | 2690 | dol_syslog(get_class($this)."::line_order search all parent lines", LOG_DEBUG); |
@@ -2495,8 +2716,7 @@ discard block |
||
| 2495 | 2716 | $this->updateRangOfLine($row, ($key+1)); |
| 2496 | 2717 | } |
| 2497 | 2718 | } |
| 2498 | - } |
|
| 2499 | - else |
|
| 2719 | + } else |
|
| 2500 | 2720 | { |
| 2501 | 2721 | dol_print_error($this->db); |
| 2502 | 2722 | } |
@@ -2589,7 +2809,9 @@ discard block |
||
| 2589 | 2809 | public function updateRangOfLine($rowid, $rang) |
| 2590 | 2810 | { |
| 2591 | 2811 | $fieldposition = 'rang'; // @TODO Rename 'rang' into 'position' |
| 2592 | - if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; |
|
| 2812 | + if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction'))) { |
|
| 2813 | + $fieldposition = 'position'; |
|
| 2814 | + } |
|
| 2593 | 2815 | |
| 2594 | 2816 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; |
| 2595 | 2817 | $sql.= ' WHERE rowid = '.$rowid; |
@@ -2630,7 +2852,9 @@ discard block |
||
| 2630 | 2852 | if ($rang > 1) |
| 2631 | 2853 | { |
| 2632 | 2854 | $fieldposition = 'rang'; |
| 2633 | - if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; |
|
| 2855 | + if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) { |
|
| 2856 | + $fieldposition = 'position'; |
|
| 2857 | + } |
|
| 2634 | 2858 | |
| 2635 | 2859 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang ; |
| 2636 | 2860 | $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
@@ -2643,8 +2867,7 @@ discard block |
||
| 2643 | 2867 | { |
| 2644 | 2868 | dol_print_error($this->db); |
| 2645 | 2869 | } |
| 2646 | - } |
|
| 2647 | - else |
|
| 2870 | + } else |
|
| 2648 | 2871 | { |
| 2649 | 2872 | dol_print_error($this->db); |
| 2650 | 2873 | } |
@@ -2664,7 +2887,9 @@ discard block |
||
| 2664 | 2887 | if ($rang < $max) |
| 2665 | 2888 | { |
| 2666 | 2889 | $fieldposition = 'rang'; |
| 2667 | - if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; |
|
| 2890 | + if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) { |
|
| 2891 | + $fieldposition = 'position'; |
|
| 2892 | + } |
|
| 2668 | 2893 | |
| 2669 | 2894 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; |
| 2670 | 2895 | $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
@@ -2677,8 +2902,7 @@ discard block |
||
| 2677 | 2902 | { |
| 2678 | 2903 | dol_print_error($this->db); |
| 2679 | 2904 | } |
| 2680 | - } |
|
| 2681 | - else |
|
| 2905 | + } else |
|
| 2682 | 2906 | { |
| 2683 | 2907 | dol_print_error($this->db); |
| 2684 | 2908 | } |
@@ -2749,8 +2973,7 @@ discard block |
||
| 2749 | 2973 | if (! empty($row[0])) |
| 2750 | 2974 | { |
| 2751 | 2975 | return $row[0]; |
| 2752 | - } |
|
| 2753 | - else |
|
| 2976 | + } else |
|
| 2754 | 2977 | { |
| 2755 | 2978 | return $this->getRangOfLine($fk_parent_line); |
| 2756 | 2979 | } |
@@ -2797,8 +3020,7 @@ discard block |
||
| 2797 | 3020 | { |
| 2798 | 3021 | $this->ref_ext = $ref_ext; |
| 2799 | 3022 | return 1; |
| 2800 | - } |
|
| 2801 | - else |
|
| 3023 | + } else |
|
| 2802 | 3024 | { |
| 2803 | 3025 | $this->error=$this->db->error(); |
| 2804 | 3026 | return -1; |
@@ -2832,7 +3054,9 @@ discard block |
||
| 2832 | 3054 | } |
| 2833 | 3055 | // Special cas |
| 2834 | 3056 | //var_dump($this->table_element);exit; |
| 2835 | - if ($this->table_element == 'product') $suffix=''; |
|
| 3057 | + if ($this->table_element == 'product') { |
|
| 3058 | + $suffix=''; |
|
| 3059 | + } |
|
| 2836 | 3060 | |
| 2837 | 3061 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 2838 | 3062 | $sql.= " SET note".$suffix." = ".(!empty($note)?("'".$this->db->escape($note)."'"):"NULL"); |
@@ -2842,16 +3066,17 @@ discard block |
||
| 2842 | 3066 | dol_syslog(get_class($this)."::update_note", LOG_DEBUG); |
| 2843 | 3067 | if ($this->db->query($sql)) |
| 2844 | 3068 | { |
| 2845 | - if ($suffix == '_public') $this->note_public = $note; |
|
| 2846 | - elseif ($suffix == '_private') $this->note_private = $note; |
|
| 2847 | - else |
|
| 3069 | + if ($suffix == '_public') { |
|
| 3070 | + $this->note_public = $note; |
|
| 3071 | + } elseif ($suffix == '_private') { |
|
| 3072 | + $this->note_private = $note; |
|
| 3073 | + } else |
|
| 2848 | 3074 | { |
| 2849 | 3075 | $this->note = $note; // deprecated |
| 2850 | 3076 | $this->note_private = $note; |
| 2851 | 3077 | } |
| 2852 | 3078 | return 1; |
| 2853 | - } |
|
| 2854 | - else |
|
| 3079 | + } else |
|
| 2855 | 3080 | { |
| 2856 | 3081 | $this->error=$this->db->lasterror(); |
| 2857 | 3082 | return -1; |
@@ -2891,36 +3116,45 @@ discard block |
||
| 2891 | 3116 | |
| 2892 | 3117 | // Some external module want no update price after a trigger because they have another method to calculate the total (ex: with an extrafield) |
| 2893 | 3118 | $MODULE = ""; |
| 2894 | - if ($this->element == 'propal') |
|
| 2895 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_PROPOSAL"; |
|
| 2896 | - elseif ($this->element == 'commande' || $this->element == 'order') |
|
| 2897 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_ORDER"; |
|
| 2898 | - elseif ($this->element == 'facture' || $this->element == 'invoice') |
|
| 2899 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE"; |
|
| 2900 | - elseif ($this->element == 'facture_fourn' || $this->element == 'supplier_invoice') |
|
| 2901 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_INVOICE"; |
|
| 2902 | - elseif ($this->element == 'order_supplier' || $this->element == 'supplier_order') |
|
| 2903 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_ORDER"; |
|
| 2904 | - elseif ($this->element == 'supplier_proposal') |
|
| 2905 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_PROPOSAL"; |
|
| 3119 | + if ($this->element == 'propal') { |
|
| 3120 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_PROPOSAL"; |
|
| 3121 | + } elseif ($this->element == 'commande' || $this->element == 'order') { |
|
| 3122 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_ORDER"; |
|
| 3123 | + } elseif ($this->element == 'facture' || $this->element == 'invoice') { |
|
| 3124 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE"; |
|
| 3125 | + } elseif ($this->element == 'facture_fourn' || $this->element == 'supplier_invoice') { |
|
| 3126 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_INVOICE"; |
|
| 3127 | + } elseif ($this->element == 'order_supplier' || $this->element == 'supplier_order') { |
|
| 3128 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_ORDER"; |
|
| 3129 | + } elseif ($this->element == 'supplier_proposal') { |
|
| 3130 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_PROPOSAL"; |
|
| 3131 | + } |
|
| 2906 | 3132 | |
| 2907 | 3133 | if (! empty($MODULE)) { |
| 2908 | 3134 | if (! empty($conf->global->$MODULE)) { |
| 2909 | 3135 | $modsactivated = explode(',', $conf->global->$MODULE); |
| 2910 | 3136 | foreach ($modsactivated as $mod) { |
| 2911 | - if ($conf->$mod->enabled) |
|
| 2912 | - return 1; // update was disabled by specific setup |
|
| 3137 | + if ($conf->$mod->enabled) { |
|
| 3138 | + return 1; |
|
| 3139 | + } |
|
| 3140 | + // update was disabled by specific setup |
|
| 2913 | 3141 | } |
| 2914 | 3142 | } |
| 2915 | 3143 | } |
| 2916 | 3144 | |
| 2917 | 3145 | include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; |
| 2918 | 3146 | |
| 2919 | - if ($roundingadjust == '-1') $roundingadjust='auto'; // For backward compatibility |
|
| 3147 | + if ($roundingadjust == '-1') { |
|
| 3148 | + $roundingadjust='auto'; |
|
| 3149 | + } |
|
| 3150 | + // For backward compatibility |
|
| 2920 | 3151 | |
| 2921 | 3152 | $forcedroundingmode=$roundingadjust; |
| 2922 | - if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) $forcedroundingmode=$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND; |
|
| 2923 | - elseif ($forcedroundingmode == 'auto') $forcedroundingmode='0'; |
|
| 3153 | + if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) { |
|
| 3154 | + $forcedroundingmode=$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND; |
|
| 3155 | + } elseif ($forcedroundingmode == 'auto') { |
|
| 3156 | + $forcedroundingmode='0'; |
|
| 3157 | + } |
|
| 2924 | 3158 | |
| 2925 | 3159 | $error=0; |
| 2926 | 3160 | |
@@ -2943,15 +3177,22 @@ discard block |
||
| 2943 | 3177 | |
| 2944 | 3178 | $sql = 'SELECT rowid, qty, '.$fieldup.' as up, remise_percent, total_ht, '.$fieldtva.' as total_tva, total_ttc, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2,'; |
| 2945 | 3179 | $sql.= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type'; |
| 2946 | - if ($this->table_element_line == 'facturedet') $sql.= ', situation_percent'; |
|
| 3180 | + if ($this->table_element_line == 'facturedet') { |
|
| 3181 | + $sql.= ', situation_percent'; |
|
| 3182 | + } |
|
| 2947 | 3183 | $sql.= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; |
| 2948 | 3184 | $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2949 | 3185 | $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
| 2950 | 3186 | if ($exclspec) |
| 2951 | 3187 | { |
| 2952 | 3188 | $product_field='product_type'; |
| 2953 | - if ($this->table_element_line == 'contratdet') $product_field=''; // contratdet table has no product_type field |
|
| 2954 | - if ($product_field) $sql.= ' AND '.$product_field.' <> 9'; |
|
| 3189 | + if ($this->table_element_line == 'contratdet') { |
|
| 3190 | + $product_field=''; |
|
| 3191 | + } |
|
| 3192 | + // contratdet table has no product_type field |
|
| 3193 | + if ($product_field) { |
|
| 3194 | + $sql.= ' AND '.$product_field.' <> 9'; |
|
| 3195 | + } |
|
| 2955 | 3196 | } |
| 2956 | 3197 | $sql.= ' ORDER by rowid'; // We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used |
| 2957 | 3198 | |
@@ -2981,9 +3222,11 @@ discard block |
||
| 2981 | 3222 | $parameters=array('fk_element' => $obj->rowid); |
| 2982 | 3223 | $reshook = $hookmanager->executeHooks('changeRoundingMode', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
| 2983 | 3224 | |
| 2984 | - if (empty($reshook) && $forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' |
|
| 3225 | + if (empty($reshook) && $forcedroundingmode == '0') { |
|
| 3226 | + // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' |
|
| 2985 | 3227 | { |
| 2986 | 3228 | $localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx); |
| 3229 | + } |
|
| 2987 | 3230 | $tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx); |
| 2988 | 3231 | $diff=price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); |
| 2989 | 3232 | if ($diff) |
@@ -2991,7 +3234,9 @@ discard block |
||
| 2991 | 3234 | $sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid; |
| 2992 | 3235 | dol_syslog('We found unconsistent data into detailed line (difference of '.$diff.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); |
| 2993 | 3236 | $resqlfix=$this->db->query($sqlfix); |
| 2994 | - if (! $resqlfix) dol_print_error($this->db, 'Failed to update line'); |
|
| 3237 | + if (! $resqlfix) { |
|
| 3238 | + dol_print_error($this->db, 'Failed to update line'); |
|
| 3239 | + } |
|
| 2995 | 3240 | $obj->total_tva = $tmpcal[1]; |
| 2996 | 3241 | $obj->total_ttc = $tmpcal[2]; |
| 2997 | 3242 | // |
@@ -3007,16 +3252,24 @@ discard block |
||
| 3007 | 3252 | $this->multicurrency_total_tva += $obj->multicurrency_total_tva; |
| 3008 | 3253 | $this->multicurrency_total_ttc += $obj->multicurrency_total_ttc; |
| 3009 | 3254 | |
| 3010 | - if (! isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate]=0; |
|
| 3011 | - if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0; |
|
| 3012 | - if (! isset($total_ttc_by_vats[$obj->vatrate])) $total_ttc_by_vats[$obj->vatrate]=0; |
|
| 3255 | + if (! isset($total_ht_by_vats[$obj->vatrate])) { |
|
| 3256 | + $total_ht_by_vats[$obj->vatrate]=0; |
|
| 3257 | + } |
|
| 3258 | + if (! isset($total_tva_by_vats[$obj->vatrate])) { |
|
| 3259 | + $total_tva_by_vats[$obj->vatrate]=0; |
|
| 3260 | + } |
|
| 3261 | + if (! isset($total_ttc_by_vats[$obj->vatrate])) { |
|
| 3262 | + $total_ttc_by_vats[$obj->vatrate]=0; |
|
| 3263 | + } |
|
| 3013 | 3264 | $total_ht_by_vats[$obj->vatrate] += $obj->total_ht; |
| 3014 | 3265 | $total_tva_by_vats[$obj->vatrate] += $obj->total_tva; |
| 3015 | 3266 | $total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc; |
| 3016 | 3267 | |
| 3017 | - if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency |
|
| 3268 | + if ($forcedroundingmode == '1') { |
|
| 3269 | + // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency |
|
| 3018 | 3270 | { |
| 3019 | 3271 | $tmpvat=price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); |
| 3272 | + } |
|
| 3020 | 3273 | $diff=price2num($total_tva_by_vats[$obj->vatrate]-$tmpvat, 'MT', 1); |
| 3021 | 3274 | //print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")."<br>\n"; |
| 3022 | 3275 | if ($diff) |
@@ -3025,7 +3278,9 @@ discard block |
||
| 3025 | 3278 | $sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".($obj->total_tva - $diff).", total_ttc = ".($obj->total_ttc - $diff)." WHERE rowid = ".$obj->rowid; |
| 3026 | 3279 | dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); |
| 3027 | 3280 | $resqlfix=$this->db->query($sqlfix); |
| 3028 | - if (! $resqlfix) dol_print_error($this->db, 'Failed to update line'); |
|
| 3281 | + if (! $resqlfix) { |
|
| 3282 | + dol_print_error($this->db, 'Failed to update line'); |
|
| 3283 | + } |
|
| 3029 | 3284 | $this->total_tva -= $diff; |
| 3030 | 3285 | $this->total_ttc -= $diff; |
| 3031 | 3286 | $total_tva_by_vats[$obj->vatrate] -= $diff; |
@@ -3066,11 +3321,21 @@ discard block |
||
| 3066 | 3321 | $fieldlocaltax2='localtax2'; |
| 3067 | 3322 | $fieldttc='total_ttc'; |
| 3068 | 3323 | // Specific code for backward compatibility with old field names |
| 3069 | - if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht='total'; |
|
| 3070 | - if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva'; |
|
| 3071 | - if ($this->element == 'propal') $fieldttc='total'; |
|
| 3072 | - if ($this->element == 'expensereport') $fieldtva='total_tva'; |
|
| 3073 | - if ($this->element == 'supplier_proposal') $fieldttc='total'; |
|
| 3324 | + if ($this->element == 'facture' || $this->element == 'facturerec') { |
|
| 3325 | + $fieldht='total'; |
|
| 3326 | + } |
|
| 3327 | + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { |
|
| 3328 | + $fieldtva='total_tva'; |
|
| 3329 | + } |
|
| 3330 | + if ($this->element == 'propal') { |
|
| 3331 | + $fieldttc='total'; |
|
| 3332 | + } |
|
| 3333 | + if ($this->element == 'expensereport') { |
|
| 3334 | + $fieldtva='total_tva'; |
|
| 3335 | + } |
|
| 3336 | + if ($this->element == 'supplier_proposal') { |
|
| 3337 | + $fieldttc='total'; |
|
| 3338 | + } |
|
| 3074 | 3339 | |
| 3075 | 3340 | if (empty($nodatabaseupdate)) |
| 3076 | 3341 | { |
@@ -3099,13 +3364,11 @@ discard block |
||
| 3099 | 3364 | if (! $error) |
| 3100 | 3365 | { |
| 3101 | 3366 | return 1; |
| 3102 | - } |
|
| 3103 | - else |
|
| 3367 | + } else |
|
| 3104 | 3368 | { |
| 3105 | 3369 | return -1; |
| 3106 | 3370 | } |
| 3107 | - } |
|
| 3108 | - else |
|
| 3371 | + } else |
|
| 3109 | 3372 | { |
| 3110 | 3373 | dol_print_error($this->db, 'Bad request in update_price'); |
| 3111 | 3374 | return -1; |
@@ -3128,10 +3391,18 @@ discard block |
||
| 3128 | 3391 | $origin_id = (! empty($origin_id) ? $origin_id : $this->origin_id); |
| 3129 | 3392 | |
| 3130 | 3393 | // Special case |
| 3131 | - if ($origin == 'order') $origin='commande'; |
|
| 3132 | - if ($origin == 'invoice') $origin='facture'; |
|
| 3133 | - if ($origin == 'invoice_template') $origin='facturerec'; |
|
| 3134 | - if ($origin == 'supplierorder') $origin='order_supplier'; |
|
| 3394 | + if ($origin == 'order') { |
|
| 3395 | + $origin='commande'; |
|
| 3396 | + } |
|
| 3397 | + if ($origin == 'invoice') { |
|
| 3398 | + $origin='facture'; |
|
| 3399 | + } |
|
| 3400 | + if ($origin == 'invoice_template') { |
|
| 3401 | + $origin='facturerec'; |
|
| 3402 | + } |
|
| 3403 | + if ($origin == 'supplierorder') { |
|
| 3404 | + $origin='order_supplier'; |
|
| 3405 | + } |
|
| 3135 | 3406 | $this->db->begin(); |
| 3136 | 3407 | |
| 3137 | 3408 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; |
@@ -3151,8 +3422,7 @@ discard block |
||
| 3151 | 3422 | { |
| 3152 | 3423 | $this->db->commit(); |
| 3153 | 3424 | return 1; |
| 3154 | - } |
|
| 3155 | - else |
|
| 3425 | + } else |
|
| 3156 | 3426 | { |
| 3157 | 3427 | $this->error=$this->db->lasterror(); |
| 3158 | 3428 | $this->db->rollback(); |
@@ -3197,12 +3467,16 @@ discard block |
||
| 3197 | 3467 | if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid)) |
| 3198 | 3468 | { |
| 3199 | 3469 | $justsource=true; // the source (id and type) is a search criteria |
| 3200 | - if (! empty($targettype)) $withtargettype=true; |
|
| 3470 | + if (! empty($targettype)) { |
|
| 3471 | + $withtargettype=true; |
|
| 3472 | + } |
|
| 3201 | 3473 | } |
| 3202 | 3474 | if (! empty($targetid) && ! empty($targettype) && empty($sourceid)) |
| 3203 | 3475 | { |
| 3204 | 3476 | $justtarget=true; // the target (id and type) is a search criteria |
| 3205 | - if (! empty($sourcetype)) $withsourcetype=true; |
|
| 3477 | + if (! empty($sourcetype)) { |
|
| 3478 | + $withsourcetype=true; |
|
| 3479 | + } |
|
| 3206 | 3480 | } |
| 3207 | 3481 | |
| 3208 | 3482 | $sourceid = (! empty($sourceid) ? $sourceid : $this->id); |
@@ -3225,15 +3499,17 @@ discard block |
||
| 3225 | 3499 | if ($justsource) |
| 3226 | 3500 | { |
| 3227 | 3501 | $sql.= "fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."'"; |
| 3228 | - if ($withtargettype) $sql.= " AND targettype = '".$targettype."'"; |
|
| 3229 | - } |
|
| 3230 | - elseif ($justtarget) |
|
| 3502 | + if ($withtargettype) { |
|
| 3503 | + $sql.= " AND targettype = '".$targettype."'"; |
|
| 3504 | + } |
|
| 3505 | + } elseif ($justtarget) |
|
| 3231 | 3506 | { |
| 3232 | 3507 | $sql.= "fk_target = ".$targetid." AND targettype = '".$targettype."'"; |
| 3233 | - if ($withsourcetype) $sql.= " AND sourcetype = '".$sourcetype."'"; |
|
| 3508 | + if ($withsourcetype) { |
|
| 3509 | + $sql.= " AND sourcetype = '".$sourcetype."'"; |
|
| 3510 | + } |
|
| 3234 | 3511 | } |
| 3235 | - } |
|
| 3236 | - else |
|
| 3512 | + } else |
|
| 3237 | 3513 | { |
| 3238 | 3514 | $sql.= "(fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."')"; |
| 3239 | 3515 | $sql.= " ".$clause." (fk_target = ".$targetid." AND targettype = '".$targettype."')"; |
@@ -3254,13 +3530,11 @@ discard block |
||
| 3254 | 3530 | if ($justsource) |
| 3255 | 3531 | { |
| 3256 | 3532 | $this->linkedObjectsIds[$obj->targettype][$obj->rowid]=$obj->fk_target; |
| 3257 | - } |
|
| 3258 | - elseif ($justtarget) |
|
| 3533 | + } elseif ($justtarget) |
|
| 3259 | 3534 | { |
| 3260 | 3535 | $this->linkedObjectsIds[$obj->sourcetype][$obj->rowid]=$obj->fk_source; |
| 3261 | 3536 | } |
| 3262 | - } |
|
| 3263 | - else |
|
| 3537 | + } else |
|
| 3264 | 3538 | { |
| 3265 | 3539 | if ($obj->fk_source == $sourceid && $obj->sourcetype == $sourcetype) |
| 3266 | 3540 | { |
@@ -3277,10 +3551,12 @@ discard block |
||
| 3277 | 3551 | if (! empty($this->linkedObjectsIds)) |
| 3278 | 3552 | { |
| 3279 | 3553 | $tmparray = $this->linkedObjectsIds; |
| 3280 | - foreach($tmparray as $objecttype => $objectids) // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...) |
|
| 3554 | + foreach($tmparray as $objecttype => $objectids) { |
|
| 3555 | + // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...) |
|
| 3281 | 3556 | { |
| 3282 | 3557 | // Parse element/subelement (ex: project_task, cabinetmed_consultation, ...) |
| 3283 | 3558 | $module = $element = $subelement = $objecttype; |
| 3559 | + } |
|
| 3284 | 3560 | if ($objecttype != 'supplier_proposal' && $objecttype != 'order_supplier' && $objecttype != 'invoice_supplier' |
| 3285 | 3561 | && preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs)) |
| 3286 | 3562 | { |
@@ -3292,29 +3568,21 @@ discard block |
||
| 3292 | 3568 | // To work with non standard classpath or module name |
| 3293 | 3569 | if ($objecttype == 'facture') { |
| 3294 | 3570 | $classpath = 'compta/facture/class'; |
| 3295 | - } |
|
| 3296 | - elseif ($objecttype == 'facturerec') { |
|
| 3571 | + } elseif ($objecttype == 'facturerec') { |
|
| 3297 | 3572 | $classpath = 'compta/facture/class'; $module = 'facture'; |
| 3298 | - } |
|
| 3299 | - elseif ($objecttype == 'propal') { |
|
| 3573 | + } elseif ($objecttype == 'propal') { |
|
| 3300 | 3574 | $classpath = 'comm/propal/class'; |
| 3301 | - } |
|
| 3302 | - elseif ($objecttype == 'supplier_proposal') { |
|
| 3575 | + } elseif ($objecttype == 'supplier_proposal') { |
|
| 3303 | 3576 | $classpath = 'supplier_proposal/class'; |
| 3304 | - } |
|
| 3305 | - elseif ($objecttype == 'shipping') { |
|
| 3577 | + } elseif ($objecttype == 'shipping') { |
|
| 3306 | 3578 | $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; |
| 3307 | - } |
|
| 3308 | - elseif ($objecttype == 'delivery') { |
|
| 3579 | + } elseif ($objecttype == 'delivery') { |
|
| 3309 | 3580 | $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; |
| 3310 | - } |
|
| 3311 | - elseif ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier') { |
|
| 3581 | + } elseif ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier') { |
|
| 3312 | 3582 | $classpath = 'fourn/class'; $module = 'fournisseur'; |
| 3313 | - } |
|
| 3314 | - elseif ($objecttype == 'fichinter') { |
|
| 3583 | + } elseif ($objecttype == 'fichinter') { |
|
| 3315 | 3584 | $classpath = 'fichinter/class'; $subelement = 'fichinter'; $module = 'ficheinter'; |
| 3316 | - } |
|
| 3317 | - elseif ($objecttype == 'subscription') { |
|
| 3585 | + } elseif ($objecttype == 'subscription') { |
|
| 3318 | 3586 | $classpath = 'adherents/class'; $module = 'adherent'; |
| 3319 | 3587 | } |
| 3320 | 3588 | |
@@ -3323,20 +3591,15 @@ discard block |
||
| 3323 | 3591 | |
| 3324 | 3592 | if ($objecttype == 'order') { |
| 3325 | 3593 | $classfile = 'commande'; $classname = 'Commande'; |
| 3326 | - } |
|
| 3327 | - elseif ($objecttype == 'invoice_supplier') { |
|
| 3594 | + } elseif ($objecttype == 'invoice_supplier') { |
|
| 3328 | 3595 | $classfile = 'fournisseur.facture'; $classname = 'FactureFournisseur'; |
| 3329 | - } |
|
| 3330 | - elseif ($objecttype == 'order_supplier') { |
|
| 3596 | + } elseif ($objecttype == 'order_supplier') { |
|
| 3331 | 3597 | $classfile = 'fournisseur.commande'; $classname = 'CommandeFournisseur'; |
| 3332 | - } |
|
| 3333 | - elseif ($objecttype == 'supplier_proposal') { |
|
| 3598 | + } elseif ($objecttype == 'supplier_proposal') { |
|
| 3334 | 3599 | $classfile = 'supplier_proposal'; $classname = 'SupplierProposal'; |
| 3335 | - } |
|
| 3336 | - elseif ($objecttype == 'facturerec') { |
|
| 3600 | + } elseif ($objecttype == 'facturerec') { |
|
| 3337 | 3601 | $classfile = 'facture-rec'; $classname = 'FactureRec'; |
| 3338 | - } |
|
| 3339 | - elseif ($objecttype == 'subscription') { |
|
| 3602 | + } elseif ($objecttype == 'subscription') { |
|
| 3340 | 3603 | $classfile = 'subscription'; $classname = 'Subscription'; |
| 3341 | 3604 | } |
| 3342 | 3605 | |
@@ -3349,9 +3612,11 @@ discard block |
||
| 3349 | 3612 | //print '/'.$classpath.'/'.$classfile.'.class.php '.class_exists($classname); |
| 3350 | 3613 | if (class_exists($classname)) |
| 3351 | 3614 | { |
| 3352 | - foreach($objectids as $i => $objectid) // $i is rowid into llx_element_element |
|
| 3615 | + foreach($objectids as $i => $objectid) { |
|
| 3616 | + // $i is rowid into llx_element_element |
|
| 3353 | 3617 | { |
| 3354 | 3618 | $object = new $classname($this->db); |
| 3619 | + } |
|
| 3355 | 3620 | $ret = $object->fetch($objectid); |
| 3356 | 3621 | if ($ret >= 0) |
| 3357 | 3622 | { |
@@ -3360,16 +3625,14 @@ discard block |
||
| 3360 | 3625 | } |
| 3361 | 3626 | } |
| 3362 | 3627 | } |
| 3363 | - } |
|
| 3364 | - else |
|
| 3628 | + } else |
|
| 3365 | 3629 | { |
| 3366 | 3630 | unset($this->linkedObjectsIds[$objecttype]); |
| 3367 | 3631 | } |
| 3368 | 3632 | } |
| 3369 | 3633 | } |
| 3370 | 3634 | return 1; |
| 3371 | - } |
|
| 3372 | - else |
|
| 3635 | + } else |
|
| 3373 | 3636 | { |
| 3374 | 3637 | dol_print_error($this->db); |
| 3375 | 3638 | return -1; |
@@ -3391,8 +3654,11 @@ discard block |
||
| 3391 | 3654 | $updatesource=false; |
| 3392 | 3655 | $updatetarget=false; |
| 3393 | 3656 | |
| 3394 | - if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $updatesource=true; |
|
| 3395 | - elseif (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $updatetarget=true; |
|
| 3657 | + if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) { |
|
| 3658 | + $updatesource=true; |
|
| 3659 | + } elseif (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) { |
|
| 3660 | + $updatetarget=true; |
|
| 3661 | + } |
|
| 3396 | 3662 | |
| 3397 | 3663 | $sql = "UPDATE ".MAIN_DB_PREFIX."element_element SET "; |
| 3398 | 3664 | if ($updatesource) |
@@ -3401,8 +3667,7 @@ discard block |
||
| 3401 | 3667 | $sql.= ", sourcetype = '".$this->db->escape($sourcetype)."'"; |
| 3402 | 3668 | $sql.= " WHERE fk_target = ".$this->id; |
| 3403 | 3669 | $sql.= " AND targettype = '".$this->db->escape($this->element)."'"; |
| 3404 | - } |
|
| 3405 | - elseif ($updatetarget) |
|
| 3670 | + } elseif ($updatetarget) |
|
| 3406 | 3671 | { |
| 3407 | 3672 | $sql.= "fk_target = ".$targetid; |
| 3408 | 3673 | $sql.= ", targettype = '".$this->db->escape($targettype)."'"; |
@@ -3414,8 +3679,7 @@ discard block |
||
| 3414 | 3679 | if ($this->db->query($sql)) |
| 3415 | 3680 | { |
| 3416 | 3681 | return 1; |
| 3417 | - } |
|
| 3418 | - else |
|
| 3682 | + } else |
|
| 3419 | 3683 | { |
| 3420 | 3684 | $this->error=$this->db->lasterror(); |
| 3421 | 3685 | return -1; |
@@ -3438,8 +3702,11 @@ discard block |
||
| 3438 | 3702 | $deletesource=false; |
| 3439 | 3703 | $deletetarget=false; |
| 3440 | 3704 | |
| 3441 | - if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $deletesource=true; |
|
| 3442 | - elseif (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $deletetarget=true; |
|
| 3705 | + if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) { |
|
| 3706 | + $deletesource=true; |
|
| 3707 | + } elseif (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) { |
|
| 3708 | + $deletetarget=true; |
|
| 3709 | + } |
|
| 3443 | 3710 | |
| 3444 | 3711 | $sourceid = (! empty($sourceid) ? $sourceid : $this->id); |
| 3445 | 3712 | $sourcetype = (! empty($sourcetype) ? $sourcetype : $this->element); |
@@ -3451,20 +3718,17 @@ discard block |
||
| 3451 | 3718 | if ($rowid > 0) |
| 3452 | 3719 | { |
| 3453 | 3720 | $sql.=" rowid = ".$rowid; |
| 3454 | - } |
|
| 3455 | - else |
|
| 3721 | + } else |
|
| 3456 | 3722 | { |
| 3457 | 3723 | if ($deletesource) |
| 3458 | 3724 | { |
| 3459 | 3725 | $sql.= " fk_source = ".$sourceid." AND sourcetype = '".$this->db->escape($sourcetype)."'"; |
| 3460 | 3726 | $sql.= " AND fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."'"; |
| 3461 | - } |
|
| 3462 | - elseif ($deletetarget) |
|
| 3727 | + } elseif ($deletetarget) |
|
| 3463 | 3728 | { |
| 3464 | 3729 | $sql.= " fk_target = ".$targetid." AND targettype = '".$this->db->escape($targettype)."'"; |
| 3465 | 3730 | $sql.= " AND fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."'"; |
| 3466 | - } |
|
| 3467 | - else |
|
| 3731 | + } else |
|
| 3468 | 3732 | { |
| 3469 | 3733 | $sql.= " (fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."')"; |
| 3470 | 3734 | $sql.= " OR"; |
@@ -3476,8 +3740,7 @@ discard block |
||
| 3476 | 3740 | if ($this->db->query($sql)) |
| 3477 | 3741 | { |
| 3478 | 3742 | return 1; |
| 3479 | - } |
|
| 3480 | - else |
|
| 3743 | + } else |
|
| 3481 | 3744 | { |
| 3482 | 3745 | $this->error=$this->db->lasterror(); |
| 3483 | 3746 | $this->errors[]=$this->error; |
@@ -3506,17 +3769,31 @@ discard block |
||
| 3506 | 3769 | $this->db->begin(); |
| 3507 | 3770 | |
| 3508 | 3771 | $fieldstatus="fk_statut"; |
| 3509 | - if ($elementTable == 'facture_rec') $fieldstatus="suspended"; |
|
| 3510 | - if ($elementTable == 'mailing') $fieldstatus="statut"; |
|
| 3511 | - if ($elementTable == 'cronjob') $fieldstatus="status"; |
|
| 3512 | - if ($elementTable == 'user') $fieldstatus="statut"; |
|
| 3513 | - if ($elementTable == 'expensereport') $fieldstatus="fk_statut"; |
|
| 3514 | - if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus="status"; |
|
| 3772 | + if ($elementTable == 'facture_rec') { |
|
| 3773 | + $fieldstatus="suspended"; |
|
| 3774 | + } |
|
| 3775 | + if ($elementTable == 'mailing') { |
|
| 3776 | + $fieldstatus="statut"; |
|
| 3777 | + } |
|
| 3778 | + if ($elementTable == 'cronjob') { |
|
| 3779 | + $fieldstatus="status"; |
|
| 3780 | + } |
|
| 3781 | + if ($elementTable == 'user') { |
|
| 3782 | + $fieldstatus="statut"; |
|
| 3783 | + } |
|
| 3784 | + if ($elementTable == 'expensereport') { |
|
| 3785 | + $fieldstatus="fk_statut"; |
|
| 3786 | + } |
|
| 3787 | + if ($elementTable == 'commande_fournisseur_dispatch') { |
|
| 3788 | + $fieldstatus="status"; |
|
| 3789 | + } |
|
| 3515 | 3790 | |
| 3516 | 3791 | $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; |
| 3517 | 3792 | $sql.= " SET ".$fieldstatus." = ".$status; |
| 3518 | 3793 | // If status = 1 = validated, update also fk_user_valid |
| 3519 | - if ($status == 1 && $elementTable == 'expensereport') $sql.=", fk_user_valid = ".$user->id; |
|
| 3794 | + if ($status == 1 && $elementTable == 'expensereport') { |
|
| 3795 | + $sql.=", fk_user_valid = ".$user->id; |
|
| 3796 | + } |
|
| 3520 | 3797 | $sql.= " WHERE rowid=".$elementId; |
| 3521 | 3798 | |
| 3522 | 3799 | dol_syslog(get_class($this)."::setStatut", LOG_DEBUG); |
@@ -3527,12 +3804,27 @@ discard block |
||
| 3527 | 3804 | // Try autoset of trigkey |
| 3528 | 3805 | if (empty($trigkey)) |
| 3529 | 3806 | { |
| 3530 | - if ($this->element == 'supplier_proposal' && $status == 2) $trigkey='SUPPLIER_PROPOSAL_SIGN'; // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class |
|
| 3531 | - if ($this->element == 'supplier_proposal' && $status == 3) $trigkey='SUPPLIER_PROPOSAL_REFUSE'; // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class |
|
| 3532 | - if ($this->element == 'supplier_proposal' && $status == 4) $trigkey='SUPPLIER_PROPOSAL_CLOSE'; // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class |
|
| 3533 | - if ($this->element == 'fichinter' && $status == 3) $trigkey='FICHINTER_CLASSIFY_DONE'; |
|
| 3534 | - if ($this->element == 'fichinter' && $status == 2) $trigkey='FICHINTER_CLASSIFY_BILLED'; |
|
| 3535 | - if ($this->element == 'fichinter' && $status == 1) $trigkey='FICHINTER_CLASSIFY_UNBILLED'; |
|
| 3807 | + if ($this->element == 'supplier_proposal' && $status == 2) { |
|
| 3808 | + $trigkey='SUPPLIER_PROPOSAL_SIGN'; |
|
| 3809 | + } |
|
| 3810 | + // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class |
|
| 3811 | + if ($this->element == 'supplier_proposal' && $status == 3) { |
|
| 3812 | + $trigkey='SUPPLIER_PROPOSAL_REFUSE'; |
|
| 3813 | + } |
|
| 3814 | + // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class |
|
| 3815 | + if ($this->element == 'supplier_proposal' && $status == 4) { |
|
| 3816 | + $trigkey='SUPPLIER_PROPOSAL_CLOSE'; |
|
| 3817 | + } |
|
| 3818 | + // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class |
|
| 3819 | + if ($this->element == 'fichinter' && $status == 3) { |
|
| 3820 | + $trigkey='FICHINTER_CLASSIFY_DONE'; |
|
| 3821 | + } |
|
| 3822 | + if ($this->element == 'fichinter' && $status == 2) { |
|
| 3823 | + $trigkey='FICHINTER_CLASSIFY_BILLED'; |
|
| 3824 | + } |
|
| 3825 | + if ($this->element == 'fichinter' && $status == 1) { |
|
| 3826 | + $trigkey='FICHINTER_CLASSIFY_UNBILLED'; |
|
| 3827 | + } |
|
| 3536 | 3828 | } |
| 3537 | 3829 | |
| 3538 | 3830 | if ($trigkey) |
@@ -3551,22 +3843,22 @@ discard block |
||
| 3551 | 3843 | { |
| 3552 | 3844 | $this->db->commit(); |
| 3553 | 3845 | |
| 3554 | - if (empty($savElementId)) // If the element we update was $this (so $elementId is null) |
|
| 3846 | + if (empty($savElementId)) { |
|
| 3847 | + // If the element we update was $this (so $elementId is null) |
|
| 3555 | 3848 | { |
| 3556 | 3849 | $this->statut = $status; |
| 3850 | + } |
|
| 3557 | 3851 | $this->status = $status; |
| 3558 | 3852 | } |
| 3559 | 3853 | |
| 3560 | 3854 | return 1; |
| 3561 | - } |
|
| 3562 | - else |
|
| 3855 | + } else |
|
| 3563 | 3856 | { |
| 3564 | 3857 | $this->db->rollback(); |
| 3565 | 3858 | dol_syslog(get_class($this)."::setStatus ".$this->error, LOG_ERR); |
| 3566 | 3859 | return -1; |
| 3567 | 3860 | } |
| 3568 | - } |
|
| 3569 | - else |
|
| 3861 | + } else |
|
| 3570 | 3862 | { |
| 3571 | 3863 | $this->error=$this->db->lasterror(); |
| 3572 | 3864 | $this->db->rollback(); |
@@ -3586,8 +3878,13 @@ discard block |
||
| 3586 | 3878 | { |
| 3587 | 3879 | global $conf; |
| 3588 | 3880 | |
| 3589 | - if (empty($id) && empty($ref)) return 0; |
|
| 3590 | - if (! empty($conf->global->MAIN_DISABLE_CANVAS)) return 0; // To increase speed. Not enabled by default. |
|
| 3881 | + if (empty($id) && empty($ref)) { |
|
| 3882 | + return 0; |
|
| 3883 | + } |
|
| 3884 | + if (! empty($conf->global->MAIN_DISABLE_CANVAS)) { |
|
| 3885 | + return 0; |
|
| 3886 | + } |
|
| 3887 | + // To increase speed. Not enabled by default. |
|
| 3591 | 3888 | |
| 3592 | 3889 | // Clean parameters |
| 3593 | 3890 | $ref = trim($ref); |
@@ -3595,8 +3892,12 @@ discard block |
||
| 3595 | 3892 | $sql = "SELECT rowid, canvas"; |
| 3596 | 3893 | $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element; |
| 3597 | 3894 | $sql.= " WHERE entity IN (".getEntity($this->element).")"; |
| 3598 | - if (! empty($id)) $sql.= " AND rowid = ".$id; |
|
| 3599 | - if (! empty($ref)) $sql.= " AND ref = '".$this->db->escape($ref)."'"; |
|
| 3895 | + if (! empty($id)) { |
|
| 3896 | + $sql.= " AND rowid = ".$id; |
|
| 3897 | + } |
|
| 3898 | + if (! empty($ref)) { |
|
| 3899 | + $sql.= " AND ref = '".$this->db->escape($ref)."'"; |
|
| 3900 | + } |
|
| 3600 | 3901 | |
| 3601 | 3902 | $resql = $this->db->query($sql); |
| 3602 | 3903 | if ($resql) |
@@ -3606,10 +3907,10 @@ discard block |
||
| 3606 | 3907 | { |
| 3607 | 3908 | $this->canvas = $obj->canvas; |
| 3608 | 3909 | return 1; |
| 3910 | + } else { |
|
| 3911 | + return 0; |
|
| 3609 | 3912 | } |
| 3610 | - else return 0; |
|
| 3611 | - } |
|
| 3612 | - else |
|
| 3913 | + } else |
|
| 3613 | 3914 | { |
| 3614 | 3915 | dol_print_error($this->db); |
| 3615 | 3916 | return -1; |
@@ -3646,7 +3947,9 @@ discard block |
||
| 3646 | 3947 | { |
| 3647 | 3948 | global $langs; |
| 3648 | 3949 | |
| 3649 | - if (empty($id)) $id=$this->id; |
|
| 3950 | + if (empty($id)) { |
|
| 3951 | + $id=$this->id; |
|
| 3952 | + } |
|
| 3650 | 3953 | |
| 3651 | 3954 | // Check parameters |
| 3652 | 3955 | if (! isset($this->childtables) || ! is_array($this->childtables) || count($this->childtables) == 0) |
@@ -3680,18 +3983,18 @@ discard block |
||
| 3680 | 3983 | $langs->load("errors"); |
| 3681 | 3984 | //print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild; |
| 3682 | 3985 | $haschild += $obj->nb; |
| 3683 | - if (is_numeric($elementname)) // old usage |
|
| 3986 | + if (is_numeric($elementname)) { |
|
| 3987 | + // old usage |
|
| 3684 | 3988 | { |
| 3685 | 3989 | $this->errors[]=$langs->trans("ErrorRecordHasAtLeastOneChildOfType", $table); |
| 3686 | 3990 | } |
| 3687 | - else // new usage: $elementname=Translation key |
|
| 3991 | + } else // new usage: $elementname=Translation key |
|
| 3688 | 3992 | { |
| 3689 | 3993 | $this->errors[]=$langs->trans("ErrorRecordHasAtLeastOneChildOfType", $langs->transnoentitiesnoconv($elementname)); |
| 3690 | 3994 | } |
| 3691 | 3995 | break; // We found at least one, we stop here |
| 3692 | 3996 | } |
| 3693 | - } |
|
| 3694 | - else |
|
| 3997 | + } else |
|
| 3695 | 3998 | { |
| 3696 | 3999 | $this->errors[]=$this->db->lasterror(); |
| 3697 | 4000 | return -1; |
@@ -3701,8 +4004,9 @@ discard block |
||
| 3701 | 4004 | { |
| 3702 | 4005 | $this->errors[]="ErrorRecordHasChildren"; |
| 3703 | 4006 | return $haschild; |
| 4007 | + } else { |
|
| 4008 | + return 0; |
|
| 3704 | 4009 | } |
| 3705 | - else return 0; |
|
| 3706 | 4010 | } |
| 3707 | 4011 | |
| 3708 | 4012 | /** |
@@ -3718,12 +4022,24 @@ discard block |
||
| 3718 | 4022 | foreach($this->lines as $key => $val) |
| 3719 | 4023 | { |
| 3720 | 4024 | $qualified=0; |
| 3721 | - if ($predefined == -1) $qualified=1; |
|
| 3722 | - if ($predefined == 1 && $val->fk_product > 0) $qualified=1; |
|
| 3723 | - if ($predefined == 0 && $val->fk_product <= 0) $qualified=1; |
|
| 3724 | - if ($predefined == 2 && $val->fk_product > 0 && $val->product_type==0) $qualified=1; |
|
| 3725 | - if ($predefined == 3 && $val->fk_product > 0 && $val->product_type==1) $qualified=1; |
|
| 3726 | - if ($qualified) $nb++; |
|
| 4025 | + if ($predefined == -1) { |
|
| 4026 | + $qualified=1; |
|
| 4027 | + } |
|
| 4028 | + if ($predefined == 1 && $val->fk_product > 0) { |
|
| 4029 | + $qualified=1; |
|
| 4030 | + } |
|
| 4031 | + if ($predefined == 0 && $val->fk_product <= 0) { |
|
| 4032 | + $qualified=1; |
|
| 4033 | + } |
|
| 4034 | + if ($predefined == 2 && $val->fk_product > 0 && $val->product_type==0) { |
|
| 4035 | + $qualified=1; |
|
| 4036 | + } |
|
| 4037 | + if ($predefined == 3 && $val->fk_product > 0 && $val->product_type==1) { |
|
| 4038 | + $qualified=1; |
|
| 4039 | + } |
|
| 4040 | + if ($qualified) { |
|
| 4041 | + $nb++; |
|
| 4042 | + } |
|
| 3727 | 4043 | } |
| 3728 | 4044 | dol_syslog(get_class($this).'::hasProductsOrServices we found '.$nb.' qualified lines of products/servcies'); |
| 3729 | 4045 | return $nb; |
@@ -3787,17 +4103,24 @@ discard block |
||
| 3787 | 4103 | { |
| 3788 | 4104 | if (isset($line->qty_asked)) |
| 3789 | 4105 | { |
| 3790 | - if (empty($totalOrdered)) $totalOrdered=0; // Avoid warning because $totalOrdered is '' |
|
| 4106 | + if (empty($totalOrdered)) { |
|
| 4107 | + $totalOrdered=0; |
|
| 4108 | + } |
|
| 4109 | + // Avoid warning because $totalOrdered is '' |
|
| 3791 | 4110 | $totalOrdered+=$line->qty_asked; // defined for shipment only |
| 3792 | 4111 | } |
| 3793 | 4112 | if (isset($line->qty_shipped)) |
| 3794 | 4113 | { |
| 3795 | - if (empty($totalToShip)) $totalToShip=0; // Avoid warning because $totalToShip is '' |
|
| 4114 | + if (empty($totalToShip)) { |
|
| 4115 | + $totalToShip=0; |
|
| 4116 | + } |
|
| 4117 | + // Avoid warning because $totalToShip is '' |
|
| 3796 | 4118 | $totalToShip+=$line->qty_shipped; // defined for shipment only |
| 3797 | - } |
|
| 3798 | - elseif ($line->element == 'commandefournisseurdispatch' && isset($line->qty)) |
|
| 4119 | + } elseif ($line->element == 'commandefournisseurdispatch' && isset($line->qty)) |
|
| 3799 | 4120 | { |
| 3800 | - if (empty($totalToShip)) $totalToShip=0; |
|
| 4121 | + if (empty($totalToShip)) { |
|
| 4122 | + $totalToShip=0; |
|
| 4123 | + } |
|
| 3801 | 4124 | $totalToShip+=$line->qty; // defined for reception only |
| 3802 | 4125 | } |
| 3803 | 4126 | |
@@ -3805,8 +4128,7 @@ discard block |
||
| 3805 | 4128 | if ($this->element == 'shipping') { |
| 3806 | 4129 | // for shipments |
| 3807 | 4130 | $qty = $line->qty_shipped ? $line->qty_shipped : 0; |
| 3808 | - } |
|
| 3809 | - else { |
|
| 4131 | + } else { |
|
| 3810 | 4132 | $qty = $line->qty ? $line->qty : 0; |
| 3811 | 4133 | } |
| 3812 | 4134 | |
@@ -3822,19 +4144,30 @@ discard block |
||
| 3822 | 4144 | |
| 3823 | 4145 | $weightUnit=0; |
| 3824 | 4146 | $volumeUnit=0; |
| 3825 | - if (! empty($weight_units)) $weightUnit = $weight_units; |
|
| 3826 | - if (! empty($volume_units)) $volumeUnit = $volume_units; |
|
| 4147 | + if (! empty($weight_units)) { |
|
| 4148 | + $weightUnit = $weight_units; |
|
| 4149 | + } |
|
| 4150 | + if (! empty($volume_units)) { |
|
| 4151 | + $volumeUnit = $volume_units; |
|
| 4152 | + } |
|
| 3827 | 4153 | |
| 3828 | - if (empty($totalWeight)) $totalWeight=0; // Avoid warning because $totalWeight is '' |
|
| 3829 | - if (empty($totalVolume)) $totalVolume=0; // Avoid warning because $totalVolume is '' |
|
| 4154 | + if (empty($totalWeight)) { |
|
| 4155 | + $totalWeight=0; |
|
| 4156 | + } |
|
| 4157 | + // Avoid warning because $totalWeight is '' |
|
| 4158 | + if (empty($totalVolume)) { |
|
| 4159 | + $totalVolume=0; |
|
| 4160 | + } |
|
| 4161 | + // Avoid warning because $totalVolume is '' |
|
| 3830 | 4162 | |
| 3831 | 4163 | //var_dump($line->volume_units); |
| 3832 | - if ($weight_units < 50) // < 50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
|
| 4164 | + if ($weight_units < 50) { |
|
| 4165 | + // < 50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
|
| 3833 | 4166 | { |
| 3834 | 4167 | $trueWeightUnit=pow(10, $weightUnit); |
| 3835 | - $totalWeight += $weight * $qty * $trueWeightUnit; |
|
| 3836 | 4168 | } |
| 3837 | - else { |
|
| 4169 | + $totalWeight += $weight * $qty * $trueWeightUnit; |
|
| 4170 | + } else { |
|
| 3838 | 4171 | if ($weight_units == 99) { |
| 3839 | 4172 | // conversion 1 Pound = 0.45359237 KG |
| 3840 | 4173 | $trueWeightUnit = 0.45359237; |
@@ -3843,19 +4176,19 @@ discard block |
||
| 3843 | 4176 | // conversion 1 Ounce = 0.0283495 KG |
| 3844 | 4177 | $trueWeightUnit = 0.0283495; |
| 3845 | 4178 | $totalWeight += $weight * $qty * $trueWeightUnit; |
| 3846 | - } |
|
| 3847 | - else { |
|
| 4179 | + } else { |
|
| 3848 | 4180 | $totalWeight += $weight * $qty; // This may be wrong if we mix different units |
| 3849 | 4181 | } |
| 3850 | 4182 | } |
| 3851 | - if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
|
| 4183 | + if ($volume_units < 50) { |
|
| 4184 | + // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
|
| 3852 | 4185 | { |
| 3853 | 4186 | //print $line->volume."x".$line->volume_units."x".($line->volume_units < 50)."x".$volumeUnit; |
| 3854 | 4187 | $trueVolumeUnit=pow(10, $volumeUnit); |
| 4188 | + } |
|
| 3855 | 4189 | //print $line->volume; |
| 3856 | 4190 | $totalVolume += $volume * $qty * $trueVolumeUnit; |
| 3857 | - } |
|
| 3858 | - else |
|
| 4191 | + } else |
|
| 3859 | 4192 | { |
| 3860 | 4193 | $totalVolume += $volume * $qty; // This may be wrong if we mix different units |
| 3861 | 4194 | } |
@@ -3887,8 +4220,7 @@ discard block |
||
| 3887 | 4220 | $this->error=$this->db->lasterror(); |
| 3888 | 4221 | $this->db->rollback(); |
| 3889 | 4222 | return -1; |
| 3890 | - } |
|
| 3891 | - else |
|
| 4223 | + } else |
|
| 3892 | 4224 | { |
| 3893 | 4225 | $this->db->commit(); |
| 3894 | 4226 | return 1; |
@@ -3940,13 +4272,11 @@ discard block |
||
| 3940 | 4272 | { |
| 3941 | 4273 | $res = $this->db->fetch_object($resql); |
| 3942 | 4274 | return 'Incoterm : '.$res->code.' - '.$this->location_incoterms; |
| 3943 | - } |
|
| 3944 | - else |
|
| 4275 | + } else |
|
| 3945 | 4276 | { |
| 3946 | 4277 | return ''; |
| 3947 | 4278 | } |
| 3948 | - } |
|
| 3949 | - else |
|
| 4279 | + } else |
|
| 3950 | 4280 | { |
| 3951 | 4281 | $this->errors[] = $this->db->lasterror(); |
| 3952 | 4282 | return false; |
@@ -3983,14 +4313,14 @@ discard block |
||
| 3983 | 4313 | $this->label_incoterms = $obj->libelle; |
| 3984 | 4314 | } |
| 3985 | 4315 | return 1; |
| 3986 | - } |
|
| 3987 | - else |
|
| 4316 | + } else |
|
| 3988 | 4317 | { |
| 3989 | 4318 | $this->errors[] = $this->db->lasterror(); |
| 3990 | 4319 | return -1; |
| 3991 | 4320 | } |
| 4321 | + } else { |
|
| 4322 | + return -1; |
|
| 3992 | 4323 | } |
| 3993 | - else return -1; |
|
| 3994 | 4324 | } |
| 3995 | 4325 | |
| 3996 | 4326 | |
@@ -4030,8 +4360,7 @@ discard block |
||
| 4030 | 4360 | if (!empty($module)) |
| 4031 | 4361 | { |
| 4032 | 4362 | $tpl = dol_buildpath($reldir.'/objectline_create.tpl.php'); |
| 4033 | - } |
|
| 4034 | - else |
|
| 4363 | + } else |
|
| 4035 | 4364 | { |
| 4036 | 4365 | $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_create.tpl.php'; |
| 4037 | 4366 | } |
@@ -4041,7 +4370,9 @@ discard block |
||
| 4041 | 4370 | } else { |
| 4042 | 4371 | $res=include $tpl; // for debug |
| 4043 | 4372 | } |
| 4044 | - if ($res) break; |
|
| 4373 | + if ($res) { |
|
| 4374 | + break; |
|
| 4375 | + } |
|
| 4045 | 4376 | } |
| 4046 | 4377 | } |
| 4047 | 4378 | |
@@ -4072,7 +4403,9 @@ discard block |
||
| 4072 | 4403 | |
| 4073 | 4404 | // Define usemargins |
| 4074 | 4405 | $usemargins=0; |
| 4075 | - if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element, array('facture','facturerec','propal','commande'))) $usemargins=1; |
|
| 4406 | + if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element, array('facture','facturerec','propal','commande'))) { |
|
| 4407 | + $usemargins=1; |
|
| 4408 | + } |
|
| 4076 | 4409 | |
| 4077 | 4410 | $num = count($this->lines); |
| 4078 | 4411 | |
@@ -4096,8 +4429,7 @@ discard block |
||
| 4096 | 4429 | if (!empty($module)) |
| 4097 | 4430 | { |
| 4098 | 4431 | $tpl = dol_buildpath($reldir.'/objectline_title.tpl.php'); |
| 4099 | - } |
|
| 4100 | - else |
|
| 4432 | + } else |
|
| 4101 | 4433 | { |
| 4102 | 4434 | $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_title.tpl.php'; |
| 4103 | 4435 | } |
@@ -4106,7 +4438,9 @@ discard block |
||
| 4106 | 4438 | } else { |
| 4107 | 4439 | $res=include $tpl; // for debug |
| 4108 | 4440 | } |
| 4109 | - if ($res) break; |
|
| 4441 | + if ($res) { |
|
| 4442 | + break; |
|
| 4443 | + } |
|
| 4110 | 4444 | } |
| 4111 | 4445 | } |
| 4112 | 4446 | |
@@ -4120,14 +4454,15 @@ discard block |
||
| 4120 | 4454 | $line->fetch_optionals(); |
| 4121 | 4455 | |
| 4122 | 4456 | //if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) |
| 4123 | - if (is_object($hookmanager)) // Old code is commented on preceding line. |
|
| 4457 | + if (is_object($hookmanager)) { |
|
| 4458 | + // Old code is commented on preceding line. |
|
| 4124 | 4459 | { |
| 4125 | 4460 | if (empty($line->fk_parent_line)) |
| 4126 | 4461 | { |
| 4127 | 4462 | $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'table_element_line'=>$line->table_element); |
| 4463 | + } |
|
| 4128 | 4464 | $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
| 4129 | - } |
|
| 4130 | - else |
|
| 4465 | + } else |
|
| 4131 | 4466 | { |
| 4132 | 4467 | $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line); |
| 4133 | 4468 | $reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
@@ -4175,8 +4510,14 @@ discard block |
||
| 4175 | 4510 | // Show product and description |
| 4176 | 4511 | $type=(! empty($line->product_type)?$line->product_type:$line->fk_product_type); |
| 4177 | 4512 | // Try to enhance type detection using date_start and date_end for free lines where type was not saved. |
| 4178 | - if (! empty($line->date_start)) $type=1; // deprecated |
|
| 4179 | - if (! empty($line->date_end)) $type=1; // deprecated |
|
| 4513 | + if (! empty($line->date_start)) { |
|
| 4514 | + $type=1; |
|
| 4515 | + } |
|
| 4516 | + // deprecated |
|
| 4517 | + if (! empty($line->date_end)) { |
|
| 4518 | + $type=1; |
|
| 4519 | + } |
|
| 4520 | + // deprecated |
|
| 4180 | 4521 | |
| 4181 | 4522 | // Ligne en mode visu |
| 4182 | 4523 | if ($action != 'editline' || $selected != $line->id) |
@@ -4205,8 +4546,13 @@ discard block |
||
| 4205 | 4546 | |
| 4206 | 4547 | $outputlangs = $langs; |
| 4207 | 4548 | $newlang=''; |
| 4208 | - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); |
|
| 4209 | - if (! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && empty($newlang) && is_object($this->thirdparty)) $newlang=$this->thirdparty->default_lang; // To use language of customer |
|
| 4549 | + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { |
|
| 4550 | + $newlang=GETPOST('lang_id', 'aZ09'); |
|
| 4551 | + } |
|
| 4552 | + if (! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && empty($newlang) && is_object($this->thirdparty)) { |
|
| 4553 | + $newlang=$this->thirdparty->default_lang; |
|
| 4554 | + } |
|
| 4555 | + // To use language of customer |
|
| 4210 | 4556 | if (! empty($newlang)) |
| 4211 | 4557 | { |
| 4212 | 4558 | $outputlangs = new Translate("", $conf); |
@@ -4214,8 +4560,7 @@ discard block |
||
| 4214 | 4560 | } |
| 4215 | 4561 | |
| 4216 | 4562 | $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $line->product_label; |
| 4217 | - } |
|
| 4218 | - else |
|
| 4563 | + } else |
|
| 4219 | 4564 | { |
| 4220 | 4565 | $label = $line->product_label; |
| 4221 | 4566 | } |
@@ -4234,8 +4579,7 @@ discard block |
||
| 4234 | 4579 | if (!empty($module)) |
| 4235 | 4580 | { |
| 4236 | 4581 | $tpl = dol_buildpath($reldir.'/objectline_view.tpl.php'); |
| 4237 | - } |
|
| 4238 | - else |
|
| 4582 | + } else |
|
| 4239 | 4583 | { |
| 4240 | 4584 | $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_view.tpl.php'; |
| 4241 | 4585 | } |
@@ -4245,7 +4589,9 @@ discard block |
||
| 4245 | 4589 | } else { |
| 4246 | 4590 | $res=include $tpl; // for debug |
| 4247 | 4591 | } |
| 4248 | - if ($res) break; |
|
| 4592 | + if ($res) { |
|
| 4593 | + break; |
|
| 4594 | + } |
|
| 4249 | 4595 | } |
| 4250 | 4596 | } |
| 4251 | 4597 | |
@@ -4265,8 +4611,7 @@ discard block |
||
| 4265 | 4611 | if (!empty($module)) |
| 4266 | 4612 | { |
| 4267 | 4613 | $tpl = dol_buildpath($reldir.'/objectline_edit.tpl.php'); |
| 4268 | - } |
|
| 4269 | - else |
|
| 4614 | + } else |
|
| 4270 | 4615 | { |
| 4271 | 4616 | $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_edit.tpl.php'; |
| 4272 | 4617 | } |
@@ -4276,7 +4621,9 @@ discard block |
||
| 4276 | 4621 | } else { |
| 4277 | 4622 | $res=include $tpl; // for debug |
| 4278 | 4623 | } |
| 4279 | - if ($res) break; |
|
| 4624 | + if ($res) { |
|
| 4625 | + break; |
|
| 4626 | + } |
|
| 4280 | 4627 | } |
| 4281 | 4628 | } |
| 4282 | 4629 | } |
@@ -4304,7 +4651,9 @@ discard block |
||
| 4304 | 4651 | print '<td>'.$langs->trans('Description').'</td>'; |
| 4305 | 4652 | print '<td class="right">'.$langs->trans('VATRate').'</td>'; |
| 4306 | 4653 | print '<td class="right">'.$langs->trans('PriceUHT').'</td>'; |
| 4307 | - if (!empty($conf->multicurrency->enabled)) print '<td class="right">'.$langs->trans('PriceUHTCurrency').'</td>'; |
|
| 4654 | + if (!empty($conf->multicurrency->enabled)) { |
|
| 4655 | + print '<td class="right">'.$langs->trans('PriceUHTCurrency').'</td>'; |
|
| 4656 | + } |
|
| 4308 | 4657 | print '<td class="right">'.$langs->trans('Qty').'</td>'; |
| 4309 | 4658 | if($conf->global->PRODUCT_USE_UNITS) |
| 4310 | 4659 | { |
@@ -4328,8 +4677,7 @@ discard block |
||
| 4328 | 4677 | $action=''; |
| 4329 | 4678 | $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
| 4330 | 4679 | } |
| 4331 | - } |
|
| 4332 | - else |
|
| 4680 | + } else |
|
| 4333 | 4681 | { |
| 4334 | 4682 | $this->printOriginLine($line, $var, $restrictlist, '/core/tpl', $selectedLines); |
| 4335 | 4683 | } |
@@ -4360,34 +4708,39 @@ discard block |
||
| 4360 | 4708 | if (!empty($line->date_start)) |
| 4361 | 4709 | { |
| 4362 | 4710 | $date_start=$line->date_start; |
| 4363 | - } |
|
| 4364 | - else |
|
| 4711 | + } else |
|
| 4365 | 4712 | { |
| 4366 | 4713 | $date_start=$line->date_debut_prevue; |
| 4367 | - if ($line->date_debut_reel) $date_start=$line->date_debut_reel; |
|
| 4714 | + if ($line->date_debut_reel) { |
|
| 4715 | + $date_start=$line->date_debut_reel; |
|
| 4716 | + } |
|
| 4368 | 4717 | } |
| 4369 | 4718 | if (!empty($line->date_end)) |
| 4370 | 4719 | { |
| 4371 | 4720 | $date_end=$line->date_end; |
| 4372 | - } |
|
| 4373 | - else |
|
| 4721 | + } else |
|
| 4374 | 4722 | { |
| 4375 | 4723 | $date_end=$line->date_fin_prevue; |
| 4376 | - if ($line->date_fin_reel) $date_end=$line->date_fin_reel; |
|
| 4724 | + if ($line->date_fin_reel) { |
|
| 4725 | + $date_end=$line->date_fin_reel; |
|
| 4726 | + } |
|
| 4377 | 4727 | } |
| 4378 | 4728 | |
| 4379 | 4729 | $this->tpl['id'] = $line->id; |
| 4380 | 4730 | |
| 4381 | 4731 | $this->tpl['label'] = ''; |
| 4382 | - if (! empty($line->fk_parent_line)) $this->tpl['label'].= img_picto('', 'rightarrow'); |
|
| 4732 | + if (! empty($line->fk_parent_line)) { |
|
| 4733 | + $this->tpl['label'].= img_picto('', 'rightarrow'); |
|
| 4734 | + } |
|
| 4383 | 4735 | |
| 4384 | - if (($line->info_bits & 2) == 2) // TODO Not sure this is used for source object |
|
| 4736 | + if (($line->info_bits & 2) == 2) { |
|
| 4737 | + // TODO Not sure this is used for source object |
|
| 4385 | 4738 | { |
| 4386 | 4739 | $discount=new DiscountAbsolute($this->db); |
| 4740 | + } |
|
| 4387 | 4741 | $discount->fk_soc = $this->socid; |
| 4388 | 4742 | $this->tpl['label'].= $discount->getNomUrl(0, 'discount'); |
| 4389 | - } |
|
| 4390 | - elseif (! empty($line->fk_product)) |
|
| 4743 | + } elseif (! empty($line->fk_product)) |
|
| 4391 | 4744 | { |
| 4392 | 4745 | $productstatic = new Product($this->db); |
| 4393 | 4746 | $productstatic->id = $line->fk_product; |
@@ -4405,13 +4758,12 @@ discard block |
||
| 4405 | 4758 | { |
| 4406 | 4759 | $this->tpl['label'].= get_date_range($date_start, $date_end); |
| 4407 | 4760 | } |
| 4408 | - } |
|
| 4409 | - else |
|
| 4761 | + } else |
|
| 4410 | 4762 | { |
| 4411 | 4763 | $this->tpl['label'].= ($line->product_type == -1 ? ' ' : ($line->product_type == 1 ? img_object($langs->trans(''), 'service') : img_object($langs->trans(''), 'product'))); |
| 4412 | 4764 | if (!empty($line->desc)) { |
| 4413 | 4765 | $this->tpl['label'].=$line->desc; |
| 4414 | - }else { |
|
| 4766 | + } else { |
|
| 4415 | 4767 | $this->tpl['label'].= ($line->label ? ' '.$line->label : ''); |
| 4416 | 4768 | } |
| 4417 | 4769 | |
@@ -4424,36 +4776,35 @@ discard block |
||
| 4424 | 4776 | |
| 4425 | 4777 | if (! empty($line->desc)) |
| 4426 | 4778 | { |
| 4427 | - if ($line->desc == '(CREDIT_NOTE)') // TODO Not sure this is used for source object |
|
| 4779 | + if ($line->desc == '(CREDIT_NOTE)') { |
|
| 4780 | + // TODO Not sure this is used for source object |
|
| 4428 | 4781 | { |
| 4429 | 4782 | $discount=new DiscountAbsolute($this->db); |
| 4783 | + } |
|
| 4430 | 4784 | $discount->fetch($line->fk_remise_except); |
| 4431 | 4785 | $this->tpl['description'] = $langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); |
| 4432 | - } |
|
| 4433 | - elseif ($line->desc == '(DEPOSIT)') // TODO Not sure this is used for source object |
|
| 4786 | + } elseif ($line->desc == '(DEPOSIT)') { |
|
| 4787 | + // TODO Not sure this is used for source object |
|
| 4434 | 4788 | { |
| 4435 | 4789 | $discount=new DiscountAbsolute($this->db); |
| 4790 | + } |
|
| 4436 | 4791 | $discount->fetch($line->fk_remise_except); |
| 4437 | 4792 | $this->tpl['description'] = $langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); |
| 4438 | - } |
|
| 4439 | - elseif ($line->desc == '(EXCESS RECEIVED)') |
|
| 4793 | + } elseif ($line->desc == '(EXCESS RECEIVED)') |
|
| 4440 | 4794 | { |
| 4441 | 4795 | $discount=new DiscountAbsolute($this->db); |
| 4442 | 4796 | $discount->fetch($line->fk_remise_except); |
| 4443 | 4797 | $this->tpl['description'] = $langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); |
| 4444 | - } |
|
| 4445 | - elseif ($line->desc == '(EXCESS PAID)') |
|
| 4798 | + } elseif ($line->desc == '(EXCESS PAID)') |
|
| 4446 | 4799 | { |
| 4447 | 4800 | $discount=new DiscountAbsolute($this->db); |
| 4448 | 4801 | $discount->fetch($line->fk_remise_except); |
| 4449 | 4802 | $this->tpl['description'] = $langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); |
| 4450 | - } |
|
| 4451 | - else |
|
| 4803 | + } else |
|
| 4452 | 4804 | { |
| 4453 | 4805 | $this->tpl['description'] = dol_trunc($line->desc, 60); |
| 4454 | 4806 | } |
| 4455 | - } |
|
| 4456 | - else |
|
| 4807 | + } else |
|
| 4457 | 4808 | { |
| 4458 | 4809 | $this->tpl['description'] = ' '; |
| 4459 | 4810 | } |
@@ -4461,17 +4812,23 @@ discard block |
||
| 4461 | 4812 | // VAT Rate |
| 4462 | 4813 | $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); |
| 4463 | 4814 | $this->tpl['vat_rate'] .= (($line->info_bits & 1) == 1) ? '*' : ''; |
| 4464 | - if (! empty($line->vat_src_code) && ! preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'].=' ('.$line->vat_src_code.')'; |
|
| 4815 | + if (! empty($line->vat_src_code) && ! preg_match('/\(/', $this->tpl['vat_rate'])) { |
|
| 4816 | + $this->tpl['vat_rate'].=' ('.$line->vat_src_code.')'; |
|
| 4817 | + } |
|
| 4465 | 4818 | |
| 4466 | 4819 | $this->tpl['price'] = price($line->subprice); |
| 4467 | 4820 | $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); |
| 4468 | 4821 | $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; |
| 4469 | - if ($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long')); |
|
| 4822 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 4823 | + $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long')); |
|
| 4824 | + } |
|
| 4470 | 4825 | $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' '; |
| 4471 | 4826 | |
| 4472 | 4827 | // Is the line strike or not |
| 4473 | 4828 | $this->tpl['strike']=0; |
| 4474 | - if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) $this->tpl['strike']=1; |
|
| 4829 | + if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) { |
|
| 4830 | + $this->tpl['strike']=1; |
|
| 4831 | + } |
|
| 4475 | 4832 | |
| 4476 | 4833 | // Output template part (modules that overwrite templates must declare this into descriptor) |
| 4477 | 4834 | // Use global variables + $dateSelector + $seller and $buyer |
@@ -4481,8 +4838,7 @@ discard block |
||
| 4481 | 4838 | if (!empty($module)) |
| 4482 | 4839 | { |
| 4483 | 4840 | $tpl = dol_buildpath($reldir.'/originproductline.tpl.php'); |
| 4484 | - } |
|
| 4485 | - else |
|
| 4841 | + } else |
|
| 4486 | 4842 | { |
| 4487 | 4843 | $tpl = DOL_DOCUMENT_ROOT.$reldir.'/originproductline.tpl.php'; |
| 4488 | 4844 | } |
@@ -4492,7 +4848,9 @@ discard block |
||
| 4492 | 4848 | } else { |
| 4493 | 4849 | $res=include $tpl; // for debug |
| 4494 | 4850 | } |
| 4495 | - if ($res) break; |
|
| 4851 | + if ($res) { |
|
| 4852 | + break; |
|
| 4853 | + } |
|
| 4496 | 4854 | } |
| 4497 | 4855 | } |
| 4498 | 4856 | |
@@ -4534,8 +4892,7 @@ discard block |
||
| 4534 | 4892 | { |
| 4535 | 4893 | $this->db->commit(); |
| 4536 | 4894 | return 1; |
| 4537 | - } |
|
| 4538 | - else |
|
| 4895 | + } else |
|
| 4539 | 4896 | { |
| 4540 | 4897 | $this->error=$this->db->lasterror(); |
| 4541 | 4898 | $this->db->rollback(); |
@@ -4570,8 +4927,7 @@ discard block |
||
| 4570 | 4927 | $this->error=$this->db->lasterror(); |
| 4571 | 4928 | $this->db->rollback(); |
| 4572 | 4929 | return -1; |
| 4573 | - } |
|
| 4574 | - else |
|
| 4930 | + } else |
|
| 4575 | 4931 | { |
| 4576 | 4932 | if (! $notrigger) |
| 4577 | 4933 | { |
@@ -4647,13 +5003,20 @@ discard block |
||
| 4647 | 5003 | $classname=''; |
| 4648 | 5004 | $filefound=0; |
| 4649 | 5005 | $dirmodels=array('/'); |
| 4650 | - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']); |
|
| 5006 | + if (is_array($conf->modules_parts['models'])) { |
|
| 5007 | + $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']); |
|
| 5008 | + } |
|
| 4651 | 5009 | foreach($dirmodels as $reldir) |
| 4652 | 5010 | { |
| 4653 | 5011 | foreach(array('doc','pdf') as $prefix) |
| 4654 | 5012 | { |
| 4655 | - if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php |
|
| 4656 | - else $file = $prefix."_".$modele.".modules.php"; |
|
| 5013 | + if (in_array(get_class($this), array('Adherent'))) { |
|
| 5014 | + $file = $prefix."_".$modele.".class.php"; |
|
| 5015 | + } |
|
| 5016 | + // Member module use prefix_module.class.php |
|
| 5017 | + else { |
|
| 5018 | + $file = $prefix."_".$modele.".modules.php"; |
|
| 5019 | + } |
|
| 4657 | 5020 | |
| 4658 | 5021 | // On verifie l'emplacement du modele |
| 4659 | 5022 | $file=dol_buildpath($reldir.$modelspath.$file, 0); |
@@ -4664,7 +5027,9 @@ discard block |
||
| 4664 | 5027 | break; |
| 4665 | 5028 | } |
| 4666 | 5029 | } |
| 4667 | - if ($filefound) break; |
|
| 5030 | + if ($filefound) { |
|
| 5031 | + break; |
|
| 5032 | + } |
|
| 4668 | 5033 | } |
| 4669 | 5034 | |
| 4670 | 5035 | // If generator was found |
@@ -4696,7 +5061,9 @@ discard block |
||
| 4696 | 5061 | if (is_dir($tmpdir)) |
| 4697 | 5062 | { |
| 4698 | 5063 | $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); |
| 4699 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); |
|
| 5064 | + if (count($tmpfiles)) { |
|
| 5065 | + $listoffiles=array_merge($listoffiles, $tmpfiles); |
|
| 5066 | + } |
|
| 4700 | 5067 | } |
| 4701 | 5068 | } |
| 4702 | 5069 | |
@@ -4734,8 +5101,7 @@ discard block |
||
| 4734 | 5101 | { |
| 4735 | 5102 | $arrayofrecords = array(); // The write_file of templates of adherent class need this var |
| 4736 | 5103 | $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); |
| 4737 | - } |
|
| 4738 | - else |
|
| 5104 | + } else |
|
| 4739 | 5105 | { |
| 4740 | 5106 | $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); |
| 4741 | 5107 | } |
@@ -4757,9 +5123,11 @@ discard block |
||
| 4757 | 5123 | $destfile = basename($destfull); |
| 4758 | 5124 | $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); |
| 4759 | 5125 | |
| 4760 | - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir |
|
| 5126 | + if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) { |
|
| 5127 | + // If not a tmp dir |
|
| 4761 | 5128 | { |
| 4762 | 5129 | $filename = basename($destfile); |
| 5130 | + } |
|
| 4763 | 5131 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
| 4764 | 5132 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
| 4765 | 5133 | |
@@ -4772,8 +5140,12 @@ discard block |
||
| 4772 | 5140 | if ($this->element == 'propal') |
| 4773 | 5141 | { |
| 4774 | 5142 | $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok |
| 4775 | - if ($useonlinesignature) $setsharekey=true; |
|
| 4776 | - if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; |
|
| 5143 | + if ($useonlinesignature) { |
|
| 5144 | + $setsharekey=true; |
|
| 5145 | + } |
|
| 5146 | + if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) { |
|
| 5147 | + $setsharekey=true; |
|
| 5148 | + } |
|
| 4777 | 5149 | } |
| 4778 | 5150 | if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { |
| 4779 | 5151 | $setsharekey=true; |
@@ -4786,9 +5158,11 @@ discard block |
||
| 4786 | 5158 | } |
| 4787 | 5159 | |
| 4788 | 5160 | if ($setsharekey) { |
| 4789 | - if (empty($ecmfile->share)) // Because object not found or share not set yet |
|
| 5161 | + if (empty($ecmfile->share)) { |
|
| 5162 | + // Because object not found or share not set yet |
|
| 4790 | 5163 | { |
| 4791 | 5164 | require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; |
| 5165 | + } |
|
| 4792 | 5166 | $ecmfile->share = getRandomPassword(true); |
| 4793 | 5167 | } |
| 4794 | 5168 | } |
@@ -4804,8 +5178,7 @@ discard block |
||
| 4804 | 5178 | if ($result < 0) { |
| 4805 | 5179 | setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
| 4806 | 5180 | } |
| 4807 | - } |
|
| 4808 | - else |
|
| 5181 | + } else |
|
| 4809 | 5182 | { |
| 4810 | 5183 | $ecmfile->entity = $conf->entity; |
| 4811 | 5184 | $ecmfile->filepath = $rel_dir; |
@@ -4831,7 +5204,9 @@ discard block |
||
| 4831 | 5204 | |
| 4832 | 5205 | // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) |
| 4833 | 5206 | $update_main_doc_field=0; |
| 4834 | - if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1; |
|
| 5207 | + if (! empty($obj->update_main_doc_field)) { |
|
| 5208 | + $update_main_doc_field=1; |
|
| 5209 | + } |
|
| 4835 | 5210 | if ($update_main_doc_field && ! empty($this->table_element)) |
| 4836 | 5211 | { |
| 4837 | 5212 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; |
@@ -4845,8 +5220,7 @@ discard block |
||
| 4845 | 5220 | } |
| 4846 | 5221 | } |
| 4847 | 5222 | } |
| 4848 | - } |
|
| 4849 | - else |
|
| 5223 | + } else |
|
| 4850 | 5224 | { |
| 4851 | 5225 | dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING); |
| 4852 | 5226 | } |
@@ -4855,22 +5229,21 @@ discard block |
||
| 4855 | 5229 | dol_meta_create($this); |
| 4856 | 5230 | |
| 4857 | 5231 | return 1; |
| 4858 | - } |
|
| 4859 | - else |
|
| 5232 | + } else |
|
| 4860 | 5233 | { |
| 4861 | 5234 | $outputlangs->charset_output=$sav_charset_output; |
| 4862 | 5235 | dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); |
| 4863 | 5236 | return -1; |
| 4864 | 5237 | } |
| 4865 | - } |
|
| 4866 | - else |
|
| 5238 | + } else |
|
| 4867 | 5239 | { |
| 4868 | 5240 | $this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file); |
| 4869 | 5241 | dol_print_error('', $this->error); |
| 4870 | 5242 | return -1; |
| 4871 | 5243 | } |
| 5244 | + } else { |
|
| 5245 | + return $reshook; |
|
| 4872 | 5246 | } |
| 4873 | - else return $reshook; |
|
| 4874 | 5247 | } |
| 4875 | 5248 | |
| 4876 | 5249 | /** |
@@ -4921,13 +5294,21 @@ discard block |
||
| 4921 | 5294 | global $conf, $_POST; |
| 4922 | 5295 | |
| 4923 | 5296 | // If param here has been posted, we use this value first. |
| 4924 | - if (isset($_POST[$fieldname])) return GETPOST($fieldname, 2); |
|
| 5297 | + if (isset($_POST[$fieldname])) { |
|
| 5298 | + return GETPOST($fieldname, 2); |
|
| 5299 | + } |
|
| 4925 | 5300 | |
| 4926 | - if (isset($alternatevalue)) return $alternatevalue; |
|
| 5301 | + if (isset($alternatevalue)) { |
|
| 5302 | + return $alternatevalue; |
|
| 5303 | + } |
|
| 4927 | 5304 | |
| 4928 | 5305 | $newelement=$this->element; |
| 4929 | - if ($newelement == 'facture') $newelement='invoice'; |
|
| 4930 | - if ($newelement == 'commande') $newelement='order'; |
|
| 5306 | + if ($newelement == 'facture') { |
|
| 5307 | + $newelement='invoice'; |
|
| 5308 | + } |
|
| 5309 | + if ($newelement == 'commande') { |
|
| 5310 | + $newelement='order'; |
|
| 5311 | + } |
|
| 4931 | 5312 | if (empty($newelement)) |
| 4932 | 5313 | { |
| 4933 | 5314 | dol_syslog("Ask a default value using common method getDefaultCreateValueForField on an object with no property ->element defined. Return empty string.", LOG_WARNING); |
@@ -4936,7 +5317,9 @@ discard block |
||
| 4936 | 5317 | |
| 4937 | 5318 | $keyforfieldname=strtoupper($newelement.'_DEFAULT_'.$fieldname); |
| 4938 | 5319 | //var_dump($keyforfieldname); |
| 4939 | - if (isset($conf->global->$keyforfieldname)) return $conf->global->$keyforfieldname; |
|
| 5320 | + if (isset($conf->global->$keyforfieldname)) { |
|
| 5321 | + return $conf->global->$keyforfieldname; |
|
| 5322 | + } |
|
| 4940 | 5323 | |
| 4941 | 5324 | // TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname |
| 4942 | 5325 | } |
@@ -4975,8 +5358,7 @@ discard block |
||
| 4975 | 5358 | if (!empty($this->errors)) |
| 4976 | 5359 | { |
| 4977 | 5360 | $this->errors=array_unique(array_merge($this->errors, $interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice. |
| 4978 | - } |
|
| 4979 | - else |
|
| 5361 | + } else |
|
| 4980 | 5362 | { |
| 4981 | 5363 | $this->errors=$interface->errors; |
| 4982 | 5364 | } |
@@ -5002,7 +5384,9 @@ discard block |
||
| 5002 | 5384 | // phpcs:enable |
| 5003 | 5385 | global $extrafields; |
| 5004 | 5386 | |
| 5005 | - if (empty($rowid)) $rowid=$this->id; |
|
| 5387 | + if (empty($rowid)) { |
|
| 5388 | + $rowid=$this->id; |
|
| 5389 | + } |
|
| 5006 | 5390 | |
| 5007 | 5391 | // To avoid SQL errors. Probably not the better solution though |
| 5008 | 5392 | if (!$this->table_element) { |
@@ -5026,15 +5410,17 @@ discard block |
||
| 5026 | 5410 | $extrafields->fetch_name_optionals_label($this->table_element); |
| 5027 | 5411 | } |
| 5028 | 5412 | $optionsArray = (! empty($extrafields->attributes[$this->table_element]['label'])?$extrafields->attributes[$this->table_element]['label']:null); |
| 5029 | - } |
|
| 5030 | - else |
|
| 5413 | + } else |
|
| 5031 | 5414 | { |
| 5032 | 5415 | global $extrafields; |
| 5033 | 5416 | dol_syslog("Warning: fetch_optionals was called with param optionsArray defined when you should pass null now", LOG_WARNING); |
| 5034 | 5417 | } |
| 5035 | 5418 | |
| 5036 | 5419 | $table_element = $this->table_element; |
| 5037 | - if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility |
|
| 5420 | + if ($table_element == 'categorie') { |
|
| 5421 | + $table_element = 'categories'; |
|
| 5422 | + } |
|
| 5423 | + // For compatibility |
|
| 5038 | 5424 | |
| 5039 | 5425 | // Request to get complementary values |
| 5040 | 5426 | if (is_array($optionsArray) && count($optionsArray) > 0) |
@@ -5070,8 +5456,7 @@ discard block |
||
| 5070 | 5456 | { |
| 5071 | 5457 | //var_dump($extrafields->attributes[$this->table_element]['type'][$key]); |
| 5072 | 5458 | $this->array_options["options_".$key]=$this->db->jdate($value); |
| 5073 | - } |
|
| 5074 | - else |
|
| 5459 | + } else |
|
| 5075 | 5460 | { |
| 5076 | 5461 | $this->array_options["options_".$key]=$value; |
| 5077 | 5462 | } |
@@ -5091,10 +5476,12 @@ discard block |
||
| 5091 | 5476 | |
| 5092 | 5477 | $this->db->free($resql); |
| 5093 | 5478 | |
| 5094 | - if ($numrows) return $numrows; |
|
| 5095 | - else return 0; |
|
| 5096 | - } |
|
| 5097 | - else |
|
| 5479 | + if ($numrows) { |
|
| 5480 | + return $numrows; |
|
| 5481 | + } else { |
|
| 5482 | + return 0; |
|
| 5483 | + } |
|
| 5484 | + } else |
|
| 5098 | 5485 | { |
| 5099 | 5486 | dol_print_error($this->db); |
| 5100 | 5487 | return -1; |
@@ -5113,7 +5500,10 @@ discard block |
||
| 5113 | 5500 | $this->db->begin(); |
| 5114 | 5501 | |
| 5115 | 5502 | $table_element = $this->table_element; |
| 5116 | - if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility |
|
| 5503 | + if ($table_element == 'categorie') { |
|
| 5504 | + $table_element = 'categories'; |
|
| 5505 | + } |
|
| 5506 | + // For compatibility |
|
| 5117 | 5507 | |
| 5118 | 5508 | $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id; |
| 5119 | 5509 | dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG); |
@@ -5123,8 +5513,7 @@ discard block |
||
| 5123 | 5513 | $this->error=$this->db->lasterror(); |
| 5124 | 5514 | $this->db->rollback(); |
| 5125 | 5515 | return -1; |
| 5126 | - } |
|
| 5127 | - else |
|
| 5516 | + } else |
|
| 5128 | 5517 | { |
| 5129 | 5518 | $this->db->commit(); |
| 5130 | 5519 | return 1; |
@@ -5145,11 +5534,16 @@ discard block |
||
| 5145 | 5534 | { |
| 5146 | 5535 | global $conf,$langs,$user; |
| 5147 | 5536 | |
| 5148 | - if (empty($userused)) $userused=$user; |
|
| 5537 | + if (empty($userused)) { |
|
| 5538 | + $userused=$user; |
|
| 5539 | + } |
|
| 5149 | 5540 | |
| 5150 | 5541 | $error=0; |
| 5151 | 5542 | |
| 5152 | - if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used |
|
| 5543 | + if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 5544 | + return 0; |
|
| 5545 | + } |
|
| 5546 | + // For avoid conflicts if trigger used |
|
| 5153 | 5547 | |
| 5154 | 5548 | if (! empty($this->array_options)) |
| 5155 | 5549 | { |
@@ -5162,10 +5556,13 @@ discard block |
||
| 5162 | 5556 | //Eliminate copied source object extra_fields that do not exist in target object |
| 5163 | 5557 | $new_array_options=array(); |
| 5164 | 5558 | foreach ($this->array_options as $key => $value) { |
| 5165 | - if (in_array(substr($key, 8), array_keys($target_extrafields))) // We remove the 'options_' from $key for test |
|
| 5559 | + if (in_array(substr($key, 8), array_keys($target_extrafields))) { |
|
| 5560 | + // We remove the 'options_' from $key for test |
|
| 5166 | 5561 | $new_array_options[$key] = $value; |
| 5167 | - elseif (in_array($key, array_keys($target_extrafields))) // We test on $key that does not contains the 'options_' prefix |
|
| 5562 | + } elseif (in_array($key, array_keys($target_extrafields))) { |
|
| 5563 | + // We test on $key that does not contains the 'options_' prefix |
|
| 5168 | 5564 | $new_array_options['options_'.$key] = $value; |
| 5565 | + } |
|
| 5169 | 5566 | } |
| 5170 | 5567 | |
| 5171 | 5568 | foreach($new_array_options as $key => $value) |
@@ -5181,8 +5578,12 @@ discard block |
||
| 5181 | 5578 | if ($attributeRequired) |
| 5182 | 5579 | { |
| 5183 | 5580 | $mandatorypb=false; |
| 5184 | - if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb=true; |
|
| 5185 | - if ($this->array_options[$key] === '') $mandatorypb=true; |
|
| 5581 | + if ($attributeType == 'link' && $this->array_options[$key] == '-1') { |
|
| 5582 | + $mandatorypb=true; |
|
| 5583 | + } |
|
| 5584 | + if ($this->array_options[$key] === '') { |
|
| 5585 | + $mandatorypb=true; |
|
| 5586 | + } |
|
| 5186 | 5587 | if ($mandatorypb) |
| 5187 | 5588 | { |
| 5188 | 5589 | dol_syslog("Mandatory extra field ".$key." is empty"); |
@@ -5201,8 +5602,7 @@ discard block |
||
| 5201 | 5602 | $value = dol_eval($attrfieldcomputed, 1, 0); |
| 5202 | 5603 | dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG); |
| 5203 | 5604 | $new_array_options[$key] = $value; |
| 5204 | - } |
|
| 5205 | - else |
|
| 5605 | + } else |
|
| 5206 | 5606 | { |
| 5207 | 5607 | $new_array_options[$key] = null; |
| 5208 | 5608 | } |
@@ -5216,8 +5616,7 @@ discard block |
||
| 5216 | 5616 | { |
| 5217 | 5617 | $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel); |
| 5218 | 5618 | return -1; |
| 5219 | - } |
|
| 5220 | - elseif ($value=='') |
|
| 5619 | + } elseif ($value=='') |
|
| 5221 | 5620 | { |
| 5222 | 5621 | $new_array_options[$key] = null; |
| 5223 | 5622 | } |
@@ -5229,8 +5628,7 @@ discard block |
||
| 5229 | 5628 | dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG); |
| 5230 | 5629 | $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel); |
| 5231 | 5630 | return -1; |
| 5232 | - } |
|
| 5233 | - elseif ($value=='') |
|
| 5631 | + } elseif ($value=='') |
|
| 5234 | 5632 | { |
| 5235 | 5633 | $new_array_options[$key] = null; |
| 5236 | 5634 | } |
@@ -5255,27 +5653,27 @@ discard block |
||
| 5255 | 5653 | //global $action; // $action may be 'create', 'update', 'update_extras'... |
| 5256 | 5654 | //var_dump($action); |
| 5257 | 5655 | //var_dump($this->oldcopy);exit; |
| 5258 | - if (is_object($this->oldcopy)) // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value |
|
| 5656 | + if (is_object($this->oldcopy)) { |
|
| 5657 | + // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value |
|
| 5259 | 5658 | { |
| 5260 | 5659 | //var_dump($this->oldcopy->array_options[$key]); var_dump($this->array_options[$key]); |
| 5261 | 5660 | if ($this->array_options[$key] == $this->oldcopy->array_options[$key]) // If old value crypted in database is same than submited new value, it means we don't change it, so we don't update. |
| 5262 | 5661 | { |
| 5263 | - $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
|
| 5264 | - } |
|
| 5265 | - else |
|
| 5662 | + $new_array_options[$key] = $this->array_options[$key]; |
|
| 5663 | + } |
|
| 5664 | + // Value is kept |
|
| 5665 | + } else |
|
| 5266 | 5666 | { |
| 5267 | 5667 | // var_dump($algo); |
| 5268 | 5668 | $newvalue = dol_hash($this->array_options[$key], $algo); |
| 5269 | 5669 | $new_array_options[$key] = $newvalue; |
| 5270 | 5670 | } |
| 5271 | - } |
|
| 5272 | - else |
|
| 5671 | + } else |
|
| 5273 | 5672 | { |
| 5274 | 5673 | $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
| 5275 | 5674 | } |
| 5276 | 5675 | } |
| 5277 | - } |
|
| 5278 | - else // Common usage |
|
| 5676 | + } else // Common usage |
|
| 5279 | 5677 | { |
| 5280 | 5678 | $new_array_options[$key] = $this->array_options[$key]; |
| 5281 | 5679 | } |
@@ -5299,26 +5697,30 @@ discard block |
||
| 5299 | 5697 | dol_include_once($InfoFieldList[1]); |
| 5300 | 5698 | if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) |
| 5301 | 5699 | { |
| 5302 | - if ($value == '-1') // -1 is key for no defined in combo list of objects |
|
| 5700 | + if ($value == '-1') { |
|
| 5701 | + // -1 is key for no defined in combo list of objects |
|
| 5303 | 5702 | { |
| 5304 | 5703 | $new_array_options[$key]=''; |
| 5305 | 5704 | } |
| 5306 | - elseif ($value) |
|
| 5705 | + } elseif ($value) |
|
| 5307 | 5706 | { |
| 5308 | 5707 | $object = new $InfoFieldList[0]($this->db); |
| 5309 | - if (is_numeric($value)) $res=$object->fetch($value); |
|
| 5310 | - else $res=$object->fetch('', $value); |
|
| 5708 | + if (is_numeric($value)) { |
|
| 5709 | + $res=$object->fetch($value); |
|
| 5710 | + } else { |
|
| 5711 | + $res=$object->fetch('', $value); |
|
| 5712 | + } |
|
| 5311 | 5713 | |
| 5312 | - if ($res > 0) $new_array_options[$key]=$object->id; |
|
| 5313 | - else |
|
| 5714 | + if ($res > 0) { |
|
| 5715 | + $new_array_options[$key]=$object->id; |
|
| 5716 | + } else |
|
| 5314 | 5717 | { |
| 5315 | 5718 | $this->error="Id/Ref '".$value."' for object '".$object->element."' not found"; |
| 5316 | 5719 | $this->db->rollback(); |
| 5317 | 5720 | return -1; |
| 5318 | 5721 | } |
| 5319 | 5722 | } |
| 5320 | - } |
|
| 5321 | - else |
|
| 5723 | + } else |
|
| 5322 | 5724 | { |
| 5323 | 5725 | dol_syslog('Error bad setup of extrafield', LOG_WARNING); |
| 5324 | 5726 | } |
@@ -5329,7 +5731,10 @@ discard block |
||
| 5329 | 5731 | $this->db->begin(); |
| 5330 | 5732 | |
| 5331 | 5733 | $table_element = $this->table_element; |
| 5332 | - if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility |
|
| 5734 | + if ($table_element == 'categorie') { |
|
| 5735 | + $table_element = 'categories'; |
|
| 5736 | + } |
|
| 5737 | + // For compatibility |
|
| 5333 | 5738 | |
| 5334 | 5739 | dol_syslog(get_class($this)."::insertExtraFields delete then insert", LOG_DEBUG); |
| 5335 | 5740 | |
@@ -5341,18 +5746,22 @@ discard block |
||
| 5341 | 5746 | { |
| 5342 | 5747 | $attributeKey = substr($key, 8); // Remove 'options_' prefix |
| 5343 | 5748 | // Add field of attribut |
| 5344 | - if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator |
|
| 5749 | + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') { |
|
| 5750 | + // Only for other type than separator |
|
| 5345 | 5751 | $sql.=",".$attributeKey; |
| 5752 | + } |
|
| 5346 | 5753 | } |
| 5347 | 5754 | // We must insert a default value for fields for other entities that are mandatory to avoid not null error |
| 5348 | 5755 | if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) |
| 5349 | 5756 | { |
| 5350 | 5757 | foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) |
| 5351 | 5758 | { |
| 5352 | - if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously |
|
| 5759 | + if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) { |
|
| 5760 | + // If field not already added previously |
|
| 5353 | 5761 | { |
| 5354 | 5762 | $sql.=",".$tmpkey; |
| 5355 | 5763 | } |
| 5764 | + } |
|
| 5356 | 5765 | } |
| 5357 | 5766 | } |
| 5358 | 5767 | $sql .= ") VALUES (".$this->id; |
@@ -5361,13 +5770,14 @@ discard block |
||
| 5361 | 5770 | { |
| 5362 | 5771 | $attributeKey = substr($key, 8); // Remove 'options_' prefix |
| 5363 | 5772 | // Add field of attribute |
| 5364 | - if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator) |
|
| 5773 | + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') { |
|
| 5774 | + // Only for other type than separator) |
|
| 5365 | 5775 | { |
| 5366 | 5776 | if ($new_array_options[$key] != '') |
| 5367 | 5777 | { |
| 5368 | 5778 | $sql.=",'".$this->db->escape($new_array_options[$key])."'"; |
| 5369 | - } |
|
| 5370 | - else |
|
| 5779 | + } |
|
| 5780 | + } else |
|
| 5371 | 5781 | { |
| 5372 | 5782 | $sql.=",null"; |
| 5373 | 5783 | } |
@@ -5378,10 +5788,13 @@ discard block |
||
| 5378 | 5788 | { |
| 5379 | 5789 | foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) |
| 5380 | 5790 | { |
| 5381 | - if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously |
|
| 5791 | + if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) { |
|
| 5792 | + // If field not already added previously |
|
| 5382 | 5793 | { |
| 5383 | 5794 | if (in_array($tmpval, array('int', 'double'))) $sql.=", 0"; |
| 5384 | - else $sql.=", ''"; |
|
| 5795 | + } else { |
|
| 5796 | + $sql.=", ''"; |
|
| 5797 | + } |
|
| 5385 | 5798 | } |
| 5386 | 5799 | } |
| 5387 | 5800 | } |
@@ -5401,7 +5814,9 @@ discard block |
||
| 5401 | 5814 | // Call trigger |
| 5402 | 5815 | $this->context=array('extrafieldaddupdate'=>1); |
| 5403 | 5816 | $result=$this->call_trigger($trigger, $userused); |
| 5404 | - if ($result < 0) $error++; |
|
| 5817 | + if ($result < 0) { |
|
| 5818 | + $error++; |
|
| 5819 | + } |
|
| 5405 | 5820 | // End call trigger |
| 5406 | 5821 | } |
| 5407 | 5822 | |
@@ -5409,14 +5824,14 @@ discard block |
||
| 5409 | 5824 | { |
| 5410 | 5825 | $this->db->rollback(); |
| 5411 | 5826 | return -1; |
| 5412 | - } |
|
| 5413 | - else |
|
| 5827 | + } else |
|
| 5414 | 5828 | { |
| 5415 | 5829 | $this->db->commit(); |
| 5416 | 5830 | return 1; |
| 5417 | 5831 | } |
| 5832 | + } else { |
|
| 5833 | + return 0; |
|
| 5418 | 5834 | } |
| 5419 | - else return 0; |
|
| 5420 | 5835 | } |
| 5421 | 5836 | |
| 5422 | 5837 | /** |
@@ -5433,11 +5848,16 @@ discard block |
||
| 5433 | 5848 | { |
| 5434 | 5849 | global $conf,$langs,$user; |
| 5435 | 5850 | |
| 5436 | - if (empty($userused)) $userused=$user; |
|
| 5851 | + if (empty($userused)) { |
|
| 5852 | + $userused=$user; |
|
| 5853 | + } |
|
| 5437 | 5854 | |
| 5438 | 5855 | $error=0; |
| 5439 | 5856 | |
| 5440 | - if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used |
|
| 5857 | + if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 5858 | + return 0; |
|
| 5859 | + } |
|
| 5860 | + // For avoid conflicts if trigger used |
|
| 5441 | 5861 | |
| 5442 | 5862 | if (! empty($this->array_options) && isset($this->array_options["options_".$key])) |
| 5443 | 5863 | { |
@@ -5464,8 +5884,7 @@ discard block |
||
| 5464 | 5884 | { |
| 5465 | 5885 | $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel); |
| 5466 | 5886 | return -1; |
| 5467 | - } |
|
| 5468 | - elseif ($value=='') |
|
| 5887 | + } elseif ($value=='') |
|
| 5469 | 5888 | { |
| 5470 | 5889 | $this->array_options["options_".$key] = null; |
| 5471 | 5890 | } |
@@ -5477,8 +5896,7 @@ discard block |
||
| 5477 | 5896 | dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG); |
| 5478 | 5897 | $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel); |
| 5479 | 5898 | return -1; |
| 5480 | - } |
|
| 5481 | - elseif ($value=='') |
|
| 5899 | + } elseif ($value=='') |
|
| 5482 | 5900 | { |
| 5483 | 5901 | $this->array_options["options_".$key] = null; |
| 5484 | 5902 | } |
@@ -5530,7 +5948,9 @@ discard block |
||
| 5530 | 5948 | // Call trigger |
| 5531 | 5949 | $this->context=array('extrafieldupdate'=>1); |
| 5532 | 5950 | $result=$this->call_trigger($trigger, $userused); |
| 5533 | - if ($result < 0) $error++; |
|
| 5951 | + if ($result < 0) { |
|
| 5952 | + $error++; |
|
| 5953 | + } |
|
| 5534 | 5954 | // End call trigger |
| 5535 | 5955 | } |
| 5536 | 5956 | |
@@ -5539,14 +5959,14 @@ discard block |
||
| 5539 | 5959 | dol_syslog(get_class($this) . "::".__METHOD__ . $this->error, LOG_ERR); |
| 5540 | 5960 | $this->db->rollback(); |
| 5541 | 5961 | return -1; |
| 5542 | - } |
|
| 5543 | - else |
|
| 5962 | + } else |
|
| 5544 | 5963 | { |
| 5545 | 5964 | $this->db->commit(); |
| 5546 | 5965 | return 1; |
| 5547 | 5966 | } |
| 5967 | + } else { |
|
| 5968 | + return 0; |
|
| 5548 | 5969 | } |
| 5549 | - else return 0; |
|
| 5550 | 5970 | } |
| 5551 | 5971 | |
| 5552 | 5972 | |
@@ -5625,8 +6045,11 @@ discard block |
||
| 5625 | 6045 | |
| 5626 | 6046 | if ($computed) |
| 5627 | 6047 | { |
| 5628 | - if (! preg_match('/^search_/', $keyprefix)) return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>'; |
|
| 5629 | - else return ''; |
|
| 6048 | + if (! preg_match('/^search_/', $keyprefix)) { |
|
| 6049 | + return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>'; |
|
| 6050 | + } else { |
|
| 6051 | + return ''; |
|
| 6052 | + } |
|
| 5630 | 6053 | } |
| 5631 | 6054 | |
| 5632 | 6055 | |
@@ -5634,38 +6057,31 @@ discard block |
||
| 5634 | 6057 | if (empty($morecss) && ! empty($val['css'])) |
| 5635 | 6058 | { |
| 5636 | 6059 | $morecss = $val['css']; |
| 5637 | - } |
|
| 5638 | - elseif (empty($morecss)) |
|
| 6060 | + } elseif (empty($morecss)) |
|
| 5639 | 6061 | { |
| 5640 | 6062 | if ($type == 'date') |
| 5641 | 6063 | { |
| 5642 | 6064 | $morecss = 'minwidth100imp'; |
| 5643 | - } |
|
| 5644 | - elseif ($type == 'datetime' || $type == 'link') |
|
| 6065 | + } elseif ($type == 'datetime' || $type == 'link') |
|
| 5645 | 6066 | { |
| 5646 | 6067 | $morecss = 'minwidth200imp'; |
| 5647 | - } |
|
| 5648 | - elseif (in_array($type, array('int','integer','price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type)) |
|
| 6068 | + } elseif (in_array($type, array('int','integer','price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type)) |
|
| 5649 | 6069 | { |
| 5650 | 6070 | $morecss = 'maxwidth75'; |
| 5651 | 6071 | } elseif ($type == 'url') { |
| 5652 | 6072 | $morecss='minwidth400'; |
| 5653 | - } |
|
| 5654 | - elseif ($type == 'boolean') |
|
| 6073 | + } elseif ($type == 'boolean') |
|
| 5655 | 6074 | { |
| 5656 | 6075 | $morecss=''; |
| 5657 | - } |
|
| 5658 | - else |
|
| 6076 | + } else |
|
| 5659 | 6077 | { |
| 5660 | 6078 | if (round($size) < 12) |
| 5661 | 6079 | { |
| 5662 | 6080 | $morecss = 'minwidth100'; |
| 5663 | - } |
|
| 5664 | - elseif (round($size) <= 48) |
|
| 6081 | + } elseif (round($size) <= 48) |
|
| 5665 | 6082 | { |
| 5666 | 6083 | $morecss = 'minwidth200'; |
| 5667 | - } |
|
| 5668 | - else |
|
| 6084 | + } else |
|
| 5669 | 6085 | { |
| 5670 | 6086 | $morecss = 'minwidth400'; |
| 5671 | 6087 | } |
@@ -5680,56 +6096,53 @@ discard block |
||
| 5680 | 6096 | $showtime = in_array($type, array('datetime')) ? 1 : 0; |
| 5681 | 6097 | |
| 5682 | 6098 | // Do not show current date when field not required (see selectDate() method) |
| 5683 | - if (!$required && $value == '') $value = '-1'; |
|
| 6099 | + if (!$required && $value == '') { |
|
| 6100 | + $value = '-1'; |
|
| 6101 | + } |
|
| 5684 | 6102 | |
| 5685 | 6103 | // TODO Must also support $moreparam |
| 5686 | 6104 | $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); |
| 5687 | - } |
|
| 5688 | - elseif (in_array($type, array('int','integer'))) |
|
| 6105 | + } elseif (in_array($type, array('int','integer'))) |
|
| 5689 | 6106 | { |
| 5690 | 6107 | $tmp=explode(',', $size); |
| 5691 | 6108 | $newsize=$tmp[0]; |
| 5692 | 6109 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>'; |
| 5693 | - } |
|
| 5694 | - elseif (in_array($type, array('real'))) |
|
| 6110 | + } elseif (in_array($type, array('real'))) |
|
| 5695 | 6111 | { |
| 5696 | 6112 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>'; |
| 5697 | - } |
|
| 5698 | - elseif (preg_match('/varchar/', $type)) |
|
| 6113 | + } elseif (preg_match('/varchar/', $type)) |
|
| 5699 | 6114 | { |
| 5700 | 6115 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>'; |
| 5701 | - } |
|
| 5702 | - elseif (in_array($type, array('mail', 'phone', 'url'))) |
|
| 6116 | + } elseif (in_array($type, array('mail', 'phone', 'url'))) |
|
| 5703 | 6117 | { |
| 5704 | 6118 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>'; |
| 5705 | - } |
|
| 5706 | - elseif ($type == 'text') |
|
| 6119 | + } elseif ($type == 'text') |
|
| 5707 | 6120 | { |
| 5708 | - if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 6121 | + if (! preg_match('/search_/', $keyprefix)) { |
|
| 6122 | + // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 5709 | 6123 | { |
| 5710 | 6124 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 6125 | + } |
|
| 5711 | 6126 | $doleditor=new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); |
| 5712 | 6127 | $out=$doleditor->Create(1); |
| 5713 | - } |
|
| 5714 | - else |
|
| 6128 | + } else |
|
| 5715 | 6129 | { |
| 5716 | 6130 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>'; |
| 5717 | 6131 | } |
| 5718 | - } |
|
| 5719 | - elseif ($type == 'html') |
|
| 6132 | + } elseif ($type == 'html') |
|
| 5720 | 6133 | { |
| 5721 | - if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 6134 | + if (! preg_match('/search_/', $keyprefix)) { |
|
| 6135 | + // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 5722 | 6136 | { |
| 5723 | 6137 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 6138 | + } |
|
| 5724 | 6139 | $doleditor=new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, ! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); |
| 5725 | 6140 | $out=$doleditor->Create(1); |
| 5726 | - } |
|
| 5727 | - else |
|
| 6141 | + } else |
|
| 5728 | 6142 | { |
| 5729 | 6143 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>'; |
| 5730 | 6144 | } |
| 5731 | - } |
|
| 5732 | - elseif ($type == 'boolean') |
|
| 6145 | + } elseif ($type == 'boolean') |
|
| 5733 | 6146 | { |
| 5734 | 6147 | $checked=''; |
| 5735 | 6148 | if (!empty($value)) { |
@@ -5738,22 +6151,19 @@ discard block |
||
| 5738 | 6151 | $checked=' value="1" '; |
| 5739 | 6152 | } |
| 5740 | 6153 | $out='<input type="checkbox" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam?$moreparam:'').'>'; |
| 5741 | - } |
|
| 5742 | - elseif ($type == 'price') |
|
| 6154 | + } elseif ($type == 'price') |
|
| 5743 | 6155 | { |
| 5744 | 6156 | if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. |
| 5745 | 6157 | $value=price($value); |
| 5746 | 6158 | } |
| 5747 | 6159 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency); |
| 5748 | - } |
|
| 5749 | - elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type)) |
|
| 6160 | + } elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type)) |
|
| 5750 | 6161 | { |
| 5751 | 6162 | if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. |
| 5752 | 6163 | $value=price($value); |
| 5753 | 6164 | } |
| 5754 | 6165 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '; |
| 5755 | - } |
|
| 5756 | - elseif ($type == 'select') |
|
| 6166 | + } elseif ($type == 'select') |
|
| 5757 | 6167 | { |
| 5758 | 6168 | $out = ''; |
| 5759 | 6169 | if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) |
@@ -5763,10 +6173,14 @@ discard block |
||
| 5763 | 6173 | } |
| 5764 | 6174 | |
| 5765 | 6175 | $out.='<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>'; |
| 5766 | - if((! isset($this->fields[$key]['default'])) ||($this->fields[$key]['notnull']!=1))$out.='<option value="0"> </option>'; |
|
| 6176 | + if((! isset($this->fields[$key]['default'])) ||($this->fields[$key]['notnull']!=1)) { |
|
| 6177 | + $out.='<option value="0"> </option>'; |
|
| 6178 | + } |
|
| 5767 | 6179 | foreach ($param['options'] as $key => $val) |
| 5768 | 6180 | { |
| 5769 | - if ((string) $key == '') continue; |
|
| 6181 | + if ((string) $key == '') { |
|
| 6182 | + continue; |
|
| 6183 | + } |
|
| 5770 | 6184 | list($val, $parent) = explode('|', $val); |
| 5771 | 6185 | $out.='<option value="'.$key.'"'; |
| 5772 | 6186 | $out.= (((string) $value == (string) $key)?' selected':''); |
@@ -5774,8 +6188,7 @@ discard block |
||
| 5774 | 6188 | $out.='>'.$val.'</option>'; |
| 5775 | 6189 | } |
| 5776 | 6190 | $out.='</select>'; |
| 5777 | - } |
|
| 5778 | - elseif ($type == 'sellist') |
|
| 6191 | + } elseif ($type == 'sellist') |
|
| 5779 | 6192 | { |
| 5780 | 6193 | $out = ''; |
| 5781 | 6194 | if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) |
@@ -5842,13 +6255,11 @@ discard block |
||
| 5842 | 6255 | { |
| 5843 | 6256 | $sql.= ' as main, '.MAIN_DB_PREFIX .$InfoFieldList[0].'_extrafields as extra'; |
| 5844 | 6257 | $sqlwhere.= ' WHERE extra.fk_object=main.'.$InfoFieldList[2]. ' AND '.$InfoFieldList[4]; |
| 5845 | - } |
|
| 5846 | - else |
|
| 6258 | + } else |
|
| 5847 | 6259 | { |
| 5848 | 6260 | $sqlwhere.= ' WHERE '.$InfoFieldList[4]; |
| 5849 | 6261 | } |
| 5850 | - } |
|
| 5851 | - else |
|
| 6262 | + } else |
|
| 5852 | 6263 | { |
| 5853 | 6264 | $sqlwhere.= ' WHERE 1=1'; |
| 5854 | 6265 | } |
@@ -5884,8 +6295,7 @@ discard block |
||
| 5884 | 6295 | { |
| 5885 | 6296 | $labeltoshow.= $obj->$field_toshow.' '; |
| 5886 | 6297 | } |
| 5887 | - } |
|
| 5888 | - else |
|
| 6298 | + } else |
|
| 5889 | 6299 | { |
| 5890 | 6300 | $labeltoshow=$obj->{$InfoFieldList[1]}; |
| 5891 | 6301 | } |
@@ -5898,25 +6308,25 @@ discard block |
||
| 5898 | 6308 | $translabel=$langs->trans($obj->$field_toshow); |
| 5899 | 6309 | if ($translabel!=$obj->$field_toshow) { |
| 5900 | 6310 | $labeltoshow=dol_trunc($translabel, 18).' '; |
| 5901 | - }else { |
|
| 6311 | + } else { |
|
| 5902 | 6312 | $labeltoshow=dol_trunc($obj->$field_toshow, 18).' '; |
| 5903 | 6313 | } |
| 5904 | 6314 | } |
| 5905 | 6315 | $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
| 5906 | - } |
|
| 5907 | - else |
|
| 6316 | + } else |
|
| 5908 | 6317 | { |
| 5909 | 6318 | if (! $notrans) |
| 5910 | 6319 | { |
| 5911 | 6320 | $translabel=$langs->trans($obj->{$InfoFieldList[1]}); |
| 5912 | 6321 | if ($translabel!=$obj->{$InfoFieldList[1]}) { |
| 5913 | 6322 | $labeltoshow=dol_trunc($translabel, 18); |
| 5914 | - } |
|
| 5915 | - else { |
|
| 6323 | + } else { |
|
| 5916 | 6324 | $labeltoshow=dol_trunc($obj->{$InfoFieldList[1]}, 18); |
| 5917 | 6325 | } |
| 5918 | 6326 | } |
| 5919 | - if (empty($labeltoshow)) $labeltoshow='(not defined)'; |
|
| 6327 | + if (empty($labeltoshow)) { |
|
| 6328 | + $labeltoshow='(not defined)'; |
|
| 6329 | + } |
|
| 5920 | 6330 | if ($value==$obj->rowid) |
| 5921 | 6331 | { |
| 5922 | 6332 | $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
@@ -5936,19 +6346,16 @@ discard block |
||
| 5936 | 6346 | $i++; |
| 5937 | 6347 | } |
| 5938 | 6348 | $this->db->free($resql); |
| 5939 | - } |
|
| 5940 | - else { |
|
| 6349 | + } else { |
|
| 5941 | 6350 | print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>'; |
| 5942 | 6351 | } |
| 5943 | 6352 | } |
| 5944 | 6353 | $out.='</select>'; |
| 5945 | - } |
|
| 5946 | - elseif ($type == 'checkbox') |
|
| 6354 | + } elseif ($type == 'checkbox') |
|
| 5947 | 6355 | { |
| 5948 | 6356 | $value_arr=explode(',', $value); |
| 5949 | 6357 | $out=$form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); |
| 5950 | - } |
|
| 5951 | - elseif ($type == 'radio') |
|
| 6358 | + } elseif ($type == 'radio') |
|
| 5952 | 6359 | { |
| 5953 | 6360 | $out=''; |
| 5954 | 6361 | foreach ($param['options'] as $keyopt => $val) |
@@ -5959,13 +6366,11 @@ discard block |
||
| 5959 | 6366 | $out.= ($value==$keyopt?'checked':''); |
| 5960 | 6367 | $out.='/><label for="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'">'.$val.'</label><br>'; |
| 5961 | 6368 | } |
| 5962 | - } |
|
| 5963 | - elseif ($type == 'chkbxlst') |
|
| 6369 | + } elseif ($type == 'chkbxlst') |
|
| 5964 | 6370 | { |
| 5965 | 6371 | if (is_array($value)) { |
| 5966 | 6372 | $value_arr = $value; |
| 5967 | - } |
|
| 5968 | - else { |
|
| 6373 | + } else { |
|
| 5969 | 6374 | $value_arr = explode(',', $value); |
| 5970 | 6375 | } |
| 5971 | 6376 | |
@@ -6103,8 +6508,7 @@ discard block |
||
| 6103 | 6508 | print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>'; |
| 6104 | 6509 | } |
| 6105 | 6510 | } |
| 6106 | - } |
|
| 6107 | - elseif ($type == 'link') |
|
| 6511 | + } elseif ($type == 'link') |
|
| 6108 | 6512 | { |
| 6109 | 6513 | $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]' |
| 6110 | 6514 | $param_list_array = explode(':', $param_list[0]); |
@@ -6112,13 +6516,18 @@ discard block |
||
| 6112 | 6516 | |
| 6113 | 6517 | $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, '', 0, empty($val['disabled'])?0:1); |
| 6114 | 6518 | |
| 6115 | - if (! empty($param_list_array[2])) // If we set to add a create button |
|
| 6519 | + if (! empty($param_list_array[2])) { |
|
| 6520 | + // If we set to add a create button |
|
| 6116 | 6521 | { |
| 6117 | 6522 | if (! GETPOSTISSET('backtopage') && empty($val['disabled'])) // To avoid to open several infinitely the 'Create Object' button and to avoid to have button if field is protected by a "disabled". |
| 6118 | 6523 | { |
| 6119 | 6524 | list($class,$classfile)=explode(':', $param_list[0]); |
| 6120 | - if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); |
|
| 6121 | - else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1); |
|
| 6525 | + } |
|
| 6526 | + if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) { |
|
| 6527 | + $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); |
|
| 6528 | + } else { |
|
| 6529 | + $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1); |
|
| 6530 | + } |
|
| 6122 | 6531 | $paramforthenewlink = ''; |
| 6123 | 6532 | $paramforthenewlink .= (GETPOSTISSET('action')?'&action='.GETPOST('action', 'aZ09'):''); |
| 6124 | 6533 | $paramforthenewlink .= (GETPOSTISSET('id')?'&id='.GETPOST('id', 'int'):''); |
@@ -6127,13 +6536,11 @@ discard block |
||
| 6127 | 6536 | $out.='<a class="butActionNew" title="'.$langs->trans("New").'" href="'.$url_path.'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].($paramforthenewlink ? '?'.$paramforthenewlink : '')).'"><span class="fa fa-plus-circle valignmiddle"></span></a>'; |
| 6128 | 6537 | } |
| 6129 | 6538 | } |
| 6130 | - } |
|
| 6131 | - elseif ($type == 'password') |
|
| 6539 | + } elseif ($type == 'password') |
|
| 6132 | 6540 | { |
| 6133 | 6541 | // If prefix is 'search_', field is used as a filter, we use a common text field. |
| 6134 | 6542 | $out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>'; |
| 6135 | - } |
|
| 6136 | - elseif ($type == 'array') |
|
| 6543 | + } elseif ($type == 'array') |
|
| 6137 | 6544 | { |
| 6138 | 6545 | $newval = $val; |
| 6139 | 6546 | $newval['type'] = 'varchar(256)'; |
@@ -6212,10 +6619,16 @@ discard block |
||
| 6212 | 6619 | { |
| 6213 | 6620 | $type = 'varchar'; // convert varchar(xx) int varchar |
| 6214 | 6621 | $size = $reg[1]; |
| 6622 | + } elseif (preg_match('/varchar/', $type)) { |
|
| 6623 | + $type = 'varchar'; |
|
| 6624 | + } |
|
| 6625 | + // convert varchar(xx) int varchar |
|
| 6626 | + if (is_array($val['arrayofkeyval'])) { |
|
| 6627 | + $type='select'; |
|
| 6628 | + } |
|
| 6629 | + if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { |
|
| 6630 | + $type='link'; |
|
| 6215 | 6631 | } |
| 6216 | - elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar |
|
| 6217 | - if (is_array($val['arrayofkeyval'])) $type='select'; |
|
| 6218 | - if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type='link'; |
|
| 6219 | 6632 | |
| 6220 | 6633 | $default=$val['default']; |
| 6221 | 6634 | $computed=$val['computed']; |
@@ -6224,13 +6637,14 @@ discard block |
||
| 6224 | 6637 | $param=array(); |
| 6225 | 6638 | $param['options']=array(); |
| 6226 | 6639 | |
| 6227 | - if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; |
|
| 6640 | + if (is_array($val['arrayofkeyval'])) { |
|
| 6641 | + $param['options'] = $val['arrayofkeyval']; |
|
| 6642 | + } |
|
| 6228 | 6643 | if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) |
| 6229 | 6644 | { |
| 6230 | 6645 | $type='link'; |
| 6231 | 6646 | $param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]); |
| 6232 | - } |
|
| 6233 | - elseif(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { |
|
| 6647 | + } elseif(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { |
|
| 6234 | 6648 | $param['options'] = array($reg[1] . ':' . $reg[2] . ':' . $reg[3] . ':' . $reg[4] => 'N'); |
| 6235 | 6649 | $type = 'sellist'; |
| 6236 | 6650 | } |
@@ -6241,7 +6655,9 @@ discard block |
||
| 6241 | 6655 | $help=$val['help']; |
| 6242 | 6656 | $hidden=(($val['visible'] == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) |
| 6243 | 6657 | |
| 6244 | - if ($hidden) return ''; |
|
| 6658 | + if ($hidden) { |
|
| 6659 | + return ''; |
|
| 6660 | + } |
|
| 6245 | 6661 | |
| 6246 | 6662 | // If field is a computed field, value must become result of compute |
| 6247 | 6663 | if ($computed) |
@@ -6256,34 +6672,27 @@ discard block |
||
| 6256 | 6672 | if ($type == 'date') |
| 6257 | 6673 | { |
| 6258 | 6674 | $morecss = 'minwidth100imp'; |
| 6259 | - } |
|
| 6260 | - elseif ($type == 'datetime' || $type == 'timestamp') |
|
| 6675 | + } elseif ($type == 'datetime' || $type == 'timestamp') |
|
| 6261 | 6676 | { |
| 6262 | 6677 | $morecss = 'minwidth200imp'; |
| 6263 | - } |
|
| 6264 | - elseif (in_array($type, array('int','double','price'))) |
|
| 6678 | + } elseif (in_array($type, array('int','double','price'))) |
|
| 6265 | 6679 | { |
| 6266 | 6680 | $morecss = 'maxwidth75'; |
| 6267 | - } |
|
| 6268 | - elseif ($type == 'url') |
|
| 6681 | + } elseif ($type == 'url') |
|
| 6269 | 6682 | { |
| 6270 | 6683 | $morecss='minwidth400'; |
| 6271 | - } |
|
| 6272 | - elseif ($type == 'boolean') |
|
| 6684 | + } elseif ($type == 'boolean') |
|
| 6273 | 6685 | { |
| 6274 | 6686 | $morecss=''; |
| 6275 | - } |
|
| 6276 | - else |
|
| 6687 | + } else |
|
| 6277 | 6688 | { |
| 6278 | 6689 | if (round($size) < 12) |
| 6279 | 6690 | { |
| 6280 | 6691 | $morecss = 'minwidth100'; |
| 6281 | - } |
|
| 6282 | - elseif (round($size) <= 48) |
|
| 6692 | + } elseif (round($size) <= 48) |
|
| 6283 | 6693 | { |
| 6284 | 6694 | $morecss = 'minwidth200'; |
| 6285 | - } |
|
| 6286 | - else |
|
| 6695 | + } else |
|
| 6287 | 6696 | { |
| 6288 | 6697 | $morecss = 'minwidth400'; |
| 6289 | 6698 | } |
@@ -6291,59 +6700,52 @@ discard block |
||
| 6291 | 6700 | } |
| 6292 | 6701 | |
| 6293 | 6702 | // Format output value differently according to properties of field |
| 6294 | - if ($key == 'ref' && method_exists($this, 'getNomUrl')) $value=$this->getNomUrl(1, '', 0, '', 1); |
|
| 6295 | - elseif ($key == 'status' && method_exists($this, 'getLibStatut')) $value=$this->getLibStatut(3); |
|
| 6296 | - elseif ($type == 'date') |
|
| 6703 | + if ($key == 'ref' && method_exists($this, 'getNomUrl')) { |
|
| 6704 | + $value=$this->getNomUrl(1, '', 0, '', 1); |
|
| 6705 | + } elseif ($key == 'status' && method_exists($this, 'getLibStatut')) { |
|
| 6706 | + $value=$this->getLibStatut(3); |
|
| 6707 | + } elseif ($type == 'date') |
|
| 6297 | 6708 | { |
| 6298 | 6709 | if(! empty($value)) { |
| 6299 | 6710 | $value=dol_print_date($value, 'day'); |
| 6300 | 6711 | } else { |
| 6301 | 6712 | $value=''; |
| 6302 | 6713 | } |
| 6303 | - } |
|
| 6304 | - elseif ($type == 'datetime' || $type == 'timestamp') |
|
| 6714 | + } elseif ($type == 'datetime' || $type == 'timestamp') |
|
| 6305 | 6715 | { |
| 6306 | 6716 | if(! empty($value)) { |
| 6307 | 6717 | $value=dol_print_date($value, 'dayhour'); |
| 6308 | 6718 | } else { |
| 6309 | 6719 | $value=''; |
| 6310 | 6720 | } |
| 6311 | - } |
|
| 6312 | - elseif ($type == 'double' || $type == 'real') |
|
| 6721 | + } elseif ($type == 'double' || $type == 'real') |
|
| 6313 | 6722 | { |
| 6314 | 6723 | if (!empty($value)) { |
| 6315 | 6724 | $value=price($value); |
| 6316 | 6725 | } |
| 6317 | - } |
|
| 6318 | - elseif ($type == 'boolean') |
|
| 6726 | + } elseif ($type == 'boolean') |
|
| 6319 | 6727 | { |
| 6320 | 6728 | $checked=''; |
| 6321 | 6729 | if (!empty($value)) { |
| 6322 | 6730 | $checked=' checked '; |
| 6323 | 6731 | } |
| 6324 | 6732 | $value='<input type="checkbox" '.$checked.' '.($moreparam?$moreparam:'').' readonly disabled>'; |
| 6325 | - } |
|
| 6326 | - elseif ($type == 'mail') |
|
| 6733 | + } elseif ($type == 'mail') |
|
| 6327 | 6734 | { |
| 6328 | 6735 | $value=dol_print_email($value, 0, 0, 0, 64, 1, 1); |
| 6329 | - } |
|
| 6330 | - elseif ($type == 'url') |
|
| 6736 | + } elseif ($type == 'url') |
|
| 6331 | 6737 | { |
| 6332 | 6738 | $value=dol_print_url($value, '_blank', 32, 1); |
| 6333 | - } |
|
| 6334 | - elseif ($type == 'phone') |
|
| 6739 | + } elseif ($type == 'phone') |
|
| 6335 | 6740 | { |
| 6336 | 6741 | $value=dol_print_phone($value, '', 0, 0, '', ' ', 1); |
| 6337 | - } |
|
| 6338 | - elseif ($type == 'price') |
|
| 6742 | + } elseif ($type == 'price') |
|
| 6339 | 6743 | { |
| 6340 | 6744 | $value=price($value, 0, $langs, 0, 0, -1, $conf->currency); |
| 6341 | - } |
|
| 6342 | - elseif ($type == 'select') |
|
| 6745 | + } elseif ($type == 'select') |
|
| 6343 | 6746 | { |
| 6344 | 6747 | $value=$param['options'][$value]; |
| 6345 | - } |
|
| 6346 | - elseif ($type == 'sellist') |
|
| 6748 | + } elseif ($type == 'sellist') |
|
| 6347 | 6749 | { |
| 6348 | 6750 | $param_list=array_keys($param['options']); |
| 6349 | 6751 | $InfoFieldList = explode(":", $param_list[0]); |
@@ -6373,7 +6775,7 @@ discard block |
||
| 6373 | 6775 | $sql.= " WHERE ".$selectkey."=0"; |
| 6374 | 6776 | } elseif ($selectkey=='rowid') { |
| 6375 | 6777 | $sql.= " WHERE ".$selectkey."=".$this->db->escape($value); |
| 6376 | - }else { |
|
| 6778 | + } else { |
|
| 6377 | 6779 | $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; |
| 6378 | 6780 | } |
| 6379 | 6781 | |
@@ -6400,12 +6802,11 @@ discard block |
||
| 6400 | 6802 | } |
| 6401 | 6803 | if ($translabel!=$field_toshow) { |
| 6402 | 6804 | $value.=dol_trunc($translabel, 18).' '; |
| 6403 | - }else { |
|
| 6805 | + } else { |
|
| 6404 | 6806 | $value.=$obj->$field_toshow.' '; |
| 6405 | 6807 | } |
| 6406 | 6808 | } |
| 6407 | - } |
|
| 6408 | - else |
|
| 6809 | + } else |
|
| 6409 | 6810 | { |
| 6410 | 6811 | $translabel=''; |
| 6411 | 6812 | if (!empty($obj->{$InfoFieldList[1]})) { |
@@ -6413,18 +6814,17 @@ discard block |
||
| 6413 | 6814 | } |
| 6414 | 6815 | if ($translabel!=$obj->{$InfoFieldList[1]}) { |
| 6415 | 6816 | $value=dol_trunc($translabel, 18); |
| 6416 | - }else { |
|
| 6817 | + } else { |
|
| 6417 | 6818 | $value=$obj->{$InfoFieldList[1]}; |
| 6418 | 6819 | } |
| 6419 | 6820 | } |
| 6821 | + } else { |
|
| 6822 | + dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); |
|
| 6420 | 6823 | } |
| 6421 | - else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); |
|
| 6422 | - } |
|
| 6423 | - elseif ($type == 'radio') |
|
| 6824 | + } elseif ($type == 'radio') |
|
| 6424 | 6825 | { |
| 6425 | 6826 | $value=$param['options'][$value]; |
| 6426 | - } |
|
| 6427 | - elseif ($type == 'checkbox') |
|
| 6827 | + } elseif ($type == 'checkbox') |
|
| 6428 | 6828 | { |
| 6429 | 6829 | $value_arr=explode(',', $value); |
| 6430 | 6830 | $value=''; |
@@ -6436,8 +6836,7 @@ discard block |
||
| 6436 | 6836 | } |
| 6437 | 6837 | $value='<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>'; |
| 6438 | 6838 | } |
| 6439 | - } |
|
| 6440 | - elseif ($type == 'chkbxlst') |
|
| 6839 | + } elseif ($type == 'chkbxlst') |
|
| 6441 | 6840 | { |
| 6442 | 6841 | $value_arr = explode(',', $value); |
| 6443 | 6842 | |
@@ -6504,8 +6903,7 @@ discard block |
||
| 6504 | 6903 | } else { |
| 6505 | 6904 | dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING); |
| 6506 | 6905 | } |
| 6507 | - } |
|
| 6508 | - elseif ($type == 'link') |
|
| 6906 | + } elseif ($type == 'link') |
|
| 6509 | 6907 | { |
| 6510 | 6908 | $out=''; |
| 6511 | 6909 | |
@@ -6527,24 +6925,21 @@ discard block |
||
| 6527 | 6925 | $object->fetch($value); |
| 6528 | 6926 | $value=$object->getNomUrl($getnomurlparam); |
| 6529 | 6927 | } |
| 6530 | - } |
|
| 6531 | - else |
|
| 6928 | + } else |
|
| 6532 | 6929 | { |
| 6533 | 6930 | dol_syslog('Error bad setup of extrafield', LOG_WARNING); |
| 6534 | 6931 | return 'Error bad setup of extrafield'; |
| 6535 | 6932 | } |
| 6933 | + } else { |
|
| 6934 | + $value=''; |
|
| 6536 | 6935 | } |
| 6537 | - else $value=''; |
|
| 6538 | - } |
|
| 6539 | - elseif ($type == 'text' || $type == 'html') |
|
| 6936 | + } elseif ($type == 'text' || $type == 'html') |
|
| 6540 | 6937 | { |
| 6541 | 6938 | $value=dol_htmlentitiesbr($value); |
| 6542 | - } |
|
| 6543 | - elseif ($type == 'password') |
|
| 6939 | + } elseif ($type == 'password') |
|
| 6544 | 6940 | { |
| 6545 | 6941 | $value=preg_replace('/./i', '*', $value); |
| 6546 | - } |
|
| 6547 | - elseif ($type == 'array') |
|
| 6942 | + } elseif ($type == 'array') |
|
| 6548 | 6943 | { |
| 6549 | 6944 | $value = implode('<br>', $value); |
| 6550 | 6945 | } |
@@ -6571,7 +6966,9 @@ discard block |
||
| 6571 | 6966 | { |
| 6572 | 6967 | global $db, $conf, $langs, $action, $form; |
| 6573 | 6968 | |
| 6574 | - if (! is_object($form)) $form=new Form($db); |
|
| 6969 | + if (! is_object($form)) { |
|
| 6970 | + $form=new Form($db); |
|
| 6971 | + } |
|
| 6575 | 6972 | |
| 6576 | 6973 | $out = ''; |
| 6577 | 6974 | |
@@ -6586,7 +6983,9 @@ discard block |
||
| 6586 | 6983 | foreach($extrafields->attributes[$this->table_element]['label'] as $key=>$label) |
| 6587 | 6984 | { |
| 6588 | 6985 | // Show only the key field in params |
| 6589 | - if (is_array($params) && array_key_exists('onlykey', $params) && $key != $params['onlykey']) continue; |
|
| 6986 | + if (is_array($params) && array_key_exists('onlykey', $params) && $key != $params['onlykey']) { |
|
| 6987 | + continue; |
|
| 6988 | + } |
|
| 6590 | 6989 | |
| 6591 | 6990 | // @TODO Add test also on 'enabled' (different than 'list' that is 'visibility') |
| 6592 | 6991 | $enabled = 1; |
@@ -6603,12 +7002,21 @@ discard block |
||
| 6603 | 7002 | $perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1); |
| 6604 | 7003 | } |
| 6605 | 7004 | |
| 6606 | - if (($mode == 'create' || $mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list |
|
| 6607 | - elseif($mode == 'view' && empty($visibility)) continue; |
|
| 6608 | - if (empty($perms)) continue; |
|
| 7005 | + if (($mode == 'create' || $mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3) { |
|
| 7006 | + continue; |
|
| 7007 | + } |
|
| 7008 | + // <> -1 and <> 1 and <> 3 = not visible on forms, only on list |
|
| 7009 | + elseif($mode == 'view' && empty($visibility)) { |
|
| 7010 | + continue; |
|
| 7011 | + } |
|
| 7012 | + if (empty($perms)) { |
|
| 7013 | + continue; |
|
| 7014 | + } |
|
| 6609 | 7015 | |
| 6610 | 7016 | // Load language if required |
| 6611 | - if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); |
|
| 7017 | + if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) { |
|
| 7018 | + $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); |
|
| 7019 | + } |
|
| 6612 | 7020 | |
| 6613 | 7021 | $colspan='3'; |
| 6614 | 7022 | if (is_array($params) && count($params)>0) { |
@@ -6656,8 +7064,7 @@ discard block |
||
| 6656 | 7064 | } |
| 6657 | 7065 | |
| 6658 | 7066 | $out .= $extrafields->showSeparator($key, $this); |
| 6659 | - } |
|
| 6660 | - else |
|
| 7067 | + } else |
|
| 6661 | 7068 | { |
| 6662 | 7069 | $class=(!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : ''); |
| 6663 | 7070 | $csstyle=''; |
@@ -6687,10 +7094,12 @@ discard block |
||
| 6687 | 7094 | if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date','datetime'))) |
| 6688 | 7095 | { |
| 6689 | 7096 | $datenotinstring = $this->array_options['options_' . $key]; |
| 6690 | - if (! is_numeric($this->array_options['options_' . $key])) // For backward compatibility |
|
| 7097 | + if (! is_numeric($this->array_options['options_' . $key])) { |
|
| 7098 | + // For backward compatibility |
|
| 6691 | 7099 | { |
| 6692 | 7100 | $datenotinstring = $this->db->jdate($datenotinstring); |
| 6693 | 7101 | } |
| 7102 | + } |
|
| 6694 | 7103 | $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)):$datenotinstring; |
| 6695 | 7104 | } |
| 6696 | 7105 | // Convert float submited string into real php numeric (value in memory must be a php numeric) |
@@ -6708,14 +7117,24 @@ discard block |
||
| 6708 | 7117 | $tpl_context = isset($params["tpl_context"]) ? $params["tpl_context"] : "none"; |
| 6709 | 7118 | if ($tpl_context=="public") { // Public page : red dot instead of fieldrequired characters |
| 6710 | 7119 | $out .= '">'; |
| 6711 | - if (! empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]); |
|
| 6712 | - else $out .= $labeltoshow; |
|
| 6713 | - if ($mode != 'view' && ! empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' <font color="red">*</font>'; |
|
| 7120 | + if (! empty($extrafields->attributes[$this->table_element]['help'][$key])) { |
|
| 7121 | + $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]); |
|
| 7122 | + } else { |
|
| 7123 | + $out .= $labeltoshow; |
|
| 7124 | + } |
|
| 7125 | + if ($mode != 'view' && ! empty($extrafields->attributes[$this->table_element]['required'][$key])) { |
|
| 7126 | + $out .= ' <font color="red">*</font>'; |
|
| 7127 | + } |
|
| 6714 | 7128 | } else { |
| 6715 | - if ($mode != 'view' && ! empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' fieldrequired'; |
|
| 7129 | + if ($mode != 'view' && ! empty($extrafields->attributes[$this->table_element]['required'][$key])) { |
|
| 7130 | + $out .= ' fieldrequired'; |
|
| 7131 | + } |
|
| 6716 | 7132 | $out .= '">'; |
| 6717 | - if (! empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]); |
|
| 6718 | - else $out .= $labeltoshow; |
|
| 7133 | + if (! empty($extrafields->attributes[$this->table_element]['help'][$key])) { |
|
| 7134 | + $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]); |
|
| 7135 | + } else { |
|
| 7136 | + $out .= $labeltoshow; |
|
| 7137 | + } |
|
| 6719 | 7138 | } |
| 6720 | 7139 | $out .= '</td>'; |
| 6721 | 7140 | |
@@ -6740,8 +7159,11 @@ discard block |
||
| 6740 | 7159 | $out .='<td class="'.$this->element.'_extras_'.$key.'"></td>'; |
| 6741 | 7160 | }*/ |
| 6742 | 7161 | |
| 6743 | - if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>'; |
|
| 6744 | - else $out .= '</tr>'; |
|
| 7162 | + if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) { |
|
| 7163 | + $out .= '</tr>'; |
|
| 7164 | + } else { |
|
| 7165 | + $out .= '</tr>'; |
|
| 7166 | + } |
|
| 6745 | 7167 | $e++; |
| 6746 | 7168 | } |
| 6747 | 7169 | } |
@@ -6793,7 +7215,9 @@ discard block |
||
| 6793 | 7215 | global $user; |
| 6794 | 7216 | |
| 6795 | 7217 | $element = $this->element; |
| 6796 | - if ($element == 'facturerec') $element='facture'; |
|
| 7218 | + if ($element == 'facturerec') { |
|
| 7219 | + $element='facture'; |
|
| 7220 | + } |
|
| 6797 | 7221 | |
| 6798 | 7222 | return $user->rights->{$element}; |
| 6799 | 7223 | } |
@@ -6818,7 +7242,10 @@ discard block |
||
| 6818 | 7242 | |
| 6819 | 7243 | if (! $db->query($sql)) |
| 6820 | 7244 | { |
| 6821 | - if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. |
|
| 7245 | + if ($ignoreerrors) { |
|
| 7246 | + return true; |
|
| 7247 | + } |
|
| 7248 | + // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. |
|
| 6822 | 7249 | //$this->errors = $db->lasterror(); |
| 6823 | 7250 | return false; |
| 6824 | 7251 | } |
@@ -6845,11 +7272,12 @@ discard block |
||
| 6845 | 7272 | |
| 6846 | 7273 | $buyPrice = 0; |
| 6847 | 7274 | |
| 6848 | - if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) // In most cases, test here is false |
|
| 7275 | + if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { |
|
| 7276 | + // In most cases, test here is false |
|
| 6849 | 7277 | { |
| 6850 | 7278 | $buyPrice = $unitPrice * (1 - $discountPercent / 100); |
| 6851 | 7279 | } |
| 6852 | - else |
|
| 7280 | + } else |
|
| 6853 | 7281 | { |
| 6854 | 7282 | // Get cost price for margin calculation |
| 6855 | 7283 | if (! empty($fk_product)) |
@@ -6867,13 +7295,11 @@ discard block |
||
| 6867 | 7295 | if ($product->cost_price > 0) |
| 6868 | 7296 | { |
| 6869 | 7297 | $buyPrice = $product->cost_price; |
| 6870 | - } |
|
| 6871 | - elseif ($product->pmp > 0) |
|
| 7298 | + } elseif ($product->pmp > 0) |
|
| 6872 | 7299 | { |
| 6873 | 7300 | $buyPrice = $product->pmp; |
| 6874 | 7301 | } |
| 6875 | - } |
|
| 6876 | - elseif (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') |
|
| 7302 | + } elseif (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') |
|
| 6877 | 7303 | { |
| 6878 | 7304 | require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
| 6879 | 7305 | $product = new Product($this->db); |
@@ -6896,8 +7322,7 @@ discard block |
||
| 6896 | 7322 | if (($result = $productFournisseur->find_min_price_product_fournisseur($fk_product)) > 0) |
| 6897 | 7323 | { |
| 6898 | 7324 | $buyPrice = $productFournisseur->fourn_unitprice; |
| 6899 | - } |
|
| 6900 | - elseif ($result < 0) |
|
| 7325 | + } elseif ($result < 0) |
|
| 6901 | 7326 | { |
| 6902 | 7327 | $this->errors[] = $productFournisseur->error; |
| 6903 | 7328 | return -2; |
@@ -6999,19 +7424,26 @@ discard block |
||
| 6999 | 7424 | if ($size == 1 || $size == 'small') { // Format vignette |
| 7000 | 7425 | // Find name of thumb file |
| 7001 | 7426 | $photo_vignette=basename(getImageFileNameForSize($dir.$file, '_small')); |
| 7002 | - if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette=''; |
|
| 7427 | + if (! dol_is_file($dirthumb.$photo_vignette)) { |
|
| 7428 | + $photo_vignette=''; |
|
| 7429 | + } |
|
| 7003 | 7430 | |
| 7004 | 7431 | // Get filesize of original file |
| 7005 | 7432 | $imgarray=dol_getImageSize($dir.$photo); |
| 7006 | 7433 | |
| 7007 | 7434 | if ($nbbyrow > 0) |
| 7008 | 7435 | { |
| 7009 | - if ($nbphoto == 1) $return.= '<table class="valigntop center centpercent" style="border: 0; padding: 2; border-spacing: 2px; border-collapse: separate;">'; |
|
| 7436 | + if ($nbphoto == 1) { |
|
| 7437 | + $return.= '<table class="valigntop center centpercent" style="border: 0; padding: 2; border-spacing: 2px; border-collapse: separate;">'; |
|
| 7438 | + } |
|
| 7010 | 7439 | |
| 7011 | - if ($nbphoto % $nbbyrow == 1) $return.= '<tr class="center valignmiddle" style="border: 1px">'; |
|
| 7440 | + if ($nbphoto % $nbbyrow == 1) { |
|
| 7441 | + $return.= '<tr class="center valignmiddle" style="border: 1px">'; |
|
| 7442 | + } |
|
| 7012 | 7443 | $return.= '<td style="width: '.ceil(100/$nbbyrow).'%" class="photo">'; |
| 7444 | + } elseif ($nbbyrow < 0) { |
|
| 7445 | + $return .= '<div class="inline-block">'; |
|
| 7013 | 7446 | } |
| 7014 | - elseif ($nbbyrow < 0) $return .= '<div class="inline-block">'; |
|
| 7015 | 7447 | |
| 7016 | 7448 | $return.= "\n"; |
| 7017 | 7449 | |
@@ -7019,15 +7451,20 @@ discard block |
||
| 7019 | 7451 | if (empty($nolink)) |
| 7020 | 7452 | { |
| 7021 | 7453 | $urladvanced=getAdvancedPreviewUrl($modulepart, $relativefile, 0, 'entity='.$this->entity); |
| 7022 | - if ($urladvanced) $return.='<a href="'.$urladvanced.'">'; |
|
| 7023 | - else $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">'; |
|
| 7454 | + if ($urladvanced) { |
|
| 7455 | + $return.='<a href="'.$urladvanced.'">'; |
|
| 7456 | + } else { |
|
| 7457 | + $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">'; |
|
| 7458 | + } |
|
| 7024 | 7459 | } |
| 7025 | 7460 | |
| 7026 | 7461 | // Show image (width height=$maxHeight) |
| 7027 | 7462 | // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine |
| 7028 | 7463 | $alt=$langs->transnoentitiesnoconv('File').': '.$relativefile; |
| 7029 | 7464 | $alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; |
| 7030 | - if ($notitle) $alt=''; |
|
| 7465 | + if ($notitle) { |
|
| 7466 | + $alt=''; |
|
| 7467 | + } |
|
| 7031 | 7468 | |
| 7032 | 7469 | if ($usesharelink) |
| 7033 | 7470 | { |
@@ -7037,35 +7474,35 @@ discard block |
||
| 7037 | 7474 | { |
| 7038 | 7475 | $return.= '<!-- Show original file (thumb not yet available with shared links) -->'; |
| 7039 | 7476 | $return.= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">'; |
| 7040 | - } |
|
| 7041 | - else { |
|
| 7477 | + } else { |
|
| 7042 | 7478 | $return.= '<!-- Show original file -->'; |
| 7043 | 7479 | $return.= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">'; |
| 7044 | 7480 | } |
| 7045 | - } |
|
| 7046 | - else |
|
| 7481 | + } else |
|
| 7047 | 7482 | { |
| 7048 | 7483 | $return.= '<!-- Show nophoto file (because file is not shared) -->'; |
| 7049 | 7484 | $return.= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png" title="'.dol_escape_htmltag($alt).'">'; |
| 7050 | 7485 | } |
| 7051 | - } |
|
| 7052 | - else |
|
| 7486 | + } else |
|
| 7053 | 7487 | { |
| 7054 | 7488 | if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) |
| 7055 | 7489 | { |
| 7056 | 7490 | $return.= '<!-- Show thumb -->'; |
| 7057 | 7491 | $return.= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; |
| 7058 | - } |
|
| 7059 | - else { |
|
| 7492 | + } else { |
|
| 7060 | 7493 | $return.= '<!-- Show original file -->'; |
| 7061 | 7494 | $return.= '<img class="photo photowithmargin" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; |
| 7062 | 7495 | } |
| 7063 | 7496 | } |
| 7064 | 7497 | |
| 7065 | - if (empty($nolink)) $return.= '</a>'; |
|
| 7498 | + if (empty($nolink)) { |
|
| 7499 | + $return.= '</a>'; |
|
| 7500 | + } |
|
| 7066 | 7501 | $return.="\n"; |
| 7067 | 7502 | |
| 7068 | - if ($showfilename) $return.= '<br>'.$viewfilename; |
|
| 7503 | + if ($showfilename) { |
|
| 7504 | + $return.= '<br>'.$viewfilename; |
|
| 7505 | + } |
|
| 7069 | 7506 | if ($showaction) |
| 7070 | 7507 | { |
| 7071 | 7508 | $return.= '<br>'; |
@@ -7090,15 +7527,20 @@ discard block |
||
| 7090 | 7527 | if ($nbbyrow > 0) |
| 7091 | 7528 | { |
| 7092 | 7529 | $return.= '</td>'; |
| 7093 | - if (($nbphoto % $nbbyrow) == 0) $return.= '</tr>'; |
|
| 7530 | + if (($nbphoto % $nbbyrow) == 0) { |
|
| 7531 | + $return.= '</tr>'; |
|
| 7532 | + } |
|
| 7533 | + } elseif ($nbbyrow < 0) { |
|
| 7534 | + $return.='</div>'; |
|
| 7094 | 7535 | } |
| 7095 | - elseif ($nbbyrow < 0) $return.='</div>'; |
|
| 7096 | 7536 | } |
| 7097 | 7537 | |
| 7098 | 7538 | if (empty($size)) { // Format origine |
| 7099 | 7539 | $return.= '<img class="photo photowithmargin" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">'; |
| 7100 | 7540 | |
| 7101 | - if ($showfilename) $return.= '<br>'.$viewfilename; |
|
| 7541 | + if ($showfilename) { |
|
| 7542 | + $return.= '<br>'.$viewfilename; |
|
| 7543 | + } |
|
| 7102 | 7544 | if ($showaction) |
| 7103 | 7545 | { |
| 7104 | 7546 | // Special case for product |
@@ -7115,7 +7557,9 @@ discard block |
||
| 7115 | 7557 | } |
| 7116 | 7558 | |
| 7117 | 7559 | // On continue ou on arrete de boucler ? |
| 7118 | - if ($nbmax && $nbphoto >= $nbmax) break; |
|
| 7560 | + if ($nbmax && $nbphoto >= $nbmax) { |
|
| 7561 | + break; |
|
| 7562 | + } |
|
| 7119 | 7563 | } |
| 7120 | 7564 | } |
| 7121 | 7565 | |
@@ -7130,7 +7574,9 @@ discard block |
||
| 7130 | 7574 | $nbphoto++; |
| 7131 | 7575 | } |
| 7132 | 7576 | |
| 7133 | - if ($nbphoto) $return.= '</table>'; |
|
| 7577 | + if ($nbphoto) { |
|
| 7578 | + $return.= '</table>'; |
|
| 7579 | + } |
|
| 7134 | 7580 | } |
| 7135 | 7581 | } |
| 7136 | 7582 | } |
@@ -7151,8 +7597,11 @@ discard block |
||
| 7151 | 7597 | { |
| 7152 | 7598 | if (is_array($info)) |
| 7153 | 7599 | { |
| 7154 | - if(isset($info['type']) && $info['type']=='array') return true; |
|
| 7155 | - else return false; |
|
| 7600 | + if(isset($info['type']) && $info['type']=='array') { |
|
| 7601 | + return true; |
|
| 7602 | + } else { |
|
| 7603 | + return false; |
|
| 7604 | + } |
|
| 7156 | 7605 | } |
| 7157 | 7606 | return false; |
| 7158 | 7607 | } |
@@ -7165,7 +7614,9 @@ discard block |
||
| 7165 | 7614 | */ |
| 7166 | 7615 | public function isDate($info) |
| 7167 | 7616 | { |
| 7168 | - if (isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true; |
|
| 7617 | + if (isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) { |
|
| 7618 | + return true; |
|
| 7619 | + } |
|
| 7169 | 7620 | return false; |
| 7170 | 7621 | } |
| 7171 | 7622 | |
@@ -7179,10 +7630,14 @@ discard block |
||
| 7179 | 7630 | { |
| 7180 | 7631 | if(is_array($info)) |
| 7181 | 7632 | { |
| 7182 | - if (isset($info['type']) && ($info['type']=='int' || preg_match('/^integer/i', $info['type']))) return true; |
|
| 7183 | - else return false; |
|
| 7633 | + if (isset($info['type']) && ($info['type']=='int' || preg_match('/^integer/i', $info['type']))) { |
|
| 7634 | + return true; |
|
| 7635 | + } else { |
|
| 7636 | + return false; |
|
| 7637 | + } |
|
| 7638 | + } else { |
|
| 7639 | + return false; |
|
| 7184 | 7640 | } |
| 7185 | - else return false; |
|
| 7186 | 7641 | } |
| 7187 | 7642 | |
| 7188 | 7643 | /** |
@@ -7195,8 +7650,11 @@ discard block |
||
| 7195 | 7650 | { |
| 7196 | 7651 | if (is_array($info)) |
| 7197 | 7652 | { |
| 7198 | - if (isset($info['type']) && (preg_match('/^(double|real|price)/i', $info['type']))) return true; |
|
| 7199 | - else return false; |
|
| 7653 | + if (isset($info['type']) && (preg_match('/^(double|real|price)/i', $info['type']))) { |
|
| 7654 | + return true; |
|
| 7655 | + } else { |
|
| 7656 | + return false; |
|
| 7657 | + } |
|
| 7200 | 7658 | } |
| 7201 | 7659 | return false; |
| 7202 | 7660 | } |
@@ -7211,8 +7669,11 @@ discard block |
||
| 7211 | 7669 | { |
| 7212 | 7670 | if (is_array($info)) |
| 7213 | 7671 | { |
| 7214 | - if(isset($info['type']) && $info['type']=='text') return true; |
|
| 7215 | - else return false; |
|
| 7672 | + if(isset($info['type']) && $info['type']=='text') { |
|
| 7673 | + return true; |
|
| 7674 | + } else { |
|
| 7675 | + return false; |
|
| 7676 | + } |
|
| 7216 | 7677 | } |
| 7217 | 7678 | return false; |
| 7218 | 7679 | } |
@@ -7227,8 +7688,11 @@ discard block |
||
| 7227 | 7688 | { |
| 7228 | 7689 | if (is_array($info)) |
| 7229 | 7690 | { |
| 7230 | - if(isset($info['notnull']) && $info['notnull']!='1') return true; |
|
| 7231 | - else return false; |
|
| 7691 | + if(isset($info['notnull']) && $info['notnull']!='1') { |
|
| 7692 | + return true; |
|
| 7693 | + } else { |
|
| 7694 | + return false; |
|
| 7695 | + } |
|
| 7232 | 7696 | } |
| 7233 | 7697 | return true; |
| 7234 | 7698 | } |
@@ -7243,8 +7707,11 @@ discard block |
||
| 7243 | 7707 | { |
| 7244 | 7708 | if (is_array($info)) |
| 7245 | 7709 | { |
| 7246 | - if(isset($info['notnull']) && $info['notnull']=='-1') return true; |
|
| 7247 | - else return false; |
|
| 7710 | + if(isset($info['notnull']) && $info['notnull']=='-1') { |
|
| 7711 | + return true; |
|
| 7712 | + } else { |
|
| 7713 | + return false; |
|
| 7714 | + } |
|
| 7248 | 7715 | } |
| 7249 | 7716 | return false; |
| 7250 | 7717 | } |
@@ -7259,8 +7726,11 @@ discard block |
||
| 7259 | 7726 | { |
| 7260 | 7727 | if (is_array($info)) |
| 7261 | 7728 | { |
| 7262 | - if(isset($info['index']) && $info['index']==true) return true; |
|
| 7263 | - else return false; |
|
| 7729 | + if(isset($info['index']) && $info['index']==true) { |
|
| 7730 | + return true; |
|
| 7731 | + } else { |
|
| 7732 | + return false; |
|
| 7733 | + } |
|
| 7264 | 7734 | } |
| 7265 | 7735 | return false; |
| 7266 | 7736 | } |
@@ -7278,7 +7748,8 @@ discard block |
||
| 7278 | 7748 | global $conf; |
| 7279 | 7749 | |
| 7280 | 7750 | $queryarray=array(); |
| 7281 | - foreach ($this->fields as $field=>$info) // Loop on definition of fields |
|
| 7751 | + foreach ($this->fields as $field=>$info) { |
|
| 7752 | + // Loop on definition of fields |
|
| 7282 | 7753 | { |
| 7283 | 7754 | // Depending on field type ('datetime', ...) |
| 7284 | 7755 | if($this->isDate($info)) |
@@ -7286,13 +7757,12 @@ discard block |
||
| 7286 | 7757 | if(empty($this->{$field})) |
| 7287 | 7758 | { |
| 7288 | 7759 | $queryarray[$field] = null; |
| 7289 | - } |
|
| 7290 | - else |
|
| 7760 | + } |
|
| 7761 | + } else |
|
| 7291 | 7762 | { |
| 7292 | 7763 | $queryarray[$field] = $this->db->idate($this->{$field}); |
| 7293 | 7764 | } |
| 7294 | - } |
|
| 7295 | - elseif($this->isArray($info)) |
|
| 7765 | + } elseif($this->isArray($info)) |
|
| 7296 | 7766 | { |
| 7297 | 7767 | if(! empty($this->{$field})) { |
| 7298 | 7768 | if(! is_array($this->{$field})) { |
@@ -7302,28 +7772,35 @@ discard block |
||
| 7302 | 7772 | } else { |
| 7303 | 7773 | $queryarray[$field] = null; |
| 7304 | 7774 | } |
| 7305 | - } |
|
| 7306 | - elseif($this->isInt($info)) |
|
| 7775 | + } elseif($this->isInt($info)) |
|
| 7307 | 7776 | { |
| 7308 | - if ($field == 'entity' && is_null($this->{$field})) $queryarray[$field]=$conf->entity; |
|
| 7309 | - else |
|
| 7777 | + if ($field == 'entity' && is_null($this->{$field})) { |
|
| 7778 | + $queryarray[$field]=$conf->entity; |
|
| 7779 | + } else |
|
| 7310 | 7780 | { |
| 7311 | 7781 | $queryarray[$field] = (int) $this->{$field}; |
| 7312 | - if (empty($queryarray[$field])) $queryarray[$field]=0; // May be reset to null later if property 'notnull' is -1 for this field. |
|
| 7782 | + if (empty($queryarray[$field])) { |
|
| 7783 | + $queryarray[$field]=0; |
|
| 7784 | + } |
|
| 7785 | + // May be reset to null later if property 'notnull' is -1 for this field. |
|
| 7313 | 7786 | } |
| 7314 | - } |
|
| 7315 | - elseif($this->isFloat($info)) |
|
| 7787 | + } elseif($this->isFloat($info)) |
|
| 7316 | 7788 | { |
| 7317 | 7789 | $queryarray[$field] = (double) $this->{$field}; |
| 7318 | - if (empty($queryarray[$field])) $queryarray[$field]=0; |
|
| 7319 | - } |
|
| 7320 | - else |
|
| 7790 | + if (empty($queryarray[$field])) { |
|
| 7791 | + $queryarray[$field]=0; |
|
| 7792 | + } |
|
| 7793 | + } else |
|
| 7321 | 7794 | { |
| 7322 | 7795 | $queryarray[$field] = $this->{$field}; |
| 7323 | 7796 | } |
| 7324 | 7797 | |
| 7325 | - if ($info['type'] == 'timestamp' && empty($queryarray[$field])) unset($queryarray[$field]); |
|
| 7326 | - if (! empty($info['notnull']) && $info['notnull'] == -1 && empty($queryarray[$field])) $queryarray[$field] = null; |
|
| 7798 | + if ($info['type'] == 'timestamp' && empty($queryarray[$field])) { |
|
| 7799 | + unset($queryarray[$field]); |
|
| 7800 | + } |
|
| 7801 | + if (! empty($info['notnull']) && $info['notnull'] == -1 && empty($queryarray[$field])) { |
|
| 7802 | + $queryarray[$field] = null; |
|
| 7803 | + } |
|
| 7327 | 7804 | } |
| 7328 | 7805 | |
| 7329 | 7806 | return $queryarray; |
@@ -7341,55 +7818,63 @@ discard block |
||
| 7341 | 7818 | { |
| 7342 | 7819 | if($this->isDate($info)) |
| 7343 | 7820 | { |
| 7344 | - if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; |
|
| 7345 | - else $this->{$field} = strtotime($obj->{$field}); |
|
| 7346 | - } |
|
| 7347 | - elseif($this->isArray($info)) |
|
| 7821 | + if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') { |
|
| 7822 | + $this->{$field} = 0; |
|
| 7823 | + } else { |
|
| 7824 | + $this->{$field} = strtotime($obj->{$field}); |
|
| 7825 | + } |
|
| 7826 | + } elseif($this->isArray($info)) |
|
| 7348 | 7827 | { |
| 7349 | 7828 | if(! empty($obj->{$field})) { |
| 7350 | 7829 | $this->{$field} = @unserialize($obj->{$field}); |
| 7351 | 7830 | // Hack for data not in UTF8 |
| 7352 | - if($this->{$field } === false) @unserialize(utf8_decode($obj->{$field})); |
|
| 7831 | + if($this->{$field } === false) { |
|
| 7832 | + @unserialize(utf8_decode($obj->{$field})); |
|
| 7833 | + } |
|
| 7353 | 7834 | } else { |
| 7354 | 7835 | $this->{$field} = array(); |
| 7355 | 7836 | } |
| 7356 | - } |
|
| 7357 | - elseif($this->isInt($info)) |
|
| 7837 | + } elseif($this->isInt($info)) |
|
| 7358 | 7838 | { |
| 7359 | - if ($field == 'rowid') $this->id = (int) $obj->{$field}; |
|
| 7360 | - else |
|
| 7839 | + if ($field == 'rowid') { |
|
| 7840 | + $this->id = (int) $obj->{$field}; |
|
| 7841 | + } else |
|
| 7361 | 7842 | { |
| 7362 | 7843 | if ($this->isForcedToNullIfZero($info)) |
| 7363 | 7844 | { |
| 7364 | - if (empty($obj->{$field})) $this->{$field} = null; |
|
| 7365 | - else $this->{$field} = (double) $obj->{$field}; |
|
| 7366 | - } |
|
| 7367 | - else |
|
| 7845 | + if (empty($obj->{$field})) { |
|
| 7846 | + $this->{$field} = null; |
|
| 7847 | + } else { |
|
| 7848 | + $this->{$field} = (double) $obj->{$field}; |
|
| 7849 | + } |
|
| 7850 | + } else |
|
| 7368 | 7851 | { |
| 7369 | 7852 | $this->{$field} = (int) $obj->{$field}; |
| 7370 | 7853 | } |
| 7371 | 7854 | } |
| 7372 | - } |
|
| 7373 | - elseif($this->isFloat($info)) |
|
| 7855 | + } elseif($this->isFloat($info)) |
|
| 7374 | 7856 | { |
| 7375 | 7857 | if ($this->isForcedToNullIfZero($info)) |
| 7376 | 7858 | { |
| 7377 | - if (empty($obj->{$field})) $this->{$field} = null; |
|
| 7378 | - else $this->{$field} = (double) $obj->{$field}; |
|
| 7379 | - } |
|
| 7380 | - else |
|
| 7859 | + if (empty($obj->{$field})) { |
|
| 7860 | + $this->{$field} = null; |
|
| 7861 | + } else { |
|
| 7862 | + $this->{$field} = (double) $obj->{$field}; |
|
| 7863 | + } |
|
| 7864 | + } else |
|
| 7381 | 7865 | { |
| 7382 | 7866 | $this->{$field} = (double) $obj->{$field}; |
| 7383 | 7867 | } |
| 7384 | - } |
|
| 7385 | - else |
|
| 7868 | + } else |
|
| 7386 | 7869 | { |
| 7387 | 7870 | $this->{$field} = $obj->{$field}; |
| 7388 | 7871 | } |
| 7389 | 7872 | } |
| 7390 | 7873 | |
| 7391 | 7874 | // If there is no 'ref' field, we force property ->ref to ->id for a better compatibility with common functions. |
| 7392 | - if (! isset($this->fields['ref']) && isset($this->id)) $this->ref = $this->id; |
|
| 7875 | + if (! isset($this->fields['ref']) && isset($this->id)) { |
|
| 7876 | + $this->ref = $this->id; |
|
| 7877 | + } |
|
| 7393 | 7878 | } |
| 7394 | 7879 | |
| 7395 | 7880 | /** |
@@ -7412,9 +7897,13 @@ discard block |
||
| 7412 | 7897 | */ |
| 7413 | 7898 | protected function quote($value, $fieldsentry) |
| 7414 | 7899 | { |
| 7415 | - if (is_null($value)) return 'NULL'; |
|
| 7416 | - elseif (preg_match('/^(int|double|real)/i', $fieldsentry['type'])) return $this->db->escape("$value"); |
|
| 7417 | - else return "'".$this->db->escape($value)."'"; |
|
| 7900 | + if (is_null($value)) { |
|
| 7901 | + return 'NULL'; |
|
| 7902 | + } elseif (preg_match('/^(int|double|real)/i', $fieldsentry['type'])) { |
|
| 7903 | + return $this->db->escape("$value"); |
|
| 7904 | + } else { |
|
| 7905 | + return "'".$this->db->escape($value)."'"; |
|
| 7906 | + } |
|
| 7418 | 7907 | } |
| 7419 | 7908 | |
| 7420 | 7909 | |
@@ -7434,10 +7923,17 @@ discard block |
||
| 7434 | 7923 | $now=dol_now(); |
| 7435 | 7924 | |
| 7436 | 7925 | $fieldvalues = $this->setSaveQuery(); |
| 7437 | - if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation']=$this->db->idate($now); |
|
| 7438 | - if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id; |
|
| 7926 | + if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) { |
|
| 7927 | + $fieldvalues['date_creation']=$this->db->idate($now); |
|
| 7928 | + } |
|
| 7929 | + if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) { |
|
| 7930 | + $fieldvalues['fk_user_creat']=$user->id; |
|
| 7931 | + } |
|
| 7439 | 7932 | unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. |
| 7440 | - if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref']=dol_string_nospecial($fieldvalues['ref']); // If field is a ref,we sanitize data |
|
| 7933 | + if (array_key_exists('ref', $fieldvalues)) { |
|
| 7934 | + $fieldvalues['ref']=dol_string_nospecial($fieldvalues['ref']); |
|
| 7935 | + } |
|
| 7936 | + // If field is a ref,we sanitize data |
|
| 7441 | 7937 | |
| 7442 | 7938 | $keys = array(); |
| 7443 | 7939 | $values = array(); |
@@ -7451,8 +7947,12 @@ discard block |
||
| 7451 | 7947 | foreach($keys as $key) |
| 7452 | 7948 | { |
| 7453 | 7949 | // If field is an implicit foreign key field |
| 7454 | - if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key]=''; |
|
| 7455 | - if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]=''; |
|
| 7950 | + if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') { |
|
| 7951 | + $values[$key]=''; |
|
| 7952 | + } |
|
| 7953 | + if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') { |
|
| 7954 | + $values[$key]=''; |
|
| 7955 | + } |
|
| 7456 | 7956 | |
| 7457 | 7957 | //var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1)); |
| 7458 | 7958 | if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && ! isset($values[$key]) && is_null($val['default'])) |
@@ -7462,11 +7962,17 @@ discard block |
||
| 7462 | 7962 | } |
| 7463 | 7963 | |
| 7464 | 7964 | // If field is an implicit foreign key field |
| 7465 | - if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) $values[$key]='null'; |
|
| 7466 | - if (! empty($this->fields[$key]['foreignkey']) && empty($values[$key])) $values[$key]='null'; |
|
| 7965 | + if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) { |
|
| 7966 | + $values[$key]='null'; |
|
| 7967 | + } |
|
| 7968 | + if (! empty($this->fields[$key]['foreignkey']) && empty($values[$key])) { |
|
| 7969 | + $values[$key]='null'; |
|
| 7970 | + } |
|
| 7467 | 7971 | } |
| 7468 | 7972 | |
| 7469 | - if ($error) return -1; |
|
| 7973 | + if ($error) { |
|
| 7974 | + return -1; |
|
| 7975 | + } |
|
| 7470 | 7976 | |
| 7471 | 7977 | $this->db->begin(); |
| 7472 | 7978 | |
@@ -7508,7 +8014,9 @@ discard block |
||
| 7508 | 8014 | if (! $error) |
| 7509 | 8015 | { |
| 7510 | 8016 | $result=$this->insertExtraFields(); |
| 7511 | - if ($result < 0) $error++; |
|
| 8017 | + if ($result < 0) { |
|
| 8018 | + $error++; |
|
| 8019 | + } |
|
| 7512 | 8020 | } |
| 7513 | 8021 | |
| 7514 | 8022 | // Create lines |
@@ -7524,7 +8032,9 @@ discard block |
||
| 7524 | 8032 | |
| 7525 | 8033 | // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array |
| 7526 | 8034 | //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. |
| 7527 | - if (! is_object($line)) $line = (object) $line; |
|
| 8035 | + if (! is_object($line)) { |
|
| 8036 | + $line = (object) $line; |
|
| 8037 | + } |
|
| 7528 | 8038 | |
| 7529 | 8039 | $result = $line->create($user, 1); |
| 7530 | 8040 | if ($result < 0) |
@@ -7566,16 +8076,27 @@ discard block |
||
| 7566 | 8076 | */ |
| 7567 | 8077 | public function fetchCommon($id, $ref = null, $morewhere = '') |
| 7568 | 8078 | { |
| 7569 | - if (empty($id) && empty($ref) && empty($morewhere)) return -1; |
|
| 8079 | + if (empty($id) && empty($ref) && empty($morewhere)) { |
|
| 8080 | + return -1; |
|
| 8081 | + } |
|
| 7570 | 8082 | |
| 7571 | 8083 | $sql = 'SELECT '.$this->getFieldList(); |
| 7572 | 8084 | $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
| 7573 | 8085 | |
| 7574 | - if (!empty($id)) $sql.= ' WHERE rowid = '.$id; |
|
| 7575 | - elseif (!empty($ref)) $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); |
|
| 7576 | - else $sql.=' WHERE 1 = 1'; // usage with empty id and empty ref is very rare |
|
| 7577 | - if (empty($id) && isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.=' AND entity IN ('.getEntity($this->table_element).')'; |
|
| 7578 | - if ($morewhere) $sql.= $morewhere; |
|
| 8086 | + if (!empty($id)) { |
|
| 8087 | + $sql.= ' WHERE rowid = '.$id; |
|
| 8088 | + } elseif (!empty($ref)) { |
|
| 8089 | + $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); |
|
| 8090 | + } else { |
|
| 8091 | + $sql.=' WHERE 1 = 1'; |
|
| 8092 | + } |
|
| 8093 | + // usage with empty id and empty ref is very rare |
|
| 8094 | + if (empty($id) && isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { |
|
| 8095 | + $sql.=' AND entity IN ('.getEntity($this->table_element).')'; |
|
| 8096 | + } |
|
| 8097 | + if ($morewhere) { |
|
| 8098 | + $sql.= $morewhere; |
|
| 8099 | + } |
|
| 7579 | 8100 | $sql.=' LIMIT 1'; // This is a fetch, to be sure to get only one record |
| 7580 | 8101 | |
| 7581 | 8102 | $res = $this->db->query($sql); |
@@ -7586,13 +8107,11 @@ discard block |
||
| 7586 | 8107 | { |
| 7587 | 8108 | $this->setVarsFromFetchObj($obj); |
| 7588 | 8109 | return $this->id; |
| 7589 | - } |
|
| 7590 | - else |
|
| 8110 | + } else |
|
| 7591 | 8111 | { |
| 7592 | 8112 | return 0; |
| 7593 | 8113 | } |
| 7594 | - } |
|
| 7595 | - else |
|
| 8114 | + } else |
|
| 7596 | 8115 | { |
| 7597 | 8116 | $this->error = $this->db->lasterror(); |
| 7598 | 8117 | $this->errors[] = $this->error; |
@@ -7620,7 +8139,9 @@ discard block |
||
| 7620 | 8139 | $sql = 'SELECT '.$objectline->getFieldList(); |
| 7621 | 8140 | $sql.= ' FROM '.MAIN_DB_PREFIX.$objectline->table_element; |
| 7622 | 8141 | $sql.=' WHERE fk_'.$this->element.' = '.$this->id; |
| 7623 | - if ($morewhere) $sql.= $morewhere; |
|
| 8142 | + if ($morewhere) { |
|
| 8143 | + $sql.= $morewhere; |
|
| 8144 | + } |
|
| 7624 | 8145 | |
| 7625 | 8146 | $resql = $this->db->query($sql); |
| 7626 | 8147 | if ($resql) |
@@ -7641,8 +8162,7 @@ discard block |
||
| 7641 | 8162 | } |
| 7642 | 8163 | |
| 7643 | 8164 | return 1; |
| 7644 | - } |
|
| 7645 | - else |
|
| 8165 | + } else |
|
| 7646 | 8166 | { |
| 7647 | 8167 | $this->error = $this->db->lasterror(); |
| 7648 | 8168 | $this->errors[] = $this->error; |
@@ -7666,8 +8186,12 @@ discard block |
||
| 7666 | 8186 | $now=dol_now(); |
| 7667 | 8187 | |
| 7668 | 8188 | $fieldvalues = $this->setSaveQuery(); |
| 7669 | - if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification']=$this->db->idate($now); |
|
| 7670 | - if (array_key_exists('fk_user_modif', $fieldvalues) && ! ($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif']=$user->id; |
|
| 8189 | + if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) { |
|
| 8190 | + $fieldvalues['date_modification']=$this->db->idate($now); |
|
| 8191 | + } |
|
| 8192 | + if (array_key_exists('fk_user_modif', $fieldvalues) && ! ($fieldvalues['fk_user_modif'] > 0)) { |
|
| 8193 | + $fieldvalues['fk_user_modif']=$user->id; |
|
| 8194 | + } |
|
| 7671 | 8195 | unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update. |
| 7672 | 8196 | |
| 7673 | 8197 | $keys = array(); |
@@ -7683,8 +8207,14 @@ discard block |
||
| 7683 | 8207 | // Clean and check mandatory |
| 7684 | 8208 | foreach($keys as $key) |
| 7685 | 8209 | { |
| 7686 | - if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key]=''; // This is an implicit foreign key field |
|
| 7687 | - if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]=''; // This is an explicit foreign key field |
|
| 8210 | + if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') { |
|
| 8211 | + $values[$key]=''; |
|
| 8212 | + } |
|
| 8213 | + // This is an implicit foreign key field |
|
| 8214 | + if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') { |
|
| 8215 | + $values[$key]=''; |
|
| 8216 | + } |
|
| 8217 | + // This is an explicit foreign key field |
|
| 7688 | 8218 | |
| 7689 | 8219 | //var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1)); |
| 7690 | 8220 | /* |
@@ -7751,11 +8281,13 @@ discard block |
||
| 7751 | 8281 | |
| 7752 | 8282 | $this->db->begin(); |
| 7753 | 8283 | |
| 7754 | - if ($forcechilddeletion) // Force also delete of childtables that should lock deletion in standard case when option force is off |
|
| 8284 | + if ($forcechilddeletion) { |
|
| 8285 | + // Force also delete of childtables that should lock deletion in standard case when option force is off |
|
| 7755 | 8286 | { |
| 7756 | 8287 | foreach($this->childtables as $table) |
| 7757 | 8288 | { |
| 7758 | 8289 | $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id; |
| 8290 | + } |
|
| 7759 | 8291 | $resql = $this->db->query($sql); |
| 7760 | 8292 | if (! $resql) |
| 7761 | 8293 | { |
@@ -7765,10 +8297,11 @@ discard block |
||
| 7765 | 8297 | return -1; |
| 7766 | 8298 | } |
| 7767 | 8299 | } |
| 7768 | - } |
|
| 7769 | - elseif (! empty($this->fk_element) && ! empty($this->childtables)) // If object has childs linked with a foreign key field, we check all child tables. |
|
| 8300 | + } elseif (! empty($this->fk_element) && ! empty($this->childtables)) { |
|
| 8301 | + // If object has childs linked with a foreign key field, we check all child tables. |
|
| 7770 | 8302 | { |
| 7771 | 8303 | $objectisused = $this->isObjectUsed($this->id); |
| 8304 | + } |
|
| 7772 | 8305 | if (! empty($objectisused)) |
| 7773 | 8306 | { |
| 7774 | 8307 | dol_syslog(get_class($this)."::deleteCommon Can't delete record as it has some child", LOG_WARNING); |
@@ -7857,7 +8390,9 @@ discard block |
||
| 7857 | 8390 | |
| 7858 | 8391 | // Call trigger |
| 7859 | 8392 | $result=$this->call_trigger('LINE'.strtoupper($tmpforobjectclass).'_DELETE', $user); |
| 7860 | - if ($result < 0) return -1; |
|
| 8393 | + if ($result < 0) { |
|
| 8394 | + return -1; |
|
| 8395 | + } |
|
| 7861 | 8396 | // End call triggers |
| 7862 | 8397 | |
| 7863 | 8398 | $this->db->begin(); |
@@ -7875,9 +8410,11 @@ discard block |
||
| 7875 | 8410 | |
| 7876 | 8411 | if (empty($error)) { |
| 7877 | 8412 | // Remove extrafields |
| 7878 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 8413 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 8414 | + // For avoid conflicts if trigger used |
|
| 7879 | 8415 | { |
| 7880 | 8416 | $tmpobjectline = new $tmpforobjectlineclass($this->db); |
| 8417 | + } |
|
| 7881 | 8418 | $tmpobjectline->id= $idline; |
| 7882 | 8419 | $result=$tmpobjectline->deleteExtraFields(); |
| 7883 | 8420 | if ($result < 0) |
@@ -7928,7 +8465,9 @@ discard block |
||
| 7928 | 8465 | if (! $error && ! $notrigger) { |
| 7929 | 8466 | // Call trigger |
| 7930 | 8467 | $result=$this->call_trigger($triggercode, $user); |
| 7931 | - if ($result < 0) $error++; |
|
| 8468 | + if ($result < 0) { |
|
| 8469 | + $error++; |
|
| 8470 | + } |
|
| 7932 | 8471 | } |
| 7933 | 8472 | |
| 7934 | 8473 | if (!$error) { |
@@ -7939,8 +8478,7 @@ discard block |
||
| 7939 | 8478 | $this->db->rollback(); |
| 7940 | 8479 | return -1; |
| 7941 | 8480 | } |
| 7942 | - } |
|
| 7943 | - else |
|
| 8481 | + } else |
|
| 7944 | 8482 | { |
| 7945 | 8483 | $this->error=$this->db->error(); |
| 7946 | 8484 | $this->db->rollback(); |
@@ -7960,14 +8498,30 @@ discard block |
||
| 7960 | 8498 | global $user; |
| 7961 | 8499 | |
| 7962 | 8500 | $this->id = 0; |
| 7963 | - if (array_key_exists('label', $this->fields)) $this->label='This is label'; |
|
| 7964 | - if (array_key_exists('note_public', $this->fields)) $this->note_public='Public note'; |
|
| 7965 | - if (array_key_exists('note_private', $this->fields)) $this->note_private='Private note'; |
|
| 7966 | - if (array_key_exists('date_creation', $this->fields)) $this->date_creation=(dol_now()-3600*24); |
|
| 7967 | - if (array_key_exists('date_modification', $this->fields)) $this->date_modification=(dol_now()-3600*24); |
|
| 7968 | - if (array_key_exists('fk_user_creat', $this->fields)) $this->fk_user_creat=$user->id; |
|
| 7969 | - if (array_key_exists('fk_user_modif', $this->fields)) $this->fk_user_modif=$user->id; |
|
| 7970 | - if (array_key_exists('date', $this->fields)) $this->date=dol_now(); |
|
| 8501 | + if (array_key_exists('label', $this->fields)) { |
|
| 8502 | + $this->label='This is label'; |
|
| 8503 | + } |
|
| 8504 | + if (array_key_exists('note_public', $this->fields)) { |
|
| 8505 | + $this->note_public='Public note'; |
|
| 8506 | + } |
|
| 8507 | + if (array_key_exists('note_private', $this->fields)) { |
|
| 8508 | + $this->note_private='Private note'; |
|
| 8509 | + } |
|
| 8510 | + if (array_key_exists('date_creation', $this->fields)) { |
|
| 8511 | + $this->date_creation=(dol_now()-3600*24); |
|
| 8512 | + } |
|
| 8513 | + if (array_key_exists('date_modification', $this->fields)) { |
|
| 8514 | + $this->date_modification=(dol_now()-3600*24); |
|
| 8515 | + } |
|
| 8516 | + if (array_key_exists('fk_user_creat', $this->fields)) { |
|
| 8517 | + $this->fk_user_creat=$user->id; |
|
| 8518 | + } |
|
| 8519 | + if (array_key_exists('fk_user_modif', $this->fields)) { |
|
| 8520 | + $this->fk_user_modif=$user->id; |
|
| 8521 | + } |
|
| 8522 | + if (array_key_exists('date', $this->fields)) { |
|
| 8523 | + $this->date=dol_now(); |
|
| 8524 | + } |
|
| 7971 | 8525 | // ... |
| 7972 | 8526 | } |
| 7973 | 8527 | |
@@ -8011,7 +8565,9 @@ discard block |
||
| 8011 | 8565 | */ |
| 8012 | 8566 | public function trimParameters($parameters) |
| 8013 | 8567 | { |
| 8014 | - if (!is_array($parameters)) return; |
|
| 8568 | + if (!is_array($parameters)) { |
|
| 8569 | + return; |
|
| 8570 | + } |
|
| 8015 | 8571 | foreach ($parameters as $parameter) { |
| 8016 | 8572 | if (isset($this->$parameter)) { |
| 8017 | 8573 | $this->$parameter = trim($this->$parameter); |
@@ -8031,7 +8587,9 @@ discard block |
||
| 8031 | 8587 | { |
| 8032 | 8588 | $this->db->begin(); |
| 8033 | 8589 | |
| 8034 | - if (empty($type)) $type = $this->table_element; |
|
| 8590 | + if (empty($type)) { |
|
| 8591 | + $type = $this->table_element; |
|
| 8592 | + } |
|
| 8035 | 8593 | |
| 8036 | 8594 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
| 8037 | 8595 | $categorystatic = new Categorie($this->db); |
@@ -27,265 +27,265 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class FormWebsite |
| 29 | 29 | { |
| 30 | - private $db; |
|
| 30 | + private $db; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | + /** |
|
| 33 | 33 | * @var string Error code (or message) |
| 34 | 34 | */ |
| 35 | 35 | public $error; |
| 36 | 36 | |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Constructor |
|
| 40 | - * |
|
| 41 | - * @param DoliDB $db Database handler |
|
| 42 | - */ |
|
| 43 | - public function __construct($db) |
|
| 44 | - { |
|
| 45 | - $this->db = $db; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Return HTML select list of websites |
|
| 51 | - * |
|
| 52 | - * @param string $selected Id modele pre-selectionne |
|
| 53 | - * @param string $htmlname Name of HTML select |
|
| 54 | - * @param int $useempty Show empty value or not |
|
| 55 | - * @return string Html component |
|
| 56 | - */ |
|
| 57 | - public function selectWebsite($selected = '', $htmlname = 'exportmodelid', $useempty = 0) |
|
| 58 | - { |
|
| 59 | - $out=''; |
|
| 60 | - |
|
| 61 | - $sql = "SELECT rowid, ref"; |
|
| 62 | - $sql.= " FROM ".MAIN_DB_PREFIX."website"; |
|
| 63 | - $sql.= " WHERE 1 = 1"; |
|
| 64 | - $sql.= " ORDER BY rowid"; |
|
| 65 | - $result = $this->db->query($sql); |
|
| 66 | - if ($result) |
|
| 67 | - { |
|
| 68 | - $out.='<select class="flat minwidth100" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 69 | - if ($useempty) |
|
| 70 | - { |
|
| 71 | - $out.='<option value="-1"> </option>'; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - $num = $this->db->num_rows($result); |
|
| 75 | - $i = 0; |
|
| 76 | - while ($i < $num) |
|
| 77 | - { |
|
| 78 | - $obj = $this->db->fetch_object($result); |
|
| 79 | - if ($selected == $obj->rowid) |
|
| 80 | - { |
|
| 81 | - $out.='<option value="'.$obj->rowid.'" selected>'; |
|
| 82 | - } |
|
| 83 | - else |
|
| 84 | - { |
|
| 85 | - $out.='<option value="'.$obj->rowid.'">'; |
|
| 86 | - } |
|
| 87 | - $out.=$obj->ref; |
|
| 88 | - $out.='</option>'; |
|
| 89 | - $i++; |
|
| 90 | - } |
|
| 91 | - $out.="</select>"; |
|
| 92 | - } |
|
| 93 | - else { |
|
| 94 | - dol_print_error($this->db); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - return $out; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Return a HTML select list of type of containers from the dictionary |
|
| 103 | - * |
|
| 104 | - * @param string $htmlname Name of select zone |
|
| 105 | - * @param string $selected Selected value |
|
| 106 | - * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. |
|
| 107 | - * @param string $moreattrib More attributes on HTML select tag |
|
| 108 | - * @return void |
|
| 109 | - */ |
|
| 110 | - public function selectTypeOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '') |
|
| 111 | - { |
|
| 112 | - global $langs, $conf, $user; |
|
| 113 | - |
|
| 114 | - $langs->load("admin"); |
|
| 115 | - |
|
| 116 | - $sql = "SELECT rowid, code, label, entity"; |
|
| 117 | - $sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container'; |
|
| 118 | - $sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")"; |
|
| 119 | - $sql.= " ORDER BY label"; |
|
| 120 | - |
|
| 121 | - dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG); |
|
| 122 | - $result = $this->db->query($sql); |
|
| 123 | - if ($result) |
|
| 124 | - { |
|
| 125 | - $num = $this->db->num_rows($result); |
|
| 126 | - $i = 0; |
|
| 127 | - if ($num) |
|
| 128 | - { |
|
| 129 | - print '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>'; |
|
| 130 | - if ($useempty == 1 || ($useempty == 2 && $num > 1)) |
|
| 131 | - { |
|
| 132 | - print '<option value="-1"> </option>'; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - while ($i < $num) |
|
| 136 | - { |
|
| 137 | - $obj = $this->db->fetch_object($result); |
|
| 138 | - if ($selected == $obj->rowid || $selected == $obj->code) |
|
| 139 | - { |
|
| 140 | - print '<option value="'.$obj->code.'" selected>'; |
|
| 141 | - } |
|
| 142 | - else |
|
| 143 | - { |
|
| 144 | - print '<option value="'.$obj->code.'">'; |
|
| 145 | - } |
|
| 146 | - print $obj->label; |
|
| 147 | - print '</option>'; |
|
| 148 | - $i++; |
|
| 149 | - } |
|
| 150 | - print "</select>"; |
|
| 151 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 152 | - } |
|
| 153 | - else |
|
| 154 | - { |
|
| 155 | - print $langs->trans("NoTypeOfPagePleaseEditDictionary"); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - else { |
|
| 159 | - dol_print_error($this->db); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Return a HTML select list of samples of containers content |
|
| 166 | - * |
|
| 167 | - * @param string $htmlname Name of select zone |
|
| 168 | - * @param string $selected Selected value |
|
| 169 | - * @param int $useempty 1=Add an empty value in list |
|
| 170 | - * @param string $moreattrib More attributes on HTML select tag |
|
| 171 | - * @return string HTML select component with list of type of containers |
|
| 172 | - */ |
|
| 173 | - public function selectSampleOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '') |
|
| 174 | - { |
|
| 175 | - global $langs, $conf, $user; |
|
| 176 | - |
|
| 177 | - $langs->load("admin"); |
|
| 178 | - |
|
| 179 | - $listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.'/website/samples', 'files', 0, '^page-sample-.*\.html$'); |
|
| 180 | - |
|
| 181 | - $arrayofsamples = array(); |
|
| 182 | - $arrayofsamples['empty']='EmptyPage'; // Always this one first |
|
| 183 | - foreach($listofsamples as $sample) |
|
| 184 | - { |
|
| 185 | - $reg = array(); |
|
| 186 | - if (preg_match('/^page-sample-(.*)\.html$/', $sample['name'], $reg)) |
|
| 187 | - { |
|
| 188 | - $key = $reg[1]; |
|
| 189 | - $labelkey = ucfirst($key); |
|
| 190 | - if ($key == 'empty') $labelkey = 'EmptyPage'; |
|
| 191 | - $arrayofsamples[$key] = $labelkey; |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - $out = ''; |
|
| 196 | - $out .= '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>'; |
|
| 197 | - |
|
| 198 | - if ($useempty == 1 || $useempty == 2) |
|
| 199 | - { |
|
| 200 | - $out .= '<option value="-1"> </option>'; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - foreach($arrayofsamples as $key => $val) |
|
| 204 | - { |
|
| 205 | - if ($selected == $key) |
|
| 206 | - { |
|
| 207 | - $out .= '<option value="'.$key.'" selected>'; |
|
| 208 | - } |
|
| 209 | - else |
|
| 210 | - { |
|
| 211 | - $out .= '<option value="'.$key.'">'; |
|
| 212 | - } |
|
| 213 | - $out .= $langs->trans($val); |
|
| 214 | - $out .= '</option>'; |
|
| 215 | - } |
|
| 216 | - $out .= "</select>"; |
|
| 217 | - |
|
| 218 | - return $out; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * Return a HTML select list of containers of a website. |
|
| 224 | - * Note: $website->lines must have been loaded. |
|
| 225 | - * |
|
| 226 | - * @param Website $website Object Website |
|
| 227 | - * @param string $htmlname Name of select zone |
|
| 228 | - * @param int $pageid Preselected container ID |
|
| 229 | - * @param int $showempty Show empty record |
|
| 230 | - * @param string $action Action on page that use this select list |
|
| 231 | - * @return string HTML select component with list of type of containers |
|
| 232 | - */ |
|
| 233 | - public function selectContainer($website, $htmlname = 'pageid', $pageid = 0, $showempty = 0, $action = '') |
|
| 234 | - { |
|
| 235 | - global $langs; |
|
| 236 | - |
|
| 237 | - $atleastonepage = (is_array($website->lines) && count($website->lines) > 0); |
|
| 238 | - |
|
| 239 | - $out=''; |
|
| 240 | - if ($atleastonepage && $action != 'editsource') |
|
| 241 | - { |
|
| 242 | - $out.='<select name="'.$htmlname.'" id="'.$htmlname.'" class="minwidth200 maxwidth300">'; |
|
| 243 | - } |
|
| 244 | - else |
|
| 245 | - { |
|
| 246 | - $out.='<select name="pageidbis" id="pageid" class="minwidth200 maxwidth300" disabled="disabled">'; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - if ($showempty || ! $atleastonepage) $out.='<option value="-1"> </option>'; |
|
| 250 | - |
|
| 251 | - if ($atleastonepage) |
|
| 252 | - { |
|
| 253 | - if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one |
|
| 254 | - { |
|
| 255 | - $firstpageid=0;$homepageid=0; |
|
| 256 | - foreach($website->lines as $key => $valpage) |
|
| 257 | - { |
|
| 258 | - if (empty($firstpageid)) $firstpageid=$valpage->id; |
|
| 259 | - if ($website->fk_default_home && $key == $website->fk_default_home) $homepageid=$valpage->id; |
|
| 260 | - } |
|
| 261 | - $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - foreach($website->lines as $key => $valpage) |
|
| 265 | - { |
|
| 266 | - $valueforoption = '<span class="opacitymedium">['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).']</span> '; |
|
| 267 | - $valueforoption.= $valpage->pageurl.' - '.$valpage->title; |
|
| 268 | - if ($website->fk_default_home && $key == $website->fk_default_home) $valueforoption.=' <span class="opacitymedium">('.$langs->trans("HomePage").')</span>'; |
|
| 269 | - |
|
| 270 | - $out.='<option value="'.$key.'"'; |
|
| 271 | - if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value |
|
| 272 | - $out.=' data-html="'.dol_escape_htmltag($valueforoption).'"'; |
|
| 273 | - $out.='>'; |
|
| 274 | - $out.=$valueforoption; |
|
| 275 | - $out.='</option>'; |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - $out.='</select>'; |
|
| 279 | - |
|
| 280 | - if ($atleastonepage && $action != 'editsource') |
|
| 281 | - { |
|
| 282 | - $out.=ajax_combobox($htmlname); |
|
| 283 | - } |
|
| 284 | - else |
|
| 285 | - { |
|
| 286 | - $out.='<input type="hidden" name="'.$htmlname.'" value="'.$pageid.'">'; |
|
| 287 | - $out.=ajax_combobox($htmlname); |
|
| 288 | - } |
|
| 289 | - return $out; |
|
| 38 | + /** |
|
| 39 | + * Constructor |
|
| 40 | + * |
|
| 41 | + * @param DoliDB $db Database handler |
|
| 42 | + */ |
|
| 43 | + public function __construct($db) |
|
| 44 | + { |
|
| 45 | + $this->db = $db; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Return HTML select list of websites |
|
| 51 | + * |
|
| 52 | + * @param string $selected Id modele pre-selectionne |
|
| 53 | + * @param string $htmlname Name of HTML select |
|
| 54 | + * @param int $useempty Show empty value or not |
|
| 55 | + * @return string Html component |
|
| 56 | + */ |
|
| 57 | + public function selectWebsite($selected = '', $htmlname = 'exportmodelid', $useempty = 0) |
|
| 58 | + { |
|
| 59 | + $out=''; |
|
| 60 | + |
|
| 61 | + $sql = "SELECT rowid, ref"; |
|
| 62 | + $sql.= " FROM ".MAIN_DB_PREFIX."website"; |
|
| 63 | + $sql.= " WHERE 1 = 1"; |
|
| 64 | + $sql.= " ORDER BY rowid"; |
|
| 65 | + $result = $this->db->query($sql); |
|
| 66 | + if ($result) |
|
| 67 | + { |
|
| 68 | + $out.='<select class="flat minwidth100" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 69 | + if ($useempty) |
|
| 70 | + { |
|
| 71 | + $out.='<option value="-1"> </option>'; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + $num = $this->db->num_rows($result); |
|
| 75 | + $i = 0; |
|
| 76 | + while ($i < $num) |
|
| 77 | + { |
|
| 78 | + $obj = $this->db->fetch_object($result); |
|
| 79 | + if ($selected == $obj->rowid) |
|
| 80 | + { |
|
| 81 | + $out.='<option value="'.$obj->rowid.'" selected>'; |
|
| 82 | + } |
|
| 83 | + else |
|
| 84 | + { |
|
| 85 | + $out.='<option value="'.$obj->rowid.'">'; |
|
| 86 | + } |
|
| 87 | + $out.=$obj->ref; |
|
| 88 | + $out.='</option>'; |
|
| 89 | + $i++; |
|
| 90 | + } |
|
| 91 | + $out.="</select>"; |
|
| 92 | + } |
|
| 93 | + else { |
|
| 94 | + dol_print_error($this->db); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + return $out; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Return a HTML select list of type of containers from the dictionary |
|
| 103 | + * |
|
| 104 | + * @param string $htmlname Name of select zone |
|
| 105 | + * @param string $selected Selected value |
|
| 106 | + * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. |
|
| 107 | + * @param string $moreattrib More attributes on HTML select tag |
|
| 108 | + * @return void |
|
| 109 | + */ |
|
| 110 | + public function selectTypeOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '') |
|
| 111 | + { |
|
| 112 | + global $langs, $conf, $user; |
|
| 113 | + |
|
| 114 | + $langs->load("admin"); |
|
| 115 | + |
|
| 116 | + $sql = "SELECT rowid, code, label, entity"; |
|
| 117 | + $sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container'; |
|
| 118 | + $sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")"; |
|
| 119 | + $sql.= " ORDER BY label"; |
|
| 120 | + |
|
| 121 | + dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG); |
|
| 122 | + $result = $this->db->query($sql); |
|
| 123 | + if ($result) |
|
| 124 | + { |
|
| 125 | + $num = $this->db->num_rows($result); |
|
| 126 | + $i = 0; |
|
| 127 | + if ($num) |
|
| 128 | + { |
|
| 129 | + print '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>'; |
|
| 130 | + if ($useempty == 1 || ($useempty == 2 && $num > 1)) |
|
| 131 | + { |
|
| 132 | + print '<option value="-1"> </option>'; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + while ($i < $num) |
|
| 136 | + { |
|
| 137 | + $obj = $this->db->fetch_object($result); |
|
| 138 | + if ($selected == $obj->rowid || $selected == $obj->code) |
|
| 139 | + { |
|
| 140 | + print '<option value="'.$obj->code.'" selected>'; |
|
| 141 | + } |
|
| 142 | + else |
|
| 143 | + { |
|
| 144 | + print '<option value="'.$obj->code.'">'; |
|
| 145 | + } |
|
| 146 | + print $obj->label; |
|
| 147 | + print '</option>'; |
|
| 148 | + $i++; |
|
| 149 | + } |
|
| 150 | + print "</select>"; |
|
| 151 | + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 152 | + } |
|
| 153 | + else |
|
| 154 | + { |
|
| 155 | + print $langs->trans("NoTypeOfPagePleaseEditDictionary"); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + else { |
|
| 159 | + dol_print_error($this->db); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Return a HTML select list of samples of containers content |
|
| 166 | + * |
|
| 167 | + * @param string $htmlname Name of select zone |
|
| 168 | + * @param string $selected Selected value |
|
| 169 | + * @param int $useempty 1=Add an empty value in list |
|
| 170 | + * @param string $moreattrib More attributes on HTML select tag |
|
| 171 | + * @return string HTML select component with list of type of containers |
|
| 172 | + */ |
|
| 173 | + public function selectSampleOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '') |
|
| 174 | + { |
|
| 175 | + global $langs, $conf, $user; |
|
| 176 | + |
|
| 177 | + $langs->load("admin"); |
|
| 178 | + |
|
| 179 | + $listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.'/website/samples', 'files', 0, '^page-sample-.*\.html$'); |
|
| 180 | + |
|
| 181 | + $arrayofsamples = array(); |
|
| 182 | + $arrayofsamples['empty']='EmptyPage'; // Always this one first |
|
| 183 | + foreach($listofsamples as $sample) |
|
| 184 | + { |
|
| 185 | + $reg = array(); |
|
| 186 | + if (preg_match('/^page-sample-(.*)\.html$/', $sample['name'], $reg)) |
|
| 187 | + { |
|
| 188 | + $key = $reg[1]; |
|
| 189 | + $labelkey = ucfirst($key); |
|
| 190 | + if ($key == 'empty') $labelkey = 'EmptyPage'; |
|
| 191 | + $arrayofsamples[$key] = $labelkey; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + $out = ''; |
|
| 196 | + $out .= '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>'; |
|
| 197 | + |
|
| 198 | + if ($useempty == 1 || $useempty == 2) |
|
| 199 | + { |
|
| 200 | + $out .= '<option value="-1"> </option>'; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + foreach($arrayofsamples as $key => $val) |
|
| 204 | + { |
|
| 205 | + if ($selected == $key) |
|
| 206 | + { |
|
| 207 | + $out .= '<option value="'.$key.'" selected>'; |
|
| 208 | + } |
|
| 209 | + else |
|
| 210 | + { |
|
| 211 | + $out .= '<option value="'.$key.'">'; |
|
| 212 | + } |
|
| 213 | + $out .= $langs->trans($val); |
|
| 214 | + $out .= '</option>'; |
|
| 215 | + } |
|
| 216 | + $out .= "</select>"; |
|
| 217 | + |
|
| 218 | + return $out; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * Return a HTML select list of containers of a website. |
|
| 224 | + * Note: $website->lines must have been loaded. |
|
| 225 | + * |
|
| 226 | + * @param Website $website Object Website |
|
| 227 | + * @param string $htmlname Name of select zone |
|
| 228 | + * @param int $pageid Preselected container ID |
|
| 229 | + * @param int $showempty Show empty record |
|
| 230 | + * @param string $action Action on page that use this select list |
|
| 231 | + * @return string HTML select component with list of type of containers |
|
| 232 | + */ |
|
| 233 | + public function selectContainer($website, $htmlname = 'pageid', $pageid = 0, $showempty = 0, $action = '') |
|
| 234 | + { |
|
| 235 | + global $langs; |
|
| 236 | + |
|
| 237 | + $atleastonepage = (is_array($website->lines) && count($website->lines) > 0); |
|
| 238 | + |
|
| 239 | + $out=''; |
|
| 240 | + if ($atleastonepage && $action != 'editsource') |
|
| 241 | + { |
|
| 242 | + $out.='<select name="'.$htmlname.'" id="'.$htmlname.'" class="minwidth200 maxwidth300">'; |
|
| 243 | + } |
|
| 244 | + else |
|
| 245 | + { |
|
| 246 | + $out.='<select name="pageidbis" id="pageid" class="minwidth200 maxwidth300" disabled="disabled">'; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + if ($showempty || ! $atleastonepage) $out.='<option value="-1"> </option>'; |
|
| 250 | + |
|
| 251 | + if ($atleastonepage) |
|
| 252 | + { |
|
| 253 | + if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one |
|
| 254 | + { |
|
| 255 | + $firstpageid=0;$homepageid=0; |
|
| 256 | + foreach($website->lines as $key => $valpage) |
|
| 257 | + { |
|
| 258 | + if (empty($firstpageid)) $firstpageid=$valpage->id; |
|
| 259 | + if ($website->fk_default_home && $key == $website->fk_default_home) $homepageid=$valpage->id; |
|
| 260 | + } |
|
| 261 | + $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + foreach($website->lines as $key => $valpage) |
|
| 265 | + { |
|
| 266 | + $valueforoption = '<span class="opacitymedium">['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).']</span> '; |
|
| 267 | + $valueforoption.= $valpage->pageurl.' - '.$valpage->title; |
|
| 268 | + if ($website->fk_default_home && $key == $website->fk_default_home) $valueforoption.=' <span class="opacitymedium">('.$langs->trans("HomePage").')</span>'; |
|
| 269 | + |
|
| 270 | + $out.='<option value="'.$key.'"'; |
|
| 271 | + if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value |
|
| 272 | + $out.=' data-html="'.dol_escape_htmltag($valueforoption).'"'; |
|
| 273 | + $out.='>'; |
|
| 274 | + $out.=$valueforoption; |
|
| 275 | + $out.='</option>'; |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + $out.='</select>'; |
|
| 279 | + |
|
| 280 | + if ($atleastonepage && $action != 'editsource') |
|
| 281 | + { |
|
| 282 | + $out.=ajax_combobox($htmlname); |
|
| 283 | + } |
|
| 284 | + else |
|
| 285 | + { |
|
| 286 | + $out.='<input type="hidden" name="'.$htmlname.'" value="'.$pageid.'">'; |
|
| 287 | + $out.=ajax_combobox($htmlname); |
|
| 288 | + } |
|
| 289 | + return $out; |
|
| 290 | 290 | } |
| 291 | 291 | } |
@@ -56,19 +56,19 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function selectWebsite($selected = '', $htmlname = 'exportmodelid', $useempty = 0) |
| 58 | 58 | { |
| 59 | - $out=''; |
|
| 59 | + $out = ''; |
|
| 60 | 60 | |
| 61 | 61 | $sql = "SELECT rowid, ref"; |
| 62 | - $sql.= " FROM ".MAIN_DB_PREFIX."website"; |
|
| 63 | - $sql.= " WHERE 1 = 1"; |
|
| 64 | - $sql.= " ORDER BY rowid"; |
|
| 62 | + $sql .= " FROM ".MAIN_DB_PREFIX."website"; |
|
| 63 | + $sql .= " WHERE 1 = 1"; |
|
| 64 | + $sql .= " ORDER BY rowid"; |
|
| 65 | 65 | $result = $this->db->query($sql); |
| 66 | 66 | if ($result) |
| 67 | 67 | { |
| 68 | - $out.='<select class="flat minwidth100" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 68 | + $out .= '<select class="flat minwidth100" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 69 | 69 | if ($useempty) |
| 70 | 70 | { |
| 71 | - $out.='<option value="-1"> </option>'; |
|
| 71 | + $out .= '<option value="-1"> </option>'; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $num = $this->db->num_rows($result); |
@@ -78,17 +78,17 @@ discard block |
||
| 78 | 78 | $obj = $this->db->fetch_object($result); |
| 79 | 79 | if ($selected == $obj->rowid) |
| 80 | 80 | { |
| 81 | - $out.='<option value="'.$obj->rowid.'" selected>'; |
|
| 81 | + $out .= '<option value="'.$obj->rowid.'" selected>'; |
|
| 82 | 82 | } |
| 83 | 83 | else |
| 84 | 84 | { |
| 85 | - $out.='<option value="'.$obj->rowid.'">'; |
|
| 85 | + $out .= '<option value="'.$obj->rowid.'">'; |
|
| 86 | 86 | } |
| 87 | - $out.=$obj->ref; |
|
| 88 | - $out.='</option>'; |
|
| 87 | + $out .= $obj->ref; |
|
| 88 | + $out .= '</option>'; |
|
| 89 | 89 | $i++; |
| 90 | 90 | } |
| 91 | - $out.="</select>"; |
|
| 91 | + $out .= "</select>"; |
|
| 92 | 92 | } |
| 93 | 93 | else { |
| 94 | 94 | dol_print_error($this->db); |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | $langs->load("admin"); |
| 115 | 115 | |
| 116 | 116 | $sql = "SELECT rowid, code, label, entity"; |
| 117 | - $sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container'; |
|
| 118 | - $sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")"; |
|
| 119 | - $sql.= " ORDER BY label"; |
|
| 117 | + $sql .= " FROM ".MAIN_DB_PREFIX.'c_type_container'; |
|
| 118 | + $sql .= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")"; |
|
| 119 | + $sql .= " ORDER BY label"; |
|
| 120 | 120 | |
| 121 | 121 | dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG); |
| 122 | 122 | $result = $this->db->query($sql); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $i = 0; |
| 127 | 127 | if ($num) |
| 128 | 128 | { |
| 129 | - print '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>'; |
|
| 129 | + print '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>'; |
|
| 130 | 130 | if ($useempty == 1 || ($useempty == 2 && $num > 1)) |
| 131 | 131 | { |
| 132 | 132 | print '<option value="-1"> </option>'; |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | $listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.'/website/samples', 'files', 0, '^page-sample-.*\.html$'); |
| 180 | 180 | |
| 181 | 181 | $arrayofsamples = array(); |
| 182 | - $arrayofsamples['empty']='EmptyPage'; // Always this one first |
|
| 183 | - foreach($listofsamples as $sample) |
|
| 182 | + $arrayofsamples['empty'] = 'EmptyPage'; // Always this one first |
|
| 183 | + foreach ($listofsamples as $sample) |
|
| 184 | 184 | { |
| 185 | 185 | $reg = array(); |
| 186 | 186 | if (preg_match('/^page-sample-(.*)\.html$/', $sample['name'], $reg)) |
@@ -193,14 +193,14 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | $out = ''; |
| 196 | - $out .= '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>'; |
|
| 196 | + $out .= '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>'; |
|
| 197 | 197 | |
| 198 | 198 | if ($useempty == 1 || $useempty == 2) |
| 199 | 199 | { |
| 200 | 200 | $out .= '<option value="-1"> </option>'; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - foreach($arrayofsamples as $key => $val) |
|
| 203 | + foreach ($arrayofsamples as $key => $val) |
|
| 204 | 204 | { |
| 205 | 205 | if ($selected == $key) |
| 206 | 206 | { |
@@ -236,55 +236,55 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | $atleastonepage = (is_array($website->lines) && count($website->lines) > 0); |
| 238 | 238 | |
| 239 | - $out=''; |
|
| 239 | + $out = ''; |
|
| 240 | 240 | if ($atleastonepage && $action != 'editsource') |
| 241 | 241 | { |
| 242 | - $out.='<select name="'.$htmlname.'" id="'.$htmlname.'" class="minwidth200 maxwidth300">'; |
|
| 242 | + $out .= '<select name="'.$htmlname.'" id="'.$htmlname.'" class="minwidth200 maxwidth300">'; |
|
| 243 | 243 | } |
| 244 | 244 | else |
| 245 | 245 | { |
| 246 | - $out.='<select name="pageidbis" id="pageid" class="minwidth200 maxwidth300" disabled="disabled">'; |
|
| 246 | + $out .= '<select name="pageidbis" id="pageid" class="minwidth200 maxwidth300" disabled="disabled">'; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if ($showempty || ! $atleastonepage) $out.='<option value="-1"> </option>'; |
|
| 249 | + if ($showempty || !$atleastonepage) $out .= '<option value="-1"> </option>'; |
|
| 250 | 250 | |
| 251 | 251 | if ($atleastonepage) |
| 252 | 252 | { |
| 253 | 253 | if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one |
| 254 | 254 | { |
| 255 | - $firstpageid=0;$homepageid=0; |
|
| 256 | - foreach($website->lines as $key => $valpage) |
|
| 255 | + $firstpageid = 0; $homepageid = 0; |
|
| 256 | + foreach ($website->lines as $key => $valpage) |
|
| 257 | 257 | { |
| 258 | - if (empty($firstpageid)) $firstpageid=$valpage->id; |
|
| 259 | - if ($website->fk_default_home && $key == $website->fk_default_home) $homepageid=$valpage->id; |
|
| 258 | + if (empty($firstpageid)) $firstpageid = $valpage->id; |
|
| 259 | + if ($website->fk_default_home && $key == $website->fk_default_home) $homepageid = $valpage->id; |
|
| 260 | 260 | } |
| 261 | - $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page |
|
| 261 | + $pageid = $homepageid ? $homepageid : $firstpageid; // We choose home page and if not defined yet, we take first page |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - foreach($website->lines as $key => $valpage) |
|
| 264 | + foreach ($website->lines as $key => $valpage) |
|
| 265 | 265 | { |
| 266 | 266 | $valueforoption = '<span class="opacitymedium">['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).']</span> '; |
| 267 | - $valueforoption.= $valpage->pageurl.' - '.$valpage->title; |
|
| 268 | - if ($website->fk_default_home && $key == $website->fk_default_home) $valueforoption.=' <span class="opacitymedium">('.$langs->trans("HomePage").')</span>'; |
|
| 269 | - |
|
| 270 | - $out.='<option value="'.$key.'"'; |
|
| 271 | - if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value |
|
| 272 | - $out.=' data-html="'.dol_escape_htmltag($valueforoption).'"'; |
|
| 273 | - $out.='>'; |
|
| 274 | - $out.=$valueforoption; |
|
| 275 | - $out.='</option>'; |
|
| 267 | + $valueforoption .= $valpage->pageurl.' - '.$valpage->title; |
|
| 268 | + if ($website->fk_default_home && $key == $website->fk_default_home) $valueforoption .= ' <span class="opacitymedium">('.$langs->trans("HomePage").')</span>'; |
|
| 269 | + |
|
| 270 | + $out .= '<option value="'.$key.'"'; |
|
| 271 | + if ($pageid > 0 && $pageid == $key) $out .= ' selected'; // To preselect a value |
|
| 272 | + $out .= ' data-html="'.dol_escape_htmltag($valueforoption).'"'; |
|
| 273 | + $out .= '>'; |
|
| 274 | + $out .= $valueforoption; |
|
| 275 | + $out .= '</option>'; |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | - $out.='</select>'; |
|
| 278 | + $out .= '</select>'; |
|
| 279 | 279 | |
| 280 | 280 | if ($atleastonepage && $action != 'editsource') |
| 281 | 281 | { |
| 282 | - $out.=ajax_combobox($htmlname); |
|
| 282 | + $out .= ajax_combobox($htmlname); |
|
| 283 | 283 | } |
| 284 | 284 | else |
| 285 | 285 | { |
| 286 | - $out.='<input type="hidden" name="'.$htmlname.'" value="'.$pageid.'">'; |
|
| 287 | - $out.=ajax_combobox($htmlname); |
|
| 286 | + $out .= '<input type="hidden" name="'.$htmlname.'" value="'.$pageid.'">'; |
|
| 287 | + $out .= ajax_combobox($htmlname); |
|
| 288 | 288 | } |
| 289 | 289 | return $out; |
| 290 | 290 | } |
@@ -79,8 +79,7 @@ discard block |
||
| 79 | 79 | if ($selected == $obj->rowid) |
| 80 | 80 | { |
| 81 | 81 | $out.='<option value="'.$obj->rowid.'" selected>'; |
| 82 | - } |
|
| 83 | - else |
|
| 82 | + } else |
|
| 84 | 83 | { |
| 85 | 84 | $out.='<option value="'.$obj->rowid.'">'; |
| 86 | 85 | } |
@@ -89,8 +88,7 @@ discard block |
||
| 89 | 88 | $i++; |
| 90 | 89 | } |
| 91 | 90 | $out.="</select>"; |
| 92 | - } |
|
| 93 | - else { |
|
| 91 | + } else { |
|
| 94 | 92 | dol_print_error($this->db); |
| 95 | 93 | } |
| 96 | 94 | |
@@ -138,8 +136,7 @@ discard block |
||
| 138 | 136 | if ($selected == $obj->rowid || $selected == $obj->code) |
| 139 | 137 | { |
| 140 | 138 | print '<option value="'.$obj->code.'" selected>'; |
| 141 | - } |
|
| 142 | - else |
|
| 139 | + } else |
|
| 143 | 140 | { |
| 144 | 141 | print '<option value="'.$obj->code.'">'; |
| 145 | 142 | } |
@@ -148,14 +145,14 @@ discard block |
||
| 148 | 145 | $i++; |
| 149 | 146 | } |
| 150 | 147 | print "</select>"; |
| 151 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 152 | - } |
|
| 153 | - else |
|
| 148 | + if ($user->admin) { |
|
| 149 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 150 | + } |
|
| 151 | + } else |
|
| 154 | 152 | { |
| 155 | 153 | print $langs->trans("NoTypeOfPagePleaseEditDictionary"); |
| 156 | 154 | } |
| 157 | - } |
|
| 158 | - else { |
|
| 155 | + } else { |
|
| 159 | 156 | dol_print_error($this->db); |
| 160 | 157 | } |
| 161 | 158 | } |
@@ -187,7 +184,9 @@ discard block |
||
| 187 | 184 | { |
| 188 | 185 | $key = $reg[1]; |
| 189 | 186 | $labelkey = ucfirst($key); |
| 190 | - if ($key == 'empty') $labelkey = 'EmptyPage'; |
|
| 187 | + if ($key == 'empty') { |
|
| 188 | + $labelkey = 'EmptyPage'; |
|
| 189 | + } |
|
| 191 | 190 | $arrayofsamples[$key] = $labelkey; |
| 192 | 191 | } |
| 193 | 192 | } |
@@ -205,8 +204,7 @@ discard block |
||
| 205 | 204 | if ($selected == $key) |
| 206 | 205 | { |
| 207 | 206 | $out .= '<option value="'.$key.'" selected>'; |
| 208 | - } |
|
| 209 | - else |
|
| 207 | + } else |
|
| 210 | 208 | { |
| 211 | 209 | $out .= '<option value="'.$key.'">'; |
| 212 | 210 | } |
@@ -240,23 +238,31 @@ discard block |
||
| 240 | 238 | if ($atleastonepage && $action != 'editsource') |
| 241 | 239 | { |
| 242 | 240 | $out.='<select name="'.$htmlname.'" id="'.$htmlname.'" class="minwidth200 maxwidth300">'; |
| 243 | - } |
|
| 244 | - else |
|
| 241 | + } else |
|
| 245 | 242 | { |
| 246 | 243 | $out.='<select name="pageidbis" id="pageid" class="minwidth200 maxwidth300" disabled="disabled">'; |
| 247 | 244 | } |
| 248 | 245 | |
| 249 | - if ($showempty || ! $atleastonepage) $out.='<option value="-1"> </option>'; |
|
| 246 | + if ($showempty || ! $atleastonepage) { |
|
| 247 | + $out.='<option value="-1"> </option>'; |
|
| 248 | + } |
|
| 250 | 249 | |
| 251 | 250 | if ($atleastonepage) |
| 252 | 251 | { |
| 253 | - if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one |
|
| 252 | + if (empty($pageid) && $action != 'createcontainer') { |
|
| 253 | + // Page id is not defined, we try to take one |
|
| 254 | 254 | { |
| 255 | - $firstpageid=0;$homepageid=0; |
|
| 255 | + $firstpageid=0; |
|
| 256 | + } |
|
| 257 | + $homepageid=0; |
|
| 256 | 258 | foreach($website->lines as $key => $valpage) |
| 257 | 259 | { |
| 258 | - if (empty($firstpageid)) $firstpageid=$valpage->id; |
|
| 259 | - if ($website->fk_default_home && $key == $website->fk_default_home) $homepageid=$valpage->id; |
|
| 260 | + if (empty($firstpageid)) { |
|
| 261 | + $firstpageid=$valpage->id; |
|
| 262 | + } |
|
| 263 | + if ($website->fk_default_home && $key == $website->fk_default_home) { |
|
| 264 | + $homepageid=$valpage->id; |
|
| 265 | + } |
|
| 260 | 266 | } |
| 261 | 267 | $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page |
| 262 | 268 | } |
@@ -265,10 +271,15 @@ discard block |
||
| 265 | 271 | { |
| 266 | 272 | $valueforoption = '<span class="opacitymedium">['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).']</span> '; |
| 267 | 273 | $valueforoption.= $valpage->pageurl.' - '.$valpage->title; |
| 268 | - if ($website->fk_default_home && $key == $website->fk_default_home) $valueforoption.=' <span class="opacitymedium">('.$langs->trans("HomePage").')</span>'; |
|
| 274 | + if ($website->fk_default_home && $key == $website->fk_default_home) { |
|
| 275 | + $valueforoption.=' <span class="opacitymedium">('.$langs->trans("HomePage").')</span>'; |
|
| 276 | + } |
|
| 269 | 277 | |
| 270 | 278 | $out.='<option value="'.$key.'"'; |
| 271 | - if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value |
|
| 279 | + if ($pageid > 0 && $pageid == $key) { |
|
| 280 | + $out.=' selected'; |
|
| 281 | + } |
|
| 282 | + // To preselect a value |
|
| 272 | 283 | $out.=' data-html="'.dol_escape_htmltag($valueforoption).'"'; |
| 273 | 284 | $out.='>'; |
| 274 | 285 | $out.=$valueforoption; |
@@ -280,8 +291,7 @@ discard block |
||
| 280 | 291 | if ($atleastonepage && $action != 'editsource') |
| 281 | 292 | { |
| 282 | 293 | $out.=ajax_combobox($htmlname); |
| 283 | - } |
|
| 284 | - else |
|
| 294 | + } else |
|
| 285 | 295 | { |
| 286 | 296 | $out.='<input type="hidden" name="'.$htmlname.'" value="'.$pageid.'">'; |
| 287 | 297 | $out.=ajax_combobox($htmlname); |
@@ -20,23 +20,23 @@ discard block |
||
| 20 | 20 | * \brief File to save result of an anonymous ping into database (1 ping is done per installation) |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
| 24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
| 25 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
| 26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
| 27 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
| 28 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
| 23 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
| 24 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
| 25 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
| 26 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
| 27 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
| 28 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
| 29 | 29 | |
| 30 | 30 | require '../../main.inc.php'; |
| 31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; |
| 32 | 32 | |
| 33 | -$action=GETPOST('action', 'alpha'); |
|
| 34 | -$hash_unique_id=GETPOST('hash_unique_id', 'alpha'); |
|
| 35 | -$hash_algo=GETPOST('hash_algo', 'alpha'); |
|
| 33 | +$action = GETPOST('action', 'alpha'); |
|
| 34 | +$hash_unique_id = GETPOST('hash_unique_id', 'alpha'); |
|
| 35 | +$hash_algo = GETPOST('hash_algo', 'alpha'); |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | // Security check |
| 39 | -if (! empty($user->socid)) |
|
| 39 | +if (!empty($user->socid)) |
|
| 40 | 40 | $socid = $user->socid; |
| 41 | 41 | |
| 42 | 42 | $now = dol_now(); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | elseif ($action == 'firstpingko') |
| 65 | 65 | { |
| 66 | 66 | // Note: pings are by installation, done on entity 1. |
| 67 | - dolibarr_set_const($db, 'MAIN_LAST_PING_KO_DATE', dol_print_date($now, 'dayhourlog'), 'gmt'); // erase last value |
|
| 67 | + dolibarr_set_const($db, 'MAIN_LAST_PING_KO_DATE', dol_print_date($now, 'dayhourlog'), 'gmt'); // erase last value |
|
| 68 | 68 | print 'First ping KO saved for entity '.$conf->entity; |
| 69 | 69 | } |
| 70 | 70 | else { |
@@ -20,12 +20,25 @@ discard block |
||
| 20 | 20 | * \brief File to save result of an anonymous ping into database (1 ping is done per installation) |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
| 24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
| 25 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
| 26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
| 27 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
| 28 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
| 23 | +if (! defined('NOTOKENRENEWAL')) { |
|
| 24 | + define('NOTOKENRENEWAL', '1'); |
|
| 25 | +} |
|
| 26 | +// Disables token renewal |
|
| 27 | +if (! defined('NOREQUIREMENU')) { |
|
| 28 | + define('NOREQUIREMENU', '1'); |
|
| 29 | +} |
|
| 30 | +if (! defined('NOREQUIREHTML')) { |
|
| 31 | + define('NOREQUIREHTML', '1'); |
|
| 32 | +} |
|
| 33 | +if (! defined('NOREQUIREAJAX')) { |
|
| 34 | + define('NOREQUIREAJAX', '1'); |
|
| 35 | +} |
|
| 36 | +if (! defined('NOREQUIRESOC')) { |
|
| 37 | + define('NOREQUIRESOC', '1'); |
|
| 38 | +} |
|
| 39 | +if (! defined('NOREQUIRETRAN')) { |
|
| 40 | + define('NOREQUIRETRAN', '1'); |
|
| 41 | +} |
|
| 29 | 42 | |
| 30 | 43 | require '../../main.inc.php'; |
| 31 | 44 | require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; |
@@ -36,8 +49,9 @@ discard block |
||
| 36 | 49 | |
| 37 | 50 | |
| 38 | 51 | // Security check |
| 39 | -if (! empty($user->socid)) |
|
| 52 | +if (! empty($user->socid)) { |
|
| 40 | 53 | $socid = $user->socid; |
| 54 | +} |
|
| 41 | 55 | |
| 42 | 56 | $now = dol_now(); |
| 43 | 57 | |
@@ -66,7 +80,6 @@ discard block |
||
| 66 | 80 | // Note: pings are by installation, done on entity 1. |
| 67 | 81 | dolibarr_set_const($db, 'MAIN_LAST_PING_KO_DATE', dol_print_date($now, 'dayhourlog'), 'gmt'); // erase last value |
| 68 | 82 | print 'First ping KO saved for entity '.$conf->entity; |
| 69 | -} |
|
| 70 | -else { |
|
| 83 | +} else { |
|
| 71 | 84 | print 'Error action='.$action.' not supported'; |
| 72 | 85 | } |