@@ -33,49 +33,49 @@ discard block |
||
| 33 | 33 | class Project extends CommonObject |
| 34 | 34 | { |
| 35 | 35 | |
| 36 | - public $element = 'project'; //!< Id that identify managed objects |
|
| 37 | - public $table_element = 'projet'; //!< Name of table without prefix where object is stored |
|
| 38 | - public $table_element_line = 'projet_task'; |
|
| 39 | - public $fk_element = 'fk_projet'; |
|
| 40 | - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 41 | - public $picto = 'projectpub'; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * {@inheritdoc} |
|
| 45 | - */ |
|
| 46 | - protected $table_ref_field = 'ref'; |
|
| 47 | - |
|
| 48 | - var $description; |
|
| 36 | + public $element = 'project'; //!< Id that identify managed objects |
|
| 37 | + public $table_element = 'projet'; //!< Name of table without prefix where object is stored |
|
| 38 | + public $table_element_line = 'projet_task'; |
|
| 39 | + public $fk_element = 'fk_projet'; |
|
| 40 | + protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 41 | + public $picto = 'projectpub'; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * {@inheritdoc} |
|
| 45 | + */ |
|
| 46 | + protected $table_ref_field = 'ref'; |
|
| 47 | + |
|
| 48 | + var $description; |
|
| 49 | 49 | /** |
| 50 | 50 | * @var string |
| 51 | 51 | * @deprecated |
| 52 | 52 | * @see title |
| 53 | 53 | */ |
| 54 | 54 | public $titre; |
| 55 | - var $title; |
|
| 56 | - var $date_start; |
|
| 57 | - var $date_end; |
|
| 58 | - var $date_close; |
|
| 55 | + var $title; |
|
| 56 | + var $date_start; |
|
| 57 | + var $date_end; |
|
| 58 | + var $date_close; |
|
| 59 | 59 | |
| 60 | - var $socid; // To store id of thirdparty |
|
| 61 | - var $thirdparty_name; // To store name of thirdparty (defined only in some cases) |
|
| 60 | + var $socid; // To store id of thirdparty |
|
| 61 | + var $thirdparty_name; // To store name of thirdparty (defined only in some cases) |
|
| 62 | 62 | |
| 63 | - var $user_author_id; //!< Id of project creator. Not defined if shared project. |
|
| 63 | + var $user_author_id; //!< Id of project creator. Not defined if shared project. |
|
| 64 | 64 | var $user_close_id; |
| 65 | - var $public; //!< Tell if this is a public or private project |
|
| 66 | - var $budget_amount; |
|
| 65 | + var $public; //!< Tell if this is a public or private project |
|
| 66 | + var $budget_amount; |
|
| 67 | 67 | |
| 68 | - var $statuts_short; |
|
| 69 | - var $statuts_long; |
|
| 68 | + var $statuts_short; |
|
| 69 | + var $statuts_long; |
|
| 70 | 70 | |
| 71 | - var $statut; // 0=draft, 1=opened, 2=closed |
|
| 72 | - var $opp_status; // opportunity status, into table llx_c_lead_status |
|
| 71 | + var $statut; // 0=draft, 1=opened, 2=closed |
|
| 72 | + var $opp_status; // opportunity status, into table llx_c_lead_status |
|
| 73 | 73 | var $opp_percent; // opportunity probability |
| 74 | 74 | |
| 75 | - var $oldcopy; |
|
| 75 | + var $oldcopy; |
|
| 76 | 76 | |
| 77 | - var $weekWorkLoad; // Used to store workload details of a projet |
|
| 78 | - var $weekWorkLoadPerTask; // Used to store workload details of tasks of a projet |
|
| 77 | + var $weekWorkLoad; // Used to store workload details of a projet |
|
| 78 | + var $weekWorkLoadPerTask; // Used to store workload details of tasks of a projet |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * @var int Creation date |
@@ -118,411 +118,411 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | |
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Constructor |
|
| 123 | - * |
|
| 124 | - * @param DoliDB $db Database handler |
|
| 125 | - */ |
|
| 126 | - function __construct($db) |
|
| 127 | - { |
|
| 128 | - $this->db = $db; |
|
| 121 | + /** |
|
| 122 | + * Constructor |
|
| 123 | + * |
|
| 124 | + * @param DoliDB $db Database handler |
|
| 125 | + */ |
|
| 126 | + function __construct($db) |
|
| 127 | + { |
|
| 128 | + $this->db = $db; |
|
| 129 | 129 | |
| 130 | - $this->statuts_short = array(0 => 'Draft', 1 => 'Opened', 2 => 'Closed'); |
|
| 131 | - $this->statuts_long = array(0 => 'Draft', 1 => 'Opened', 2 => 'Closed'); |
|
| 132 | - } |
|
| 130 | + $this->statuts_short = array(0 => 'Draft', 1 => 'Opened', 2 => 'Closed'); |
|
| 131 | + $this->statuts_long = array(0 => 'Draft', 1 => 'Opened', 2 => 'Closed'); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * Create a project into database |
|
| 136 | - * |
|
| 137 | - * @param User $user User making creation |
|
| 138 | - * @param int $notrigger Disable triggers |
|
| 139 | - * @return int <0 if KO, id of created project if OK |
|
| 140 | - */ |
|
| 141 | - function create($user, $notrigger=0) |
|
| 142 | - { |
|
| 143 | - global $conf, $langs; |
|
| 134 | + /** |
|
| 135 | + * Create a project into database |
|
| 136 | + * |
|
| 137 | + * @param User $user User making creation |
|
| 138 | + * @param int $notrigger Disable triggers |
|
| 139 | + * @return int <0 if KO, id of created project if OK |
|
| 140 | + */ |
|
| 141 | + function create($user, $notrigger=0) |
|
| 142 | + { |
|
| 143 | + global $conf, $langs; |
|
| 144 | 144 | |
| 145 | - $error = 0; |
|
| 146 | - $ret = 0; |
|
| 145 | + $error = 0; |
|
| 146 | + $ret = 0; |
|
| 147 | 147 | |
| 148 | - $now=dol_now(); |
|
| 148 | + $now=dol_now(); |
|
| 149 | 149 | |
| 150 | - // Check parameters |
|
| 151 | - if (!trim($this->ref)) |
|
| 152 | - { |
|
| 153 | - $this->error = 'ErrorFieldsRequired'; |
|
| 154 | - dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR); |
|
| 155 | - return -1; |
|
| 156 | - } |
|
| 157 | - if (! empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) && ! $this->socid > 0) |
|
| 158 | - { |
|
| 159 | - $this->error = 'ErrorFieldsRequired'; |
|
| 160 | - dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR); |
|
| 161 | - return -1; |
|
| 162 | - } |
|
| 150 | + // Check parameters |
|
| 151 | + if (!trim($this->ref)) |
|
| 152 | + { |
|
| 153 | + $this->error = 'ErrorFieldsRequired'; |
|
| 154 | + dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR); |
|
| 155 | + return -1; |
|
| 156 | + } |
|
| 157 | + if (! empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) && ! $this->socid > 0) |
|
| 158 | + { |
|
| 159 | + $this->error = 'ErrorFieldsRequired'; |
|
| 160 | + dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR); |
|
| 161 | + return -1; |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - $this->db->begin(); |
|
| 165 | - |
|
| 166 | - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "projet ("; |
|
| 167 | - $sql.= "ref"; |
|
| 168 | - $sql.= ", title"; |
|
| 169 | - $sql.= ", description"; |
|
| 170 | - $sql.= ", fk_soc"; |
|
| 171 | - $sql.= ", fk_user_creat"; |
|
| 172 | - $sql.= ", fk_statut"; |
|
| 173 | - $sql.= ", fk_opp_status"; |
|
| 174 | - $sql.= ", opp_percent"; |
|
| 175 | - $sql.= ", public"; |
|
| 176 | - $sql.= ", datec"; |
|
| 177 | - $sql.= ", dateo"; |
|
| 178 | - $sql.= ", datee"; |
|
| 179 | - $sql.= ", opp_amount"; |
|
| 180 | - $sql.= ", budget_amount"; |
|
| 181 | - $sql.= ", entity"; |
|
| 182 | - $sql.= ") VALUES ("; |
|
| 183 | - $sql.= "'" . $this->db->escape($this->ref) . "'"; |
|
| 184 | - $sql.= ", '" . $this->db->escape($this->title) . "'"; |
|
| 185 | - $sql.= ", '" . $this->db->escape($this->description) . "'"; |
|
| 186 | - $sql.= ", " . ($this->socid > 0 ? $this->socid : "null"); |
|
| 187 | - $sql.= ", " . $user->id; |
|
| 188 | - $sql.= ", ".(is_numeric($this->statut) ? $this->statut : '0'); |
|
| 189 | - $sql.= ", ".(is_numeric($this->opp_status) ? $this->opp_status : 'NULL'); |
|
| 190 | - $sql.= ", ".(is_numeric($this->opp_percent) ? $this->opp_percent : 'NULL'); |
|
| 191 | - $sql.= ", " . ($this->public ? 1 : 0); |
|
| 192 | - $sql.= ", '".$this->db->idate($now)."'"; |
|
| 193 | - $sql.= ", " . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); |
|
| 194 | - $sql.= ", " . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); |
|
| 195 | - $sql.= ", " . (strcmp($this->opp_amount,'') ? price2num($this->opp_amount) : 'null'); |
|
| 196 | - $sql.= ", " . (strcmp($this->budget_amount,'') ? price2num($this->budget_amount) : 'null'); |
|
| 197 | - $sql.= ", ".$conf->entity; |
|
| 198 | - $sql.= ")"; |
|
| 199 | - |
|
| 200 | - dol_syslog(get_class($this)."::create", LOG_DEBUG); |
|
| 201 | - $resql = $this->db->query($sql); |
|
| 202 | - if ($resql) |
|
| 203 | - { |
|
| 204 | - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "projet"); |
|
| 205 | - $ret = $this->id; |
|
| 206 | - |
|
| 207 | - if (!$notrigger) |
|
| 208 | - { |
|
| 209 | - // Call trigger |
|
| 210 | - $result=$this->call_trigger('PROJECT_CREATE',$user); |
|
| 211 | - if ($result < 0) { $error++; } |
|
| 212 | - // End call triggers |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - else |
|
| 216 | - { |
|
| 217 | - $this->error = $this->db->lasterror(); |
|
| 218 | - $this->errno = $this->db->lasterrno(); |
|
| 219 | - $error++; |
|
| 220 | - } |
|
| 164 | + $this->db->begin(); |
|
| 221 | 165 | |
| 222 | - // Update extrafield |
|
| 223 | - if (!$error) { |
|
| 224 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 225 | - { |
|
| 226 | - $result=$this->insertExtraFields(); |
|
| 227 | - if ($result < 0) |
|
| 228 | - { |
|
| 229 | - $error++; |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - } |
|
| 166 | + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "projet ("; |
|
| 167 | + $sql.= "ref"; |
|
| 168 | + $sql.= ", title"; |
|
| 169 | + $sql.= ", description"; |
|
| 170 | + $sql.= ", fk_soc"; |
|
| 171 | + $sql.= ", fk_user_creat"; |
|
| 172 | + $sql.= ", fk_statut"; |
|
| 173 | + $sql.= ", fk_opp_status"; |
|
| 174 | + $sql.= ", opp_percent"; |
|
| 175 | + $sql.= ", public"; |
|
| 176 | + $sql.= ", datec"; |
|
| 177 | + $sql.= ", dateo"; |
|
| 178 | + $sql.= ", datee"; |
|
| 179 | + $sql.= ", opp_amount"; |
|
| 180 | + $sql.= ", budget_amount"; |
|
| 181 | + $sql.= ", entity"; |
|
| 182 | + $sql.= ") VALUES ("; |
|
| 183 | + $sql.= "'" . $this->db->escape($this->ref) . "'"; |
|
| 184 | + $sql.= ", '" . $this->db->escape($this->title) . "'"; |
|
| 185 | + $sql.= ", '" . $this->db->escape($this->description) . "'"; |
|
| 186 | + $sql.= ", " . ($this->socid > 0 ? $this->socid : "null"); |
|
| 187 | + $sql.= ", " . $user->id; |
|
| 188 | + $sql.= ", ".(is_numeric($this->statut) ? $this->statut : '0'); |
|
| 189 | + $sql.= ", ".(is_numeric($this->opp_status) ? $this->opp_status : 'NULL'); |
|
| 190 | + $sql.= ", ".(is_numeric($this->opp_percent) ? $this->opp_percent : 'NULL'); |
|
| 191 | + $sql.= ", " . ($this->public ? 1 : 0); |
|
| 192 | + $sql.= ", '".$this->db->idate($now)."'"; |
|
| 193 | + $sql.= ", " . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); |
|
| 194 | + $sql.= ", " . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); |
|
| 195 | + $sql.= ", " . (strcmp($this->opp_amount,'') ? price2num($this->opp_amount) : 'null'); |
|
| 196 | + $sql.= ", " . (strcmp($this->budget_amount,'') ? price2num($this->budget_amount) : 'null'); |
|
| 197 | + $sql.= ", ".$conf->entity; |
|
| 198 | + $sql.= ")"; |
|
| 199 | + |
|
| 200 | + dol_syslog(get_class($this)."::create", LOG_DEBUG); |
|
| 201 | + $resql = $this->db->query($sql); |
|
| 202 | + if ($resql) |
|
| 203 | + { |
|
| 204 | + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "projet"); |
|
| 205 | + $ret = $this->id; |
|
| 233 | 206 | |
| 234 | - if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) |
|
| 235 | - { |
|
| 236 | - $res = $this->setValid($user); |
|
| 237 | - if ($res < 0) $error++; |
|
| 238 | - } |
|
| 207 | + if (!$notrigger) |
|
| 208 | + { |
|
| 209 | + // Call trigger |
|
| 210 | + $result=$this->call_trigger('PROJECT_CREATE',$user); |
|
| 211 | + if ($result < 0) { $error++; } |
|
| 212 | + // End call triggers |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + else |
|
| 216 | + { |
|
| 217 | + $this->error = $this->db->lasterror(); |
|
| 218 | + $this->errno = $this->db->lasterrno(); |
|
| 219 | + $error++; |
|
| 220 | + } |
|
| 239 | 221 | |
| 240 | - if (!$error) |
|
| 241 | - { |
|
| 242 | - $this->db->commit(); |
|
| 243 | - return $ret; |
|
| 244 | - } |
|
| 245 | - else |
|
| 246 | - { |
|
| 247 | - $this->db->rollback(); |
|
| 248 | - return -1; |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Update a project |
|
| 254 | - * |
|
| 255 | - * @param User $user User object of making update |
|
| 256 | - * @param int $notrigger 1=Disable all triggers |
|
| 257 | - * @return int <=0 if KO, >0 if OK |
|
| 258 | - */ |
|
| 259 | - function update($user, $notrigger=0) |
|
| 260 | - { |
|
| 261 | - global $langs, $conf; |
|
| 222 | + // Update extrafield |
|
| 223 | + if (!$error) { |
|
| 224 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 225 | + { |
|
| 226 | + $result=$this->insertExtraFields(); |
|
| 227 | + if ($result < 0) |
|
| 228 | + { |
|
| 229 | + $error++; |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) |
|
| 235 | + { |
|
| 236 | + $res = $this->setValid($user); |
|
| 237 | + if ($res < 0) $error++; |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + if (!$error) |
|
| 241 | + { |
|
| 242 | + $this->db->commit(); |
|
| 243 | + return $ret; |
|
| 244 | + } |
|
| 245 | + else |
|
| 246 | + { |
|
| 247 | + $this->db->rollback(); |
|
| 248 | + return -1; |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Update a project |
|
| 254 | + * |
|
| 255 | + * @param User $user User object of making update |
|
| 256 | + * @param int $notrigger 1=Disable all triggers |
|
| 257 | + * @return int <=0 if KO, >0 if OK |
|
| 258 | + */ |
|
| 259 | + function update($user, $notrigger=0) |
|
| 260 | + { |
|
| 261 | + global $langs, $conf; |
|
| 262 | 262 | |
| 263 | 263 | $error=0; |
| 264 | 264 | |
| 265 | - // Clean parameters |
|
| 266 | - $this->title = trim($this->title); |
|
| 267 | - $this->description = trim($this->description); |
|
| 265 | + // Clean parameters |
|
| 266 | + $this->title = trim($this->title); |
|
| 267 | + $this->description = trim($this->description); |
|
| 268 | 268 | if ($this->opp_amount < 0) $this->opp_amount=''; |
| 269 | 269 | if ($this->opp_percent < 0) $this->opp_percent=''; |
| 270 | - if ($this->date_end && $this->date_end < $this->date_start) |
|
| 271 | - { |
|
| 272 | - $this->error = $langs->trans("ErrorDateEndLowerThanDateStart"); |
|
| 273 | - $this->errors[] = $this->error; |
|
| 274 | - $this->db->rollback(); |
|
| 275 | - dol_syslog(get_class($this)."::update error -3 " . $this->error, LOG_ERR); |
|
| 276 | - return -3; |
|
| 277 | - } |
|
| 270 | + if ($this->date_end && $this->date_end < $this->date_start) |
|
| 271 | + { |
|
| 272 | + $this->error = $langs->trans("ErrorDateEndLowerThanDateStart"); |
|
| 273 | + $this->errors[] = $this->error; |
|
| 274 | + $this->db->rollback(); |
|
| 275 | + dol_syslog(get_class($this)."::update error -3 " . $this->error, LOG_ERR); |
|
| 276 | + return -3; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - if (dol_strlen(trim($this->ref)) > 0) |
|
| 280 | - { |
|
| 281 | - $this->db->begin(); |
|
| 282 | - |
|
| 283 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "projet SET"; |
|
| 284 | - $sql.= " ref='" . $this->db->escape($this->ref) . "'"; |
|
| 285 | - $sql.= ", title = '" . $this->db->escape($this->title) . "'"; |
|
| 286 | - $sql.= ", description = '" . $this->db->escape($this->description) . "'"; |
|
| 287 | - $sql.= ", fk_soc = " . ($this->socid > 0 ? $this->socid : "null"); |
|
| 288 | - $sql.= ", fk_statut = " . $this->statut; |
|
| 289 | - $sql.= ", fk_opp_status = " . ((is_numeric($this->opp_status) && $this->opp_status > 0) ? $this->opp_status : 'null'); |
|
| 279 | + if (dol_strlen(trim($this->ref)) > 0) |
|
| 280 | + { |
|
| 281 | + $this->db->begin(); |
|
| 282 | + |
|
| 283 | + $sql = "UPDATE " . MAIN_DB_PREFIX . "projet SET"; |
|
| 284 | + $sql.= " ref='" . $this->db->escape($this->ref) . "'"; |
|
| 285 | + $sql.= ", title = '" . $this->db->escape($this->title) . "'"; |
|
| 286 | + $sql.= ", description = '" . $this->db->escape($this->description) . "'"; |
|
| 287 | + $sql.= ", fk_soc = " . ($this->socid > 0 ? $this->socid : "null"); |
|
| 288 | + $sql.= ", fk_statut = " . $this->statut; |
|
| 289 | + $sql.= ", fk_opp_status = " . ((is_numeric($this->opp_status) && $this->opp_status > 0) ? $this->opp_status : 'null'); |
|
| 290 | 290 | $sql.= ", opp_percent = " . ((is_numeric($this->opp_percent) && $this->opp_percent != '') ? $this->opp_percent : 'null'); |
| 291 | - $sql.= ", public = " . ($this->public ? 1 : 0); |
|
| 292 | - $sql.= ", datec=" . ($this->date_c != '' ? "'".$this->db->idate($this->date_c)."'" : 'null'); |
|
| 293 | - $sql.= ", dateo=" . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); |
|
| 294 | - $sql.= ", datee=" . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); |
|
| 295 | - $sql.= ", date_close=" . ($this->date_close != '' ? "'".$this->db->idate($this->date_close)."'" : 'null'); |
|
| 296 | - $sql.= ", fk_user_close=" . ($this->fk_user_close > 0 ? $this->fk_user_close : "null"); |
|
| 297 | - $sql.= ", opp_amount = " . (strcmp($this->opp_amount, '') ? price2num($this->opp_amount) : "null"); |
|
| 298 | - $sql.= ", budget_amount = " . (strcmp($this->budget_amount, '') ? price2num($this->budget_amount) : "null"); |
|
| 299 | - $sql.= " WHERE rowid = " . $this->id; |
|
| 300 | - |
|
| 301 | - dol_syslog(get_class($this)."::update", LOG_DEBUG); |
|
| 302 | - $resql=$this->db->query($sql); |
|
| 303 | - if ($resql) |
|
| 304 | - { |
|
| 305 | - if (!$notrigger) |
|
| 306 | - { |
|
| 307 | - // Call trigger |
|
| 308 | - $result=$this->call_trigger('PROJECT_MODIFY',$user); |
|
| 309 | - if ($result < 0) { $error++; } |
|
| 310 | - // End call triggers |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - //Update extrafield |
|
| 314 | - if (!$error) { |
|
| 315 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 316 | - { |
|
| 317 | - $result=$this->insertExtraFields(); |
|
| 318 | - if ($result < 0) |
|
| 319 | - { |
|
| 320 | - $error++; |
|
| 321 | - } |
|
| 322 | - } |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) |
|
| 326 | - { |
|
| 327 | - // We remove directory |
|
| 328 | - if ($conf->projet->dir_output) |
|
| 329 | - { |
|
| 330 | - $olddir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); |
|
| 331 | - $newdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->ref); |
|
| 332 | - if (file_exists($olddir)) |
|
| 333 | - { |
|
| 291 | + $sql.= ", public = " . ($this->public ? 1 : 0); |
|
| 292 | + $sql.= ", datec=" . ($this->date_c != '' ? "'".$this->db->idate($this->date_c)."'" : 'null'); |
|
| 293 | + $sql.= ", dateo=" . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); |
|
| 294 | + $sql.= ", datee=" . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); |
|
| 295 | + $sql.= ", date_close=" . ($this->date_close != '' ? "'".$this->db->idate($this->date_close)."'" : 'null'); |
|
| 296 | + $sql.= ", fk_user_close=" . ($this->fk_user_close > 0 ? $this->fk_user_close : "null"); |
|
| 297 | + $sql.= ", opp_amount = " . (strcmp($this->opp_amount, '') ? price2num($this->opp_amount) : "null"); |
|
| 298 | + $sql.= ", budget_amount = " . (strcmp($this->budget_amount, '') ? price2num($this->budget_amount) : "null"); |
|
| 299 | + $sql.= " WHERE rowid = " . $this->id; |
|
| 300 | + |
|
| 301 | + dol_syslog(get_class($this)."::update", LOG_DEBUG); |
|
| 302 | + $resql=$this->db->query($sql); |
|
| 303 | + if ($resql) |
|
| 304 | + { |
|
| 305 | + if (!$notrigger) |
|
| 306 | + { |
|
| 307 | + // Call trigger |
|
| 308 | + $result=$this->call_trigger('PROJECT_MODIFY',$user); |
|
| 309 | + if ($result < 0) { $error++; } |
|
| 310 | + // End call triggers |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + //Update extrafield |
|
| 314 | + if (!$error) { |
|
| 315 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 316 | + { |
|
| 317 | + $result=$this->insertExtraFields(); |
|
| 318 | + if ($result < 0) |
|
| 319 | + { |
|
| 320 | + $error++; |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) |
|
| 326 | + { |
|
| 327 | + // We remove directory |
|
| 328 | + if ($conf->projet->dir_output) |
|
| 329 | + { |
|
| 330 | + $olddir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); |
|
| 331 | + $newdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->ref); |
|
| 332 | + if (file_exists($olddir)) |
|
| 333 | + { |
|
| 334 | 334 | include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
| 335 | 335 | $res=dol_move($olddir, $newdir); |
| 336 | 336 | if (! $res) |
| 337 | - { |
|
| 338 | - $langs->load("errors"); |
|
| 337 | + { |
|
| 338 | + $langs->load("errors"); |
|
| 339 | 339 | $this->error=$langs->trans('ErrorFailToRenameDir',$olddir,$newdir); |
| 340 | - $error++; |
|
| 341 | - } |
|
| 342 | - } |
|
| 343 | - } |
|
| 344 | - } |
|
| 345 | - if (! $error ) |
|
| 346 | - { |
|
| 347 | - $this->db->commit(); |
|
| 348 | - $result = 1; |
|
| 349 | - } |
|
| 350 | - else |
|
| 351 | - { |
|
| 352 | - $this->db->rollback(); |
|
| 353 | - $result = -1; |
|
| 354 | - } |
|
| 355 | - } |
|
| 356 | - else |
|
| 340 | + $error++; |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | + } |
|
| 344 | + } |
|
| 345 | + if (! $error ) |
|
| 346 | + { |
|
| 347 | + $this->db->commit(); |
|
| 348 | + $result = 1; |
|
| 349 | + } |
|
| 350 | + else |
|
| 351 | + { |
|
| 352 | + $this->db->rollback(); |
|
| 353 | + $result = -1; |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | + else |
|
| 357 | 357 | { |
| 358 | - $this->error = $this->db->lasterror(); |
|
| 359 | - $this->errors[] = $this->error; |
|
| 360 | - $this->db->rollback(); |
|
| 361 | - if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
|
| 362 | - { |
|
| 363 | - $result = -4; |
|
| 364 | - } |
|
| 365 | - else |
|
| 366 | - { |
|
| 367 | - $result = -2; |
|
| 368 | - } |
|
| 369 | - dol_syslog(get_class($this)."::update error " . $result . " " . $this->error, LOG_ERR); |
|
| 358 | + $this->error = $this->db->lasterror(); |
|
| 359 | + $this->errors[] = $this->error; |
|
| 360 | + $this->db->rollback(); |
|
| 361 | + if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
|
| 362 | + { |
|
| 363 | + $result = -4; |
|
| 364 | + } |
|
| 365 | + else |
|
| 366 | + { |
|
| 367 | + $result = -2; |
|
| 368 | + } |
|
| 369 | + dol_syslog(get_class($this)."::update error " . $result . " " . $this->error, LOG_ERR); |
|
| 370 | 370 | } |
| 371 | - } |
|
| 372 | - else |
|
| 373 | - { |
|
| 374 | - dol_syslog(get_class($this)."::update ref null"); |
|
| 375 | - $result = -1; |
|
| 376 | - } |
|
| 371 | + } |
|
| 372 | + else |
|
| 373 | + { |
|
| 374 | + dol_syslog(get_class($this)."::update ref null"); |
|
| 375 | + $result = -1; |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - return $result; |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * Get object from database |
|
| 383 | - * |
|
| 384 | - * @param int $id Id of object to load |
|
| 385 | - * @param string $ref Ref of project |
|
| 386 | - * @return int >0 if OK, 0 if not found, <0 if KO |
|
| 387 | - */ |
|
| 388 | - function fetch($id, $ref='') |
|
| 389 | - { |
|
| 390 | - if (empty($id) && empty($ref)) return -1; |
|
| 391 | - |
|
| 392 | - $sql = "SELECT rowid, ref, title, description, public, datec, opp_amount, budget_amount,"; |
|
| 393 | - $sql.= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_close, fk_statut, fk_opp_status, opp_percent, note_private, note_public, model_pdf"; |
|
| 394 | - $sql.= " FROM " . MAIN_DB_PREFIX . "projet"; |
|
| 395 | - if (! empty($id)) |
|
| 396 | - { |
|
| 397 | - $sql.= " WHERE rowid=".$id; |
|
| 398 | - } |
|
| 399 | - else if (! empty($ref)) |
|
| 400 | - { |
|
| 401 | - $sql.= " WHERE ref='".$this->db->escape($ref)."'"; |
|
| 402 | - $sql.= " AND entity IN (".getEntity('project').")"; |
|
| 403 | - } |
|
| 378 | + return $result; |
|
| 379 | + } |
|
| 404 | 380 | |
| 405 | - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
|
| 406 | - $resql = $this->db->query($sql); |
|
| 407 | - if ($resql) |
|
| 408 | - { |
|
| 409 | - $num_rows = $this->db->num_rows($resql); |
|
| 410 | - |
|
| 411 | - if ($num_rows) |
|
| 412 | - { |
|
| 413 | - $obj = $this->db->fetch_object($resql); |
|
| 414 | - |
|
| 415 | - $this->id = $obj->rowid; |
|
| 416 | - $this->ref = $obj->ref; |
|
| 417 | - $this->title = $obj->title; |
|
| 418 | - $this->titre = $obj->title; // TODO deprecated |
|
| 419 | - $this->description = $obj->description; |
|
| 420 | - $this->date_c = $this->db->jdate($obj->datec); |
|
| 421 | - $this->datec = $this->db->jdate($obj->datec); // TODO deprecated |
|
| 422 | - $this->date_m = $this->db->jdate($obj->tms); |
|
| 423 | - $this->datem = $this->db->jdate($obj->tms); // TODO deprecated |
|
| 424 | - $this->date_start = $this->db->jdate($obj->dateo); |
|
| 425 | - $this->date_end = $this->db->jdate($obj->datee); |
|
| 426 | - $this->date_close = $this->db->jdate($obj->date_close); |
|
| 427 | - $this->note_private = $obj->note_private; |
|
| 428 | - $this->note_public = $obj->note_public; |
|
| 429 | - $this->socid = $obj->fk_soc; |
|
| 430 | - $this->user_author_id = $obj->fk_user_creat; |
|
| 431 | - $this->user_close_id = $obj->fk_user_close; |
|
| 432 | - $this->public = $obj->public; |
|
| 433 | - $this->statut = $obj->fk_statut; |
|
| 434 | - $this->opp_status = $obj->fk_opp_status; |
|
| 435 | - $this->opp_amount = $obj->opp_amount; |
|
| 436 | - $this->opp_percent = $obj->opp_percent; |
|
| 437 | - $this->budget_amount = $obj->budget_amount; |
|
| 438 | - $this->modelpdf = $obj->model_pdf; |
|
| 439 | - |
|
| 440 | - $this->db->free($resql); |
|
| 441 | - |
|
| 442 | - // Retreive all extrafield for thirdparty |
|
| 443 | - $this->fetch_optionals(); |
|
| 444 | - |
|
| 445 | - return 1; |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - $this->db->free($resql); |
|
| 449 | - |
|
| 450 | - if ($num_rows) return 1; |
|
| 451 | - else return 0; |
|
| 452 | - } |
|
| 453 | - else |
|
| 454 | - { |
|
| 455 | - $this->error = $this->db->lasterror(); |
|
| 456 | - return -1; |
|
| 457 | - } |
|
| 458 | - } |
|
| 459 | - |
|
| 460 | - /** |
|
| 461 | - * Return list of projects |
|
| 462 | - * |
|
| 463 | - * @param int $socid To filter on a particular third party |
|
| 464 | - * @return array List of projects |
|
| 465 | - */ |
|
| 466 | - function liste_array($socid='') |
|
| 467 | - { |
|
| 468 | - global $conf; |
|
| 469 | - |
|
| 470 | - $projects = array(); |
|
| 471 | - |
|
| 472 | - $sql = "SELECT rowid, title"; |
|
| 473 | - $sql.= " FROM " . MAIN_DB_PREFIX . "projet"; |
|
| 474 | - $sql.= " WHERE entity = " . $conf->entity; |
|
| 475 | - if (! empty($socid)) $sql.= " AND fk_soc = " . $socid; |
|
| 476 | - |
|
| 477 | - $resql = $this->db->query($sql); |
|
| 478 | - if ($resql) |
|
| 479 | - { |
|
| 480 | - $nump = $this->db->num_rows($resql); |
|
| 481 | - |
|
| 482 | - if ($nump) |
|
| 483 | - { |
|
| 484 | - $i = 0; |
|
| 485 | - while ($i < $nump) |
|
| 486 | - { |
|
| 487 | - $obj = $this->db->fetch_object($resql); |
|
| 488 | - |
|
| 489 | - $projects[$obj->rowid] = $obj->title; |
|
| 490 | - $i++; |
|
| 491 | - } |
|
| 492 | - } |
|
| 493 | - return $projects; |
|
| 494 | - } |
|
| 495 | - else |
|
| 496 | - { |
|
| 497 | - print $this->db->lasterror(); |
|
| 498 | - } |
|
| 499 | - } |
|
| 500 | - |
|
| 501 | - /** |
|
| 502 | - * Return list of elements for type, linked to project |
|
| 503 | - * |
|
| 504 | - * @param string $type 'propal','order','invoice','order_supplier','invoice_supplier',... |
|
| 505 | - * @param string $tablename name of table associated of the type |
|
| 506 | - * @param string $datefieldname name of date field for filter |
|
| 507 | - * @param string $dates Start date (ex 00:00:00) |
|
| 508 | - * @param string $datee End date (ex 23:59:59) |
|
| 509 | - * @return mixed Array list of object ids linked to project, < 0 or string if error |
|
| 510 | - */ |
|
| 511 | - function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='') |
|
| 512 | - { |
|
| 513 | - $elements = array(); |
|
| 514 | - |
|
| 515 | - if ($this->id <= 0) return $elements; |
|
| 381 | + /** |
|
| 382 | + * Get object from database |
|
| 383 | + * |
|
| 384 | + * @param int $id Id of object to load |
|
| 385 | + * @param string $ref Ref of project |
|
| 386 | + * @return int >0 if OK, 0 if not found, <0 if KO |
|
| 387 | + */ |
|
| 388 | + function fetch($id, $ref='') |
|
| 389 | + { |
|
| 390 | + if (empty($id) && empty($ref)) return -1; |
|
| 391 | + |
|
| 392 | + $sql = "SELECT rowid, ref, title, description, public, datec, opp_amount, budget_amount,"; |
|
| 393 | + $sql.= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_close, fk_statut, fk_opp_status, opp_percent, note_private, note_public, model_pdf"; |
|
| 394 | + $sql.= " FROM " . MAIN_DB_PREFIX . "projet"; |
|
| 395 | + if (! empty($id)) |
|
| 396 | + { |
|
| 397 | + $sql.= " WHERE rowid=".$id; |
|
| 398 | + } |
|
| 399 | + else if (! empty($ref)) |
|
| 400 | + { |
|
| 401 | + $sql.= " WHERE ref='".$this->db->escape($ref)."'"; |
|
| 402 | + $sql.= " AND entity IN (".getEntity('project').")"; |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
|
| 406 | + $resql = $this->db->query($sql); |
|
| 407 | + if ($resql) |
|
| 408 | + { |
|
| 409 | + $num_rows = $this->db->num_rows($resql); |
|
| 410 | + |
|
| 411 | + if ($num_rows) |
|
| 412 | + { |
|
| 413 | + $obj = $this->db->fetch_object($resql); |
|
| 414 | + |
|
| 415 | + $this->id = $obj->rowid; |
|
| 416 | + $this->ref = $obj->ref; |
|
| 417 | + $this->title = $obj->title; |
|
| 418 | + $this->titre = $obj->title; // TODO deprecated |
|
| 419 | + $this->description = $obj->description; |
|
| 420 | + $this->date_c = $this->db->jdate($obj->datec); |
|
| 421 | + $this->datec = $this->db->jdate($obj->datec); // TODO deprecated |
|
| 422 | + $this->date_m = $this->db->jdate($obj->tms); |
|
| 423 | + $this->datem = $this->db->jdate($obj->tms); // TODO deprecated |
|
| 424 | + $this->date_start = $this->db->jdate($obj->dateo); |
|
| 425 | + $this->date_end = $this->db->jdate($obj->datee); |
|
| 426 | + $this->date_close = $this->db->jdate($obj->date_close); |
|
| 427 | + $this->note_private = $obj->note_private; |
|
| 428 | + $this->note_public = $obj->note_public; |
|
| 429 | + $this->socid = $obj->fk_soc; |
|
| 430 | + $this->user_author_id = $obj->fk_user_creat; |
|
| 431 | + $this->user_close_id = $obj->fk_user_close; |
|
| 432 | + $this->public = $obj->public; |
|
| 433 | + $this->statut = $obj->fk_statut; |
|
| 434 | + $this->opp_status = $obj->fk_opp_status; |
|
| 435 | + $this->opp_amount = $obj->opp_amount; |
|
| 436 | + $this->opp_percent = $obj->opp_percent; |
|
| 437 | + $this->budget_amount = $obj->budget_amount; |
|
| 438 | + $this->modelpdf = $obj->model_pdf; |
|
| 439 | + |
|
| 440 | + $this->db->free($resql); |
|
| 441 | + |
|
| 442 | + // Retreive all extrafield for thirdparty |
|
| 443 | + $this->fetch_optionals(); |
|
| 444 | + |
|
| 445 | + return 1; |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + $this->db->free($resql); |
|
| 449 | + |
|
| 450 | + if ($num_rows) return 1; |
|
| 451 | + else return 0; |
|
| 452 | + } |
|
| 453 | + else |
|
| 454 | + { |
|
| 455 | + $this->error = $this->db->lasterror(); |
|
| 456 | + return -1; |
|
| 457 | + } |
|
| 458 | + } |
|
| 459 | + |
|
| 460 | + /** |
|
| 461 | + * Return list of projects |
|
| 462 | + * |
|
| 463 | + * @param int $socid To filter on a particular third party |
|
| 464 | + * @return array List of projects |
|
| 465 | + */ |
|
| 466 | + function liste_array($socid='') |
|
| 467 | + { |
|
| 468 | + global $conf; |
|
| 469 | + |
|
| 470 | + $projects = array(); |
|
| 471 | + |
|
| 472 | + $sql = "SELECT rowid, title"; |
|
| 473 | + $sql.= " FROM " . MAIN_DB_PREFIX . "projet"; |
|
| 474 | + $sql.= " WHERE entity = " . $conf->entity; |
|
| 475 | + if (! empty($socid)) $sql.= " AND fk_soc = " . $socid; |
|
| 476 | + |
|
| 477 | + $resql = $this->db->query($sql); |
|
| 478 | + if ($resql) |
|
| 479 | + { |
|
| 480 | + $nump = $this->db->num_rows($resql); |
|
| 481 | + |
|
| 482 | + if ($nump) |
|
| 483 | + { |
|
| 484 | + $i = 0; |
|
| 485 | + while ($i < $nump) |
|
| 486 | + { |
|
| 487 | + $obj = $this->db->fetch_object($resql); |
|
| 488 | + |
|
| 489 | + $projects[$obj->rowid] = $obj->title; |
|
| 490 | + $i++; |
|
| 491 | + } |
|
| 492 | + } |
|
| 493 | + return $projects; |
|
| 494 | + } |
|
| 495 | + else |
|
| 496 | + { |
|
| 497 | + print $this->db->lasterror(); |
|
| 498 | + } |
|
| 499 | + } |
|
| 500 | + |
|
| 501 | + /** |
|
| 502 | + * Return list of elements for type, linked to project |
|
| 503 | + * |
|
| 504 | + * @param string $type 'propal','order','invoice','order_supplier','invoice_supplier',... |
|
| 505 | + * @param string $tablename name of table associated of the type |
|
| 506 | + * @param string $datefieldname name of date field for filter |
|
| 507 | + * @param string $dates Start date (ex 00:00:00) |
|
| 508 | + * @param string $datee End date (ex 23:59:59) |
|
| 509 | + * @return mixed Array list of object ids linked to project, < 0 or string if error |
|
| 510 | + */ |
|
| 511 | + function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='') |
|
| 512 | + { |
|
| 513 | + $elements = array(); |
|
| 514 | + |
|
| 515 | + if ($this->id <= 0) return $elements; |
|
| 516 | 516 | |
| 517 | 517 | if ($type == 'agenda') |
| 518 | - { |
|
| 519 | - $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id; |
|
| 520 | - } |
|
| 521 | - elseif ($type == 'expensereport') |
|
| 522 | 518 | { |
| 523 | - $sql = "SELECT ed.rowid FROM " . MAIN_DB_PREFIX . "expensereport as e, " . MAIN_DB_PREFIX . "expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND ed.fk_projet=" . $this->id; |
|
| 519 | + $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id; |
|
| 524 | 520 | } |
| 525 | - elseif ($type == 'project_task') |
|
| 521 | + elseif ($type == 'expensereport') |
|
| 522 | + { |
|
| 523 | + $sql = "SELECT ed.rowid FROM " . MAIN_DB_PREFIX . "expensereport as e, " . MAIN_DB_PREFIX . "expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND ed.fk_projet=" . $this->id; |
|
| 524 | + } |
|
| 525 | + elseif ($type == 'project_task') |
|
| 526 | 526 | { |
| 527 | 527 | $sql = "SELECT DISTINCT pt.rowid FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=" . $this->id; |
| 528 | 528 | } |
@@ -534,9 +534,9 @@ discard block |
||
| 534 | 534 | { |
| 535 | 535 | $sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM ' . MAIN_DB_PREFIX . 'stock_mouvement as ms WHERE ms.origintype = "project" AND ms.fk_origin = ' . $this->id . ' AND ms.type_mouvement = 1'; |
| 536 | 536 | } |
| 537 | - else |
|
| 537 | + else |
|
| 538 | 538 | { |
| 539 | - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id; |
|
| 539 | + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id; |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | if ($dates > 0) |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | if (empty($datefieldname)) return 'Error this object has no date field defined'; |
| 546 | 546 | $sql.=" AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; |
| 547 | 547 | } |
| 548 | - if ($datee > 0) |
|
| 548 | + if ($datee > 0) |
|
| 549 | 549 | { |
| 550 | 550 | if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date; |
| 551 | 551 | if (empty($datefieldname)) return 'Error this object has no date field defined'; |
@@ -553,454 +553,454 @@ discard block |
||
| 553 | 553 | } |
| 554 | 554 | if (! $sql) return -1; |
| 555 | 555 | |
| 556 | - //print $sql; |
|
| 557 | - dol_syslog(get_class($this)."::get_element_list", LOG_DEBUG); |
|
| 558 | - $result = $this->db->query($sql); |
|
| 559 | - if ($result) |
|
| 560 | - { |
|
| 561 | - $nump = $this->db->num_rows($result); |
|
| 562 | - if ($nump) |
|
| 563 | - { |
|
| 564 | - $i = 0; |
|
| 565 | - while ($i < $nump) |
|
| 566 | - { |
|
| 567 | - $obj = $this->db->fetch_object($result); |
|
| 568 | - |
|
| 569 | - $elements[$i] = $obj->rowid.(empty($obj->fk_user)?'':'_'.$obj->fk_user); |
|
| 570 | - |
|
| 571 | - $i++; |
|
| 572 | - } |
|
| 573 | - $this->db->free($result); |
|
| 574 | - |
|
| 575 | - /* Return array */ |
|
| 576 | - return $elements; |
|
| 577 | - } |
|
| 578 | - } |
|
| 579 | - else |
|
| 580 | - { |
|
| 581 | - dol_print_error($this->db); |
|
| 582 | - } |
|
| 583 | - } |
|
| 556 | + //print $sql; |
|
| 557 | + dol_syslog(get_class($this)."::get_element_list", LOG_DEBUG); |
|
| 558 | + $result = $this->db->query($sql); |
|
| 559 | + if ($result) |
|
| 560 | + { |
|
| 561 | + $nump = $this->db->num_rows($result); |
|
| 562 | + if ($nump) |
|
| 563 | + { |
|
| 564 | + $i = 0; |
|
| 565 | + while ($i < $nump) |
|
| 566 | + { |
|
| 567 | + $obj = $this->db->fetch_object($result); |
|
| 584 | 568 | |
| 585 | - /** |
|
| 586 | - * Delete a project from database |
|
| 587 | - * |
|
| 588 | - * @param User $user User |
|
| 589 | - * @param int $notrigger Disable triggers |
|
| 590 | - * @return int <0 if KO, 0 if not possible, >0 if OK |
|
| 591 | - */ |
|
| 592 | - function delete($user, $notrigger=0) |
|
| 593 | - { |
|
| 594 | - global $langs, $conf; |
|
| 595 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
| 569 | + $elements[$i] = $obj->rowid.(empty($obj->fk_user)?'':'_'.$obj->fk_user); |
|
| 596 | 570 | |
| 597 | - $error = 0; |
|
| 571 | + $i++; |
|
| 572 | + } |
|
| 573 | + $this->db->free($result); |
|
| 598 | 574 | |
| 599 | - $this->db->begin(); |
|
| 575 | + /* Return array */ |
|
| 576 | + return $elements; |
|
| 577 | + } |
|
| 578 | + } |
|
| 579 | + else |
|
| 580 | + { |
|
| 581 | + dol_print_error($this->db); |
|
| 582 | + } |
|
| 583 | + } |
|
| 600 | 584 | |
| 601 | - if (!$error) |
|
| 602 | - { |
|
| 603 | - // Delete linked contacts |
|
| 604 | - $res = $this->delete_linked_contact(); |
|
| 605 | - if ($res < 0) |
|
| 606 | - { |
|
| 607 | - $this->error = 'ErrorFailToDeleteLinkedContact'; |
|
| 608 | - //$error++; |
|
| 609 | - $this->db->rollback(); |
|
| 610 | - return 0; |
|
| 611 | - } |
|
| 612 | - } |
|
| 585 | + /** |
|
| 586 | + * Delete a project from database |
|
| 587 | + * |
|
| 588 | + * @param User $user User |
|
| 589 | + * @param int $notrigger Disable triggers |
|
| 590 | + * @return int <0 if KO, 0 if not possible, >0 if OK |
|
| 591 | + */ |
|
| 592 | + function delete($user, $notrigger=0) |
|
| 593 | + { |
|
| 594 | + global $langs, $conf; |
|
| 595 | + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
| 613 | 596 | |
| 614 | - // Set fk_projet into elements to null |
|
| 615 | - $listoftables=array( |
|
| 616 | - 'facture'=>'fk_projet','propal'=>'fk_projet','commande'=>'fk_projet', |
|
| 617 | - 'facture_fourn'=>'fk_projet','commande_fournisseur'=>'fk_projet','supplier_proposal'=>'fk_projet', |
|
| 618 | - 'expensereport_det'=>'fk_projet','contrat'=>'fk_projet','fichinter'=>'fk_projet','don'=>'fk_projet' |
|
| 619 | - ); |
|
| 620 | - foreach($listoftables as $key => $value) |
|
| 621 | - { |
|
| 622 | - $sql = "UPDATE " . MAIN_DB_PREFIX . $key . " SET ".$value." = NULL where ".$value." = ". $this->id; |
|
| 623 | - $resql = $this->db->query($sql); |
|
| 624 | - if (!$resql) |
|
| 625 | - { |
|
| 626 | - $this->errors[] = $this->db->lasterror(); |
|
| 627 | - $error++; |
|
| 628 | - break; |
|
| 629 | - } |
|
| 630 | - } |
|
| 597 | + $error = 0; |
|
| 631 | 598 | |
| 632 | - // Delete tasks |
|
| 633 | - if (! $error) |
|
| 634 | - { |
|
| 635 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task_time"; |
|
| 636 | - $sql.= " WHERE fk_task IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "projet_task WHERE fk_projet=" . $this->id . ")"; |
|
| 637 | - |
|
| 638 | - $resql = $this->db->query($sql); |
|
| 639 | - if (!$resql) |
|
| 640 | - { |
|
| 641 | - $this->errors[] = $this->db->lasterror(); |
|
| 642 | - $error++; |
|
| 643 | - } |
|
| 644 | - } |
|
| 599 | + $this->db->begin(); |
|
| 645 | 600 | |
| 646 | - if (! $error) |
|
| 647 | - { |
|
| 648 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task_extrafields"; |
|
| 649 | - $sql.= " WHERE fk_object IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "projet_task WHERE fk_projet=" . $this->id . ")"; |
|
| 650 | - |
|
| 651 | - $resql = $this->db->query($sql); |
|
| 652 | - if (!$resql) |
|
| 653 | - { |
|
| 654 | - $this->errors[] = $this->db->lasterror(); |
|
| 655 | - $error++; |
|
| 656 | - } |
|
| 657 | - } |
|
| 601 | + if (!$error) |
|
| 602 | + { |
|
| 603 | + // Delete linked contacts |
|
| 604 | + $res = $this->delete_linked_contact(); |
|
| 605 | + if ($res < 0) |
|
| 606 | + { |
|
| 607 | + $this->error = 'ErrorFailToDeleteLinkedContact'; |
|
| 608 | + //$error++; |
|
| 609 | + $this->db->rollback(); |
|
| 610 | + return 0; |
|
| 611 | + } |
|
| 612 | + } |
|
| 658 | 613 | |
| 659 | - if (! $error) |
|
| 660 | - { |
|
| 661 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task"; |
|
| 662 | - $sql.= " WHERE fk_projet=" . $this->id; |
|
| 663 | - |
|
| 664 | - $resql = $this->db->query($sql); |
|
| 665 | - if (!$resql) |
|
| 666 | - { |
|
| 667 | - $this->errors[] = $this->db->lasterror(); |
|
| 668 | - $error++; |
|
| 669 | - } |
|
| 670 | - } |
|
| 614 | + // Set fk_projet into elements to null |
|
| 615 | + $listoftables=array( |
|
| 616 | + 'facture'=>'fk_projet','propal'=>'fk_projet','commande'=>'fk_projet', |
|
| 617 | + 'facture_fourn'=>'fk_projet','commande_fournisseur'=>'fk_projet','supplier_proposal'=>'fk_projet', |
|
| 618 | + 'expensereport_det'=>'fk_projet','contrat'=>'fk_projet','fichinter'=>'fk_projet','don'=>'fk_projet' |
|
| 619 | + ); |
|
| 620 | + foreach($listoftables as $key => $value) |
|
| 621 | + { |
|
| 622 | + $sql = "UPDATE " . MAIN_DB_PREFIX . $key . " SET ".$value." = NULL where ".$value." = ". $this->id; |
|
| 623 | + $resql = $this->db->query($sql); |
|
| 624 | + if (!$resql) |
|
| 625 | + { |
|
| 626 | + $this->errors[] = $this->db->lasterror(); |
|
| 627 | + $error++; |
|
| 628 | + break; |
|
| 629 | + } |
|
| 630 | + } |
|
| 671 | 631 | |
| 672 | - // Delete project |
|
| 673 | - if (! $error) |
|
| 674 | - { |
|
| 675 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet"; |
|
| 676 | - $sql.= " WHERE rowid=" . $this->id; |
|
| 677 | - |
|
| 678 | - $resql = $this->db->query($sql); |
|
| 679 | - if (!$resql) |
|
| 680 | - { |
|
| 681 | - $this->errors[] = $langs->trans("CantRemoveProject"); |
|
| 682 | - $error++; |
|
| 683 | - } |
|
| 684 | - } |
|
| 632 | + // Delete tasks |
|
| 633 | + if (! $error) |
|
| 634 | + { |
|
| 635 | + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task_time"; |
|
| 636 | + $sql.= " WHERE fk_task IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "projet_task WHERE fk_projet=" . $this->id . ")"; |
|
| 685 | 637 | |
| 686 | - if (! $error) |
|
| 687 | - { |
|
| 688 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_extrafields"; |
|
| 689 | - $sql.= " WHERE fk_object=" . $this->id; |
|
| 690 | - |
|
| 691 | - $resql = $this->db->query($sql); |
|
| 692 | - if (! $resql) |
|
| 693 | - { |
|
| 694 | - $this->errors[] = $this->db->lasterror(); |
|
| 695 | - $error++; |
|
| 696 | - } |
|
| 697 | - } |
|
| 638 | + $resql = $this->db->query($sql); |
|
| 639 | + if (!$resql) |
|
| 640 | + { |
|
| 641 | + $this->errors[] = $this->db->lasterror(); |
|
| 642 | + $error++; |
|
| 643 | + } |
|
| 644 | + } |
|
| 698 | 645 | |
| 699 | - if (empty($error)) |
|
| 700 | - { |
|
| 701 | - // We remove directory |
|
| 702 | - $projectref = dol_sanitizeFileName($this->ref); |
|
| 703 | - if ($conf->projet->dir_output) |
|
| 704 | - { |
|
| 705 | - $dir = $conf->projet->dir_output . "/" . $projectref; |
|
| 706 | - if (file_exists($dir)) |
|
| 707 | - { |
|
| 708 | - $res = @dol_delete_dir_recursive($dir); |
|
| 709 | - if (!$res) |
|
| 710 | - { |
|
| 711 | - $this->errors[] = 'ErrorFailToDeleteDir'; |
|
| 712 | - $error++; |
|
| 713 | - } |
|
| 714 | - } |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - if (!$notrigger) |
|
| 718 | - { |
|
| 719 | - // Call trigger |
|
| 720 | - $result=$this->call_trigger('PROJECT_DELETE',$user); |
|
| 721 | - |
|
| 722 | - if ($result < 0) { |
|
| 723 | - $error++; |
|
| 724 | - } |
|
| 725 | - // End call triggers |
|
| 726 | - } |
|
| 727 | - } |
|
| 646 | + if (! $error) |
|
| 647 | + { |
|
| 648 | + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task_extrafields"; |
|
| 649 | + $sql.= " WHERE fk_object IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "projet_task WHERE fk_projet=" . $this->id . ")"; |
|
| 728 | 650 | |
| 729 | - if (empty($error)) |
|
| 730 | - { |
|
| 731 | - $this->db->commit(); |
|
| 732 | - return 1; |
|
| 733 | - } |
|
| 734 | - else |
|
| 735 | - { |
|
| 736 | - foreach ( $this->errors as $errmsg ) |
|
| 737 | - { |
|
| 651 | + $resql = $this->db->query($sql); |
|
| 652 | + if (!$resql) |
|
| 653 | + { |
|
| 654 | + $this->errors[] = $this->db->lasterror(); |
|
| 655 | + $error++; |
|
| 656 | + } |
|
| 657 | + } |
|
| 658 | + |
|
| 659 | + if (! $error) |
|
| 660 | + { |
|
| 661 | + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task"; |
|
| 662 | + $sql.= " WHERE fk_projet=" . $this->id; |
|
| 663 | + |
|
| 664 | + $resql = $this->db->query($sql); |
|
| 665 | + if (!$resql) |
|
| 666 | + { |
|
| 667 | + $this->errors[] = $this->db->lasterror(); |
|
| 668 | + $error++; |
|
| 669 | + } |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + // Delete project |
|
| 673 | + if (! $error) |
|
| 674 | + { |
|
| 675 | + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet"; |
|
| 676 | + $sql.= " WHERE rowid=" . $this->id; |
|
| 677 | + |
|
| 678 | + $resql = $this->db->query($sql); |
|
| 679 | + if (!$resql) |
|
| 680 | + { |
|
| 681 | + $this->errors[] = $langs->trans("CantRemoveProject"); |
|
| 682 | + $error++; |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | + |
|
| 686 | + if (! $error) |
|
| 687 | + { |
|
| 688 | + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_extrafields"; |
|
| 689 | + $sql.= " WHERE fk_object=" . $this->id; |
|
| 690 | + |
|
| 691 | + $resql = $this->db->query($sql); |
|
| 692 | + if (! $resql) |
|
| 693 | + { |
|
| 694 | + $this->errors[] = $this->db->lasterror(); |
|
| 695 | + $error++; |
|
| 696 | + } |
|
| 697 | + } |
|
| 698 | + |
|
| 699 | + if (empty($error)) |
|
| 700 | + { |
|
| 701 | + // We remove directory |
|
| 702 | + $projectref = dol_sanitizeFileName($this->ref); |
|
| 703 | + if ($conf->projet->dir_output) |
|
| 704 | + { |
|
| 705 | + $dir = $conf->projet->dir_output . "/" . $projectref; |
|
| 706 | + if (file_exists($dir)) |
|
| 707 | + { |
|
| 708 | + $res = @dol_delete_dir_recursive($dir); |
|
| 709 | + if (!$res) |
|
| 710 | + { |
|
| 711 | + $this->errors[] = 'ErrorFailToDeleteDir'; |
|
| 712 | + $error++; |
|
| 713 | + } |
|
| 714 | + } |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + if (!$notrigger) |
|
| 718 | + { |
|
| 719 | + // Call trigger |
|
| 720 | + $result=$this->call_trigger('PROJECT_DELETE',$user); |
|
| 721 | + |
|
| 722 | + if ($result < 0) { |
|
| 723 | + $error++; |
|
| 724 | + } |
|
| 725 | + // End call triggers |
|
| 726 | + } |
|
| 727 | + } |
|
| 728 | + |
|
| 729 | + if (empty($error)) |
|
| 730 | + { |
|
| 731 | + $this->db->commit(); |
|
| 732 | + return 1; |
|
| 733 | + } |
|
| 734 | + else |
|
| 735 | + { |
|
| 736 | + foreach ( $this->errors as $errmsg ) |
|
| 737 | + { |
|
| 738 | 738 | dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); |
| 739 | 739 | $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); |
| 740 | 740 | } |
| 741 | - dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR); |
|
| 742 | - $this->db->rollback(); |
|
| 743 | - return -1; |
|
| 744 | - } |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - /** |
|
| 748 | - * Validate a project |
|
| 749 | - * |
|
| 750 | - * @param User $user User that validate |
|
| 751 | - * @param int $notrigger 1=Disable triggers |
|
| 752 | - * @return int <0 if KO, >0 if OK |
|
| 753 | - */ |
|
| 754 | - function setValid($user, $notrigger=0) |
|
| 755 | - { |
|
| 756 | - global $langs, $conf; |
|
| 741 | + dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR); |
|
| 742 | + $this->db->rollback(); |
|
| 743 | + return -1; |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + /** |
|
| 748 | + * Validate a project |
|
| 749 | + * |
|
| 750 | + * @param User $user User that validate |
|
| 751 | + * @param int $notrigger 1=Disable triggers |
|
| 752 | + * @return int <0 if KO, >0 if OK |
|
| 753 | + */ |
|
| 754 | + function setValid($user, $notrigger=0) |
|
| 755 | + { |
|
| 756 | + global $langs, $conf; |
|
| 757 | 757 | |
| 758 | 758 | $error=0; |
| 759 | 759 | |
| 760 | - if ($this->statut != 1) |
|
| 761 | - { |
|
| 762 | - // Check parameters |
|
| 763 | - if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->title)) |
|
| 764 | - { |
|
| 765 | - $this->error=$langs->trans("ErrorFieldFormat",$langs->transnoentities("Label")).'. '.$langs->trans('RemoveString',$langs->transnoentitiesnoconv("CopyOf")); |
|
| 766 | - return -1; |
|
| 767 | - } |
|
| 768 | - |
|
| 769 | - $this->db->begin(); |
|
| 770 | - |
|
| 771 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "projet"; |
|
| 772 | - $sql.= " SET fk_statut = 1"; |
|
| 773 | - $sql.= " WHERE rowid = " . $this->id; |
|
| 774 | - $sql.= " AND entity = " . $conf->entity; |
|
| 775 | - |
|
| 776 | - dol_syslog(get_class($this)."::setValid", LOG_DEBUG); |
|
| 777 | - $resql = $this->db->query($sql); |
|
| 778 | - if ($resql) |
|
| 779 | - { |
|
| 780 | - // Call trigger |
|
| 781 | - if (empty($notrigger)) |
|
| 782 | - { |
|
| 783 | - $result=$this->call_trigger('PROJECT_VALIDATE',$user); |
|
| 784 | - if ($result < 0) { $error++; } |
|
| 785 | - // End call triggers |
|
| 786 | - } |
|
| 787 | - |
|
| 788 | - if (!$error) |
|
| 789 | - { |
|
| 790 | - $this->statut=1; |
|
| 791 | - $this->db->commit(); |
|
| 792 | - return 1; |
|
| 793 | - } |
|
| 794 | - else |
|
| 795 | - { |
|
| 796 | - $this->db->rollback(); |
|
| 797 | - $this->error = join(',', $this->errors); |
|
| 798 | - dol_syslog(get_class($this)."::setValid " . $this->error, LOG_ERR); |
|
| 799 | - return -1; |
|
| 800 | - } |
|
| 801 | - } |
|
| 802 | - else |
|
| 803 | - { |
|
| 804 | - $this->db->rollback(); |
|
| 805 | - $this->error = $this->db->lasterror(); |
|
| 806 | - return -1; |
|
| 807 | - } |
|
| 808 | - } |
|
| 809 | - } |
|
| 760 | + if ($this->statut != 1) |
|
| 761 | + { |
|
| 762 | + // Check parameters |
|
| 763 | + if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->title)) |
|
| 764 | + { |
|
| 765 | + $this->error=$langs->trans("ErrorFieldFormat",$langs->transnoentities("Label")).'. '.$langs->trans('RemoveString',$langs->transnoentitiesnoconv("CopyOf")); |
|
| 766 | + return -1; |
|
| 767 | + } |
|
| 768 | + |
|
| 769 | + $this->db->begin(); |
|
| 770 | + |
|
| 771 | + $sql = "UPDATE " . MAIN_DB_PREFIX . "projet"; |
|
| 772 | + $sql.= " SET fk_statut = 1"; |
|
| 773 | + $sql.= " WHERE rowid = " . $this->id; |
|
| 774 | + $sql.= " AND entity = " . $conf->entity; |
|
| 775 | + |
|
| 776 | + dol_syslog(get_class($this)."::setValid", LOG_DEBUG); |
|
| 777 | + $resql = $this->db->query($sql); |
|
| 778 | + if ($resql) |
|
| 779 | + { |
|
| 780 | + // Call trigger |
|
| 781 | + if (empty($notrigger)) |
|
| 782 | + { |
|
| 783 | + $result=$this->call_trigger('PROJECT_VALIDATE',$user); |
|
| 784 | + if ($result < 0) { $error++; } |
|
| 785 | + // End call triggers |
|
| 786 | + } |
|
| 787 | + |
|
| 788 | + if (!$error) |
|
| 789 | + { |
|
| 790 | + $this->statut=1; |
|
| 791 | + $this->db->commit(); |
|
| 792 | + return 1; |
|
| 793 | + } |
|
| 794 | + else |
|
| 795 | + { |
|
| 796 | + $this->db->rollback(); |
|
| 797 | + $this->error = join(',', $this->errors); |
|
| 798 | + dol_syslog(get_class($this)."::setValid " . $this->error, LOG_ERR); |
|
| 799 | + return -1; |
|
| 800 | + } |
|
| 801 | + } |
|
| 802 | + else |
|
| 803 | + { |
|
| 804 | + $this->db->rollback(); |
|
| 805 | + $this->error = $this->db->lasterror(); |
|
| 806 | + return -1; |
|
| 807 | + } |
|
| 808 | + } |
|
| 809 | + } |
|
| 810 | + |
|
| 811 | + /** |
|
| 812 | + * Close a project |
|
| 813 | + * |
|
| 814 | + * @param User $user User that close project |
|
| 815 | + * @return int <0 if KO, 0 if already closed, >0 if OK |
|
| 816 | + */ |
|
| 817 | + function setClose($user) |
|
| 818 | + { |
|
| 819 | + global $langs, $conf; |
|
| 820 | + |
|
| 821 | + $now = dol_now(); |
|
| 822 | + |
|
| 823 | + $error=0; |
|
| 824 | + |
|
| 825 | + if ($this->statut != 2) |
|
| 826 | + { |
|
| 827 | + $this->db->begin(); |
|
| 828 | + |
|
| 829 | + $sql = "UPDATE " . MAIN_DB_PREFIX . "projet"; |
|
| 830 | + $sql.= " SET fk_statut = 2, fk_user_close = ".$user->id.", date_close = '".$this->db->idate($now)."'"; |
|
| 831 | + $sql.= " WHERE rowid = " . $this->id; |
|
| 832 | + $sql.= " AND entity = " . $conf->entity; |
|
| 833 | + $sql.= " AND fk_statut = 1"; |
|
| 834 | + |
|
| 835 | + if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 836 | + { |
|
| 837 | + // TODO What to do if fk_opp_status is not code 'WON' or 'LOST' |
|
| 838 | + } |
|
| 839 | + |
|
| 840 | + dol_syslog(get_class($this)."::setClose", LOG_DEBUG); |
|
| 841 | + $resql = $this->db->query($sql); |
|
| 842 | + if ($resql) |
|
| 843 | + { |
|
| 844 | + // Call trigger |
|
| 845 | + $result=$this->call_trigger('PROJECT_CLOSE',$user); |
|
| 846 | + if ($result < 0) { $error++; } |
|
| 847 | + // End call triggers |
|
| 848 | + |
|
| 849 | + if (!$error) |
|
| 850 | + { |
|
| 851 | + $this->statut = 2; |
|
| 852 | + $this->db->commit(); |
|
| 853 | + return 1; |
|
| 854 | + } |
|
| 855 | + else |
|
| 856 | + { |
|
| 857 | + $this->db->rollback(); |
|
| 858 | + $this->error = join(',', $this->errors); |
|
| 859 | + dol_syslog(get_class($this)."::setClose " . $this->error, LOG_ERR); |
|
| 860 | + return -1; |
|
| 861 | + } |
|
| 862 | + } |
|
| 863 | + else |
|
| 864 | + { |
|
| 865 | + $this->db->rollback(); |
|
| 866 | + $this->error = $this->db->lasterror(); |
|
| 867 | + return -1; |
|
| 868 | + } |
|
| 869 | + } |
|
| 810 | 870 | |
| 811 | - /** |
|
| 812 | - * Close a project |
|
| 813 | - * |
|
| 814 | - * @param User $user User that close project |
|
| 815 | - * @return int <0 if KO, 0 if already closed, >0 if OK |
|
| 816 | - */ |
|
| 817 | - function setClose($user) |
|
| 818 | - { |
|
| 819 | - global $langs, $conf; |
|
| 871 | + return 0; |
|
| 872 | + } |
|
| 820 | 873 | |
| 821 | - $now = dol_now(); |
|
| 874 | + /** |
|
| 875 | + * Return status label of object |
|
| 876 | + * |
|
| 877 | + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto |
|
| 878 | + * @return string Label |
|
| 879 | + */ |
|
| 880 | + function getLibStatut($mode=0) |
|
| 881 | + { |
|
| 882 | + return $this->LibStatut($this->statut, $mode); |
|
| 883 | + } |
|
| 822 | 884 | |
| 823 | - $error=0; |
|
| 885 | + /** |
|
| 886 | + * Renvoi status label for a status |
|
| 887 | + * |
|
| 888 | + * @param int $statut id statut |
|
| 889 | + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto |
|
| 890 | + * @return string Label |
|
| 891 | + */ |
|
| 892 | + function LibStatut($statut, $mode=0) |
|
| 893 | + { |
|
| 894 | + global $langs; |
|
| 824 | 895 | |
| 825 | - if ($this->statut != 2) |
|
| 826 | - { |
|
| 827 | - $this->db->begin(); |
|
| 828 | - |
|
| 829 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "projet"; |
|
| 830 | - $sql.= " SET fk_statut = 2, fk_user_close = ".$user->id.", date_close = '".$this->db->idate($now)."'"; |
|
| 831 | - $sql.= " WHERE rowid = " . $this->id; |
|
| 832 | - $sql.= " AND entity = " . $conf->entity; |
|
| 833 | - $sql.= " AND fk_statut = 1"; |
|
| 834 | - |
|
| 835 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 836 | - { |
|
| 837 | - // TODO What to do if fk_opp_status is not code 'WON' or 'LOST' |
|
| 838 | - } |
|
| 839 | - |
|
| 840 | - dol_syslog(get_class($this)."::setClose", LOG_DEBUG); |
|
| 841 | - $resql = $this->db->query($sql); |
|
| 842 | - if ($resql) |
|
| 843 | - { |
|
| 844 | - // Call trigger |
|
| 845 | - $result=$this->call_trigger('PROJECT_CLOSE',$user); |
|
| 846 | - if ($result < 0) { $error++; } |
|
| 847 | - // End call triggers |
|
| 848 | - |
|
| 849 | - if (!$error) |
|
| 850 | - { |
|
| 851 | - $this->statut = 2; |
|
| 852 | - $this->db->commit(); |
|
| 853 | - return 1; |
|
| 854 | - } |
|
| 855 | - else |
|
| 856 | - { |
|
| 857 | - $this->db->rollback(); |
|
| 858 | - $this->error = join(',', $this->errors); |
|
| 859 | - dol_syslog(get_class($this)."::setClose " . $this->error, LOG_ERR); |
|
| 860 | - return -1; |
|
| 861 | - } |
|
| 862 | - } |
|
| 863 | - else |
|
| 864 | - { |
|
| 865 | - $this->db->rollback(); |
|
| 866 | - $this->error = $this->db->lasterror(); |
|
| 867 | - return -1; |
|
| 868 | - } |
|
| 869 | - } |
|
| 896 | + if ($mode == 0) |
|
| 897 | + { |
|
| 898 | + return $langs->trans($this->statuts_long[$statut]); |
|
| 899 | + } |
|
| 900 | + if ($mode == 1) |
|
| 901 | + { |
|
| 902 | + return $langs->trans($this->statuts_short[$statut]); |
|
| 903 | + } |
|
| 904 | + if ($mode == 2) |
|
| 905 | + { |
|
| 906 | + if ($statut == 0) |
|
| 907 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 908 | + if ($statut == 1) |
|
| 909 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 910 | + if ($statut == 2) |
|
| 911 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 912 | + } |
|
| 913 | + if ($mode == 3) |
|
| 914 | + { |
|
| 915 | + if ($statut == 0) |
|
| 916 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); |
|
| 917 | + if ($statut == 1) |
|
| 918 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); |
|
| 919 | + if ($statut == 2) |
|
| 920 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); |
|
| 921 | + } |
|
| 922 | + if ($mode == 4) |
|
| 923 | + { |
|
| 924 | + if ($statut == 0) |
|
| 925 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 926 | + if ($statut == 1) |
|
| 927 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 928 | + if ($statut == 2) |
|
| 929 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 930 | + } |
|
| 931 | + if ($mode == 5) |
|
| 932 | + { |
|
| 933 | + if ($statut == 0) |
|
| 934 | + return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); |
|
| 935 | + if ($statut == 1) |
|
| 936 | + return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); |
|
| 937 | + if ($statut == 2) |
|
| 938 | + return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); |
|
| 939 | + } |
|
| 940 | + } |
|
| 870 | 941 | |
| 871 | - return 0; |
|
| 872 | - } |
|
| 873 | - |
|
| 874 | - /** |
|
| 875 | - * Return status label of object |
|
| 876 | - * |
|
| 877 | - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto |
|
| 878 | - * @return string Label |
|
| 879 | - */ |
|
| 880 | - function getLibStatut($mode=0) |
|
| 881 | - { |
|
| 882 | - return $this->LibStatut($this->statut, $mode); |
|
| 883 | - } |
|
| 884 | - |
|
| 885 | - /** |
|
| 886 | - * Renvoi status label for a status |
|
| 887 | - * |
|
| 888 | - * @param int $statut id statut |
|
| 889 | - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto |
|
| 890 | - * @return string Label |
|
| 891 | - */ |
|
| 892 | - function LibStatut($statut, $mode=0) |
|
| 893 | - { |
|
| 894 | - global $langs; |
|
| 895 | - |
|
| 896 | - if ($mode == 0) |
|
| 897 | - { |
|
| 898 | - return $langs->trans($this->statuts_long[$statut]); |
|
| 899 | - } |
|
| 900 | - if ($mode == 1) |
|
| 901 | - { |
|
| 902 | - return $langs->trans($this->statuts_short[$statut]); |
|
| 903 | - } |
|
| 904 | - if ($mode == 2) |
|
| 905 | - { |
|
| 906 | - if ($statut == 0) |
|
| 907 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 908 | - if ($statut == 1) |
|
| 909 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 910 | - if ($statut == 2) |
|
| 911 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 912 | - } |
|
| 913 | - if ($mode == 3) |
|
| 914 | - { |
|
| 915 | - if ($statut == 0) |
|
| 916 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); |
|
| 917 | - if ($statut == 1) |
|
| 918 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); |
|
| 919 | - if ($statut == 2) |
|
| 920 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); |
|
| 921 | - } |
|
| 922 | - if ($mode == 4) |
|
| 923 | - { |
|
| 924 | - if ($statut == 0) |
|
| 925 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 926 | - if ($statut == 1) |
|
| 927 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 928 | - if ($statut == 2) |
|
| 929 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 930 | - } |
|
| 931 | - if ($mode == 5) |
|
| 932 | - { |
|
| 933 | - if ($statut == 0) |
|
| 934 | - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); |
|
| 935 | - if ($statut == 1) |
|
| 936 | - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); |
|
| 937 | - if ($statut == 2) |
|
| 938 | - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); |
|
| 939 | - } |
|
| 940 | - } |
|
| 941 | - |
|
| 942 | - /** |
|
| 943 | - * Return clicable name (with picto eventually) |
|
| 944 | - * |
|
| 945 | - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto |
|
| 946 | - * @param string $option Variant ('', 'nolink') |
|
| 947 | - * @param int $addlabel 0=Default, 1=Add label into string, >1=Add first chars into string |
|
| 948 | - * @param string $moreinpopup Text to add into popup |
|
| 949 | - * @param string $sep Separator between ref and label if option addlabel is set |
|
| 950 | - * @param int $notooltip 1=Disable tooltip |
|
| 951 | - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
|
| 952 | - * @return string String with URL |
|
| 953 | - */ |
|
| 954 | - function getNomUrl($withpicto=0, $option='', $addlabel=0, $moreinpopup='', $sep=' - ', $notooltip=0, $save_lastsearch_value=-1) |
|
| 955 | - { |
|
| 956 | - global $conf, $langs, $user; |
|
| 957 | - |
|
| 958 | - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
| 959 | - |
|
| 960 | - $result = ''; |
|
| 961 | - |
|
| 962 | - $label=''; |
|
| 963 | - if ($option != 'nolink') $label = '<u>' . $langs->trans("ShowProject") . '</u>'; |
|
| 964 | - $label .= ($label?'<br>':'').'<b>' . $langs->trans('Ref') . ': </b>' . $this->ref; // The space must be after the : to not being explode when showing the title in img_picto |
|
| 965 | - $label .= ($label?'<br>':'').'<b>' . $langs->trans('Label') . ': </b>' . $this->title; // The space must be after the : to not being explode when showing the title in img_picto |
|
| 966 | - if (! empty($this->thirdparty_name)) |
|
| 967 | - $label .= ($label?'<br>':'').'<b>' . $langs->trans('ThirdParty') . ': </b>' . $this->thirdparty_name; // The space must be after the : to not being explode when showing the title in img_picto |
|
| 968 | - if (! empty($this->dateo)) |
|
| 969 | - $label .= ($label?'<br>':'').'<b>' . $langs->trans('DateStart') . ': </b>' . dol_print_date($this->dateo, 'day'); // The space must be after the : to not being explode when showing the title in img_picto |
|
| 970 | - if (! empty($this->datee)) |
|
| 971 | - $label .= ($label?'<br>':'').'<b>' . $langs->trans('DateEnd') . ': </b>' . dol_print_date($this->datee, 'day'); // The space must be after the : to not being explode when showing the title in img_picto |
|
| 972 | - if ($moreinpopup) $label.='<br>'.$moreinpopup; |
|
| 973 | - |
|
| 974 | - $url=''; |
|
| 975 | - if ($option != 'nolink') |
|
| 976 | - { |
|
| 977 | - if (preg_match('/\.php$/',$option)) { |
|
| 978 | - $url = dol_buildpath($option,1) . '?id=' . $this->id; |
|
| 979 | - } |
|
| 980 | - else if ($option == 'task') |
|
| 981 | - { |
|
| 982 | - $url = DOL_URL_ROOT . '/projet/tasks.php?id=' . $this->id; |
|
| 983 | - } |
|
| 984 | - else |
|
| 985 | - { |
|
| 986 | - $url = DOL_URL_ROOT . '/projet/card.php?id=' . $this->id; |
|
| 987 | - } |
|
| 988 | - // Add param to save lastsearch_values or not |
|
| 989 | - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
| 990 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 991 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 992 | - } |
|
| 942 | + /** |
|
| 943 | + * Return clicable name (with picto eventually) |
|
| 944 | + * |
|
| 945 | + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto |
|
| 946 | + * @param string $option Variant ('', 'nolink') |
|
| 947 | + * @param int $addlabel 0=Default, 1=Add label into string, >1=Add first chars into string |
|
| 948 | + * @param string $moreinpopup Text to add into popup |
|
| 949 | + * @param string $sep Separator between ref and label if option addlabel is set |
|
| 950 | + * @param int $notooltip 1=Disable tooltip |
|
| 951 | + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
|
| 952 | + * @return string String with URL |
|
| 953 | + */ |
|
| 954 | + function getNomUrl($withpicto=0, $option='', $addlabel=0, $moreinpopup='', $sep=' - ', $notooltip=0, $save_lastsearch_value=-1) |
|
| 955 | + { |
|
| 956 | + global $conf, $langs, $user; |
|
| 957 | + |
|
| 958 | + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
| 959 | + |
|
| 960 | + $result = ''; |
|
| 961 | + |
|
| 962 | + $label=''; |
|
| 963 | + if ($option != 'nolink') $label = '<u>' . $langs->trans("ShowProject") . '</u>'; |
|
| 964 | + $label .= ($label?'<br>':'').'<b>' . $langs->trans('Ref') . ': </b>' . $this->ref; // The space must be after the : to not being explode when showing the title in img_picto |
|
| 965 | + $label .= ($label?'<br>':'').'<b>' . $langs->trans('Label') . ': </b>' . $this->title; // The space must be after the : to not being explode when showing the title in img_picto |
|
| 966 | + if (! empty($this->thirdparty_name)) |
|
| 967 | + $label .= ($label?'<br>':'').'<b>' . $langs->trans('ThirdParty') . ': </b>' . $this->thirdparty_name; // The space must be after the : to not being explode when showing the title in img_picto |
|
| 968 | + if (! empty($this->dateo)) |
|
| 969 | + $label .= ($label?'<br>':'').'<b>' . $langs->trans('DateStart') . ': </b>' . dol_print_date($this->dateo, 'day'); // The space must be after the : to not being explode when showing the title in img_picto |
|
| 970 | + if (! empty($this->datee)) |
|
| 971 | + $label .= ($label?'<br>':'').'<b>' . $langs->trans('DateEnd') . ': </b>' . dol_print_date($this->datee, 'day'); // The space must be after the : to not being explode when showing the title in img_picto |
|
| 972 | + if ($moreinpopup) $label.='<br>'.$moreinpopup; |
|
| 973 | + |
|
| 974 | + $url=''; |
|
| 975 | + if ($option != 'nolink') |
|
| 976 | + { |
|
| 977 | + if (preg_match('/\.php$/',$option)) { |
|
| 978 | + $url = dol_buildpath($option,1) . '?id=' . $this->id; |
|
| 979 | + } |
|
| 980 | + else if ($option == 'task') |
|
| 981 | + { |
|
| 982 | + $url = DOL_URL_ROOT . '/projet/tasks.php?id=' . $this->id; |
|
| 983 | + } |
|
| 984 | + else |
|
| 985 | + { |
|
| 986 | + $url = DOL_URL_ROOT . '/projet/card.php?id=' . $this->id; |
|
| 987 | + } |
|
| 988 | + // Add param to save lastsearch_values or not |
|
| 989 | + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
| 990 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 991 | + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 992 | + } |
|
| 993 | 993 | |
| 994 | - $linkclose=''; |
|
| 995 | - if (empty($notooltip) && $user->rights->projet->lire) |
|
| 996 | - { |
|
| 997 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 998 | - { |
|
| 999 | - $label=$langs->trans("ShowProject"); |
|
| 1000 | - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1001 | - } |
|
| 1002 | - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1003 | - $linkclose.=' class="classfortooltip"'; |
|
| 994 | + $linkclose=''; |
|
| 995 | + if (empty($notooltip) && $user->rights->projet->lire) |
|
| 996 | + { |
|
| 997 | + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 998 | + { |
|
| 999 | + $label=$langs->trans("ShowProject"); |
|
| 1000 | + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1001 | + } |
|
| 1002 | + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1003 | + $linkclose.=' class="classfortooltip"'; |
|
| 1004 | 1004 | |
| 1005 | 1005 | if (! is_object($hookmanager)) { |
| 1006 | 1006 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
@@ -1012,49 +1012,49 @@ discard block |
||
| 1012 | 1012 | $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); |
| 1013 | 1013 | if ($reshook > 0) |
| 1014 | 1014 | $linkclose = $hookmanager->resPrint; |
| 1015 | - } |
|
| 1015 | + } |
|
| 1016 | + |
|
| 1017 | + $picto = 'projectpub'; |
|
| 1018 | + if (!$this->public) $picto = 'project'; |
|
| 1019 | + |
|
| 1020 | + $linkstart = '<a href="'.$url.'"'; |
|
| 1021 | + $linkstart.=$linkclose.'>'; |
|
| 1022 | + $linkend='</a>'; |
|
| 1016 | 1023 | |
| 1017 | - $picto = 'projectpub'; |
|
| 1018 | - if (!$this->public) $picto = 'project'; |
|
| 1019 | - |
|
| 1020 | - $linkstart = '<a href="'.$url.'"'; |
|
| 1021 | - $linkstart.=$linkclose.'>'; |
|
| 1022 | - $linkend='</a>'; |
|
| 1023 | - |
|
| 1024 | - if ($withpicto) $result.=($linkstart . img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1) . $linkend); |
|
| 1025 | - if ($withpicto && $withpicto != 2) $result.=' '; |
|
| 1026 | - if ($withpicto != 2) $result.=$linkstart . $this->ref . $linkend . (($addlabel && $this->title) ? $sep . dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : ''); |
|
| 1027 | - return $result; |
|
| 1028 | - } |
|
| 1029 | - |
|
| 1030 | - /** |
|
| 1031 | - * Initialise an instance with random values. |
|
| 1032 | - * Used to build previews or test instances. |
|
| 1033 | - * id must be 0 if object instance is a specimen. |
|
| 1034 | - * |
|
| 1035 | - * @return void |
|
| 1036 | - */ |
|
| 1037 | - function initAsSpecimen() |
|
| 1038 | - { |
|
| 1039 | - global $user, $langs, $conf; |
|
| 1040 | - |
|
| 1041 | - $now=dol_now(); |
|
| 1042 | - |
|
| 1043 | - // Initialise parameters |
|
| 1044 | - $this->id = 0; |
|
| 1045 | - $this->ref = 'SPECIMEN'; |
|
| 1046 | - $this->specimen = 1; |
|
| 1047 | - $this->socid = 1; |
|
| 1048 | - $this->date_c = $now; |
|
| 1049 | - $this->date_m = $now; |
|
| 1050 | - $this->date_start = $now; |
|
| 1051 | - $this->date_end = $now + (3600 * 24 * 365); |
|
| 1052 | - $this->note_public = 'SPECIMEN'; |
|
| 1024 | + if ($withpicto) $result.=($linkstart . img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1) . $linkend); |
|
| 1025 | + if ($withpicto && $withpicto != 2) $result.=' '; |
|
| 1026 | + if ($withpicto != 2) $result.=$linkstart . $this->ref . $linkend . (($addlabel && $this->title) ? $sep . dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : ''); |
|
| 1027 | + return $result; |
|
| 1028 | + } |
|
| 1029 | + |
|
| 1030 | + /** |
|
| 1031 | + * Initialise an instance with random values. |
|
| 1032 | + * Used to build previews or test instances. |
|
| 1033 | + * id must be 0 if object instance is a specimen. |
|
| 1034 | + * |
|
| 1035 | + * @return void |
|
| 1036 | + */ |
|
| 1037 | + function initAsSpecimen() |
|
| 1038 | + { |
|
| 1039 | + global $user, $langs, $conf; |
|
| 1040 | + |
|
| 1041 | + $now=dol_now(); |
|
| 1042 | + |
|
| 1043 | + // Initialise parameters |
|
| 1044 | + $this->id = 0; |
|
| 1045 | + $this->ref = 'SPECIMEN'; |
|
| 1046 | + $this->specimen = 1; |
|
| 1047 | + $this->socid = 1; |
|
| 1048 | + $this->date_c = $now; |
|
| 1049 | + $this->date_m = $now; |
|
| 1050 | + $this->date_start = $now; |
|
| 1051 | + $this->date_end = $now + (3600 * 24 * 365); |
|
| 1052 | + $this->note_public = 'SPECIMEN'; |
|
| 1053 | 1053 | $this->fk_ele = 20000; |
| 1054 | - $this->opp_amount = 20000; |
|
| 1055 | - $this->budget_amount = 10000; |
|
| 1054 | + $this->opp_amount = 20000; |
|
| 1055 | + $this->budget_amount = 10000; |
|
| 1056 | 1056 | |
| 1057 | - /* |
|
| 1057 | + /* |
|
| 1058 | 1058 | $nbp = mt_rand(1, 9); |
| 1059 | 1059 | $xnbp = 0; |
| 1060 | 1060 | while ($xnbp < $nbp) |
@@ -1068,166 +1068,166 @@ discard block |
||
| 1068 | 1068 | $xnbp++; |
| 1069 | 1069 | } |
| 1070 | 1070 | */ |
| 1071 | - } |
|
| 1072 | - |
|
| 1073 | - /** |
|
| 1074 | - * Check if user has permission on current project |
|
| 1075 | - * |
|
| 1076 | - * @param User $user Object user to evaluate |
|
| 1077 | - * @param string $mode Type of permission we want to know: 'read', 'write' |
|
| 1078 | - * @return int >0 if user has permission, <0 if user has no permission |
|
| 1079 | - */ |
|
| 1080 | - function restrictedProjectArea($user, $mode='read') |
|
| 1081 | - { |
|
| 1082 | - // To verify role of users |
|
| 1083 | - $userAccess = 0; |
|
| 1084 | - if (($mode == 'read' && ! empty($user->rights->projet->all->lire)) || ($mode == 'write' && ! empty($user->rights->projet->all->creer)) || ($mode == 'delete' && ! empty($user->rights->projet->all->supprimer))) |
|
| 1085 | - { |
|
| 1086 | - $userAccess = 1; |
|
| 1087 | - } |
|
| 1088 | - else if ($this->public && (($mode == 'read' && ! empty($user->rights->projet->lire)) || ($mode == 'write' && ! empty($user->rights->projet->creer)) || ($mode == 'delete' && ! empty($user->rights->projet->supprimer)))) |
|
| 1089 | - { |
|
| 1090 | - $userAccess = 1; |
|
| 1091 | - } |
|
| 1092 | - else |
|
| 1093 | - { |
|
| 1094 | - foreach (array('internal', 'external') as $source) |
|
| 1095 | - { |
|
| 1096 | - $userRole = $this->liste_contact(4, $source); |
|
| 1097 | - $num = count($userRole); |
|
| 1098 | - |
|
| 1099 | - $nblinks = 0; |
|
| 1100 | - while ($nblinks < $num) |
|
| 1101 | - { |
|
| 1102 | - if ($source == 'internal' && preg_match('/^PROJECT/', $userRole[$nblinks]['code']) && $user->id == $userRole[$nblinks]['id']) |
|
| 1103 | - { |
|
| 1104 | - if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; |
|
| 1105 | - if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; |
|
| 1106 | - if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++; |
|
| 1107 | - } |
|
| 1108 | - $nblinks++; |
|
| 1109 | - } |
|
| 1110 | - } |
|
| 1111 | - //if (empty($nblinks)) // If nobody has permission, we grant creator |
|
| 1112 | - //{ |
|
| 1113 | - // if ((!empty($this->user_author_id) && $this->user_author_id == $user->id)) |
|
| 1114 | - // { |
|
| 1115 | - // $userAccess = 1; |
|
| 1116 | - // } |
|
| 1117 | - //} |
|
| 1118 | - } |
|
| 1071 | + } |
|
| 1119 | 1072 | |
| 1120 | - return ($userAccess?$userAccess:-1); |
|
| 1121 | - } |
|
| 1122 | - |
|
| 1123 | - /** |
|
| 1124 | - * Return array of projects a user has permission on, is affected to, or all projects |
|
| 1125 | - * |
|
| 1126 | - * @param User $user User object |
|
| 1127 | - * @param int $mode 0=All project I have permission on (assigned to me and public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts |
|
| 1128 | - * @param int $list 0=Return array,1=Return string list |
|
| 1129 | - * @param int $socid 0=No filter on third party, id of third party |
|
| 1130 | - * @param string $filter additionnal filter on project (statut, ref, ...) |
|
| 1131 | - * @return array or string Array of projects id, or string with projects id separated with "," |
|
| 1132 | - */ |
|
| 1133 | - function getProjectsAuthorizedForUser($user, $mode=0, $list=0, $socid=0, $filter='') |
|
| 1134 | - { |
|
| 1135 | - $projects = array(); |
|
| 1136 | - $temp = array(); |
|
| 1137 | - |
|
| 1138 | - $sql = "SELECT ".(($mode == 0 || $mode == 1) ? "DISTINCT " : "")."p.rowid, p.ref"; |
|
| 1139 | - $sql.= " FROM " . MAIN_DB_PREFIX . "projet as p"; |
|
| 1140 | - if ($mode == 0 || $mode == 1) |
|
| 1141 | - { |
|
| 1142 | - $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ec"; |
|
| 1143 | - } |
|
| 1144 | - $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
|
| 1145 | - // Internal users must see project he is contact to even if project linked to a third party he can't see. |
|
| 1146 | - //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1147 | - if ($socid > 0) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")"; |
|
| 1148 | - |
|
| 1149 | - // Get id of types of contacts for projects (This list never contains a lot of elements) |
|
| 1150 | - $listofprojectcontacttype=array(); |
|
| 1151 | - $sql2 = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
|
| 1152 | - $sql2.= " WHERE ctc.element = '" . $this->db->escape($this->element) . "'"; |
|
| 1153 | - $sql2.= " AND ctc.source = 'internal'"; |
|
| 1154 | - $resql = $this->db->query($sql2); |
|
| 1155 | - if ($resql) |
|
| 1156 | - { |
|
| 1157 | - while($obj = $this->db->fetch_object($resql)) |
|
| 1158 | - { |
|
| 1159 | - $listofprojectcontacttype[$obj->rowid]=$obj->code; |
|
| 1160 | - } |
|
| 1161 | - } |
|
| 1162 | - else dol_print_error($this->db); |
|
| 1163 | - if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid syntax error if not found |
|
| 1073 | + /** |
|
| 1074 | + * Check if user has permission on current project |
|
| 1075 | + * |
|
| 1076 | + * @param User $user Object user to evaluate |
|
| 1077 | + * @param string $mode Type of permission we want to know: 'read', 'write' |
|
| 1078 | + * @return int >0 if user has permission, <0 if user has no permission |
|
| 1079 | + */ |
|
| 1080 | + function restrictedProjectArea($user, $mode='read') |
|
| 1081 | + { |
|
| 1082 | + // To verify role of users |
|
| 1083 | + $userAccess = 0; |
|
| 1084 | + if (($mode == 'read' && ! empty($user->rights->projet->all->lire)) || ($mode == 'write' && ! empty($user->rights->projet->all->creer)) || ($mode == 'delete' && ! empty($user->rights->projet->all->supprimer))) |
|
| 1085 | + { |
|
| 1086 | + $userAccess = 1; |
|
| 1087 | + } |
|
| 1088 | + else if ($this->public && (($mode == 'read' && ! empty($user->rights->projet->lire)) || ($mode == 'write' && ! empty($user->rights->projet->creer)) || ($mode == 'delete' && ! empty($user->rights->projet->supprimer)))) |
|
| 1089 | + { |
|
| 1090 | + $userAccess = 1; |
|
| 1091 | + } |
|
| 1092 | + else |
|
| 1093 | + { |
|
| 1094 | + foreach (array('internal', 'external') as $source) |
|
| 1095 | + { |
|
| 1096 | + $userRole = $this->liste_contact(4, $source); |
|
| 1097 | + $num = count($userRole); |
|
| 1164 | 1098 | |
| 1165 | - if ($mode == 0) |
|
| 1166 | - { |
|
| 1167 | - $sql.= " AND ec.element_id = p.rowid"; |
|
| 1168 | - $sql.= " AND ( p.public = 1"; |
|
| 1169 | - $sql.= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; |
|
| 1170 | - $sql.= " AND ec.fk_socpeople = ".$user->id.")"; |
|
| 1171 | - $sql.= " )"; |
|
| 1172 | - } |
|
| 1173 | - if ($mode == 1) |
|
| 1174 | - { |
|
| 1175 | - $sql.= " AND ec.element_id = p.rowid"; |
|
| 1176 | - $sql.= " AND ("; |
|
| 1177 | - $sql.= " ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; |
|
| 1178 | - $sql.= " AND ec.fk_socpeople = ".$user->id.")"; |
|
| 1179 | - $sql.= " )"; |
|
| 1180 | - } |
|
| 1181 | - if ($mode == 2) |
|
| 1182 | - { |
|
| 1183 | - // No filter. Use this if user has permission to see all project |
|
| 1184 | - } |
|
| 1099 | + $nblinks = 0; |
|
| 1100 | + while ($nblinks < $num) |
|
| 1101 | + { |
|
| 1102 | + if ($source == 'internal' && preg_match('/^PROJECT/', $userRole[$nblinks]['code']) && $user->id == $userRole[$nblinks]['id']) |
|
| 1103 | + { |
|
| 1104 | + if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; |
|
| 1105 | + if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; |
|
| 1106 | + if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++; |
|
| 1107 | + } |
|
| 1108 | + $nblinks++; |
|
| 1109 | + } |
|
| 1110 | + } |
|
| 1111 | + //if (empty($nblinks)) // If nobody has permission, we grant creator |
|
| 1112 | + //{ |
|
| 1113 | + // if ((!empty($this->user_author_id) && $this->user_author_id == $user->id)) |
|
| 1114 | + // { |
|
| 1115 | + // $userAccess = 1; |
|
| 1116 | + // } |
|
| 1117 | + //} |
|
| 1118 | + } |
|
| 1119 | + |
|
| 1120 | + return ($userAccess?$userAccess:-1); |
|
| 1121 | + } |
|
| 1122 | + |
|
| 1123 | + /** |
|
| 1124 | + * Return array of projects a user has permission on, is affected to, or all projects |
|
| 1125 | + * |
|
| 1126 | + * @param User $user User object |
|
| 1127 | + * @param int $mode 0=All project I have permission on (assigned to me and public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts |
|
| 1128 | + * @param int $list 0=Return array,1=Return string list |
|
| 1129 | + * @param int $socid 0=No filter on third party, id of third party |
|
| 1130 | + * @param string $filter additionnal filter on project (statut, ref, ...) |
|
| 1131 | + * @return array or string Array of projects id, or string with projects id separated with "," |
|
| 1132 | + */ |
|
| 1133 | + function getProjectsAuthorizedForUser($user, $mode=0, $list=0, $socid=0, $filter='') |
|
| 1134 | + { |
|
| 1135 | + $projects = array(); |
|
| 1136 | + $temp = array(); |
|
| 1137 | + |
|
| 1138 | + $sql = "SELECT ".(($mode == 0 || $mode == 1) ? "DISTINCT " : "")."p.rowid, p.ref"; |
|
| 1139 | + $sql.= " FROM " . MAIN_DB_PREFIX . "projet as p"; |
|
| 1140 | + if ($mode == 0 || $mode == 1) |
|
| 1141 | + { |
|
| 1142 | + $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ec"; |
|
| 1143 | + } |
|
| 1144 | + $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
|
| 1145 | + // Internal users must see project he is contact to even if project linked to a third party he can't see. |
|
| 1146 | + //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1147 | + if ($socid > 0) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")"; |
|
| 1148 | + |
|
| 1149 | + // Get id of types of contacts for projects (This list never contains a lot of elements) |
|
| 1150 | + $listofprojectcontacttype=array(); |
|
| 1151 | + $sql2 = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
|
| 1152 | + $sql2.= " WHERE ctc.element = '" . $this->db->escape($this->element) . "'"; |
|
| 1153 | + $sql2.= " AND ctc.source = 'internal'"; |
|
| 1154 | + $resql = $this->db->query($sql2); |
|
| 1155 | + if ($resql) |
|
| 1156 | + { |
|
| 1157 | + while($obj = $this->db->fetch_object($resql)) |
|
| 1158 | + { |
|
| 1159 | + $listofprojectcontacttype[$obj->rowid]=$obj->code; |
|
| 1160 | + } |
|
| 1161 | + } |
|
| 1162 | + else dol_print_error($this->db); |
|
| 1163 | + if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid syntax error if not found |
|
| 1164 | + |
|
| 1165 | + if ($mode == 0) |
|
| 1166 | + { |
|
| 1167 | + $sql.= " AND ec.element_id = p.rowid"; |
|
| 1168 | + $sql.= " AND ( p.public = 1"; |
|
| 1169 | + $sql.= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; |
|
| 1170 | + $sql.= " AND ec.fk_socpeople = ".$user->id.")"; |
|
| 1171 | + $sql.= " )"; |
|
| 1172 | + } |
|
| 1173 | + if ($mode == 1) |
|
| 1174 | + { |
|
| 1175 | + $sql.= " AND ec.element_id = p.rowid"; |
|
| 1176 | + $sql.= " AND ("; |
|
| 1177 | + $sql.= " ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; |
|
| 1178 | + $sql.= " AND ec.fk_socpeople = ".$user->id.")"; |
|
| 1179 | + $sql.= " )"; |
|
| 1180 | + } |
|
| 1181 | + if ($mode == 2) |
|
| 1182 | + { |
|
| 1183 | + // No filter. Use this if user has permission to see all project |
|
| 1184 | + } |
|
| 1185 | 1185 | |
| 1186 | 1186 | $sql.= $filter; |
| 1187 | - //print $sql; |
|
| 1187 | + //print $sql; |
|
| 1188 | 1188 | |
| 1189 | - $resql = $this->db->query($sql); |
|
| 1190 | - if ($resql) |
|
| 1191 | - { |
|
| 1192 | - $num = $this->db->num_rows($resql); |
|
| 1193 | - $i = 0; |
|
| 1194 | - while ($i < $num) |
|
| 1195 | - { |
|
| 1196 | - $row = $this->db->fetch_row($resql); |
|
| 1197 | - $projects[$row[0]] = $row[1]; |
|
| 1198 | - $temp[] = $row[0]; |
|
| 1199 | - $i++; |
|
| 1200 | - } |
|
| 1201 | - |
|
| 1202 | - $this->db->free($resql); |
|
| 1203 | - |
|
| 1204 | - if ($list) |
|
| 1205 | - { |
|
| 1206 | - if (empty($temp)) return '0'; |
|
| 1207 | - $result = implode(',', $temp); |
|
| 1208 | - return $result; |
|
| 1209 | - } |
|
| 1210 | - } |
|
| 1211 | - else |
|
| 1212 | - { |
|
| 1213 | - dol_print_error($this->db); |
|
| 1214 | - } |
|
| 1189 | + $resql = $this->db->query($sql); |
|
| 1190 | + if ($resql) |
|
| 1191 | + { |
|
| 1192 | + $num = $this->db->num_rows($resql); |
|
| 1193 | + $i = 0; |
|
| 1194 | + while ($i < $num) |
|
| 1195 | + { |
|
| 1196 | + $row = $this->db->fetch_row($resql); |
|
| 1197 | + $projects[$row[0]] = $row[1]; |
|
| 1198 | + $temp[] = $row[0]; |
|
| 1199 | + $i++; |
|
| 1200 | + } |
|
| 1201 | + |
|
| 1202 | + $this->db->free($resql); |
|
| 1215 | 1203 | |
| 1216 | - return $projects; |
|
| 1217 | - } |
|
| 1204 | + if ($list) |
|
| 1205 | + { |
|
| 1206 | + if (empty($temp)) return '0'; |
|
| 1207 | + $result = implode(',', $temp); |
|
| 1208 | + return $result; |
|
| 1209 | + } |
|
| 1210 | + } |
|
| 1211 | + else |
|
| 1212 | + { |
|
| 1213 | + dol_print_error($this->db); |
|
| 1214 | + } |
|
| 1215 | + |
|
| 1216 | + return $projects; |
|
| 1217 | + } |
|
| 1218 | 1218 | |
| 1219 | - /** |
|
| 1220 | - * Load an object from its id and create a new one in database |
|
| 1219 | + /** |
|
| 1220 | + * Load an object from its id and create a new one in database |
|
| 1221 | 1221 | * |
| 1222 | 1222 | * @param int $fromid Id of object to clone |
| 1223 | 1223 | * @param bool $clone_contact Clone contact of project |
| 1224 | 1224 | * @param bool $clone_task Clone task of project |
| 1225 | 1225 | * @param bool $clone_project_file Clone file of project |
| 1226 | 1226 | * @param bool $clone_task_file Clone file of task (if task are copied) |
| 1227 | - * @param bool $clone_note Clone note of project |
|
| 1228 | - * @param bool $move_date Move task date on clone |
|
| 1229 | - * @param integer $notrigger No trigger flag |
|
| 1230 | - * @param int $newthirdpartyid New thirdparty id |
|
| 1227 | + * @param bool $clone_note Clone note of project |
|
| 1228 | + * @param bool $move_date Move task date on clone |
|
| 1229 | + * @param integer $notrigger No trigger flag |
|
| 1230 | + * @param int $newthirdpartyid New thirdparty id |
|
| 1231 | 1231 | * @return int New id of clone |
| 1232 | 1232 | */ |
| 1233 | 1233 | function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_project_file=false,$clone_task_file=false,$clone_note=true,$move_date=true,$notrigger=0,$newthirdpartyid=0) |
@@ -1257,40 +1257,40 @@ discard block |
||
| 1257 | 1257 | |
| 1258 | 1258 | $clone_project->id=0; |
| 1259 | 1259 | if ($move_date) { |
| 1260 | - $clone_project->date_start = $now; |
|
| 1261 | - if (!(empty($clone_project->date_end))) |
|
| 1262 | - { |
|
| 1263 | - $clone_project->date_end = $clone_project->date_end + ($now - $orign_dt_start); |
|
| 1264 | - } |
|
| 1260 | + $clone_project->date_start = $now; |
|
| 1261 | + if (!(empty($clone_project->date_end))) |
|
| 1262 | + { |
|
| 1263 | + $clone_project->date_end = $clone_project->date_end + ($now - $orign_dt_start); |
|
| 1264 | + } |
|
| 1265 | 1265 | } |
| 1266 | 1266 | |
| 1267 | - $clone_project->datec = $now; |
|
| 1267 | + $clone_project->datec = $now; |
|
| 1268 | 1268 | |
| 1269 | - if (! $clone_note) |
|
| 1270 | - { |
|
| 1271 | - $clone_project->note_private=''; |
|
| 1272 | - $clone_project->note_public=''; |
|
| 1273 | - } |
|
| 1269 | + if (! $clone_note) |
|
| 1270 | + { |
|
| 1271 | + $clone_project->note_private=''; |
|
| 1272 | + $clone_project->note_public=''; |
|
| 1273 | + } |
|
| 1274 | 1274 | |
| 1275 | 1275 | //Generate next ref |
| 1276 | 1276 | $defaultref=''; |
| 1277 | - $obj = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; |
|
| 1278 | - // Search template files |
|
| 1279 | - $file=''; $classname=''; $filefound=0; |
|
| 1280 | - $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); |
|
| 1281 | - foreach($dirmodels as $reldir) |
|
| 1282 | - { |
|
| 1283 | - $file=dol_buildpath($reldir."core/modules/project/".$obj.'.php',0); |
|
| 1284 | - if (file_exists($file)) |
|
| 1285 | - { |
|
| 1286 | - $filefound=1; |
|
| 1287 | - dol_include_once($reldir."core/modules/project/".$obj.'.php'); |
|
| 1288 | - $modProject = new $obj; |
|
| 1289 | - $defaultref = $modProject->getNextValue(is_object($clone_project->thirdparty)?$clone_project->thirdparty:null, $clone_project); |
|
| 1290 | - break; |
|
| 1291 | - } |
|
| 1292 | - } |
|
| 1293 | - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; |
|
| 1277 | + $obj = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; |
|
| 1278 | + // Search template files |
|
| 1279 | + $file=''; $classname=''; $filefound=0; |
|
| 1280 | + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); |
|
| 1281 | + foreach($dirmodels as $reldir) |
|
| 1282 | + { |
|
| 1283 | + $file=dol_buildpath($reldir."core/modules/project/".$obj.'.php',0); |
|
| 1284 | + if (file_exists($file)) |
|
| 1285 | + { |
|
| 1286 | + $filefound=1; |
|
| 1287 | + dol_include_once($reldir."core/modules/project/".$obj.'.php'); |
|
| 1288 | + $modProject = new $obj; |
|
| 1289 | + $defaultref = $modProject->getNextValue(is_object($clone_project->thirdparty)?$clone_project->thirdparty:null, $clone_project); |
|
| 1290 | + break; |
|
| 1291 | + } |
|
| 1292 | + } |
|
| 1293 | + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; |
|
| 1294 | 1294 | |
| 1295 | 1295 | $clone_project->ref=$defaultref; |
| 1296 | 1296 | $clone_project->title=$langs->trans("CopyOf").' '.$clone_project->title; |
@@ -1312,13 +1312,13 @@ discard block |
||
| 1312 | 1312 | |
| 1313 | 1313 | //Note Update |
| 1314 | 1314 | if (!$clone_note) |
| 1315 | - { |
|
| 1316 | - $clone_project->note_private=''; |
|
| 1317 | - $clone_project->note_public=''; |
|
| 1318 | - } |
|
| 1319 | - else |
|
| 1320 | - { |
|
| 1321 | - $this->db->begin(); |
|
| 1315 | + { |
|
| 1316 | + $clone_project->note_private=''; |
|
| 1317 | + $clone_project->note_public=''; |
|
| 1318 | + } |
|
| 1319 | + else |
|
| 1320 | + { |
|
| 1321 | + $this->db->begin(); |
|
| 1322 | 1322 | $res=$clone_project->update_note(dol_html_entity_decode($clone_project->note_public, ENT_QUOTES),'_public'); |
| 1323 | 1323 | if ($res < 0) |
| 1324 | 1324 | { |
@@ -1343,7 +1343,7 @@ discard block |
||
| 1343 | 1343 | { |
| 1344 | 1344 | $this->db->commit(); |
| 1345 | 1345 | } |
| 1346 | - } |
|
| 1346 | + } |
|
| 1347 | 1347 | |
| 1348 | 1348 | //Duplicate contact |
| 1349 | 1349 | if ($clone_contact) |
@@ -1420,45 +1420,45 @@ discard block |
||
| 1420 | 1420 | $tab_conv_child_parent=array(); |
| 1421 | 1421 | |
| 1422 | 1422 | // Loop on each task, to clone it |
| 1423 | - foreach ($tasksarray as $tasktoclone) |
|
| 1424 | - { |
|
| 1423 | + foreach ($tasksarray as $tasktoclone) |
|
| 1424 | + { |
|
| 1425 | 1425 | $result_clone = $taskstatic->createFromClone($tasktoclone->id,$clone_project_id,$tasktoclone->fk_parent,$move_date,true,false,$clone_task_file,true,false); |
| 1426 | 1426 | if ($result_clone <= 0) |
| 1427 | - { |
|
| 1428 | - $this->error.=$result_clone->error; |
|
| 1427 | + { |
|
| 1428 | + $this->error.=$result_clone->error; |
|
| 1429 | 1429 | $error++; |
| 1430 | - } |
|
| 1431 | - else |
|
| 1432 | - { |
|
| 1433 | - $new_task_id=$result_clone; |
|
| 1434 | - $taskstatic->fetch($tasktoclone->id); |
|
| 1435 | - |
|
| 1436 | - //manage new parent clone task id |
|
| 1437 | - // if the current task has child we store the original task id and the equivalent clone task id |
|
| 1430 | + } |
|
| 1431 | + else |
|
| 1432 | + { |
|
| 1433 | + $new_task_id=$result_clone; |
|
| 1434 | + $taskstatic->fetch($tasktoclone->id); |
|
| 1435 | + |
|
| 1436 | + //manage new parent clone task id |
|
| 1437 | + // if the current task has child we store the original task id and the equivalent clone task id |
|
| 1438 | 1438 | if (($taskstatic->hasChildren()) && !array_key_exists($tasktoclone->id,$tab_conv_child_parent)) |
| 1439 | 1439 | { |
| 1440 | 1440 | $tab_conv_child_parent[$tasktoclone->id] = $new_task_id; |
| 1441 | 1441 | } |
| 1442 | - } |
|
| 1443 | - |
|
| 1444 | - } |
|
| 1445 | - |
|
| 1446 | - //Parse all clone node to be sure to update new parent |
|
| 1447 | - $tasksarray=$taskstatic->getTasksArray(0, 0, $clone_project_id, $socid, 0); |
|
| 1448 | - foreach ($tasksarray as $task_cloned) |
|
| 1449 | - { |
|
| 1450 | - $taskstatic->fetch($task_cloned->id); |
|
| 1451 | - if ($taskstatic->fk_task_parent!=0) |
|
| 1452 | - { |
|
| 1453 | - $taskstatic->fk_task_parent=$tab_conv_child_parent[$taskstatic->fk_task_parent]; |
|
| 1454 | - } |
|
| 1455 | - $res=$taskstatic->update($user,$notrigger); |
|
| 1456 | - if ($result_clone <= 0) |
|
| 1457 | - { |
|
| 1458 | - $this->error.=$taskstatic->error; |
|
| 1442 | + } |
|
| 1443 | + |
|
| 1444 | + } |
|
| 1445 | + |
|
| 1446 | + //Parse all clone node to be sure to update new parent |
|
| 1447 | + $tasksarray=$taskstatic->getTasksArray(0, 0, $clone_project_id, $socid, 0); |
|
| 1448 | + foreach ($tasksarray as $task_cloned) |
|
| 1449 | + { |
|
| 1450 | + $taskstatic->fetch($task_cloned->id); |
|
| 1451 | + if ($taskstatic->fk_task_parent!=0) |
|
| 1452 | + { |
|
| 1453 | + $taskstatic->fk_task_parent=$tab_conv_child_parent[$taskstatic->fk_task_parent]; |
|
| 1454 | + } |
|
| 1455 | + $res=$taskstatic->update($user,$notrigger); |
|
| 1456 | + if ($result_clone <= 0) |
|
| 1457 | + { |
|
| 1458 | + $this->error.=$taskstatic->error; |
|
| 1459 | 1459 | $error++; |
| 1460 | - } |
|
| 1461 | - } |
|
| 1460 | + } |
|
| 1461 | + } |
|
| 1462 | 1462 | } |
| 1463 | 1463 | } |
| 1464 | 1464 | |
@@ -1498,51 +1498,51 @@ discard block |
||
| 1498 | 1498 | |
| 1499 | 1499 | $tasksarray=$taskstatic->getTasksArray(0, 0, $this->id, $socid, 0); |
| 1500 | 1500 | |
| 1501 | - foreach ($tasksarray as $tasktoshiftdate) |
|
| 1502 | - { |
|
| 1503 | - $to_update=false; |
|
| 1504 | - // Fetch only if update of date will be made |
|
| 1505 | - if ((!empty($tasktoshiftdate->date_start)) || (!empty($tasktoshiftdate->date_end))) |
|
| 1506 | - { |
|
| 1507 | - //dol_syslog(get_class($this)."::shiftTaskDate to_update", LOG_DEBUG); |
|
| 1508 | - $to_update=true; |
|
| 1509 | - $task = new Task($this->db); |
|
| 1510 | - $result = $task->fetch($tasktoshiftdate->id); |
|
| 1511 | - if (!$result) |
|
| 1512 | - { |
|
| 1513 | - $error++; |
|
| 1514 | - $this->error.=$task->error; |
|
| 1515 | - } |
|
| 1516 | - } |
|
| 1501 | + foreach ($tasksarray as $tasktoshiftdate) |
|
| 1502 | + { |
|
| 1503 | + $to_update=false; |
|
| 1504 | + // Fetch only if update of date will be made |
|
| 1505 | + if ((!empty($tasktoshiftdate->date_start)) || (!empty($tasktoshiftdate->date_end))) |
|
| 1506 | + { |
|
| 1507 | + //dol_syslog(get_class($this)."::shiftTaskDate to_update", LOG_DEBUG); |
|
| 1508 | + $to_update=true; |
|
| 1509 | + $task = new Task($this->db); |
|
| 1510 | + $result = $task->fetch($tasktoshiftdate->id); |
|
| 1511 | + if (!$result) |
|
| 1512 | + { |
|
| 1513 | + $error++; |
|
| 1514 | + $this->error.=$task->error; |
|
| 1515 | + } |
|
| 1516 | + } |
|
| 1517 | 1517 | //print "$this->date_start + $tasktoshiftdate->date_start - $old_project_dt_start";exit; |
| 1518 | 1518 | |
| 1519 | - //Calcultate new task start date with difference between old proj start date and origin task start date |
|
| 1520 | - if (!empty($tasktoshiftdate->date_start)) |
|
| 1521 | - { |
|
| 1519 | + //Calcultate new task start date with difference between old proj start date and origin task start date |
|
| 1520 | + if (!empty($tasktoshiftdate->date_start)) |
|
| 1521 | + { |
|
| 1522 | 1522 | $task->date_start = $this->date_start + ($tasktoshiftdate->date_start - $old_project_dt_start); |
| 1523 | - } |
|
| 1523 | + } |
|
| 1524 | 1524 | |
| 1525 | - //Calcultate new task end date with difference between origin proj end date and origin task end date |
|
| 1526 | - if (!empty($tasktoshiftdate->date_end)) |
|
| 1527 | - { |
|
| 1525 | + //Calcultate new task end date with difference between origin proj end date and origin task end date |
|
| 1526 | + if (!empty($tasktoshiftdate->date_end)) |
|
| 1527 | + { |
|
| 1528 | 1528 | $task->date_end = $this->date_start + ($tasktoshiftdate->date_end - $old_project_dt_start); |
| 1529 | - } |
|
| 1529 | + } |
|
| 1530 | 1530 | |
| 1531 | 1531 | if ($to_update) |
| 1532 | 1532 | { |
| 1533 | - $result = $task->update($user); |
|
| 1534 | - if (!$result) |
|
| 1535 | - { |
|
| 1536 | - $error++; |
|
| 1537 | - $this->error.=$task->error; |
|
| 1538 | - } |
|
| 1533 | + $result = $task->update($user); |
|
| 1534 | + if (!$result) |
|
| 1535 | + { |
|
| 1536 | + $error++; |
|
| 1537 | + $this->error.=$task->error; |
|
| 1538 | + } |
|
| 1539 | 1539 | } |
| 1540 | - } |
|
| 1541 | - if ($error!=0) |
|
| 1542 | - { |
|
| 1543 | - return -1; |
|
| 1544 | - } |
|
| 1545 | - return $result; |
|
| 1540 | + } |
|
| 1541 | + if ($error!=0) |
|
| 1542 | + { |
|
| 1543 | + return -1; |
|
| 1544 | + } |
|
| 1545 | + return $result; |
|
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | 1548 | |
@@ -1654,109 +1654,109 @@ discard block |
||
| 1654 | 1654 | * @return int <0 if OK, >0 if KO |
| 1655 | 1655 | */ |
| 1656 | 1656 | public function loadTimeSpent($datestart,$taskid=0,$userid=0) |
| 1657 | - { |
|
| 1658 | - $error=0; |
|
| 1659 | - |
|
| 1660 | - if (empty($datestart)) dol_print_error('','Error datestart parameter is empty'); |
|
| 1661 | - |
|
| 1662 | - $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.fk_task"; |
|
| 1663 | - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; |
|
| 1664 | - $sql.= " WHERE ptt.fk_task = pt.rowid"; |
|
| 1665 | - $sql.= " AND pt.fk_projet = ".$this->id; |
|
| 1666 | - $sql.= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' "; |
|
| 1667 | - $sql.= " AND ptt.task_date <= '".$this->db->idate($datestart + (7 * 24 * 3600) - 1)."')"; |
|
| 1668 | - if ($task_id) $sql.= " AND ptt.fk_task=".$taskid; |
|
| 1669 | - if (is_numeric($userid)) $sql.= " AND ptt.fk_user=".$userid; |
|
| 1670 | - |
|
| 1671 | - //print $sql; |
|
| 1672 | - $resql=$this->db->query($sql); |
|
| 1673 | - if ($resql) |
|
| 1674 | - { |
|
| 1657 | + { |
|
| 1658 | + $error=0; |
|
| 1675 | 1659 | |
| 1676 | - $num = $this->db->num_rows($resql); |
|
| 1677 | - $i = 0; |
|
| 1678 | - // Loop on each record found, so each couple (project id, task id) |
|
| 1679 | - while ($i < $num) |
|
| 1680 | - { |
|
| 1681 | - $obj=$this->db->fetch_object($resql); |
|
| 1682 | - $day=$this->db->jdate($obj->task_date); |
|
| 1683 | - $this->weekWorkLoad[$day] += $obj->task_duration; |
|
| 1684 | - $this->weekWorkLoadPerTask[$day][$obj->fk_task] += $obj->task_duration; |
|
| 1685 | - $i++; |
|
| 1686 | - } |
|
| 1687 | - $this->db->free($resql); |
|
| 1688 | - return 1; |
|
| 1689 | - } |
|
| 1690 | - else |
|
| 1691 | - { |
|
| 1692 | - $this->error="Error ".$this->db->lasterror(); |
|
| 1693 | - dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); |
|
| 1694 | - return -1; |
|
| 1695 | - } |
|
| 1696 | - } |
|
| 1697 | - |
|
| 1698 | - |
|
| 1699 | - /** |
|
| 1700 | - * Load indicators for dashboard (this->nbtodo and this->nbtodolate) |
|
| 1701 | - * |
|
| 1702 | - * @param User $user Objet user |
|
| 1703 | - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK |
|
| 1704 | - */ |
|
| 1705 | - function load_board($user) |
|
| 1706 | - { |
|
| 1707 | - global $conf, $langs; |
|
| 1708 | - |
|
| 1709 | - $mine=0; $socid=$user->societe_id; |
|
| 1710 | - |
|
| 1711 | - $projectsListId = $this->getProjectsAuthorizedForUser($user,$mine?$mine:($user->rights->projet->all->lire?2:0),1,$socid); |
|
| 1712 | - |
|
| 1713 | - $sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee"; |
|
| 1714 | - $sql.= " FROM (".MAIN_DB_PREFIX."projet as p"; |
|
| 1715 | - $sql.= ")"; |
|
| 1716 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; |
|
| 1717 | - if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; |
|
| 1718 | - $sql.= " WHERE p.fk_statut = 1"; |
|
| 1719 | - $sql.= " AND p.entity IN (".getEntity('project', 0).')'; |
|
| 1720 | - if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
| 1721 | - // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser |
|
| 1722 | - //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1723 | - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1724 | - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; |
|
| 1725 | - |
|
| 1726 | - $resql=$this->db->query($sql); |
|
| 1727 | - if ($resql) |
|
| 1728 | - { |
|
| 1729 | - $project_static = new Project($this->db); |
|
| 1730 | - |
|
| 1731 | - $response = new WorkboardResponse(); |
|
| 1732 | - $response->warning_delay = $conf->projet->warning_delay/60/60/24; |
|
| 1733 | - $response->label = $langs->trans("OpenedProjects"); |
|
| 1734 | - if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/list.php?search_status=1&mainmenu=project'; |
|
| 1735 | - else $response->url = DOL_URL_ROOT.'/projet/list.php?search_project_user=-1&search_status=1&mainmenu=project'; |
|
| 1736 | - $response->img = img_object('',"projectpub"); |
|
| 1737 | - |
|
| 1738 | - // This assignment in condition is not a bug. It allows walking the results. |
|
| 1739 | - while ($obj=$this->db->fetch_object($resql)) |
|
| 1740 | - { |
|
| 1741 | - $response->nbtodo++; |
|
| 1742 | - |
|
| 1743 | - $project_static->statut = $obj->status; |
|
| 1744 | - $project_static->opp_status = $obj->opp_status; |
|
| 1745 | - $project_static->datee = $this->db->jdate($obj->datee); |
|
| 1746 | - |
|
| 1747 | - if ($project_static->hasDelay()) { |
|
| 1748 | - $response->nbtodolate++; |
|
| 1749 | - } |
|
| 1750 | - } |
|
| 1751 | - |
|
| 1752 | - return $response; |
|
| 1753 | - } |
|
| 1754 | - else |
|
| 1755 | - { |
|
| 1756 | - $this->error=$this->db->error(); |
|
| 1757 | - return -1; |
|
| 1758 | - } |
|
| 1759 | - } |
|
| 1660 | + if (empty($datestart)) dol_print_error('','Error datestart parameter is empty'); |
|
| 1661 | + |
|
| 1662 | + $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.fk_task"; |
|
| 1663 | + $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; |
|
| 1664 | + $sql.= " WHERE ptt.fk_task = pt.rowid"; |
|
| 1665 | + $sql.= " AND pt.fk_projet = ".$this->id; |
|
| 1666 | + $sql.= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' "; |
|
| 1667 | + $sql.= " AND ptt.task_date <= '".$this->db->idate($datestart + (7 * 24 * 3600) - 1)."')"; |
|
| 1668 | + if ($task_id) $sql.= " AND ptt.fk_task=".$taskid; |
|
| 1669 | + if (is_numeric($userid)) $sql.= " AND ptt.fk_user=".$userid; |
|
| 1670 | + |
|
| 1671 | + //print $sql; |
|
| 1672 | + $resql=$this->db->query($sql); |
|
| 1673 | + if ($resql) |
|
| 1674 | + { |
|
| 1675 | + |
|
| 1676 | + $num = $this->db->num_rows($resql); |
|
| 1677 | + $i = 0; |
|
| 1678 | + // Loop on each record found, so each couple (project id, task id) |
|
| 1679 | + while ($i < $num) |
|
| 1680 | + { |
|
| 1681 | + $obj=$this->db->fetch_object($resql); |
|
| 1682 | + $day=$this->db->jdate($obj->task_date); |
|
| 1683 | + $this->weekWorkLoad[$day] += $obj->task_duration; |
|
| 1684 | + $this->weekWorkLoadPerTask[$day][$obj->fk_task] += $obj->task_duration; |
|
| 1685 | + $i++; |
|
| 1686 | + } |
|
| 1687 | + $this->db->free($resql); |
|
| 1688 | + return 1; |
|
| 1689 | + } |
|
| 1690 | + else |
|
| 1691 | + { |
|
| 1692 | + $this->error="Error ".$this->db->lasterror(); |
|
| 1693 | + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); |
|
| 1694 | + return -1; |
|
| 1695 | + } |
|
| 1696 | + } |
|
| 1697 | + |
|
| 1698 | + |
|
| 1699 | + /** |
|
| 1700 | + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) |
|
| 1701 | + * |
|
| 1702 | + * @param User $user Objet user |
|
| 1703 | + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK |
|
| 1704 | + */ |
|
| 1705 | + function load_board($user) |
|
| 1706 | + { |
|
| 1707 | + global $conf, $langs; |
|
| 1708 | + |
|
| 1709 | + $mine=0; $socid=$user->societe_id; |
|
| 1710 | + |
|
| 1711 | + $projectsListId = $this->getProjectsAuthorizedForUser($user,$mine?$mine:($user->rights->projet->all->lire?2:0),1,$socid); |
|
| 1712 | + |
|
| 1713 | + $sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee"; |
|
| 1714 | + $sql.= " FROM (".MAIN_DB_PREFIX."projet as p"; |
|
| 1715 | + $sql.= ")"; |
|
| 1716 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; |
|
| 1717 | + if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; |
|
| 1718 | + $sql.= " WHERE p.fk_statut = 1"; |
|
| 1719 | + $sql.= " AND p.entity IN (".getEntity('project', 0).')'; |
|
| 1720 | + if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
| 1721 | + // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser |
|
| 1722 | + //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1723 | + if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1724 | + if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; |
|
| 1725 | + |
|
| 1726 | + $resql=$this->db->query($sql); |
|
| 1727 | + if ($resql) |
|
| 1728 | + { |
|
| 1729 | + $project_static = new Project($this->db); |
|
| 1730 | + |
|
| 1731 | + $response = new WorkboardResponse(); |
|
| 1732 | + $response->warning_delay = $conf->projet->warning_delay/60/60/24; |
|
| 1733 | + $response->label = $langs->trans("OpenedProjects"); |
|
| 1734 | + if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/list.php?search_status=1&mainmenu=project'; |
|
| 1735 | + else $response->url = DOL_URL_ROOT.'/projet/list.php?search_project_user=-1&search_status=1&mainmenu=project'; |
|
| 1736 | + $response->img = img_object('',"projectpub"); |
|
| 1737 | + |
|
| 1738 | + // This assignment in condition is not a bug. It allows walking the results. |
|
| 1739 | + while ($obj=$this->db->fetch_object($resql)) |
|
| 1740 | + { |
|
| 1741 | + $response->nbtodo++; |
|
| 1742 | + |
|
| 1743 | + $project_static->statut = $obj->status; |
|
| 1744 | + $project_static->opp_status = $obj->opp_status; |
|
| 1745 | + $project_static->datee = $this->db->jdate($obj->datee); |
|
| 1746 | + |
|
| 1747 | + if ($project_static->hasDelay()) { |
|
| 1748 | + $response->nbtodolate++; |
|
| 1749 | + } |
|
| 1750 | + } |
|
| 1751 | + |
|
| 1752 | + return $response; |
|
| 1753 | + } |
|
| 1754 | + else |
|
| 1755 | + { |
|
| 1756 | + $this->error=$this->db->error(); |
|
| 1757 | + return -1; |
|
| 1758 | + } |
|
| 1759 | + } |
|
| 1760 | 1760 | |
| 1761 | 1761 | |
| 1762 | 1762 | /** |
@@ -1784,36 +1784,36 @@ discard block |
||
| 1784 | 1784 | */ |
| 1785 | 1785 | function load_state_board() |
| 1786 | 1786 | { |
| 1787 | - global $user; |
|
| 1787 | + global $user; |
|
| 1788 | 1788 | |
| 1789 | - $this->nb=array(); |
|
| 1789 | + $this->nb=array(); |
|
| 1790 | 1790 | |
| 1791 | - $sql = "SELECT count(p.rowid) as nb"; |
|
| 1792 | - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
| 1793 | - $sql.= " WHERE"; |
|
| 1794 | - $sql.= " p.entity IN (".getEntity('projet').")"; |
|
| 1791 | + $sql = "SELECT count(p.rowid) as nb"; |
|
| 1792 | + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
| 1793 | + $sql.= " WHERE"; |
|
| 1794 | + $sql.= " p.entity IN (".getEntity('projet').")"; |
|
| 1795 | 1795 | if (! $user->rights->projet->all->lire) |
| 1796 | 1796 | { |
| 1797 | 1797 | $projectsListId = $this->getProjectsAuthorizedForUser($user,0,1); |
| 1798 | 1798 | $sql .= "AND p.rowid IN (".$projectsListId.")"; |
| 1799 | 1799 | } |
| 1800 | 1800 | |
| 1801 | - $resql=$this->db->query($sql); |
|
| 1802 | - if ($resql) |
|
| 1803 | - { |
|
| 1804 | - while ($obj=$this->db->fetch_object($resql)) |
|
| 1805 | - { |
|
| 1806 | - $this->nb["projects"]=$obj->nb; |
|
| 1807 | - } |
|
| 1808 | - $this->db->free($resql); |
|
| 1809 | - return 1; |
|
| 1810 | - } |
|
| 1811 | - else |
|
| 1812 | - { |
|
| 1813 | - dol_print_error($this->db); |
|
| 1814 | - $this->error=$this->db->error(); |
|
| 1815 | - return -1; |
|
| 1816 | - } |
|
| 1801 | + $resql=$this->db->query($sql); |
|
| 1802 | + if ($resql) |
|
| 1803 | + { |
|
| 1804 | + while ($obj=$this->db->fetch_object($resql)) |
|
| 1805 | + { |
|
| 1806 | + $this->nb["projects"]=$obj->nb; |
|
| 1807 | + } |
|
| 1808 | + $this->db->free($resql); |
|
| 1809 | + return 1; |
|
| 1810 | + } |
|
| 1811 | + else |
|
| 1812 | + { |
|
| 1813 | + dol_print_error($this->db); |
|
| 1814 | + $this->error=$this->db->error(); |
|
| 1815 | + return -1; |
|
| 1816 | + } |
|
| 1817 | 1817 | } |
| 1818 | 1818 | |
| 1819 | 1819 | |
@@ -1824,14 +1824,14 @@ discard block |
||
| 1824 | 1824 | */ |
| 1825 | 1825 | public function hasDelay() |
| 1826 | 1826 | { |
| 1827 | - global $conf; |
|
| 1827 | + global $conf; |
|
| 1828 | 1828 | |
| 1829 | - if (! ($this->statut == 1)) return false; |
|
| 1830 | - if (! $this->datee && ! $this->date_end) return false; |
|
| 1829 | + if (! ($this->statut == 1)) return false; |
|
| 1830 | + if (! $this->datee && ! $this->date_end) return false; |
|
| 1831 | 1831 | |
| 1832 | - $now = dol_now(); |
|
| 1832 | + $now = dol_now(); |
|
| 1833 | 1833 | |
| 1834 | - return ($this->datee ? $this->datee : $this->date_end) < ($now - $conf->projet->warning_delay); |
|
| 1834 | + return ($this->datee ? $this->datee : $this->date_end) < ($now - $conf->projet->warning_delay); |
|
| 1835 | 1835 | } |
| 1836 | 1836 | |
| 1837 | 1837 | |
@@ -1843,44 +1843,44 @@ discard block |
||
| 1843 | 1843 | */ |
| 1844 | 1844 | function info($id) |
| 1845 | 1845 | { |
| 1846 | - $sql = 'SELECT c.rowid, datec as datec, tms as datem,'; |
|
| 1847 | - $sql.= ' date_close as datecloture,'; |
|
| 1848 | - $sql.= ' fk_user_creat as fk_user_author, fk_user_close as fk_use_cloture'; |
|
| 1849 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'projet as c'; |
|
| 1850 | - $sql.= ' WHERE c.rowid = '.$id; |
|
| 1851 | - $result=$this->db->query($sql); |
|
| 1852 | - if ($result) |
|
| 1853 | - { |
|
| 1854 | - if ($this->db->num_rows($result)) |
|
| 1855 | - { |
|
| 1856 | - $obj = $this->db->fetch_object($result); |
|
| 1857 | - $this->id = $obj->rowid; |
|
| 1858 | - if ($obj->fk_user_author) |
|
| 1859 | - { |
|
| 1860 | - $cuser = new User($this->db); |
|
| 1861 | - $cuser->fetch($obj->fk_user_author); |
|
| 1862 | - $this->user_creation = $cuser; |
|
| 1863 | - } |
|
| 1864 | - |
|
| 1865 | - if ($obj->fk_user_cloture) |
|
| 1866 | - { |
|
| 1867 | - $cluser = new User($this->db); |
|
| 1868 | - $cluser->fetch($obj->fk_user_cloture); |
|
| 1869 | - $this->user_cloture = $cluser; |
|
| 1870 | - } |
|
| 1871 | - |
|
| 1872 | - $this->date_creation = $this->db->jdate($obj->datec); |
|
| 1873 | - $this->date_modification = $this->db->jdate($obj->datem); |
|
| 1874 | - $this->date_cloture = $this->db->jdate($obj->datecloture); |
|
| 1875 | - } |
|
| 1876 | - |
|
| 1877 | - $this->db->free($result); |
|
| 1878 | - |
|
| 1879 | - } |
|
| 1880 | - else |
|
| 1881 | - { |
|
| 1882 | - dol_print_error($this->db); |
|
| 1883 | - } |
|
| 1846 | + $sql = 'SELECT c.rowid, datec as datec, tms as datem,'; |
|
| 1847 | + $sql.= ' date_close as datecloture,'; |
|
| 1848 | + $sql.= ' fk_user_creat as fk_user_author, fk_user_close as fk_use_cloture'; |
|
| 1849 | + $sql.= ' FROM '.MAIN_DB_PREFIX.'projet as c'; |
|
| 1850 | + $sql.= ' WHERE c.rowid = '.$id; |
|
| 1851 | + $result=$this->db->query($sql); |
|
| 1852 | + if ($result) |
|
| 1853 | + { |
|
| 1854 | + if ($this->db->num_rows($result)) |
|
| 1855 | + { |
|
| 1856 | + $obj = $this->db->fetch_object($result); |
|
| 1857 | + $this->id = $obj->rowid; |
|
| 1858 | + if ($obj->fk_user_author) |
|
| 1859 | + { |
|
| 1860 | + $cuser = new User($this->db); |
|
| 1861 | + $cuser->fetch($obj->fk_user_author); |
|
| 1862 | + $this->user_creation = $cuser; |
|
| 1863 | + } |
|
| 1864 | + |
|
| 1865 | + if ($obj->fk_user_cloture) |
|
| 1866 | + { |
|
| 1867 | + $cluser = new User($this->db); |
|
| 1868 | + $cluser->fetch($obj->fk_user_cloture); |
|
| 1869 | + $this->user_cloture = $cluser; |
|
| 1870 | + } |
|
| 1871 | + |
|
| 1872 | + $this->date_creation = $this->db->jdate($obj->datec); |
|
| 1873 | + $this->date_modification = $this->db->jdate($obj->datem); |
|
| 1874 | + $this->date_cloture = $this->db->jdate($obj->datecloture); |
|
| 1875 | + } |
|
| 1876 | + |
|
| 1877 | + $this->db->free($result); |
|
| 1878 | + |
|
| 1879 | + } |
|
| 1880 | + else |
|
| 1881 | + { |
|
| 1882 | + dol_print_error($this->db); |
|
| 1883 | + } |
|
| 1884 | 1884 | } |
| 1885 | 1885 | |
| 1886 | 1886 | /** |
@@ -1952,10 +1952,10 @@ discard block |
||
| 1952 | 1952 | */ |
| 1953 | 1953 | function getLinesArray($user) |
| 1954 | 1954 | { |
| 1955 | - require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
|
| 1956 | - $taskstatic = new Task($this->db); |
|
| 1955 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
|
| 1956 | + $taskstatic = new Task($this->db); |
|
| 1957 | 1957 | |
| 1958 | - $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0); |
|
| 1958 | + $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0); |
|
| 1959 | 1959 | } |
| 1960 | 1960 | |
| 1961 | 1961 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * \ingroup projet |
| 26 | 26 | * \brief File of class to manage projects |
| 27 | 27 | */ |
| 28 | -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; |
|
| 28 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Class to manage projects |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | class Project extends CommonObject |
| 34 | 34 | { |
| 35 | 35 | |
| 36 | - public $element = 'project'; //!< Id that identify managed objects |
|
| 37 | - public $table_element = 'projet'; //!< Name of table without prefix where object is stored |
|
| 36 | + public $element = 'project'; //!< Id that identify managed objects |
|
| 37 | + public $table_element = 'projet'; //!< Name of table without prefix where object is stored |
|
| 38 | 38 | public $table_element_line = 'projet_task'; |
| 39 | 39 | public $fk_element = 'fk_projet'; |
| 40 | - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 40 | + protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 41 | 41 | public $picto = 'projectpub'; |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -57,25 +57,25 @@ discard block |
||
| 57 | 57 | var $date_end; |
| 58 | 58 | var $date_close; |
| 59 | 59 | |
| 60 | - var $socid; // To store id of thirdparty |
|
| 61 | - var $thirdparty_name; // To store name of thirdparty (defined only in some cases) |
|
| 60 | + var $socid; // To store id of thirdparty |
|
| 61 | + var $thirdparty_name; // To store name of thirdparty (defined only in some cases) |
|
| 62 | 62 | |
| 63 | - var $user_author_id; //!< Id of project creator. Not defined if shared project. |
|
| 63 | + var $user_author_id; //!< Id of project creator. Not defined if shared project. |
|
| 64 | 64 | var $user_close_id; |
| 65 | - var $public; //!< Tell if this is a public or private project |
|
| 65 | + var $public; //!< Tell if this is a public or private project |
|
| 66 | 66 | var $budget_amount; |
| 67 | 67 | |
| 68 | 68 | var $statuts_short; |
| 69 | 69 | var $statuts_long; |
| 70 | 70 | |
| 71 | - var $statut; // 0=draft, 1=opened, 2=closed |
|
| 72 | - var $opp_status; // opportunity status, into table llx_c_lead_status |
|
| 73 | - var $opp_percent; // opportunity probability |
|
| 71 | + var $statut; // 0=draft, 1=opened, 2=closed |
|
| 72 | + var $opp_status; // opportunity status, into table llx_c_lead_status |
|
| 73 | + var $opp_percent; // opportunity probability |
|
| 74 | 74 | |
| 75 | 75 | var $oldcopy; |
| 76 | 76 | |
| 77 | - var $weekWorkLoad; // Used to store workload details of a projet |
|
| 78 | - var $weekWorkLoadPerTask; // Used to store workload details of tasks of a projet |
|
| 77 | + var $weekWorkLoad; // Used to store workload details of a projet |
|
| 78 | + var $weekWorkLoadPerTask; // Used to store workload details of tasks of a projet |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * @var int Creation date |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | * @param int $notrigger Disable triggers |
| 139 | 139 | * @return int <0 if KO, id of created project if OK |
| 140 | 140 | */ |
| 141 | - function create($user, $notrigger=0) |
|
| 141 | + function create($user, $notrigger = 0) |
|
| 142 | 142 | { |
| 143 | 143 | global $conf, $langs; |
| 144 | 144 | |
| 145 | 145 | $error = 0; |
| 146 | 146 | $ret = 0; |
| 147 | 147 | |
| 148 | - $now=dol_now(); |
|
| 148 | + $now = dol_now(); |
|
| 149 | 149 | |
| 150 | 150 | // Check parameters |
| 151 | 151 | if (!trim($this->ref)) |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR); |
| 155 | 155 | return -1; |
| 156 | 156 | } |
| 157 | - if (! empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) && ! $this->socid > 0) |
|
| 157 | + if (!empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) && !$this->socid > 0) |
|
| 158 | 158 | { |
| 159 | 159 | $this->error = 'ErrorFieldsRequired'; |
| 160 | 160 | dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR); |
@@ -163,51 +163,51 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | $this->db->begin(); |
| 165 | 165 | |
| 166 | - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "projet ("; |
|
| 167 | - $sql.= "ref"; |
|
| 168 | - $sql.= ", title"; |
|
| 169 | - $sql.= ", description"; |
|
| 170 | - $sql.= ", fk_soc"; |
|
| 171 | - $sql.= ", fk_user_creat"; |
|
| 172 | - $sql.= ", fk_statut"; |
|
| 173 | - $sql.= ", fk_opp_status"; |
|
| 174 | - $sql.= ", opp_percent"; |
|
| 175 | - $sql.= ", public"; |
|
| 176 | - $sql.= ", datec"; |
|
| 177 | - $sql.= ", dateo"; |
|
| 178 | - $sql.= ", datee"; |
|
| 179 | - $sql.= ", opp_amount"; |
|
| 180 | - $sql.= ", budget_amount"; |
|
| 181 | - $sql.= ", entity"; |
|
| 182 | - $sql.= ") VALUES ("; |
|
| 183 | - $sql.= "'" . $this->db->escape($this->ref) . "'"; |
|
| 184 | - $sql.= ", '" . $this->db->escape($this->title) . "'"; |
|
| 185 | - $sql.= ", '" . $this->db->escape($this->description) . "'"; |
|
| 186 | - $sql.= ", " . ($this->socid > 0 ? $this->socid : "null"); |
|
| 187 | - $sql.= ", " . $user->id; |
|
| 188 | - $sql.= ", ".(is_numeric($this->statut) ? $this->statut : '0'); |
|
| 189 | - $sql.= ", ".(is_numeric($this->opp_status) ? $this->opp_status : 'NULL'); |
|
| 190 | - $sql.= ", ".(is_numeric($this->opp_percent) ? $this->opp_percent : 'NULL'); |
|
| 191 | - $sql.= ", " . ($this->public ? 1 : 0); |
|
| 192 | - $sql.= ", '".$this->db->idate($now)."'"; |
|
| 193 | - $sql.= ", " . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); |
|
| 194 | - $sql.= ", " . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); |
|
| 195 | - $sql.= ", " . (strcmp($this->opp_amount,'') ? price2num($this->opp_amount) : 'null'); |
|
| 196 | - $sql.= ", " . (strcmp($this->budget_amount,'') ? price2num($this->budget_amount) : 'null'); |
|
| 197 | - $sql.= ", ".$conf->entity; |
|
| 198 | - $sql.= ")"; |
|
| 166 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet ("; |
|
| 167 | + $sql .= "ref"; |
|
| 168 | + $sql .= ", title"; |
|
| 169 | + $sql .= ", description"; |
|
| 170 | + $sql .= ", fk_soc"; |
|
| 171 | + $sql .= ", fk_user_creat"; |
|
| 172 | + $sql .= ", fk_statut"; |
|
| 173 | + $sql .= ", fk_opp_status"; |
|
| 174 | + $sql .= ", opp_percent"; |
|
| 175 | + $sql .= ", public"; |
|
| 176 | + $sql .= ", datec"; |
|
| 177 | + $sql .= ", dateo"; |
|
| 178 | + $sql .= ", datee"; |
|
| 179 | + $sql .= ", opp_amount"; |
|
| 180 | + $sql .= ", budget_amount"; |
|
| 181 | + $sql .= ", entity"; |
|
| 182 | + $sql .= ") VALUES ("; |
|
| 183 | + $sql .= "'".$this->db->escape($this->ref)."'"; |
|
| 184 | + $sql .= ", '".$this->db->escape($this->title)."'"; |
|
| 185 | + $sql .= ", '".$this->db->escape($this->description)."'"; |
|
| 186 | + $sql .= ", ".($this->socid > 0 ? $this->socid : "null"); |
|
| 187 | + $sql .= ", ".$user->id; |
|
| 188 | + $sql .= ", ".(is_numeric($this->statut) ? $this->statut : '0'); |
|
| 189 | + $sql .= ", ".(is_numeric($this->opp_status) ? $this->opp_status : 'NULL'); |
|
| 190 | + $sql .= ", ".(is_numeric($this->opp_percent) ? $this->opp_percent : 'NULL'); |
|
| 191 | + $sql .= ", ".($this->public ? 1 : 0); |
|
| 192 | + $sql .= ", '".$this->db->idate($now)."'"; |
|
| 193 | + $sql .= ", ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); |
|
| 194 | + $sql .= ", ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); |
|
| 195 | + $sql .= ", ".(strcmp($this->opp_amount, '') ? price2num($this->opp_amount) : 'null'); |
|
| 196 | + $sql .= ", ".(strcmp($this->budget_amount, '') ? price2num($this->budget_amount) : 'null'); |
|
| 197 | + $sql .= ", ".$conf->entity; |
|
| 198 | + $sql .= ")"; |
|
| 199 | 199 | |
| 200 | 200 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
| 201 | 201 | $resql = $this->db->query($sql); |
| 202 | 202 | if ($resql) |
| 203 | 203 | { |
| 204 | - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "projet"); |
|
| 204 | + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet"); |
|
| 205 | 205 | $ret = $this->id; |
| 206 | 206 | |
| 207 | 207 | if (!$notrigger) |
| 208 | 208 | { |
| 209 | 209 | // Call trigger |
| 210 | - $result=$this->call_trigger('PROJECT_CREATE',$user); |
|
| 210 | + $result = $this->call_trigger('PROJECT_CREATE', $user); |
|
| 211 | 211 | if ($result < 0) { $error++; } |
| 212 | 212 | // End call triggers |
| 213 | 213 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | if (!$error) { |
| 224 | 224 | if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
| 225 | 225 | { |
| 226 | - $result=$this->insertExtraFields(); |
|
| 226 | + $result = $this->insertExtraFields(); |
|
| 227 | 227 | if ($result < 0) |
| 228 | 228 | { |
| 229 | 229 | $error++; |
@@ -256,23 +256,23 @@ discard block |
||
| 256 | 256 | * @param int $notrigger 1=Disable all triggers |
| 257 | 257 | * @return int <=0 if KO, >0 if OK |
| 258 | 258 | */ |
| 259 | - function update($user, $notrigger=0) |
|
| 259 | + function update($user, $notrigger = 0) |
|
| 260 | 260 | { |
| 261 | 261 | global $langs, $conf; |
| 262 | 262 | |
| 263 | - $error=0; |
|
| 263 | + $error = 0; |
|
| 264 | 264 | |
| 265 | 265 | // Clean parameters |
| 266 | 266 | $this->title = trim($this->title); |
| 267 | 267 | $this->description = trim($this->description); |
| 268 | - if ($this->opp_amount < 0) $this->opp_amount=''; |
|
| 269 | - if ($this->opp_percent < 0) $this->opp_percent=''; |
|
| 268 | + if ($this->opp_amount < 0) $this->opp_amount = ''; |
|
| 269 | + if ($this->opp_percent < 0) $this->opp_percent = ''; |
|
| 270 | 270 | if ($this->date_end && $this->date_end < $this->date_start) |
| 271 | 271 | { |
| 272 | 272 | $this->error = $langs->trans("ErrorDateEndLowerThanDateStart"); |
| 273 | 273 | $this->errors[] = $this->error; |
| 274 | 274 | $this->db->rollback(); |
| 275 | - dol_syslog(get_class($this)."::update error -3 " . $this->error, LOG_ERR); |
|
| 275 | + dol_syslog(get_class($this)."::update error -3 ".$this->error, LOG_ERR); |
|
| 276 | 276 | return -3; |
| 277 | 277 | } |
| 278 | 278 | |
@@ -280,32 +280,32 @@ discard block |
||
| 280 | 280 | { |
| 281 | 281 | $this->db->begin(); |
| 282 | 282 | |
| 283 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "projet SET"; |
|
| 284 | - $sql.= " ref='" . $this->db->escape($this->ref) . "'"; |
|
| 285 | - $sql.= ", title = '" . $this->db->escape($this->title) . "'"; |
|
| 286 | - $sql.= ", description = '" . $this->db->escape($this->description) . "'"; |
|
| 287 | - $sql.= ", fk_soc = " . ($this->socid > 0 ? $this->socid : "null"); |
|
| 288 | - $sql.= ", fk_statut = " . $this->statut; |
|
| 289 | - $sql.= ", fk_opp_status = " . ((is_numeric($this->opp_status) && $this->opp_status > 0) ? $this->opp_status : 'null'); |
|
| 290 | - $sql.= ", opp_percent = " . ((is_numeric($this->opp_percent) && $this->opp_percent != '') ? $this->opp_percent : 'null'); |
|
| 291 | - $sql.= ", public = " . ($this->public ? 1 : 0); |
|
| 292 | - $sql.= ", datec=" . ($this->date_c != '' ? "'".$this->db->idate($this->date_c)."'" : 'null'); |
|
| 293 | - $sql.= ", dateo=" . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); |
|
| 294 | - $sql.= ", datee=" . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); |
|
| 295 | - $sql.= ", date_close=" . ($this->date_close != '' ? "'".$this->db->idate($this->date_close)."'" : 'null'); |
|
| 296 | - $sql.= ", fk_user_close=" . ($this->fk_user_close > 0 ? $this->fk_user_close : "null"); |
|
| 297 | - $sql.= ", opp_amount = " . (strcmp($this->opp_amount, '') ? price2num($this->opp_amount) : "null"); |
|
| 298 | - $sql.= ", budget_amount = " . (strcmp($this->budget_amount, '') ? price2num($this->budget_amount) : "null"); |
|
| 299 | - $sql.= " WHERE rowid = " . $this->id; |
|
| 283 | + $sql = "UPDATE ".MAIN_DB_PREFIX."projet SET"; |
|
| 284 | + $sql .= " ref='".$this->db->escape($this->ref)."'"; |
|
| 285 | + $sql .= ", title = '".$this->db->escape($this->title)."'"; |
|
| 286 | + $sql .= ", description = '".$this->db->escape($this->description)."'"; |
|
| 287 | + $sql .= ", fk_soc = ".($this->socid > 0 ? $this->socid : "null"); |
|
| 288 | + $sql .= ", fk_statut = ".$this->statut; |
|
| 289 | + $sql .= ", fk_opp_status = ".((is_numeric($this->opp_status) && $this->opp_status > 0) ? $this->opp_status : 'null'); |
|
| 290 | + $sql .= ", opp_percent = ".((is_numeric($this->opp_percent) && $this->opp_percent != '') ? $this->opp_percent : 'null'); |
|
| 291 | + $sql .= ", public = ".($this->public ? 1 : 0); |
|
| 292 | + $sql .= ", datec=".($this->date_c != '' ? "'".$this->db->idate($this->date_c)."'" : 'null'); |
|
| 293 | + $sql .= ", dateo=".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); |
|
| 294 | + $sql .= ", datee=".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); |
|
| 295 | + $sql .= ", date_close=".($this->date_close != '' ? "'".$this->db->idate($this->date_close)."'" : 'null'); |
|
| 296 | + $sql .= ", fk_user_close=".($this->fk_user_close > 0 ? $this->fk_user_close : "null"); |
|
| 297 | + $sql .= ", opp_amount = ".(strcmp($this->opp_amount, '') ? price2num($this->opp_amount) : "null"); |
|
| 298 | + $sql .= ", budget_amount = ".(strcmp($this->budget_amount, '') ? price2num($this->budget_amount) : "null"); |
|
| 299 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 300 | 300 | |
| 301 | 301 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
| 302 | - $resql=$this->db->query($sql); |
|
| 302 | + $resql = $this->db->query($sql); |
|
| 303 | 303 | if ($resql) |
| 304 | 304 | { |
| 305 | 305 | if (!$notrigger) |
| 306 | 306 | { |
| 307 | 307 | // Call trigger |
| 308 | - $result=$this->call_trigger('PROJECT_MODIFY',$user); |
|
| 308 | + $result = $this->call_trigger('PROJECT_MODIFY', $user); |
|
| 309 | 309 | if ($result < 0) { $error++; } |
| 310 | 310 | // End call triggers |
| 311 | 311 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | if (!$error) { |
| 315 | 315 | if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
| 316 | 316 | { |
| 317 | - $result=$this->insertExtraFields(); |
|
| 317 | + $result = $this->insertExtraFields(); |
|
| 318 | 318 | if ($result < 0) |
| 319 | 319 | { |
| 320 | 320 | $error++; |
@@ -322,27 +322,27 @@ discard block |
||
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) |
|
| 325 | + if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) |
|
| 326 | 326 | { |
| 327 | 327 | // We remove directory |
| 328 | 328 | if ($conf->projet->dir_output) |
| 329 | 329 | { |
| 330 | - $olddir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); |
|
| 331 | - $newdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->ref); |
|
| 330 | + $olddir = $conf->projet->dir_output."/".dol_sanitizeFileName($this->oldcopy->ref); |
|
| 331 | + $newdir = $conf->projet->dir_output."/".dol_sanitizeFileName($this->ref); |
|
| 332 | 332 | if (file_exists($olddir)) |
| 333 | 333 | { |
| 334 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
| 335 | - $res=dol_move($olddir, $newdir); |
|
| 336 | - if (! $res) |
|
| 334 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 335 | + $res = dol_move($olddir, $newdir); |
|
| 336 | + if (!$res) |
|
| 337 | 337 | { |
| 338 | 338 | $langs->load("errors"); |
| 339 | - $this->error=$langs->trans('ErrorFailToRenameDir',$olddir,$newdir); |
|
| 339 | + $this->error = $langs->trans('ErrorFailToRenameDir', $olddir, $newdir); |
|
| 340 | 340 | $error++; |
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | - if (! $error ) |
|
| 345 | + if (!$error) |
|
| 346 | 346 | { |
| 347 | 347 | $this->db->commit(); |
| 348 | 348 | $result = 1; |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | { |
| 367 | 367 | $result = -2; |
| 368 | 368 | } |
| 369 | - dol_syslog(get_class($this)."::update error " . $result . " " . $this->error, LOG_ERR); |
|
| 369 | + dol_syslog(get_class($this)."::update error ".$result." ".$this->error, LOG_ERR); |
|
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | else |
@@ -385,21 +385,21 @@ discard block |
||
| 385 | 385 | * @param string $ref Ref of project |
| 386 | 386 | * @return int >0 if OK, 0 if not found, <0 if KO |
| 387 | 387 | */ |
| 388 | - function fetch($id, $ref='') |
|
| 388 | + function fetch($id, $ref = '') |
|
| 389 | 389 | { |
| 390 | 390 | if (empty($id) && empty($ref)) return -1; |
| 391 | 391 | |
| 392 | 392 | $sql = "SELECT rowid, ref, title, description, public, datec, opp_amount, budget_amount,"; |
| 393 | - $sql.= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_close, fk_statut, fk_opp_status, opp_percent, note_private, note_public, model_pdf"; |
|
| 394 | - $sql.= " FROM " . MAIN_DB_PREFIX . "projet"; |
|
| 395 | - if (! empty($id)) |
|
| 393 | + $sql .= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_close, fk_statut, fk_opp_status, opp_percent, note_private, note_public, model_pdf"; |
|
| 394 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet"; |
|
| 395 | + if (!empty($id)) |
|
| 396 | 396 | { |
| 397 | - $sql.= " WHERE rowid=".$id; |
|
| 397 | + $sql .= " WHERE rowid=".$id; |
|
| 398 | 398 | } |
| 399 | - else if (! empty($ref)) |
|
| 399 | + else if (!empty($ref)) |
|
| 400 | 400 | { |
| 401 | - $sql.= " WHERE ref='".$this->db->escape($ref)."'"; |
|
| 402 | - $sql.= " AND entity IN (".getEntity('project').")"; |
|
| 401 | + $sql .= " WHERE ref='".$this->db->escape($ref)."'"; |
|
| 402 | + $sql .= " AND entity IN (".getEntity('project').")"; |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | $this->date_c = $this->db->jdate($obj->datec); |
| 421 | 421 | $this->datec = $this->db->jdate($obj->datec); // TODO deprecated |
| 422 | 422 | $this->date_m = $this->db->jdate($obj->tms); |
| 423 | - $this->datem = $this->db->jdate($obj->tms); // TODO deprecated |
|
| 423 | + $this->datem = $this->db->jdate($obj->tms); // TODO deprecated |
|
| 424 | 424 | $this->date_start = $this->db->jdate($obj->dateo); |
| 425 | 425 | $this->date_end = $this->db->jdate($obj->datee); |
| 426 | 426 | $this->date_close = $this->db->jdate($obj->date_close); |
@@ -433,9 +433,9 @@ discard block |
||
| 433 | 433 | $this->statut = $obj->fk_statut; |
| 434 | 434 | $this->opp_status = $obj->fk_opp_status; |
| 435 | 435 | $this->opp_amount = $obj->opp_amount; |
| 436 | - $this->opp_percent = $obj->opp_percent; |
|
| 437 | - $this->budget_amount = $obj->budget_amount; |
|
| 438 | - $this->modelpdf = $obj->model_pdf; |
|
| 436 | + $this->opp_percent = $obj->opp_percent; |
|
| 437 | + $this->budget_amount = $obj->budget_amount; |
|
| 438 | + $this->modelpdf = $obj->model_pdf; |
|
| 439 | 439 | |
| 440 | 440 | $this->db->free($resql); |
| 441 | 441 | |
@@ -463,16 +463,16 @@ discard block |
||
| 463 | 463 | * @param int $socid To filter on a particular third party |
| 464 | 464 | * @return array List of projects |
| 465 | 465 | */ |
| 466 | - function liste_array($socid='') |
|
| 466 | + function liste_array($socid = '') |
|
| 467 | 467 | { |
| 468 | 468 | global $conf; |
| 469 | 469 | |
| 470 | 470 | $projects = array(); |
| 471 | 471 | |
| 472 | 472 | $sql = "SELECT rowid, title"; |
| 473 | - $sql.= " FROM " . MAIN_DB_PREFIX . "projet"; |
|
| 474 | - $sql.= " WHERE entity = " . $conf->entity; |
|
| 475 | - if (! empty($socid)) $sql.= " AND fk_soc = " . $socid; |
|
| 473 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet"; |
|
| 474 | + $sql .= " WHERE entity = ".$conf->entity; |
|
| 475 | + if (!empty($socid)) $sql .= " AND fk_soc = ".$socid; |
|
| 476 | 476 | |
| 477 | 477 | $resql = $this->db->query($sql); |
| 478 | 478 | if ($resql) |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | * @param string $datee End date (ex 23:59:59) |
| 509 | 509 | * @return mixed Array list of object ids linked to project, < 0 or string if error |
| 510 | 510 | */ |
| 511 | - function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='') |
|
| 511 | + function get_element_list($type, $tablename, $datefieldname = '', $dates = '', $datee = '') |
|
| 512 | 512 | { |
| 513 | 513 | $elements = array(); |
| 514 | 514 | |
@@ -516,42 +516,42 @@ discard block |
||
| 516 | 516 | |
| 517 | 517 | if ($type == 'agenda') |
| 518 | 518 | { |
| 519 | - $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id; |
|
| 519 | + $sql = "SELECT id as rowid FROM ".MAIN_DB_PREFIX."actioncomm WHERE fk_project=".$this->id; |
|
| 520 | 520 | } |
| 521 | 521 | elseif ($type == 'expensereport') |
| 522 | 522 | { |
| 523 | - $sql = "SELECT ed.rowid FROM " . MAIN_DB_PREFIX . "expensereport as e, " . MAIN_DB_PREFIX . "expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND ed.fk_projet=" . $this->id; |
|
| 523 | + $sql = "SELECT ed.rowid FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND ed.fk_projet=".$this->id; |
|
| 524 | 524 | } |
| 525 | 525 | elseif ($type == 'project_task') |
| 526 | 526 | { |
| 527 | - $sql = "SELECT DISTINCT pt.rowid FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=" . $this->id; |
|
| 527 | + $sql = "SELECT DISTINCT pt.rowid FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=".$this->id; |
|
| 528 | 528 | } |
| 529 | 529 | elseif ($type == 'project_task_time') // Case we want to duplicate line foreach user |
| 530 | 530 | { |
| 531 | - $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=" . $this->id; |
|
| 531 | + $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=".$this->id; |
|
| 532 | 532 | } |
| 533 | 533 | elseif ($type == 'stock_mouvement') |
| 534 | 534 | { |
| 535 | - $sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM ' . MAIN_DB_PREFIX . 'stock_mouvement as ms WHERE ms.origintype = "project" AND ms.fk_origin = ' . $this->id . ' AND ms.type_mouvement = 1'; |
|
| 535 | + $sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX.'stock_mouvement as ms WHERE ms.origintype = "project" AND ms.fk_origin = '.$this->id.' AND ms.type_mouvement = 1'; |
|
| 536 | 536 | } |
| 537 | 537 | else |
| 538 | 538 | { |
| 539 | - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id; |
|
| 539 | + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE fk_projet=".$this->id; |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | if ($dates > 0) |
| 543 | 543 | { |
| 544 | - if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date; |
|
| 544 | + if (empty($datefieldname) && !empty($this->table_element_date)) $datefieldname = $this->table_element_date; |
|
| 545 | 545 | if (empty($datefieldname)) return 'Error this object has no date field defined'; |
| 546 | - $sql.=" AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; |
|
| 546 | + $sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; |
|
| 547 | 547 | } |
| 548 | 548 | if ($datee > 0) |
| 549 | 549 | { |
| 550 | - if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date; |
|
| 550 | + if (empty($datefieldname) && !empty($this->table_element_date)) $datefieldname = $this->table_element_date; |
|
| 551 | 551 | if (empty($datefieldname)) return 'Error this object has no date field defined'; |
| 552 | - $sql.=" AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; |
|
| 552 | + $sql .= " AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; |
|
| 553 | 553 | } |
| 554 | - if (! $sql) return -1; |
|
| 554 | + if (!$sql) return -1; |
|
| 555 | 555 | |
| 556 | 556 | //print $sql; |
| 557 | 557 | dol_syslog(get_class($this)."::get_element_list", LOG_DEBUG); |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | { |
| 567 | 567 | $obj = $this->db->fetch_object($result); |
| 568 | 568 | |
| 569 | - $elements[$i] = $obj->rowid.(empty($obj->fk_user)?'':'_'.$obj->fk_user); |
|
| 569 | + $elements[$i] = $obj->rowid.(empty($obj->fk_user) ? '' : '_'.$obj->fk_user); |
|
| 570 | 570 | |
| 571 | 571 | $i++; |
| 572 | 572 | } |
@@ -589,10 +589,10 @@ discard block |
||
| 589 | 589 | * @param int $notrigger Disable triggers |
| 590 | 590 | * @return int <0 if KO, 0 if not possible, >0 if OK |
| 591 | 591 | */ |
| 592 | - function delete($user, $notrigger=0) |
|
| 592 | + function delete($user, $notrigger = 0) |
|
| 593 | 593 | { |
| 594 | 594 | global $langs, $conf; |
| 595 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
| 595 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 596 | 596 | |
| 597 | 597 | $error = 0; |
| 598 | 598 | |
@@ -612,14 +612,14 @@ discard block |
||
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | // Set fk_projet into elements to null |
| 615 | - $listoftables=array( |
|
| 616 | - 'facture'=>'fk_projet','propal'=>'fk_projet','commande'=>'fk_projet', |
|
| 617 | - 'facture_fourn'=>'fk_projet','commande_fournisseur'=>'fk_projet','supplier_proposal'=>'fk_projet', |
|
| 618 | - 'expensereport_det'=>'fk_projet','contrat'=>'fk_projet','fichinter'=>'fk_projet','don'=>'fk_projet' |
|
| 615 | + $listoftables = array( |
|
| 616 | + 'facture'=>'fk_projet', 'propal'=>'fk_projet', 'commande'=>'fk_projet', |
|
| 617 | + 'facture_fourn'=>'fk_projet', 'commande_fournisseur'=>'fk_projet', 'supplier_proposal'=>'fk_projet', |
|
| 618 | + 'expensereport_det'=>'fk_projet', 'contrat'=>'fk_projet', 'fichinter'=>'fk_projet', 'don'=>'fk_projet' |
|
| 619 | 619 | ); |
| 620 | - foreach($listoftables as $key => $value) |
|
| 620 | + foreach ($listoftables as $key => $value) |
|
| 621 | 621 | { |
| 622 | - $sql = "UPDATE " . MAIN_DB_PREFIX . $key . " SET ".$value." = NULL where ".$value." = ". $this->id; |
|
| 622 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$key." SET ".$value." = NULL where ".$value." = ".$this->id; |
|
| 623 | 623 | $resql = $this->db->query($sql); |
| 624 | 624 | if (!$resql) |
| 625 | 625 | { |
@@ -630,10 +630,10 @@ discard block |
||
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | // Delete tasks |
| 633 | - if (! $error) |
|
| 633 | + if (!$error) |
|
| 634 | 634 | { |
| 635 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task_time"; |
|
| 636 | - $sql.= " WHERE fk_task IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "projet_task WHERE fk_projet=" . $this->id . ")"; |
|
| 635 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time"; |
|
| 636 | + $sql .= " WHERE fk_task IN (SELECT rowid FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet=".$this->id.")"; |
|
| 637 | 637 | |
| 638 | 638 | $resql = $this->db->query($sql); |
| 639 | 639 | if (!$resql) |
@@ -643,10 +643,10 @@ discard block |
||
| 643 | 643 | } |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - if (! $error) |
|
| 646 | + if (!$error) |
|
| 647 | 647 | { |
| 648 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task_extrafields"; |
|
| 649 | - $sql.= " WHERE fk_object IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "projet_task WHERE fk_projet=" . $this->id . ")"; |
|
| 648 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_extrafields"; |
|
| 649 | + $sql .= " WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet=".$this->id.")"; |
|
| 650 | 650 | |
| 651 | 651 | $resql = $this->db->query($sql); |
| 652 | 652 | if (!$resql) |
@@ -656,10 +656,10 @@ discard block |
||
| 656 | 656 | } |
| 657 | 657 | } |
| 658 | 658 | |
| 659 | - if (! $error) |
|
| 659 | + if (!$error) |
|
| 660 | 660 | { |
| 661 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task"; |
|
| 662 | - $sql.= " WHERE fk_projet=" . $this->id; |
|
| 661 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task"; |
|
| 662 | + $sql .= " WHERE fk_projet=".$this->id; |
|
| 663 | 663 | |
| 664 | 664 | $resql = $this->db->query($sql); |
| 665 | 665 | if (!$resql) |
@@ -670,10 +670,10 @@ discard block |
||
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | // Delete project |
| 673 | - if (! $error) |
|
| 673 | + if (!$error) |
|
| 674 | 674 | { |
| 675 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet"; |
|
| 676 | - $sql.= " WHERE rowid=" . $this->id; |
|
| 675 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet"; |
|
| 676 | + $sql .= " WHERE rowid=".$this->id; |
|
| 677 | 677 | |
| 678 | 678 | $resql = $this->db->query($sql); |
| 679 | 679 | if (!$resql) |
@@ -683,13 +683,13 @@ discard block |
||
| 683 | 683 | } |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - if (! $error) |
|
| 686 | + if (!$error) |
|
| 687 | 687 | { |
| 688 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_extrafields"; |
|
| 689 | - $sql.= " WHERE fk_object=" . $this->id; |
|
| 688 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_extrafields"; |
|
| 689 | + $sql .= " WHERE fk_object=".$this->id; |
|
| 690 | 690 | |
| 691 | 691 | $resql = $this->db->query($sql); |
| 692 | - if (! $resql) |
|
| 692 | + if (!$resql) |
|
| 693 | 693 | { |
| 694 | 694 | $this->errors[] = $this->db->lasterror(); |
| 695 | 695 | $error++; |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | $projectref = dol_sanitizeFileName($this->ref); |
| 703 | 703 | if ($conf->projet->dir_output) |
| 704 | 704 | { |
| 705 | - $dir = $conf->projet->dir_output . "/" . $projectref; |
|
| 705 | + $dir = $conf->projet->dir_output."/".$projectref; |
|
| 706 | 706 | if (file_exists($dir)) |
| 707 | 707 | { |
| 708 | 708 | $res = @dol_delete_dir_recursive($dir); |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | if (!$notrigger) |
| 718 | 718 | { |
| 719 | 719 | // Call trigger |
| 720 | - $result=$this->call_trigger('PROJECT_DELETE',$user); |
|
| 720 | + $result = $this->call_trigger('PROJECT_DELETE', $user); |
|
| 721 | 721 | |
| 722 | 722 | if ($result < 0) { |
| 723 | 723 | $error++; |
@@ -733,12 +733,12 @@ discard block |
||
| 733 | 733 | } |
| 734 | 734 | else |
| 735 | 735 | { |
| 736 | - foreach ( $this->errors as $errmsg ) |
|
| 736 | + foreach ($this->errors as $errmsg) |
|
| 737 | 737 | { |
| 738 | - dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); |
|
| 739 | - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); |
|
| 738 | + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
|
| 739 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 740 | 740 | } |
| 741 | - dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR); |
|
| 741 | + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); |
|
| 742 | 742 | $this->db->rollback(); |
| 743 | 743 | return -1; |
| 744 | 744 | } |
@@ -751,27 +751,27 @@ discard block |
||
| 751 | 751 | * @param int $notrigger 1=Disable triggers |
| 752 | 752 | * @return int <0 if KO, >0 if OK |
| 753 | 753 | */ |
| 754 | - function setValid($user, $notrigger=0) |
|
| 754 | + function setValid($user, $notrigger = 0) |
|
| 755 | 755 | { |
| 756 | 756 | global $langs, $conf; |
| 757 | 757 | |
| 758 | - $error=0; |
|
| 758 | + $error = 0; |
|
| 759 | 759 | |
| 760 | 760 | if ($this->statut != 1) |
| 761 | 761 | { |
| 762 | 762 | // Check parameters |
| 763 | 763 | if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->title)) |
| 764 | 764 | { |
| 765 | - $this->error=$langs->trans("ErrorFieldFormat",$langs->transnoentities("Label")).'. '.$langs->trans('RemoveString',$langs->transnoentitiesnoconv("CopyOf")); |
|
| 765 | + $this->error = $langs->trans("ErrorFieldFormat", $langs->transnoentities("Label")).'. '.$langs->trans('RemoveString', $langs->transnoentitiesnoconv("CopyOf")); |
|
| 766 | 766 | return -1; |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | $this->db->begin(); |
| 770 | 770 | |
| 771 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "projet"; |
|
| 772 | - $sql.= " SET fk_statut = 1"; |
|
| 773 | - $sql.= " WHERE rowid = " . $this->id; |
|
| 774 | - $sql.= " AND entity = " . $conf->entity; |
|
| 771 | + $sql = "UPDATE ".MAIN_DB_PREFIX."projet"; |
|
| 772 | + $sql .= " SET fk_statut = 1"; |
|
| 773 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 774 | + $sql .= " AND entity = ".$conf->entity; |
|
| 775 | 775 | |
| 776 | 776 | dol_syslog(get_class($this)."::setValid", LOG_DEBUG); |
| 777 | 777 | $resql = $this->db->query($sql); |
@@ -780,14 +780,14 @@ discard block |
||
| 780 | 780 | // Call trigger |
| 781 | 781 | if (empty($notrigger)) |
| 782 | 782 | { |
| 783 | - $result=$this->call_trigger('PROJECT_VALIDATE',$user); |
|
| 783 | + $result = $this->call_trigger('PROJECT_VALIDATE', $user); |
|
| 784 | 784 | if ($result < 0) { $error++; } |
| 785 | 785 | // End call triggers |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | if (!$error) |
| 789 | 789 | { |
| 790 | - $this->statut=1; |
|
| 790 | + $this->statut = 1; |
|
| 791 | 791 | $this->db->commit(); |
| 792 | 792 | return 1; |
| 793 | 793 | } |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | { |
| 796 | 796 | $this->db->rollback(); |
| 797 | 797 | $this->error = join(',', $this->errors); |
| 798 | - dol_syslog(get_class($this)."::setValid " . $this->error, LOG_ERR); |
|
| 798 | + dol_syslog(get_class($this)."::setValid ".$this->error, LOG_ERR); |
|
| 799 | 799 | return -1; |
| 800 | 800 | } |
| 801 | 801 | } |
@@ -820,19 +820,19 @@ discard block |
||
| 820 | 820 | |
| 821 | 821 | $now = dol_now(); |
| 822 | 822 | |
| 823 | - $error=0; |
|
| 823 | + $error = 0; |
|
| 824 | 824 | |
| 825 | 825 | if ($this->statut != 2) |
| 826 | 826 | { |
| 827 | 827 | $this->db->begin(); |
| 828 | 828 | |
| 829 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "projet"; |
|
| 830 | - $sql.= " SET fk_statut = 2, fk_user_close = ".$user->id.", date_close = '".$this->db->idate($now)."'"; |
|
| 831 | - $sql.= " WHERE rowid = " . $this->id; |
|
| 832 | - $sql.= " AND entity = " . $conf->entity; |
|
| 833 | - $sql.= " AND fk_statut = 1"; |
|
| 829 | + $sql = "UPDATE ".MAIN_DB_PREFIX."projet"; |
|
| 830 | + $sql .= " SET fk_statut = 2, fk_user_close = ".$user->id.", date_close = '".$this->db->idate($now)."'"; |
|
| 831 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 832 | + $sql .= " AND entity = ".$conf->entity; |
|
| 833 | + $sql .= " AND fk_statut = 1"; |
|
| 834 | 834 | |
| 835 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 835 | + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 836 | 836 | { |
| 837 | 837 | // TODO What to do if fk_opp_status is not code 'WON' or 'LOST' |
| 838 | 838 | } |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | if ($resql) |
| 843 | 843 | { |
| 844 | 844 | // Call trigger |
| 845 | - $result=$this->call_trigger('PROJECT_CLOSE',$user); |
|
| 845 | + $result = $this->call_trigger('PROJECT_CLOSE', $user); |
|
| 846 | 846 | if ($result < 0) { $error++; } |
| 847 | 847 | // End call triggers |
| 848 | 848 | |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | { |
| 857 | 857 | $this->db->rollback(); |
| 858 | 858 | $this->error = join(',', $this->errors); |
| 859 | - dol_syslog(get_class($this)."::setClose " . $this->error, LOG_ERR); |
|
| 859 | + dol_syslog(get_class($this)."::setClose ".$this->error, LOG_ERR); |
|
| 860 | 860 | return -1; |
| 861 | 861 | } |
| 862 | 862 | } |
@@ -877,7 +877,7 @@ discard block |
||
| 877 | 877 | * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto |
| 878 | 878 | * @return string Label |
| 879 | 879 | */ |
| 880 | - function getLibStatut($mode=0) |
|
| 880 | + function getLibStatut($mode = 0) |
|
| 881 | 881 | { |
| 882 | 882 | return $this->LibStatut($this->statut, $mode); |
| 883 | 883 | } |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto |
| 890 | 890 | * @return string Label |
| 891 | 891 | */ |
| 892 | - function LibStatut($statut, $mode=0) |
|
| 892 | + function LibStatut($statut, $mode = 0) |
|
| 893 | 893 | { |
| 894 | 894 | global $langs; |
| 895 | 895 | |
@@ -904,11 +904,11 @@ discard block |
||
| 904 | 904 | if ($mode == 2) |
| 905 | 905 | { |
| 906 | 906 | if ($statut == 0) |
| 907 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 907 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0').' '.$langs->trans($this->statuts_short[$statut]); |
|
| 908 | 908 | if ($statut == 1) |
| 909 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 909 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4').' '.$langs->trans($this->statuts_short[$statut]); |
|
| 910 | 910 | if ($statut == 2) |
| 911 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 911 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6').' '.$langs->trans($this->statuts_short[$statut]); |
|
| 912 | 912 | } |
| 913 | 913 | if ($mode == 3) |
| 914 | 914 | { |
@@ -922,20 +922,20 @@ discard block |
||
| 922 | 922 | if ($mode == 4) |
| 923 | 923 | { |
| 924 | 924 | if ($statut == 0) |
| 925 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 925 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0').' '.$langs->trans($this->statuts_long[$statut]); |
|
| 926 | 926 | if ($statut == 1) |
| 927 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 927 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4').' '.$langs->trans($this->statuts_long[$statut]); |
|
| 928 | 928 | if ($statut == 2) |
| 929 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 929 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6').' '.$langs->trans($this->statuts_long[$statut]); |
|
| 930 | 930 | } |
| 931 | 931 | if ($mode == 5) |
| 932 | 932 | { |
| 933 | 933 | if ($statut == 0) |
| 934 | - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); |
|
| 934 | + return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); |
|
| 935 | 935 | if ($statut == 1) |
| 936 | - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); |
|
| 936 | + return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); |
|
| 937 | 937 | if ($statut == 2) |
| 938 | - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); |
|
| 938 | + return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); |
|
| 939 | 939 | } |
| 940 | 940 | } |
| 941 | 941 | |
@@ -951,65 +951,65 @@ discard block |
||
| 951 | 951 | * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
| 952 | 952 | * @return string String with URL |
| 953 | 953 | */ |
| 954 | - function getNomUrl($withpicto=0, $option='', $addlabel=0, $moreinpopup='', $sep=' - ', $notooltip=0, $save_lastsearch_value=-1) |
|
| 954 | + function getNomUrl($withpicto = 0, $option = '', $addlabel = 0, $moreinpopup = '', $sep = ' - ', $notooltip = 0, $save_lastsearch_value = -1) |
|
| 955 | 955 | { |
| 956 | 956 | global $conf, $langs, $user; |
| 957 | 957 | |
| 958 | - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
| 958 | + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips |
|
| 959 | 959 | |
| 960 | 960 | $result = ''; |
| 961 | 961 | |
| 962 | - $label=''; |
|
| 963 | - if ($option != 'nolink') $label = '<u>' . $langs->trans("ShowProject") . '</u>'; |
|
| 964 | - $label .= ($label?'<br>':'').'<b>' . $langs->trans('Ref') . ': </b>' . $this->ref; // The space must be after the : to not being explode when showing the title in img_picto |
|
| 965 | - $label .= ($label?'<br>':'').'<b>' . $langs->trans('Label') . ': </b>' . $this->title; // The space must be after the : to not being explode when showing the title in img_picto |
|
| 966 | - if (! empty($this->thirdparty_name)) |
|
| 967 | - $label .= ($label?'<br>':'').'<b>' . $langs->trans('ThirdParty') . ': </b>' . $this->thirdparty_name; // The space must be after the : to not being explode when showing the title in img_picto |
|
| 968 | - if (! empty($this->dateo)) |
|
| 969 | - $label .= ($label?'<br>':'').'<b>' . $langs->trans('DateStart') . ': </b>' . dol_print_date($this->dateo, 'day'); // The space must be after the : to not being explode when showing the title in img_picto |
|
| 970 | - if (! empty($this->datee)) |
|
| 971 | - $label .= ($label?'<br>':'').'<b>' . $langs->trans('DateEnd') . ': </b>' . dol_print_date($this->datee, 'day'); // The space must be after the : to not being explode when showing the title in img_picto |
|
| 972 | - if ($moreinpopup) $label.='<br>'.$moreinpopup; |
|
| 973 | - |
|
| 974 | - $url=''; |
|
| 962 | + $label = ''; |
|
| 963 | + if ($option != 'nolink') $label = '<u>'.$langs->trans("ShowProject").'</u>'; |
|
| 964 | + $label .= ($label ? '<br>' : '').'<b>'.$langs->trans('Ref').': </b>'.$this->ref; // The space must be after the : to not being explode when showing the title in img_picto |
|
| 965 | + $label .= ($label ? '<br>' : '').'<b>'.$langs->trans('Label').': </b>'.$this->title; // The space must be after the : to not being explode when showing the title in img_picto |
|
| 966 | + if (!empty($this->thirdparty_name)) |
|
| 967 | + $label .= ($label ? '<br>' : '').'<b>'.$langs->trans('ThirdParty').': </b>'.$this->thirdparty_name; // The space must be after the : to not being explode when showing the title in img_picto |
|
| 968 | + if (!empty($this->dateo)) |
|
| 969 | + $label .= ($label ? '<br>' : '').'<b>'.$langs->trans('DateStart').': </b>'.dol_print_date($this->dateo, 'day'); // The space must be after the : to not being explode when showing the title in img_picto |
|
| 970 | + if (!empty($this->datee)) |
|
| 971 | + $label .= ($label ? '<br>' : '').'<b>'.$langs->trans('DateEnd').': </b>'.dol_print_date($this->datee, 'day'); // The space must be after the : to not being explode when showing the title in img_picto |
|
| 972 | + if ($moreinpopup) $label .= '<br>'.$moreinpopup; |
|
| 973 | + |
|
| 974 | + $url = ''; |
|
| 975 | 975 | if ($option != 'nolink') |
| 976 | 976 | { |
| 977 | - if (preg_match('/\.php$/',$option)) { |
|
| 978 | - $url = dol_buildpath($option,1) . '?id=' . $this->id; |
|
| 977 | + if (preg_match('/\.php$/', $option)) { |
|
| 978 | + $url = dol_buildpath($option, 1).'?id='.$this->id; |
|
| 979 | 979 | } |
| 980 | 980 | else if ($option == 'task') |
| 981 | 981 | { |
| 982 | - $url = DOL_URL_ROOT . '/projet/tasks.php?id=' . $this->id; |
|
| 982 | + $url = DOL_URL_ROOT.'/projet/tasks.php?id='.$this->id; |
|
| 983 | 983 | } |
| 984 | 984 | else |
| 985 | 985 | { |
| 986 | - $url = DOL_URL_ROOT . '/projet/card.php?id=' . $this->id; |
|
| 986 | + $url = DOL_URL_ROOT.'/projet/card.php?id='.$this->id; |
|
| 987 | 987 | } |
| 988 | 988 | // Add param to save lastsearch_values or not |
| 989 | - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
| 990 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 991 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 989 | + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
|
| 990 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; |
|
| 991 | + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; |
|
| 992 | 992 | } |
| 993 | 993 | |
| 994 | - $linkclose=''; |
|
| 994 | + $linkclose = ''; |
|
| 995 | 995 | if (empty($notooltip) && $user->rights->projet->lire) |
| 996 | 996 | { |
| 997 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 997 | + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 998 | 998 | { |
| 999 | - $label=$langs->trans("ShowProject"); |
|
| 1000 | - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 999 | + $label = $langs->trans("ShowProject"); |
|
| 1000 | + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1001 | 1001 | } |
| 1002 | - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1003 | - $linkclose.=' class="classfortooltip"'; |
|
| 1002 | + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 1003 | + $linkclose .= ' class="classfortooltip"'; |
|
| 1004 | 1004 | |
| 1005 | - if (! is_object($hookmanager)) { |
|
| 1005 | + if (!is_object($hookmanager)) { |
|
| 1006 | 1006 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
| 1007 | - $hookmanager=new HookManager($this->db); |
|
| 1007 | + $hookmanager = new HookManager($this->db); |
|
| 1008 | 1008 | } |
| 1009 | 1009 | $hookmanager->initHooks(array('projectdao')); |
| 1010 | - $parameters=array('id'=>$this->id); |
|
| 1010 | + $parameters = array('id'=>$this->id); |
|
| 1011 | 1011 | // Note that $action and $object may have been modified by some hooks |
| 1012 | - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); |
|
| 1012 | + $reshook = $hookmanager->executeHooks('getnomurltooltip', $parameters, $this, $action); |
|
| 1013 | 1013 | if ($reshook > 0) |
| 1014 | 1014 | $linkclose = $hookmanager->resPrint; |
| 1015 | 1015 | } |
@@ -1018,12 +1018,12 @@ discard block |
||
| 1018 | 1018 | if (!$this->public) $picto = 'project'; |
| 1019 | 1019 | |
| 1020 | 1020 | $linkstart = '<a href="'.$url.'"'; |
| 1021 | - $linkstart.=$linkclose.'>'; |
|
| 1022 | - $linkend='</a>'; |
|
| 1021 | + $linkstart .= $linkclose.'>'; |
|
| 1022 | + $linkend = '</a>'; |
|
| 1023 | 1023 | |
| 1024 | - if ($withpicto) $result.=($linkstart . img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1) . $linkend); |
|
| 1025 | - if ($withpicto && $withpicto != 2) $result.=' '; |
|
| 1026 | - if ($withpicto != 2) $result.=$linkstart . $this->ref . $linkend . (($addlabel && $this->title) ? $sep . dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : ''); |
|
| 1024 | + if ($withpicto) $result .= ($linkstart.img_object(($notooltip ? '' : $label), $picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend); |
|
| 1025 | + if ($withpicto && $withpicto != 2) $result .= ' '; |
|
| 1026 | + if ($withpicto != 2) $result .= $linkstart.$this->ref.$linkend.(($addlabel && $this->title) ? $sep.dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : ''); |
|
| 1027 | 1027 | return $result; |
| 1028 | 1028 | } |
| 1029 | 1029 | |
@@ -1038,7 +1038,7 @@ discard block |
||
| 1038 | 1038 | { |
| 1039 | 1039 | global $user, $langs, $conf; |
| 1040 | 1040 | |
| 1041 | - $now=dol_now(); |
|
| 1041 | + $now = dol_now(); |
|
| 1042 | 1042 | |
| 1043 | 1043 | // Initialise parameters |
| 1044 | 1044 | $this->id = 0; |
@@ -1077,15 +1077,15 @@ discard block |
||
| 1077 | 1077 | * @param string $mode Type of permission we want to know: 'read', 'write' |
| 1078 | 1078 | * @return int >0 if user has permission, <0 if user has no permission |
| 1079 | 1079 | */ |
| 1080 | - function restrictedProjectArea($user, $mode='read') |
|
| 1080 | + function restrictedProjectArea($user, $mode = 'read') |
|
| 1081 | 1081 | { |
| 1082 | 1082 | // To verify role of users |
| 1083 | 1083 | $userAccess = 0; |
| 1084 | - if (($mode == 'read' && ! empty($user->rights->projet->all->lire)) || ($mode == 'write' && ! empty($user->rights->projet->all->creer)) || ($mode == 'delete' && ! empty($user->rights->projet->all->supprimer))) |
|
| 1084 | + if (($mode == 'read' && !empty($user->rights->projet->all->lire)) || ($mode == 'write' && !empty($user->rights->projet->all->creer)) || ($mode == 'delete' && !empty($user->rights->projet->all->supprimer))) |
|
| 1085 | 1085 | { |
| 1086 | 1086 | $userAccess = 1; |
| 1087 | 1087 | } |
| 1088 | - else if ($this->public && (($mode == 'read' && ! empty($user->rights->projet->lire)) || ($mode == 'write' && ! empty($user->rights->projet->creer)) || ($mode == 'delete' && ! empty($user->rights->projet->supprimer)))) |
|
| 1088 | + else if ($this->public && (($mode == 'read' && !empty($user->rights->projet->lire)) || ($mode == 'write' && !empty($user->rights->projet->creer)) || ($mode == 'delete' && !empty($user->rights->projet->supprimer)))) |
|
| 1089 | 1089 | { |
| 1090 | 1090 | $userAccess = 1; |
| 1091 | 1091 | } |
@@ -1101,8 +1101,8 @@ discard block |
||
| 1101 | 1101 | { |
| 1102 | 1102 | if ($source == 'internal' && preg_match('/^PROJECT/', $userRole[$nblinks]['code']) && $user->id == $userRole[$nblinks]['id']) |
| 1103 | 1103 | { |
| 1104 | - if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; |
|
| 1105 | - if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; |
|
| 1104 | + if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; |
|
| 1105 | + if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; |
|
| 1106 | 1106 | if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++; |
| 1107 | 1107 | } |
| 1108 | 1108 | $nblinks++; |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | //} |
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | - return ($userAccess?$userAccess:-1); |
|
| 1120 | + return ($userAccess ? $userAccess : -1); |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | 1123 | /** |
@@ -1130,60 +1130,60 @@ discard block |
||
| 1130 | 1130 | * @param string $filter additionnal filter on project (statut, ref, ...) |
| 1131 | 1131 | * @return array or string Array of projects id, or string with projects id separated with "," |
| 1132 | 1132 | */ |
| 1133 | - function getProjectsAuthorizedForUser($user, $mode=0, $list=0, $socid=0, $filter='') |
|
| 1133 | + function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid = 0, $filter = '') |
|
| 1134 | 1134 | { |
| 1135 | 1135 | $projects = array(); |
| 1136 | 1136 | $temp = array(); |
| 1137 | 1137 | |
| 1138 | 1138 | $sql = "SELECT ".(($mode == 0 || $mode == 1) ? "DISTINCT " : "")."p.rowid, p.ref"; |
| 1139 | - $sql.= " FROM " . MAIN_DB_PREFIX . "projet as p"; |
|
| 1139 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
| 1140 | 1140 | if ($mode == 0 || $mode == 1) |
| 1141 | 1141 | { |
| 1142 | - $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ec"; |
|
| 1142 | + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; |
|
| 1143 | 1143 | } |
| 1144 | - $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
|
| 1144 | + $sql .= " WHERE p.entity IN (".getEntity('project').")"; |
|
| 1145 | 1145 | // Internal users must see project he is contact to even if project linked to a third party he can't see. |
| 1146 | 1146 | //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
| 1147 | - if ($socid > 0) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")"; |
|
| 1147 | + if ($socid > 0) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1148 | 1148 | |
| 1149 | 1149 | // Get id of types of contacts for projects (This list never contains a lot of elements) |
| 1150 | - $listofprojectcontacttype=array(); |
|
| 1150 | + $listofprojectcontacttype = array(); |
|
| 1151 | 1151 | $sql2 = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
| 1152 | - $sql2.= " WHERE ctc.element = '" . $this->db->escape($this->element) . "'"; |
|
| 1153 | - $sql2.= " AND ctc.source = 'internal'"; |
|
| 1152 | + $sql2 .= " WHERE ctc.element = '".$this->db->escape($this->element)."'"; |
|
| 1153 | + $sql2 .= " AND ctc.source = 'internal'"; |
|
| 1154 | 1154 | $resql = $this->db->query($sql2); |
| 1155 | 1155 | if ($resql) |
| 1156 | 1156 | { |
| 1157 | - while($obj = $this->db->fetch_object($resql)) |
|
| 1157 | + while ($obj = $this->db->fetch_object($resql)) |
|
| 1158 | 1158 | { |
| 1159 | - $listofprojectcontacttype[$obj->rowid]=$obj->code; |
|
| 1159 | + $listofprojectcontacttype[$obj->rowid] = $obj->code; |
|
| 1160 | 1160 | } |
| 1161 | 1161 | } |
| 1162 | 1162 | else dol_print_error($this->db); |
| 1163 | - if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid syntax error if not found |
|
| 1163 | + if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid syntax error if not found |
|
| 1164 | 1164 | |
| 1165 | 1165 | if ($mode == 0) |
| 1166 | 1166 | { |
| 1167 | - $sql.= " AND ec.element_id = p.rowid"; |
|
| 1168 | - $sql.= " AND ( p.public = 1"; |
|
| 1169 | - $sql.= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; |
|
| 1170 | - $sql.= " AND ec.fk_socpeople = ".$user->id.")"; |
|
| 1171 | - $sql.= " )"; |
|
| 1167 | + $sql .= " AND ec.element_id = p.rowid"; |
|
| 1168 | + $sql .= " AND ( p.public = 1"; |
|
| 1169 | + $sql .= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; |
|
| 1170 | + $sql .= " AND ec.fk_socpeople = ".$user->id.")"; |
|
| 1171 | + $sql .= " )"; |
|
| 1172 | 1172 | } |
| 1173 | 1173 | if ($mode == 1) |
| 1174 | 1174 | { |
| 1175 | - $sql.= " AND ec.element_id = p.rowid"; |
|
| 1176 | - $sql.= " AND ("; |
|
| 1177 | - $sql.= " ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; |
|
| 1178 | - $sql.= " AND ec.fk_socpeople = ".$user->id.")"; |
|
| 1179 | - $sql.= " )"; |
|
| 1175 | + $sql .= " AND ec.element_id = p.rowid"; |
|
| 1176 | + $sql .= " AND ("; |
|
| 1177 | + $sql .= " ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; |
|
| 1178 | + $sql .= " AND ec.fk_socpeople = ".$user->id.")"; |
|
| 1179 | + $sql .= " )"; |
|
| 1180 | 1180 | } |
| 1181 | 1181 | if ($mode == 2) |
| 1182 | 1182 | { |
| 1183 | 1183 | // No filter. Use this if user has permission to see all project |
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | - $sql.= $filter; |
|
| 1186 | + $sql .= $filter; |
|
| 1187 | 1187 | //print $sql; |
| 1188 | 1188 | |
| 1189 | 1189 | $resql = $this->db->query($sql); |
@@ -1230,19 +1230,19 @@ discard block |
||
| 1230 | 1230 | * @param int $newthirdpartyid New thirdparty id |
| 1231 | 1231 | * @return int New id of clone |
| 1232 | 1232 | */ |
| 1233 | - function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_project_file=false,$clone_task_file=false,$clone_note=true,$move_date=true,$notrigger=0,$newthirdpartyid=0) |
|
| 1233 | + function createFromClone($fromid, $clone_contact = false, $clone_task = true, $clone_project_file = false, $clone_task_file = false, $clone_note = true, $move_date = true, $notrigger = 0, $newthirdpartyid = 0) |
|
| 1234 | 1234 | { |
| 1235 | - global $user,$langs,$conf; |
|
| 1235 | + global $user, $langs, $conf; |
|
| 1236 | 1236 | |
| 1237 | - $error=0; |
|
| 1237 | + $error = 0; |
|
| 1238 | 1238 | |
| 1239 | - dol_syslog("createFromClone clone_contact=".$clone_contact." clone_task=".$clone_task." clone_project_file=".$clone_project_file." clone_note=".$clone_note." move_date=".$move_date,LOG_DEBUG); |
|
| 1239 | + dol_syslog("createFromClone clone_contact=".$clone_contact." clone_task=".$clone_task." clone_project_file=".$clone_project_file." clone_note=".$clone_note." move_date=".$move_date, LOG_DEBUG); |
|
| 1240 | 1240 | |
| 1241 | - $now = dol_mktime(0,0,0,idate('m',dol_now()),idate('d',dol_now()),idate('Y',dol_now())); |
|
| 1241 | + $now = dol_mktime(0, 0, 0, idate('m', dol_now()), idate('d', dol_now()), idate('Y', dol_now())); |
|
| 1242 | 1242 | |
| 1243 | - $clone_project=new Project($this->db); |
|
| 1243 | + $clone_project = new Project($this->db); |
|
| 1244 | 1244 | |
| 1245 | - $clone_project->context['createfromclone']='createfromclone'; |
|
| 1245 | + $clone_project->context['createfromclone'] = 'createfromclone'; |
|
| 1246 | 1246 | |
| 1247 | 1247 | $this->db->begin(); |
| 1248 | 1248 | |
@@ -1252,10 +1252,10 @@ discard block |
||
| 1252 | 1252 | if ($newthirdpartyid > 0) $clone_project->socid = $newthirdpartyid; |
| 1253 | 1253 | $clone_project->fetch_thirdparty(); |
| 1254 | 1254 | |
| 1255 | - $orign_dt_start=$clone_project->date_start; |
|
| 1256 | - $orign_project_ref=$clone_project->ref; |
|
| 1255 | + $orign_dt_start = $clone_project->date_start; |
|
| 1256 | + $orign_project_ref = $clone_project->ref; |
|
| 1257 | 1257 | |
| 1258 | - $clone_project->id=0; |
|
| 1258 | + $clone_project->id = 0; |
|
| 1259 | 1259 | if ($move_date) { |
| 1260 | 1260 | $clone_project->date_start = $now; |
| 1261 | 1261 | if (!(empty($clone_project->date_end))) |
@@ -1266,63 +1266,63 @@ discard block |
||
| 1266 | 1266 | |
| 1267 | 1267 | $clone_project->datec = $now; |
| 1268 | 1268 | |
| 1269 | - if (! $clone_note) |
|
| 1269 | + if (!$clone_note) |
|
| 1270 | 1270 | { |
| 1271 | - $clone_project->note_private=''; |
|
| 1272 | - $clone_project->note_public=''; |
|
| 1271 | + $clone_project->note_private = ''; |
|
| 1272 | + $clone_project->note_public = ''; |
|
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | //Generate next ref |
| 1276 | - $defaultref=''; |
|
| 1277 | - $obj = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; |
|
| 1276 | + $defaultref = ''; |
|
| 1277 | + $obj = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON; |
|
| 1278 | 1278 | // Search template files |
| 1279 | - $file=''; $classname=''; $filefound=0; |
|
| 1280 | - $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); |
|
| 1281 | - foreach($dirmodels as $reldir) |
|
| 1279 | + $file = ''; $classname = ''; $filefound = 0; |
|
| 1280 | + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); |
|
| 1281 | + foreach ($dirmodels as $reldir) |
|
| 1282 | 1282 | { |
| 1283 | - $file=dol_buildpath($reldir."core/modules/project/".$obj.'.php',0); |
|
| 1283 | + $file = dol_buildpath($reldir."core/modules/project/".$obj.'.php', 0); |
|
| 1284 | 1284 | if (file_exists($file)) |
| 1285 | 1285 | { |
| 1286 | - $filefound=1; |
|
| 1286 | + $filefound = 1; |
|
| 1287 | 1287 | dol_include_once($reldir."core/modules/project/".$obj.'.php'); |
| 1288 | 1288 | $modProject = new $obj; |
| 1289 | - $defaultref = $modProject->getNextValue(is_object($clone_project->thirdparty)?$clone_project->thirdparty:null, $clone_project); |
|
| 1289 | + $defaultref = $modProject->getNextValue(is_object($clone_project->thirdparty) ? $clone_project->thirdparty : null, $clone_project); |
|
| 1290 | 1290 | break; |
| 1291 | 1291 | } |
| 1292 | 1292 | } |
| 1293 | - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; |
|
| 1293 | + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; |
|
| 1294 | 1294 | |
| 1295 | - $clone_project->ref=$defaultref; |
|
| 1296 | - $clone_project->title=$langs->trans("CopyOf").' '.$clone_project->title; |
|
| 1295 | + $clone_project->ref = $defaultref; |
|
| 1296 | + $clone_project->title = $langs->trans("CopyOf").' '.$clone_project->title; |
|
| 1297 | 1297 | |
| 1298 | 1298 | // Create clone |
| 1299 | - $result=$clone_project->create($user,$notrigger); |
|
| 1299 | + $result = $clone_project->create($user, $notrigger); |
|
| 1300 | 1300 | |
| 1301 | 1301 | // Other options |
| 1302 | 1302 | if ($result < 0) |
| 1303 | 1303 | { |
| 1304 | - $this->error.=$clone_project->error; |
|
| 1304 | + $this->error .= $clone_project->error; |
|
| 1305 | 1305 | $error++; |
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | - if (! $error) |
|
| 1308 | + if (!$error) |
|
| 1309 | 1309 | { |
| 1310 | 1310 | //Get the new project id |
| 1311 | - $clone_project_id=$clone_project->id; |
|
| 1311 | + $clone_project_id = $clone_project->id; |
|
| 1312 | 1312 | |
| 1313 | 1313 | //Note Update |
| 1314 | 1314 | if (!$clone_note) |
| 1315 | 1315 | { |
| 1316 | - $clone_project->note_private=''; |
|
| 1317 | - $clone_project->note_public=''; |
|
| 1316 | + $clone_project->note_private = ''; |
|
| 1317 | + $clone_project->note_public = ''; |
|
| 1318 | 1318 | } |
| 1319 | 1319 | else |
| 1320 | 1320 | { |
| 1321 | 1321 | $this->db->begin(); |
| 1322 | - $res=$clone_project->update_note(dol_html_entity_decode($clone_project->note_public, ENT_QUOTES),'_public'); |
|
| 1322 | + $res = $clone_project->update_note(dol_html_entity_decode($clone_project->note_public, ENT_QUOTES), '_public'); |
|
| 1323 | 1323 | if ($res < 0) |
| 1324 | 1324 | { |
| 1325 | - $this->error.=$clone_project->error; |
|
| 1325 | + $this->error .= $clone_project->error; |
|
| 1326 | 1326 | $error++; |
| 1327 | 1327 | $this->db->rollback(); |
| 1328 | 1328 | } |
@@ -1332,10 +1332,10 @@ discard block |
||
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | 1334 | $this->db->begin(); |
| 1335 | - $res=$clone_project->update_note(dol_html_entity_decode($clone_project->note_private, ENT_QUOTES), '_private'); |
|
| 1335 | + $res = $clone_project->update_note(dol_html_entity_decode($clone_project->note_private, ENT_QUOTES), '_private'); |
|
| 1336 | 1336 | if ($res < 0) |
| 1337 | 1337 | { |
| 1338 | - $this->error.=$clone_project->error; |
|
| 1338 | + $this->error .= $clone_project->error; |
|
| 1339 | 1339 | $error++; |
| 1340 | 1340 | $this->db->rollback(); |
| 1341 | 1341 | } |
@@ -1351,24 +1351,24 @@ discard block |
||
| 1351 | 1351 | $origin_project = new Project($this->db); |
| 1352 | 1352 | $origin_project->fetch($fromid); |
| 1353 | 1353 | |
| 1354 | - foreach(array('internal','external') as $source) |
|
| 1354 | + foreach (array('internal', 'external') as $source) |
|
| 1355 | 1355 | { |
| 1356 | - $tab = $origin_project->liste_contact(-1,$source); |
|
| 1356 | + $tab = $origin_project->liste_contact(-1, $source); |
|
| 1357 | 1357 | |
| 1358 | 1358 | foreach ($tab as $contacttoadd) |
| 1359 | 1359 | { |
| 1360 | - $clone_project->add_contact($contacttoadd['id'], $contacttoadd['code'], $contacttoadd['source'],$notrigger); |
|
| 1360 | + $clone_project->add_contact($contacttoadd['id'], $contacttoadd['code'], $contacttoadd['source'], $notrigger); |
|
| 1361 | 1361 | if ($clone_project->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
| 1362 | 1362 | { |
| 1363 | 1363 | $langs->load("errors"); |
| 1364 | - $this->error.=$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); |
|
| 1364 | + $this->error .= $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); |
|
| 1365 | 1365 | $error++; |
| 1366 | 1366 | } |
| 1367 | 1367 | else |
| 1368 | 1368 | { |
| 1369 | - if ($clone_project->error!='') |
|
| 1369 | + if ($clone_project->error != '') |
|
| 1370 | 1370 | { |
| 1371 | - $this->error.=$clone_project->error; |
|
| 1371 | + $this->error .= $clone_project->error; |
|
| 1372 | 1372 | $error++; |
| 1373 | 1373 | } |
| 1374 | 1374 | } |
@@ -1381,25 +1381,25 @@ discard block |
||
| 1381 | 1381 | { |
| 1382 | 1382 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 1383 | 1383 | |
| 1384 | - $clone_project_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($defaultref); |
|
| 1385 | - $ori_project_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($orign_project_ref); |
|
| 1384 | + $clone_project_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($defaultref); |
|
| 1385 | + $ori_project_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($orign_project_ref); |
|
| 1386 | 1386 | |
| 1387 | 1387 | if (dol_mkdir($clone_project_dir) >= 0) |
| 1388 | 1388 | { |
| 1389 | - $filearray=dol_dir_list($ori_project_dir,"files",0,'','(\.meta|_preview.*\.png)$','',SORT_ASC,1); |
|
| 1390 | - foreach($filearray as $key => $file) |
|
| 1389 | + $filearray = dol_dir_list($ori_project_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); |
|
| 1390 | + foreach ($filearray as $key => $file) |
|
| 1391 | 1391 | { |
| 1392 | - $rescopy = dol_copy($ori_project_dir . '/' . $file['name'], $clone_project_dir . '/' . $file['name'],0,1); |
|
| 1392 | + $rescopy = dol_copy($ori_project_dir.'/'.$file['name'], $clone_project_dir.'/'.$file['name'], 0, 1); |
|
| 1393 | 1393 | if (is_numeric($rescopy) && $rescopy < 0) |
| 1394 | 1394 | { |
| 1395 | - $this->error.=$langs->trans("ErrorFailToCopyFile",$ori_project_dir . '/' . $file['name'],$clone_project_dir . '/' . $file['name']); |
|
| 1395 | + $this->error .= $langs->trans("ErrorFailToCopyFile", $ori_project_dir.'/'.$file['name'], $clone_project_dir.'/'.$file['name']); |
|
| 1396 | 1396 | $error++; |
| 1397 | 1397 | } |
| 1398 | 1398 | } |
| 1399 | 1399 | } |
| 1400 | 1400 | else |
| 1401 | 1401 | { |
| 1402 | - $this->error.=$langs->trans('ErrorInternalErrorDetected').':dol_mkdir'; |
|
| 1402 | + $this->error .= $langs->trans('ErrorInternalErrorDetected').':dol_mkdir'; |
|
| 1403 | 1403 | $error++; |
| 1404 | 1404 | } |
| 1405 | 1405 | } |
@@ -1407,55 +1407,55 @@ discard block |
||
| 1407 | 1407 | //Duplicate task |
| 1408 | 1408 | if ($clone_task) |
| 1409 | 1409 | { |
| 1410 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php'; |
|
| 1410 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
|
| 1411 | 1411 | |
| 1412 | 1412 | $taskstatic = new Task($this->db); |
| 1413 | 1413 | |
| 1414 | 1414 | // Security check |
| 1415 | - $socid=0; |
|
| 1415 | + $socid = 0; |
|
| 1416 | 1416 | if ($user->societe_id > 0) $socid = $user->societe_id; |
| 1417 | 1417 | |
| 1418 | - $tasksarray=$taskstatic->getTasksArray(0, 0, $fromid, $socid, 0); |
|
| 1418 | + $tasksarray = $taskstatic->getTasksArray(0, 0, $fromid, $socid, 0); |
|
| 1419 | 1419 | |
| 1420 | - $tab_conv_child_parent=array(); |
|
| 1420 | + $tab_conv_child_parent = array(); |
|
| 1421 | 1421 | |
| 1422 | 1422 | // Loop on each task, to clone it |
| 1423 | 1423 | foreach ($tasksarray as $tasktoclone) |
| 1424 | 1424 | { |
| 1425 | - $result_clone = $taskstatic->createFromClone($tasktoclone->id,$clone_project_id,$tasktoclone->fk_parent,$move_date,true,false,$clone_task_file,true,false); |
|
| 1425 | + $result_clone = $taskstatic->createFromClone($tasktoclone->id, $clone_project_id, $tasktoclone->fk_parent, $move_date, true, false, $clone_task_file, true, false); |
|
| 1426 | 1426 | if ($result_clone <= 0) |
| 1427 | 1427 | { |
| 1428 | - $this->error.=$result_clone->error; |
|
| 1428 | + $this->error .= $result_clone->error; |
|
| 1429 | 1429 | $error++; |
| 1430 | 1430 | } |
| 1431 | 1431 | else |
| 1432 | 1432 | { |
| 1433 | - $new_task_id=$result_clone; |
|
| 1433 | + $new_task_id = $result_clone; |
|
| 1434 | 1434 | $taskstatic->fetch($tasktoclone->id); |
| 1435 | 1435 | |
| 1436 | 1436 | //manage new parent clone task id |
| 1437 | 1437 | // if the current task has child we store the original task id and the equivalent clone task id |
| 1438 | - if (($taskstatic->hasChildren()) && !array_key_exists($tasktoclone->id,$tab_conv_child_parent)) |
|
| 1438 | + if (($taskstatic->hasChildren()) && !array_key_exists($tasktoclone->id, $tab_conv_child_parent)) |
|
| 1439 | 1439 | { |
| 1440 | - $tab_conv_child_parent[$tasktoclone->id] = $new_task_id; |
|
| 1440 | + $tab_conv_child_parent[$tasktoclone->id] = $new_task_id; |
|
| 1441 | 1441 | } |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | 1446 | //Parse all clone node to be sure to update new parent |
| 1447 | - $tasksarray=$taskstatic->getTasksArray(0, 0, $clone_project_id, $socid, 0); |
|
| 1447 | + $tasksarray = $taskstatic->getTasksArray(0, 0, $clone_project_id, $socid, 0); |
|
| 1448 | 1448 | foreach ($tasksarray as $task_cloned) |
| 1449 | 1449 | { |
| 1450 | 1450 | $taskstatic->fetch($task_cloned->id); |
| 1451 | - if ($taskstatic->fk_task_parent!=0) |
|
| 1451 | + if ($taskstatic->fk_task_parent != 0) |
|
| 1452 | 1452 | { |
| 1453 | - $taskstatic->fk_task_parent=$tab_conv_child_parent[$taskstatic->fk_task_parent]; |
|
| 1453 | + $taskstatic->fk_task_parent = $tab_conv_child_parent[$taskstatic->fk_task_parent]; |
|
| 1454 | 1454 | } |
| 1455 | - $res=$taskstatic->update($user,$notrigger); |
|
| 1455 | + $res = $taskstatic->update($user, $notrigger); |
|
| 1456 | 1456 | if ($result_clone <= 0) |
| 1457 | 1457 | { |
| 1458 | - $this->error.=$taskstatic->error; |
|
| 1458 | + $this->error .= $taskstatic->error; |
|
| 1459 | 1459 | $error++; |
| 1460 | 1460 | } |
| 1461 | 1461 | } |
@@ -1464,7 +1464,7 @@ discard block |
||
| 1464 | 1464 | |
| 1465 | 1465 | unset($clone_project->context['createfromclone']); |
| 1466 | 1466 | |
| 1467 | - if (! $error) |
|
| 1467 | + if (!$error) |
|
| 1468 | 1468 | { |
| 1469 | 1469 | $this->db->commit(); |
| 1470 | 1470 | return $clone_project_id; |
@@ -1472,7 +1472,7 @@ discard block |
||
| 1472 | 1472 | else |
| 1473 | 1473 | { |
| 1474 | 1474 | $this->db->rollback(); |
| 1475 | - dol_syslog(get_class($this)."::createFromClone nbError: ".$error." error : " . $this->error, LOG_ERR); |
|
| 1475 | + dol_syslog(get_class($this)."::createFromClone nbError: ".$error." error : ".$this->error, LOG_ERR); |
|
| 1476 | 1476 | return -1; |
| 1477 | 1477 | } |
| 1478 | 1478 | } |
@@ -1486,32 +1486,32 @@ discard block |
||
| 1486 | 1486 | */ |
| 1487 | 1487 | function shiftTaskDate($old_project_dt_start) |
| 1488 | 1488 | { |
| 1489 | - global $user,$langs,$conf; |
|
| 1489 | + global $user, $langs, $conf; |
|
| 1490 | 1490 | |
| 1491 | - $error=0; |
|
| 1491 | + $error = 0; |
|
| 1492 | 1492 | |
| 1493 | 1493 | $taskstatic = new Task($this->db); |
| 1494 | 1494 | |
| 1495 | 1495 | // Security check |
| 1496 | - $socid=0; |
|
| 1496 | + $socid = 0; |
|
| 1497 | 1497 | if ($user->societe_id > 0) $socid = $user->societe_id; |
| 1498 | 1498 | |
| 1499 | - $tasksarray=$taskstatic->getTasksArray(0, 0, $this->id, $socid, 0); |
|
| 1499 | + $tasksarray = $taskstatic->getTasksArray(0, 0, $this->id, $socid, 0); |
|
| 1500 | 1500 | |
| 1501 | 1501 | foreach ($tasksarray as $tasktoshiftdate) |
| 1502 | 1502 | { |
| 1503 | - $to_update=false; |
|
| 1503 | + $to_update = false; |
|
| 1504 | 1504 | // Fetch only if update of date will be made |
| 1505 | 1505 | if ((!empty($tasktoshiftdate->date_start)) || (!empty($tasktoshiftdate->date_end))) |
| 1506 | 1506 | { |
| 1507 | 1507 | //dol_syslog(get_class($this)."::shiftTaskDate to_update", LOG_DEBUG); |
| 1508 | - $to_update=true; |
|
| 1508 | + $to_update = true; |
|
| 1509 | 1509 | $task = new Task($this->db); |
| 1510 | 1510 | $result = $task->fetch($tasktoshiftdate->id); |
| 1511 | 1511 | if (!$result) |
| 1512 | 1512 | { |
| 1513 | 1513 | $error++; |
| 1514 | - $this->error.=$task->error; |
|
| 1514 | + $this->error .= $task->error; |
|
| 1515 | 1515 | } |
| 1516 | 1516 | } |
| 1517 | 1517 | //print "$this->date_start + $tasktoshiftdate->date_start - $old_project_dt_start";exit; |
@@ -1519,13 +1519,13 @@ discard block |
||
| 1519 | 1519 | //Calcultate new task start date with difference between old proj start date and origin task start date |
| 1520 | 1520 | if (!empty($tasktoshiftdate->date_start)) |
| 1521 | 1521 | { |
| 1522 | - $task->date_start = $this->date_start + ($tasktoshiftdate->date_start - $old_project_dt_start); |
|
| 1522 | + $task->date_start = $this->date_start + ($tasktoshiftdate->date_start - $old_project_dt_start); |
|
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | //Calcultate new task end date with difference between origin proj end date and origin task end date |
| 1526 | 1526 | if (!empty($tasktoshiftdate->date_end)) |
| 1527 | 1527 | { |
| 1528 | - $task->date_end = $this->date_start + ($tasktoshiftdate->date_end - $old_project_dt_start); |
|
| 1528 | + $task->date_end = $this->date_start + ($tasktoshiftdate->date_end - $old_project_dt_start); |
|
| 1529 | 1529 | } |
| 1530 | 1530 | |
| 1531 | 1531 | if ($to_update) |
@@ -1534,11 +1534,11 @@ discard block |
||
| 1534 | 1534 | if (!$result) |
| 1535 | 1535 | { |
| 1536 | 1536 | $error++; |
| 1537 | - $this->error.=$task->error; |
|
| 1537 | + $this->error .= $task->error; |
|
| 1538 | 1538 | } |
| 1539 | 1539 | } |
| 1540 | 1540 | } |
| 1541 | - if ($error!=0) |
|
| 1541 | + if ($error != 0) |
|
| 1542 | 1542 | { |
| 1543 | 1543 | return -1; |
| 1544 | 1544 | } |
@@ -1555,25 +1555,25 @@ discard block |
||
| 1555 | 1555 | */ |
| 1556 | 1556 | function update_element($tableName, $elementSelectId) |
| 1557 | 1557 | { |
| 1558 | - $sql="UPDATE ".MAIN_DB_PREFIX.$tableName; |
|
| 1558 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$tableName; |
|
| 1559 | 1559 | |
| 1560 | 1560 | if ($tableName == "actioncomm") |
| 1561 | 1561 | { |
| 1562 | - $sql.= " SET fk_project=".$this->id; |
|
| 1563 | - $sql.= " WHERE id=".$elementSelectId; |
|
| 1562 | + $sql .= " SET fk_project=".$this->id; |
|
| 1563 | + $sql .= " WHERE id=".$elementSelectId; |
|
| 1564 | 1564 | } |
| 1565 | 1565 | else |
| 1566 | 1566 | { |
| 1567 | - $sql.= " SET fk_projet=".$this->id; |
|
| 1568 | - $sql.= " WHERE rowid=".$elementSelectId; |
|
| 1567 | + $sql .= " SET fk_projet=".$this->id; |
|
| 1568 | + $sql .= " WHERE rowid=".$elementSelectId; |
|
| 1569 | 1569 | } |
| 1570 | 1570 | |
| 1571 | 1571 | dol_syslog(get_class($this)."::update_element", LOG_DEBUG); |
| 1572 | - $resql=$this->db->query($sql); |
|
| 1572 | + $resql = $this->db->query($sql); |
|
| 1573 | 1573 | if (!$resql) { |
| 1574 | - $this->error=$this->db->lasterror(); |
|
| 1574 | + $this->error = $this->db->lasterror(); |
|
| 1575 | 1575 | return -1; |
| 1576 | - }else { |
|
| 1576 | + } else { |
|
| 1577 | 1577 | return 1; |
| 1578 | 1578 | } |
| 1579 | 1579 | |
@@ -1588,25 +1588,25 @@ discard block |
||
| 1588 | 1588 | */ |
| 1589 | 1589 | function remove_element($tableName, $elementSelectId) |
| 1590 | 1590 | { |
| 1591 | - $sql="UPDATE ".MAIN_DB_PREFIX.$tableName; |
|
| 1591 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$tableName; |
|
| 1592 | 1592 | |
| 1593 | - if ($TableName=="actioncomm") |
|
| 1593 | + if ($TableName == "actioncomm") |
|
| 1594 | 1594 | { |
| 1595 | - $sql.= " SET fk_project=NULL"; |
|
| 1596 | - $sql.= " WHERE id=".$elementSelectId; |
|
| 1595 | + $sql .= " SET fk_project=NULL"; |
|
| 1596 | + $sql .= " WHERE id=".$elementSelectId; |
|
| 1597 | 1597 | } |
| 1598 | 1598 | else |
| 1599 | 1599 | { |
| 1600 | - $sql.= " SET fk_projet=NULL"; |
|
| 1601 | - $sql.= " WHERE rowid=".$elementSelectId; |
|
| 1600 | + $sql .= " SET fk_projet=NULL"; |
|
| 1601 | + $sql .= " WHERE rowid=".$elementSelectId; |
|
| 1602 | 1602 | } |
| 1603 | 1603 | |
| 1604 | 1604 | dol_syslog(get_class($this)."::remove_element", LOG_DEBUG); |
| 1605 | - $resql=$this->db->query($sql); |
|
| 1605 | + $resql = $this->db->query($sql); |
|
| 1606 | 1606 | if (!$resql) { |
| 1607 | - $this->error=$this->db->lasterror(); |
|
| 1607 | + $this->error = $this->db->lasterror(); |
|
| 1608 | 1608 | return -1; |
| 1609 | - }else { |
|
| 1609 | + } else { |
|
| 1610 | 1610 | return 1; |
| 1611 | 1611 | } |
| 1612 | 1612 | |
@@ -1622,19 +1622,19 @@ discard block |
||
| 1622 | 1622 | * @param int $hideref Hide ref |
| 1623 | 1623 | * @return int 0 if KO, 1 if OK |
| 1624 | 1624 | */ |
| 1625 | - public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) |
|
| 1625 | + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
| 1626 | 1626 | { |
| 1627 | - global $conf,$langs; |
|
| 1627 | + global $conf, $langs; |
|
| 1628 | 1628 | |
| 1629 | 1629 | $langs->load("projects"); |
| 1630 | 1630 | |
| 1631 | - if (! dol_strlen($modele)) { |
|
| 1631 | + if (!dol_strlen($modele)) { |
|
| 1632 | 1632 | |
| 1633 | 1633 | $modele = 'baleine'; |
| 1634 | 1634 | |
| 1635 | 1635 | if ($this->modelpdf) { |
| 1636 | 1636 | $modele = $this->modelpdf; |
| 1637 | - } elseif (! empty($conf->global->PROJECT_ADDON_PDF)) { |
|
| 1637 | + } elseif (!empty($conf->global->PROJECT_ADDON_PDF)) { |
|
| 1638 | 1638 | $modele = $conf->global->PROJECT_ADDON_PDF; |
| 1639 | 1639 | } |
| 1640 | 1640 | } |
@@ -1653,23 +1653,23 @@ discard block |
||
| 1653 | 1653 | * @param int $userid Time spent by a particular user |
| 1654 | 1654 | * @return int <0 if OK, >0 if KO |
| 1655 | 1655 | */ |
| 1656 | - public function loadTimeSpent($datestart,$taskid=0,$userid=0) |
|
| 1656 | + public function loadTimeSpent($datestart, $taskid = 0, $userid = 0) |
|
| 1657 | 1657 | { |
| 1658 | - $error=0; |
|
| 1658 | + $error = 0; |
|
| 1659 | 1659 | |
| 1660 | - if (empty($datestart)) dol_print_error('','Error datestart parameter is empty'); |
|
| 1660 | + if (empty($datestart)) dol_print_error('', 'Error datestart parameter is empty'); |
|
| 1661 | 1661 | |
| 1662 | 1662 | $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.fk_task"; |
| 1663 | - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; |
|
| 1664 | - $sql.= " WHERE ptt.fk_task = pt.rowid"; |
|
| 1665 | - $sql.= " AND pt.fk_projet = ".$this->id; |
|
| 1666 | - $sql.= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' "; |
|
| 1667 | - $sql.= " AND ptt.task_date <= '".$this->db->idate($datestart + (7 * 24 * 3600) - 1)."')"; |
|
| 1668 | - if ($task_id) $sql.= " AND ptt.fk_task=".$taskid; |
|
| 1669 | - if (is_numeric($userid)) $sql.= " AND ptt.fk_user=".$userid; |
|
| 1663 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; |
|
| 1664 | + $sql .= " WHERE ptt.fk_task = pt.rowid"; |
|
| 1665 | + $sql .= " AND pt.fk_projet = ".$this->id; |
|
| 1666 | + $sql .= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' "; |
|
| 1667 | + $sql .= " AND ptt.task_date <= '".$this->db->idate($datestart + (7 * 24 * 3600) - 1)."')"; |
|
| 1668 | + if ($task_id) $sql .= " AND ptt.fk_task=".$taskid; |
|
| 1669 | + if (is_numeric($userid)) $sql .= " AND ptt.fk_user=".$userid; |
|
| 1670 | 1670 | |
| 1671 | 1671 | //print $sql; |
| 1672 | - $resql=$this->db->query($sql); |
|
| 1672 | + $resql = $this->db->query($sql); |
|
| 1673 | 1673 | if ($resql) |
| 1674 | 1674 | { |
| 1675 | 1675 | |
@@ -1678,9 +1678,9 @@ discard block |
||
| 1678 | 1678 | // Loop on each record found, so each couple (project id, task id) |
| 1679 | 1679 | while ($i < $num) |
| 1680 | 1680 | { |
| 1681 | - $obj=$this->db->fetch_object($resql); |
|
| 1682 | - $day=$this->db->jdate($obj->task_date); |
|
| 1683 | - $this->weekWorkLoad[$day] += $obj->task_duration; |
|
| 1681 | + $obj = $this->db->fetch_object($resql); |
|
| 1682 | + $day = $this->db->jdate($obj->task_date); |
|
| 1683 | + $this->weekWorkLoad[$day] += $obj->task_duration; |
|
| 1684 | 1684 | $this->weekWorkLoadPerTask[$day][$obj->fk_task] += $obj->task_duration; |
| 1685 | 1685 | $i++; |
| 1686 | 1686 | } |
@@ -1689,7 +1689,7 @@ discard block |
||
| 1689 | 1689 | } |
| 1690 | 1690 | else |
| 1691 | 1691 | { |
| 1692 | - $this->error="Error ".$this->db->lasterror(); |
|
| 1692 | + $this->error = "Error ".$this->db->lasterror(); |
|
| 1693 | 1693 | dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); |
| 1694 | 1694 | return -1; |
| 1695 | 1695 | } |
@@ -1706,37 +1706,37 @@ discard block |
||
| 1706 | 1706 | { |
| 1707 | 1707 | global $conf, $langs; |
| 1708 | 1708 | |
| 1709 | - $mine=0; $socid=$user->societe_id; |
|
| 1709 | + $mine = 0; $socid = $user->societe_id; |
|
| 1710 | 1710 | |
| 1711 | - $projectsListId = $this->getProjectsAuthorizedForUser($user,$mine?$mine:($user->rights->projet->all->lire?2:0),1,$socid); |
|
| 1711 | + $projectsListId = $this->getProjectsAuthorizedForUser($user, $mine ? $mine : ($user->rights->projet->all->lire ? 2 : 0), 1, $socid); |
|
| 1712 | 1712 | |
| 1713 | 1713 | $sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee"; |
| 1714 | - $sql.= " FROM (".MAIN_DB_PREFIX."projet as p"; |
|
| 1715 | - $sql.= ")"; |
|
| 1716 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; |
|
| 1717 | - if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; |
|
| 1718 | - $sql.= " WHERE p.fk_statut = 1"; |
|
| 1719 | - $sql.= " AND p.entity IN (".getEntity('project', 0).')'; |
|
| 1720 | - if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
| 1714 | + $sql .= " FROM (".MAIN_DB_PREFIX."projet as p"; |
|
| 1715 | + $sql .= ")"; |
|
| 1716 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; |
|
| 1717 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; |
|
| 1718 | + $sql .= " WHERE p.fk_statut = 1"; |
|
| 1719 | + $sql .= " AND p.entity IN (".getEntity('project', 0).')'; |
|
| 1720 | + if ($mine || !$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; |
|
| 1721 | 1721 | // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser |
| 1722 | 1722 | //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
| 1723 | - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1724 | - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; |
|
| 1723 | + if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1724 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id.") OR (s.rowid IS NULL))"; |
|
| 1725 | 1725 | |
| 1726 | - $resql=$this->db->query($sql); |
|
| 1726 | + $resql = $this->db->query($sql); |
|
| 1727 | 1727 | if ($resql) |
| 1728 | 1728 | { |
| 1729 | 1729 | $project_static = new Project($this->db); |
| 1730 | 1730 | |
| 1731 | 1731 | $response = new WorkboardResponse(); |
| 1732 | - $response->warning_delay = $conf->projet->warning_delay/60/60/24; |
|
| 1732 | + $response->warning_delay = $conf->projet->warning_delay / 60 / 60 / 24; |
|
| 1733 | 1733 | $response->label = $langs->trans("OpenedProjects"); |
| 1734 | 1734 | if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/list.php?search_status=1&mainmenu=project'; |
| 1735 | 1735 | else $response->url = DOL_URL_ROOT.'/projet/list.php?search_project_user=-1&search_status=1&mainmenu=project'; |
| 1736 | - $response->img = img_object('',"projectpub"); |
|
| 1736 | + $response->img = img_object('', "projectpub"); |
|
| 1737 | 1737 | |
| 1738 | 1738 | // This assignment in condition is not a bug. It allows walking the results. |
| 1739 | - while ($obj=$this->db->fetch_object($resql)) |
|
| 1739 | + while ($obj = $this->db->fetch_object($resql)) |
|
| 1740 | 1740 | { |
| 1741 | 1741 | $response->nbtodo++; |
| 1742 | 1742 | |
@@ -1753,7 +1753,7 @@ discard block |
||
| 1753 | 1753 | } |
| 1754 | 1754 | else |
| 1755 | 1755 | { |
| 1756 | - $this->error=$this->db->error(); |
|
| 1756 | + $this->error = $this->db->error(); |
|
| 1757 | 1757 | return -1; |
| 1758 | 1758 | } |
| 1759 | 1759 | } |
@@ -1786,24 +1786,24 @@ discard block |
||
| 1786 | 1786 | { |
| 1787 | 1787 | global $user; |
| 1788 | 1788 | |
| 1789 | - $this->nb=array(); |
|
| 1789 | + $this->nb = array(); |
|
| 1790 | 1790 | |
| 1791 | 1791 | $sql = "SELECT count(p.rowid) as nb"; |
| 1792 | - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
| 1793 | - $sql.= " WHERE"; |
|
| 1794 | - $sql.= " p.entity IN (".getEntity('projet').")"; |
|
| 1795 | - if (! $user->rights->projet->all->lire) |
|
| 1792 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
| 1793 | + $sql .= " WHERE"; |
|
| 1794 | + $sql .= " p.entity IN (".getEntity('projet').")"; |
|
| 1795 | + if (!$user->rights->projet->all->lire) |
|
| 1796 | 1796 | { |
| 1797 | - $projectsListId = $this->getProjectsAuthorizedForUser($user,0,1); |
|
| 1797 | + $projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1); |
|
| 1798 | 1798 | $sql .= "AND p.rowid IN (".$projectsListId.")"; |
| 1799 | 1799 | } |
| 1800 | 1800 | |
| 1801 | - $resql=$this->db->query($sql); |
|
| 1801 | + $resql = $this->db->query($sql); |
|
| 1802 | 1802 | if ($resql) |
| 1803 | 1803 | { |
| 1804 | - while ($obj=$this->db->fetch_object($resql)) |
|
| 1804 | + while ($obj = $this->db->fetch_object($resql)) |
|
| 1805 | 1805 | { |
| 1806 | - $this->nb["projects"]=$obj->nb; |
|
| 1806 | + $this->nb["projects"] = $obj->nb; |
|
| 1807 | 1807 | } |
| 1808 | 1808 | $this->db->free($resql); |
| 1809 | 1809 | return 1; |
@@ -1811,7 +1811,7 @@ discard block |
||
| 1811 | 1811 | else |
| 1812 | 1812 | { |
| 1813 | 1813 | dol_print_error($this->db); |
| 1814 | - $this->error=$this->db->error(); |
|
| 1814 | + $this->error = $this->db->error(); |
|
| 1815 | 1815 | return -1; |
| 1816 | 1816 | } |
| 1817 | 1817 | } |
@@ -1826,8 +1826,8 @@ discard block |
||
| 1826 | 1826 | { |
| 1827 | 1827 | global $conf; |
| 1828 | 1828 | |
| 1829 | - if (! ($this->statut == 1)) return false; |
|
| 1830 | - if (! $this->datee && ! $this->date_end) return false; |
|
| 1829 | + if (!($this->statut == 1)) return false; |
|
| 1830 | + if (!$this->datee && !$this->date_end) return false; |
|
| 1831 | 1831 | |
| 1832 | 1832 | $now = dol_now(); |
| 1833 | 1833 | |
@@ -1844,11 +1844,11 @@ discard block |
||
| 1844 | 1844 | function info($id) |
| 1845 | 1845 | { |
| 1846 | 1846 | $sql = 'SELECT c.rowid, datec as datec, tms as datem,'; |
| 1847 | - $sql.= ' date_close as datecloture,'; |
|
| 1848 | - $sql.= ' fk_user_creat as fk_user_author, fk_user_close as fk_use_cloture'; |
|
| 1849 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'projet as c'; |
|
| 1850 | - $sql.= ' WHERE c.rowid = '.$id; |
|
| 1851 | - $result=$this->db->query($sql); |
|
| 1847 | + $sql .= ' date_close as datecloture,'; |
|
| 1848 | + $sql .= ' fk_user_creat as fk_user_author, fk_user_close as fk_use_cloture'; |
|
| 1849 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as c'; |
|
| 1850 | + $sql .= ' WHERE c.rowid = '.$id; |
|
| 1851 | + $result = $this->db->query($sql); |
|
| 1852 | 1852 | if ($result) |
| 1853 | 1853 | { |
| 1854 | 1854 | if ($this->db->num_rows($result)) |
@@ -1859,14 +1859,14 @@ discard block |
||
| 1859 | 1859 | { |
| 1860 | 1860 | $cuser = new User($this->db); |
| 1861 | 1861 | $cuser->fetch($obj->fk_user_author); |
| 1862 | - $this->user_creation = $cuser; |
|
| 1862 | + $this->user_creation = $cuser; |
|
| 1863 | 1863 | } |
| 1864 | 1864 | |
| 1865 | 1865 | if ($obj->fk_user_cloture) |
| 1866 | 1866 | { |
| 1867 | 1867 | $cluser = new User($this->db); |
| 1868 | 1868 | $cluser->fetch($obj->fk_user_cloture); |
| 1869 | - $this->user_cloture = $cluser; |
|
| 1869 | + $this->user_cloture = $cluser; |
|
| 1870 | 1870 | } |
| 1871 | 1871 | |
| 1872 | 1872 | $this->date_creation = $this->db->jdate($obj->datec); |
@@ -1905,7 +1905,7 @@ discard block |
||
| 1905 | 1905 | } |
| 1906 | 1906 | |
| 1907 | 1907 | // Get current categories |
| 1908 | - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; |
|
| 1908 | + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
|
| 1909 | 1909 | $c = new Categorie($this->db); |
| 1910 | 1910 | $existing = $c->containing($this->id, $type_id, 'id'); |
| 1911 | 1911 | |
@@ -1921,20 +1921,20 @@ discard block |
||
| 1921 | 1921 | // Process |
| 1922 | 1922 | foreach ($to_del as $del) { |
| 1923 | 1923 | if ($c->fetch($del) > 0) { |
| 1924 | - $result=$c->del_type($this, $type_text); |
|
| 1925 | - if ($result<0) { |
|
| 1926 | - $this->errors=$c->errors; |
|
| 1927 | - $this->error=$c->error; |
|
| 1924 | + $result = $c->del_type($this, $type_text); |
|
| 1925 | + if ($result < 0) { |
|
| 1926 | + $this->errors = $c->errors; |
|
| 1927 | + $this->error = $c->error; |
|
| 1928 | 1928 | return -1; |
| 1929 | 1929 | } |
| 1930 | 1930 | } |
| 1931 | 1931 | } |
| 1932 | 1932 | foreach ($to_add as $add) { |
| 1933 | 1933 | if ($c->fetch($add) > 0) { |
| 1934 | - $result=$c->add_type($this, $type_text); |
|
| 1935 | - if ($result<0) { |
|
| 1936 | - $this->errors=$c->errors; |
|
| 1937 | - $this->error=$c->error; |
|
| 1934 | + $result = $c->add_type($this, $type_text); |
|
| 1935 | + if ($result < 0) { |
|
| 1936 | + $this->errors = $c->errors; |
|
| 1937 | + $this->error = $c->error; |
|
| 1938 | 1938 | return -1; |
| 1939 | 1939 | } |
| 1940 | 1940 | } |
@@ -211,8 +211,7 @@ discard block |
||
| 211 | 211 | if ($result < 0) { $error++; } |
| 212 | 212 | // End call triggers |
| 213 | 213 | } |
| 214 | - } |
|
| 215 | - else |
|
| 214 | + } else |
|
| 216 | 215 | { |
| 217 | 216 | $this->error = $this->db->lasterror(); |
| 218 | 217 | $this->errno = $this->db->lasterrno(); |
@@ -221,9 +220,11 @@ discard block |
||
| 221 | 220 | |
| 222 | 221 | // Update extrafield |
| 223 | 222 | if (!$error) { |
| 224 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 223 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 224 | + // For avoid conflicts if trigger used |
|
| 225 | 225 | { |
| 226 | 226 | $result=$this->insertExtraFields(); |
| 227 | + } |
|
| 227 | 228 | if ($result < 0) |
| 228 | 229 | { |
| 229 | 230 | $error++; |
@@ -234,15 +235,16 @@ discard block |
||
| 234 | 235 | if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) |
| 235 | 236 | { |
| 236 | 237 | $res = $this->setValid($user); |
| 237 | - if ($res < 0) $error++; |
|
| 238 | + if ($res < 0) { |
|
| 239 | + $error++; |
|
| 240 | + } |
|
| 238 | 241 | } |
| 239 | 242 | |
| 240 | 243 | if (!$error) |
| 241 | 244 | { |
| 242 | 245 | $this->db->commit(); |
| 243 | 246 | return $ret; |
| 244 | - } |
|
| 245 | - else |
|
| 247 | + } else |
|
| 246 | 248 | { |
| 247 | 249 | $this->db->rollback(); |
| 248 | 250 | return -1; |
@@ -265,8 +267,12 @@ discard block |
||
| 265 | 267 | // Clean parameters |
| 266 | 268 | $this->title = trim($this->title); |
| 267 | 269 | $this->description = trim($this->description); |
| 268 | - if ($this->opp_amount < 0) $this->opp_amount=''; |
|
| 269 | - if ($this->opp_percent < 0) $this->opp_percent=''; |
|
| 270 | + if ($this->opp_amount < 0) { |
|
| 271 | + $this->opp_amount=''; |
|
| 272 | + } |
|
| 273 | + if ($this->opp_percent < 0) { |
|
| 274 | + $this->opp_percent=''; |
|
| 275 | + } |
|
| 270 | 276 | if ($this->date_end && $this->date_end < $this->date_start) |
| 271 | 277 | { |
| 272 | 278 | $this->error = $langs->trans("ErrorDateEndLowerThanDateStart"); |
@@ -312,9 +318,11 @@ discard block |
||
| 312 | 318 | |
| 313 | 319 | //Update extrafield |
| 314 | 320 | if (!$error) { |
| 315 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
| 321 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 322 | + // For avoid conflicts if trigger used |
|
| 316 | 323 | { |
| 317 | 324 | $result=$this->insertExtraFields(); |
| 325 | + } |
|
| 318 | 326 | if ($result < 0) |
| 319 | 327 | { |
| 320 | 328 | $error++; |
@@ -346,14 +354,12 @@ discard block |
||
| 346 | 354 | { |
| 347 | 355 | $this->db->commit(); |
| 348 | 356 | $result = 1; |
| 349 | - } |
|
| 350 | - else |
|
| 357 | + } else |
|
| 351 | 358 | { |
| 352 | 359 | $this->db->rollback(); |
| 353 | 360 | $result = -1; |
| 354 | 361 | } |
| 355 | - } |
|
| 356 | - else |
|
| 362 | + } else |
|
| 357 | 363 | { |
| 358 | 364 | $this->error = $this->db->lasterror(); |
| 359 | 365 | $this->errors[] = $this->error; |
@@ -361,15 +367,13 @@ discard block |
||
| 361 | 367 | if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
| 362 | 368 | { |
| 363 | 369 | $result = -4; |
| 364 | - } |
|
| 365 | - else |
|
| 370 | + } else |
|
| 366 | 371 | { |
| 367 | 372 | $result = -2; |
| 368 | 373 | } |
| 369 | 374 | dol_syslog(get_class($this)."::update error " . $result . " " . $this->error, LOG_ERR); |
| 370 | 375 | } |
| 371 | - } |
|
| 372 | - else |
|
| 376 | + } else |
|
| 373 | 377 | { |
| 374 | 378 | dol_syslog(get_class($this)."::update ref null"); |
| 375 | 379 | $result = -1; |
@@ -387,7 +391,9 @@ discard block |
||
| 387 | 391 | */ |
| 388 | 392 | function fetch($id, $ref='') |
| 389 | 393 | { |
| 390 | - if (empty($id) && empty($ref)) return -1; |
|
| 394 | + if (empty($id) && empty($ref)) { |
|
| 395 | + return -1; |
|
| 396 | + } |
|
| 391 | 397 | |
| 392 | 398 | $sql = "SELECT rowid, ref, title, description, public, datec, opp_amount, budget_amount,"; |
| 393 | 399 | $sql.= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_close, fk_statut, fk_opp_status, opp_percent, note_private, note_public, model_pdf"; |
@@ -395,8 +401,7 @@ discard block |
||
| 395 | 401 | if (! empty($id)) |
| 396 | 402 | { |
| 397 | 403 | $sql.= " WHERE rowid=".$id; |
| 398 | - } |
|
| 399 | - else if (! empty($ref)) |
|
| 404 | + } else if (! empty($ref)) |
|
| 400 | 405 | { |
| 401 | 406 | $sql.= " WHERE ref='".$this->db->escape($ref)."'"; |
| 402 | 407 | $sql.= " AND entity IN (".getEntity('project').")"; |
@@ -447,10 +452,12 @@ discard block |
||
| 447 | 452 | |
| 448 | 453 | $this->db->free($resql); |
| 449 | 454 | |
| 450 | - if ($num_rows) return 1; |
|
| 451 | - else return 0; |
|
| 452 | - } |
|
| 453 | - else |
|
| 455 | + if ($num_rows) { |
|
| 456 | + return 1; |
|
| 457 | + } else { |
|
| 458 | + return 0; |
|
| 459 | + } |
|
| 460 | + } else |
|
| 454 | 461 | { |
| 455 | 462 | $this->error = $this->db->lasterror(); |
| 456 | 463 | return -1; |
@@ -472,7 +479,9 @@ discard block |
||
| 472 | 479 | $sql = "SELECT rowid, title"; |
| 473 | 480 | $sql.= " FROM " . MAIN_DB_PREFIX . "projet"; |
| 474 | 481 | $sql.= " WHERE entity = " . $conf->entity; |
| 475 | - if (! empty($socid)) $sql.= " AND fk_soc = " . $socid; |
|
| 482 | + if (! empty($socid)) { |
|
| 483 | + $sql.= " AND fk_soc = " . $socid; |
|
| 484 | + } |
|
| 476 | 485 | |
| 477 | 486 | $resql = $this->db->query($sql); |
| 478 | 487 | if ($resql) |
@@ -491,8 +500,7 @@ discard block |
||
| 491 | 500 | } |
| 492 | 501 | } |
| 493 | 502 | return $projects; |
| 494 | - } |
|
| 495 | - else |
|
| 503 | + } else |
|
| 496 | 504 | { |
| 497 | 505 | print $this->db->lasterror(); |
| 498 | 506 | } |
@@ -512,46 +520,55 @@ discard block |
||
| 512 | 520 | { |
| 513 | 521 | $elements = array(); |
| 514 | 522 | |
| 515 | - if ($this->id <= 0) return $elements; |
|
| 523 | + if ($this->id <= 0) { |
|
| 524 | + return $elements; |
|
| 525 | + } |
|
| 516 | 526 | |
| 517 | 527 | if ($type == 'agenda') |
| 518 | 528 | { |
| 519 | 529 | $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id; |
| 520 | - } |
|
| 521 | - elseif ($type == 'expensereport') |
|
| 530 | + } elseif ($type == 'expensereport') |
|
| 522 | 531 | { |
| 523 | 532 | $sql = "SELECT ed.rowid FROM " . MAIN_DB_PREFIX . "expensereport as e, " . MAIN_DB_PREFIX . "expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND ed.fk_projet=" . $this->id; |
| 524 | - } |
|
| 525 | - elseif ($type == 'project_task') |
|
| 533 | + } elseif ($type == 'project_task') |
|
| 526 | 534 | { |
| 527 | 535 | $sql = "SELECT DISTINCT pt.rowid FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=" . $this->id; |
| 528 | - } |
|
| 529 | - elseif ($type == 'project_task_time') // Case we want to duplicate line foreach user |
|
| 536 | + } elseif ($type == 'project_task_time') { |
|
| 537 | + // Case we want to duplicate line foreach user |
|
| 530 | 538 | { |
| 531 | 539 | $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=" . $this->id; |
| 532 | 540 | } |
| 533 | - elseif ($type == 'stock_mouvement') |
|
| 541 | + } elseif ($type == 'stock_mouvement') |
|
| 534 | 542 | { |
| 535 | 543 | $sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM ' . MAIN_DB_PREFIX . 'stock_mouvement as ms WHERE ms.origintype = "project" AND ms.fk_origin = ' . $this->id . ' AND ms.type_mouvement = 1'; |
| 536 | - } |
|
| 537 | - else |
|
| 544 | + } else |
|
| 538 | 545 | { |
| 539 | 546 | $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id; |
| 540 | 547 | } |
| 541 | 548 | |
| 542 | 549 | if ($dates > 0) |
| 543 | 550 | { |
| 544 | - if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date; |
|
| 545 | - if (empty($datefieldname)) return 'Error this object has no date field defined'; |
|
| 551 | + if (empty($datefieldname) && ! empty($this->table_element_date)) { |
|
| 552 | + $datefieldname=$this->table_element_date; |
|
| 553 | + } |
|
| 554 | + if (empty($datefieldname)) { |
|
| 555 | + return 'Error this object has no date field defined'; |
|
| 556 | + } |
|
| 546 | 557 | $sql.=" AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; |
| 547 | 558 | } |
| 548 | 559 | if ($datee > 0) |
| 549 | 560 | { |
| 550 | - if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date; |
|
| 551 | - if (empty($datefieldname)) return 'Error this object has no date field defined'; |
|
| 561 | + if (empty($datefieldname) && ! empty($this->table_element_date)) { |
|
| 562 | + $datefieldname=$this->table_element_date; |
|
| 563 | + } |
|
| 564 | + if (empty($datefieldname)) { |
|
| 565 | + return 'Error this object has no date field defined'; |
|
| 566 | + } |
|
| 552 | 567 | $sql.=" AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; |
| 553 | 568 | } |
| 554 | - if (! $sql) return -1; |
|
| 569 | + if (! $sql) { |
|
| 570 | + return -1; |
|
| 571 | + } |
|
| 555 | 572 | |
| 556 | 573 | //print $sql; |
| 557 | 574 | dol_syslog(get_class($this)."::get_element_list", LOG_DEBUG); |
@@ -575,8 +592,7 @@ discard block |
||
| 575 | 592 | /* Return array */ |
| 576 | 593 | return $elements; |
| 577 | 594 | } |
| 578 | - } |
|
| 579 | - else |
|
| 595 | + } else |
|
| 580 | 596 | { |
| 581 | 597 | dol_print_error($this->db); |
| 582 | 598 | } |
@@ -730,8 +746,7 @@ discard block |
||
| 730 | 746 | { |
| 731 | 747 | $this->db->commit(); |
| 732 | 748 | return 1; |
| 733 | - } |
|
| 734 | - else |
|
| 749 | + } else |
|
| 735 | 750 | { |
| 736 | 751 | foreach ( $this->errors as $errmsg ) |
| 737 | 752 | { |
@@ -790,16 +805,14 @@ discard block |
||
| 790 | 805 | $this->statut=1; |
| 791 | 806 | $this->db->commit(); |
| 792 | 807 | return 1; |
| 793 | - } |
|
| 794 | - else |
|
| 808 | + } else |
|
| 795 | 809 | { |
| 796 | 810 | $this->db->rollback(); |
| 797 | 811 | $this->error = join(',', $this->errors); |
| 798 | 812 | dol_syslog(get_class($this)."::setValid " . $this->error, LOG_ERR); |
| 799 | 813 | return -1; |
| 800 | 814 | } |
| 801 | - } |
|
| 802 | - else |
|
| 815 | + } else |
|
| 803 | 816 | { |
| 804 | 817 | $this->db->rollback(); |
| 805 | 818 | $this->error = $this->db->lasterror(); |
@@ -851,16 +864,14 @@ discard block |
||
| 851 | 864 | $this->statut = 2; |
| 852 | 865 | $this->db->commit(); |
| 853 | 866 | return 1; |
| 854 | - } |
|
| 855 | - else |
|
| 867 | + } else |
|
| 856 | 868 | { |
| 857 | 869 | $this->db->rollback(); |
| 858 | 870 | $this->error = join(',', $this->errors); |
| 859 | 871 | dol_syslog(get_class($this)."::setClose " . $this->error, LOG_ERR); |
| 860 | 872 | return -1; |
| 861 | 873 | } |
| 862 | - } |
|
| 863 | - else |
|
| 874 | + } else |
|
| 864 | 875 | { |
| 865 | 876 | $this->db->rollback(); |
| 866 | 877 | $this->error = $this->db->lasterror(); |
@@ -903,39 +914,51 @@ discard block |
||
| 903 | 914 | } |
| 904 | 915 | if ($mode == 2) |
| 905 | 916 | { |
| 906 | - if ($statut == 0) |
|
| 907 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 908 | - if ($statut == 1) |
|
| 909 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 910 | - if ($statut == 2) |
|
| 911 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 917 | + if ($statut == 0) { |
|
| 918 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 919 | + } |
|
| 920 | + if ($statut == 1) { |
|
| 921 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 922 | + } |
|
| 923 | + if ($statut == 2) { |
|
| 924 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_short[$statut]); |
|
| 925 | + } |
|
| 912 | 926 | } |
| 913 | 927 | if ($mode == 3) |
| 914 | 928 | { |
| 915 | - if ($statut == 0) |
|
| 916 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); |
|
| 917 | - if ($statut == 1) |
|
| 918 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); |
|
| 919 | - if ($statut == 2) |
|
| 920 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); |
|
| 929 | + if ($statut == 0) { |
|
| 930 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); |
|
| 931 | + } |
|
| 932 | + if ($statut == 1) { |
|
| 933 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); |
|
| 934 | + } |
|
| 935 | + if ($statut == 2) { |
|
| 936 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); |
|
| 937 | + } |
|
| 921 | 938 | } |
| 922 | 939 | if ($mode == 4) |
| 923 | 940 | { |
| 924 | - if ($statut == 0) |
|
| 925 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 926 | - if ($statut == 1) |
|
| 927 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 928 | - if ($statut == 2) |
|
| 929 | - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 941 | + if ($statut == 0) { |
|
| 942 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 943 | + } |
|
| 944 | + if ($statut == 1) { |
|
| 945 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 946 | + } |
|
| 947 | + if ($statut == 2) { |
|
| 948 | + return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_long[$statut]); |
|
| 949 | + } |
|
| 930 | 950 | } |
| 931 | 951 | if ($mode == 5) |
| 932 | 952 | { |
| 933 | - if ($statut == 0) |
|
| 934 | - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); |
|
| 935 | - if ($statut == 1) |
|
| 936 | - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); |
|
| 937 | - if ($statut == 2) |
|
| 938 | - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); |
|
| 953 | + if ($statut == 0) { |
|
| 954 | + return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); |
|
| 955 | + } |
|
| 956 | + if ($statut == 1) { |
|
| 957 | + return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); |
|
| 958 | + } |
|
| 959 | + if ($statut == 2) { |
|
| 960 | + return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); |
|
| 961 | + } |
|
| 939 | 962 | } |
| 940 | 963 | } |
| 941 | 964 | |
@@ -955,40 +978,55 @@ discard block |
||
| 955 | 978 | { |
| 956 | 979 | global $conf, $langs, $user; |
| 957 | 980 | |
| 958 | - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
| 981 | + if (! empty($conf->dol_no_mouse_hover)) { |
|
| 982 | + $notooltip=1; |
|
| 983 | + } |
|
| 984 | + // Force disable tooltips |
|
| 959 | 985 | |
| 960 | 986 | $result = ''; |
| 961 | 987 | |
| 962 | 988 | $label=''; |
| 963 | - if ($option != 'nolink') $label = '<u>' . $langs->trans("ShowProject") . '</u>'; |
|
| 989 | + if ($option != 'nolink') { |
|
| 990 | + $label = '<u>' . $langs->trans("ShowProject") . '</u>'; |
|
| 991 | + } |
|
| 964 | 992 | $label .= ($label?'<br>':'').'<b>' . $langs->trans('Ref') . ': </b>' . $this->ref; // The space must be after the : to not being explode when showing the title in img_picto |
| 965 | 993 | $label .= ($label?'<br>':'').'<b>' . $langs->trans('Label') . ': </b>' . $this->title; // The space must be after the : to not being explode when showing the title in img_picto |
| 966 | - if (! empty($this->thirdparty_name)) |
|
| 967 | - $label .= ($label?'<br>':'').'<b>' . $langs->trans('ThirdParty') . ': </b>' . $this->thirdparty_name; // The space must be after the : to not being explode when showing the title in img_picto |
|
| 968 | - if (! empty($this->dateo)) |
|
| 969 | - $label .= ($label?'<br>':'').'<b>' . $langs->trans('DateStart') . ': </b>' . dol_print_date($this->dateo, 'day'); // The space must be after the : to not being explode when showing the title in img_picto |
|
| 970 | - if (! empty($this->datee)) |
|
| 971 | - $label .= ($label?'<br>':'').'<b>' . $langs->trans('DateEnd') . ': </b>' . dol_print_date($this->datee, 'day'); // The space must be after the : to not being explode when showing the title in img_picto |
|
| 972 | - if ($moreinpopup) $label.='<br>'.$moreinpopup; |
|
| 994 | + if (! empty($this->thirdparty_name)) { |
|
| 995 | + $label .= ($label?'<br>':'').'<b>' . $langs->trans('ThirdParty') . ': </b>' . $this->thirdparty_name; |
|
| 996 | + } |
|
| 997 | + // The space must be after the : to not being explode when showing the title in img_picto |
|
| 998 | + if (! empty($this->dateo)) { |
|
| 999 | + $label .= ($label?'<br>':'').'<b>' . $langs->trans('DateStart') . ': </b>' . dol_print_date($this->dateo, 'day'); |
|
| 1000 | + } |
|
| 1001 | + // The space must be after the : to not being explode when showing the title in img_picto |
|
| 1002 | + if (! empty($this->datee)) { |
|
| 1003 | + $label .= ($label?'<br>':'').'<b>' . $langs->trans('DateEnd') . ': </b>' . dol_print_date($this->datee, 'day'); |
|
| 1004 | + } |
|
| 1005 | + // The space must be after the : to not being explode when showing the title in img_picto |
|
| 1006 | + if ($moreinpopup) { |
|
| 1007 | + $label.='<br>'.$moreinpopup; |
|
| 1008 | + } |
|
| 973 | 1009 | |
| 974 | 1010 | $url=''; |
| 975 | 1011 | if ($option != 'nolink') |
| 976 | 1012 | { |
| 977 | 1013 | if (preg_match('/\.php$/',$option)) { |
| 978 | 1014 | $url = dol_buildpath($option,1) . '?id=' . $this->id; |
| 979 | - } |
|
| 980 | - else if ($option == 'task') |
|
| 1015 | + } else if ($option == 'task') |
|
| 981 | 1016 | { |
| 982 | 1017 | $url = DOL_URL_ROOT . '/projet/tasks.php?id=' . $this->id; |
| 983 | - } |
|
| 984 | - else |
|
| 1018 | + } else |
|
| 985 | 1019 | { |
| 986 | 1020 | $url = DOL_URL_ROOT . '/projet/card.php?id=' . $this->id; |
| 987 | 1021 | } |
| 988 | 1022 | // Add param to save lastsearch_values or not |
| 989 | 1023 | $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
| 990 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 991 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 1024 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) { |
|
| 1025 | + $add_save_lastsearch_values=1; |
|
| 1026 | + } |
|
| 1027 | + if ($add_save_lastsearch_values) { |
|
| 1028 | + $url.='&save_lastsearch_values=1'; |
|
| 1029 | + } |
|
| 992 | 1030 | } |
| 993 | 1031 | |
| 994 | 1032 | $linkclose=''; |
@@ -1010,20 +1048,29 @@ discard block |
||
| 1010 | 1048 | $parameters=array('id'=>$this->id); |
| 1011 | 1049 | // Note that $action and $object may have been modified by some hooks |
| 1012 | 1050 | $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); |
| 1013 | - if ($reshook > 0) |
|
| 1014 | - $linkclose = $hookmanager->resPrint; |
|
| 1051 | + if ($reshook > 0) { |
|
| 1052 | + $linkclose = $hookmanager->resPrint; |
|
| 1053 | + } |
|
| 1015 | 1054 | } |
| 1016 | 1055 | |
| 1017 | 1056 | $picto = 'projectpub'; |
| 1018 | - if (!$this->public) $picto = 'project'; |
|
| 1057 | + if (!$this->public) { |
|
| 1058 | + $picto = 'project'; |
|
| 1059 | + } |
|
| 1019 | 1060 | |
| 1020 | 1061 | $linkstart = '<a href="'.$url.'"'; |
| 1021 | 1062 | $linkstart.=$linkclose.'>'; |
| 1022 | 1063 | $linkend='</a>'; |
| 1023 | 1064 | |
| 1024 | - if ($withpicto) $result.=($linkstart . img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1) . $linkend); |
|
| 1025 | - if ($withpicto && $withpicto != 2) $result.=' '; |
|
| 1026 | - if ($withpicto != 2) $result.=$linkstart . $this->ref . $linkend . (($addlabel && $this->title) ? $sep . dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : ''); |
|
| 1065 | + if ($withpicto) { |
|
| 1066 | + $result.=($linkstart . img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1) . $linkend); |
|
| 1067 | + } |
|
| 1068 | + if ($withpicto && $withpicto != 2) { |
|
| 1069 | + $result.=' '; |
|
| 1070 | + } |
|
| 1071 | + if ($withpicto != 2) { |
|
| 1072 | + $result.=$linkstart . $this->ref . $linkend . (($addlabel && $this->title) ? $sep . dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : ''); |
|
| 1073 | + } |
|
| 1027 | 1074 | return $result; |
| 1028 | 1075 | } |
| 1029 | 1076 | |
@@ -1084,12 +1131,10 @@ discard block |
||
| 1084 | 1131 | if (($mode == 'read' && ! empty($user->rights->projet->all->lire)) || ($mode == 'write' && ! empty($user->rights->projet->all->creer)) || ($mode == 'delete' && ! empty($user->rights->projet->all->supprimer))) |
| 1085 | 1132 | { |
| 1086 | 1133 | $userAccess = 1; |
| 1087 | - } |
|
| 1088 | - else if ($this->public && (($mode == 'read' && ! empty($user->rights->projet->lire)) || ($mode == 'write' && ! empty($user->rights->projet->creer)) || ($mode == 'delete' && ! empty($user->rights->projet->supprimer)))) |
|
| 1134 | + } else if ($this->public && (($mode == 'read' && ! empty($user->rights->projet->lire)) || ($mode == 'write' && ! empty($user->rights->projet->creer)) || ($mode == 'delete' && ! empty($user->rights->projet->supprimer)))) |
|
| 1089 | 1135 | { |
| 1090 | 1136 | $userAccess = 1; |
| 1091 | - } |
|
| 1092 | - else |
|
| 1137 | + } else |
|
| 1093 | 1138 | { |
| 1094 | 1139 | foreach (array('internal', 'external') as $source) |
| 1095 | 1140 | { |
@@ -1101,9 +1146,15 @@ discard block |
||
| 1101 | 1146 | { |
| 1102 | 1147 | if ($source == 'internal' && preg_match('/^PROJECT/', $userRole[$nblinks]['code']) && $user->id == $userRole[$nblinks]['id']) |
| 1103 | 1148 | { |
| 1104 | - if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; |
|
| 1105 | - if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; |
|
| 1106 | - if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++; |
|
| 1149 | + if ($mode == 'read' && $user->rights->projet->lire) { |
|
| 1150 | + $userAccess++; |
|
| 1151 | + } |
|
| 1152 | + if ($mode == 'write' && $user->rights->projet->creer) { |
|
| 1153 | + $userAccess++; |
|
| 1154 | + } |
|
| 1155 | + if ($mode == 'delete' && $user->rights->projet->supprimer) { |
|
| 1156 | + $userAccess++; |
|
| 1157 | + } |
|
| 1107 | 1158 | } |
| 1108 | 1159 | $nblinks++; |
| 1109 | 1160 | } |
@@ -1144,7 +1195,9 @@ discard block |
||
| 1144 | 1195 | $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
| 1145 | 1196 | // Internal users must see project he is contact to even if project linked to a third party he can't see. |
| 1146 | 1197 | //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
| 1147 | - if ($socid > 0) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")"; |
|
| 1198 | + if ($socid > 0) { |
|
| 1199 | + $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")"; |
|
| 1200 | + } |
|
| 1148 | 1201 | |
| 1149 | 1202 | // Get id of types of contacts for projects (This list never contains a lot of elements) |
| 1150 | 1203 | $listofprojectcontacttype=array(); |
@@ -1158,9 +1211,13 @@ discard block |
||
| 1158 | 1211 | { |
| 1159 | 1212 | $listofprojectcontacttype[$obj->rowid]=$obj->code; |
| 1160 | 1213 | } |
| 1214 | + } else { |
|
| 1215 | + dol_print_error($this->db); |
|
| 1216 | + } |
|
| 1217 | + if (count($listofprojectcontacttype) == 0) { |
|
| 1218 | + $listofprojectcontacttype[0]='0'; |
|
| 1161 | 1219 | } |
| 1162 | - else dol_print_error($this->db); |
|
| 1163 | - if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid syntax error if not found |
|
| 1220 | + // To avoid syntax error if not found |
|
| 1164 | 1221 | |
| 1165 | 1222 | if ($mode == 0) |
| 1166 | 1223 | { |
@@ -1203,12 +1260,13 @@ discard block |
||
| 1203 | 1260 | |
| 1204 | 1261 | if ($list) |
| 1205 | 1262 | { |
| 1206 | - if (empty($temp)) return '0'; |
|
| 1263 | + if (empty($temp)) { |
|
| 1264 | + return '0'; |
|
| 1265 | + } |
|
| 1207 | 1266 | $result = implode(',', $temp); |
| 1208 | 1267 | return $result; |
| 1209 | 1268 | } |
| 1210 | - } |
|
| 1211 | - else |
|
| 1269 | + } else |
|
| 1212 | 1270 | { |
| 1213 | 1271 | dol_print_error($this->db); |
| 1214 | 1272 | } |
@@ -1249,7 +1307,9 @@ discard block |
||
| 1249 | 1307 | // Load source object |
| 1250 | 1308 | $clone_project->fetch($fromid); |
| 1251 | 1309 | $clone_project->fetch_optionals(); |
| 1252 | - if ($newthirdpartyid > 0) $clone_project->socid = $newthirdpartyid; |
|
| 1310 | + if ($newthirdpartyid > 0) { |
|
| 1311 | + $clone_project->socid = $newthirdpartyid; |
|
| 1312 | + } |
|
| 1253 | 1313 | $clone_project->fetch_thirdparty(); |
| 1254 | 1314 | |
| 1255 | 1315 | $orign_dt_start=$clone_project->date_start; |
@@ -1290,7 +1350,9 @@ discard block |
||
| 1290 | 1350 | break; |
| 1291 | 1351 | } |
| 1292 | 1352 | } |
| 1293 | - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; |
|
| 1353 | + if (is_numeric($defaultref) && $defaultref <= 0) { |
|
| 1354 | + $defaultref=''; |
|
| 1355 | + } |
|
| 1294 | 1356 | |
| 1295 | 1357 | $clone_project->ref=$defaultref; |
| 1296 | 1358 | $clone_project->title=$langs->trans("CopyOf").' '.$clone_project->title; |
@@ -1315,8 +1377,7 @@ discard block |
||
| 1315 | 1377 | { |
| 1316 | 1378 | $clone_project->note_private=''; |
| 1317 | 1379 | $clone_project->note_public=''; |
| 1318 | - } |
|
| 1319 | - else |
|
| 1380 | + } else |
|
| 1320 | 1381 | { |
| 1321 | 1382 | $this->db->begin(); |
| 1322 | 1383 | $res=$clone_project->update_note(dol_html_entity_decode($clone_project->note_public, ENT_QUOTES),'_public'); |
@@ -1325,8 +1386,7 @@ discard block |
||
| 1325 | 1386 | $this->error.=$clone_project->error; |
| 1326 | 1387 | $error++; |
| 1327 | 1388 | $this->db->rollback(); |
| 1328 | - } |
|
| 1329 | - else |
|
| 1389 | + } else |
|
| 1330 | 1390 | { |
| 1331 | 1391 | $this->db->commit(); |
| 1332 | 1392 | } |
@@ -1338,8 +1398,7 @@ discard block |
||
| 1338 | 1398 | $this->error.=$clone_project->error; |
| 1339 | 1399 | $error++; |
| 1340 | 1400 | $this->db->rollback(); |
| 1341 | - } |
|
| 1342 | - else |
|
| 1401 | + } else |
|
| 1343 | 1402 | { |
| 1344 | 1403 | $this->db->commit(); |
| 1345 | 1404 | } |
@@ -1363,8 +1422,7 @@ discard block |
||
| 1363 | 1422 | $langs->load("errors"); |
| 1364 | 1423 | $this->error.=$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); |
| 1365 | 1424 | $error++; |
| 1366 | - } |
|
| 1367 | - else |
|
| 1425 | + } else |
|
| 1368 | 1426 | { |
| 1369 | 1427 | if ($clone_project->error!='') |
| 1370 | 1428 | { |
@@ -1396,8 +1454,7 @@ discard block |
||
| 1396 | 1454 | $error++; |
| 1397 | 1455 | } |
| 1398 | 1456 | } |
| 1399 | - } |
|
| 1400 | - else |
|
| 1457 | + } else |
|
| 1401 | 1458 | { |
| 1402 | 1459 | $this->error.=$langs->trans('ErrorInternalErrorDetected').':dol_mkdir'; |
| 1403 | 1460 | $error++; |
@@ -1413,7 +1470,9 @@ discard block |
||
| 1413 | 1470 | |
| 1414 | 1471 | // Security check |
| 1415 | 1472 | $socid=0; |
| 1416 | - if ($user->societe_id > 0) $socid = $user->societe_id; |
|
| 1473 | + if ($user->societe_id > 0) { |
|
| 1474 | + $socid = $user->societe_id; |
|
| 1475 | + } |
|
| 1417 | 1476 | |
| 1418 | 1477 | $tasksarray=$taskstatic->getTasksArray(0, 0, $fromid, $socid, 0); |
| 1419 | 1478 | |
@@ -1427,8 +1486,7 @@ discard block |
||
| 1427 | 1486 | { |
| 1428 | 1487 | $this->error.=$result_clone->error; |
| 1429 | 1488 | $error++; |
| 1430 | - } |
|
| 1431 | - else |
|
| 1489 | + } else |
|
| 1432 | 1490 | { |
| 1433 | 1491 | $new_task_id=$result_clone; |
| 1434 | 1492 | $taskstatic->fetch($tasktoclone->id); |
@@ -1468,8 +1526,7 @@ discard block |
||
| 1468 | 1526 | { |
| 1469 | 1527 | $this->db->commit(); |
| 1470 | 1528 | return $clone_project_id; |
| 1471 | - } |
|
| 1472 | - else |
|
| 1529 | + } else |
|
| 1473 | 1530 | { |
| 1474 | 1531 | $this->db->rollback(); |
| 1475 | 1532 | dol_syslog(get_class($this)."::createFromClone nbError: ".$error." error : " . $this->error, LOG_ERR); |
@@ -1494,7 +1551,9 @@ discard block |
||
| 1494 | 1551 | |
| 1495 | 1552 | // Security check |
| 1496 | 1553 | $socid=0; |
| 1497 | - if ($user->societe_id > 0) $socid = $user->societe_id; |
|
| 1554 | + if ($user->societe_id > 0) { |
|
| 1555 | + $socid = $user->societe_id; |
|
| 1556 | + } |
|
| 1498 | 1557 | |
| 1499 | 1558 | $tasksarray=$taskstatic->getTasksArray(0, 0, $this->id, $socid, 0); |
| 1500 | 1559 | |
@@ -1561,8 +1620,7 @@ discard block |
||
| 1561 | 1620 | { |
| 1562 | 1621 | $sql.= " SET fk_project=".$this->id; |
| 1563 | 1622 | $sql.= " WHERE id=".$elementSelectId; |
| 1564 | - } |
|
| 1565 | - else |
|
| 1623 | + } else |
|
| 1566 | 1624 | { |
| 1567 | 1625 | $sql.= " SET fk_projet=".$this->id; |
| 1568 | 1626 | $sql.= " WHERE rowid=".$elementSelectId; |
@@ -1573,7 +1631,7 @@ discard block |
||
| 1573 | 1631 | if (!$resql) { |
| 1574 | 1632 | $this->error=$this->db->lasterror(); |
| 1575 | 1633 | return -1; |
| 1576 | - }else { |
|
| 1634 | + } else { |
|
| 1577 | 1635 | return 1; |
| 1578 | 1636 | } |
| 1579 | 1637 | |
@@ -1594,8 +1652,7 @@ discard block |
||
| 1594 | 1652 | { |
| 1595 | 1653 | $sql.= " SET fk_project=NULL"; |
| 1596 | 1654 | $sql.= " WHERE id=".$elementSelectId; |
| 1597 | - } |
|
| 1598 | - else |
|
| 1655 | + } else |
|
| 1599 | 1656 | { |
| 1600 | 1657 | $sql.= " SET fk_projet=NULL"; |
| 1601 | 1658 | $sql.= " WHERE rowid=".$elementSelectId; |
@@ -1606,7 +1663,7 @@ discard block |
||
| 1606 | 1663 | if (!$resql) { |
| 1607 | 1664 | $this->error=$this->db->lasterror(); |
| 1608 | 1665 | return -1; |
| 1609 | - }else { |
|
| 1666 | + } else { |
|
| 1610 | 1667 | return 1; |
| 1611 | 1668 | } |
| 1612 | 1669 | |
@@ -1657,7 +1714,9 @@ discard block |
||
| 1657 | 1714 | { |
| 1658 | 1715 | $error=0; |
| 1659 | 1716 | |
| 1660 | - if (empty($datestart)) dol_print_error('','Error datestart parameter is empty'); |
|
| 1717 | + if (empty($datestart)) { |
|
| 1718 | + dol_print_error('','Error datestart parameter is empty'); |
|
| 1719 | + } |
|
| 1661 | 1720 | |
| 1662 | 1721 | $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.fk_task"; |
| 1663 | 1722 | $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; |
@@ -1665,8 +1724,12 @@ discard block |
||
| 1665 | 1724 | $sql.= " AND pt.fk_projet = ".$this->id; |
| 1666 | 1725 | $sql.= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' "; |
| 1667 | 1726 | $sql.= " AND ptt.task_date <= '".$this->db->idate($datestart + (7 * 24 * 3600) - 1)."')"; |
| 1668 | - if ($task_id) $sql.= " AND ptt.fk_task=".$taskid; |
|
| 1669 | - if (is_numeric($userid)) $sql.= " AND ptt.fk_user=".$userid; |
|
| 1727 | + if ($task_id) { |
|
| 1728 | + $sql.= " AND ptt.fk_task=".$taskid; |
|
| 1729 | + } |
|
| 1730 | + if (is_numeric($userid)) { |
|
| 1731 | + $sql.= " AND ptt.fk_user=".$userid; |
|
| 1732 | + } |
|
| 1670 | 1733 | |
| 1671 | 1734 | //print $sql; |
| 1672 | 1735 | $resql=$this->db->query($sql); |
@@ -1686,8 +1749,7 @@ discard block |
||
| 1686 | 1749 | } |
| 1687 | 1750 | $this->db->free($resql); |
| 1688 | 1751 | return 1; |
| 1689 | - } |
|
| 1690 | - else |
|
| 1752 | + } else |
|
| 1691 | 1753 | { |
| 1692 | 1754 | $this->error="Error ".$this->db->lasterror(); |
| 1693 | 1755 | dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); |
@@ -1714,14 +1776,22 @@ discard block |
||
| 1714 | 1776 | $sql.= " FROM (".MAIN_DB_PREFIX."projet as p"; |
| 1715 | 1777 | $sql.= ")"; |
| 1716 | 1778 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; |
| 1717 | - if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; |
|
| 1779 | + if (! $user->rights->societe->client->voir && ! $socid) { |
|
| 1780 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; |
|
| 1781 | + } |
|
| 1718 | 1782 | $sql.= " WHERE p.fk_statut = 1"; |
| 1719 | 1783 | $sql.= " AND p.entity IN (".getEntity('project', 0).')'; |
| 1720 | - if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
| 1784 | + if ($mine || ! $user->rights->projet->all->lire) { |
|
| 1785 | + $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
| 1786 | + } |
|
| 1721 | 1787 | // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser |
| 1722 | 1788 | //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
| 1723 | - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1724 | - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; |
|
| 1789 | + if ($socid) { |
|
| 1790 | + $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1791 | + } |
|
| 1792 | + if (! $user->rights->societe->client->voir && ! $socid) { |
|
| 1793 | + $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; |
|
| 1794 | + } |
|
| 1725 | 1795 | |
| 1726 | 1796 | $resql=$this->db->query($sql); |
| 1727 | 1797 | if ($resql) |
@@ -1731,8 +1801,11 @@ discard block |
||
| 1731 | 1801 | $response = new WorkboardResponse(); |
| 1732 | 1802 | $response->warning_delay = $conf->projet->warning_delay/60/60/24; |
| 1733 | 1803 | $response->label = $langs->trans("OpenedProjects"); |
| 1734 | - if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/list.php?search_status=1&mainmenu=project'; |
|
| 1735 | - else $response->url = DOL_URL_ROOT.'/projet/list.php?search_project_user=-1&search_status=1&mainmenu=project'; |
|
| 1804 | + if ($user->rights->projet->all->lire) { |
|
| 1805 | + $response->url = DOL_URL_ROOT.'/projet/list.php?search_status=1&mainmenu=project'; |
|
| 1806 | + } else { |
|
| 1807 | + $response->url = DOL_URL_ROOT.'/projet/list.php?search_project_user=-1&search_status=1&mainmenu=project'; |
|
| 1808 | + } |
|
| 1736 | 1809 | $response->img = img_object('',"projectpub"); |
| 1737 | 1810 | |
| 1738 | 1811 | // This assignment in condition is not a bug. It allows walking the results. |
@@ -1750,8 +1823,7 @@ discard block |
||
| 1750 | 1823 | } |
| 1751 | 1824 | |
| 1752 | 1825 | return $response; |
| 1753 | - } |
|
| 1754 | - else |
|
| 1826 | + } else |
|
| 1755 | 1827 | { |
| 1756 | 1828 | $this->error=$this->db->error(); |
| 1757 | 1829 | return -1; |
@@ -1807,8 +1879,7 @@ discard block |
||
| 1807 | 1879 | } |
| 1808 | 1880 | $this->db->free($resql); |
| 1809 | 1881 | return 1; |
| 1810 | - } |
|
| 1811 | - else |
|
| 1882 | + } else |
|
| 1812 | 1883 | { |
| 1813 | 1884 | dol_print_error($this->db); |
| 1814 | 1885 | $this->error=$this->db->error(); |
@@ -1826,8 +1897,12 @@ discard block |
||
| 1826 | 1897 | { |
| 1827 | 1898 | global $conf; |
| 1828 | 1899 | |
| 1829 | - if (! ($this->statut == 1)) return false; |
|
| 1830 | - if (! $this->datee && ! $this->date_end) return false; |
|
| 1900 | + if (! ($this->statut == 1)) { |
|
| 1901 | + return false; |
|
| 1902 | + } |
|
| 1903 | + if (! $this->datee && ! $this->date_end) { |
|
| 1904 | + return false; |
|
| 1905 | + } |
|
| 1831 | 1906 | |
| 1832 | 1907 | $now = dol_now(); |
| 1833 | 1908 | |
@@ -1876,8 +1951,7 @@ discard block |
||
| 1876 | 1951 | |
| 1877 | 1952 | $this->db->free($result); |
| 1878 | 1953 | |
| 1879 | - } |
|
| 1880 | - else |
|
| 1954 | + } else |
|
| 1881 | 1955 | { |
| 1882 | 1956 | dol_print_error($this->db); |
| 1883 | 1957 | } |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | // Check if company name is defined (first install) |
| 45 | 45 | if (!isset($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_NOM)) |
| 46 | 46 | { |
| 47 | - header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); |
|
| 48 | - exit; |
|
| 47 | + header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); |
|
| 48 | + exit; |
|
| 49 | 49 | } |
| 50 | 50 | if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled |
| 51 | 51 | { |
| 52 | - header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); |
|
| 53 | - exit; |
|
| 52 | + header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); |
|
| 53 | + exit; |
|
| 54 | 54 | } |
| 55 | 55 | if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled) |
| 56 | 56 | { |
@@ -85,19 +85,19 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | if (! empty($conf->global->MAIN_MOTD)) |
| 87 | 87 | { |
| 88 | - $conf->global->MAIN_MOTD=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i','<br>',$conf->global->MAIN_MOTD); |
|
| 89 | - if (! empty($conf->global->MAIN_MOTD)) |
|
| 90 | - { |
|
| 91 | - $substitutionarray=getCommonSubstitutionArray($langs); |
|
| 92 | - complete_substitutions_array($substitutionarray, $langs); |
|
| 93 | - $texttoshow = make_substitutions($conf->global->MAIN_MOTD, $substitutionarray, $langs); |
|
| 94 | - |
|
| 95 | - print "\n<!-- Start of welcome text -->\n"; |
|
| 96 | - print '<table width="100%" class="notopnoleftnoright"><tr><td>'; |
|
| 97 | - print dol_htmlentitiesbr($texttoshow); |
|
| 98 | - print '</td></tr></table><br>'; |
|
| 99 | - print "\n<!-- End of welcome text -->\n"; |
|
| 100 | - } |
|
| 88 | + $conf->global->MAIN_MOTD=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i','<br>',$conf->global->MAIN_MOTD); |
|
| 89 | + if (! empty($conf->global->MAIN_MOTD)) |
|
| 90 | + { |
|
| 91 | + $substitutionarray=getCommonSubstitutionArray($langs); |
|
| 92 | + complete_substitutions_array($substitutionarray, $langs); |
|
| 93 | + $texttoshow = make_substitutions($conf->global->MAIN_MOTD, $substitutionarray, $langs); |
|
| 94 | + |
|
| 95 | + print "\n<!-- Start of welcome text -->\n"; |
|
| 96 | + print '<table width="100%" class="notopnoleftnoright"><tr><td>'; |
|
| 97 | + print dol_htmlentitiesbr($texttoshow); |
|
| 98 | + print '</td></tr></table><br>'; |
|
| 99 | + print "\n<!-- End of welcome text -->\n"; |
|
| 100 | + } |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
@@ -117,241 +117,241 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | if (empty($user->societe_id)) |
| 119 | 119 | { |
| 120 | - $boxstat.='<div class="box">'; |
|
| 121 | - $boxstat.='<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable" width="100%">'; |
|
| 122 | - $boxstat.='<tr class="liste_titre">'; |
|
| 123 | - $boxstat.='<th class="liste_titre">'.$langs->trans("DolibarrStateBoard").'</th>'; |
|
| 124 | - $boxstat.='</tr>'; |
|
| 125 | - $boxstat.='<tr class="impair"><td class="tdboxstats nohover flexcontainer">'; |
|
| 126 | - |
|
| 127 | - $var=true; |
|
| 128 | - |
|
| 129 | - $object=new stdClass(); |
|
| 130 | - $parameters=array(); |
|
| 131 | - $action=''; |
|
| 132 | - $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 133 | - $boxstat.=$hookmanager->resPrint; |
|
| 134 | - |
|
| 135 | - if (empty($reshook)) |
|
| 136 | - { |
|
| 137 | - // Condition to be checked for each display line dashboard |
|
| 138 | - $conditions=array( |
|
| 139 | - $user->rights->user->user->lire, |
|
| 140 | - ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS), |
|
| 141 | - ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS), |
|
| 142 | - ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS), |
|
| 143 | - ! empty($conf->societe->enabled) && $user->rights->societe->contact->lire, |
|
| 144 | - ! empty($conf->adherent->enabled) && $user->rights->adherent->lire, |
|
| 145 | - ! empty($conf->product->enabled) && $user->rights->produit->lire, |
|
| 146 | - ! empty($conf->service->enabled) && $user->rights->service->lire, |
|
| 147 | - ! empty($conf->propal->enabled) && $user->rights->propale->lire, |
|
| 148 | - ! empty($conf->commande->enabled) && $user->rights->commande->lire, |
|
| 149 | - ! empty($conf->facture->enabled) && $user->rights->facture->lire, |
|
| 150 | - ! empty($conf->contrat->enabled) && $user->rights->contrat->lire, |
|
| 151 | - ! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire, |
|
| 120 | + $boxstat.='<div class="box">'; |
|
| 121 | + $boxstat.='<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable" width="100%">'; |
|
| 122 | + $boxstat.='<tr class="liste_titre">'; |
|
| 123 | + $boxstat.='<th class="liste_titre">'.$langs->trans("DolibarrStateBoard").'</th>'; |
|
| 124 | + $boxstat.='</tr>'; |
|
| 125 | + $boxstat.='<tr class="impair"><td class="tdboxstats nohover flexcontainer">'; |
|
| 126 | + |
|
| 127 | + $var=true; |
|
| 128 | + |
|
| 129 | + $object=new stdClass(); |
|
| 130 | + $parameters=array(); |
|
| 131 | + $action=''; |
|
| 132 | + $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 133 | + $boxstat.=$hookmanager->resPrint; |
|
| 134 | + |
|
| 135 | + if (empty($reshook)) |
|
| 136 | + { |
|
| 137 | + // Condition to be checked for each display line dashboard |
|
| 138 | + $conditions=array( |
|
| 139 | + $user->rights->user->user->lire, |
|
| 140 | + ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS), |
|
| 141 | + ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS), |
|
| 142 | + ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS), |
|
| 143 | + ! empty($conf->societe->enabled) && $user->rights->societe->contact->lire, |
|
| 144 | + ! empty($conf->adherent->enabled) && $user->rights->adherent->lire, |
|
| 145 | + ! empty($conf->product->enabled) && $user->rights->produit->lire, |
|
| 146 | + ! empty($conf->service->enabled) && $user->rights->service->lire, |
|
| 147 | + ! empty($conf->propal->enabled) && $user->rights->propale->lire, |
|
| 148 | + ! empty($conf->commande->enabled) && $user->rights->commande->lire, |
|
| 149 | + ! empty($conf->facture->enabled) && $user->rights->facture->lire, |
|
| 150 | + ! empty($conf->contrat->enabled) && $user->rights->contrat->lire, |
|
| 151 | + ! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire, |
|
| 152 | 152 | ! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS), |
| 153 | 153 | ! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS), |
| 154 | 154 | ! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS), |
| 155 | - ! empty($conf->projet->enabled) && $user->rights->projet->lire, |
|
| 156 | - ! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire, |
|
| 155 | + ! empty($conf->projet->enabled) && $user->rights->projet->lire, |
|
| 156 | + ! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire, |
|
| 157 | 157 | ! empty($conf->don->enabled) && $user->rights->don->lire |
| 158 | - ); |
|
| 159 | - // Class file containing the method load_state_board for each line |
|
| 160 | - $includes=array( |
|
| 161 | - DOL_DOCUMENT_ROOT."/user/class/user.class.php", |
|
| 162 | - DOL_DOCUMENT_ROOT."/societe/class/client.class.php", |
|
| 163 | - DOL_DOCUMENT_ROOT."/societe/class/client.class.php", |
|
| 164 | - DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.class.php", |
|
| 165 | - DOL_DOCUMENT_ROOT."/contact/class/contact.class.php", |
|
| 166 | - DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php", |
|
| 167 | - DOL_DOCUMENT_ROOT."/product/class/product.class.php", |
|
| 168 | - DOL_DOCUMENT_ROOT."/product/class/product.class.php", |
|
| 169 | - DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php", |
|
| 170 | - DOL_DOCUMENT_ROOT."/commande/class/commande.class.php", |
|
| 171 | - DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php", |
|
| 172 | - DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php", |
|
| 173 | - DOL_DOCUMENT_ROOT."/fichinter/class/fichinter.class.php", |
|
| 174 | - DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php", |
|
| 175 | - DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php", |
|
| 176 | - DOL_DOCUMENT_ROOT."/supplier_proposal/class/supplier_proposal.class.php", |
|
| 177 | - DOL_DOCUMENT_ROOT."/projet/class/project.class.php", |
|
| 178 | - DOL_DOCUMENT_ROOT."/expensereport/class/expensereport.class.php", |
|
| 158 | + ); |
|
| 159 | + // Class file containing the method load_state_board for each line |
|
| 160 | + $includes=array( |
|
| 161 | + DOL_DOCUMENT_ROOT."/user/class/user.class.php", |
|
| 162 | + DOL_DOCUMENT_ROOT."/societe/class/client.class.php", |
|
| 163 | + DOL_DOCUMENT_ROOT."/societe/class/client.class.php", |
|
| 164 | + DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.class.php", |
|
| 165 | + DOL_DOCUMENT_ROOT."/contact/class/contact.class.php", |
|
| 166 | + DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php", |
|
| 167 | + DOL_DOCUMENT_ROOT."/product/class/product.class.php", |
|
| 168 | + DOL_DOCUMENT_ROOT."/product/class/product.class.php", |
|
| 169 | + DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php", |
|
| 170 | + DOL_DOCUMENT_ROOT."/commande/class/commande.class.php", |
|
| 171 | + DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php", |
|
| 172 | + DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php", |
|
| 173 | + DOL_DOCUMENT_ROOT."/fichinter/class/fichinter.class.php", |
|
| 174 | + DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php", |
|
| 175 | + DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php", |
|
| 176 | + DOL_DOCUMENT_ROOT."/supplier_proposal/class/supplier_proposal.class.php", |
|
| 177 | + DOL_DOCUMENT_ROOT."/projet/class/project.class.php", |
|
| 178 | + DOL_DOCUMENT_ROOT."/expensereport/class/expensereport.class.php", |
|
| 179 | 179 | DOL_DOCUMENT_ROOT."/don/class/don.class.php" |
| 180 | - ); |
|
| 181 | - // Name class containing the method load_state_board for each line |
|
| 182 | - $classes=array('User', |
|
| 183 | - 'Client', |
|
| 184 | - 'Client', |
|
| 185 | - 'Fournisseur', |
|
| 186 | - 'Contact', |
|
| 187 | - 'Adherent', |
|
| 188 | - 'Product', |
|
| 189 | - 'Product', |
|
| 190 | - 'Propal', |
|
| 191 | - 'Commande', |
|
| 192 | - 'Facture', |
|
| 193 | - 'Contrat', |
|
| 194 | - 'Fichinter', |
|
| 195 | - 'CommandeFournisseur', |
|
| 196 | - 'FactureFournisseur', |
|
| 197 | - 'SupplierProposal', |
|
| 198 | - 'Project', |
|
| 199 | - 'ExpenseReport', |
|
| 180 | + ); |
|
| 181 | + // Name class containing the method load_state_board for each line |
|
| 182 | + $classes=array('User', |
|
| 183 | + 'Client', |
|
| 184 | + 'Client', |
|
| 185 | + 'Fournisseur', |
|
| 186 | + 'Contact', |
|
| 187 | + 'Adherent', |
|
| 188 | + 'Product', |
|
| 189 | + 'Product', |
|
| 190 | + 'Propal', |
|
| 191 | + 'Commande', |
|
| 192 | + 'Facture', |
|
| 193 | + 'Contrat', |
|
| 194 | + 'Fichinter', |
|
| 195 | + 'CommandeFournisseur', |
|
| 196 | + 'FactureFournisseur', |
|
| 197 | + 'SupplierProposal', |
|
| 198 | + 'Project', |
|
| 199 | + 'ExpenseReport', |
|
| 200 | 200 | 'Don' |
| 201 | - ); |
|
| 202 | - // Cle array returned by the method load_state_board for each line |
|
| 203 | - $keys=array('users', |
|
| 204 | - 'customers', |
|
| 205 | - 'prospects', |
|
| 206 | - 'suppliers', |
|
| 207 | - 'contacts', |
|
| 208 | - 'members', |
|
| 209 | - 'products', |
|
| 210 | - 'services', |
|
| 211 | - 'proposals', |
|
| 212 | - 'orders', |
|
| 213 | - 'invoices', |
|
| 214 | - 'Contracts', |
|
| 215 | - 'fichinters', |
|
| 216 | - 'supplier_orders', |
|
| 217 | - 'supplier_invoices', |
|
| 218 | - 'askprice', |
|
| 219 | - 'projects', |
|
| 220 | - 'expensereports', |
|
| 201 | + ); |
|
| 202 | + // Cle array returned by the method load_state_board for each line |
|
| 203 | + $keys=array('users', |
|
| 204 | + 'customers', |
|
| 205 | + 'prospects', |
|
| 206 | + 'suppliers', |
|
| 207 | + 'contacts', |
|
| 208 | + 'members', |
|
| 209 | + 'products', |
|
| 210 | + 'services', |
|
| 211 | + 'proposals', |
|
| 212 | + 'orders', |
|
| 213 | + 'invoices', |
|
| 214 | + 'Contracts', |
|
| 215 | + 'fichinters', |
|
| 216 | + 'supplier_orders', |
|
| 217 | + 'supplier_invoices', |
|
| 218 | + 'askprice', |
|
| 219 | + 'projects', |
|
| 220 | + 'expensereports', |
|
| 221 | 221 | 'donations' |
| 222 | - ); |
|
| 223 | - // Dashboard Icon lines |
|
| 224 | - $icons=array('user', |
|
| 225 | - 'company', |
|
| 226 | - 'company', |
|
| 227 | - 'company', |
|
| 228 | - 'contact', |
|
| 229 | - 'user', |
|
| 230 | - 'product', |
|
| 231 | - 'service', |
|
| 232 | - 'propal', |
|
| 233 | - 'order', |
|
| 234 | - 'bill', |
|
| 235 | - 'order', |
|
| 236 | - 'order', |
|
| 237 | - 'order', |
|
| 238 | - 'bill', |
|
| 239 | - 'propal', |
|
| 240 | - 'projectpub', |
|
| 222 | + ); |
|
| 223 | + // Dashboard Icon lines |
|
| 224 | + $icons=array('user', |
|
| 225 | + 'company', |
|
| 226 | + 'company', |
|
| 227 | + 'company', |
|
| 228 | + 'contact', |
|
| 229 | + 'user', |
|
| 230 | + 'product', |
|
| 231 | + 'service', |
|
| 232 | + 'propal', |
|
| 233 | + 'order', |
|
| 234 | + 'bill', |
|
| 235 | + 'order', |
|
| 236 | + 'order', |
|
| 237 | + 'order', |
|
| 238 | + 'bill', |
|
| 239 | + 'propal', |
|
| 240 | + 'projectpub', |
|
| 241 | 241 | 'trip', |
| 242 | 242 | 'generic' |
| 243 | - ); |
|
| 244 | - // Translation keyword |
|
| 245 | - $titres=array("Users", |
|
| 246 | - "ThirdPartyCustomersStats", |
|
| 247 | - "ThirdPartyProspectsStats", |
|
| 248 | - "Suppliers", |
|
| 249 | - "Contacts", |
|
| 250 | - "Members", |
|
| 251 | - "Products", |
|
| 252 | - "Services", |
|
| 253 | - "CommercialProposalsShort", |
|
| 254 | - "CustomersOrders", |
|
| 255 | - "BillsCustomers", |
|
| 256 | - "Contracts", |
|
| 257 | - "Interventions", |
|
| 258 | - "SuppliersOrders", |
|
| 259 | - "SuppliersInvoices", |
|
| 260 | - "SupplierProposalShort", |
|
| 261 | - "Projects", |
|
| 243 | + ); |
|
| 244 | + // Translation keyword |
|
| 245 | + $titres=array("Users", |
|
| 246 | + "ThirdPartyCustomersStats", |
|
| 247 | + "ThirdPartyProspectsStats", |
|
| 248 | + "Suppliers", |
|
| 249 | + "Contacts", |
|
| 250 | + "Members", |
|
| 251 | + "Products", |
|
| 252 | + "Services", |
|
| 253 | + "CommercialProposalsShort", |
|
| 254 | + "CustomersOrders", |
|
| 255 | + "BillsCustomers", |
|
| 256 | + "Contracts", |
|
| 257 | + "Interventions", |
|
| 258 | + "SuppliersOrders", |
|
| 259 | + "SuppliersInvoices", |
|
| 260 | + "SupplierProposalShort", |
|
| 261 | + "Projects", |
|
| 262 | 262 | "ExpenseReports", |
| 263 | 263 | "Donations" |
| 264 | - ); |
|
| 265 | - // Dashboard Link lines |
|
| 266 | - $links=array( |
|
| 267 | - DOL_URL_ROOT.'/user/index.php', |
|
| 268 | - DOL_URL_ROOT.'/societe/list.php?type=c', |
|
| 269 | - DOL_URL_ROOT.'/societe/list.php?type=p', |
|
| 270 | - DOL_URL_ROOT.'/societe/list.php?type=f', |
|
| 271 | - DOL_URL_ROOT.'/contact/list.php', |
|
| 272 | - DOL_URL_ROOT.'/adherents/list.php?statut=1&mainmenu=members', |
|
| 273 | - DOL_URL_ROOT.'/product/list.php?type=0&mainmenu=products', |
|
| 274 | - DOL_URL_ROOT.'/product/list.php?type=1&mainmenu=products', |
|
| 275 | - DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial', |
|
| 276 | - DOL_URL_ROOT.'/commande/list.php?mainmenu=commercial', |
|
| 277 | - DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy', |
|
| 278 | - DOL_URL_ROOT.'/contrat/list.php', |
|
| 279 | - DOL_URL_ROOT.'/fichinter/list.php', |
|
| 280 | - DOL_URL_ROOT.'/fourn/commande/list.php', |
|
| 281 | - DOL_URL_ROOT.'/fourn/facture/list.php', |
|
| 282 | - DOL_URL_ROOT.'/supplier_proposal/list.php', |
|
| 283 | - DOL_URL_ROOT.'/projet/list.php?mainmenu=project', |
|
| 284 | - DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm', |
|
| 264 | + ); |
|
| 265 | + // Dashboard Link lines |
|
| 266 | + $links=array( |
|
| 267 | + DOL_URL_ROOT.'/user/index.php', |
|
| 268 | + DOL_URL_ROOT.'/societe/list.php?type=c', |
|
| 269 | + DOL_URL_ROOT.'/societe/list.php?type=p', |
|
| 270 | + DOL_URL_ROOT.'/societe/list.php?type=f', |
|
| 271 | + DOL_URL_ROOT.'/contact/list.php', |
|
| 272 | + DOL_URL_ROOT.'/adherents/list.php?statut=1&mainmenu=members', |
|
| 273 | + DOL_URL_ROOT.'/product/list.php?type=0&mainmenu=products', |
|
| 274 | + DOL_URL_ROOT.'/product/list.php?type=1&mainmenu=products', |
|
| 275 | + DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial', |
|
| 276 | + DOL_URL_ROOT.'/commande/list.php?mainmenu=commercial', |
|
| 277 | + DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy', |
|
| 278 | + DOL_URL_ROOT.'/contrat/list.php', |
|
| 279 | + DOL_URL_ROOT.'/fichinter/list.php', |
|
| 280 | + DOL_URL_ROOT.'/fourn/commande/list.php', |
|
| 281 | + DOL_URL_ROOT.'/fourn/facture/list.php', |
|
| 282 | + DOL_URL_ROOT.'/supplier_proposal/list.php', |
|
| 283 | + DOL_URL_ROOT.'/projet/list.php?mainmenu=project', |
|
| 284 | + DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm', |
|
| 285 | 285 | DOL_URL_ROOT.'/don/list.php?leftmenu=donations' |
| 286 | - ); |
|
| 287 | - // Translation lang files |
|
| 288 | - $langfile=array("users", |
|
| 289 | - "companies", |
|
| 290 | - "prospects", |
|
| 291 | - "suppliers", |
|
| 292 | - "companies", |
|
| 293 | - "members", |
|
| 294 | - "products", |
|
| 295 | - "products", |
|
| 296 | - "propal", |
|
| 297 | - "orders", |
|
| 298 | - "bills", |
|
| 286 | + ); |
|
| 287 | + // Translation lang files |
|
| 288 | + $langfile=array("users", |
|
| 289 | + "companies", |
|
| 290 | + "prospects", |
|
| 291 | + "suppliers", |
|
| 292 | + "companies", |
|
| 293 | + "members", |
|
| 294 | + "products", |
|
| 295 | + "products", |
|
| 296 | + "propal", |
|
| 297 | + "orders", |
|
| 298 | + "bills", |
|
| 299 | 299 | "contracts", |
| 300 | 300 | "interventions", |
| 301 | - "bills", |
|
| 302 | - "bills", |
|
| 303 | - "supplier_proposal", |
|
| 304 | - "projects", |
|
| 301 | + "bills", |
|
| 302 | + "bills", |
|
| 303 | + "supplier_proposal", |
|
| 304 | + "projects", |
|
| 305 | 305 | "trips", |
| 306 | 306 | "donations" |
| 307 | - ); |
|
| 308 | - |
|
| 309 | - |
|
| 310 | - // Loop and displays each line of table |
|
| 311 | - foreach ($keys as $key=>$val) |
|
| 312 | - { |
|
| 313 | - if ($conditions[$key]) |
|
| 314 | - { |
|
| 315 | - $classe=$classes[$key]; |
|
| 316 | - // Search in cache if load_state_board is already realized |
|
| 317 | - if (! isset($boardloaded[$classe]) || ! is_object($boardloaded[$classe])) |
|
| 318 | - { |
|
| 319 | - include_once $includes[$key]; // Loading a class cost around 1Mb |
|
| 320 | - |
|
| 321 | - $board=new $classe($db); |
|
| 322 | - $board->load_state_board($user); |
|
| 323 | - $boardloaded[$classe]=$board; |
|
| 324 | - } |
|
| 325 | - else |
|
| 326 | - { |
|
| 327 | - $board=$boardloaded[$classe]; |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - |
|
| 331 | - if (!empty($langfile[$key])) $langs->load($langfile[$key]); |
|
| 332 | - $text=$langs->trans($titres[$key]); |
|
| 333 | - $boxstat.='<a href="'.$links[$key].'" class="boxstatsindicator thumbstat nobold nounderline">'; |
|
| 334 | - $boxstat.='<div class="boxstats">'; |
|
| 335 | - $boxstat.='<span class="boxstatstext" title="'.dol_escape_htmltag($text).'">'.img_object("",$icons[$key]).' '.$text.'</span><br>'; |
|
| 336 | - $boxstat.='<span class="boxstatsindicator">'.($board->nb[$val]?$board->nb[$val]:0).'</span>'; |
|
| 337 | - $boxstat.='</div>'; |
|
| 338 | - $boxstat.='</a>'; |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 344 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 345 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 346 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 347 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 348 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 349 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 350 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 351 | - |
|
| 352 | - $boxstat.='</td></tr>'; |
|
| 353 | - $boxstat.='</table>'; |
|
| 354 | - $boxstat.='</div>'; |
|
| 307 | + ); |
|
| 308 | + |
|
| 309 | + |
|
| 310 | + // Loop and displays each line of table |
|
| 311 | + foreach ($keys as $key=>$val) |
|
| 312 | + { |
|
| 313 | + if ($conditions[$key]) |
|
| 314 | + { |
|
| 315 | + $classe=$classes[$key]; |
|
| 316 | + // Search in cache if load_state_board is already realized |
|
| 317 | + if (! isset($boardloaded[$classe]) || ! is_object($boardloaded[$classe])) |
|
| 318 | + { |
|
| 319 | + include_once $includes[$key]; // Loading a class cost around 1Mb |
|
| 320 | + |
|
| 321 | + $board=new $classe($db); |
|
| 322 | + $board->load_state_board($user); |
|
| 323 | + $boardloaded[$classe]=$board; |
|
| 324 | + } |
|
| 325 | + else |
|
| 326 | + { |
|
| 327 | + $board=$boardloaded[$classe]; |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + |
|
| 331 | + if (!empty($langfile[$key])) $langs->load($langfile[$key]); |
|
| 332 | + $text=$langs->trans($titres[$key]); |
|
| 333 | + $boxstat.='<a href="'.$links[$key].'" class="boxstatsindicator thumbstat nobold nounderline">'; |
|
| 334 | + $boxstat.='<div class="boxstats">'; |
|
| 335 | + $boxstat.='<span class="boxstatstext" title="'.dol_escape_htmltag($text).'">'.img_object("",$icons[$key]).' '.$text.'</span><br>'; |
|
| 336 | + $boxstat.='<span class="boxstatsindicator">'.($board->nb[$val]?$board->nb[$val]:0).'</span>'; |
|
| 337 | + $boxstat.='</div>'; |
|
| 338 | + $boxstat.='</a>'; |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 344 | + $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 345 | + $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 346 | + $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 347 | + $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 348 | + $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 349 | + $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 350 | + $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 351 | + |
|
| 352 | + $boxstat.='</td></tr>'; |
|
| 353 | + $boxstat.='</table>'; |
|
| 354 | + $boxstat.='</div>'; |
|
| 355 | 355 | } |
| 356 | 356 | //print $boxstat; |
| 357 | 357 | |
@@ -372,130 +372,130 @@ discard block |
||
| 372 | 372 | // Number of actions to do (late) |
| 373 | 373 | if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) |
| 374 | 374 | { |
| 375 | - include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
| 376 | - $board=new ActionComm($db); |
|
| 375 | + include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
| 376 | + $board=new ActionComm($db); |
|
| 377 | 377 | |
| 378 | - $dashboardlines[] = $board->load_board($user); |
|
| 378 | + $dashboardlines[] = $board->load_board($user); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | // Number of project opened |
| 382 | 382 | if (! empty($conf->projet->enabled) && $user->rights->projet->lire) |
| 383 | 383 | { |
| 384 | - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
| 385 | - $board=new Project($db); |
|
| 386 | - $dashboardlines[] = $board->load_board($user); |
|
| 384 | + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
| 385 | + $board=new Project($db); |
|
| 386 | + $dashboardlines[] = $board->load_board($user); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | // Number of tasks to do (late) |
| 390 | 390 | if (! empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->rights->projet->lire) |
| 391 | 391 | { |
| 392 | - include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
|
| 393 | - $board=new Task($db); |
|
| 394 | - $dashboardlines[] = $board->load_board($user); |
|
| 392 | + include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
|
| 393 | + $board=new Task($db); |
|
| 394 | + $dashboardlines[] = $board->load_board($user); |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | // Number of commercial proposals opened (expired) |
| 398 | 398 | if (! empty($conf->propal->enabled) && $user->rights->propale->lire) |
| 399 | 399 | { |
| 400 | - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 401 | - $board=new Propal($db); |
|
| 402 | - $dashboardlines[] = $board->load_board($user,"opened"); |
|
| 403 | - // Number of commercial proposals CLOSED signed (billed) |
|
| 404 | - $dashboardlines[] = $board->load_board($user,"signed"); |
|
| 400 | + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 401 | + $board=new Propal($db); |
|
| 402 | + $dashboardlines[] = $board->load_board($user,"opened"); |
|
| 403 | + // Number of commercial proposals CLOSED signed (billed) |
|
| 404 | + $dashboardlines[] = $board->load_board($user,"signed"); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | // Number of commercial proposals opened (expired) |
| 408 | 408 | if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) |
| 409 | 409 | { |
| 410 | - include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; |
|
| 411 | - $board=new SupplierProposal($db); |
|
| 412 | - $dashboardlines[] = $board->load_board($user,"opened"); |
|
| 413 | - // Number of commercial proposals CLOSED signed (billed) |
|
| 414 | - $dashboardlines[] = $board->load_board($user,"signed"); |
|
| 410 | + include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; |
|
| 411 | + $board=new SupplierProposal($db); |
|
| 412 | + $dashboardlines[] = $board->load_board($user,"opened"); |
|
| 413 | + // Number of commercial proposals CLOSED signed (billed) |
|
| 414 | + $dashboardlines[] = $board->load_board($user,"signed"); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | // Number of customer orders a deal |
| 418 | 418 | if (! empty($conf->commande->enabled) && $user->rights->commande->lire) |
| 419 | 419 | { |
| 420 | - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 421 | - $board=new Commande($db); |
|
| 420 | + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 421 | + $board=new Commande($db); |
|
| 422 | 422 | $dashboardlines[] = $board->load_board($user); |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Number of suppliers orders a deal |
| 426 | 426 | if (! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire) |
| 427 | 427 | { |
| 428 | - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
|
| 429 | - $board=new CommandeFournisseur($db); |
|
| 428 | + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
|
| 429 | + $board=new CommandeFournisseur($db); |
|
| 430 | 430 | $dashboardlines[] = $board->load_board($user); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | // Number of services enabled (delayed) |
| 434 | 434 | if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) |
| 435 | 435 | { |
| 436 | - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
| 437 | - $board=new Contrat($db); |
|
| 438 | - $dashboardlines[] = $board->load_board($user,"inactives"); |
|
| 436 | + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
| 437 | + $board=new Contrat($db); |
|
| 438 | + $dashboardlines[] = $board->load_board($user,"inactives"); |
|
| 439 | 439 | // Number of active services (expired) |
| 440 | - $dashboardlines[] = $board->load_board($user,"expired"); |
|
| 440 | + $dashboardlines[] = $board->load_board($user,"expired"); |
|
| 441 | 441 | } |
| 442 | 442 | // Number of invoices customers (has paid) |
| 443 | 443 | if (! empty($conf->facture->enabled) && $user->rights->facture->lire) |
| 444 | 444 | { |
| 445 | - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 446 | - $board=new Facture($db); |
|
| 447 | - $dashboardlines[] = $board->load_board($user); |
|
| 445 | + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 446 | + $board=new Facture($db); |
|
| 447 | + $dashboardlines[] = $board->load_board($user); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | // Number of supplier invoices (has paid) |
| 451 | 451 | if (! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire) |
| 452 | 452 | { |
| 453 | - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
| 454 | - $board=new FactureFournisseur($db); |
|
| 455 | - $dashboardlines[] = $board->load_board($user); |
|
| 453 | + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
| 454 | + $board=new FactureFournisseur($db); |
|
| 455 | + $dashboardlines[] = $board->load_board($user); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | // Number of transactions to conciliate |
| 459 | 459 | if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id) |
| 460 | 460 | { |
| 461 | - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
|
| 462 | - $board=new Account($db); |
|
| 463 | - $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate |
|
| 464 | - if ($nb > 0) |
|
| 465 | - { |
|
| 466 | - $dashboardlines[] = $board->load_board($user); |
|
| 467 | - } |
|
| 461 | + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
|
| 462 | + $board=new Account($db); |
|
| 463 | + $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate |
|
| 464 | + if ($nb > 0) |
|
| 465 | + { |
|
| 466 | + $dashboardlines[] = $board->load_board($user); |
|
| 467 | + } |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | // Number of cheque to send |
| 471 | 471 | if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) |
| 472 | 472 | { |
| 473 | - include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; |
|
| 474 | - $board=new RemiseCheque($db); |
|
| 475 | - $dashboardlines[] = $board->load_board($user); |
|
| 473 | + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; |
|
| 474 | + $board=new RemiseCheque($db); |
|
| 475 | + $dashboardlines[] = $board->load_board($user); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | // Number of foundation members |
| 479 | 479 | if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire && ! $user->societe_id) |
| 480 | 480 | { |
| 481 | - include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
| 482 | - $board=new Adherent($db); |
|
| 483 | - $dashboardlines[] = $board->load_board($user); |
|
| 481 | + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
| 482 | + $board=new Adherent($db); |
|
| 483 | + $dashboardlines[] = $board->load_board($user); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | // Number of expense reports to approve |
| 487 | 487 | if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) |
| 488 | 488 | { |
| 489 | - include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; |
|
| 490 | - $board=new ExpenseReport($db); |
|
| 489 | + include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; |
|
| 490 | + $board=new ExpenseReport($db); |
|
| 491 | 491 | $dashboardlines[] = $board->load_board($user,'toapprove'); |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | // Number of expense reports to pay |
| 495 | 495 | if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) |
| 496 | 496 | { |
| 497 | - include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; |
|
| 498 | - $board=new ExpenseReport($db); |
|
| 497 | + include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; |
|
| 498 | + $board=new ExpenseReport($db); |
|
| 499 | 499 | $dashboardlines[] = $board->load_board($user,'topay'); |
| 500 | 500 | } |
| 501 | 501 | |
@@ -514,9 +514,9 @@ discard block |
||
| 514 | 514 | // We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop |
| 515 | 515 | foreach($valid_dashboardlines as $board) |
| 516 | 516 | { |
| 517 | - if ($board->nbtodolate > 0) { |
|
| 518 | - $totallate += $board->nbtodolate; |
|
| 519 | - } |
|
| 517 | + if ($board->nbtodolate > 0) { |
|
| 518 | + $totallate += $board->nbtodolate; |
|
| 519 | + } |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | |
@@ -529,16 +529,16 @@ discard block |
||
| 529 | 529 | |
| 530 | 530 | if ($showweather) |
| 531 | 531 | { |
| 532 | - $boxwork.='<tr class="nohover">'; |
|
| 533 | - $boxwork.='<td class="nohover hideonsmartphone center valignmiddle">'; |
|
| 534 | - $text=''; |
|
| 535 | - if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate).')'; |
|
| 536 | - $text.='. '.$langs->trans("LateDesc"); |
|
| 537 | - //$text.=$form->textwithpicto('',$langs->trans("LateDesc")); |
|
| 538 | - $options='height="64px"'; |
|
| 539 | - $boxwork.=showWeather($totallate,$text,$options); |
|
| 540 | - $boxwork.='</td>'; |
|
| 541 | - $boxwork.='</tr>'; |
|
| 532 | + $boxwork.='<tr class="nohover">'; |
|
| 533 | + $boxwork.='<td class="nohover hideonsmartphone center valignmiddle">'; |
|
| 534 | + $text=''; |
|
| 535 | + if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate).')'; |
|
| 536 | + $text.='. '.$langs->trans("LateDesc"); |
|
| 537 | + //$text.=$form->textwithpicto('',$langs->trans("LateDesc")); |
|
| 538 | + $options='height="64px"'; |
|
| 539 | + $boxwork.=showWeather($totallate,$text,$options); |
|
| 540 | + $boxwork.='</td>'; |
|
| 541 | + $boxwork.='</tr>'; |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | $boxwork.='<tr class="nohover"><td class="tdboxstats nohover flexcontainer">'; |
@@ -547,48 +547,48 @@ discard block |
||
| 547 | 547 | $nbworkboardempty=0; |
| 548 | 548 | if (! empty($valid_dashboardlines)) |
| 549 | 549 | { |
| 550 | - foreach($valid_dashboardlines as $board) |
|
| 551 | - { |
|
| 552 | - if (empty($boad->nbtodo)) $nbworkboardempty++; |
|
| 553 | - |
|
| 554 | - $textlate = $langs->trans("NActionsLate",$board->nbtodolate); |
|
| 555 | - $textlate.= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')'; |
|
| 556 | - |
|
| 557 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats130 boxstatsborder">'; |
|
| 558 | - $boxwork .= '<div class="boxstatscontent">'; |
|
| 559 | - $boxwork .= '<span class="boxstatstext" title="'.dol_escape_htmltag($board->label).'">'.$board->img.' '.$board->label.'</span><br>'; |
|
| 560 | - $boxwork .= '<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0)?' dashboardlineok':'').'">'.$board->nbtodo.'</span></a>'; |
|
| 561 | - $boxwork .= '</div>'; |
|
| 562 | - if ($board->nbtodolate > 0) |
|
| 563 | - { |
|
| 564 | - $boxwork .= '<div class="dashboardlinelatecoin nowrap">'; |
|
| 565 | - $boxwork .= '<a title="'.dol_escape_htmltag($textlate).'" class="valignmiddle dashboardlineindicatorlate'.($board->nbtodolate>0?' dashboardlineko':' dashboardlineok').'" href="'.((!$board->url_late) ? $board->url : $board->url_late ).'">'; |
|
| 566 | - //$boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').''; |
|
| 567 | - $boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').''; |
|
| 568 | - $boxwork .= '<span class="dashboardlineindicatorlate'.($board->nbtodolate>0?' dashboardlineko':' dashboardlineok').'">'; |
|
| 569 | - $boxwork .= $board->nbtodolate; |
|
| 570 | - $boxwork .= '</span>'; |
|
| 571 | - $boxwork .= '</a>'; |
|
| 572 | - $boxwork .= '</div>'; |
|
| 573 | - } |
|
| 574 | - $boxwork.='</div></div>'; |
|
| 575 | - $boxwork .="\n"; |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 579 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 580 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 581 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 582 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 583 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 550 | + foreach($valid_dashboardlines as $board) |
|
| 551 | + { |
|
| 552 | + if (empty($boad->nbtodo)) $nbworkboardempty++; |
|
| 553 | + |
|
| 554 | + $textlate = $langs->trans("NActionsLate",$board->nbtodolate); |
|
| 555 | + $textlate.= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')'; |
|
| 556 | + |
|
| 557 | + $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats130 boxstatsborder">'; |
|
| 558 | + $boxwork .= '<div class="boxstatscontent">'; |
|
| 559 | + $boxwork .= '<span class="boxstatstext" title="'.dol_escape_htmltag($board->label).'">'.$board->img.' '.$board->label.'</span><br>'; |
|
| 560 | + $boxwork .= '<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0)?' dashboardlineok':'').'">'.$board->nbtodo.'</span></a>'; |
|
| 561 | + $boxwork .= '</div>'; |
|
| 562 | + if ($board->nbtodolate > 0) |
|
| 563 | + { |
|
| 564 | + $boxwork .= '<div class="dashboardlinelatecoin nowrap">'; |
|
| 565 | + $boxwork .= '<a title="'.dol_escape_htmltag($textlate).'" class="valignmiddle dashboardlineindicatorlate'.($board->nbtodolate>0?' dashboardlineko':' dashboardlineok').'" href="'.((!$board->url_late) ? $board->url : $board->url_late ).'">'; |
|
| 566 | + //$boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').''; |
|
| 567 | + $boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').''; |
|
| 568 | + $boxwork .= '<span class="dashboardlineindicatorlate'.($board->nbtodolate>0?' dashboardlineko':' dashboardlineok').'">'; |
|
| 569 | + $boxwork .= $board->nbtodolate; |
|
| 570 | + $boxwork .= '</span>'; |
|
| 571 | + $boxwork .= '</a>'; |
|
| 572 | + $boxwork .= '</div>'; |
|
| 573 | + } |
|
| 574 | + $boxwork.='</div></div>'; |
|
| 575 | + $boxwork .="\n"; |
|
| 576 | + } |
|
| 577 | + |
|
| 578 | + $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 579 | + $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 580 | + $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 581 | + $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 582 | + $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 583 | + $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 584 | 584 | } |
| 585 | 585 | else |
| 586 | 586 | { |
| 587 | - $boxwork.='<tr class="nohover">'; |
|
| 588 | - $boxwork.='<td colspan="4" class="nohover valignmiddle opacitymedium">'; |
|
| 589 | - $boxwork.=$langs->trans("NoOpenedElementToProcess"); |
|
| 590 | - $boxwork.='</td>'; |
|
| 591 | - $boxwork.='</tr>'; |
|
| 587 | + $boxwork.='<tr class="nohover">'; |
|
| 588 | + $boxwork.='<td colspan="4" class="nohover valignmiddle opacitymedium">'; |
|
| 589 | + $boxwork.=$langs->trans("NoOpenedElementToProcess"); |
|
| 590 | + $boxwork.='</td>'; |
|
| 591 | + $boxwork.='</tr>'; |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | $boxwork.='</td></tr>'; |
@@ -637,32 +637,32 @@ discard block |
||
| 637 | 637 | // Security warning repertoire install existe (si utilisateur admin) |
| 638 | 638 | if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) |
| 639 | 639 | { |
| 640 | - $message=''; |
|
| 641 | - |
|
| 642 | - // Check if install lock file is present |
|
| 643 | - $lockfile=DOL_DATA_ROOT.'/install.lock'; |
|
| 644 | - if (! empty($lockfile) && ! file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install")) |
|
| 645 | - { |
|
| 646 | - $langs->load("errors"); |
|
| 647 | - //if (! empty($message)) $message.='<br>'; |
|
| 648 | - $message.=info_admin($langs->trans("WarningLockFileDoesNotExists",DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); |
|
| 649 | - } |
|
| 650 | - |
|
| 651 | - // Conf files must be in read only mode |
|
| 652 | - if (is_writable($conffile)) |
|
| 653 | - { |
|
| 654 | - $langs->load("errors"); |
|
| 655 | - //$langs->load("other"); |
|
| 656 | - //if (! empty($message)) $message.='<br>'; |
|
| 657 | - $message.=info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); |
|
| 658 | - } |
|
| 659 | - |
|
| 660 | - if ($message) |
|
| 661 | - { |
|
| 662 | - print $message; |
|
| 663 | - //$message.='<br>'; |
|
| 664 | - //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); |
|
| 665 | - } |
|
| 640 | + $message=''; |
|
| 641 | + |
|
| 642 | + // Check if install lock file is present |
|
| 643 | + $lockfile=DOL_DATA_ROOT.'/install.lock'; |
|
| 644 | + if (! empty($lockfile) && ! file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install")) |
|
| 645 | + { |
|
| 646 | + $langs->load("errors"); |
|
| 647 | + //if (! empty($message)) $message.='<br>'; |
|
| 648 | + $message.=info_admin($langs->trans("WarningLockFileDoesNotExists",DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); |
|
| 649 | + } |
|
| 650 | + |
|
| 651 | + // Conf files must be in read only mode |
|
| 652 | + if (is_writable($conffile)) |
|
| 653 | + { |
|
| 654 | + $langs->load("errors"); |
|
| 655 | + //$langs->load("other"); |
|
| 656 | + //if (! empty($message)) $message.='<br>'; |
|
| 657 | + $message.=info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); |
|
| 658 | + } |
|
| 659 | + |
|
| 660 | + if ($message) |
|
| 661 | + { |
|
| 662 | + print $message; |
|
| 663 | + //$message.='<br>'; |
|
| 664 | + //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); |
|
| 665 | + } |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | //print 'mem='.memory_get_usage().' - '.memory_get_peak_usage(); |
@@ -683,21 +683,21 @@ discard block |
||
| 683 | 683 | */ |
| 684 | 684 | function showWeather($totallate,$text,$options) |
| 685 | 685 | { |
| 686 | - global $conf; |
|
| 687 | - |
|
| 688 | - $out=''; |
|
| 689 | - $offset=0; |
|
| 690 | - $factor=10; // By default |
|
| 691 | - |
|
| 692 | - $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0; |
|
| 693 | - $level1=$offset+1*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1; |
|
| 694 | - $level2=$offset+2*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2; |
|
| 695 | - $level3=$offset+3*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3; |
|
| 696 | - |
|
| 697 | - if ($totallate <= $level0) $out.=img_weather($text,'weather-clear.png',$options); |
|
| 698 | - if ($totallate > $level0 && $totallate <= $level1) $out.=img_weather($text,'weather-few-clouds.png',$options); |
|
| 699 | - if ($totallate > $level1 && $totallate <= $level2) $out.=img_weather($text,'weather-clouds.png',$options); |
|
| 700 | - if ($totallate > $level2 && $totallate <= $level3) $out.=img_weather($text,'weather-many-clouds.png',$options); |
|
| 701 | - if ($totallate > $level3) $out.=img_weather($text,'weather-storm.png',$options); |
|
| 702 | - return $out; |
|
| 686 | + global $conf; |
|
| 687 | + |
|
| 688 | + $out=''; |
|
| 689 | + $offset=0; |
|
| 690 | + $factor=10; // By default |
|
| 691 | + |
|
| 692 | + $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0; |
|
| 693 | + $level1=$offset+1*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1; |
|
| 694 | + $level2=$offset+2*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2; |
|
| 695 | + $level3=$offset+3*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3; |
|
| 696 | + |
|
| 697 | + if ($totallate <= $level0) $out.=img_weather($text,'weather-clear.png',$options); |
|
| 698 | + if ($totallate > $level0 && $totallate <= $level1) $out.=img_weather($text,'weather-few-clouds.png',$options); |
|
| 699 | + if ($totallate > $level1 && $totallate <= $level2) $out.=img_weather($text,'weather-clouds.png',$options); |
|
| 700 | + if ($totallate > $level2 && $totallate <= $level3) $out.=img_weather($text,'weather-many-clouds.png',$options); |
|
| 701 | + if ($totallate > $level3) $out.=img_weather($text,'weather-storm.png',$options); |
|
| 702 | + return $out; |
|
| 703 | 703 | } |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | * \brief Dolibarr home page |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -define('NOCSRFCHECK',1); // This is main home and login page. We must be able to go on it from another web site. |
|
| 27 | +define('NOCSRFCHECK', 1); // This is main home and login page. We must be able to go on it from another web site. |
|
| 28 | 28 | |
| 29 | 29 | require 'main.inc.php'; |
| 30 | 30 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; |
| 31 | 31 | |
| 32 | 32 | // If not defined, we select menu "home" |
| 33 | -$_GET['mainmenu']=GETPOST('mainmenu', 'aZ09')?GETPOST('mainmenu', 'aZ09'):'home'; |
|
| 34 | -$action=GETPOST('action','aZ09'); |
|
| 33 | +$_GET['mainmenu'] = GETPOST('mainmenu', 'aZ09') ? GETPOST('mainmenu', 'aZ09') : 'home'; |
|
| 34 | +$action = GETPOST('action', 'aZ09'); |
|
| 35 | 35 | |
| 36 | 36 | $hookmanager->initHooks(array('index')); |
| 37 | 37 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); |
| 48 | 48 | exit; |
| 49 | 49 | } |
| 50 | -if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled |
|
| 50 | +if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled |
|
| 51 | 51 | { |
| 52 | 52 | header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); |
| 53 | 53 | exit; |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled) |
| 56 | 56 | { |
| 57 | 57 | require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; |
| 58 | - $zone=GETPOST('areacode', 'aZ09'); |
|
| 59 | - $userid=GETPOST('userid', 'int'); |
|
| 60 | - $boxorder=GETPOST('boxorder', 'aZ09'); |
|
| 61 | - $boxorder.=GETPOST('boxcombo', 'aZ09'); |
|
| 58 | + $zone = GETPOST('areacode', 'aZ09'); |
|
| 59 | + $userid = GETPOST('userid', 'int'); |
|
| 60 | + $boxorder = GETPOST('boxorder', 'aZ09'); |
|
| 61 | + $boxorder .= GETPOST('boxcombo', 'aZ09'); |
|
| 62 | 62 | |
| 63 | - $result=InfoBox::saveboxorder($db,$zone,$boxorder,$userid); |
|
| 63 | + $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); |
|
| 64 | 64 | if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -69,26 +69,26 @@ discard block |
||
| 69 | 69 | * View |
| 70 | 70 | */ |
| 71 | 71 | |
| 72 | -if (! is_object($form)) $form=new Form($db); |
|
| 72 | +if (!is_object($form)) $form = new Form($db); |
|
| 73 | 73 | |
| 74 | 74 | // Title |
| 75 | -$title=$langs->trans("HomeArea").' - Dolibarr '.DOL_VERSION; |
|
| 76 | -if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$langs->trans("HomeArea").' - '.$conf->global->MAIN_APPLICATION_TITLE; |
|
| 75 | +$title = $langs->trans("HomeArea").' - Dolibarr '.DOL_VERSION; |
|
| 76 | +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = $langs->trans("HomeArea").' - '.$conf->global->MAIN_APPLICATION_TITLE; |
|
| 77 | 77 | |
| 78 | -llxHeader('',$title); |
|
| 78 | +llxHeader('', $title); |
|
| 79 | 79 | |
| 80 | 80 | |
| 81 | -$resultboxes=FormOther::getBoxesArea($user,"0"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) |
|
| 81 | +$resultboxes = FormOther::getBoxesArea($user, "0"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) |
|
| 82 | 82 | |
| 83 | 83 | |
| 84 | -print load_fiche_titre($langs->trans("HomeArea"),$resultboxes['selectboxlist'],'title_home'); |
|
| 84 | +print load_fiche_titre($langs->trans("HomeArea"), $resultboxes['selectboxlist'], 'title_home'); |
|
| 85 | 85 | |
| 86 | -if (! empty($conf->global->MAIN_MOTD)) |
|
| 86 | +if (!empty($conf->global->MAIN_MOTD)) |
|
| 87 | 87 | { |
| 88 | - $conf->global->MAIN_MOTD=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i','<br>',$conf->global->MAIN_MOTD); |
|
| 89 | - if (! empty($conf->global->MAIN_MOTD)) |
|
| 88 | + $conf->global->MAIN_MOTD = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $conf->global->MAIN_MOTD); |
|
| 89 | + if (!empty($conf->global->MAIN_MOTD)) |
|
| 90 | 90 | { |
| 91 | - $substitutionarray=getCommonSubstitutionArray($langs); |
|
| 91 | + $substitutionarray = getCommonSubstitutionArray($langs); |
|
| 92 | 92 | complete_substitutions_array($substitutionarray, $langs); |
| 93 | 93 | $texttoshow = make_substitutions($conf->global->MAIN_MOTD, $substitutionarray, $langs); |
| 94 | 94 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * Dashboard Dolibarr states (statistics) |
| 109 | 109 | * Hidden for external users |
| 110 | 110 | */ |
| 111 | -$boxstat=''; |
|
| 111 | +$boxstat = ''; |
|
| 112 | 112 | |
| 113 | 113 | $langs->load("commercial"); |
| 114 | 114 | $langs->load("bills"); |
@@ -117,47 +117,47 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | if (empty($user->societe_id)) |
| 119 | 119 | { |
| 120 | - $boxstat.='<div class="box">'; |
|
| 121 | - $boxstat.='<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable" width="100%">'; |
|
| 122 | - $boxstat.='<tr class="liste_titre">'; |
|
| 123 | - $boxstat.='<th class="liste_titre">'.$langs->trans("DolibarrStateBoard").'</th>'; |
|
| 124 | - $boxstat.='</tr>'; |
|
| 125 | - $boxstat.='<tr class="impair"><td class="tdboxstats nohover flexcontainer">'; |
|
| 120 | + $boxstat .= '<div class="box">'; |
|
| 121 | + $boxstat .= '<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable" width="100%">'; |
|
| 122 | + $boxstat .= '<tr class="liste_titre">'; |
|
| 123 | + $boxstat .= '<th class="liste_titre">'.$langs->trans("DolibarrStateBoard").'</th>'; |
|
| 124 | + $boxstat .= '</tr>'; |
|
| 125 | + $boxstat .= '<tr class="impair"><td class="tdboxstats nohover flexcontainer">'; |
|
| 126 | 126 | |
| 127 | - $var=true; |
|
| 127 | + $var = true; |
|
| 128 | 128 | |
| 129 | - $object=new stdClass(); |
|
| 130 | - $parameters=array(); |
|
| 131 | - $action=''; |
|
| 132 | - $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 133 | - $boxstat.=$hookmanager->resPrint; |
|
| 129 | + $object = new stdClass(); |
|
| 130 | + $parameters = array(); |
|
| 131 | + $action = ''; |
|
| 132 | + $reshook = $hookmanager->executeHooks('addStatisticLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
| 133 | + $boxstat .= $hookmanager->resPrint; |
|
| 134 | 134 | |
| 135 | 135 | if (empty($reshook)) |
| 136 | 136 | { |
| 137 | 137 | // Condition to be checked for each display line dashboard |
| 138 | - $conditions=array( |
|
| 138 | + $conditions = array( |
|
| 139 | 139 | $user->rights->user->user->lire, |
| 140 | - ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS), |
|
| 141 | - ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS), |
|
| 142 | - ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS), |
|
| 143 | - ! empty($conf->societe->enabled) && $user->rights->societe->contact->lire, |
|
| 144 | - ! empty($conf->adherent->enabled) && $user->rights->adherent->lire, |
|
| 145 | - ! empty($conf->product->enabled) && $user->rights->produit->lire, |
|
| 146 | - ! empty($conf->service->enabled) && $user->rights->service->lire, |
|
| 147 | - ! empty($conf->propal->enabled) && $user->rights->propale->lire, |
|
| 148 | - ! empty($conf->commande->enabled) && $user->rights->commande->lire, |
|
| 149 | - ! empty($conf->facture->enabled) && $user->rights->facture->lire, |
|
| 150 | - ! empty($conf->contrat->enabled) && $user->rights->contrat->lire, |
|
| 151 | - ! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire, |
|
| 152 | - ! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS), |
|
| 153 | - ! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS), |
|
| 154 | - ! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS), |
|
| 155 | - ! empty($conf->projet->enabled) && $user->rights->projet->lire, |
|
| 156 | - ! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire, |
|
| 157 | - ! empty($conf->don->enabled) && $user->rights->don->lire |
|
| 140 | + !empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS), |
|
| 141 | + !empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS), |
|
| 142 | + !empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS), |
|
| 143 | + !empty($conf->societe->enabled) && $user->rights->societe->contact->lire, |
|
| 144 | + !empty($conf->adherent->enabled) && $user->rights->adherent->lire, |
|
| 145 | + !empty($conf->product->enabled) && $user->rights->produit->lire, |
|
| 146 | + !empty($conf->service->enabled) && $user->rights->service->lire, |
|
| 147 | + !empty($conf->propal->enabled) && $user->rights->propale->lire, |
|
| 148 | + !empty($conf->commande->enabled) && $user->rights->commande->lire, |
|
| 149 | + !empty($conf->facture->enabled) && $user->rights->facture->lire, |
|
| 150 | + !empty($conf->contrat->enabled) && $user->rights->contrat->lire, |
|
| 151 | + !empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire, |
|
| 152 | + !empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS), |
|
| 153 | + !empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS), |
|
| 154 | + !empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS), |
|
| 155 | + !empty($conf->projet->enabled) && $user->rights->projet->lire, |
|
| 156 | + !empty($conf->expensereport->enabled) && $user->rights->expensereport->lire, |
|
| 157 | + !empty($conf->don->enabled) && $user->rights->don->lire |
|
| 158 | 158 | ); |
| 159 | 159 | // Class file containing the method load_state_board for each line |
| 160 | - $includes=array( |
|
| 160 | + $includes = array( |
|
| 161 | 161 | DOL_DOCUMENT_ROOT."/user/class/user.class.php", |
| 162 | 162 | DOL_DOCUMENT_ROOT."/societe/class/client.class.php", |
| 163 | 163 | DOL_DOCUMENT_ROOT."/societe/class/client.class.php", |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | DOL_DOCUMENT_ROOT."/don/class/don.class.php" |
| 180 | 180 | ); |
| 181 | 181 | // Name class containing the method load_state_board for each line |
| 182 | - $classes=array('User', |
|
| 182 | + $classes = array('User', |
|
| 183 | 183 | 'Client', |
| 184 | 184 | 'Client', |
| 185 | 185 | 'Fournisseur', |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | 'Don' |
| 201 | 201 | ); |
| 202 | 202 | // Cle array returned by the method load_state_board for each line |
| 203 | - $keys=array('users', |
|
| 203 | + $keys = array('users', |
|
| 204 | 204 | 'customers', |
| 205 | 205 | 'prospects', |
| 206 | 206 | 'suppliers', |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | 'donations' |
| 222 | 222 | ); |
| 223 | 223 | // Dashboard Icon lines |
| 224 | - $icons=array('user', |
|
| 224 | + $icons = array('user', |
|
| 225 | 225 | 'company', |
| 226 | 226 | 'company', |
| 227 | 227 | 'company', |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | 'generic' |
| 243 | 243 | ); |
| 244 | 244 | // Translation keyword |
| 245 | - $titres=array("Users", |
|
| 245 | + $titres = array("Users", |
|
| 246 | 246 | "ThirdPartyCustomersStats", |
| 247 | 247 | "ThirdPartyProspectsStats", |
| 248 | 248 | "Suppliers", |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | "Donations" |
| 264 | 264 | ); |
| 265 | 265 | // Dashboard Link lines |
| 266 | - $links=array( |
|
| 266 | + $links = array( |
|
| 267 | 267 | DOL_URL_ROOT.'/user/index.php', |
| 268 | 268 | DOL_URL_ROOT.'/societe/list.php?type=c', |
| 269 | 269 | DOL_URL_ROOT.'/societe/list.php?type=p', |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | DOL_URL_ROOT.'/don/list.php?leftmenu=donations' |
| 286 | 286 | ); |
| 287 | 287 | // Translation lang files |
| 288 | - $langfile=array("users", |
|
| 288 | + $langfile = array("users", |
|
| 289 | 289 | "companies", |
| 290 | 290 | "prospects", |
| 291 | 291 | "suppliers", |
@@ -312,46 +312,46 @@ discard block |
||
| 312 | 312 | { |
| 313 | 313 | if ($conditions[$key]) |
| 314 | 314 | { |
| 315 | - $classe=$classes[$key]; |
|
| 315 | + $classe = $classes[$key]; |
|
| 316 | 316 | // Search in cache if load_state_board is already realized |
| 317 | - if (! isset($boardloaded[$classe]) || ! is_object($boardloaded[$classe])) |
|
| 317 | + if (!isset($boardloaded[$classe]) || !is_object($boardloaded[$classe])) |
|
| 318 | 318 | { |
| 319 | - include_once $includes[$key]; // Loading a class cost around 1Mb |
|
| 319 | + include_once $includes[$key]; // Loading a class cost around 1Mb |
|
| 320 | 320 | |
| 321 | - $board=new $classe($db); |
|
| 321 | + $board = new $classe($db); |
|
| 322 | 322 | $board->load_state_board($user); |
| 323 | - $boardloaded[$classe]=$board; |
|
| 323 | + $boardloaded[$classe] = $board; |
|
| 324 | 324 | } |
| 325 | 325 | else |
| 326 | 326 | { |
| 327 | - $board=$boardloaded[$classe]; |
|
| 327 | + $board = $boardloaded[$classe]; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | |
| 331 | 331 | if (!empty($langfile[$key])) $langs->load($langfile[$key]); |
| 332 | - $text=$langs->trans($titres[$key]); |
|
| 333 | - $boxstat.='<a href="'.$links[$key].'" class="boxstatsindicator thumbstat nobold nounderline">'; |
|
| 334 | - $boxstat.='<div class="boxstats">'; |
|
| 335 | - $boxstat.='<span class="boxstatstext" title="'.dol_escape_htmltag($text).'">'.img_object("",$icons[$key]).' '.$text.'</span><br>'; |
|
| 336 | - $boxstat.='<span class="boxstatsindicator">'.($board->nb[$val]?$board->nb[$val]:0).'</span>'; |
|
| 337 | - $boxstat.='</div>'; |
|
| 338 | - $boxstat.='</a>'; |
|
| 332 | + $text = $langs->trans($titres[$key]); |
|
| 333 | + $boxstat .= '<a href="'.$links[$key].'" class="boxstatsindicator thumbstat nobold nounderline">'; |
|
| 334 | + $boxstat .= '<div class="boxstats">'; |
|
| 335 | + $boxstat .= '<span class="boxstatstext" title="'.dol_escape_htmltag($text).'">'.img_object("", $icons[$key]).' '.$text.'</span><br>'; |
|
| 336 | + $boxstat .= '<span class="boxstatsindicator">'.($board->nb[$val] ? $board->nb[$val] : 0).'</span>'; |
|
| 337 | + $boxstat .= '</div>'; |
|
| 338 | + $boxstat .= '</a>'; |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 344 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 345 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 346 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 347 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 348 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 349 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 350 | - $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 351 | - |
|
| 352 | - $boxstat.='</td></tr>'; |
|
| 353 | - $boxstat.='</table>'; |
|
| 354 | - $boxstat.='</div>'; |
|
| 343 | + $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 344 | + $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 345 | + $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 346 | + $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 347 | + $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 348 | + $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 349 | + $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 350 | + $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"></a>'; |
|
| 351 | + |
|
| 352 | + $boxstat .= '</td></tr>'; |
|
| 353 | + $boxstat .= '</table>'; |
|
| 354 | + $boxstat .= '</div>'; |
|
| 355 | 355 | } |
| 356 | 356 | //print $boxstat; |
| 357 | 357 | |
@@ -361,106 +361,106 @@ discard block |
||
| 361 | 361 | /* |
| 362 | 362 | * Dolibarr Working Board with weather |
| 363 | 363 | */ |
| 364 | -$showweather=empty($conf->global->MAIN_DISABLE_METEO)?1:0; |
|
| 364 | +$showweather = empty($conf->global->MAIN_DISABLE_METEO) ? 1 : 0; |
|
| 365 | 365 | |
| 366 | 366 | //Array that contains all WorkboardResponse classes to process them |
| 367 | -$dashboardlines=array(); |
|
| 367 | +$dashboardlines = array(); |
|
| 368 | 368 | |
| 369 | 369 | // Do not include sections without management permission |
| 370 | 370 | require DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php'; |
| 371 | 371 | |
| 372 | 372 | // Number of actions to do (late) |
| 373 | -if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) |
|
| 373 | +if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) |
|
| 374 | 374 | { |
| 375 | 375 | include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
| 376 | - $board=new ActionComm($db); |
|
| 376 | + $board = new ActionComm($db); |
|
| 377 | 377 | |
| 378 | 378 | $dashboardlines[] = $board->load_board($user); |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | // Number of project opened |
| 382 | -if (! empty($conf->projet->enabled) && $user->rights->projet->lire) |
|
| 382 | +if (!empty($conf->projet->enabled) && $user->rights->projet->lire) |
|
| 383 | 383 | { |
| 384 | 384 | include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 385 | - $board=new Project($db); |
|
| 385 | + $board = new Project($db); |
|
| 386 | 386 | $dashboardlines[] = $board->load_board($user); |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | // Number of tasks to do (late) |
| 390 | -if (! empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->rights->projet->lire) |
|
| 390 | +if (!empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->rights->projet->lire) |
|
| 391 | 391 | { |
| 392 | 392 | include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
| 393 | - $board=new Task($db); |
|
| 393 | + $board = new Task($db); |
|
| 394 | 394 | $dashboardlines[] = $board->load_board($user); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | // Number of commercial proposals opened (expired) |
| 398 | -if (! empty($conf->propal->enabled) && $user->rights->propale->lire) |
|
| 398 | +if (!empty($conf->propal->enabled) && $user->rights->propale->lire) |
|
| 399 | 399 | { |
| 400 | 400 | include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
| 401 | - $board=new Propal($db); |
|
| 402 | - $dashboardlines[] = $board->load_board($user,"opened"); |
|
| 401 | + $board = new Propal($db); |
|
| 402 | + $dashboardlines[] = $board->load_board($user, "opened"); |
|
| 403 | 403 | // Number of commercial proposals CLOSED signed (billed) |
| 404 | - $dashboardlines[] = $board->load_board($user,"signed"); |
|
| 404 | + $dashboardlines[] = $board->load_board($user, "signed"); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | // Number of commercial proposals opened (expired) |
| 408 | -if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) |
|
| 408 | +if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) |
|
| 409 | 409 | { |
| 410 | 410 | include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; |
| 411 | - $board=new SupplierProposal($db); |
|
| 412 | - $dashboardlines[] = $board->load_board($user,"opened"); |
|
| 411 | + $board = new SupplierProposal($db); |
|
| 412 | + $dashboardlines[] = $board->load_board($user, "opened"); |
|
| 413 | 413 | // Number of commercial proposals CLOSED signed (billed) |
| 414 | - $dashboardlines[] = $board->load_board($user,"signed"); |
|
| 414 | + $dashboardlines[] = $board->load_board($user, "signed"); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | // Number of customer orders a deal |
| 418 | -if (! empty($conf->commande->enabled) && $user->rights->commande->lire) |
|
| 418 | +if (!empty($conf->commande->enabled) && $user->rights->commande->lire) |
|
| 419 | 419 | { |
| 420 | 420 | include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
| 421 | - $board=new Commande($db); |
|
| 421 | + $board = new Commande($db); |
|
| 422 | 422 | $dashboardlines[] = $board->load_board($user); |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Number of suppliers orders a deal |
| 426 | -if (! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire) |
|
| 426 | +if (!empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire) |
|
| 427 | 427 | { |
| 428 | 428 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
| 429 | - $board=new CommandeFournisseur($db); |
|
| 429 | + $board = new CommandeFournisseur($db); |
|
| 430 | 430 | $dashboardlines[] = $board->load_board($user); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | // Number of services enabled (delayed) |
| 434 | -if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) |
|
| 434 | +if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) |
|
| 435 | 435 | { |
| 436 | 436 | include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
| 437 | - $board=new Contrat($db); |
|
| 438 | - $dashboardlines[] = $board->load_board($user,"inactives"); |
|
| 437 | + $board = new Contrat($db); |
|
| 438 | + $dashboardlines[] = $board->load_board($user, "inactives"); |
|
| 439 | 439 | // Number of active services (expired) |
| 440 | - $dashboardlines[] = $board->load_board($user,"expired"); |
|
| 440 | + $dashboardlines[] = $board->load_board($user, "expired"); |
|
| 441 | 441 | } |
| 442 | 442 | // Number of invoices customers (has paid) |
| 443 | -if (! empty($conf->facture->enabled) && $user->rights->facture->lire) |
|
| 443 | +if (!empty($conf->facture->enabled) && $user->rights->facture->lire) |
|
| 444 | 444 | { |
| 445 | 445 | include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
| 446 | - $board=new Facture($db); |
|
| 446 | + $board = new Facture($db); |
|
| 447 | 447 | $dashboardlines[] = $board->load_board($user); |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | // Number of supplier invoices (has paid) |
| 451 | -if (! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire) |
|
| 451 | +if (!empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire) |
|
| 452 | 452 | { |
| 453 | 453 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
| 454 | - $board=new FactureFournisseur($db); |
|
| 454 | + $board = new FactureFournisseur($db); |
|
| 455 | 455 | $dashboardlines[] = $board->load_board($user); |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | // Number of transactions to conciliate |
| 459 | -if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id) |
|
| 459 | +if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->societe_id) |
|
| 460 | 460 | { |
| 461 | 461 | include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
| 462 | - $board=new Account($db); |
|
| 463 | - $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate |
|
| 462 | + $board = new Account($db); |
|
| 463 | + $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate |
|
| 464 | 464 | if ($nb > 0) |
| 465 | 465 | { |
| 466 | 466 | $dashboardlines[] = $board->load_board($user); |
@@ -468,51 +468,51 @@ discard block |
||
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | // Number of cheque to send |
| 471 | -if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) |
|
| 471 | +if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->societe_id && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) |
|
| 472 | 472 | { |
| 473 | 473 | include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; |
| 474 | - $board=new RemiseCheque($db); |
|
| 474 | + $board = new RemiseCheque($db); |
|
| 475 | 475 | $dashboardlines[] = $board->load_board($user); |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | // Number of foundation members |
| 479 | -if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire && ! $user->societe_id) |
|
| 479 | +if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire && !$user->societe_id) |
|
| 480 | 480 | { |
| 481 | 481 | include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
| 482 | - $board=new Adherent($db); |
|
| 482 | + $board = new Adherent($db); |
|
| 483 | 483 | $dashboardlines[] = $board->load_board($user); |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | // Number of expense reports to approve |
| 487 | -if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) |
|
| 487 | +if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) |
|
| 488 | 488 | { |
| 489 | 489 | include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; |
| 490 | - $board=new ExpenseReport($db); |
|
| 491 | - $dashboardlines[] = $board->load_board($user,'toapprove'); |
|
| 490 | + $board = new ExpenseReport($db); |
|
| 491 | + $dashboardlines[] = $board->load_board($user, 'toapprove'); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | // Number of expense reports to pay |
| 495 | -if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) |
|
| 495 | +if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) |
|
| 496 | 496 | { |
| 497 | 497 | include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; |
| 498 | - $board=new ExpenseReport($db); |
|
| 499 | - $dashboardlines[] = $board->load_board($user,'topay'); |
|
| 498 | + $board = new ExpenseReport($db); |
|
| 499 | + $dashboardlines[] = $board->load_board($user, 'topay'); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | // Calculate total nb of late |
| 503 | -$totallate=0; |
|
| 504 | -$var=true; |
|
| 503 | +$totallate = 0; |
|
| 504 | +$var = true; |
|
| 505 | 505 | |
| 506 | 506 | //Remove any invalid response |
| 507 | 507 | //load_board can return an integer if failed or WorkboardResponse if OK |
| 508 | -$valid_dashboardlines=array(); |
|
| 509 | -foreach($dashboardlines as $tmp) |
|
| 508 | +$valid_dashboardlines = array(); |
|
| 509 | +foreach ($dashboardlines as $tmp) |
|
| 510 | 510 | { |
| 511 | 511 | if ($tmp instanceof WorkboardResponse) $valid_dashboardlines[] = $tmp; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | // We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop |
| 515 | -foreach($valid_dashboardlines as $board) |
|
| 515 | +foreach ($valid_dashboardlines as $board) |
|
| 516 | 516 | { |
| 517 | 517 | if ($board->nbtodolate > 0) { |
| 518 | 518 | $totallate += $board->nbtodolate; |
@@ -520,81 +520,81 @@ discard block |
||
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | |
| 523 | -$boxwork=''; |
|
| 524 | -$boxwork.='<div class="box">'; |
|
| 525 | -$boxwork.='<table summary="'.dol_escape_htmltag($langs->trans("WorkingBoard")).'" class="noborder boxtable" width="100%">'."\n"; |
|
| 526 | -$boxwork.='<tr class="liste_titre">'; |
|
| 527 | -$boxwork.='<th class="liste_titre">'.$langs->trans("DolibarrWorkBoard").'</th>'; |
|
| 528 | -$boxwork.='</tr>'."\n"; |
|
| 523 | +$boxwork = ''; |
|
| 524 | +$boxwork .= '<div class="box">'; |
|
| 525 | +$boxwork .= '<table summary="'.dol_escape_htmltag($langs->trans("WorkingBoard")).'" class="noborder boxtable" width="100%">'."\n"; |
|
| 526 | +$boxwork .= '<tr class="liste_titre">'; |
|
| 527 | +$boxwork .= '<th class="liste_titre">'.$langs->trans("DolibarrWorkBoard").'</th>'; |
|
| 528 | +$boxwork .= '</tr>'."\n"; |
|
| 529 | 529 | |
| 530 | 530 | if ($showweather) |
| 531 | 531 | { |
| 532 | - $boxwork.='<tr class="nohover">'; |
|
| 533 | - $boxwork.='<td class="nohover hideonsmartphone center valignmiddle">'; |
|
| 534 | - $text=''; |
|
| 535 | - if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate).')'; |
|
| 536 | - $text.='. '.$langs->trans("LateDesc"); |
|
| 532 | + $boxwork .= '<tr class="nohover">'; |
|
| 533 | + $boxwork .= '<td class="nohover hideonsmartphone center valignmiddle">'; |
|
| 534 | + $text = ''; |
|
| 535 | + if ($totallate > 0) $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate", $totallate).')'; |
|
| 536 | + $text .= '. '.$langs->trans("LateDesc"); |
|
| 537 | 537 | //$text.=$form->textwithpicto('',$langs->trans("LateDesc")); |
| 538 | - $options='height="64px"'; |
|
| 539 | - $boxwork.=showWeather($totallate,$text,$options); |
|
| 540 | - $boxwork.='</td>'; |
|
| 541 | - $boxwork.='</tr>'; |
|
| 538 | + $options = 'height="64px"'; |
|
| 539 | + $boxwork .= showWeather($totallate, $text, $options); |
|
| 540 | + $boxwork .= '</td>'; |
|
| 541 | + $boxwork .= '</tr>'; |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | -$boxwork.='<tr class="nohover"><td class="tdboxstats nohover flexcontainer">'; |
|
| 544 | +$boxwork .= '<tr class="nohover"><td class="tdboxstats nohover flexcontainer">'; |
|
| 545 | 545 | |
| 546 | 546 | // Show dashboard |
| 547 | -$nbworkboardempty=0; |
|
| 548 | -if (! empty($valid_dashboardlines)) |
|
| 547 | +$nbworkboardempty = 0; |
|
| 548 | +if (!empty($valid_dashboardlines)) |
|
| 549 | 549 | { |
| 550 | - foreach($valid_dashboardlines as $board) |
|
| 550 | + foreach ($valid_dashboardlines as $board) |
|
| 551 | 551 | { |
| 552 | 552 | if (empty($boad->nbtodo)) $nbworkboardempty++; |
| 553 | 553 | |
| 554 | - $textlate = $langs->trans("NActionsLate",$board->nbtodolate); |
|
| 555 | - $textlate.= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')'; |
|
| 554 | + $textlate = $langs->trans("NActionsLate", $board->nbtodolate); |
|
| 555 | + $textlate .= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')'; |
|
| 556 | 556 | |
| 557 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats130 boxstatsborder">'; |
|
| 557 | + $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats130 boxstatsborder">'; |
|
| 558 | 558 | $boxwork .= '<div class="boxstatscontent">'; |
| 559 | 559 | $boxwork .= '<span class="boxstatstext" title="'.dol_escape_htmltag($board->label).'">'.$board->img.' '.$board->label.'</span><br>'; |
| 560 | - $boxwork .= '<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0)?' dashboardlineok':'').'">'.$board->nbtodo.'</span></a>'; |
|
| 560 | + $boxwork .= '<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0) ? ' dashboardlineok' : '').'">'.$board->nbtodo.'</span></a>'; |
|
| 561 | 561 | $boxwork .= '</div>'; |
| 562 | 562 | if ($board->nbtodolate > 0) |
| 563 | 563 | { |
| 564 | 564 | $boxwork .= '<div class="dashboardlinelatecoin nowrap">'; |
| 565 | - $boxwork .= '<a title="'.dol_escape_htmltag($textlate).'" class="valignmiddle dashboardlineindicatorlate'.($board->nbtodolate>0?' dashboardlineko':' dashboardlineok').'" href="'.((!$board->url_late) ? $board->url : $board->url_late ).'">'; |
|
| 565 | + $boxwork .= '<a title="'.dol_escape_htmltag($textlate).'" class="valignmiddle dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'" href="'.((!$board->url_late) ? $board->url : $board->url_late).'">'; |
|
| 566 | 566 | //$boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').''; |
| 567 | 567 | $boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').''; |
| 568 | - $boxwork .= '<span class="dashboardlineindicatorlate'.($board->nbtodolate>0?' dashboardlineko':' dashboardlineok').'">'; |
|
| 568 | + $boxwork .= '<span class="dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'">'; |
|
| 569 | 569 | $boxwork .= $board->nbtodolate; |
| 570 | 570 | $boxwork .= '</span>'; |
| 571 | 571 | $boxwork .= '</a>'; |
| 572 | 572 | $boxwork .= '</div>'; |
| 573 | 573 | } |
| 574 | - $boxwork.='</div></div>'; |
|
| 575 | - $boxwork .="\n"; |
|
| 574 | + $boxwork .= '</div></div>'; |
|
| 575 | + $boxwork .= "\n"; |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 579 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 580 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 581 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 582 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 583 | - $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 578 | + $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 579 | + $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 580 | + $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 581 | + $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 582 | + $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 583 | + $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"></div>'; |
|
| 584 | 584 | } |
| 585 | 585 | else |
| 586 | 586 | { |
| 587 | - $boxwork.='<tr class="nohover">'; |
|
| 588 | - $boxwork.='<td colspan="4" class="nohover valignmiddle opacitymedium">'; |
|
| 589 | - $boxwork.=$langs->trans("NoOpenedElementToProcess"); |
|
| 590 | - $boxwork.='</td>'; |
|
| 591 | - $boxwork.='</tr>'; |
|
| 587 | + $boxwork .= '<tr class="nohover">'; |
|
| 588 | + $boxwork .= '<td colspan="4" class="nohover valignmiddle opacitymedium">'; |
|
| 589 | + $boxwork .= $langs->trans("NoOpenedElementToProcess"); |
|
| 590 | + $boxwork .= '</td>'; |
|
| 591 | + $boxwork .= '</tr>'; |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | -$boxwork.='</td></tr>'; |
|
| 594 | +$boxwork .= '</td></tr>'; |
|
| 595 | 595 | |
| 596 | -$boxwork.='</table>'; // End table array of working board |
|
| 597 | -$boxwork.='</div>'; |
|
| 596 | +$boxwork .= '</table>'; // End table array of working board |
|
| 597 | +$boxwork .= '</div>'; |
|
| 598 | 598 | |
| 599 | 599 | print '</div></div></div><div class="clearboth"></div>'; |
| 600 | 600 | |
@@ -605,25 +605,25 @@ discard block |
||
| 605 | 605 | * Show boxes |
| 606 | 606 | */ |
| 607 | 607 | |
| 608 | -$boxlist.='<table width="100%" class="notopnoleftnoright">'; |
|
| 609 | -$boxlist.='<tr><td class="notopnoleftnoright">'."\n"; |
|
| 608 | +$boxlist .= '<table width="100%" class="notopnoleftnoright">'; |
|
| 609 | +$boxlist .= '<tr><td class="notopnoleftnoright">'."\n"; |
|
| 610 | 610 | |
| 611 | -$boxlist.='<div class="fichehalfleft">'; |
|
| 611 | +$boxlist .= '<div class="fichehalfleft">'; |
|
| 612 | 612 | |
| 613 | 613 | //$boxlist.=$boxinfo; |
| 614 | -$boxlist.=$boxstat; |
|
| 615 | -$boxlist.=$resultboxes['boxlista']; |
|
| 614 | +$boxlist .= $boxstat; |
|
| 615 | +$boxlist .= $resultboxes['boxlista']; |
|
| 616 | 616 | |
| 617 | -$boxlist.= '</div><div class="fichehalfright"><div class="ficheaddleft">'; |
|
| 617 | +$boxlist .= '</div><div class="fichehalfright"><div class="ficheaddleft">'; |
|
| 618 | 618 | |
| 619 | -$boxlist.=$boxwork; |
|
| 620 | -$boxlist.=$resultboxes['boxlistb']; |
|
| 619 | +$boxlist .= $boxwork; |
|
| 620 | +$boxlist .= $resultboxes['boxlistb']; |
|
| 621 | 621 | |
| 622 | -$boxlist.= '</div></div>'; |
|
| 623 | -$boxlist.= "\n"; |
|
| 622 | +$boxlist .= '</div></div>'; |
|
| 623 | +$boxlist .= "\n"; |
|
| 624 | 624 | |
| 625 | -$boxlist.= "</td></tr>"; |
|
| 626 | -$boxlist.= "</table>"; |
|
| 625 | +$boxlist .= "</td></tr>"; |
|
| 626 | +$boxlist .= "</table>"; |
|
| 627 | 627 | |
| 628 | 628 | print $boxlist; |
| 629 | 629 | |
@@ -637,15 +637,15 @@ discard block |
||
| 637 | 637 | // Security warning repertoire install existe (si utilisateur admin) |
| 638 | 638 | if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) |
| 639 | 639 | { |
| 640 | - $message=''; |
|
| 640 | + $message = ''; |
|
| 641 | 641 | |
| 642 | 642 | // Check if install lock file is present |
| 643 | - $lockfile=DOL_DATA_ROOT.'/install.lock'; |
|
| 644 | - if (! empty($lockfile) && ! file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install")) |
|
| 643 | + $lockfile = DOL_DATA_ROOT.'/install.lock'; |
|
| 644 | + if (!empty($lockfile) && !file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install")) |
|
| 645 | 645 | { |
| 646 | 646 | $langs->load("errors"); |
| 647 | 647 | //if (! empty($message)) $message.='<br>'; |
| 648 | - $message.=info_admin($langs->trans("WarningLockFileDoesNotExists",DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); |
|
| 648 | + $message .= info_admin($langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install")); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | // Conf files must be in read only mode |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | $langs->load("errors"); |
| 655 | 655 | //$langs->load("other"); |
| 656 | 656 | //if (! empty($message)) $message.='<br>'; |
| 657 | - $message.=info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); |
|
| 657 | + $message .= info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install")); |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | if ($message) |
@@ -681,23 +681,23 @@ discard block |
||
| 681 | 681 | * @param string $options More parameters on img tag |
| 682 | 682 | * @return string Return img tag of weather |
| 683 | 683 | */ |
| 684 | -function showWeather($totallate,$text,$options) |
|
| 684 | +function showWeather($totallate, $text, $options) |
|
| 685 | 685 | { |
| 686 | 686 | global $conf; |
| 687 | 687 | |
| 688 | - $out=''; |
|
| 689 | - $offset=0; |
|
| 690 | - $factor=10; // By default |
|
| 688 | + $out = ''; |
|
| 689 | + $offset = 0; |
|
| 690 | + $factor = 10; // By default |
|
| 691 | 691 | |
| 692 | - $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0; |
|
| 693 | - $level1=$offset+1*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1; |
|
| 694 | - $level2=$offset+2*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2; |
|
| 695 | - $level3=$offset+3*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3; |
|
| 692 | + $level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) $level0 = $conf->global->MAIN_METEO_LEVEL0; |
|
| 693 | + $level1 = $offset + 1 * $factor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) $level1 = $conf->global->MAIN_METEO_LEVEL1; |
|
| 694 | + $level2 = $offset + 2 * $factor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) $level2 = $conf->global->MAIN_METEO_LEVEL2; |
|
| 695 | + $level3 = $offset + 3 * $factor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) $level3 = $conf->global->MAIN_METEO_LEVEL3; |
|
| 696 | 696 | |
| 697 | - if ($totallate <= $level0) $out.=img_weather($text,'weather-clear.png',$options); |
|
| 698 | - if ($totallate > $level0 && $totallate <= $level1) $out.=img_weather($text,'weather-few-clouds.png',$options); |
|
| 699 | - if ($totallate > $level1 && $totallate <= $level2) $out.=img_weather($text,'weather-clouds.png',$options); |
|
| 700 | - if ($totallate > $level2 && $totallate <= $level3) $out.=img_weather($text,'weather-many-clouds.png',$options); |
|
| 701 | - if ($totallate > $level3) $out.=img_weather($text,'weather-storm.png',$options); |
|
| 697 | + if ($totallate <= $level0) $out .= img_weather($text, 'weather-clear.png', $options); |
|
| 698 | + if ($totallate > $level0 && $totallate <= $level1) $out .= img_weather($text, 'weather-few-clouds.png', $options); |
|
| 699 | + if ($totallate > $level1 && $totallate <= $level2) $out .= img_weather($text, 'weather-clouds.png', $options); |
|
| 700 | + if ($totallate > $level2 && $totallate <= $level3) $out .= img_weather($text, 'weather-many-clouds.png', $options); |
|
| 701 | + if ($totallate > $level3) $out .= img_weather($text, 'weather-storm.png', $options); |
|
| 702 | 702 | return $out; |
| 703 | 703 | } |
@@ -84,16 +84,16 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | if ($id > 0 || ! empty($ref)) |
| 86 | 86 | { |
| 87 | - $result = $object->fetch($id, $ref); |
|
| 87 | + $result = $object->fetch($id, $ref); |
|
| 88 | 88 | |
| 89 | - if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); |
|
| 90 | - elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); |
|
| 89 | + if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); |
|
| 90 | + elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); |
|
| 91 | 91 | |
| 92 | - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs |
|
| 93 | - { |
|
| 94 | - if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; |
|
| 95 | - else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; |
|
| 96 | - } |
|
| 92 | + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs |
|
| 93 | + { |
|
| 94 | + if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; |
|
| 95 | + else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; |
|
| 96 | + } |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $modulepart='product'; |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | $objcanvas=null; |
| 104 | 104 | if (! empty($canvas)) |
| 105 | 105 | { |
| 106 | - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; |
|
| 107 | - $objcanvas = new Canvas($db,$action); |
|
| 108 | - $objcanvas->getCanvas('product','card',$canvas); |
|
| 106 | + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; |
|
| 107 | + $objcanvas = new Canvas($db,$action); |
|
| 108 | + $objcanvas->getCanvas('product','card',$canvas); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // Security check |
@@ -133,177 +133,177 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | if (empty($reshook)) |
| 135 | 135 | { |
| 136 | - // Type |
|
| 137 | - if ($action == 'setfk_product_type' && $user->rights->produit->creer) |
|
| 138 | - { |
|
| 139 | - $result = $object->setValueFrom('fk_product_type', GETPOST('fk_product_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); |
|
| 140 | - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
|
| 141 | - exit; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - // Actions to build doc |
|
| 145 | - $upload_dir = $conf->produit->dir_output; |
|
| 146 | - $permissioncreate = $user->rights->produit->creer; |
|
| 147 | - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; |
|
| 148 | - |
|
| 149 | - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; |
|
| 150 | - |
|
| 151 | - // Barcode type |
|
| 152 | - if ($action == 'setfk_barcode_type' && $createbarcode) |
|
| 153 | - { |
|
| 154 | - $result = $object->setValueFrom('fk_barcode_type', GETPOST('fk_barcode_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); |
|
| 155 | - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
|
| 156 | - exit; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - // Barcode value |
|
| 160 | - if ($action == 'setbarcode' && $createbarcode) |
|
| 161 | - { |
|
| 162 | - $result=$object->check_barcode(GETPOST('barcode'),GETPOST('barcode_type_code')); |
|
| 136 | + // Type |
|
| 137 | + if ($action == 'setfk_product_type' && $user->rights->produit->creer) |
|
| 138 | + { |
|
| 139 | + $result = $object->setValueFrom('fk_product_type', GETPOST('fk_product_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); |
|
| 140 | + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
|
| 141 | + exit; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + // Actions to build doc |
|
| 145 | + $upload_dir = $conf->produit->dir_output; |
|
| 146 | + $permissioncreate = $user->rights->produit->creer; |
|
| 147 | + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; |
|
| 148 | + |
|
| 149 | + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; |
|
| 150 | + |
|
| 151 | + // Barcode type |
|
| 152 | + if ($action == 'setfk_barcode_type' && $createbarcode) |
|
| 153 | + { |
|
| 154 | + $result = $object->setValueFrom('fk_barcode_type', GETPOST('fk_barcode_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); |
|
| 155 | + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
|
| 156 | + exit; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + // Barcode value |
|
| 160 | + if ($action == 'setbarcode' && $createbarcode) |
|
| 161 | + { |
|
| 162 | + $result=$object->check_barcode(GETPOST('barcode'),GETPOST('barcode_type_code')); |
|
| 163 | 163 | |
| 164 | 164 | if ($result >= 0) |
| 165 | 165 | { |
| 166 | - $result = $object->setValueFrom('barcode', GETPOST('barcode')); |
|
| 167 | - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
|
| 168 | - exit; |
|
| 166 | + $result = $object->setValueFrom('barcode', GETPOST('barcode')); |
|
| 167 | + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
|
| 168 | + exit; |
|
| 169 | 169 | } |
| 170 | 170 | else |
| 171 | 171 | { |
| 172 | 172 | $langs->load("errors"); |
| 173 | - if ($result == -1) $errors[] = 'ErrorBadBarCodeSyntax'; |
|
| 174 | - else if ($result == -2) $errors[] = 'ErrorBarCodeRequired'; |
|
| 175 | - else if ($result == -3) $errors[] = 'ErrorBarCodeAlreadyUsed'; |
|
| 176 | - else $errors[] = 'FailedToValidateBarCode'; |
|
| 173 | + if ($result == -1) $errors[] = 'ErrorBadBarCodeSyntax'; |
|
| 174 | + else if ($result == -2) $errors[] = 'ErrorBarCodeRequired'; |
|
| 175 | + else if ($result == -3) $errors[] = 'ErrorBarCodeAlreadyUsed'; |
|
| 176 | + else $errors[] = 'FailedToValidateBarCode'; |
|
| 177 | 177 | |
| 178 | 178 | $error++; |
| 179 | 179 | setEventMessages($errors, null, 'errors'); |
| 180 | 180 | } |
| 181 | - } |
|
| 182 | - |
|
| 183 | - // Add a product or service |
|
| 184 | - if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) |
|
| 185 | - { |
|
| 186 | - $error=0; |
|
| 187 | - |
|
| 188 | - if (! GETPOST('label')) |
|
| 189 | - { |
|
| 190 | - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')), null, 'errors'); |
|
| 191 | - $action = "create"; |
|
| 192 | - $error++; |
|
| 193 | - } |
|
| 194 | - if (empty($ref)) |
|
| 195 | - { |
|
| 196 | - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')), null, 'errors'); |
|
| 197 | - $action = "create"; |
|
| 198 | - $error++; |
|
| 199 | - } |
|
| 200 | - if (! empty($duration_value) && empty($duration_unit)) |
|
| 201 | - { |
|
| 202 | - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Unit')), null, 'errors'); |
|
| 203 | - $action = "create"; |
|
| 204 | - $error++; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - if (! $error) |
|
| 208 | - { |
|
| 209 | - $units = GETPOST('units', 'int'); |
|
| 210 | - |
|
| 211 | - $object->ref = $ref; |
|
| 212 | - $object->label = GETPOST('label'); |
|
| 213 | - $object->price_base_type = GETPOST('price_base_type'); |
|
| 214 | - |
|
| 215 | - if ($object->price_base_type == 'TTC') |
|
| 216 | - $object->price_ttc = GETPOST('price'); |
|
| 217 | - else |
|
| 218 | - $object->price = GETPOST('price'); |
|
| 219 | - if ($object->price_base_type == 'TTC') |
|
| 220 | - $object->price_min_ttc = GETPOST('price_min'); |
|
| 221 | - else |
|
| 222 | - $object->price_min = GETPOST('price_min'); |
|
| 223 | - |
|
| 224 | - $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' |
|
| 225 | - |
|
| 226 | - // We must define tva_tx, npr and local taxes |
|
| 227 | - $vatratecode = ''; |
|
| 228 | - $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot |
|
| 229 | - $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; |
|
| 230 | - $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; |
|
| 231 | - // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes |
|
| 232 | - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) |
|
| 233 | - { |
|
| 234 | - // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price. |
|
| 235 | - $vatratecode=$reg[1]; |
|
| 236 | - // Get record from code |
|
| 237 | - $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; |
|
| 238 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; |
|
| 239 | - $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; |
|
| 240 | - $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; |
|
| 241 | - $sql.= " AND t.code ='".$vatratecode."'"; |
|
| 242 | - $resql=$db->query($sql); |
|
| 243 | - if ($resql) |
|
| 244 | - { |
|
| 245 | - $obj = $db->fetch_object($resql); |
|
| 246 | - $npr = $obj->recuperableonly; |
|
| 247 | - $localtax1 = $obj->localtax1; |
|
| 248 | - $localtax2 = $obj->localtax2; |
|
| 249 | - $localtax1_type = $obj->localtax1_type; |
|
| 250 | - $localtax2_type = $obj->localtax2_type; |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - $object->default_vat_code = $vatratecode; |
|
| 255 | - $object->tva_tx = $tva_tx; |
|
| 256 | - $object->tva_npr = $npr; |
|
| 257 | - $object->localtax1_tx = $localtax1; |
|
| 258 | - $object->localtax2_tx = $localtax2; |
|
| 259 | - $object->localtax1_type = $localtax1_type; |
|
| 260 | - $object->localtax2_type = $localtax2_type; |
|
| 261 | - |
|
| 262 | - $object->type = $type; |
|
| 263 | - $object->status = GETPOST('statut'); |
|
| 264 | - $object->status_buy = GETPOST('statut_buy'); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + // Add a product or service |
|
| 184 | + if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) |
|
| 185 | + { |
|
| 186 | + $error=0; |
|
| 187 | + |
|
| 188 | + if (! GETPOST('label')) |
|
| 189 | + { |
|
| 190 | + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')), null, 'errors'); |
|
| 191 | + $action = "create"; |
|
| 192 | + $error++; |
|
| 193 | + } |
|
| 194 | + if (empty($ref)) |
|
| 195 | + { |
|
| 196 | + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')), null, 'errors'); |
|
| 197 | + $action = "create"; |
|
| 198 | + $error++; |
|
| 199 | + } |
|
| 200 | + if (! empty($duration_value) && empty($duration_unit)) |
|
| 201 | + { |
|
| 202 | + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Unit')), null, 'errors'); |
|
| 203 | + $action = "create"; |
|
| 204 | + $error++; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + if (! $error) |
|
| 208 | + { |
|
| 209 | + $units = GETPOST('units', 'int'); |
|
| 210 | + |
|
| 211 | + $object->ref = $ref; |
|
| 212 | + $object->label = GETPOST('label'); |
|
| 213 | + $object->price_base_type = GETPOST('price_base_type'); |
|
| 214 | + |
|
| 215 | + if ($object->price_base_type == 'TTC') |
|
| 216 | + $object->price_ttc = GETPOST('price'); |
|
| 217 | + else |
|
| 218 | + $object->price = GETPOST('price'); |
|
| 219 | + if ($object->price_base_type == 'TTC') |
|
| 220 | + $object->price_min_ttc = GETPOST('price_min'); |
|
| 221 | + else |
|
| 222 | + $object->price_min = GETPOST('price_min'); |
|
| 223 | + |
|
| 224 | + $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' |
|
| 225 | + |
|
| 226 | + // We must define tva_tx, npr and local taxes |
|
| 227 | + $vatratecode = ''; |
|
| 228 | + $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot |
|
| 229 | + $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; |
|
| 230 | + $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; |
|
| 231 | + // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes |
|
| 232 | + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) |
|
| 233 | + { |
|
| 234 | + // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price. |
|
| 235 | + $vatratecode=$reg[1]; |
|
| 236 | + // Get record from code |
|
| 237 | + $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; |
|
| 238 | + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; |
|
| 239 | + $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; |
|
| 240 | + $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; |
|
| 241 | + $sql.= " AND t.code ='".$vatratecode."'"; |
|
| 242 | + $resql=$db->query($sql); |
|
| 243 | + if ($resql) |
|
| 244 | + { |
|
| 245 | + $obj = $db->fetch_object($resql); |
|
| 246 | + $npr = $obj->recuperableonly; |
|
| 247 | + $localtax1 = $obj->localtax1; |
|
| 248 | + $localtax2 = $obj->localtax2; |
|
| 249 | + $localtax1_type = $obj->localtax1_type; |
|
| 250 | + $localtax2_type = $obj->localtax2_type; |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + $object->default_vat_code = $vatratecode; |
|
| 255 | + $object->tva_tx = $tva_tx; |
|
| 256 | + $object->tva_npr = $npr; |
|
| 257 | + $object->localtax1_tx = $localtax1; |
|
| 258 | + $object->localtax2_tx = $localtax2; |
|
| 259 | + $object->localtax1_type = $localtax1_type; |
|
| 260 | + $object->localtax2_type = $localtax2_type; |
|
| 261 | + |
|
| 262 | + $object->type = $type; |
|
| 263 | + $object->status = GETPOST('statut'); |
|
| 264 | + $object->status_buy = GETPOST('statut_buy'); |
|
| 265 | 265 | $object->status_batch = GETPOST('status_batch'); |
| 266 | 266 | |
| 267 | - $object->barcode_type = GETPOST('fk_barcode_type'); |
|
| 268 | - $object->barcode = GETPOST('barcode'); |
|
| 269 | - // Set barcode_type_xxx from barcode_type id |
|
| 270 | - $stdobject=new GenericObject($db); |
|
| 271 | - $stdobject->element='product'; |
|
| 272 | - $stdobject->barcode_type=GETPOST('fk_barcode_type'); |
|
| 273 | - $result=$stdobject->fetch_barcode(); |
|
| 274 | - if ($result < 0) |
|
| 275 | - { |
|
| 276 | - $error++; |
|
| 277 | - $mesg='Failed to get bar code type information '; |
|
| 278 | - setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); |
|
| 279 | - } |
|
| 280 | - $object->barcode_type_code = $stdobject->barcode_type_code; |
|
| 281 | - $object->barcode_type_coder = $stdobject->barcode_type_coder; |
|
| 282 | - $object->barcode_type_label = $stdobject->barcode_type_label; |
|
| 283 | - |
|
| 284 | - $object->description = dol_htmlcleanlastbr(GETPOST('desc')); |
|
| 285 | - $object->url = GETPOST('url'); |
|
| 286 | - $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private')); |
|
| 287 | - $object->note = $object->note_private; // deprecated |
|
| 288 | - $object->customcode = GETPOST('customcode'); |
|
| 289 | - $object->country_id = GETPOST('country_id'); |
|
| 290 | - $object->duration_value = $duration_value; |
|
| 291 | - $object->duration_unit = $duration_unit; |
|
| 292 | - $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte')?GETPOST('seuil_stock_alerte'):0; |
|
| 293 | - $object->desiredstock = GETPOST('desiredstock')?GETPOST('desiredstock'):0; |
|
| 294 | - $object->canvas = GETPOST('canvas'); |
|
| 295 | - $object->weight = GETPOST('weight'); |
|
| 296 | - $object->weight_units = GETPOST('weight_units'); |
|
| 297 | - $object->length = GETPOST('size'); |
|
| 298 | - $object->length_units = GETPOST('size_units'); |
|
| 299 | - $object->width = GETPOST('sizewidth'); |
|
| 300 | - $object->height = GETPOST('sizeheight'); |
|
| 301 | - $object->surface = GETPOST('surface'); |
|
| 302 | - $object->surface_units = GETPOST('surface_units'); |
|
| 303 | - $object->volume = GETPOST('volume'); |
|
| 304 | - $object->volume_units = GETPOST('volume_units'); |
|
| 305 | - $object->finished = GETPOST('finished'); |
|
| 306 | - $object->fk_unit = GETPOST('units'); |
|
| 267 | + $object->barcode_type = GETPOST('fk_barcode_type'); |
|
| 268 | + $object->barcode = GETPOST('barcode'); |
|
| 269 | + // Set barcode_type_xxx from barcode_type id |
|
| 270 | + $stdobject=new GenericObject($db); |
|
| 271 | + $stdobject->element='product'; |
|
| 272 | + $stdobject->barcode_type=GETPOST('fk_barcode_type'); |
|
| 273 | + $result=$stdobject->fetch_barcode(); |
|
| 274 | + if ($result < 0) |
|
| 275 | + { |
|
| 276 | + $error++; |
|
| 277 | + $mesg='Failed to get bar code type information '; |
|
| 278 | + setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); |
|
| 279 | + } |
|
| 280 | + $object->barcode_type_code = $stdobject->barcode_type_code; |
|
| 281 | + $object->barcode_type_coder = $stdobject->barcode_type_coder; |
|
| 282 | + $object->barcode_type_label = $stdobject->barcode_type_label; |
|
| 283 | + |
|
| 284 | + $object->description = dol_htmlcleanlastbr(GETPOST('desc')); |
|
| 285 | + $object->url = GETPOST('url'); |
|
| 286 | + $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private')); |
|
| 287 | + $object->note = $object->note_private; // deprecated |
|
| 288 | + $object->customcode = GETPOST('customcode'); |
|
| 289 | + $object->country_id = GETPOST('country_id'); |
|
| 290 | + $object->duration_value = $duration_value; |
|
| 291 | + $object->duration_unit = $duration_unit; |
|
| 292 | + $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte')?GETPOST('seuil_stock_alerte'):0; |
|
| 293 | + $object->desiredstock = GETPOST('desiredstock')?GETPOST('desiredstock'):0; |
|
| 294 | + $object->canvas = GETPOST('canvas'); |
|
| 295 | + $object->weight = GETPOST('weight'); |
|
| 296 | + $object->weight_units = GETPOST('weight_units'); |
|
| 297 | + $object->length = GETPOST('size'); |
|
| 298 | + $object->length_units = GETPOST('size_units'); |
|
| 299 | + $object->width = GETPOST('sizewidth'); |
|
| 300 | + $object->height = GETPOST('sizeheight'); |
|
| 301 | + $object->surface = GETPOST('surface'); |
|
| 302 | + $object->surface_units = GETPOST('surface_units'); |
|
| 303 | + $object->volume = GETPOST('volume'); |
|
| 304 | + $object->volume_units = GETPOST('volume_units'); |
|
| 305 | + $object->finished = GETPOST('finished'); |
|
| 306 | + $object->fk_unit = GETPOST('units'); |
|
| 307 | 307 | |
| 308 | 308 | $accountancy_code_sell = GETPOST('accountancy_code_sell'); |
| 309 | 309 | $accountancy_code_buy = GETPOST('accountancy_code_buy'); |
@@ -311,123 +311,123 @@ discard block |
||
| 311 | 311 | if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } |
| 312 | 312 | if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } |
| 313 | 313 | |
| 314 | - // MultiPrix |
|
| 315 | - if (! empty($conf->global->PRODUIT_MULTIPRICES)) |
|
| 316 | - { |
|
| 317 | - for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) |
|
| 318 | - { |
|
| 319 | - if (isset($_POST["price_".$i])) |
|
| 320 | - { |
|
| 321 | - $object->multiprices["$i"] = price2num($_POST["price_".$i],'MU'); |
|
| 322 | - $object->multiprices_base_type["$i"] = $_POST["multiprices_base_type_".$i]; |
|
| 323 | - } |
|
| 324 | - else |
|
| 325 | - { |
|
| 326 | - $object->multiprices["$i"] = ""; |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - } |
|
| 314 | + // MultiPrix |
|
| 315 | + if (! empty($conf->global->PRODUIT_MULTIPRICES)) |
|
| 316 | + { |
|
| 317 | + for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) |
|
| 318 | + { |
|
| 319 | + if (isset($_POST["price_".$i])) |
|
| 320 | + { |
|
| 321 | + $object->multiprices["$i"] = price2num($_POST["price_".$i],'MU'); |
|
| 322 | + $object->multiprices_base_type["$i"] = $_POST["multiprices_base_type_".$i]; |
|
| 323 | + } |
|
| 324 | + else |
|
| 325 | + { |
|
| 326 | + $object->multiprices["$i"] = ""; |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - // Fill array 'array_options' with data from add form |
|
| 332 | - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
|
| 331 | + // Fill array 'array_options' with data from add form |
|
| 332 | + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
|
| 333 | 333 | if ($ret < 0) $error++; |
| 334 | 334 | |
| 335 | 335 | if (! $error) |
| 336 | 336 | { |
| 337 | - $id = $object->create($user); |
|
| 337 | + $id = $object->create($user); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if ($id > 0) |
|
| 341 | - { |
|
| 340 | + if ($id > 0) |
|
| 341 | + { |
|
| 342 | 342 | // Category association |
| 343 | 343 | $categories = GETPOST('categories'); |
| 344 | 344 | $object->setCategories($categories); |
| 345 | 345 | |
| 346 | - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); |
|
| 347 | - exit; |
|
| 348 | - } |
|
| 349 | - else |
|
| 346 | + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); |
|
| 347 | + exit; |
|
| 348 | + } |
|
| 349 | + else |
|
| 350 | 350 | { |
| 351 | - if (count($object->errors)) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 351 | + if (count($object->errors)) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 352 | 352 | else setEventMessages($langs->trans($object->error), null, 'errors'); |
| 353 | - $action = "create"; |
|
| 354 | - } |
|
| 355 | - } |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - // Update a product or service |
|
| 359 | - if ($action == 'update' && ($user->rights->produit->creer || $user->rights->service->creer)) |
|
| 360 | - { |
|
| 361 | - if (GETPOST('cancel')) |
|
| 362 | - { |
|
| 363 | - $action = ''; |
|
| 364 | - } |
|
| 365 | - else |
|
| 366 | - { |
|
| 367 | - if ($object->id > 0) |
|
| 368 | - { |
|
| 353 | + $action = "create"; |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + // Update a product or service |
|
| 359 | + if ($action == 'update' && ($user->rights->produit->creer || $user->rights->service->creer)) |
|
| 360 | + { |
|
| 361 | + if (GETPOST('cancel')) |
|
| 362 | + { |
|
| 363 | + $action = ''; |
|
| 364 | + } |
|
| 365 | + else |
|
| 366 | + { |
|
| 367 | + if ($object->id > 0) |
|
| 368 | + { |
|
| 369 | 369 | $object->oldcopy= clone $object; |
| 370 | 370 | |
| 371 | - $object->ref = $ref; |
|
| 372 | - $object->label = GETPOST('label'); |
|
| 373 | - $object->description = dol_htmlcleanlastbr(GETPOST('desc')); |
|
| 374 | - $object->url = GETPOST('url'); |
|
| 375 | - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
| 376 | - { |
|
| 377 | - $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private')); |
|
| 378 | - $object->note = $object->note_private; |
|
| 379 | - } |
|
| 380 | - $object->customcode = GETPOST('customcode'); |
|
| 381 | - $object->country_id = GETPOST('country_id'); |
|
| 382 | - $object->status = GETPOST('statut'); |
|
| 383 | - $object->status_buy = GETPOST('statut_buy'); |
|
| 384 | - $object->status_batch = GETPOST('status_batch'); |
|
| 385 | - // removed from update view so GETPOST always empty |
|
| 386 | - /* |
|
| 371 | + $object->ref = $ref; |
|
| 372 | + $object->label = GETPOST('label'); |
|
| 373 | + $object->description = dol_htmlcleanlastbr(GETPOST('desc')); |
|
| 374 | + $object->url = GETPOST('url'); |
|
| 375 | + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
| 376 | + { |
|
| 377 | + $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private')); |
|
| 378 | + $object->note = $object->note_private; |
|
| 379 | + } |
|
| 380 | + $object->customcode = GETPOST('customcode'); |
|
| 381 | + $object->country_id = GETPOST('country_id'); |
|
| 382 | + $object->status = GETPOST('statut'); |
|
| 383 | + $object->status_buy = GETPOST('statut_buy'); |
|
| 384 | + $object->status_batch = GETPOST('status_batch'); |
|
| 385 | + // removed from update view so GETPOST always empty |
|
| 386 | + /* |
|
| 387 | 387 | $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); |
| 388 | 388 | $object->desiredstock = GETPOST('desiredstock'); |
| 389 | 389 | */ |
| 390 | - $object->duration_value = GETPOST('duration_value'); |
|
| 391 | - $object->duration_unit = GETPOST('duration_unit'); |
|
| 392 | - |
|
| 393 | - $object->canvas = GETPOST('canvas'); |
|
| 394 | - $object->weight = GETPOST('weight'); |
|
| 395 | - $object->weight_units = GETPOST('weight_units'); |
|
| 396 | - $object->length = GETPOST('size'); |
|
| 397 | - $object->length_units = GETPOST('size_units'); |
|
| 398 | - $object->width = GETPOST('sizewidth'); |
|
| 399 | - $object->height = GETPOST('sizeheight'); |
|
| 400 | - |
|
| 401 | - $object->surface = GETPOST('surface'); |
|
| 402 | - $object->surface_units = GETPOST('surface_units'); |
|
| 403 | - $object->volume = GETPOST('volume'); |
|
| 404 | - $object->volume_units = GETPOST('volume_units'); |
|
| 405 | - $object->finished = GETPOST('finished'); |
|
| 406 | - |
|
| 407 | - $units = GETPOST('units', 'int'); |
|
| 408 | - |
|
| 409 | - if ($units > 0) { |
|
| 410 | - $object->fk_unit = $units; |
|
| 411 | - } else { |
|
| 412 | - $object->fk_unit = null; |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - $object->barcode_type = GETPOST('fk_barcode_type'); |
|
| 416 | - $object->barcode = GETPOST('barcode'); |
|
| 417 | - // Set barcode_type_xxx from barcode_type id |
|
| 418 | - $stdobject=new GenericObject($db); |
|
| 419 | - $stdobject->element='product'; |
|
| 420 | - $stdobject->barcode_type=GETPOST('fk_barcode_type'); |
|
| 421 | - $result=$stdobject->fetch_barcode(); |
|
| 422 | - if ($result < 0) |
|
| 423 | - { |
|
| 424 | - $error++; |
|
| 425 | - $mesg='Failed to get bar code type information '; |
|
| 426 | - setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); |
|
| 427 | - } |
|
| 428 | - $object->barcode_type_code = $stdobject->barcode_type_code; |
|
| 429 | - $object->barcode_type_coder = $stdobject->barcode_type_coder; |
|
| 430 | - $object->barcode_type_label = $stdobject->barcode_type_label; |
|
| 390 | + $object->duration_value = GETPOST('duration_value'); |
|
| 391 | + $object->duration_unit = GETPOST('duration_unit'); |
|
| 392 | + |
|
| 393 | + $object->canvas = GETPOST('canvas'); |
|
| 394 | + $object->weight = GETPOST('weight'); |
|
| 395 | + $object->weight_units = GETPOST('weight_units'); |
|
| 396 | + $object->length = GETPOST('size'); |
|
| 397 | + $object->length_units = GETPOST('size_units'); |
|
| 398 | + $object->width = GETPOST('sizewidth'); |
|
| 399 | + $object->height = GETPOST('sizeheight'); |
|
| 400 | + |
|
| 401 | + $object->surface = GETPOST('surface'); |
|
| 402 | + $object->surface_units = GETPOST('surface_units'); |
|
| 403 | + $object->volume = GETPOST('volume'); |
|
| 404 | + $object->volume_units = GETPOST('volume_units'); |
|
| 405 | + $object->finished = GETPOST('finished'); |
|
| 406 | + |
|
| 407 | + $units = GETPOST('units', 'int'); |
|
| 408 | + |
|
| 409 | + if ($units > 0) { |
|
| 410 | + $object->fk_unit = $units; |
|
| 411 | + } else { |
|
| 412 | + $object->fk_unit = null; |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + $object->barcode_type = GETPOST('fk_barcode_type'); |
|
| 416 | + $object->barcode = GETPOST('barcode'); |
|
| 417 | + // Set barcode_type_xxx from barcode_type id |
|
| 418 | + $stdobject=new GenericObject($db); |
|
| 419 | + $stdobject->element='product'; |
|
| 420 | + $stdobject->barcode_type=GETPOST('fk_barcode_type'); |
|
| 421 | + $result=$stdobject->fetch_barcode(); |
|
| 422 | + if ($result < 0) |
|
| 423 | + { |
|
| 424 | + $error++; |
|
| 425 | + $mesg='Failed to get bar code type information '; |
|
| 426 | + setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); |
|
| 427 | + } |
|
| 428 | + $object->barcode_type_code = $stdobject->barcode_type_code; |
|
| 429 | + $object->barcode_type_coder = $stdobject->barcode_type_coder; |
|
| 430 | + $object->barcode_type_label = $stdobject->barcode_type_label; |
|
| 431 | 431 | |
| 432 | 432 | $accountancy_code_sell = GETPOST('accountancy_code_sell'); |
| 433 | 433 | $accountancy_code_buy = GETPOST('accountancy_code_buy'); |
@@ -435,384 +435,384 @@ discard block |
||
| 435 | 435 | if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } |
| 436 | 436 | if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } |
| 437 | 437 | |
| 438 | - // Fill array 'array_options' with data from add form |
|
| 439 | - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
|
| 438 | + // Fill array 'array_options' with data from add form |
|
| 439 | + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
|
| 440 | 440 | if ($ret < 0) $error++; |
| 441 | 441 | |
| 442 | - if (! $error && $object->check()) |
|
| 443 | - { |
|
| 444 | - if ($object->update($object->id, $user) > 0) |
|
| 445 | - { |
|
| 442 | + if (! $error && $object->check()) |
|
| 443 | + { |
|
| 444 | + if ($object->update($object->id, $user) > 0) |
|
| 445 | + { |
|
| 446 | 446 | // Category association |
| 447 | 447 | $categories = GETPOST('categories'); |
| 448 | 448 | $object->setCategories($categories); |
| 449 | 449 | |
| 450 | - $action = 'view'; |
|
| 451 | - } |
|
| 452 | - else |
|
| 450 | + $action = 'view'; |
|
| 451 | + } |
|
| 452 | + else |
|
| 453 | 453 | { |
| 454 | 454 | if (count($object->errors)) setEventMessages($object->error, $object->errors, 'errors'); |
| 455 | - else setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 456 | - $action = 'edit'; |
|
| 457 | - } |
|
| 458 | - } |
|
| 459 | - else |
|
| 455 | + else setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 456 | + $action = 'edit'; |
|
| 457 | + } |
|
| 458 | + } |
|
| 459 | + else |
|
| 460 | 460 | { |
| 461 | 461 | if (count($object->errors)) setEventMessages($object->error, $object->errors, 'errors'); |
| 462 | - else setEventMessages($langs->trans("ErrorProductBadRefOrLabel"), null, 'errors'); |
|
| 463 | - $action = 'edit'; |
|
| 464 | - } |
|
| 465 | - } |
|
| 462 | + else setEventMessages($langs->trans("ErrorProductBadRefOrLabel"), null, 'errors'); |
|
| 463 | + $action = 'edit'; |
|
| 464 | + } |
|
| 465 | + } |
|
| 466 | 466 | |
| 467 | - } |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - // Action clone object |
|
| 471 | - if ($action == 'confirm_clone' && $confirm != 'yes') { $action=''; } |
|
| 472 | - if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->produit->creer || $user->rights->service->creer)) |
|
| 473 | - { |
|
| 474 | - if (! GETPOST('clone_content') && ! GETPOST('clone_prices') ) |
|
| 475 | - { |
|
| 476 | - setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); |
|
| 477 | - } |
|
| 478 | - else |
|
| 479 | - { |
|
| 480 | - $db->begin(); |
|
| 481 | - |
|
| 482 | - $originalId = $id; |
|
| 483 | - if ($object->id > 0) |
|
| 484 | - { |
|
| 485 | - $object->ref = GETPOST('clone_ref'); |
|
| 486 | - $object->status = 0; |
|
| 487 | - $object->status_buy = 0; |
|
| 488 | - $object->id = null; |
|
| 489 | - $object->barcode = -1; |
|
| 490 | - |
|
| 491 | - if ($object->check()) |
|
| 492 | - { |
|
| 493 | - $id = $object->create($user); |
|
| 494 | - if ($id > 0) |
|
| 495 | - { |
|
| 496 | - if (GETPOST('clone_composition')) |
|
| 497 | - { |
|
| 498 | - $result = $object->clone_associations($originalId, $id); |
|
| 499 | - |
|
| 500 | - if ($result < 1) |
|
| 501 | - { |
|
| 502 | - $db->rollback(); |
|
| 503 | - setEventMessages($langs->trans('ErrorProductClone'), null, 'errors'); |
|
| 504 | - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$originalId); |
|
| 505 | - exit; |
|
| 506 | - } |
|
| 507 | - } |
|
| 508 | - |
|
| 509 | - // $object->clone_fournisseurs($originalId, $id); |
|
| 510 | - |
|
| 511 | - $db->commit(); |
|
| 512 | - $db->close(); |
|
| 513 | - |
|
| 514 | - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); |
|
| 515 | - exit; |
|
| 516 | - } |
|
| 517 | - else |
|
| 518 | - { |
|
| 519 | - $id=$originalId; |
|
| 520 | - |
|
| 521 | - if ($object->error == 'ErrorProductAlreadyExists') |
|
| 522 | - { |
|
| 523 | - $db->rollback(); |
|
| 524 | - |
|
| 525 | - $refalreadyexists++; |
|
| 526 | - $action = ""; |
|
| 527 | - |
|
| 528 | - $mesg=$langs->trans("ErrorProductAlreadyExists",$object->ref); |
|
| 529 | - $mesg.=' <a href="'.$_SERVER["PHP_SELF"].'?ref='.$object->ref.'">'.$langs->trans("ShowCardHere").'</a>.'; |
|
| 530 | - setEventMessages($mesg, null, 'errors'); |
|
| 531 | - $object->fetch($id); |
|
| 532 | - } |
|
| 533 | - else |
|
| 534 | - { |
|
| 535 | - $db->rollback(); |
|
| 536 | - if (count($object->errors)) |
|
| 537 | - { |
|
| 538 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
| 539 | - dol_print_error($db,$object->errors); |
|
| 540 | - } |
|
| 541 | - else |
|
| 542 | - { |
|
| 543 | - setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 544 | - dol_print_error($db,$object->error); |
|
| 545 | - } |
|
| 546 | - } |
|
| 547 | - } |
|
| 548 | - } |
|
| 549 | - } |
|
| 550 | - else |
|
| 551 | - { |
|
| 552 | - $db->rollback(); |
|
| 553 | - dol_print_error($db,$object->error); |
|
| 554 | - } |
|
| 555 | - } |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - // Delete a product |
|
| 559 | - if ($action == 'confirm_delete' && $confirm != 'yes') { $action=''; } |
|
| 560 | - if ($action == 'confirm_delete' && $confirm == 'yes') |
|
| 561 | - { |
|
| 562 | - if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)) |
|
| 563 | - { |
|
| 564 | - $result = $object->delete($user); |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - if ($result > 0) |
|
| 568 | - { |
|
| 569 | - header('Location: '.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'&delprod='.urlencode($object->ref)); |
|
| 570 | - exit; |
|
| 571 | - } |
|
| 572 | - else |
|
| 573 | - { |
|
| 574 | - setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 575 | - $reload = 0; |
|
| 576 | - $action=''; |
|
| 577 | - } |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - |
|
| 581 | - // Add product into object |
|
| 582 | - if ($object->id > 0 && $action == 'addin') |
|
| 583 | - { |
|
| 584 | - $thirpdartyid =0 ; |
|
| 585 | - if (GETPOST('propalid') > 0) |
|
| 586 | - { |
|
| 587 | - $propal = new Propal($db); |
|
| 588 | - $result=$propal->fetch(GETPOST('propalid')); |
|
| 589 | - if ($result <= 0) |
|
| 590 | - { |
|
| 591 | - dol_print_error($db,$propal->error); |
|
| 592 | - exit; |
|
| 593 | - } |
|
| 594 | - $thirpdartyid = $propal->socid; |
|
| 595 | - } |
|
| 596 | - elseif (GETPOST('commandeid') > 0) |
|
| 597 | - { |
|
| 598 | - $commande = new Commande($db); |
|
| 599 | - $result=$commande->fetch(GETPOST('commandeid')); |
|
| 600 | - if ($result <= 0) |
|
| 601 | - { |
|
| 602 | - dol_print_error($db,$commande->error); |
|
| 603 | - exit; |
|
| 604 | - } |
|
| 605 | - $thirpdartyid = $commande->socid; |
|
| 606 | - } |
|
| 607 | - elseif (GETPOST('factureid') > 0) |
|
| 608 | - { |
|
| 609 | - $facture = new Facture($db); |
|
| 610 | - $result=$facture->fetch(GETPOST('factureid')); |
|
| 611 | - if ($result <= 0) |
|
| 612 | - { |
|
| 613 | - dol_print_error($db,$facture->error); |
|
| 614 | - exit; |
|
| 615 | - } |
|
| 616 | - $thirpdartyid = $facture->socid; |
|
| 617 | - } |
|
| 618 | - |
|
| 619 | - if ( $thirpdartyid > 0) { |
|
| 620 | - $soc = new Societe($db); |
|
| 621 | - $result = $soc->fetch($thirpdartyid); |
|
| 622 | - if ($result <= 0) { |
|
| 623 | - dol_print_error($db, $soc->error); |
|
| 624 | - exit; |
|
| 625 | - } |
|
| 467 | + } |
|
| 468 | + } |
|
| 626 | 469 | |
| 627 | - $desc = $object->description; |
|
| 628 | - |
|
| 629 | - $tva_tx = get_default_tva($mysoc, $soc, $object->id); |
|
| 630 | - $tva_npr = get_default_npr($mysoc, $soc, $object->id); |
|
| 631 | - if (empty($tva_tx)) $tva_npr=0; |
|
| 632 | - $localtax1_tx = get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr); |
|
| 633 | - $localtax2_tx = get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr); |
|
| 634 | - |
|
| 635 | - $pu_ht = $object->price; |
|
| 636 | - $pu_ttc = $object->price_ttc; |
|
| 637 | - $price_base_type = $object->price_base_type; |
|
| 638 | - |
|
| 639 | - // If multiprice |
|
| 640 | - if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) { |
|
| 641 | - $pu_ht = $object->multiprices[$soc->price_level]; |
|
| 642 | - $pu_ttc = $object->multiprices_ttc[$soc->price_level]; |
|
| 643 | - $price_base_type = $object->multiprices_base_type[$soc->price_level]; |
|
| 644 | - } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { |
|
| 645 | - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; |
|
| 646 | - |
|
| 647 | - $prodcustprice = new Productcustomerprice($db); |
|
| 648 | - |
|
| 649 | - $filter = array('t.fk_product' => $object->id, 't.fk_soc' => $soc->id); |
|
| 650 | - |
|
| 651 | - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); |
|
| 652 | - if ($result) { |
|
| 653 | - if (count($prodcustprice->lines) > 0) { |
|
| 654 | - $pu_ht = price($prodcustprice->lines [0]->price); |
|
| 655 | - $pu_ttc = price($prodcustprice->lines [0]->price_ttc); |
|
| 656 | - $price_base_type = $prodcustprice->lines [0]->price_base_type; |
|
| 657 | - $tva_tx = $prodcustprice->lines [0]->tva_tx; |
|
| 658 | - } |
|
| 659 | - } |
|
| 660 | - } |
|
| 470 | + // Action clone object |
|
| 471 | + if ($action == 'confirm_clone' && $confirm != 'yes') { $action=''; } |
|
| 472 | + if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->produit->creer || $user->rights->service->creer)) |
|
| 473 | + { |
|
| 474 | + if (! GETPOST('clone_content') && ! GETPOST('clone_prices') ) |
|
| 475 | + { |
|
| 476 | + setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); |
|
| 477 | + } |
|
| 478 | + else |
|
| 479 | + { |
|
| 480 | + $db->begin(); |
|
| 481 | + |
|
| 482 | + $originalId = $id; |
|
| 483 | + if ($object->id > 0) |
|
| 484 | + { |
|
| 485 | + $object->ref = GETPOST('clone_ref'); |
|
| 486 | + $object->status = 0; |
|
| 487 | + $object->status_buy = 0; |
|
| 488 | + $object->id = null; |
|
| 489 | + $object->barcode = -1; |
|
| 490 | + |
|
| 491 | + if ($object->check()) |
|
| 492 | + { |
|
| 493 | + $id = $object->create($user); |
|
| 494 | + if ($id > 0) |
|
| 495 | + { |
|
| 496 | + if (GETPOST('clone_composition')) |
|
| 497 | + { |
|
| 498 | + $result = $object->clone_associations($originalId, $id); |
|
| 499 | + |
|
| 500 | + if ($result < 1) |
|
| 501 | + { |
|
| 502 | + $db->rollback(); |
|
| 503 | + setEventMessages($langs->trans('ErrorProductClone'), null, 'errors'); |
|
| 504 | + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$originalId); |
|
| 505 | + exit; |
|
| 506 | + } |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + // $object->clone_fournisseurs($originalId, $id); |
|
| 510 | + |
|
| 511 | + $db->commit(); |
|
| 512 | + $db->close(); |
|
| 513 | + |
|
| 514 | + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); |
|
| 515 | + exit; |
|
| 516 | + } |
|
| 517 | + else |
|
| 518 | + { |
|
| 519 | + $id=$originalId; |
|
| 520 | + |
|
| 521 | + if ($object->error == 'ErrorProductAlreadyExists') |
|
| 522 | + { |
|
| 523 | + $db->rollback(); |
|
| 524 | + |
|
| 525 | + $refalreadyexists++; |
|
| 526 | + $action = ""; |
|
| 527 | + |
|
| 528 | + $mesg=$langs->trans("ErrorProductAlreadyExists",$object->ref); |
|
| 529 | + $mesg.=' <a href="'.$_SERVER["PHP_SELF"].'?ref='.$object->ref.'">'.$langs->trans("ShowCardHere").'</a>.'; |
|
| 530 | + setEventMessages($mesg, null, 'errors'); |
|
| 531 | + $object->fetch($id); |
|
| 532 | + } |
|
| 533 | + else |
|
| 534 | + { |
|
| 535 | + $db->rollback(); |
|
| 536 | + if (count($object->errors)) |
|
| 537 | + { |
|
| 538 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 539 | + dol_print_error($db,$object->errors); |
|
| 540 | + } |
|
| 541 | + else |
|
| 542 | + { |
|
| 543 | + setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 544 | + dol_print_error($db,$object->error); |
|
| 545 | + } |
|
| 546 | + } |
|
| 547 | + } |
|
| 548 | + } |
|
| 549 | + } |
|
| 550 | + else |
|
| 551 | + { |
|
| 552 | + $db->rollback(); |
|
| 553 | + dol_print_error($db,$object->error); |
|
| 554 | + } |
|
| 555 | + } |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + // Delete a product |
|
| 559 | + if ($action == 'confirm_delete' && $confirm != 'yes') { $action=''; } |
|
| 560 | + if ($action == 'confirm_delete' && $confirm == 'yes') |
|
| 561 | + { |
|
| 562 | + if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)) |
|
| 563 | + { |
|
| 564 | + $result = $object->delete($user); |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + if ($result > 0) |
|
| 568 | + { |
|
| 569 | + header('Location: '.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'&delprod='.urlencode($object->ref)); |
|
| 570 | + exit; |
|
| 571 | + } |
|
| 572 | + else |
|
| 573 | + { |
|
| 574 | + setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 575 | + $reload = 0; |
|
| 576 | + $action=''; |
|
| 577 | + } |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + |
|
| 581 | + // Add product into object |
|
| 582 | + if ($object->id > 0 && $action == 'addin') |
|
| 583 | + { |
|
| 584 | + $thirpdartyid =0 ; |
|
| 585 | + if (GETPOST('propalid') > 0) |
|
| 586 | + { |
|
| 587 | + $propal = new Propal($db); |
|
| 588 | + $result=$propal->fetch(GETPOST('propalid')); |
|
| 589 | + if ($result <= 0) |
|
| 590 | + { |
|
| 591 | + dol_print_error($db,$propal->error); |
|
| 592 | + exit; |
|
| 593 | + } |
|
| 594 | + $thirpdartyid = $propal->socid; |
|
| 595 | + } |
|
| 596 | + elseif (GETPOST('commandeid') > 0) |
|
| 597 | + { |
|
| 598 | + $commande = new Commande($db); |
|
| 599 | + $result=$commande->fetch(GETPOST('commandeid')); |
|
| 600 | + if ($result <= 0) |
|
| 601 | + { |
|
| 602 | + dol_print_error($db,$commande->error); |
|
| 603 | + exit; |
|
| 604 | + } |
|
| 605 | + $thirpdartyid = $commande->socid; |
|
| 606 | + } |
|
| 607 | + elseif (GETPOST('factureid') > 0) |
|
| 608 | + { |
|
| 609 | + $facture = new Facture($db); |
|
| 610 | + $result=$facture->fetch(GETPOST('factureid')); |
|
| 611 | + if ($result <= 0) |
|
| 612 | + { |
|
| 613 | + dol_print_error($db,$facture->error); |
|
| 614 | + exit; |
|
| 615 | + } |
|
| 616 | + $thirpdartyid = $facture->socid; |
|
| 617 | + } |
|
| 618 | + |
|
| 619 | + if ( $thirpdartyid > 0) { |
|
| 620 | + $soc = new Societe($db); |
|
| 621 | + $result = $soc->fetch($thirpdartyid); |
|
| 622 | + if ($result <= 0) { |
|
| 623 | + dol_print_error($db, $soc->error); |
|
| 624 | + exit; |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + $desc = $object->description; |
|
| 628 | + |
|
| 629 | + $tva_tx = get_default_tva($mysoc, $soc, $object->id); |
|
| 630 | + $tva_npr = get_default_npr($mysoc, $soc, $object->id); |
|
| 631 | + if (empty($tva_tx)) $tva_npr=0; |
|
| 632 | + $localtax1_tx = get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr); |
|
| 633 | + $localtax2_tx = get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr); |
|
| 634 | + |
|
| 635 | + $pu_ht = $object->price; |
|
| 636 | + $pu_ttc = $object->price_ttc; |
|
| 637 | + $price_base_type = $object->price_base_type; |
|
| 638 | + |
|
| 639 | + // If multiprice |
|
| 640 | + if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) { |
|
| 641 | + $pu_ht = $object->multiprices[$soc->price_level]; |
|
| 642 | + $pu_ttc = $object->multiprices_ttc[$soc->price_level]; |
|
| 643 | + $price_base_type = $object->multiprices_base_type[$soc->price_level]; |
|
| 644 | + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { |
|
| 645 | + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; |
|
| 646 | + |
|
| 647 | + $prodcustprice = new Productcustomerprice($db); |
|
| 648 | + |
|
| 649 | + $filter = array('t.fk_product' => $object->id, 't.fk_soc' => $soc->id); |
|
| 650 | + |
|
| 651 | + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); |
|
| 652 | + if ($result) { |
|
| 653 | + if (count($prodcustprice->lines) > 0) { |
|
| 654 | + $pu_ht = price($prodcustprice->lines [0]->price); |
|
| 655 | + $pu_ttc = price($prodcustprice->lines [0]->price_ttc); |
|
| 656 | + $price_base_type = $prodcustprice->lines [0]->price_base_type; |
|
| 657 | + $tva_tx = $prodcustprice->lines [0]->tva_tx; |
|
| 658 | + } |
|
| 659 | + } |
|
| 660 | + } |
|
| 661 | 661 | |
| 662 | 662 | $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); |
| 663 | 663 | $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); |
| 664 | 664 | |
| 665 | - // On reevalue prix selon taux tva car taux tva transaction peut etre different |
|
| 666 | - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). |
|
| 667 | - if ($tmpvat != $tmpprodvat) { |
|
| 668 | - if ($price_base_type != 'HT') { |
|
| 669 | - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); |
|
| 670 | - } else { |
|
| 671 | - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); |
|
| 672 | - } |
|
| 673 | - } |
|
| 665 | + // On reevalue prix selon taux tva car taux tva transaction peut etre different |
|
| 666 | + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). |
|
| 667 | + if ($tmpvat != $tmpprodvat) { |
|
| 668 | + if ($price_base_type != 'HT') { |
|
| 669 | + $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); |
|
| 670 | + } else { |
|
| 671 | + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); |
|
| 672 | + } |
|
| 673 | + } |
|
| 674 | 674 | |
| 675 | - if (GETPOST('propalid') > 0) { |
|
| 676 | - // Define cost price for margin calculation |
|
| 677 | - $buyprice=0; |
|
| 678 | - if (($result = $propal->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0) |
|
| 679 | - { |
|
| 680 | - dol_syslog($langs->trans('FailedToGetCostPrice')); |
|
| 681 | - setEventMessage($langs->trans('FailedToGetCostPrice'), 'errors'); |
|
| 682 | - } |
|
| 683 | - else |
|
| 684 | - { |
|
| 685 | - $buyprice = $result; |
|
| 686 | - } |
|
| 687 | - |
|
| 688 | - $result = $propal->addline( |
|
| 689 | - $desc, |
|
| 690 | - $pu_ht, |
|
| 691 | - GETPOST('qty'), |
|
| 692 | - $tva_tx, |
|
| 693 | - $localtax1_tx, // localtax1 |
|
| 694 | - $localtax2_tx, // localtax2 |
|
| 695 | - $object->id, |
|
| 696 | - GETPOST('remise_percent'), |
|
| 697 | - $price_base_type, |
|
| 698 | - $pu_ttc, |
|
| 699 | - 0, |
|
| 700 | - 0, |
|
| 701 | - -1, |
|
| 702 | - 0, |
|
| 703 | - 0, |
|
| 704 | - 0, |
|
| 705 | - $buyprice, |
|
| 706 | - '', |
|
| 707 | - '', |
|
| 708 | - '', |
|
| 709 | - 0, |
|
| 710 | - $object->fk_unit |
|
| 711 | - ); |
|
| 712 | - if ($result > 0) { |
|
| 713 | - header("Location: " . DOL_URL_ROOT . "/comm/propal/card.php?id=" . $propal->id); |
|
| 714 | - return; |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - setEventMessages($langs->trans("ErrorUnknown") . ": $result", null, 'errors'); |
|
| 718 | - } elseif (GETPOST('commandeid') > 0) { |
|
| 719 | - // Define cost price for margin calculation |
|
| 720 | - $buyprice=0; |
|
| 721 | - if (($result = $commande->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0) |
|
| 722 | - { |
|
| 723 | - dol_syslog($langs->trans('FailedToGetCostPrice')); |
|
| 724 | - setEventMessage($langs->trans('FailedToGetCostPrice'), 'errors'); |
|
| 725 | - } |
|
| 726 | - else |
|
| 727 | - { |
|
| 728 | - $buyprice = $result; |
|
| 729 | - } |
|
| 730 | - |
|
| 731 | - $result = $commande->addline( |
|
| 732 | - $desc, |
|
| 733 | - $pu_ht, |
|
| 734 | - GETPOST('qty'), |
|
| 735 | - $tva_tx, |
|
| 736 | - $localtax1_tx, // localtax1 |
|
| 737 | - $localtax2_tx, // localtax2 |
|
| 738 | - $object->id, |
|
| 739 | - GETPOST('remise_percent'), |
|
| 740 | - '', |
|
| 741 | - '', |
|
| 742 | - $price_base_type, |
|
| 743 | - $pu_ttc, |
|
| 744 | - '', |
|
| 745 | - '', |
|
| 746 | - 0, |
|
| 747 | - -1, |
|
| 748 | - 0, |
|
| 749 | - 0, |
|
| 750 | - null, |
|
| 751 | - $buyprice, |
|
| 752 | - '', |
|
| 753 | - 0, |
|
| 754 | - $object->fk_unit |
|
| 755 | - ); |
|
| 756 | - |
|
| 757 | - if ($result > 0) { |
|
| 758 | - header("Location: " . DOL_URL_ROOT . "/commande/card.php?id=" . $commande->id); |
|
| 759 | - exit; |
|
| 760 | - } |
|
| 761 | - } elseif (GETPOST('factureid') > 0) { |
|
| 762 | - // Define cost price for margin calculation |
|
| 763 | - $buyprice=0; |
|
| 764 | - if (($result = $facture->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0) |
|
| 765 | - { |
|
| 766 | - dol_syslog($langs->trans('FailedToGetCostPrice')); |
|
| 767 | - setEventMessage($langs->trans('FailedToGetCostPrice'), 'errors'); |
|
| 768 | - } |
|
| 769 | - else |
|
| 770 | - { |
|
| 771 | - $buyprice = $result; |
|
| 772 | - } |
|
| 773 | - |
|
| 774 | - $result = $facture->addline( |
|
| 775 | - $desc, |
|
| 776 | - $pu_ht, |
|
| 777 | - GETPOST('qty'), |
|
| 778 | - $tva_tx, |
|
| 779 | - $localtax1_tx, |
|
| 780 | - $localtax2_tx, |
|
| 781 | - $object->id, |
|
| 782 | - GETPOST('remise_percent'), |
|
| 783 | - '', |
|
| 784 | - '', |
|
| 785 | - '', |
|
| 786 | - '', |
|
| 787 | - '', |
|
| 788 | - $price_base_type, |
|
| 789 | - $pu_ttc, |
|
| 790 | - Facture::TYPE_STANDARD, |
|
| 791 | - -1, |
|
| 792 | - 0, |
|
| 793 | - '', |
|
| 794 | - 0, |
|
| 795 | - 0, |
|
| 796 | - null, |
|
| 797 | - $buyprice, |
|
| 798 | - '', |
|
| 799 | - 0, |
|
| 800 | - 100, |
|
| 801 | - '', |
|
| 802 | - $object->fk_unit |
|
| 803 | - ); |
|
| 804 | - |
|
| 805 | - if ($result > 0) { |
|
| 806 | - header("Location: " . DOL_URL_ROOT . "/compta/facture/card.php?facid=" . $facture->id); |
|
| 807 | - exit; |
|
| 808 | - } |
|
| 809 | - } |
|
| 810 | - } |
|
| 811 | - else { |
|
| 812 | - $action=""; |
|
| 813 | - setEventMessages($langs->trans("WarningSelectOneDocument"), null, 'warnings'); |
|
| 814 | - } |
|
| 815 | - } |
|
| 675 | + if (GETPOST('propalid') > 0) { |
|
| 676 | + // Define cost price for margin calculation |
|
| 677 | + $buyprice=0; |
|
| 678 | + if (($result = $propal->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0) |
|
| 679 | + { |
|
| 680 | + dol_syslog($langs->trans('FailedToGetCostPrice')); |
|
| 681 | + setEventMessage($langs->trans('FailedToGetCostPrice'), 'errors'); |
|
| 682 | + } |
|
| 683 | + else |
|
| 684 | + { |
|
| 685 | + $buyprice = $result; |
|
| 686 | + } |
|
| 687 | + |
|
| 688 | + $result = $propal->addline( |
|
| 689 | + $desc, |
|
| 690 | + $pu_ht, |
|
| 691 | + GETPOST('qty'), |
|
| 692 | + $tva_tx, |
|
| 693 | + $localtax1_tx, // localtax1 |
|
| 694 | + $localtax2_tx, // localtax2 |
|
| 695 | + $object->id, |
|
| 696 | + GETPOST('remise_percent'), |
|
| 697 | + $price_base_type, |
|
| 698 | + $pu_ttc, |
|
| 699 | + 0, |
|
| 700 | + 0, |
|
| 701 | + -1, |
|
| 702 | + 0, |
|
| 703 | + 0, |
|
| 704 | + 0, |
|
| 705 | + $buyprice, |
|
| 706 | + '', |
|
| 707 | + '', |
|
| 708 | + '', |
|
| 709 | + 0, |
|
| 710 | + $object->fk_unit |
|
| 711 | + ); |
|
| 712 | + if ($result > 0) { |
|
| 713 | + header("Location: " . DOL_URL_ROOT . "/comm/propal/card.php?id=" . $propal->id); |
|
| 714 | + return; |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + setEventMessages($langs->trans("ErrorUnknown") . ": $result", null, 'errors'); |
|
| 718 | + } elseif (GETPOST('commandeid') > 0) { |
|
| 719 | + // Define cost price for margin calculation |
|
| 720 | + $buyprice=0; |
|
| 721 | + if (($result = $commande->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0) |
|
| 722 | + { |
|
| 723 | + dol_syslog($langs->trans('FailedToGetCostPrice')); |
|
| 724 | + setEventMessage($langs->trans('FailedToGetCostPrice'), 'errors'); |
|
| 725 | + } |
|
| 726 | + else |
|
| 727 | + { |
|
| 728 | + $buyprice = $result; |
|
| 729 | + } |
|
| 730 | + |
|
| 731 | + $result = $commande->addline( |
|
| 732 | + $desc, |
|
| 733 | + $pu_ht, |
|
| 734 | + GETPOST('qty'), |
|
| 735 | + $tva_tx, |
|
| 736 | + $localtax1_tx, // localtax1 |
|
| 737 | + $localtax2_tx, // localtax2 |
|
| 738 | + $object->id, |
|
| 739 | + GETPOST('remise_percent'), |
|
| 740 | + '', |
|
| 741 | + '', |
|
| 742 | + $price_base_type, |
|
| 743 | + $pu_ttc, |
|
| 744 | + '', |
|
| 745 | + '', |
|
| 746 | + 0, |
|
| 747 | + -1, |
|
| 748 | + 0, |
|
| 749 | + 0, |
|
| 750 | + null, |
|
| 751 | + $buyprice, |
|
| 752 | + '', |
|
| 753 | + 0, |
|
| 754 | + $object->fk_unit |
|
| 755 | + ); |
|
| 756 | + |
|
| 757 | + if ($result > 0) { |
|
| 758 | + header("Location: " . DOL_URL_ROOT . "/commande/card.php?id=" . $commande->id); |
|
| 759 | + exit; |
|
| 760 | + } |
|
| 761 | + } elseif (GETPOST('factureid') > 0) { |
|
| 762 | + // Define cost price for margin calculation |
|
| 763 | + $buyprice=0; |
|
| 764 | + if (($result = $facture->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0) |
|
| 765 | + { |
|
| 766 | + dol_syslog($langs->trans('FailedToGetCostPrice')); |
|
| 767 | + setEventMessage($langs->trans('FailedToGetCostPrice'), 'errors'); |
|
| 768 | + } |
|
| 769 | + else |
|
| 770 | + { |
|
| 771 | + $buyprice = $result; |
|
| 772 | + } |
|
| 773 | + |
|
| 774 | + $result = $facture->addline( |
|
| 775 | + $desc, |
|
| 776 | + $pu_ht, |
|
| 777 | + GETPOST('qty'), |
|
| 778 | + $tva_tx, |
|
| 779 | + $localtax1_tx, |
|
| 780 | + $localtax2_tx, |
|
| 781 | + $object->id, |
|
| 782 | + GETPOST('remise_percent'), |
|
| 783 | + '', |
|
| 784 | + '', |
|
| 785 | + '', |
|
| 786 | + '', |
|
| 787 | + '', |
|
| 788 | + $price_base_type, |
|
| 789 | + $pu_ttc, |
|
| 790 | + Facture::TYPE_STANDARD, |
|
| 791 | + -1, |
|
| 792 | + 0, |
|
| 793 | + '', |
|
| 794 | + 0, |
|
| 795 | + 0, |
|
| 796 | + null, |
|
| 797 | + $buyprice, |
|
| 798 | + '', |
|
| 799 | + 0, |
|
| 800 | + 100, |
|
| 801 | + '', |
|
| 802 | + $object->fk_unit |
|
| 803 | + ); |
|
| 804 | + |
|
| 805 | + if ($result > 0) { |
|
| 806 | + header("Location: " . DOL_URL_ROOT . "/compta/facture/card.php?facid=" . $facture->id); |
|
| 807 | + exit; |
|
| 808 | + } |
|
| 809 | + } |
|
| 810 | + } |
|
| 811 | + else { |
|
| 812 | + $action=""; |
|
| 813 | + setEventMessages($langs->trans("WarningSelectOneDocument"), null, 'warnings'); |
|
| 814 | + } |
|
| 815 | + } |
|
| 816 | 816 | } |
| 817 | 817 | |
| 818 | 818 | |
@@ -876,72 +876,72 @@ discard block |
||
| 876 | 876 | } |
| 877 | 877 | else |
| 878 | 878 | { |
| 879 | - // ----------------------------------------- |
|
| 880 | - // When used in standard mode |
|
| 881 | - // ----------------------------------------- |
|
| 882 | - if ($action == 'create' && ($user->rights->produit->creer || $user->rights->service->creer)) |
|
| 883 | - { |
|
| 884 | - //WYSIWYG Editor |
|
| 885 | - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
| 879 | + // ----------------------------------------- |
|
| 880 | + // When used in standard mode |
|
| 881 | + // ----------------------------------------- |
|
| 882 | + if ($action == 'create' && ($user->rights->produit->creer || $user->rights->service->creer)) |
|
| 883 | + { |
|
| 884 | + //WYSIWYG Editor |
|
| 885 | + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
| 886 | 886 | |
| 887 | 887 | // Load object modCodeProduct |
| 888 | - $module=(! empty($conf->global->PRODUCT_CODEPRODUCT_ADDON)?$conf->global->PRODUCT_CODEPRODUCT_ADDON:'mod_codeproduct_leopard'); |
|
| 889 | - if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') |
|
| 890 | - { |
|
| 891 | - $module = substr($module, 0, dol_strlen($module)-4); |
|
| 892 | - } |
|
| 893 | - $result=dol_include_once('/core/modules/product/'.$module.'.php'); |
|
| 894 | - if ($result > 0) |
|
| 895 | - { |
|
| 896 | - $modCodeProduct = new $module(); |
|
| 897 | - } |
|
| 898 | - |
|
| 899 | - dol_set_focus('input[name="ref"]'); |
|
| 900 | - |
|
| 901 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
| 902 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 903 | - print '<input type="hidden" name="action" value="add">'; |
|
| 904 | - print '<input type="hidden" name="type" value="'.$type.'">'."\n"; |
|
| 888 | + $module=(! empty($conf->global->PRODUCT_CODEPRODUCT_ADDON)?$conf->global->PRODUCT_CODEPRODUCT_ADDON:'mod_codeproduct_leopard'); |
|
| 889 | + if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') |
|
| 890 | + { |
|
| 891 | + $module = substr($module, 0, dol_strlen($module)-4); |
|
| 892 | + } |
|
| 893 | + $result=dol_include_once('/core/modules/product/'.$module.'.php'); |
|
| 894 | + if ($result > 0) |
|
| 895 | + { |
|
| 896 | + $modCodeProduct = new $module(); |
|
| 897 | + } |
|
| 898 | + |
|
| 899 | + dol_set_focus('input[name="ref"]'); |
|
| 900 | + |
|
| 901 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
| 902 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 903 | + print '<input type="hidden" name="action" value="add">'; |
|
| 904 | + print '<input type="hidden" name="type" value="'.$type.'">'."\n"; |
|
| 905 | 905 | if (! empty($modCodeProduct->code_auto)) |
| 906 | 906 | print '<input type="hidden" name="code_auto" value="1">'; |
| 907 | 907 | if (! empty($modBarCodeProduct->code_auto)) |
| 908 | 908 | print '<input type="hidden" name="barcode_auto" value="1">'; |
| 909 | 909 | |
| 910 | - if ($type==1) $title=$langs->trans("NewService"); |
|
| 911 | - else $title=$langs->trans("NewProduct"); |
|
| 912 | - $linkback=""; |
|
| 913 | - print load_fiche_titre($title,$linkback,'title_products.png'); |
|
| 910 | + if ($type==1) $title=$langs->trans("NewService"); |
|
| 911 | + else $title=$langs->trans("NewProduct"); |
|
| 912 | + $linkback=""; |
|
| 913 | + print load_fiche_titre($title,$linkback,'title_products.png'); |
|
| 914 | 914 | |
| 915 | - dol_fiche_head(''); |
|
| 915 | + dol_fiche_head(''); |
|
| 916 | 916 | |
| 917 | - print '<table class="border centpercent">'; |
|
| 917 | + print '<table class="border centpercent">'; |
|
| 918 | 918 | |
| 919 | - print '<tr>'; |
|
| 920 | - $tmpcode=''; |
|
| 919 | + print '<tr>'; |
|
| 920 | + $tmpcode=''; |
|
| 921 | 921 | if (! empty($modCodeProduct->code_auto)) $tmpcode=$modCodeProduct->getNextValue($object,$type); |
| 922 | - print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="'.dol_escape_htmltag(GETPOST('ref')?GETPOST('ref'):$tmpcode).'">'; |
|
| 923 | - if ($refalreadyexists) |
|
| 924 | - { |
|
| 925 | - print $langs->trans("RefAlreadyExists"); |
|
| 926 | - } |
|
| 927 | - print '</td></tr>'; |
|
| 928 | - |
|
| 929 | - // Label |
|
| 930 | - print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="'.dol_escape_htmltag(GETPOST('label')).'"></td></tr>'; |
|
| 931 | - |
|
| 932 | - // On sell |
|
| 933 | - print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="3">'; |
|
| 934 | - $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); |
|
| 935 | - print $form->selectarray('statut',$statutarray,GETPOST('statut')); |
|
| 936 | - print '</td></tr>'; |
|
| 937 | - |
|
| 938 | - // To buy |
|
| 939 | - print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="3">'; |
|
| 940 | - $statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy")); |
|
| 941 | - print $form->selectarray('statut_buy',$statutarray,GETPOST('statut_buy')); |
|
| 942 | - print '</td></tr>'; |
|
| 943 | - |
|
| 944 | - // Batch number management |
|
| 922 | + print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="'.dol_escape_htmltag(GETPOST('ref')?GETPOST('ref'):$tmpcode).'">'; |
|
| 923 | + if ($refalreadyexists) |
|
| 924 | + { |
|
| 925 | + print $langs->trans("RefAlreadyExists"); |
|
| 926 | + } |
|
| 927 | + print '</td></tr>'; |
|
| 928 | + |
|
| 929 | + // Label |
|
| 930 | + print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="'.dol_escape_htmltag(GETPOST('label')).'"></td></tr>'; |
|
| 931 | + |
|
| 932 | + // On sell |
|
| 933 | + print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="3">'; |
|
| 934 | + $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); |
|
| 935 | + print $form->selectarray('statut',$statutarray,GETPOST('statut')); |
|
| 936 | + print '</td></tr>'; |
|
| 937 | + |
|
| 938 | + // To buy |
|
| 939 | + print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="3">'; |
|
| 940 | + $statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy")); |
|
| 941 | + print $form->selectarray('statut_buy',$statutarray,GETPOST('statut_buy')); |
|
| 942 | + print '</td></tr>'; |
|
| 943 | + |
|
| 944 | + // Batch number management |
|
| 945 | 945 | if (! empty($conf->productbatch->enabled)) |
| 946 | 946 | { |
| 947 | 947 | print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="3">'; |
@@ -950,153 +950,153 @@ discard block |
||
| 950 | 950 | print '</td></tr>'; |
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - $showbarcode=empty($conf->barcode->enabled)?0:1; |
|
| 954 | - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; |
|
| 955 | - |
|
| 956 | - if ($showbarcode) |
|
| 957 | - { |
|
| 958 | - print '<tr><td>'.$langs->trans('BarcodeType').'</td><td>'; |
|
| 959 | - if (isset($_POST['fk_barcode_type'])) |
|
| 960 | - { |
|
| 961 | - $fk_barcode_type=GETPOST('fk_barcode_type'); |
|
| 962 | - } |
|
| 963 | - else |
|
| 964 | - { |
|
| 965 | - if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 966 | - } |
|
| 967 | - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; |
|
| 968 | - $formbarcode = new FormBarCode($db); |
|
| 969 | - print $formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); |
|
| 970 | - print '</td><td>'.$langs->trans("BarcodeValue").'</td><td>'; |
|
| 971 | - $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; |
|
| 972 | - if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
|
| 973 | - print '<input class="maxwidth100" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).'">'; |
|
| 974 | - print '</td></tr>'; |
|
| 975 | - } |
|
| 976 | - |
|
| 977 | - // Description (used in invoice, propal...) |
|
| 978 | - print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">'; |
|
| 979 | - |
|
| 980 | - $doleditor = new DolEditor('desc', GETPOST('desc'), '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); |
|
| 981 | - $doleditor->Create(); |
|
| 982 | - |
|
| 983 | - print "</td></tr>"; |
|
| 984 | - |
|
| 985 | - // Public URL |
|
| 986 | - print '<tr><td>'.$langs->trans("PublicUrl").'</td><td colspan="3">'; |
|
| 953 | + $showbarcode=empty($conf->barcode->enabled)?0:1; |
|
| 954 | + if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; |
|
| 955 | + |
|
| 956 | + if ($showbarcode) |
|
| 957 | + { |
|
| 958 | + print '<tr><td>'.$langs->trans('BarcodeType').'</td><td>'; |
|
| 959 | + if (isset($_POST['fk_barcode_type'])) |
|
| 960 | + { |
|
| 961 | + $fk_barcode_type=GETPOST('fk_barcode_type'); |
|
| 962 | + } |
|
| 963 | + else |
|
| 964 | + { |
|
| 965 | + if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 966 | + } |
|
| 967 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; |
|
| 968 | + $formbarcode = new FormBarCode($db); |
|
| 969 | + print $formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); |
|
| 970 | + print '</td><td>'.$langs->trans("BarcodeValue").'</td><td>'; |
|
| 971 | + $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; |
|
| 972 | + if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
|
| 973 | + print '<input class="maxwidth100" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).'">'; |
|
| 974 | + print '</td></tr>'; |
|
| 975 | + } |
|
| 976 | + |
|
| 977 | + // Description (used in invoice, propal...) |
|
| 978 | + print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">'; |
|
| 979 | + |
|
| 980 | + $doleditor = new DolEditor('desc', GETPOST('desc'), '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); |
|
| 981 | + $doleditor->Create(); |
|
| 982 | + |
|
| 983 | + print "</td></tr>"; |
|
| 984 | + |
|
| 985 | + // Public URL |
|
| 986 | + print '<tr><td>'.$langs->trans("PublicUrl").'</td><td colspan="3">'; |
|
| 987 | 987 | print '<input type="text" name="url" class="quatrevingtpercent" value="'.GETPOST('url').'">'; |
| 988 | - print '</td></tr>'; |
|
| 989 | - |
|
| 990 | - // Stock min level |
|
| 991 | - if ($type != 1 && ! empty($conf->stock->enabled)) |
|
| 992 | - { |
|
| 993 | - print '<tr><td>'.$form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1).'</td><td>'; |
|
| 994 | - print '<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST('seuil_stock_alerte').'">'; |
|
| 995 | - print '</td>'; |
|
| 996 | - // Stock desired level |
|
| 997 | - print '<td>'.$form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1).'</td><td>'; |
|
| 998 | - print '<input name="desiredstock" class="maxwidth50" value="'.GETPOST('desiredstock').'">'; |
|
| 999 | - print '</td></tr>'; |
|
| 1000 | - } |
|
| 1001 | - else |
|
| 1002 | - { |
|
| 1003 | - print '<input name="seuil_stock_alerte" type="hidden" value="0">'; |
|
| 1004 | - print '<input name="desiredstock" type="hidden" value="0">'; |
|
| 1005 | - } |
|
| 1006 | - |
|
| 1007 | - // Nature |
|
| 1008 | - if ($type != 1) |
|
| 1009 | - { |
|
| 1010 | - print '<tr><td>'.$langs->trans("Nature").'</td><td colspan="3">'; |
|
| 1011 | - $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); |
|
| 1012 | - print $form->selectarray('finished',$statutarray,GETPOST('finished'),1); |
|
| 1013 | - print '</td></tr>'; |
|
| 1014 | - } |
|
| 1015 | - |
|
| 1016 | - // Duration |
|
| 1017 | - if ($type == 1) |
|
| 1018 | - { |
|
| 1019 | - print '<tr><td>' . $langs->trans("Duration") . '</td><td colspan="3"><input name="duration_value" size="6" maxlength="5" value="' . $duration_value . '"> '; |
|
| 1020 | - print '<input name="duration_unit" type="radio" value="h">'.$langs->trans("Hour").' '; |
|
| 1021 | - print '<input name="duration_unit" type="radio" value="d">'.$langs->trans("Day").' '; |
|
| 1022 | - print '<input name="duration_unit" type="radio" value="w">'.$langs->trans("Week").' '; |
|
| 1023 | - print '<input name="duration_unit" type="radio" value="m">'.$langs->trans("Month").' '; |
|
| 1024 | - print '<input name="duration_unit" type="radio" value="y">'.$langs->trans("Year").' '; |
|
| 1025 | - print '</td></tr>'; |
|
| 1026 | - } |
|
| 1027 | - |
|
| 1028 | - if ($type != 1) // Le poids et le volume ne concerne que les produits et pas les services |
|
| 1029 | - { |
|
| 1030 | - // Weight |
|
| 1031 | - print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="3">'; |
|
| 1032 | - print '<input name="weight" size="4" value="'.GETPOST('weight').'">'; |
|
| 1033 | - print $formproduct->select_measuring_units("weight_units","weight"); |
|
| 1034 | - print '</td></tr>'; |
|
| 1035 | - // Length |
|
| 1036 | - if (empty($conf->global->PRODUCT_DISABLE_SIZE)) |
|
| 1037 | - { |
|
| 1038 | - print '<tr><td>'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").'</td><td colspan="3">'; |
|
| 1039 | - print '<input name="size" size="4" value="'.GETPOST('size').'"> x '; |
|
| 1040 | - print '<input name="sizewidth" size="4" value="'.GETPOST('sizewidth').'"> x '; |
|
| 1041 | - print '<input name="sizeheight" size="4" value="'.GETPOST('sizeheight').'">'; |
|
| 1042 | - print $formproduct->select_measuring_units("size_units","size"); |
|
| 1043 | - print '</td></tr>'; |
|
| 1044 | - } |
|
| 1045 | - if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) |
|
| 1046 | - { |
|
| 1047 | - // Surface |
|
| 1048 | - print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="3">'; |
|
| 1049 | - print '<input name="surface" size="4" value="'.GETPOST('surface').'">'; |
|
| 1050 | - print $formproduct->select_measuring_units("surface_units","surface"); |
|
| 1051 | - print '</td></tr>'; |
|
| 1052 | - } |
|
| 1053 | - // Volume |
|
| 1054 | - print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="3">'; |
|
| 1055 | - print '<input name="volume" size="4" value="'.GETPOST('volume').'">'; |
|
| 1056 | - print $formproduct->select_measuring_units("volume_units","volume"); |
|
| 1057 | - print '</td></tr>'; |
|
| 1058 | - } |
|
| 1059 | - |
|
| 1060 | - // Units |
|
| 1061 | - if($conf->global->PRODUCT_USE_UNITS) |
|
| 1062 | - { |
|
| 1063 | - print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>'; |
|
| 1064 | - print '<td colspan="3">'; |
|
| 1065 | - print $form->selectUnits('','units'); |
|
| 1066 | - print '</td></tr>'; |
|
| 1067 | - } |
|
| 1068 | - |
|
| 1069 | - // Custom code |
|
| 1070 | - if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO) && empty($type)) |
|
| 1071 | - { |
|
| 1072 | - print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.GETPOST('customcode').'"></td>'; |
|
| 1073 | - // Origin country |
|
| 1074 | - print '<td>'.$langs->trans("CountryOrigin").'</td><td>'; |
|
| 1075 | - print $form->select_country(GETPOST('country_id','int'),'country_id'); |
|
| 1076 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 1077 | - print '</td></tr>'; |
|
| 1078 | - } |
|
| 1079 | - |
|
| 1080 | - // Other attributes |
|
| 1081 | - $parameters=array('cols' => 3); |
|
| 1082 | - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 1083 | - print $hookmanager->resPrint; |
|
| 1084 | - if (empty($reshook) && ! empty($extrafields->attribute_label)) |
|
| 1085 | - { |
|
| 1086 | - print $object->showOptionals($extrafields,'edit',$parameters); |
|
| 1087 | - } |
|
| 1088 | - |
|
| 1089 | - // Note (private, no output on invoices, propales...) |
|
| 1090 | - //if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) available in create mode |
|
| 1091 | - //{ |
|
| 1092 | - print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">'; |
|
| 1093 | - |
|
| 1094 | - // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. |
|
| 1095 | - $doleditor = new DolEditor('note_private', GETPOST('note_private'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_8, '90%'); |
|
| 1096 | - $doleditor->Create(); |
|
| 1097 | - |
|
| 1098 | - print "</td></tr>"; |
|
| 1099 | - //} |
|
| 988 | + print '</td></tr>'; |
|
| 989 | + |
|
| 990 | + // Stock min level |
|
| 991 | + if ($type != 1 && ! empty($conf->stock->enabled)) |
|
| 992 | + { |
|
| 993 | + print '<tr><td>'.$form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1).'</td><td>'; |
|
| 994 | + print '<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST('seuil_stock_alerte').'">'; |
|
| 995 | + print '</td>'; |
|
| 996 | + // Stock desired level |
|
| 997 | + print '<td>'.$form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1).'</td><td>'; |
|
| 998 | + print '<input name="desiredstock" class="maxwidth50" value="'.GETPOST('desiredstock').'">'; |
|
| 999 | + print '</td></tr>'; |
|
| 1000 | + } |
|
| 1001 | + else |
|
| 1002 | + { |
|
| 1003 | + print '<input name="seuil_stock_alerte" type="hidden" value="0">'; |
|
| 1004 | + print '<input name="desiredstock" type="hidden" value="0">'; |
|
| 1005 | + } |
|
| 1006 | + |
|
| 1007 | + // Nature |
|
| 1008 | + if ($type != 1) |
|
| 1009 | + { |
|
| 1010 | + print '<tr><td>'.$langs->trans("Nature").'</td><td colspan="3">'; |
|
| 1011 | + $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); |
|
| 1012 | + print $form->selectarray('finished',$statutarray,GETPOST('finished'),1); |
|
| 1013 | + print '</td></tr>'; |
|
| 1014 | + } |
|
| 1015 | + |
|
| 1016 | + // Duration |
|
| 1017 | + if ($type == 1) |
|
| 1018 | + { |
|
| 1019 | + print '<tr><td>' . $langs->trans("Duration") . '</td><td colspan="3"><input name="duration_value" size="6" maxlength="5" value="' . $duration_value . '"> '; |
|
| 1020 | + print '<input name="duration_unit" type="radio" value="h">'.$langs->trans("Hour").' '; |
|
| 1021 | + print '<input name="duration_unit" type="radio" value="d">'.$langs->trans("Day").' '; |
|
| 1022 | + print '<input name="duration_unit" type="radio" value="w">'.$langs->trans("Week").' '; |
|
| 1023 | + print '<input name="duration_unit" type="radio" value="m">'.$langs->trans("Month").' '; |
|
| 1024 | + print '<input name="duration_unit" type="radio" value="y">'.$langs->trans("Year").' '; |
|
| 1025 | + print '</td></tr>'; |
|
| 1026 | + } |
|
| 1027 | + |
|
| 1028 | + if ($type != 1) // Le poids et le volume ne concerne que les produits et pas les services |
|
| 1029 | + { |
|
| 1030 | + // Weight |
|
| 1031 | + print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="3">'; |
|
| 1032 | + print '<input name="weight" size="4" value="'.GETPOST('weight').'">'; |
|
| 1033 | + print $formproduct->select_measuring_units("weight_units","weight"); |
|
| 1034 | + print '</td></tr>'; |
|
| 1035 | + // Length |
|
| 1036 | + if (empty($conf->global->PRODUCT_DISABLE_SIZE)) |
|
| 1037 | + { |
|
| 1038 | + print '<tr><td>'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").'</td><td colspan="3">'; |
|
| 1039 | + print '<input name="size" size="4" value="'.GETPOST('size').'"> x '; |
|
| 1040 | + print '<input name="sizewidth" size="4" value="'.GETPOST('sizewidth').'"> x '; |
|
| 1041 | + print '<input name="sizeheight" size="4" value="'.GETPOST('sizeheight').'">'; |
|
| 1042 | + print $formproduct->select_measuring_units("size_units","size"); |
|
| 1043 | + print '</td></tr>'; |
|
| 1044 | + } |
|
| 1045 | + if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) |
|
| 1046 | + { |
|
| 1047 | + // Surface |
|
| 1048 | + print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="3">'; |
|
| 1049 | + print '<input name="surface" size="4" value="'.GETPOST('surface').'">'; |
|
| 1050 | + print $formproduct->select_measuring_units("surface_units","surface"); |
|
| 1051 | + print '</td></tr>'; |
|
| 1052 | + } |
|
| 1053 | + // Volume |
|
| 1054 | + print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="3">'; |
|
| 1055 | + print '<input name="volume" size="4" value="'.GETPOST('volume').'">'; |
|
| 1056 | + print $formproduct->select_measuring_units("volume_units","volume"); |
|
| 1057 | + print '</td></tr>'; |
|
| 1058 | + } |
|
| 1059 | + |
|
| 1060 | + // Units |
|
| 1061 | + if($conf->global->PRODUCT_USE_UNITS) |
|
| 1062 | + { |
|
| 1063 | + print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>'; |
|
| 1064 | + print '<td colspan="3">'; |
|
| 1065 | + print $form->selectUnits('','units'); |
|
| 1066 | + print '</td></tr>'; |
|
| 1067 | + } |
|
| 1068 | + |
|
| 1069 | + // Custom code |
|
| 1070 | + if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO) && empty($type)) |
|
| 1071 | + { |
|
| 1072 | + print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.GETPOST('customcode').'"></td>'; |
|
| 1073 | + // Origin country |
|
| 1074 | + print '<td>'.$langs->trans("CountryOrigin").'</td><td>'; |
|
| 1075 | + print $form->select_country(GETPOST('country_id','int'),'country_id'); |
|
| 1076 | + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 1077 | + print '</td></tr>'; |
|
| 1078 | + } |
|
| 1079 | + |
|
| 1080 | + // Other attributes |
|
| 1081 | + $parameters=array('cols' => 3); |
|
| 1082 | + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 1083 | + print $hookmanager->resPrint; |
|
| 1084 | + if (empty($reshook) && ! empty($extrafields->attribute_label)) |
|
| 1085 | + { |
|
| 1086 | + print $object->showOptionals($extrafields,'edit',$parameters); |
|
| 1087 | + } |
|
| 1088 | + |
|
| 1089 | + // Note (private, no output on invoices, propales...) |
|
| 1090 | + //if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) available in create mode |
|
| 1091 | + //{ |
|
| 1092 | + print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">'; |
|
| 1093 | + |
|
| 1094 | + // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. |
|
| 1095 | + $doleditor = new DolEditor('note_private', GETPOST('note_private'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_8, '90%'); |
|
| 1096 | + $doleditor->Create(); |
|
| 1097 | + |
|
| 1098 | + print "</td></tr>"; |
|
| 1099 | + //} |
|
| 1100 | 1100 | |
| 1101 | 1101 | if($conf->categorie->enabled) { |
| 1102 | 1102 | // Categories |
@@ -1106,150 +1106,150 @@ discard block |
||
| 1106 | 1106 | print "</td></tr>"; |
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | - print '</table>'; |
|
| 1109 | + print '</table>'; |
|
| 1110 | 1110 | |
| 1111 | - print '<br>'; |
|
| 1111 | + print '<br>'; |
|
| 1112 | 1112 | |
| 1113 | - if (! empty($conf->global->PRODUIT_MULTIPRICES)) |
|
| 1114 | - { |
|
| 1115 | - // We do no show price array on create when multiprices enabled. |
|
| 1116 | - // We must set them on prices tab. |
|
| 1117 | - } |
|
| 1118 | - else |
|
| 1113 | + if (! empty($conf->global->PRODUIT_MULTIPRICES)) |
|
| 1114 | + { |
|
| 1115 | + // We do no show price array on create when multiprices enabled. |
|
| 1116 | + // We must set them on prices tab. |
|
| 1117 | + } |
|
| 1118 | + else |
|
| 1119 | 1119 | { |
| 1120 | - print '<table class="border" width="100%">'; |
|
| 1120 | + print '<table class="border" width="100%">'; |
|
| 1121 | 1121 | |
| 1122 | - // Price |
|
| 1123 | - print '<tr><td class="titlefieldcreate">'.$langs->trans("SellingPrice").'</td>'; |
|
| 1124 | - print '<td><input name="price" class="maxwidth50" value="'.$object->price.'">'; |
|
| 1125 | - print $form->selectPriceBaseType($object->price_base_type, "price_base_type"); |
|
| 1126 | - print '</td></tr>'; |
|
| 1122 | + // Price |
|
| 1123 | + print '<tr><td class="titlefieldcreate">'.$langs->trans("SellingPrice").'</td>'; |
|
| 1124 | + print '<td><input name="price" class="maxwidth50" value="'.$object->price.'">'; |
|
| 1125 | + print $form->selectPriceBaseType($object->price_base_type, "price_base_type"); |
|
| 1126 | + print '</td></tr>'; |
|
| 1127 | 1127 | |
| 1128 | - // Min price |
|
| 1129 | - print '<tr><td>'.$langs->trans("MinPrice").'</td>'; |
|
| 1130 | - print '<td><input name="price_min" class="maxwidth50" value="'.$object->price_min.'">'; |
|
| 1131 | - print '</td></tr>'; |
|
| 1128 | + // Min price |
|
| 1129 | + print '<tr><td>'.$langs->trans("MinPrice").'</td>'; |
|
| 1130 | + print '<td><input name="price_min" class="maxwidth50" value="'.$object->price_min.'">'; |
|
| 1131 | + print '</td></tr>'; |
|
| 1132 | 1132 | |
| 1133 | - // VAT |
|
| 1134 | - print '<tr><td>'.$langs->trans("VATRate").'</td><td>'; |
|
| 1135 | - $defaultva=get_default_tva($mysoc, $mysoc); |
|
| 1136 | - print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1); |
|
| 1137 | - print '</td></tr>'; |
|
| 1133 | + // VAT |
|
| 1134 | + print '<tr><td>'.$langs->trans("VATRate").'</td><td>'; |
|
| 1135 | + $defaultva=get_default_tva($mysoc, $mysoc); |
|
| 1136 | + print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1); |
|
| 1137 | + print '</td></tr>'; |
|
| 1138 | 1138 | |
| 1139 | - print '</table>'; |
|
| 1139 | + print '</table>'; |
|
| 1140 | 1140 | |
| 1141 | - print '<br>'; |
|
| 1142 | - } |
|
| 1141 | + print '<br>'; |
|
| 1142 | + } |
|
| 1143 | 1143 | |
| 1144 | - // Accountancy codes |
|
| 1145 | - print '<table class="border" width="100%">'; |
|
| 1144 | + // Accountancy codes |
|
| 1145 | + print '<table class="border" width="100%">'; |
|
| 1146 | 1146 | |
| 1147 | 1147 | if (! empty($conf->accounting->enabled)) |
| 1148 | 1148 | { |
| 1149 | - // Accountancy_code_sell |
|
| 1150 | - print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>'; |
|
| 1151 | - print '<td>'; |
|
| 1152 | - print $formaccounting->select_account(GETPOST('accountancy_code_sell'), 'accountancy_code_sell', 1, null, 1, 1, ''); |
|
| 1153 | - print '</td></tr>'; |
|
| 1149 | + // Accountancy_code_sell |
|
| 1150 | + print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>'; |
|
| 1151 | + print '<td>'; |
|
| 1152 | + print $formaccounting->select_account(GETPOST('accountancy_code_sell'), 'accountancy_code_sell', 1, null, 1, 1, ''); |
|
| 1153 | + print '</td></tr>'; |
|
| 1154 | 1154 | |
| 1155 | - // Accountancy_code_buy |
|
| 1156 | - print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>'; |
|
| 1157 | - print '<td>'; |
|
| 1155 | + // Accountancy_code_buy |
|
| 1156 | + print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>'; |
|
| 1157 | + print '<td>'; |
|
| 1158 | 1158 | print $formaccounting->select_account(GETPOST('accountancy_code_buy'), 'accountancy_code_buy', 1, null, 1, 1, ''); |
| 1159 | - print '</td></tr>'; |
|
| 1159 | + print '</td></tr>'; |
|
| 1160 | 1160 | } |
| 1161 | 1161 | else // For external software |
| 1162 | 1162 | { |
| 1163 | - // Accountancy_code_sell |
|
| 1164 | - print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>'; |
|
| 1165 | - print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.'">'; |
|
| 1166 | - print '</td></tr>'; |
|
| 1163 | + // Accountancy_code_sell |
|
| 1164 | + print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>'; |
|
| 1165 | + print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.'">'; |
|
| 1166 | + print '</td></tr>'; |
|
| 1167 | 1167 | |
| 1168 | - // Accountancy_code_buy |
|
| 1169 | - print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>'; |
|
| 1170 | - print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.'">'; |
|
| 1171 | - print '</td></tr>'; |
|
| 1172 | - } |
|
| 1168 | + // Accountancy_code_buy |
|
| 1169 | + print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>'; |
|
| 1170 | + print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.'">'; |
|
| 1171 | + print '</td></tr>'; |
|
| 1172 | + } |
|
| 1173 | 1173 | print '</table>'; |
| 1174 | 1174 | |
| 1175 | - dol_fiche_end(); |
|
| 1175 | + dol_fiche_end(); |
|
| 1176 | 1176 | |
| 1177 | 1177 | print '<div class="center">'; |
| 1178 | 1178 | print '<input type="submit" class="button" value="' . $langs->trans("Create") . '">'; |
| 1179 | - print ' '; |
|
| 1179 | + print ' '; |
|
| 1180 | 1180 | print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">'; |
| 1181 | 1181 | print '</div>'; |
| 1182 | 1182 | |
| 1183 | - print '</form>'; |
|
| 1184 | - } |
|
| 1183 | + print '</form>'; |
|
| 1184 | + } |
|
| 1185 | 1185 | |
| 1186 | - /* |
|
| 1186 | + /* |
|
| 1187 | 1187 | * Product card |
| 1188 | 1188 | */ |
| 1189 | 1189 | |
| 1190 | - else if ($object->id > 0) |
|
| 1191 | - { |
|
| 1192 | - // Fiche en mode edition |
|
| 1193 | - if ($action == 'edit' && ((($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)))) |
|
| 1194 | - { |
|
| 1195 | - //WYSIWYG Editor |
|
| 1196 | - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
| 1197 | - |
|
| 1198 | - $type = $langs->trans('Product'); |
|
| 1199 | - if ($object->isService()) $type = $langs->trans('Service'); |
|
| 1200 | - //print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), ""); |
|
| 1201 | - |
|
| 1202 | - // Main official, simple, and not duplicated code |
|
| 1203 | - print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">'."\n"; |
|
| 1204 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 1205 | - print '<input type="hidden" name="action" value="update">'; |
|
| 1206 | - print '<input type="hidden" name="id" value="'.$object->id.'">'; |
|
| 1207 | - print '<input type="hidden" name="canvas" value="'.$object->canvas.'">'; |
|
| 1208 | - |
|
| 1209 | - $head=product_prepare_head($object); |
|
| 1210 | - $titre=$langs->trans("CardProduct".$object->type); |
|
| 1211 | - $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); |
|
| 1212 | - dol_fiche_head($head, 'card', $titre, 0, $picto); |
|
| 1213 | - |
|
| 1214 | - print '<table class="border allwidth">'; |
|
| 1215 | - |
|
| 1216 | - // Ref |
|
| 1217 | - print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input name="ref" class="maxwidth200" maxlength="128" value="'.dol_escape_htmltag($object->ref).'"></td></tr>'; |
|
| 1218 | - |
|
| 1219 | - // Label |
|
| 1220 | - print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="'.dol_escape_htmltag($object->label).'"></td></tr>'; |
|
| 1221 | - |
|
| 1222 | - // Status To sell |
|
| 1223 | - print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="3">'; |
|
| 1224 | - print '<select class="flat" name="statut">'; |
|
| 1225 | - if ($object->status) |
|
| 1226 | - { |
|
| 1227 | - print '<option value="1" selected>'.$langs->trans("OnSell").'</option>'; |
|
| 1228 | - print '<option value="0">'.$langs->trans("NotOnSell").'</option>'; |
|
| 1229 | - } |
|
| 1230 | - else |
|
| 1231 | - { |
|
| 1232 | - print '<option value="1">'.$langs->trans("OnSell").'</option>'; |
|
| 1233 | - print '<option value="0" selected>'.$langs->trans("NotOnSell").'</option>'; |
|
| 1234 | - } |
|
| 1235 | - print '</select>'; |
|
| 1236 | - print '</td></tr>'; |
|
| 1190 | + else if ($object->id > 0) |
|
| 1191 | + { |
|
| 1192 | + // Fiche en mode edition |
|
| 1193 | + if ($action == 'edit' && ((($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)))) |
|
| 1194 | + { |
|
| 1195 | + //WYSIWYG Editor |
|
| 1196 | + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
| 1237 | 1197 | |
| 1238 | - // Status To Buy |
|
| 1239 | - print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="3">'; |
|
| 1240 | - print '<select class="flat" name="statut_buy">'; |
|
| 1241 | - if ($object->status_buy) |
|
| 1242 | - { |
|
| 1243 | - print '<option value="1" selected>'.$langs->trans("ProductStatusOnBuy").'</option>'; |
|
| 1244 | - print '<option value="0">'.$langs->trans("ProductStatusNotOnBuy").'</option>'; |
|
| 1245 | - } |
|
| 1246 | - else |
|
| 1247 | - { |
|
| 1248 | - print '<option value="1">'.$langs->trans("ProductStatusOnBuy").'</option>'; |
|
| 1249 | - print '<option value="0" selected>'.$langs->trans("ProductStatusNotOnBuy").'</option>'; |
|
| 1250 | - } |
|
| 1251 | - print '</select>'; |
|
| 1252 | - print '</td></tr>'; |
|
| 1198 | + $type = $langs->trans('Product'); |
|
| 1199 | + if ($object->isService()) $type = $langs->trans('Service'); |
|
| 1200 | + //print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), ""); |
|
| 1201 | + |
|
| 1202 | + // Main official, simple, and not duplicated code |
|
| 1203 | + print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">'."\n"; |
|
| 1204 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 1205 | + print '<input type="hidden" name="action" value="update">'; |
|
| 1206 | + print '<input type="hidden" name="id" value="'.$object->id.'">'; |
|
| 1207 | + print '<input type="hidden" name="canvas" value="'.$object->canvas.'">'; |
|
| 1208 | + |
|
| 1209 | + $head=product_prepare_head($object); |
|
| 1210 | + $titre=$langs->trans("CardProduct".$object->type); |
|
| 1211 | + $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); |
|
| 1212 | + dol_fiche_head($head, 'card', $titre, 0, $picto); |
|
| 1213 | + |
|
| 1214 | + print '<table class="border allwidth">'; |
|
| 1215 | + |
|
| 1216 | + // Ref |
|
| 1217 | + print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input name="ref" class="maxwidth200" maxlength="128" value="'.dol_escape_htmltag($object->ref).'"></td></tr>'; |
|
| 1218 | + |
|
| 1219 | + // Label |
|
| 1220 | + print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="'.dol_escape_htmltag($object->label).'"></td></tr>'; |
|
| 1221 | + |
|
| 1222 | + // Status To sell |
|
| 1223 | + print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="3">'; |
|
| 1224 | + print '<select class="flat" name="statut">'; |
|
| 1225 | + if ($object->status) |
|
| 1226 | + { |
|
| 1227 | + print '<option value="1" selected>'.$langs->trans("OnSell").'</option>'; |
|
| 1228 | + print '<option value="0">'.$langs->trans("NotOnSell").'</option>'; |
|
| 1229 | + } |
|
| 1230 | + else |
|
| 1231 | + { |
|
| 1232 | + print '<option value="1">'.$langs->trans("OnSell").'</option>'; |
|
| 1233 | + print '<option value="0" selected>'.$langs->trans("NotOnSell").'</option>'; |
|
| 1234 | + } |
|
| 1235 | + print '</select>'; |
|
| 1236 | + print '</td></tr>'; |
|
| 1237 | + |
|
| 1238 | + // Status To Buy |
|
| 1239 | + print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="3">'; |
|
| 1240 | + print '<select class="flat" name="statut_buy">'; |
|
| 1241 | + if ($object->status_buy) |
|
| 1242 | + { |
|
| 1243 | + print '<option value="1" selected>'.$langs->trans("ProductStatusOnBuy").'</option>'; |
|
| 1244 | + print '<option value="0">'.$langs->trans("ProductStatusNotOnBuy").'</option>'; |
|
| 1245 | + } |
|
| 1246 | + else |
|
| 1247 | + { |
|
| 1248 | + print '<option value="1">'.$langs->trans("ProductStatusOnBuy").'</option>'; |
|
| 1249 | + print '<option value="0" selected>'.$langs->trans("ProductStatusNotOnBuy").'</option>'; |
|
| 1250 | + } |
|
| 1251 | + print '</select>'; |
|
| 1252 | + print '</td></tr>'; |
|
| 1253 | 1253 | |
| 1254 | 1254 | // Batch number managment |
| 1255 | 1255 | if ($conf->productbatch->enabled) { |
@@ -1259,49 +1259,49 @@ discard block |
||
| 1259 | 1259 | print '</td></tr>'; |
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | - // Barcode |
|
| 1263 | - $showbarcode=empty($conf->barcode->enabled)?0:1; |
|
| 1264 | - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; |
|
| 1265 | - |
|
| 1266 | - if ($showbarcode) |
|
| 1267 | - { |
|
| 1268 | - print '<tr><td>'.$langs->trans('BarcodeType').'</td><td>'; |
|
| 1269 | - if (isset($_POST['fk_barcode_type'])) |
|
| 1270 | - { |
|
| 1271 | - $fk_barcode_type=GETPOST('fk_barcode_type'); |
|
| 1272 | - } |
|
| 1273 | - else |
|
| 1274 | - { |
|
| 1275 | - $fk_barcode_type=$object->barcode_type; |
|
| 1276 | - if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 1277 | - } |
|
| 1278 | - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; |
|
| 1279 | - $formbarcode = new FormBarCode($db); |
|
| 1280 | - print $formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); |
|
| 1281 | - print '</td><td>'.$langs->trans("BarcodeValue").'</td><td>'; |
|
| 1282 | - $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; |
|
| 1283 | - if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
|
| 1284 | - print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).'">'; |
|
| 1285 | - print '</td></tr>'; |
|
| 1286 | - } |
|
| 1287 | - |
|
| 1288 | - // Description (used in invoice, propal...) |
|
| 1289 | - print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">'; |
|
| 1290 | - |
|
| 1291 | - // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. |
|
| 1292 | - $doleditor = new DolEditor('desc', $object->description, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); |
|
| 1293 | - $doleditor->Create(); |
|
| 1294 | - |
|
| 1295 | - print "</td></tr>"; |
|
| 1296 | - print "\n"; |
|
| 1297 | - |
|
| 1298 | - // Public Url |
|
| 1299 | - print '<tr><td>'.$langs->trans("PublicUrl").'</td><td colspan="3">'; |
|
| 1262 | + // Barcode |
|
| 1263 | + $showbarcode=empty($conf->barcode->enabled)?0:1; |
|
| 1264 | + if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; |
|
| 1265 | + |
|
| 1266 | + if ($showbarcode) |
|
| 1267 | + { |
|
| 1268 | + print '<tr><td>'.$langs->trans('BarcodeType').'</td><td>'; |
|
| 1269 | + if (isset($_POST['fk_barcode_type'])) |
|
| 1270 | + { |
|
| 1271 | + $fk_barcode_type=GETPOST('fk_barcode_type'); |
|
| 1272 | + } |
|
| 1273 | + else |
|
| 1274 | + { |
|
| 1275 | + $fk_barcode_type=$object->barcode_type; |
|
| 1276 | + if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 1277 | + } |
|
| 1278 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; |
|
| 1279 | + $formbarcode = new FormBarCode($db); |
|
| 1280 | + print $formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); |
|
| 1281 | + print '</td><td>'.$langs->trans("BarcodeValue").'</td><td>'; |
|
| 1282 | + $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; |
|
| 1283 | + if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
|
| 1284 | + print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).'">'; |
|
| 1285 | + print '</td></tr>'; |
|
| 1286 | + } |
|
| 1287 | + |
|
| 1288 | + // Description (used in invoice, propal...) |
|
| 1289 | + print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">'; |
|
| 1290 | + |
|
| 1291 | + // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. |
|
| 1292 | + $doleditor = new DolEditor('desc', $object->description, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); |
|
| 1293 | + $doleditor->Create(); |
|
| 1294 | + |
|
| 1295 | + print "</td></tr>"; |
|
| 1296 | + print "\n"; |
|
| 1297 | + |
|
| 1298 | + // Public Url |
|
| 1299 | + print '<tr><td>'.$langs->trans("PublicUrl").'</td><td colspan="3">'; |
|
| 1300 | 1300 | print '<input type="text" name="url" class="quatrevingtpercent" value="'.$object->url.'">'; |
| 1301 | - print '</td></tr>'; |
|
| 1301 | + print '</td></tr>'; |
|
| 1302 | 1302 | |
| 1303 | - // Stock |
|
| 1304 | - /* |
|
| 1303 | + // Stock |
|
| 1304 | + /* |
|
| 1305 | 1305 | if ($object->isProduct() && ! empty($conf->stock->enabled)) |
| 1306 | 1306 | { |
| 1307 | 1307 | print "<tr>".'<td>'.$langs->trans("StockLimit").'</td><td>'; |
@@ -1318,97 +1318,97 @@ discard block |
||
| 1318 | 1318 | print '<input name="desiredstock" type="hidden" value="'.$object->desiredstock.'">'; |
| 1319 | 1319 | }*/ |
| 1320 | 1320 | |
| 1321 | - // Nature |
|
| 1322 | - if($object->type!= Product::TYPE_SERVICE) |
|
| 1323 | - { |
|
| 1324 | - print '<tr><td>'.$langs->trans("Nature").'</td><td colspan="3">'; |
|
| 1325 | - $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); |
|
| 1326 | - print $form->selectarray('finished',$statutarray,$object->finished); |
|
| 1327 | - print '</td></tr>'; |
|
| 1328 | - } |
|
| 1321 | + // Nature |
|
| 1322 | + if($object->type!= Product::TYPE_SERVICE) |
|
| 1323 | + { |
|
| 1324 | + print '<tr><td>'.$langs->trans("Nature").'</td><td colspan="3">'; |
|
| 1325 | + $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); |
|
| 1326 | + print $form->selectarray('finished',$statutarray,$object->finished); |
|
| 1327 | + print '</td></tr>'; |
|
| 1328 | + } |
|
| 1329 | 1329 | |
| 1330 | - if ($object->isService()) |
|
| 1331 | - { |
|
| 1332 | - // Duration |
|
| 1333 | - print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3"><input name="duration_value" size="3" maxlength="5" value="'.$object->duration_value.'">'; |
|
| 1334 | - print ' '; |
|
| 1335 | - print '<input name="duration_unit" type="radio" value="h"'.($object->duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour"); |
|
| 1336 | - print ' '; |
|
| 1337 | - print '<input name="duration_unit" type="radio" value="d"'.($object->duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); |
|
| 1338 | - print ' '; |
|
| 1339 | - print '<input name="duration_unit" type="radio" value="w"'.($object->duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); |
|
| 1340 | - print ' '; |
|
| 1341 | - print '<input name="duration_unit" type="radio" value="m"'.($object->duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); |
|
| 1342 | - print ' '; |
|
| 1343 | - print '<input name="duration_unit" type="radio" value="y"'.($object->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); |
|
| 1330 | + if ($object->isService()) |
|
| 1331 | + { |
|
| 1332 | + // Duration |
|
| 1333 | + print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3"><input name="duration_value" size="3" maxlength="5" value="'.$object->duration_value.'">'; |
|
| 1334 | + print ' '; |
|
| 1335 | + print '<input name="duration_unit" type="radio" value="h"'.($object->duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour"); |
|
| 1336 | + print ' '; |
|
| 1337 | + print '<input name="duration_unit" type="radio" value="d"'.($object->duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); |
|
| 1338 | + print ' '; |
|
| 1339 | + print '<input name="duration_unit" type="radio" value="w"'.($object->duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); |
|
| 1340 | + print ' '; |
|
| 1341 | + print '<input name="duration_unit" type="radio" value="m"'.($object->duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); |
|
| 1342 | + print ' '; |
|
| 1343 | + print '<input name="duration_unit" type="radio" value="y"'.($object->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); |
|
| 1344 | 1344 | |
| 1345 | - print '</td></tr>'; |
|
| 1346 | - } |
|
| 1347 | - else |
|
| 1345 | + print '</td></tr>'; |
|
| 1346 | + } |
|
| 1347 | + else |
|
| 1348 | 1348 | { |
| 1349 | - // Weight |
|
| 1350 | - print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="3">'; |
|
| 1351 | - print '<input name="weight" size="5" value="'.$object->weight.'"> '; |
|
| 1352 | - print $formproduct->select_measuring_units("weight_units", "weight", $object->weight_units); |
|
| 1353 | - print '</td></tr>'; |
|
| 1354 | - if (empty($conf->global->PRODUCT_DISABLE_SIZE)) |
|
| 1355 | - { |
|
| 1356 | - // Length |
|
| 1357 | - print '<tr><td>'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").'</td><td colspan="3">'; |
|
| 1358 | - print '<input name="size" size="5" value="'.$object->length.'">x'; |
|
| 1359 | - print '<input name="sizewidth" size="5" value="'.$object->width.'">x'; |
|
| 1360 | - print '<input name="sizeheight" size="5" value="'.$object->height.'"> '; |
|
| 1361 | - print $formproduct->select_measuring_units("size_units", "size", $object->length_units); |
|
| 1362 | - print '</td></tr>'; |
|
| 1363 | - } |
|
| 1364 | - if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) |
|
| 1365 | - { |
|
| 1366 | - // Surface |
|
| 1367 | - print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="3">'; |
|
| 1368 | - print '<input name="surface" size="5" value="'.$object->surface.'"> '; |
|
| 1369 | - print $formproduct->select_measuring_units("surface_units", "surface", $object->surface_units); |
|
| 1370 | - print '</td></tr>'; |
|
| 1371 | - } |
|
| 1372 | - if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) |
|
| 1373 | - { |
|
| 1374 | - // Volume |
|
| 1375 | - print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="3">'; |
|
| 1376 | - print '<input name="volume" size="5" value="'.$object->volume.'"> '; |
|
| 1377 | - print $formproduct->select_measuring_units("volume_units", "volume", $object->volume_units); |
|
| 1378 | - print '</td></tr>'; |
|
| 1379 | - } |
|
| 1380 | - } |
|
| 1381 | - // Units |
|
| 1382 | - if($conf->global->PRODUCT_USE_UNITS) |
|
| 1383 | - { |
|
| 1384 | - print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>'; |
|
| 1385 | - print '<td colspan="3">'; |
|
| 1386 | - print $form->selectUnits($object->fk_unit, 'units'); |
|
| 1387 | - print '</td></tr>'; |
|
| 1388 | - } |
|
| 1389 | - |
|
| 1390 | - // Custom code |
|
| 1391 | - if (! $object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) |
|
| 1392 | - { |
|
| 1393 | - print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.$object->customcode.'"></td>'; |
|
| 1394 | - // Origin country |
|
| 1395 | - print '<td>'.$langs->trans("CountryOrigin").'</td><td>'; |
|
| 1396 | - print $form->select_country($object->country_id, 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone'); |
|
| 1397 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 1398 | - print '</td></tr>'; |
|
| 1399 | - } |
|
| 1400 | - |
|
| 1401 | - // Other attributes |
|
| 1402 | - $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); |
|
| 1403 | - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 1404 | - print $hookmanager->resPrint; |
|
| 1405 | - if (empty($reshook) && ! empty($extrafields->attribute_label)) |
|
| 1406 | - { |
|
| 1407 | - print $object->showOptionals($extrafields,'edit'); |
|
| 1408 | - } |
|
| 1349 | + // Weight |
|
| 1350 | + print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="3">'; |
|
| 1351 | + print '<input name="weight" size="5" value="'.$object->weight.'"> '; |
|
| 1352 | + print $formproduct->select_measuring_units("weight_units", "weight", $object->weight_units); |
|
| 1353 | + print '</td></tr>'; |
|
| 1354 | + if (empty($conf->global->PRODUCT_DISABLE_SIZE)) |
|
| 1355 | + { |
|
| 1356 | + // Length |
|
| 1357 | + print '<tr><td>'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").'</td><td colspan="3">'; |
|
| 1358 | + print '<input name="size" size="5" value="'.$object->length.'">x'; |
|
| 1359 | + print '<input name="sizewidth" size="5" value="'.$object->width.'">x'; |
|
| 1360 | + print '<input name="sizeheight" size="5" value="'.$object->height.'"> '; |
|
| 1361 | + print $formproduct->select_measuring_units("size_units", "size", $object->length_units); |
|
| 1362 | + print '</td></tr>'; |
|
| 1363 | + } |
|
| 1364 | + if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) |
|
| 1365 | + { |
|
| 1366 | + // Surface |
|
| 1367 | + print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="3">'; |
|
| 1368 | + print '<input name="surface" size="5" value="'.$object->surface.'"> '; |
|
| 1369 | + print $formproduct->select_measuring_units("surface_units", "surface", $object->surface_units); |
|
| 1370 | + print '</td></tr>'; |
|
| 1371 | + } |
|
| 1372 | + if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) |
|
| 1373 | + { |
|
| 1374 | + // Volume |
|
| 1375 | + print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="3">'; |
|
| 1376 | + print '<input name="volume" size="5" value="'.$object->volume.'"> '; |
|
| 1377 | + print $formproduct->select_measuring_units("volume_units", "volume", $object->volume_units); |
|
| 1378 | + print '</td></tr>'; |
|
| 1379 | + } |
|
| 1380 | + } |
|
| 1381 | + // Units |
|
| 1382 | + if($conf->global->PRODUCT_USE_UNITS) |
|
| 1383 | + { |
|
| 1384 | + print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>'; |
|
| 1385 | + print '<td colspan="3">'; |
|
| 1386 | + print $form->selectUnits($object->fk_unit, 'units'); |
|
| 1387 | + print '</td></tr>'; |
|
| 1388 | + } |
|
| 1389 | + |
|
| 1390 | + // Custom code |
|
| 1391 | + if (! $object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) |
|
| 1392 | + { |
|
| 1393 | + print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.$object->customcode.'"></td>'; |
|
| 1394 | + // Origin country |
|
| 1395 | + print '<td>'.$langs->trans("CountryOrigin").'</td><td>'; |
|
| 1396 | + print $form->select_country($object->country_id, 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone'); |
|
| 1397 | + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 1398 | + print '</td></tr>'; |
|
| 1399 | + } |
|
| 1400 | + |
|
| 1401 | + // Other attributes |
|
| 1402 | + $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); |
|
| 1403 | + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 1404 | + print $hookmanager->resPrint; |
|
| 1405 | + if (empty($reshook) && ! empty($extrafields->attribute_label)) |
|
| 1406 | + { |
|
| 1407 | + print $object->showOptionals($extrafields,'edit'); |
|
| 1408 | + } |
|
| 1409 | 1409 | |
| 1410 | 1410 | // Tags-Categories |
| 1411 | - if ($conf->categorie->enabled) |
|
| 1411 | + if ($conf->categorie->enabled) |
|
| 1412 | 1412 | { |
| 1413 | 1413 | print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td colspan="3">'; |
| 1414 | 1414 | $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); |
@@ -1421,134 +1421,134 @@ discard block |
||
| 1421 | 1421 | print "</td></tr>"; |
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | - // Note private |
|
| 1424 | + // Note private |
|
| 1425 | 1425 | if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
| 1426 | 1426 | { |
| 1427 | - print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">'; |
|
| 1427 | + print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">'; |
|
| 1428 | 1428 | |
| 1429 | - $doleditor = new DolEditor('note_private', $object->note_private, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); |
|
| 1430 | - $doleditor->Create(); |
|
| 1429 | + $doleditor = new DolEditor('note_private', $object->note_private, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); |
|
| 1430 | + $doleditor->Create(); |
|
| 1431 | 1431 | |
| 1432 | - print "</td></tr>"; |
|
| 1432 | + print "</td></tr>"; |
|
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | - print '</table>'; |
|
| 1435 | + print '</table>'; |
|
| 1436 | 1436 | |
| 1437 | - print '<br>'; |
|
| 1437 | + print '<br>'; |
|
| 1438 | 1438 | |
| 1439 | - print '<table class="border" width="100%">'; |
|
| 1439 | + print '<table class="border" width="100%">'; |
|
| 1440 | 1440 | |
| 1441 | 1441 | if (! empty($conf->accounting->enabled)) |
| 1442 | 1442 | { |
| 1443 | - // Accountancy_code_sell |
|
| 1444 | - print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>'; |
|
| 1445 | - print '<td>'; |
|
| 1443 | + // Accountancy_code_sell |
|
| 1444 | + print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>'; |
|
| 1445 | + print '<td>'; |
|
| 1446 | 1446 | print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1); |
| 1447 | - print '</td></tr>'; |
|
| 1447 | + print '</td></tr>'; |
|
| 1448 | 1448 | |
| 1449 | - // Accountancy_code_buy |
|
| 1450 | - print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>'; |
|
| 1451 | - print '<td>'; |
|
| 1449 | + // Accountancy_code_buy |
|
| 1450 | + print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>'; |
|
| 1451 | + print '<td>'; |
|
| 1452 | 1452 | print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1); |
| 1453 | - print '</td></tr>'; |
|
| 1453 | + print '</td></tr>'; |
|
| 1454 | 1454 | } |
| 1455 | 1455 | else // For external software |
| 1456 | 1456 | { |
| 1457 | - // Accountancy_code_sell |
|
| 1458 | - print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>'; |
|
| 1459 | - print '<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.'">'; |
|
| 1460 | - print '</td></tr>'; |
|
| 1457 | + // Accountancy_code_sell |
|
| 1458 | + print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>'; |
|
| 1459 | + print '<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.'">'; |
|
| 1460 | + print '</td></tr>'; |
|
| 1461 | 1461 | |
| 1462 | - // Accountancy_code_buy |
|
| 1463 | - print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>'; |
|
| 1464 | - print '<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.'">'; |
|
| 1465 | - print '</td></tr>'; |
|
| 1466 | - } |
|
| 1462 | + // Accountancy_code_buy |
|
| 1463 | + print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>'; |
|
| 1464 | + print '<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.'">'; |
|
| 1465 | + print '</td></tr>'; |
|
| 1466 | + } |
|
| 1467 | 1467 | print '</table>'; |
| 1468 | 1468 | |
| 1469 | - dol_fiche_end(); |
|
| 1469 | + dol_fiche_end(); |
|
| 1470 | 1470 | |
| 1471 | - print '<div class="center">'; |
|
| 1471 | + print '<div class="center">'; |
|
| 1472 | 1472 | print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; |
| 1473 | 1473 | print ' '; |
| 1474 | - print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; |
|
| 1474 | + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; |
|
| 1475 | 1475 | print '</div>'; |
| 1476 | 1476 | |
| 1477 | - print '</form>'; |
|
| 1478 | - } |
|
| 1479 | - // Fiche en mode visu |
|
| 1480 | - else |
|
| 1477 | + print '</form>'; |
|
| 1478 | + } |
|
| 1479 | + // Fiche en mode visu |
|
| 1480 | + else |
|
| 1481 | 1481 | { |
| 1482 | - $showbarcode=empty($conf->barcode->enabled)?0:1; |
|
| 1483 | - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; |
|
| 1482 | + $showbarcode=empty($conf->barcode->enabled)?0:1; |
|
| 1483 | + if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; |
|
| 1484 | 1484 | |
| 1485 | - $head=product_prepare_head($object); |
|
| 1486 | - $titre=$langs->trans("CardProduct".$object->type); |
|
| 1487 | - $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); |
|
| 1485 | + $head=product_prepare_head($object); |
|
| 1486 | + $titre=$langs->trans("CardProduct".$object->type); |
|
| 1487 | + $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); |
|
| 1488 | 1488 | |
| 1489 | - dol_fiche_head($head, 'card', $titre, -1, $picto); |
|
| 1489 | + dol_fiche_head($head, 'card', $titre, -1, $picto); |
|
| 1490 | 1490 | |
| 1491 | - $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'">'.$langs->trans("BackToList").'</a>'; |
|
| 1492 | - $object->next_prev_filter=" fk_product_type = ".$object->type; |
|
| 1491 | + $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'">'.$langs->trans("BackToList").'</a>'; |
|
| 1492 | + $object->next_prev_filter=" fk_product_type = ".$object->type; |
|
| 1493 | 1493 | |
| 1494 | - $shownav = 1; |
|
| 1495 | - if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; |
|
| 1494 | + $shownav = 1; |
|
| 1495 | + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; |
|
| 1496 | 1496 | |
| 1497 | - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); |
|
| 1497 | + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); |
|
| 1498 | 1498 | |
| 1499 | 1499 | |
| 1500 | - print '<div class="fichecenter">'; |
|
| 1501 | - print '<div class="fichehalfleft">'; |
|
| 1500 | + print '<div class="fichecenter">'; |
|
| 1501 | + print '<div class="fichehalfleft">'; |
|
| 1502 | 1502 | |
| 1503 | - print '<div class="underbanner clearboth"></div>'; |
|
| 1504 | - print '<table class="border tableforfield" width="100%">'; |
|
| 1503 | + print '<div class="underbanner clearboth"></div>'; |
|
| 1504 | + print '<table class="border tableforfield" width="100%">'; |
|
| 1505 | 1505 | |
| 1506 | - // Type |
|
| 1507 | - if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) |
|
| 1508 | - { |
|
| 1509 | - // TODO change for compatibility with edit in place |
|
| 1510 | - $typeformat='select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); |
|
| 1511 | - print '<tr><td class="titlefield">'.$form->editfieldkey("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat).'</td><td colspan="2">'; |
|
| 1512 | - print $form->editfieldval("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat); |
|
| 1513 | - print '</td></tr>'; |
|
| 1514 | - } |
|
| 1506 | + // Type |
|
| 1507 | + if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) |
|
| 1508 | + { |
|
| 1509 | + // TODO change for compatibility with edit in place |
|
| 1510 | + $typeformat='select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); |
|
| 1511 | + print '<tr><td class="titlefield">'.$form->editfieldkey("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat).'</td><td colspan="2">'; |
|
| 1512 | + print $form->editfieldval("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat); |
|
| 1513 | + print '</td></tr>'; |
|
| 1514 | + } |
|
| 1515 | 1515 | |
| 1516 | - if ($showbarcode) |
|
| 1517 | - { |
|
| 1518 | - // Barcode type |
|
| 1519 | - print '<tr><td class="nowrap">'; |
|
| 1520 | - print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
|
| 1521 | - print $langs->trans("BarcodeType"); |
|
| 1522 | - print '</td>'; |
|
| 1523 | - if (($action != 'editbarcodetype') && ! empty($user->rights->produit->creer) && $createbarcode) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>'; |
|
| 1524 | - print '</tr></table>'; |
|
| 1525 | - print '</td><td colspan="2">'; |
|
| 1526 | - if ($action == 'editbarcodetype' || $action == 'editbarcode') |
|
| 1527 | - { |
|
| 1528 | - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; |
|
| 1529 | - $formbarcode = new FormBarCode($db); |
|
| 1516 | + if ($showbarcode) |
|
| 1517 | + { |
|
| 1518 | + // Barcode type |
|
| 1519 | + print '<tr><td class="nowrap">'; |
|
| 1520 | + print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
|
| 1521 | + print $langs->trans("BarcodeType"); |
|
| 1522 | + print '</td>'; |
|
| 1523 | + if (($action != 'editbarcodetype') && ! empty($user->rights->produit->creer) && $createbarcode) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>'; |
|
| 1524 | + print '</tr></table>'; |
|
| 1525 | + print '</td><td colspan="2">'; |
|
| 1526 | + if ($action == 'editbarcodetype' || $action == 'editbarcode') |
|
| 1527 | + { |
|
| 1528 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; |
|
| 1529 | + $formbarcode = new FormBarCode($db); |
|
| 1530 | 1530 | } |
| 1531 | - if ($action == 'editbarcodetype') |
|
| 1532 | - { |
|
| 1533 | - $formbarcode->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$object->id,$object->barcode_type,'fk_barcode_type'); |
|
| 1534 | - } |
|
| 1535 | - else |
|
| 1536 | - { |
|
| 1537 | - $object->fetch_barcode(); |
|
| 1538 | - print $object->barcode_type_label?$object->barcode_type_label:($object->barcode?'<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>':''); |
|
| 1539 | - } |
|
| 1540 | - print '</td></tr>'."\n"; |
|
| 1541 | - |
|
| 1542 | - // Barcode value |
|
| 1543 | - print '<tr><td class="nowrap">'; |
|
| 1544 | - print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
|
| 1545 | - print $langs->trans("BarcodeValue"); |
|
| 1546 | - print '</td>'; |
|
| 1547 | - if (($action != 'editbarcode') && ! empty($user->rights->produit->creer) && $createbarcode) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>'; |
|
| 1548 | - print '</tr></table>'; |
|
| 1549 | - print '</td><td colspan="2">'; |
|
| 1550 | - if ($action == 'editbarcode') |
|
| 1551 | - { |
|
| 1531 | + if ($action == 'editbarcodetype') |
|
| 1532 | + { |
|
| 1533 | + $formbarcode->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$object->id,$object->barcode_type,'fk_barcode_type'); |
|
| 1534 | + } |
|
| 1535 | + else |
|
| 1536 | + { |
|
| 1537 | + $object->fetch_barcode(); |
|
| 1538 | + print $object->barcode_type_label?$object->barcode_type_label:($object->barcode?'<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>':''); |
|
| 1539 | + } |
|
| 1540 | + print '</td></tr>'."\n"; |
|
| 1541 | + |
|
| 1542 | + // Barcode value |
|
| 1543 | + print '<tr><td class="nowrap">'; |
|
| 1544 | + print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
|
| 1545 | + print $langs->trans("BarcodeValue"); |
|
| 1546 | + print '</td>'; |
|
| 1547 | + if (($action != 'editbarcode') && ! empty($user->rights->produit->creer) && $createbarcode) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>'; |
|
| 1548 | + print '</tr></table>'; |
|
| 1549 | + print '</td><td colspan="2">'; |
|
| 1550 | + if ($action == 'editbarcode') |
|
| 1551 | + { |
|
| 1552 | 1552 | $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; |
| 1553 | 1553 | if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
| 1554 | 1554 | |
@@ -1559,46 +1559,46 @@ discard block |
||
| 1559 | 1559 | print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$tmpcode.'">'; |
| 1560 | 1560 | print ' <input type="submit" class="button" value="'.$langs->trans("Modify").'">'; |
| 1561 | 1561 | print '</form>'; |
| 1562 | - } |
|
| 1563 | - else |
|
| 1564 | - { |
|
| 1565 | - print $object->barcode; |
|
| 1566 | - } |
|
| 1567 | - print '</td></tr>'."\n"; |
|
| 1568 | - } |
|
| 1562 | + } |
|
| 1563 | + else |
|
| 1564 | + { |
|
| 1565 | + print $object->barcode; |
|
| 1566 | + } |
|
| 1567 | + print '</td></tr>'."\n"; |
|
| 1568 | + } |
|
| 1569 | 1569 | |
| 1570 | - // Accountancy sell code |
|
| 1570 | + // Accountancy sell code |
|
| 1571 | 1571 | print '<tr><td class="nowrap">'; |
| 1572 | - print $langs->trans("ProductAccountancySellCode"); |
|
| 1573 | - print '</td><td colspan="2">'; |
|
| 1572 | + print $langs->trans("ProductAccountancySellCode"); |
|
| 1573 | + print '</td><td colspan="2">'; |
|
| 1574 | 1574 | if (! empty($conf->accounting->enabled)) |
| 1575 | 1575 | { |
| 1576 | 1576 | $accountingaccount = new AccountingAccount($db); |
| 1577 | 1577 | $accountingaccount->fetch('',$object->accountancy_code_sell); |
| 1578 | 1578 | |
| 1579 | 1579 | print $accountingaccount->getNomUrl(0,1,1,'',1); |
| 1580 | - } else { |
|
| 1580 | + } else { |
|
| 1581 | 1581 | print $object->accountancy_code_sell; |
| 1582 | 1582 | } |
| 1583 | 1583 | print '</td></tr>'; |
| 1584 | 1584 | |
| 1585 | - // Accountancy buy code |
|
| 1585 | + // Accountancy buy code |
|
| 1586 | 1586 | print '<tr><td class="nowrap">'; |
| 1587 | - print $langs->trans("ProductAccountancyBuyCode"); |
|
| 1588 | - print '</td><td colspan="2">'; |
|
| 1587 | + print $langs->trans("ProductAccountancyBuyCode"); |
|
| 1588 | + print '</td><td colspan="2">'; |
|
| 1589 | 1589 | if (! empty($conf->accounting->enabled)) |
| 1590 | 1590 | { |
| 1591 | 1591 | $accountingaccount2 = new AccountingAccount($db); |
| 1592 | 1592 | $accountingaccount2->fetch('',$object->accountancy_code_buy); |
| 1593 | 1593 | |
| 1594 | 1594 | print $accountingaccount2->getNomUrl(0,1,1,'',1); |
| 1595 | - } else { |
|
| 1595 | + } else { |
|
| 1596 | 1596 | print $object->accountancy_code_buy; |
| 1597 | 1597 | } |
| 1598 | - print '</td></tr>'; |
|
| 1598 | + print '</td></tr>'; |
|
| 1599 | 1599 | |
| 1600 | - // Status (to sell) |
|
| 1601 | - /* |
|
| 1600 | + // Status (to sell) |
|
| 1601 | + /* |
|
| 1602 | 1602 | print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="2">'; |
| 1603 | 1603 | if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { |
| 1604 | 1604 | print ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); |
@@ -1617,131 +1617,131 @@ discard block |
||
| 1617 | 1617 | print '</td></tr>'; |
| 1618 | 1618 | */ |
| 1619 | 1619 | |
| 1620 | - // Batch number management (to batch) |
|
| 1621 | - if (! empty($conf->productbatch->enabled)) { |
|
| 1622 | - print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="2">'; |
|
| 1623 | - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { |
|
| 1624 | - print ajax_object_onoff($object, 'status_batch', 'tobatch', 'ProductStatusOnBatch', 'ProductStatusNotOnBatch'); |
|
| 1625 | - } else { |
|
| 1626 | - print $object->getLibStatut(0,2); |
|
| 1627 | - } |
|
| 1628 | - print '</td></tr>'; |
|
| 1629 | - } |
|
| 1620 | + // Batch number management (to batch) |
|
| 1621 | + if (! empty($conf->productbatch->enabled)) { |
|
| 1622 | + print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="2">'; |
|
| 1623 | + if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { |
|
| 1624 | + print ajax_object_onoff($object, 'status_batch', 'tobatch', 'ProductStatusOnBatch', 'ProductStatusNotOnBatch'); |
|
| 1625 | + } else { |
|
| 1626 | + print $object->getLibStatut(0,2); |
|
| 1627 | + } |
|
| 1628 | + print '</td></tr>'; |
|
| 1629 | + } |
|
| 1630 | 1630 | |
| 1631 | - // Description |
|
| 1632 | - print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="2">'.(dol_textishtml($object->description)?$object->description:dol_nl2br($object->description,1,true)).'</td></tr>'; |
|
| 1631 | + // Description |
|
| 1632 | + print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="2">'.(dol_textishtml($object->description)?$object->description:dol_nl2br($object->description,1,true)).'</td></tr>'; |
|
| 1633 | 1633 | |
| 1634 | - // Public URL |
|
| 1635 | - print '<tr><td>'.$langs->trans("PublicUrl").'</td><td colspan="2">'; |
|
| 1634 | + // Public URL |
|
| 1635 | + print '<tr><td>'.$langs->trans("PublicUrl").'</td><td colspan="2">'; |
|
| 1636 | 1636 | print dol_print_url($object->url); |
| 1637 | - print '</td></tr>'; |
|
| 1637 | + print '</td></tr>'; |
|
| 1638 | 1638 | |
| 1639 | - //Parent product. |
|
| 1640 | - if (!empty($conf->variants->enabled) && $object->isProduct()) { |
|
| 1639 | + //Parent product. |
|
| 1640 | + if (!empty($conf->variants->enabled) && $object->isProduct()) { |
|
| 1641 | 1641 | |
| 1642 | - $combination = new ProductCombination($db); |
|
| 1642 | + $combination = new ProductCombination($db); |
|
| 1643 | 1643 | |
| 1644 | - if ($combination->fetchByFkProductChild($object->id) > 0) { |
|
| 1645 | - $prodstatic = new Product($db); |
|
| 1646 | - $prodstatic->fetch($combination->fk_product_parent); |
|
| 1644 | + if ($combination->fetchByFkProductChild($object->id) > 0) { |
|
| 1645 | + $prodstatic = new Product($db); |
|
| 1646 | + $prodstatic->fetch($combination->fk_product_parent); |
|
| 1647 | 1647 | |
| 1648 | - // Parent product |
|
| 1649 | - print '<tr><td>'.$langs->trans("ParentProduct").'</td><td colspan="2">'; |
|
| 1650 | - print $prodstatic->getNomUrl(1); |
|
| 1651 | - print '</td></tr>'; |
|
| 1652 | - } |
|
| 1653 | - } |
|
| 1648 | + // Parent product |
|
| 1649 | + print '<tr><td>'.$langs->trans("ParentProduct").'</td><td colspan="2">'; |
|
| 1650 | + print $prodstatic->getNomUrl(1); |
|
| 1651 | + print '</td></tr>'; |
|
| 1652 | + } |
|
| 1653 | + } |
|
| 1654 | 1654 | |
| 1655 | - print '</table>'; |
|
| 1656 | - print '</div>'; |
|
| 1657 | - print '<div class="fichehalfright"><div class="ficheaddleft">'; |
|
| 1655 | + print '</table>'; |
|
| 1656 | + print '</div>'; |
|
| 1657 | + print '<div class="fichehalfright"><div class="ficheaddleft">'; |
|
| 1658 | 1658 | |
| 1659 | - print '<div class="underbanner clearboth"></div>'; |
|
| 1660 | - print '<table class="border tableforfield" width="100%">'; |
|
| 1659 | + print '<div class="underbanner clearboth"></div>'; |
|
| 1660 | + print '<table class="border tableforfield" width="100%">'; |
|
| 1661 | 1661 | |
| 1662 | - // Nature |
|
| 1663 | - if($object->type!= Product::TYPE_SERVICE) |
|
| 1664 | - { |
|
| 1665 | - print '<tr><td class="titlefield">'.$langs->trans("Nature").'</td><td colspan="2">'; |
|
| 1666 | - print $object->getLibFinished(); |
|
| 1667 | - print '</td></tr>'; |
|
| 1668 | - } |
|
| 1662 | + // Nature |
|
| 1663 | + if($object->type!= Product::TYPE_SERVICE) |
|
| 1664 | + { |
|
| 1665 | + print '<tr><td class="titlefield">'.$langs->trans("Nature").'</td><td colspan="2">'; |
|
| 1666 | + print $object->getLibFinished(); |
|
| 1667 | + print '</td></tr>'; |
|
| 1668 | + } |
|
| 1669 | 1669 | |
| 1670 | - if ($object->isService()) |
|
| 1671 | - { |
|
| 1672 | - // Duration |
|
| 1673 | - print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.' '; |
|
| 1674 | - if ($object->duration_value > 1) |
|
| 1675 | - { |
|
| 1676 | - $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); |
|
| 1677 | - } |
|
| 1678 | - else if ($object->duration_value > 0) |
|
| 1679 | - { |
|
| 1680 | - $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); |
|
| 1681 | - } |
|
| 1682 | - print (! empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; |
|
| 1670 | + if ($object->isService()) |
|
| 1671 | + { |
|
| 1672 | + // Duration |
|
| 1673 | + print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.' '; |
|
| 1674 | + if ($object->duration_value > 1) |
|
| 1675 | + { |
|
| 1676 | + $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); |
|
| 1677 | + } |
|
| 1678 | + else if ($object->duration_value > 0) |
|
| 1679 | + { |
|
| 1680 | + $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); |
|
| 1681 | + } |
|
| 1682 | + print (! empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; |
|
| 1683 | 1683 | |
| 1684 | - print '</td></tr>'; |
|
| 1685 | - } |
|
| 1686 | - else |
|
| 1687 | - { |
|
| 1688 | - // Weight |
|
| 1689 | - print '<tr><td class="titlefield">'.$langs->trans("Weight").'</td><td colspan="2">'; |
|
| 1690 | - if ($object->weight != '') |
|
| 1691 | - { |
|
| 1692 | - print $object->weight." ".measuring_units_string($object->weight_units,"weight"); |
|
| 1693 | - } |
|
| 1694 | - else |
|
| 1695 | - { |
|
| 1696 | - print ' '; |
|
| 1697 | - } |
|
| 1698 | - print "</td></tr>\n"; |
|
| 1699 | - if (empty($conf->global->PRODUCT_DISABLE_SIZE)) |
|
| 1700 | - { |
|
| 1701 | - // Length |
|
| 1702 | - print '<tr><td>'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").'</td><td colspan="2">'; |
|
| 1703 | - if ($object->length != '' || $object->width != '' || $object->height != '') |
|
| 1704 | - { |
|
| 1705 | - print $object->length; |
|
| 1706 | - if ($object->width) print " x ".$object->width; |
|
| 1707 | - if ($object->height) print " x ".$object->height; |
|
| 1708 | - print ' '.measuring_units_string($object->length_units,"size"); |
|
| 1709 | - } |
|
| 1710 | - else |
|
| 1711 | - { |
|
| 1712 | - print ' '; |
|
| 1713 | - } |
|
| 1714 | - print "</td></tr>\n"; |
|
| 1715 | - } |
|
| 1716 | - if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) |
|
| 1717 | - { |
|
| 1718 | - // Surface |
|
| 1719 | - print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="2">'; |
|
| 1720 | - if ($object->surface != '') |
|
| 1721 | - { |
|
| 1722 | - print $object->surface." ".measuring_units_string($object->surface_units,"surface"); |
|
| 1723 | - } |
|
| 1724 | - else |
|
| 1725 | - { |
|
| 1726 | - print ' '; |
|
| 1727 | - } |
|
| 1728 | - print "</td></tr>\n"; |
|
| 1729 | - } |
|
| 1730 | - if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) |
|
| 1731 | - { |
|
| 1732 | - // Volume |
|
| 1733 | - print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="2">'; |
|
| 1734 | - if ($object->volume != '') |
|
| 1735 | - { |
|
| 1736 | - print $object->volume." ".measuring_units_string($object->volume_units,"volume"); |
|
| 1737 | - } |
|
| 1738 | - else |
|
| 1739 | - { |
|
| 1740 | - print ' '; |
|
| 1741 | - } |
|
| 1742 | - print "</td></tr>\n"; |
|
| 1743 | - } |
|
| 1744 | - } |
|
| 1684 | + print '</td></tr>'; |
|
| 1685 | + } |
|
| 1686 | + else |
|
| 1687 | + { |
|
| 1688 | + // Weight |
|
| 1689 | + print '<tr><td class="titlefield">'.$langs->trans("Weight").'</td><td colspan="2">'; |
|
| 1690 | + if ($object->weight != '') |
|
| 1691 | + { |
|
| 1692 | + print $object->weight." ".measuring_units_string($object->weight_units,"weight"); |
|
| 1693 | + } |
|
| 1694 | + else |
|
| 1695 | + { |
|
| 1696 | + print ' '; |
|
| 1697 | + } |
|
| 1698 | + print "</td></tr>\n"; |
|
| 1699 | + if (empty($conf->global->PRODUCT_DISABLE_SIZE)) |
|
| 1700 | + { |
|
| 1701 | + // Length |
|
| 1702 | + print '<tr><td>'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").'</td><td colspan="2">'; |
|
| 1703 | + if ($object->length != '' || $object->width != '' || $object->height != '') |
|
| 1704 | + { |
|
| 1705 | + print $object->length; |
|
| 1706 | + if ($object->width) print " x ".$object->width; |
|
| 1707 | + if ($object->height) print " x ".$object->height; |
|
| 1708 | + print ' '.measuring_units_string($object->length_units,"size"); |
|
| 1709 | + } |
|
| 1710 | + else |
|
| 1711 | + { |
|
| 1712 | + print ' '; |
|
| 1713 | + } |
|
| 1714 | + print "</td></tr>\n"; |
|
| 1715 | + } |
|
| 1716 | + if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) |
|
| 1717 | + { |
|
| 1718 | + // Surface |
|
| 1719 | + print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="2">'; |
|
| 1720 | + if ($object->surface != '') |
|
| 1721 | + { |
|
| 1722 | + print $object->surface." ".measuring_units_string($object->surface_units,"surface"); |
|
| 1723 | + } |
|
| 1724 | + else |
|
| 1725 | + { |
|
| 1726 | + print ' '; |
|
| 1727 | + } |
|
| 1728 | + print "</td></tr>\n"; |
|
| 1729 | + } |
|
| 1730 | + if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) |
|
| 1731 | + { |
|
| 1732 | + // Volume |
|
| 1733 | + print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="2">'; |
|
| 1734 | + if ($object->volume != '') |
|
| 1735 | + { |
|
| 1736 | + print $object->volume." ".measuring_units_string($object->volume_units,"volume"); |
|
| 1737 | + } |
|
| 1738 | + else |
|
| 1739 | + { |
|
| 1740 | + print ' '; |
|
| 1741 | + } |
|
| 1742 | + print "</td></tr>\n"; |
|
| 1743 | + } |
|
| 1744 | + } |
|
| 1745 | 1745 | |
| 1746 | 1746 | // Unit |
| 1747 | 1747 | if (! empty($conf->global->PRODUCT_USE_UNITS)) |
@@ -1755,18 +1755,18 @@ discard block |
||
| 1755 | 1755 | print '</td></tr>'; |
| 1756 | 1756 | } |
| 1757 | 1757 | |
| 1758 | - // Custom code |
|
| 1759 | - if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) |
|
| 1760 | - { |
|
| 1761 | - print '<tr><td>'.$langs->trans("CustomCode").'</td><td colspan="2">'.$object->customcode.'</td>'; |
|
| 1758 | + // Custom code |
|
| 1759 | + if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) |
|
| 1760 | + { |
|
| 1761 | + print '<tr><td>'.$langs->trans("CustomCode").'</td><td colspan="2">'.$object->customcode.'</td>'; |
|
| 1762 | 1762 | |
| 1763 | - // Origin country code |
|
| 1764 | - print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td colspan="2">'.getCountry($object->country_id,0,$db).'</td>'; |
|
| 1765 | - } |
|
| 1763 | + // Origin country code |
|
| 1764 | + print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td colspan="2">'.getCountry($object->country_id,0,$db).'</td>'; |
|
| 1765 | + } |
|
| 1766 | 1766 | |
| 1767 | - // Other attributes |
|
| 1768 | - $parameters=array('colspan' => ' colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'"'); |
|
| 1769 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
| 1767 | + // Other attributes |
|
| 1768 | + $parameters=array('colspan' => ' colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'"'); |
|
| 1769 | + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
| 1770 | 1770 | |
| 1771 | 1771 | // Categories |
| 1772 | 1772 | if($conf->categorie->enabled) { |
@@ -1775,35 +1775,35 @@ discard block |
||
| 1775 | 1775 | print "</td></tr>"; |
| 1776 | 1776 | } |
| 1777 | 1777 | |
| 1778 | - // Note private |
|
| 1778 | + // Note private |
|
| 1779 | 1779 | if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
| 1780 | 1780 | { |
| 1781 | - print '<!-- show Note --> '."\n"; |
|
| 1782 | - print '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td><td colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'">'.(dol_textishtml($object->note_private)?$object->note_private:dol_nl2br($object->note_private,1,true)).'</td></tr>'."\n"; |
|
| 1783 | - print '<!-- End show Note --> '."\n"; |
|
| 1781 | + print '<!-- show Note --> '."\n"; |
|
| 1782 | + print '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td><td colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'">'.(dol_textishtml($object->note_private)?$object->note_private:dol_nl2br($object->note_private,1,true)).'</td></tr>'."\n"; |
|
| 1783 | + print '<!-- End show Note --> '."\n"; |
|
| 1784 | 1784 | } |
| 1785 | 1785 | |
| 1786 | - print "</table>\n"; |
|
| 1787 | - print '</div>'; |
|
| 1786 | + print "</table>\n"; |
|
| 1787 | + print '</div>'; |
|
| 1788 | 1788 | |
| 1789 | - print '</div></div>'; |
|
| 1790 | - print '<div style="clear:both"></div>'; |
|
| 1789 | + print '</div></div>'; |
|
| 1790 | + print '<div style="clear:both"></div>'; |
|
| 1791 | 1791 | |
| 1792 | - dol_fiche_end(); |
|
| 1793 | - } |
|
| 1792 | + dol_fiche_end(); |
|
| 1793 | + } |
|
| 1794 | 1794 | |
| 1795 | - } |
|
| 1796 | - else if ($action != 'create') |
|
| 1797 | - { |
|
| 1798 | - exit; |
|
| 1799 | - } |
|
| 1795 | + } |
|
| 1796 | + else if ($action != 'create') |
|
| 1797 | + { |
|
| 1798 | + exit; |
|
| 1799 | + } |
|
| 1800 | 1800 | } |
| 1801 | 1801 | |
| 1802 | 1802 | // Load object modCodeProduct |
| 1803 | 1803 | $module=(! empty($conf->global->PRODUCT_CODEPRODUCT_ADDON)?$conf->global->PRODUCT_CODEPRODUCT_ADDON:'mod_codeproduct_leopard'); |
| 1804 | 1804 | if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') |
| 1805 | 1805 | { |
| 1806 | - $module = substr($module, 0, dol_strlen($module)-4); |
|
| 1806 | + $module = substr($module, 0, dol_strlen($module)-4); |
|
| 1807 | 1807 | } |
| 1808 | 1808 | $result=dol_include_once('/core/modules/product/'.$module.'.php'); |
| 1809 | 1809 | if ($result > 0) |
@@ -1817,27 +1817,27 @@ discard block |
||
| 1817 | 1817 | // Define confirmation messages |
| 1818 | 1818 | $formquestionclone=array( |
| 1819 | 1819 | 'text' => $langs->trans("ConfirmClone"), |
| 1820 | - array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24), |
|
| 1821 | - array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1), |
|
| 1822 | - array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true), |
|
| 1820 | + array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24), |
|
| 1821 | + array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1), |
|
| 1822 | + array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true), |
|
| 1823 | 1823 | ); |
| 1824 | 1824 | if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) |
| 1825 | 1825 | { |
| 1826 | - $formquestionclone[]=array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1); |
|
| 1826 | + $formquestionclone[]=array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1); |
|
| 1827 | 1827 | } |
| 1828 | 1828 | |
| 1829 | 1829 | // Confirm delete product |
| 1830 | 1830 | if (($action == 'delete' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js |
| 1831 | 1831 | || (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) // Always output when not jmobile nor js |
| 1832 | 1832 | { |
| 1833 | - print $form->formconfirm("card.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); |
|
| 1833 | + print $form->formconfirm("card.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); |
|
| 1834 | 1834 | } |
| 1835 | 1835 | |
| 1836 | 1836 | // Clone confirmation |
| 1837 | 1837 | if (($action == 'clone' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js |
| 1838 | 1838 | || (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) // Always output when not jmobile nor js |
| 1839 | 1839 | { |
| 1840 | - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',250,600); |
|
| 1840 | + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',250,600); |
|
| 1841 | 1841 | } |
| 1842 | 1842 | |
| 1843 | 1843 | |
@@ -1848,57 +1848,57 @@ discard block |
||
| 1848 | 1848 | /* ************************************************************************** */ |
| 1849 | 1849 | if ($action != 'create' && $action != 'edit') |
| 1850 | 1850 | { |
| 1851 | - print "\n".'<div class="tabsAction">'."\n"; |
|
| 1852 | - |
|
| 1853 | - $parameters=array(); |
|
| 1854 | - $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 1855 | - if (empty($reshook)) |
|
| 1856 | - { |
|
| 1857 | - if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer ) || |
|
| 1858 | - ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)) |
|
| 1859 | - { |
|
| 1860 | - if (! isset($object->no_button_edit) || $object->no_button_edit <> 1) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans("Modify").'</a></div>'; |
|
| 1861 | - |
|
| 1862 | - if (! isset($object->no_button_copy) || $object->no_button_copy <> 1) |
|
| 1863 | - { |
|
| 1864 | - if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) |
|
| 1865 | - { |
|
| 1866 | - print '<div class="inline-block divButAction"><span id="action-clone" class="butAction">'.$langs->trans('ToClone').'</span></div>'."\n"; |
|
| 1867 | - } |
|
| 1868 | - else |
|
| 1869 | - { |
|
| 1870 | - print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=clone&id='.$object->id.'">'.$langs->trans("ToClone").'</a></div>'; |
|
| 1871 | - } |
|
| 1872 | - } |
|
| 1873 | - } |
|
| 1874 | - $object_is_used = $object->isObjectUsed($object->id); |
|
| 1851 | + print "\n".'<div class="tabsAction">'."\n"; |
|
| 1875 | 1852 | |
| 1876 | - if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) |
|
| 1877 | - || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)) |
|
| 1878 | - { |
|
| 1879 | - if (empty($object_is_used) && (! isset($object->no_button_delete) || $object->no_button_delete <> 1)) |
|
| 1880 | - { |
|
| 1881 | - if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) |
|
| 1882 | - { |
|
| 1883 | - print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n"; |
|
| 1884 | - } |
|
| 1885 | - else |
|
| 1886 | - { |
|
| 1887 | - print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans("Delete").'</a></div>'; |
|
| 1888 | - } |
|
| 1889 | - } |
|
| 1890 | - else |
|
| 1891 | - { |
|
| 1892 | - print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("ProductIsUsed").'">'.$langs->trans("Delete").'</a></div>'; |
|
| 1893 | - } |
|
| 1894 | - } |
|
| 1895 | - else |
|
| 1896 | - { |
|
| 1897 | - print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Delete").'</a></div>'; |
|
| 1898 | - } |
|
| 1899 | - } |
|
| 1900 | - |
|
| 1901 | - print "\n</div>\n"; |
|
| 1853 | + $parameters=array(); |
|
| 1854 | + $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 1855 | + if (empty($reshook)) |
|
| 1856 | + { |
|
| 1857 | + if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer ) || |
|
| 1858 | + ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)) |
|
| 1859 | + { |
|
| 1860 | + if (! isset($object->no_button_edit) || $object->no_button_edit <> 1) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans("Modify").'</a></div>'; |
|
| 1861 | + |
|
| 1862 | + if (! isset($object->no_button_copy) || $object->no_button_copy <> 1) |
|
| 1863 | + { |
|
| 1864 | + if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) |
|
| 1865 | + { |
|
| 1866 | + print '<div class="inline-block divButAction"><span id="action-clone" class="butAction">'.$langs->trans('ToClone').'</span></div>'."\n"; |
|
| 1867 | + } |
|
| 1868 | + else |
|
| 1869 | + { |
|
| 1870 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=clone&id='.$object->id.'">'.$langs->trans("ToClone").'</a></div>'; |
|
| 1871 | + } |
|
| 1872 | + } |
|
| 1873 | + } |
|
| 1874 | + $object_is_used = $object->isObjectUsed($object->id); |
|
| 1875 | + |
|
| 1876 | + if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) |
|
| 1877 | + || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)) |
|
| 1878 | + { |
|
| 1879 | + if (empty($object_is_used) && (! isset($object->no_button_delete) || $object->no_button_delete <> 1)) |
|
| 1880 | + { |
|
| 1881 | + if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) |
|
| 1882 | + { |
|
| 1883 | + print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n"; |
|
| 1884 | + } |
|
| 1885 | + else |
|
| 1886 | + { |
|
| 1887 | + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans("Delete").'</a></div>'; |
|
| 1888 | + } |
|
| 1889 | + } |
|
| 1890 | + else |
|
| 1891 | + { |
|
| 1892 | + print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("ProductIsUsed").'">'.$langs->trans("Delete").'</a></div>'; |
|
| 1893 | + } |
|
| 1894 | + } |
|
| 1895 | + else |
|
| 1896 | + { |
|
| 1897 | + print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Delete").'</a></div>'; |
|
| 1898 | + } |
|
| 1899 | + } |
|
| 1900 | + |
|
| 1901 | + print "\n</div>\n"; |
|
| 1902 | 1902 | } |
| 1903 | 1903 | |
| 1904 | 1904 | /* |
@@ -1907,112 +1907,112 @@ discard block |
||
| 1907 | 1907 | |
| 1908 | 1908 | if (! empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == '' || $action == 'view') && $object->status) |
| 1909 | 1909 | { |
| 1910 | - //Variable used to check if any text is going to be printed |
|
| 1911 | - $html = ''; |
|
| 1910 | + //Variable used to check if any text is going to be printed |
|
| 1911 | + $html = ''; |
|
| 1912 | 1912 | //print '<div class="fichecenter"><div class="fichehalfleft">'; |
| 1913 | 1913 | |
| 1914 | - // Propals |
|
| 1915 | - if (! empty($conf->propal->enabled) && $user->rights->propale->creer) |
|
| 1916 | - { |
|
| 1917 | - $propal = new Propal($db); |
|
| 1918 | - |
|
| 1919 | - $langs->load("propal"); |
|
| 1920 | - |
|
| 1921 | - $otherprop = $propal->liste_array(2,1,0); |
|
| 1922 | - |
|
| 1923 | - if (is_array($otherprop) && count($otherprop)) |
|
| 1924 | - { |
|
| 1925 | - $html .= '<tr><td style="width: 200px;">'; |
|
| 1926 | - $html .= $langs->trans("AddToDraftProposals").'</td><td>'; |
|
| 1927 | - $html .= $form->selectarray("propalid", $otherprop, 0, 1); |
|
| 1928 | - $html .= '</td></tr>'; |
|
| 1929 | - } |
|
| 1930 | - else |
|
| 1931 | - { |
|
| 1932 | - $html .= '<tr><td style="width: 200px;">'; |
|
| 1933 | - $html .= $langs->trans("AddToDraftProposals").'</td><td>'; |
|
| 1934 | - $html .= $langs->trans("NoDraftProposals"); |
|
| 1935 | - $html .= '</td></tr>'; |
|
| 1936 | - } |
|
| 1937 | - } |
|
| 1938 | - |
|
| 1939 | - // Commande |
|
| 1940 | - if (! empty($conf->commande->enabled) && $user->rights->commande->creer) |
|
| 1941 | - { |
|
| 1942 | - $commande = new Commande($db); |
|
| 1943 | - |
|
| 1944 | - $langs->load("orders"); |
|
| 1945 | - |
|
| 1946 | - $othercom = $commande->liste_array(2, 1, null); |
|
| 1947 | - if (is_array($othercom) && count($othercom)) |
|
| 1948 | - { |
|
| 1949 | - $html .= '<tr><td style="width: 200px;">'; |
|
| 1950 | - $html .= $langs->trans("AddToDraftOrders").'</td><td>'; |
|
| 1951 | - $html .= $form->selectarray("commandeid", $othercom, 0, 1); |
|
| 1952 | - $html .= '</td></tr>'; |
|
| 1953 | - } |
|
| 1954 | - else |
|
| 1914 | + // Propals |
|
| 1915 | + if (! empty($conf->propal->enabled) && $user->rights->propale->creer) |
|
| 1916 | + { |
|
| 1917 | + $propal = new Propal($db); |
|
| 1918 | + |
|
| 1919 | + $langs->load("propal"); |
|
| 1920 | + |
|
| 1921 | + $otherprop = $propal->liste_array(2,1,0); |
|
| 1922 | + |
|
| 1923 | + if (is_array($otherprop) && count($otherprop)) |
|
| 1955 | 1924 | { |
| 1956 | - $html .= '<tr><td style="width: 200px;">'; |
|
| 1957 | - $html .= $langs->trans("AddToDraftOrders").'</td><td>'; |
|
| 1958 | - $html .= $langs->trans("NoDraftOrders"); |
|
| 1959 | - $html .= '</td></tr>'; |
|
| 1960 | - } |
|
| 1961 | - } |
|
| 1962 | - |
|
| 1963 | - // Factures |
|
| 1964 | - if (! empty($conf->facture->enabled) && $user->rights->facture->creer) |
|
| 1965 | - { |
|
| 1966 | - $invoice = new Facture($db); |
|
| 1967 | - |
|
| 1968 | - $langs->load("bills"); |
|
| 1969 | - |
|
| 1970 | - $otherinvoice = $invoice->liste_array(2, 1, null); |
|
| 1971 | - if (is_array($otherinvoice) && count($otherinvoice)) |
|
| 1972 | - { |
|
| 1973 | - $html .= '<tr><td style="width: 200px;">'; |
|
| 1974 | - $html .= $langs->trans("AddToDraftInvoices").'</td><td>'; |
|
| 1975 | - $html .= $form->selectarray("factureid", $otherinvoice, 0, 1); |
|
| 1976 | - $html .= '</td></tr>'; |
|
| 1977 | - } |
|
| 1978 | - else |
|
| 1979 | - { |
|
| 1980 | - $html .= '<tr><td style="width: 200px;">'; |
|
| 1981 | - $html .= $langs->trans("AddToDraftInvoices").'</td><td>'; |
|
| 1982 | - $html .= $langs->trans("NoDraftInvoices"); |
|
| 1983 | - $html .= '</td></tr>'; |
|
| 1984 | - } |
|
| 1985 | - } |
|
| 1986 | - |
|
| 1987 | - //If any text is going to be printed, then we show the table |
|
| 1988 | - if (!empty($html)) |
|
| 1989 | - { |
|
| 1990 | - print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'; |
|
| 1991 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 1992 | - print '<input type="hidden" name="action" value="addin">'; |
|
| 1993 | - |
|
| 1994 | - print load_fiche_titre($langs->trans("AddToDraft"),'',''); |
|
| 1925 | + $html .= '<tr><td style="width: 200px;">'; |
|
| 1926 | + $html .= $langs->trans("AddToDraftProposals").'</td><td>'; |
|
| 1927 | + $html .= $form->selectarray("propalid", $otherprop, 0, 1); |
|
| 1928 | + $html .= '</td></tr>'; |
|
| 1929 | + } |
|
| 1930 | + else |
|
| 1931 | + { |
|
| 1932 | + $html .= '<tr><td style="width: 200px;">'; |
|
| 1933 | + $html .= $langs->trans("AddToDraftProposals").'</td><td>'; |
|
| 1934 | + $html .= $langs->trans("NoDraftProposals"); |
|
| 1935 | + $html .= '</td></tr>'; |
|
| 1936 | + } |
|
| 1937 | + } |
|
| 1938 | + |
|
| 1939 | + // Commande |
|
| 1940 | + if (! empty($conf->commande->enabled) && $user->rights->commande->creer) |
|
| 1941 | + { |
|
| 1942 | + $commande = new Commande($db); |
|
| 1943 | + |
|
| 1944 | + $langs->load("orders"); |
|
| 1945 | + |
|
| 1946 | + $othercom = $commande->liste_array(2, 1, null); |
|
| 1947 | + if (is_array($othercom) && count($othercom)) |
|
| 1948 | + { |
|
| 1949 | + $html .= '<tr><td style="width: 200px;">'; |
|
| 1950 | + $html .= $langs->trans("AddToDraftOrders").'</td><td>'; |
|
| 1951 | + $html .= $form->selectarray("commandeid", $othercom, 0, 1); |
|
| 1952 | + $html .= '</td></tr>'; |
|
| 1953 | + } |
|
| 1954 | + else |
|
| 1955 | + { |
|
| 1956 | + $html .= '<tr><td style="width: 200px;">'; |
|
| 1957 | + $html .= $langs->trans("AddToDraftOrders").'</td><td>'; |
|
| 1958 | + $html .= $langs->trans("NoDraftOrders"); |
|
| 1959 | + $html .= '</td></tr>'; |
|
| 1960 | + } |
|
| 1961 | + } |
|
| 1962 | + |
|
| 1963 | + // Factures |
|
| 1964 | + if (! empty($conf->facture->enabled) && $user->rights->facture->creer) |
|
| 1965 | + { |
|
| 1966 | + $invoice = new Facture($db); |
|
| 1967 | + |
|
| 1968 | + $langs->load("bills"); |
|
| 1969 | + |
|
| 1970 | + $otherinvoice = $invoice->liste_array(2, 1, null); |
|
| 1971 | + if (is_array($otherinvoice) && count($otherinvoice)) |
|
| 1972 | + { |
|
| 1973 | + $html .= '<tr><td style="width: 200px;">'; |
|
| 1974 | + $html .= $langs->trans("AddToDraftInvoices").'</td><td>'; |
|
| 1975 | + $html .= $form->selectarray("factureid", $otherinvoice, 0, 1); |
|
| 1976 | + $html .= '</td></tr>'; |
|
| 1977 | + } |
|
| 1978 | + else |
|
| 1979 | + { |
|
| 1980 | + $html .= '<tr><td style="width: 200px;">'; |
|
| 1981 | + $html .= $langs->trans("AddToDraftInvoices").'</td><td>'; |
|
| 1982 | + $html .= $langs->trans("NoDraftInvoices"); |
|
| 1983 | + $html .= '</td></tr>'; |
|
| 1984 | + } |
|
| 1985 | + } |
|
| 1986 | + |
|
| 1987 | + //If any text is going to be printed, then we show the table |
|
| 1988 | + if (!empty($html)) |
|
| 1989 | + { |
|
| 1990 | + print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'; |
|
| 1991 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 1992 | + print '<input type="hidden" name="action" value="addin">'; |
|
| 1993 | + |
|
| 1994 | + print load_fiche_titre($langs->trans("AddToDraft"),'',''); |
|
| 1995 | 1995 | |
| 1996 | 1996 | dol_fiche_head(''); |
| 1997 | 1997 | |
| 1998 | - $html .= '<tr><td class="nowrap">'.$langs->trans("Quantity").' '; |
|
| 1999 | - $html .= '<input type="text" class="flat" name="qty" size="1" value="1"></td>'; |
|
| 2000 | - $html .= '<td class="nowrap">'.$langs->trans("ReductionShort").'(%) '; |
|
| 2001 | - $html .= '<input type="text" class="flat" name="remise_percent" size="1" value="0">'; |
|
| 2002 | - $html .= '</td></tr>'; |
|
| 1998 | + $html .= '<tr><td class="nowrap">'.$langs->trans("Quantity").' '; |
|
| 1999 | + $html .= '<input type="text" class="flat" name="qty" size="1" value="1"></td>'; |
|
| 2000 | + $html .= '<td class="nowrap">'.$langs->trans("ReductionShort").'(%) '; |
|
| 2001 | + $html .= '<input type="text" class="flat" name="remise_percent" size="1" value="0">'; |
|
| 2002 | + $html .= '</td></tr>'; |
|
| 2003 | 2003 | |
| 2004 | - print '<table width="100%" class="border">'; |
|
| 2005 | - print $html; |
|
| 2006 | - print '</table>'; |
|
| 2004 | + print '<table width="100%" class="border">'; |
|
| 2005 | + print $html; |
|
| 2006 | + print '</table>'; |
|
| 2007 | 2007 | |
| 2008 | - print '<div class="center">'; |
|
| 2009 | - print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; |
|
| 2010 | - print '</div>'; |
|
| 2008 | + print '<div class="center">'; |
|
| 2009 | + print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; |
|
| 2010 | + print '</div>'; |
|
| 2011 | 2011 | |
| 2012 | - dol_fiche_end(); |
|
| 2012 | + dol_fiche_end(); |
|
| 2013 | 2013 | |
| 2014 | - print '</form>'; |
|
| 2015 | - } |
|
| 2014 | + print '</form>'; |
|
| 2015 | + } |
|
| 2016 | 2016 | } |
| 2017 | 2017 | |
| 2018 | 2018 | |
@@ -2022,25 +2022,25 @@ discard block |
||
| 2022 | 2022 | |
| 2023 | 2023 | if ($action != 'create' && $action != 'edit' && $action != 'delete') |
| 2024 | 2024 | { |
| 2025 | - print '<div class="fichecenter"><div class="fichehalfleft">'; |
|
| 2026 | - print '<a name="builddoc"></a>'; // ancre |
|
| 2025 | + print '<div class="fichecenter"><div class="fichehalfleft">'; |
|
| 2026 | + print '<a name="builddoc"></a>'; // ancre |
|
| 2027 | 2027 | |
| 2028 | - // Documents |
|
| 2029 | - $objectref = dol_sanitizeFileName($object->ref); |
|
| 2030 | - $relativepath = $comref . '/' . $objectref . '.pdf'; |
|
| 2031 | - $filedir = $conf->produit->dir_output . '/' . $objectref; |
|
| 2032 | - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; |
|
| 2033 | - $genallowed=$user->rights->produit->creer; |
|
| 2034 | - $delallowed=$user->rights->produit->supprimer; |
|
| 2028 | + // Documents |
|
| 2029 | + $objectref = dol_sanitizeFileName($object->ref); |
|
| 2030 | + $relativepath = $comref . '/' . $objectref . '.pdf'; |
|
| 2031 | + $filedir = $conf->produit->dir_output . '/' . $objectref; |
|
| 2032 | + $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; |
|
| 2033 | + $genallowed=$user->rights->produit->creer; |
|
| 2034 | + $delallowed=$user->rights->produit->supprimer; |
|
| 2035 | 2035 | |
| 2036 | - $var=true; |
|
| 2036 | + $var=true; |
|
| 2037 | 2037 | |
| 2038 | - print $formfile->showdocuments($modulepart,$object->ref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); |
|
| 2039 | - $somethingshown=$formfile->numoffiles; |
|
| 2038 | + print $formfile->showdocuments($modulepart,$object->ref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); |
|
| 2039 | + $somethingshown=$formfile->numoffiles; |
|
| 2040 | 2040 | |
| 2041 | - print '</div><div class="fichehalfright"><div class="ficheaddleft">'; |
|
| 2041 | + print '</div><div class="fichehalfright"><div class="ficheaddleft">'; |
|
| 2042 | 2042 | |
| 2043 | - print '</div></div></div>'; |
|
| 2043 | + print '</div></div></div>'; |
|
| 2044 | 2044 | } |
| 2045 | 2045 | |
| 2046 | 2046 | |
@@ -48,73 +48,73 @@ discard block |
||
| 48 | 48 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
| 49 | 49 | require_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.php'; |
| 50 | 50 | |
| 51 | -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 52 | -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 53 | -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 54 | -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
| 55 | -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; |
|
| 56 | -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; |
|
| 51 | +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 52 | +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 53 | +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 54 | +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
| 55 | +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; |
|
| 56 | +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; |
|
| 57 | 57 | |
| 58 | 58 | $langs->load("products"); |
| 59 | 59 | $langs->load("other"); |
| 60 | -if (! empty($conf->stock->enabled)) $langs->load("stocks"); |
|
| 61 | -if (! empty($conf->facture->enabled)) $langs->load("bills"); |
|
| 62 | -if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); |
|
| 60 | +if (!empty($conf->stock->enabled)) $langs->load("stocks"); |
|
| 61 | +if (!empty($conf->facture->enabled)) $langs->load("bills"); |
|
| 62 | +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); |
|
| 63 | 63 | |
| 64 | -$mesg=''; $error=0; $errors=array(); |
|
| 64 | +$mesg = ''; $error = 0; $errors = array(); |
|
| 65 | 65 | |
| 66 | -$refalreadyexists=0; |
|
| 66 | +$refalreadyexists = 0; |
|
| 67 | 67 | |
| 68 | -$id=GETPOST('id', 'int'); |
|
| 69 | -$ref=GETPOST('ref', 'alpha'); |
|
| 70 | -$type=GETPOST('type','int'); |
|
| 71 | -$action=(GETPOST('action','alpha') ? GETPOST('action','alpha') : 'view'); |
|
| 72 | -$cancel=GETPOST('cancel'); |
|
| 73 | -$confirm=GETPOST('confirm','alpha'); |
|
| 74 | -$socid=GETPOST('socid','int'); |
|
| 68 | +$id = GETPOST('id', 'int'); |
|
| 69 | +$ref = GETPOST('ref', 'alpha'); |
|
| 70 | +$type = GETPOST('type', 'int'); |
|
| 71 | +$action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view'); |
|
| 72 | +$cancel = GETPOST('cancel'); |
|
| 73 | +$confirm = GETPOST('confirm', 'alpha'); |
|
| 74 | +$socid = GETPOST('socid', 'int'); |
|
| 75 | 75 | $duration_value = GETPOST('duration_value'); |
| 76 | 76 | $duration_unit = GETPOST('duration_unit'); |
| 77 | -if (! empty($user->societe_id)) $socid=$user->societe_id; |
|
| 77 | +if (!empty($user->societe_id)) $socid = $user->societe_id; |
|
| 78 | 78 | |
| 79 | 79 | $object = new Product($db); |
| 80 | 80 | $extrafields = new ExtraFields($db); |
| 81 | 81 | |
| 82 | 82 | // fetch optionals attributes and labels |
| 83 | -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); |
|
| 83 | +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
|
| 84 | 84 | |
| 85 | -if ($id > 0 || ! empty($ref)) |
|
| 85 | +if ($id > 0 || !empty($ref)) |
|
| 86 | 86 | { |
| 87 | 87 | $result = $object->fetch($id, $ref); |
| 88 | 88 | |
| 89 | - if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); |
|
| 90 | - elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); |
|
| 89 | + if (!empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); |
|
| 90 | + elseif (!empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); |
|
| 91 | 91 | |
| 92 | - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs |
|
| 92 | + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs |
|
| 93 | 93 | { |
| 94 | - if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; |
|
| 95 | - else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; |
|
| 94 | + if (!empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; |
|
| 95 | + else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | -$modulepart='product'; |
|
| 99 | +$modulepart = 'product'; |
|
| 100 | 100 | |
| 101 | 101 | // Get object canvas (By default, this is not defined, so standard usage of dolibarr) |
| 102 | -$canvas = !empty($object->canvas)?$object->canvas:GETPOST("canvas"); |
|
| 103 | -$objcanvas=null; |
|
| 104 | -if (! empty($canvas)) |
|
| 102 | +$canvas = !empty($object->canvas) ? $object->canvas : GETPOST("canvas"); |
|
| 103 | +$objcanvas = null; |
|
| 104 | +if (!empty($canvas)) |
|
| 105 | 105 | { |
| 106 | 106 | require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; |
| 107 | - $objcanvas = new Canvas($db,$action); |
|
| 108 | - $objcanvas->getCanvas('product','card',$canvas); |
|
| 107 | + $objcanvas = new Canvas($db, $action); |
|
| 108 | + $objcanvas->getCanvas('product', 'card', $canvas); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // Security check |
| 112 | -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); |
|
| 113 | -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); |
|
| 114 | -$result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype,$objcanvas); |
|
| 112 | +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); |
|
| 113 | +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); |
|
| 114 | +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype, $objcanvas); |
|
| 115 | 115 | |
| 116 | 116 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
| 117 | -$hookmanager->initHooks(array('productcard','globalcard')); |
|
| 117 | +$hookmanager->initHooks(array('productcard', 'globalcard')); |
|
| 118 | 118 | |
| 119 | 119 | |
| 120 | 120 | |
@@ -124,17 +124,17 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | if ($cancel) $action = ''; |
| 126 | 126 | |
| 127 | -$createbarcode=empty($conf->barcode->enabled)?0:1; |
|
| 128 | -if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) $createbarcode=0; |
|
| 127 | +$createbarcode = empty($conf->barcode->enabled) ? 0 : 1; |
|
| 128 | +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) $createbarcode = 0; |
|
| 129 | 129 | |
| 130 | -$parameters=array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas); |
|
| 131 | -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 130 | +$parameters = array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas); |
|
| 131 | +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
| 132 | 132 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
| 133 | 133 | |
| 134 | 134 | if (empty($reshook)) |
| 135 | 135 | { |
| 136 | 136 | // Type |
| 137 | - if ($action == 'setfk_product_type' && $user->rights->produit->creer) |
|
| 137 | + if ($action == 'setfk_product_type' && $user->rights->produit->creer) |
|
| 138 | 138 | { |
| 139 | 139 | $result = $object->setValueFrom('fk_product_type', GETPOST('fk_product_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); |
| 140 | 140 | header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; |
| 150 | 150 | |
| 151 | 151 | // Barcode type |
| 152 | - if ($action == 'setfk_barcode_type' && $createbarcode) |
|
| 152 | + if ($action == 'setfk_barcode_type' && $createbarcode) |
|
| 153 | 153 | { |
| 154 | 154 | $result = $object->setValueFrom('fk_barcode_type', GETPOST('fk_barcode_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); |
| 155 | 155 | header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // Barcode value |
| 160 | - if ($action == 'setbarcode' && $createbarcode) |
|
| 160 | + if ($action == 'setbarcode' && $createbarcode) |
|
| 161 | 161 | { |
| 162 | - $result=$object->check_barcode(GETPOST('barcode'),GETPOST('barcode_type_code')); |
|
| 162 | + $result = $object->check_barcode(GETPOST('barcode'), GETPOST('barcode_type_code')); |
|
| 163 | 163 | |
| 164 | 164 | if ($result >= 0) |
| 165 | 165 | { |
@@ -183,28 +183,28 @@ discard block |
||
| 183 | 183 | // Add a product or service |
| 184 | 184 | if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) |
| 185 | 185 | { |
| 186 | - $error=0; |
|
| 186 | + $error = 0; |
|
| 187 | 187 | |
| 188 | - if (! GETPOST('label')) |
|
| 188 | + if (!GETPOST('label')) |
|
| 189 | 189 | { |
| 190 | - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')), null, 'errors'); |
|
| 190 | + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Label')), null, 'errors'); |
|
| 191 | 191 | $action = "create"; |
| 192 | 192 | $error++; |
| 193 | 193 | } |
| 194 | 194 | if (empty($ref)) |
| 195 | 195 | { |
| 196 | - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')), null, 'errors'); |
|
| 196 | + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Ref')), null, 'errors'); |
|
| 197 | 197 | $action = "create"; |
| 198 | 198 | $error++; |
| 199 | 199 | } |
| 200 | - if (! empty($duration_value) && empty($duration_unit)) |
|
| 200 | + if (!empty($duration_value) && empty($duration_unit)) |
|
| 201 | 201 | { |
| 202 | - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Unit')), null, 'errors'); |
|
| 202 | + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Unit')), null, 'errors'); |
|
| 203 | 203 | $action = "create"; |
| 204 | 204 | $error++; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if (! $error) |
|
| 207 | + if (!$error) |
|
| 208 | 208 | { |
| 209 | 209 | $units = GETPOST('units', 'int'); |
| 210 | 210 | |
@@ -221,25 +221,25 @@ discard block |
||
| 221 | 221 | else |
| 222 | 222 | $object->price_min = GETPOST('price_min'); |
| 223 | 223 | |
| 224 | - $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' |
|
| 224 | + $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' |
|
| 225 | 225 | |
| 226 | 226 | // We must define tva_tx, npr and local taxes |
| 227 | 227 | $vatratecode = ''; |
| 228 | - $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot |
|
| 228 | + $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot |
|
| 229 | 229 | $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; |
| 230 | 230 | $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; |
| 231 | 231 | // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes |
| 232 | 232 | if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) |
| 233 | 233 | { |
| 234 | 234 | // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price. |
| 235 | - $vatratecode=$reg[1]; |
|
| 235 | + $vatratecode = $reg[1]; |
|
| 236 | 236 | // Get record from code |
| 237 | 237 | $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; |
| 238 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; |
|
| 239 | - $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; |
|
| 240 | - $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; |
|
| 241 | - $sql.= " AND t.code ='".$vatratecode."'"; |
|
| 242 | - $resql=$db->query($sql); |
|
| 238 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; |
|
| 239 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; |
|
| 240 | + $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; |
|
| 241 | + $sql .= " AND t.code ='".$vatratecode."'"; |
|
| 242 | + $resql = $db->query($sql); |
|
| 243 | 243 | if ($resql) |
| 244 | 244 | { |
| 245 | 245 | $obj = $db->fetch_object($resql); |
@@ -262,19 +262,19 @@ discard block |
||
| 262 | 262 | $object->type = $type; |
| 263 | 263 | $object->status = GETPOST('statut'); |
| 264 | 264 | $object->status_buy = GETPOST('statut_buy'); |
| 265 | - $object->status_batch = GETPOST('status_batch'); |
|
| 265 | + $object->status_batch = GETPOST('status_batch'); |
|
| 266 | 266 | |
| 267 | 267 | $object->barcode_type = GETPOST('fk_barcode_type'); |
| 268 | - $object->barcode = GETPOST('barcode'); |
|
| 268 | + $object->barcode = GETPOST('barcode'); |
|
| 269 | 269 | // Set barcode_type_xxx from barcode_type id |
| 270 | - $stdobject=new GenericObject($db); |
|
| 271 | - $stdobject->element='product'; |
|
| 272 | - $stdobject->barcode_type=GETPOST('fk_barcode_type'); |
|
| 273 | - $result=$stdobject->fetch_barcode(); |
|
| 270 | + $stdobject = new GenericObject($db); |
|
| 271 | + $stdobject->element = 'product'; |
|
| 272 | + $stdobject->barcode_type = GETPOST('fk_barcode_type'); |
|
| 273 | + $result = $stdobject->fetch_barcode(); |
|
| 274 | 274 | if ($result < 0) |
| 275 | 275 | { |
| 276 | 276 | $error++; |
| 277 | - $mesg='Failed to get bar code type information '; |
|
| 277 | + $mesg = 'Failed to get bar code type information '; |
|
| 278 | 278 | setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); |
| 279 | 279 | } |
| 280 | 280 | $object->barcode_type_code = $stdobject->barcode_type_code; |
@@ -282,43 +282,43 @@ discard block |
||
| 282 | 282 | $object->barcode_type_label = $stdobject->barcode_type_label; |
| 283 | 283 | |
| 284 | 284 | $object->description = dol_htmlcleanlastbr(GETPOST('desc')); |
| 285 | - $object->url = GETPOST('url'); |
|
| 285 | + $object->url = GETPOST('url'); |
|
| 286 | 286 | $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private')); |
| 287 | - $object->note = $object->note_private; // deprecated |
|
| 287 | + $object->note = $object->note_private; // deprecated |
|
| 288 | 288 | $object->customcode = GETPOST('customcode'); |
| 289 | 289 | $object->country_id = GETPOST('country_id'); |
| 290 | 290 | $object->duration_value = $duration_value; |
| 291 | 291 | $object->duration_unit = $duration_unit; |
| 292 | - $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte')?GETPOST('seuil_stock_alerte'):0; |
|
| 293 | - $object->desiredstock = GETPOST('desiredstock')?GETPOST('desiredstock'):0; |
|
| 292 | + $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte') ? GETPOST('seuil_stock_alerte') : 0; |
|
| 293 | + $object->desiredstock = GETPOST('desiredstock') ? GETPOST('desiredstock') : 0; |
|
| 294 | 294 | $object->canvas = GETPOST('canvas'); |
| 295 | 295 | $object->weight = GETPOST('weight'); |
| 296 | 296 | $object->weight_units = GETPOST('weight_units'); |
| 297 | 297 | $object->length = GETPOST('size'); |
| 298 | 298 | $object->length_units = GETPOST('size_units'); |
| 299 | - $object->width = GETPOST('sizewidth'); |
|
| 299 | + $object->width = GETPOST('sizewidth'); |
|
| 300 | 300 | $object->height = GETPOST('sizeheight'); |
| 301 | - $object->surface = GETPOST('surface'); |
|
| 301 | + $object->surface = GETPOST('surface'); |
|
| 302 | 302 | $object->surface_units = GETPOST('surface_units'); |
| 303 | 303 | $object->volume = GETPOST('volume'); |
| 304 | 304 | $object->volume_units = GETPOST('volume_units'); |
| 305 | 305 | $object->finished = GETPOST('finished'); |
| 306 | 306 | $object->fk_unit = GETPOST('units'); |
| 307 | 307 | |
| 308 | - $accountancy_code_sell = GETPOST('accountancy_code_sell'); |
|
| 309 | - $accountancy_code_buy = GETPOST('accountancy_code_buy'); |
|
| 308 | + $accountancy_code_sell = GETPOST('accountancy_code_sell'); |
|
| 309 | + $accountancy_code_buy = GETPOST('accountancy_code_buy'); |
|
| 310 | 310 | |
| 311 | 311 | if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } |
| 312 | 312 | if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } |
| 313 | 313 | |
| 314 | 314 | // MultiPrix |
| 315 | - if (! empty($conf->global->PRODUIT_MULTIPRICES)) |
|
| 315 | + if (!empty($conf->global->PRODUIT_MULTIPRICES)) |
|
| 316 | 316 | { |
| 317 | - for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) |
|
| 317 | + for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) |
|
| 318 | 318 | { |
| 319 | 319 | if (isset($_POST["price_".$i])) |
| 320 | 320 | { |
| 321 | - $object->multiprices["$i"] = price2num($_POST["price_".$i],'MU'); |
|
| 321 | + $object->multiprices["$i"] = price2num($_POST["price_".$i], 'MU'); |
|
| 322 | 322 | $object->multiprices_base_type["$i"] = $_POST["multiprices_base_type_".$i]; |
| 323 | 323 | } |
| 324 | 324 | else |
@@ -329,10 +329,10 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // Fill array 'array_options' with data from add form |
| 332 | - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
|
| 332 | + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); |
|
| 333 | 333 | if ($ret < 0) $error++; |
| 334 | 334 | |
| 335 | - if (! $error) |
|
| 335 | + if (!$error) |
|
| 336 | 336 | { |
| 337 | 337 | $id = $object->create($user); |
| 338 | 338 | } |
@@ -366,22 +366,22 @@ discard block |
||
| 366 | 366 | { |
| 367 | 367 | if ($object->id > 0) |
| 368 | 368 | { |
| 369 | - $object->oldcopy= clone $object; |
|
| 369 | + $object->oldcopy = clone $object; |
|
| 370 | 370 | |
| 371 | 371 | $object->ref = $ref; |
| 372 | 372 | $object->label = GETPOST('label'); |
| 373 | 373 | $object->description = dol_htmlcleanlastbr(GETPOST('desc')); |
| 374 | - $object->url = GETPOST('url'); |
|
| 375 | - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
| 374 | + $object->url = GETPOST('url'); |
|
| 375 | + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
| 376 | 376 | { |
| 377 | - $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private')); |
|
| 378 | - $object->note = $object->note_private; |
|
| 377 | + $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private')); |
|
| 378 | + $object->note = $object->note_private; |
|
| 379 | 379 | } |
| 380 | 380 | $object->customcode = GETPOST('customcode'); |
| 381 | 381 | $object->country_id = GETPOST('country_id'); |
| 382 | 382 | $object->status = GETPOST('statut'); |
| 383 | 383 | $object->status_buy = GETPOST('statut_buy'); |
| 384 | - $object->status_batch = GETPOST('status_batch'); |
|
| 384 | + $object->status_batch = GETPOST('status_batch'); |
|
| 385 | 385 | // removed from update view so GETPOST always empty |
| 386 | 386 | /* |
| 387 | 387 | $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); |
@@ -395,8 +395,8 @@ discard block |
||
| 395 | 395 | $object->weight_units = GETPOST('weight_units'); |
| 396 | 396 | $object->length = GETPOST('size'); |
| 397 | 397 | $object->length_units = GETPOST('size_units'); |
| 398 | - $object->width = GETPOST('sizewidth'); |
|
| 399 | - $object->height = GETPOST('sizeheight'); |
|
| 398 | + $object->width = GETPOST('sizewidth'); |
|
| 399 | + $object->height = GETPOST('sizeheight'); |
|
| 400 | 400 | |
| 401 | 401 | $object->surface = GETPOST('surface'); |
| 402 | 402 | $object->surface_units = GETPOST('surface_units'); |
@@ -412,34 +412,34 @@ discard block |
||
| 412 | 412 | $object->fk_unit = null; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - $object->barcode_type = GETPOST('fk_barcode_type'); |
|
| 416 | - $object->barcode = GETPOST('barcode'); |
|
| 415 | + $object->barcode_type = GETPOST('fk_barcode_type'); |
|
| 416 | + $object->barcode = GETPOST('barcode'); |
|
| 417 | 417 | // Set barcode_type_xxx from barcode_type id |
| 418 | - $stdobject=new GenericObject($db); |
|
| 419 | - $stdobject->element='product'; |
|
| 420 | - $stdobject->barcode_type=GETPOST('fk_barcode_type'); |
|
| 421 | - $result=$stdobject->fetch_barcode(); |
|
| 418 | + $stdobject = new GenericObject($db); |
|
| 419 | + $stdobject->element = 'product'; |
|
| 420 | + $stdobject->barcode_type = GETPOST('fk_barcode_type'); |
|
| 421 | + $result = $stdobject->fetch_barcode(); |
|
| 422 | 422 | if ($result < 0) |
| 423 | 423 | { |
| 424 | 424 | $error++; |
| 425 | - $mesg='Failed to get bar code type information '; |
|
| 425 | + $mesg = 'Failed to get bar code type information '; |
|
| 426 | 426 | setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); |
| 427 | 427 | } |
| 428 | 428 | $object->barcode_type_code = $stdobject->barcode_type_code; |
| 429 | 429 | $object->barcode_type_coder = $stdobject->barcode_type_coder; |
| 430 | 430 | $object->barcode_type_label = $stdobject->barcode_type_label; |
| 431 | 431 | |
| 432 | - $accountancy_code_sell = GETPOST('accountancy_code_sell'); |
|
| 433 | - $accountancy_code_buy = GETPOST('accountancy_code_buy'); |
|
| 432 | + $accountancy_code_sell = GETPOST('accountancy_code_sell'); |
|
| 433 | + $accountancy_code_buy = GETPOST('accountancy_code_buy'); |
|
| 434 | 434 | |
| 435 | 435 | if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } |
| 436 | 436 | if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } |
| 437 | 437 | |
| 438 | 438 | // Fill array 'array_options' with data from add form |
| 439 | - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
|
| 439 | + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); |
|
| 440 | 440 | if ($ret < 0) $error++; |
| 441 | 441 | |
| 442 | - if (! $error && $object->check()) |
|
| 442 | + if (!$error && $object->check()) |
|
| 443 | 443 | { |
| 444 | 444 | if ($object->update($object->id, $user) > 0) |
| 445 | 445 | { |
@@ -468,10 +468,10 @@ discard block |
||
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | // Action clone object |
| 471 | - if ($action == 'confirm_clone' && $confirm != 'yes') { $action=''; } |
|
| 471 | + if ($action == 'confirm_clone' && $confirm != 'yes') { $action = ''; } |
|
| 472 | 472 | if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->produit->creer || $user->rights->service->creer)) |
| 473 | 473 | { |
| 474 | - if (! GETPOST('clone_content') && ! GETPOST('clone_prices') ) |
|
| 474 | + if (!GETPOST('clone_content') && !GETPOST('clone_prices')) |
|
| 475 | 475 | { |
| 476 | 476 | setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); |
| 477 | 477 | } |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | } |
| 517 | 517 | else |
| 518 | 518 | { |
| 519 | - $id=$originalId; |
|
| 519 | + $id = $originalId; |
|
| 520 | 520 | |
| 521 | 521 | if ($object->error == 'ErrorProductAlreadyExists') |
| 522 | 522 | { |
@@ -525,8 +525,8 @@ discard block |
||
| 525 | 525 | $refalreadyexists++; |
| 526 | 526 | $action = ""; |
| 527 | 527 | |
| 528 | - $mesg=$langs->trans("ErrorProductAlreadyExists",$object->ref); |
|
| 529 | - $mesg.=' <a href="'.$_SERVER["PHP_SELF"].'?ref='.$object->ref.'">'.$langs->trans("ShowCardHere").'</a>.'; |
|
| 528 | + $mesg = $langs->trans("ErrorProductAlreadyExists", $object->ref); |
|
| 529 | + $mesg .= ' <a href="'.$_SERVER["PHP_SELF"].'?ref='.$object->ref.'">'.$langs->trans("ShowCardHere").'</a>.'; |
|
| 530 | 530 | setEventMessages($mesg, null, 'errors'); |
| 531 | 531 | $object->fetch($id); |
| 532 | 532 | } |
@@ -536,12 +536,12 @@ discard block |
||
| 536 | 536 | if (count($object->errors)) |
| 537 | 537 | { |
| 538 | 538 | setEventMessages($object->error, $object->errors, 'errors'); |
| 539 | - dol_print_error($db,$object->errors); |
|
| 539 | + dol_print_error($db, $object->errors); |
|
| 540 | 540 | } |
| 541 | 541 | else |
| 542 | 542 | { |
| 543 | 543 | setEventMessages($langs->trans($object->error), null, 'errors'); |
| 544 | - dol_print_error($db,$object->error); |
|
| 544 | + dol_print_error($db, $object->error); |
|
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | 547 | } |
@@ -550,13 +550,13 @@ discard block |
||
| 550 | 550 | else |
| 551 | 551 | { |
| 552 | 552 | $db->rollback(); |
| 553 | - dol_print_error($db,$object->error); |
|
| 553 | + dol_print_error($db, $object->error); |
|
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | // Delete a product |
| 559 | - if ($action == 'confirm_delete' && $confirm != 'yes') { $action=''; } |
|
| 559 | + if ($action == 'confirm_delete' && $confirm != 'yes') { $action = ''; } |
|
| 560 | 560 | if ($action == 'confirm_delete' && $confirm == 'yes') |
| 561 | 561 | { |
| 562 | 562 | if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)) |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | { |
| 574 | 574 | setEventMessages($langs->trans($object->error), null, 'errors'); |
| 575 | 575 | $reload = 0; |
| 576 | - $action=''; |
|
| 576 | + $action = ''; |
|
| 577 | 577 | } |
| 578 | 578 | } |
| 579 | 579 | |
@@ -581,14 +581,14 @@ discard block |
||
| 581 | 581 | // Add product into object |
| 582 | 582 | if ($object->id > 0 && $action == 'addin') |
| 583 | 583 | { |
| 584 | - $thirpdartyid =0 ; |
|
| 584 | + $thirpdartyid = 0; |
|
| 585 | 585 | if (GETPOST('propalid') > 0) |
| 586 | 586 | { |
| 587 | 587 | $propal = new Propal($db); |
| 588 | - $result=$propal->fetch(GETPOST('propalid')); |
|
| 588 | + $result = $propal->fetch(GETPOST('propalid')); |
|
| 589 | 589 | if ($result <= 0) |
| 590 | 590 | { |
| 591 | - dol_print_error($db,$propal->error); |
|
| 591 | + dol_print_error($db, $propal->error); |
|
| 592 | 592 | exit; |
| 593 | 593 | } |
| 594 | 594 | $thirpdartyid = $propal->socid; |
@@ -596,10 +596,10 @@ discard block |
||
| 596 | 596 | elseif (GETPOST('commandeid') > 0) |
| 597 | 597 | { |
| 598 | 598 | $commande = new Commande($db); |
| 599 | - $result=$commande->fetch(GETPOST('commandeid')); |
|
| 599 | + $result = $commande->fetch(GETPOST('commandeid')); |
|
| 600 | 600 | if ($result <= 0) |
| 601 | 601 | { |
| 602 | - dol_print_error($db,$commande->error); |
|
| 602 | + dol_print_error($db, $commande->error); |
|
| 603 | 603 | exit; |
| 604 | 604 | } |
| 605 | 605 | $thirpdartyid = $commande->socid; |
@@ -607,16 +607,16 @@ discard block |
||
| 607 | 607 | elseif (GETPOST('factureid') > 0) |
| 608 | 608 | { |
| 609 | 609 | $facture = new Facture($db); |
| 610 | - $result=$facture->fetch(GETPOST('factureid')); |
|
| 610 | + $result = $facture->fetch(GETPOST('factureid')); |
|
| 611 | 611 | if ($result <= 0) |
| 612 | 612 | { |
| 613 | - dol_print_error($db,$facture->error); |
|
| 613 | + dol_print_error($db, $facture->error); |
|
| 614 | 614 | exit; |
| 615 | 615 | } |
| 616 | 616 | $thirpdartyid = $facture->socid; |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - if ( $thirpdartyid > 0) { |
|
| 619 | + if ($thirpdartyid > 0) { |
|
| 620 | 620 | $soc = new Societe($db); |
| 621 | 621 | $result = $soc->fetch($thirpdartyid); |
| 622 | 622 | if ($result <= 0) { |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | |
| 629 | 629 | $tva_tx = get_default_tva($mysoc, $soc, $object->id); |
| 630 | 630 | $tva_npr = get_default_npr($mysoc, $soc, $object->id); |
| 631 | - if (empty($tva_tx)) $tva_npr=0; |
|
| 631 | + if (empty($tva_tx)) $tva_npr = 0; |
|
| 632 | 632 | $localtax1_tx = get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr); |
| 633 | 633 | $localtax2_tx = get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr); |
| 634 | 634 | |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | $pu_ttc = $object->multiprices_ttc[$soc->price_level]; |
| 643 | 643 | $price_base_type = $object->multiprices_base_type[$soc->price_level]; |
| 644 | 644 | } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { |
| 645 | - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; |
|
| 645 | + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; |
|
| 646 | 646 | |
| 647 | 647 | $prodcustprice = new Productcustomerprice($db); |
| 648 | 648 | |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | |
| 675 | 675 | if (GETPOST('propalid') > 0) { |
| 676 | 676 | // Define cost price for margin calculation |
| 677 | - $buyprice=0; |
|
| 677 | + $buyprice = 0; |
|
| 678 | 678 | if (($result = $propal->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0) |
| 679 | 679 | { |
| 680 | 680 | dol_syslog($langs->trans('FailedToGetCostPrice')); |
@@ -710,14 +710,14 @@ discard block |
||
| 710 | 710 | $object->fk_unit |
| 711 | 711 | ); |
| 712 | 712 | if ($result > 0) { |
| 713 | - header("Location: " . DOL_URL_ROOT . "/comm/propal/card.php?id=" . $propal->id); |
|
| 713 | + header("Location: ".DOL_URL_ROOT."/comm/propal/card.php?id=".$propal->id); |
|
| 714 | 714 | return; |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | - setEventMessages($langs->trans("ErrorUnknown") . ": $result", null, 'errors'); |
|
| 717 | + setEventMessages($langs->trans("ErrorUnknown").": $result", null, 'errors'); |
|
| 718 | 718 | } elseif (GETPOST('commandeid') > 0) { |
| 719 | 719 | // Define cost price for margin calculation |
| 720 | - $buyprice=0; |
|
| 720 | + $buyprice = 0; |
|
| 721 | 721 | if (($result = $commande->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0) |
| 722 | 722 | { |
| 723 | 723 | dol_syslog($langs->trans('FailedToGetCostPrice')); |
@@ -755,12 +755,12 @@ discard block |
||
| 755 | 755 | ); |
| 756 | 756 | |
| 757 | 757 | if ($result > 0) { |
| 758 | - header("Location: " . DOL_URL_ROOT . "/commande/card.php?id=" . $commande->id); |
|
| 758 | + header("Location: ".DOL_URL_ROOT."/commande/card.php?id=".$commande->id); |
|
| 759 | 759 | exit; |
| 760 | 760 | } |
| 761 | 761 | } elseif (GETPOST('factureid') > 0) { |
| 762 | 762 | // Define cost price for margin calculation |
| 763 | - $buyprice=0; |
|
| 763 | + $buyprice = 0; |
|
| 764 | 764 | if (($result = $facture->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0) |
| 765 | 765 | { |
| 766 | 766 | dol_syslog($langs->trans('FailedToGetCostPrice')); |
@@ -803,13 +803,13 @@ discard block |
||
| 803 | 803 | ); |
| 804 | 804 | |
| 805 | 805 | if ($result > 0) { |
| 806 | - header("Location: " . DOL_URL_ROOT . "/compta/facture/card.php?facid=" . $facture->id); |
|
| 806 | + header("Location: ".DOL_URL_ROOT."/compta/facture/card.php?facid=".$facture->id); |
|
| 807 | 807 | exit; |
| 808 | 808 | } |
| 809 | 809 | } |
| 810 | 810 | } |
| 811 | 811 | else { |
| 812 | - $action=""; |
|
| 812 | + $action = ""; |
|
| 813 | 813 | setEventMessages($langs->trans("WarningSelectOneDocument"), null, 'warnings'); |
| 814 | 814 | } |
| 815 | 815 | } |
@@ -823,16 +823,16 @@ discard block |
||
| 823 | 823 | |
| 824 | 824 | $title = $langs->trans('ProductServiceCard'); |
| 825 | 825 | $helpurl = ''; |
| 826 | -$shortlabel = dol_trunc($object->label,16); |
|
| 826 | +$shortlabel = dol_trunc($object->label, 16); |
|
| 827 | 827 | if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) |
| 828 | 828 | { |
| 829 | - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Card'); |
|
| 830 | - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; |
|
| 829 | + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card'); |
|
| 830 | + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; |
|
| 831 | 831 | } |
| 832 | 832 | if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) |
| 833 | 833 | { |
| 834 | - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Card'); |
|
| 835 | - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; |
|
| 834 | + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card'); |
|
| 835 | + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | llxHeader('', $title, $helpurl); |
@@ -840,22 +840,22 @@ discard block |
||
| 840 | 840 | $form = new Form($db); |
| 841 | 841 | $formfile = new FormFile($db); |
| 842 | 842 | $formproduct = new FormProduct($db); |
| 843 | -if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db); |
|
| 843 | +if (!empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db); |
|
| 844 | 844 | |
| 845 | 845 | // Load object modBarCodeProduct |
| 846 | -$res=0; |
|
| 847 | -if (! empty($conf->barcode->enabled) && ! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) |
|
| 846 | +$res = 0; |
|
| 847 | +if (!empty($conf->barcode->enabled) && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) |
|
| 848 | 848 | { |
| 849 | - $module=strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); |
|
| 850 | - $dirbarcode=array_merge(array('/core/modules/barcode/'),$conf->modules_parts['barcode']); |
|
| 849 | + $module = strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); |
|
| 850 | + $dirbarcode = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); |
|
| 851 | 851 | foreach ($dirbarcode as $dirroot) |
| 852 | 852 | { |
| 853 | - $res=dol_include_once($dirroot.$module.'.php'); |
|
| 853 | + $res = dol_include_once($dirroot.$module.'.php'); |
|
| 854 | 854 | if ($res) break; |
| 855 | 855 | } |
| 856 | 856 | if ($res > 0) |
| 857 | 857 | { |
| 858 | - $modBarCodeProduct =new $module(); |
|
| 858 | + $modBarCodeProduct = new $module(); |
|
| 859 | 859 | } |
| 860 | 860 | } |
| 861 | 861 | |
@@ -868,11 +868,11 @@ discard block |
||
| 868 | 868 | if (empty($object->error) && $id) |
| 869 | 869 | { |
| 870 | 870 | $object = new Product($db); |
| 871 | - $result=$object->fetch($id); |
|
| 872 | - if ($result <= 0) dol_print_error('',$object->error); |
|
| 871 | + $result = $object->fetch($id); |
|
| 872 | + if ($result <= 0) dol_print_error('', $object->error); |
|
| 873 | 873 | } |
| 874 | - $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates |
|
| 875 | - $objcanvas->display_canvas($action); // Show template |
|
| 874 | + $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates |
|
| 875 | + $objcanvas->display_canvas($action); // Show template |
|
| 876 | 876 | } |
| 877 | 877 | else |
| 878 | 878 | { |
@@ -885,12 +885,12 @@ discard block |
||
| 885 | 885 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 886 | 886 | |
| 887 | 887 | // Load object modCodeProduct |
| 888 | - $module=(! empty($conf->global->PRODUCT_CODEPRODUCT_ADDON)?$conf->global->PRODUCT_CODEPRODUCT_ADDON:'mod_codeproduct_leopard'); |
|
| 888 | + $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard'); |
|
| 889 | 889 | if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') |
| 890 | 890 | { |
| 891 | - $module = substr($module, 0, dol_strlen($module)-4); |
|
| 891 | + $module = substr($module, 0, dol_strlen($module) - 4); |
|
| 892 | 892 | } |
| 893 | - $result=dol_include_once('/core/modules/product/'.$module.'.php'); |
|
| 893 | + $result = dol_include_once('/core/modules/product/'.$module.'.php'); |
|
| 894 | 894 | if ($result > 0) |
| 895 | 895 | { |
| 896 | 896 | $modCodeProduct = new $module(); |
@@ -902,24 +902,24 @@ discard block |
||
| 902 | 902 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 903 | 903 | print '<input type="hidden" name="action" value="add">'; |
| 904 | 904 | print '<input type="hidden" name="type" value="'.$type.'">'."\n"; |
| 905 | - if (! empty($modCodeProduct->code_auto)) |
|
| 905 | + if (!empty($modCodeProduct->code_auto)) |
|
| 906 | 906 | print '<input type="hidden" name="code_auto" value="1">'; |
| 907 | - if (! empty($modBarCodeProduct->code_auto)) |
|
| 907 | + if (!empty($modBarCodeProduct->code_auto)) |
|
| 908 | 908 | print '<input type="hidden" name="barcode_auto" value="1">'; |
| 909 | 909 | |
| 910 | - if ($type==1) $title=$langs->trans("NewService"); |
|
| 911 | - else $title=$langs->trans("NewProduct"); |
|
| 912 | - $linkback=""; |
|
| 913 | - print load_fiche_titre($title,$linkback,'title_products.png'); |
|
| 910 | + if ($type == 1) $title = $langs->trans("NewService"); |
|
| 911 | + else $title = $langs->trans("NewProduct"); |
|
| 912 | + $linkback = ""; |
|
| 913 | + print load_fiche_titre($title, $linkback, 'title_products.png'); |
|
| 914 | 914 | |
| 915 | 915 | dol_fiche_head(''); |
| 916 | 916 | |
| 917 | 917 | print '<table class="border centpercent">'; |
| 918 | 918 | |
| 919 | 919 | print '<tr>'; |
| 920 | - $tmpcode=''; |
|
| 921 | - if (! empty($modCodeProduct->code_auto)) $tmpcode=$modCodeProduct->getNextValue($object,$type); |
|
| 922 | - print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="'.dol_escape_htmltag(GETPOST('ref')?GETPOST('ref'):$tmpcode).'">'; |
|
| 920 | + $tmpcode = ''; |
|
| 921 | + if (!empty($modCodeProduct->code_auto)) $tmpcode = $modCodeProduct->getNextValue($object, $type); |
|
| 922 | + print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="'.dol_escape_htmltag(GETPOST('ref') ? GETPOST('ref') : $tmpcode).'">'; |
|
| 923 | 923 | if ($refalreadyexists) |
| 924 | 924 | { |
| 925 | 925 | print $langs->trans("RefAlreadyExists"); |
@@ -931,45 +931,45 @@ discard block |
||
| 931 | 931 | |
| 932 | 932 | // On sell |
| 933 | 933 | print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="3">'; |
| 934 | - $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); |
|
| 935 | - print $form->selectarray('statut',$statutarray,GETPOST('statut')); |
|
| 934 | + $statutarray = array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); |
|
| 935 | + print $form->selectarray('statut', $statutarray, GETPOST('statut')); |
|
| 936 | 936 | print '</td></tr>'; |
| 937 | 937 | |
| 938 | 938 | // To buy |
| 939 | 939 | print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="3">'; |
| 940 | - $statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy")); |
|
| 941 | - print $form->selectarray('statut_buy',$statutarray,GETPOST('statut_buy')); |
|
| 940 | + $statutarray = array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy")); |
|
| 941 | + print $form->selectarray('statut_buy', $statutarray, GETPOST('statut_buy')); |
|
| 942 | 942 | print '</td></tr>'; |
| 943 | 943 | |
| 944 | 944 | // Batch number management |
| 945 | - if (! empty($conf->productbatch->enabled)) |
|
| 945 | + if (!empty($conf->productbatch->enabled)) |
|
| 946 | 946 | { |
| 947 | 947 | print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="3">'; |
| 948 | - $statutarray=array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch")); |
|
| 949 | - print $form->selectarray('status_batch',$statutarray,GETPOST('status_batch')); |
|
| 948 | + $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch")); |
|
| 949 | + print $form->selectarray('status_batch', $statutarray, GETPOST('status_batch')); |
|
| 950 | 950 | print '</td></tr>'; |
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - $showbarcode=empty($conf->barcode->enabled)?0:1; |
|
| 954 | - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; |
|
| 953 | + $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; |
|
| 954 | + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0; |
|
| 955 | 955 | |
| 956 | 956 | if ($showbarcode) |
| 957 | 957 | { |
| 958 | 958 | print '<tr><td>'.$langs->trans('BarcodeType').'</td><td>'; |
| 959 | 959 | if (isset($_POST['fk_barcode_type'])) |
| 960 | 960 | { |
| 961 | - $fk_barcode_type=GETPOST('fk_barcode_type'); |
|
| 961 | + $fk_barcode_type = GETPOST('fk_barcode_type'); |
|
| 962 | 962 | } |
| 963 | 963 | else |
| 964 | 964 | { |
| 965 | - if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 965 | + if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 966 | 966 | } |
| 967 | 967 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; |
| 968 | 968 | $formbarcode = new FormBarCode($db); |
| 969 | 969 | print $formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); |
| 970 | 970 | print '</td><td>'.$langs->trans("BarcodeValue").'</td><td>'; |
| 971 | - $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; |
|
| 972 | - if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
|
| 971 | + $tmpcode = isset($_POST['barcode']) ? GETPOST('barcode') : $object->barcode; |
|
| 972 | + if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) $tmpcode = $modBarCodeProduct->getNextValue($object, $type); |
|
| 973 | 973 | print '<input class="maxwidth100" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).'">'; |
| 974 | 974 | print '</td></tr>'; |
| 975 | 975 | } |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | print '</td></tr>'; |
| 989 | 989 | |
| 990 | 990 | // Stock min level |
| 991 | - if ($type != 1 && ! empty($conf->stock->enabled)) |
|
| 991 | + if ($type != 1 && !empty($conf->stock->enabled)) |
|
| 992 | 992 | { |
| 993 | 993 | print '<tr><td>'.$form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1).'</td><td>'; |
| 994 | 994 | print '<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST('seuil_stock_alerte').'">'; |
@@ -1008,15 +1008,15 @@ discard block |
||
| 1008 | 1008 | if ($type != 1) |
| 1009 | 1009 | { |
| 1010 | 1010 | print '<tr><td>'.$langs->trans("Nature").'</td><td colspan="3">'; |
| 1011 | - $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); |
|
| 1012 | - print $form->selectarray('finished',$statutarray,GETPOST('finished'),1); |
|
| 1011 | + $statutarray = array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); |
|
| 1012 | + print $form->selectarray('finished', $statutarray, GETPOST('finished'), 1); |
|
| 1013 | 1013 | print '</td></tr>'; |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | // Duration |
| 1017 | 1017 | if ($type == 1) |
| 1018 | 1018 | { |
| 1019 | - print '<tr><td>' . $langs->trans("Duration") . '</td><td colspan="3"><input name="duration_value" size="6" maxlength="5" value="' . $duration_value . '"> '; |
|
| 1019 | + print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3"><input name="duration_value" size="6" maxlength="5" value="'.$duration_value.'"> '; |
|
| 1020 | 1020 | print '<input name="duration_unit" type="radio" value="h">'.$langs->trans("Hour").' '; |
| 1021 | 1021 | print '<input name="duration_unit" type="radio" value="d">'.$langs->trans("Day").' '; |
| 1022 | 1022 | print '<input name="duration_unit" type="radio" value="w">'.$langs->trans("Week").' '; |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | // Weight |
| 1031 | 1031 | print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="3">'; |
| 1032 | 1032 | print '<input name="weight" size="4" value="'.GETPOST('weight').'">'; |
| 1033 | - print $formproduct->select_measuring_units("weight_units","weight"); |
|
| 1033 | + print $formproduct->select_measuring_units("weight_units", "weight"); |
|
| 1034 | 1034 | print '</td></tr>'; |
| 1035 | 1035 | // Length |
| 1036 | 1036 | if (empty($conf->global->PRODUCT_DISABLE_SIZE)) |
@@ -1039,7 +1039,7 @@ discard block |
||
| 1039 | 1039 | print '<input name="size" size="4" value="'.GETPOST('size').'"> x '; |
| 1040 | 1040 | print '<input name="sizewidth" size="4" value="'.GETPOST('sizewidth').'"> x '; |
| 1041 | 1041 | print '<input name="sizeheight" size="4" value="'.GETPOST('sizeheight').'">'; |
| 1042 | - print $formproduct->select_measuring_units("size_units","size"); |
|
| 1042 | + print $formproduct->select_measuring_units("size_units", "size"); |
|
| 1043 | 1043 | print '</td></tr>'; |
| 1044 | 1044 | } |
| 1045 | 1045 | if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) |
@@ -1047,22 +1047,22 @@ discard block |
||
| 1047 | 1047 | // Surface |
| 1048 | 1048 | print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="3">'; |
| 1049 | 1049 | print '<input name="surface" size="4" value="'.GETPOST('surface').'">'; |
| 1050 | - print $formproduct->select_measuring_units("surface_units","surface"); |
|
| 1050 | + print $formproduct->select_measuring_units("surface_units", "surface"); |
|
| 1051 | 1051 | print '</td></tr>'; |
| 1052 | 1052 | } |
| 1053 | 1053 | // Volume |
| 1054 | 1054 | print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="3">'; |
| 1055 | 1055 | print '<input name="volume" size="4" value="'.GETPOST('volume').'">'; |
| 1056 | - print $formproduct->select_measuring_units("volume_units","volume"); |
|
| 1056 | + print $formproduct->select_measuring_units("volume_units", "volume"); |
|
| 1057 | 1057 | print '</td></tr>'; |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | // Units |
| 1061 | - if($conf->global->PRODUCT_USE_UNITS) |
|
| 1061 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
| 1062 | 1062 | { |
| 1063 | 1063 | print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>'; |
| 1064 | 1064 | print '<td colspan="3">'; |
| 1065 | - print $form->selectUnits('','units'); |
|
| 1065 | + print $form->selectUnits('', 'units'); |
|
| 1066 | 1066 | print '</td></tr>'; |
| 1067 | 1067 | } |
| 1068 | 1068 | |
@@ -1072,18 +1072,18 @@ discard block |
||
| 1072 | 1072 | print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.GETPOST('customcode').'"></td>'; |
| 1073 | 1073 | // Origin country |
| 1074 | 1074 | print '<td>'.$langs->trans("CountryOrigin").'</td><td>'; |
| 1075 | - print $form->select_country(GETPOST('country_id','int'),'country_id'); |
|
| 1076 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 1075 | + print $form->select_country(GETPOST('country_id', 'int'), 'country_id'); |
|
| 1076 | + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 1077 | 1077 | print '</td></tr>'; |
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | // Other attributes |
| 1081 | - $parameters=array('cols' => 3); |
|
| 1082 | - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 1081 | + $parameters = array('cols' => 3); |
|
| 1082 | + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
| 1083 | 1083 | print $hookmanager->resPrint; |
| 1084 | - if (empty($reshook) && ! empty($extrafields->attribute_label)) |
|
| 1084 | + if (empty($reshook) && !empty($extrafields->attribute_label)) |
|
| 1085 | 1085 | { |
| 1086 | - print $object->showOptionals($extrafields,'edit',$parameters); |
|
| 1086 | + print $object->showOptionals($extrafields, 'edit', $parameters); |
|
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | 1089 | // Note (private, no output on invoices, propales...) |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | print "</td></tr>"; |
| 1099 | 1099 | //} |
| 1100 | 1100 | |
| 1101 | - if($conf->categorie->enabled) { |
|
| 1101 | + if ($conf->categorie->enabled) { |
|
| 1102 | 1102 | // Categories |
| 1103 | 1103 | print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">'; |
| 1104 | 1104 | $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); |
@@ -1110,7 +1110,7 @@ discard block |
||
| 1110 | 1110 | |
| 1111 | 1111 | print '<br>'; |
| 1112 | 1112 | |
| 1113 | - if (! empty($conf->global->PRODUIT_MULTIPRICES)) |
|
| 1113 | + if (!empty($conf->global->PRODUIT_MULTIPRICES)) |
|
| 1114 | 1114 | { |
| 1115 | 1115 | // We do no show price array on create when multiprices enabled. |
| 1116 | 1116 | // We must set them on prices tab. |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | |
| 1133 | 1133 | // VAT |
| 1134 | 1134 | print '<tr><td>'.$langs->trans("VATRate").'</td><td>'; |
| 1135 | - $defaultva=get_default_tva($mysoc, $mysoc); |
|
| 1135 | + $defaultva = get_default_tva($mysoc, $mysoc); |
|
| 1136 | 1136 | print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1); |
| 1137 | 1137 | print '</td></tr>'; |
| 1138 | 1138 | |
@@ -1144,7 +1144,7 @@ discard block |
||
| 1144 | 1144 | // Accountancy codes |
| 1145 | 1145 | print '<table class="border" width="100%">'; |
| 1146 | 1146 | |
| 1147 | - if (! empty($conf->accounting->enabled)) |
|
| 1147 | + if (!empty($conf->accounting->enabled)) |
|
| 1148 | 1148 | { |
| 1149 | 1149 | // Accountancy_code_sell |
| 1150 | 1150 | print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>'; |
@@ -1175,9 +1175,9 @@ discard block |
||
| 1175 | 1175 | dol_fiche_end(); |
| 1176 | 1176 | |
| 1177 | 1177 | print '<div class="center">'; |
| 1178 | - print '<input type="submit" class="button" value="' . $langs->trans("Create") . '">'; |
|
| 1178 | + print '<input type="submit" class="button" value="'.$langs->trans("Create").'">'; |
|
| 1179 | 1179 | print ' '; |
| 1180 | - print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">'; |
|
| 1180 | + print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; |
|
| 1181 | 1181 | print '</div>'; |
| 1182 | 1182 | |
| 1183 | 1183 | print '</form>'; |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | else if ($object->id > 0) |
| 1191 | 1191 | { |
| 1192 | 1192 | // Fiche en mode edition |
| 1193 | - if ($action == 'edit' && ((($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)))) |
|
| 1193 | + if ($action == 'edit' && ((($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)))) |
|
| 1194 | 1194 | { |
| 1195 | 1195 | //WYSIWYG Editor |
| 1196 | 1196 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
@@ -1206,9 +1206,9 @@ discard block |
||
| 1206 | 1206 | print '<input type="hidden" name="id" value="'.$object->id.'">'; |
| 1207 | 1207 | print '<input type="hidden" name="canvas" value="'.$object->canvas.'">'; |
| 1208 | 1208 | |
| 1209 | - $head=product_prepare_head($object); |
|
| 1210 | - $titre=$langs->trans("CardProduct".$object->type); |
|
| 1211 | - $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); |
|
| 1209 | + $head = product_prepare_head($object); |
|
| 1210 | + $titre = $langs->trans("CardProduct".$object->type); |
|
| 1211 | + $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); |
|
| 1212 | 1212 | dol_fiche_head($head, 'card', $titre, 0, $picto); |
| 1213 | 1213 | |
| 1214 | 1214 | print '<table class="border allwidth">'; |
@@ -1254,33 +1254,33 @@ discard block |
||
| 1254 | 1254 | // Batch number managment |
| 1255 | 1255 | if ($conf->productbatch->enabled) { |
| 1256 | 1256 | print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="3">'; |
| 1257 | - $statutarray=array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch")); |
|
| 1258 | - print $form->selectarray('status_batch',$statutarray,$object->status_batch); |
|
| 1257 | + $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch")); |
|
| 1258 | + print $form->selectarray('status_batch', $statutarray, $object->status_batch); |
|
| 1259 | 1259 | print '</td></tr>'; |
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | // Barcode |
| 1263 | - $showbarcode=empty($conf->barcode->enabled)?0:1; |
|
| 1264 | - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; |
|
| 1263 | + $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; |
|
| 1264 | + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0; |
|
| 1265 | 1265 | |
| 1266 | 1266 | if ($showbarcode) |
| 1267 | 1267 | { |
| 1268 | 1268 | print '<tr><td>'.$langs->trans('BarcodeType').'</td><td>'; |
| 1269 | 1269 | if (isset($_POST['fk_barcode_type'])) |
| 1270 | 1270 | { |
| 1271 | - $fk_barcode_type=GETPOST('fk_barcode_type'); |
|
| 1271 | + $fk_barcode_type = GETPOST('fk_barcode_type'); |
|
| 1272 | 1272 | } |
| 1273 | 1273 | else |
| 1274 | 1274 | { |
| 1275 | - $fk_barcode_type=$object->barcode_type; |
|
| 1276 | - if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 1275 | + $fk_barcode_type = $object->barcode_type; |
|
| 1276 | + if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 1277 | 1277 | } |
| 1278 | 1278 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; |
| 1279 | 1279 | $formbarcode = new FormBarCode($db); |
| 1280 | 1280 | print $formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); |
| 1281 | 1281 | print '</td><td>'.$langs->trans("BarcodeValue").'</td><td>'; |
| 1282 | - $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; |
|
| 1283 | - if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
|
| 1282 | + $tmpcode = isset($_POST['barcode']) ? GETPOST('barcode') : $object->barcode; |
|
| 1283 | + if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) $tmpcode = $modBarCodeProduct->getNextValue($object, $type); |
|
| 1284 | 1284 | print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).'">'; |
| 1285 | 1285 | print '</td></tr>'; |
| 1286 | 1286 | } |
@@ -1319,11 +1319,11 @@ discard block |
||
| 1319 | 1319 | }*/ |
| 1320 | 1320 | |
| 1321 | 1321 | // Nature |
| 1322 | - if($object->type!= Product::TYPE_SERVICE) |
|
| 1322 | + if ($object->type != Product::TYPE_SERVICE) |
|
| 1323 | 1323 | { |
| 1324 | 1324 | print '<tr><td>'.$langs->trans("Nature").'</td><td colspan="3">'; |
| 1325 | - $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); |
|
| 1326 | - print $form->selectarray('finished',$statutarray,$object->finished); |
|
| 1325 | + $statutarray = array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); |
|
| 1326 | + print $form->selectarray('finished', $statutarray, $object->finished); |
|
| 1327 | 1327 | print '</td></tr>'; |
| 1328 | 1328 | } |
| 1329 | 1329 | |
@@ -1332,15 +1332,15 @@ discard block |
||
| 1332 | 1332 | // Duration |
| 1333 | 1333 | print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3"><input name="duration_value" size="3" maxlength="5" value="'.$object->duration_value.'">'; |
| 1334 | 1334 | print ' '; |
| 1335 | - print '<input name="duration_unit" type="radio" value="h"'.($object->duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour"); |
|
| 1335 | + print '<input name="duration_unit" type="radio" value="h"'.($object->duration_unit == 'h' ? ' checked' : '').'>'.$langs->trans("Hour"); |
|
| 1336 | 1336 | print ' '; |
| 1337 | - print '<input name="duration_unit" type="radio" value="d"'.($object->duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); |
|
| 1337 | + print '<input name="duration_unit" type="radio" value="d"'.($object->duration_unit == 'd' ? ' checked' : '').'>'.$langs->trans("Day"); |
|
| 1338 | 1338 | print ' '; |
| 1339 | - print '<input name="duration_unit" type="radio" value="w"'.($object->duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); |
|
| 1339 | + print '<input name="duration_unit" type="radio" value="w"'.($object->duration_unit == 'w' ? ' checked' : '').'>'.$langs->trans("Week"); |
|
| 1340 | 1340 | print ' '; |
| 1341 | - print '<input name="duration_unit" type="radio" value="m"'.($object->duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); |
|
| 1341 | + print '<input name="duration_unit" type="radio" value="m"'.($object->duration_unit == 'm' ? ' checked' : '').'>'.$langs->trans("Month"); |
|
| 1342 | 1342 | print ' '; |
| 1343 | - print '<input name="duration_unit" type="radio" value="y"'.($object->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); |
|
| 1343 | + print '<input name="duration_unit" type="radio" value="y"'.($object->duration_unit == 'y' ? ' checked' : '').'>'.$langs->trans("Year"); |
|
| 1344 | 1344 | |
| 1345 | 1345 | print '</td></tr>'; |
| 1346 | 1346 | } |
@@ -1379,7 +1379,7 @@ discard block |
||
| 1379 | 1379 | } |
| 1380 | 1380 | } |
| 1381 | 1381 | // Units |
| 1382 | - if($conf->global->PRODUCT_USE_UNITS) |
|
| 1382 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
| 1383 | 1383 | { |
| 1384 | 1384 | print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>'; |
| 1385 | 1385 | print '<td colspan="3">'; |
@@ -1388,23 +1388,23 @@ discard block |
||
| 1388 | 1388 | } |
| 1389 | 1389 | |
| 1390 | 1390 | // Custom code |
| 1391 | - if (! $object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) |
|
| 1391 | + if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) |
|
| 1392 | 1392 | { |
| 1393 | 1393 | print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.$object->customcode.'"></td>'; |
| 1394 | 1394 | // Origin country |
| 1395 | 1395 | print '<td>'.$langs->trans("CountryOrigin").'</td><td>'; |
| 1396 | 1396 | print $form->select_country($object->country_id, 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone'); |
| 1397 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 1397 | + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 1398 | 1398 | print '</td></tr>'; |
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | 1401 | // Other attributes |
| 1402 | - $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); |
|
| 1403 | - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 1402 | + $parameters = array('colspan' => ' colspan="3"', 'cols'=>3); |
|
| 1403 | + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
| 1404 | 1404 | print $hookmanager->resPrint; |
| 1405 | - if (empty($reshook) && ! empty($extrafields->attribute_label)) |
|
| 1405 | + if (empty($reshook) && !empty($extrafields->attribute_label)) |
|
| 1406 | 1406 | { |
| 1407 | - print $object->showOptionals($extrafields,'edit'); |
|
| 1407 | + print $object->showOptionals($extrafields, 'edit'); |
|
| 1408 | 1408 | } |
| 1409 | 1409 | |
| 1410 | 1410 | // Tags-Categories |
@@ -1413,8 +1413,8 @@ discard block |
||
| 1413 | 1413 | print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td colspan="3">'; |
| 1414 | 1414 | $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); |
| 1415 | 1415 | $c = new Categorie($db); |
| 1416 | - $cats = $c->containing($object->id,Categorie::TYPE_PRODUCT); |
|
| 1417 | - foreach($cats as $cat) { |
|
| 1416 | + $cats = $c->containing($object->id, Categorie::TYPE_PRODUCT); |
|
| 1417 | + foreach ($cats as $cat) { |
|
| 1418 | 1418 | $arrayselected[] = $cat->id; |
| 1419 | 1419 | } |
| 1420 | 1420 | print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); |
@@ -1422,7 +1422,7 @@ discard block |
||
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | 1424 | // Note private |
| 1425 | - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
| 1425 | + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
| 1426 | 1426 | { |
| 1427 | 1427 | print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">'; |
| 1428 | 1428 | |
@@ -1438,7 +1438,7 @@ discard block |
||
| 1438 | 1438 | |
| 1439 | 1439 | print '<table class="border" width="100%">'; |
| 1440 | 1440 | |
| 1441 | - if (! empty($conf->accounting->enabled)) |
|
| 1441 | + if (!empty($conf->accounting->enabled)) |
|
| 1442 | 1442 | { |
| 1443 | 1443 | // Accountancy_code_sell |
| 1444 | 1444 | print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>'; |
@@ -1479,20 +1479,20 @@ discard block |
||
| 1479 | 1479 | // Fiche en mode visu |
| 1480 | 1480 | else |
| 1481 | 1481 | { |
| 1482 | - $showbarcode=empty($conf->barcode->enabled)?0:1; |
|
| 1483 | - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; |
|
| 1482 | + $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; |
|
| 1483 | + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0; |
|
| 1484 | 1484 | |
| 1485 | - $head=product_prepare_head($object); |
|
| 1486 | - $titre=$langs->trans("CardProduct".$object->type); |
|
| 1487 | - $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); |
|
| 1485 | + $head = product_prepare_head($object); |
|
| 1486 | + $titre = $langs->trans("CardProduct".$object->type); |
|
| 1487 | + $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); |
|
| 1488 | 1488 | |
| 1489 | 1489 | dol_fiche_head($head, 'card', $titre, -1, $picto); |
| 1490 | 1490 | |
| 1491 | 1491 | $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'">'.$langs->trans("BackToList").'</a>'; |
| 1492 | - $object->next_prev_filter=" fk_product_type = ".$object->type; |
|
| 1492 | + $object->next_prev_filter = " fk_product_type = ".$object->type; |
|
| 1493 | 1493 | |
| 1494 | 1494 | $shownav = 1; |
| 1495 | - if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; |
|
| 1495 | + if ($user->societe_id && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; |
|
| 1496 | 1496 | |
| 1497 | 1497 | dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); |
| 1498 | 1498 | |
@@ -1504,12 +1504,12 @@ discard block |
||
| 1504 | 1504 | print '<table class="border tableforfield" width="100%">'; |
| 1505 | 1505 | |
| 1506 | 1506 | // Type |
| 1507 | - if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) |
|
| 1507 | + if (!empty($conf->produit->enabled) && !empty($conf->service->enabled)) |
|
| 1508 | 1508 | { |
| 1509 | 1509 | // TODO change for compatibility with edit in place |
| 1510 | - $typeformat='select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); |
|
| 1511 | - print '<tr><td class="titlefield">'.$form->editfieldkey("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat).'</td><td colspan="2">'; |
|
| 1512 | - print $form->editfieldval("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat); |
|
| 1510 | + $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); |
|
| 1511 | + print '<tr><td class="titlefield">'.$form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $user->rights->produit->creer || $user->rights->service->creer, $typeformat).'</td><td colspan="2">'; |
|
| 1512 | + print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, $user->rights->produit->creer || $user->rights->service->creer, $typeformat); |
|
| 1513 | 1513 | print '</td></tr>'; |
| 1514 | 1514 | } |
| 1515 | 1515 | |
@@ -1520,7 +1520,7 @@ discard block |
||
| 1520 | 1520 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
| 1521 | 1521 | print $langs->trans("BarcodeType"); |
| 1522 | 1522 | print '</td>'; |
| 1523 | - if (($action != 'editbarcodetype') && ! empty($user->rights->produit->creer) && $createbarcode) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>'; |
|
| 1523 | + if (($action != 'editbarcodetype') && !empty($user->rights->produit->creer) && $createbarcode) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&id='.$object->id.'">'.img_edit($langs->trans('Edit'), 1).'</a></td>'; |
|
| 1524 | 1524 | print '</tr></table>'; |
| 1525 | 1525 | print '</td><td colspan="2">'; |
| 1526 | 1526 | if ($action == 'editbarcodetype' || $action == 'editbarcode') |
@@ -1530,12 +1530,12 @@ discard block |
||
| 1530 | 1530 | } |
| 1531 | 1531 | if ($action == 'editbarcodetype') |
| 1532 | 1532 | { |
| 1533 | - $formbarcode->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$object->id,$object->barcode_type,'fk_barcode_type'); |
|
| 1533 | + $formbarcode->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$object->id, $object->barcode_type, 'fk_barcode_type'); |
|
| 1534 | 1534 | } |
| 1535 | 1535 | else |
| 1536 | 1536 | { |
| 1537 | 1537 | $object->fetch_barcode(); |
| 1538 | - print $object->barcode_type_label?$object->barcode_type_label:($object->barcode?'<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>':''); |
|
| 1538 | + print $object->barcode_type_label ? $object->barcode_type_label : ($object->barcode ? '<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>' : ''); |
|
| 1539 | 1539 | } |
| 1540 | 1540 | print '</td></tr>'."\n"; |
| 1541 | 1541 | |
@@ -1544,13 +1544,13 @@ discard block |
||
| 1544 | 1544 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
| 1545 | 1545 | print $langs->trans("BarcodeValue"); |
| 1546 | 1546 | print '</td>'; |
| 1547 | - if (($action != 'editbarcode') && ! empty($user->rights->produit->creer) && $createbarcode) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>'; |
|
| 1547 | + if (($action != 'editbarcode') && !empty($user->rights->produit->creer) && $createbarcode) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&id='.$object->id.'">'.img_edit($langs->trans('Edit'), 1).'</a></td>'; |
|
| 1548 | 1548 | print '</tr></table>'; |
| 1549 | 1549 | print '</td><td colspan="2">'; |
| 1550 | 1550 | if ($action == 'editbarcode') |
| 1551 | 1551 | { |
| 1552 | - $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; |
|
| 1553 | - if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
|
| 1552 | + $tmpcode = isset($_POST['barcode']) ? GETPOST('barcode') : $object->barcode; |
|
| 1553 | + if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) $tmpcode = $modBarCodeProduct->getNextValue($object, $type); |
|
| 1554 | 1554 | |
| 1555 | 1555 | print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'; |
| 1556 | 1556 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
@@ -1571,12 +1571,12 @@ discard block |
||
| 1571 | 1571 | print '<tr><td class="nowrap">'; |
| 1572 | 1572 | print $langs->trans("ProductAccountancySellCode"); |
| 1573 | 1573 | print '</td><td colspan="2">'; |
| 1574 | - if (! empty($conf->accounting->enabled)) |
|
| 1574 | + if (!empty($conf->accounting->enabled)) |
|
| 1575 | 1575 | { |
| 1576 | 1576 | $accountingaccount = new AccountingAccount($db); |
| 1577 | - $accountingaccount->fetch('',$object->accountancy_code_sell); |
|
| 1577 | + $accountingaccount->fetch('', $object->accountancy_code_sell); |
|
| 1578 | 1578 | |
| 1579 | - print $accountingaccount->getNomUrl(0,1,1,'',1); |
|
| 1579 | + print $accountingaccount->getNomUrl(0, 1, 1, '', 1); |
|
| 1580 | 1580 | } else { |
| 1581 | 1581 | print $object->accountancy_code_sell; |
| 1582 | 1582 | } |
@@ -1586,12 +1586,12 @@ discard block |
||
| 1586 | 1586 | print '<tr><td class="nowrap">'; |
| 1587 | 1587 | print $langs->trans("ProductAccountancyBuyCode"); |
| 1588 | 1588 | print '</td><td colspan="2">'; |
| 1589 | - if (! empty($conf->accounting->enabled)) |
|
| 1589 | + if (!empty($conf->accounting->enabled)) |
|
| 1590 | 1590 | { |
| 1591 | 1591 | $accountingaccount2 = new AccountingAccount($db); |
| 1592 | - $accountingaccount2->fetch('',$object->accountancy_code_buy); |
|
| 1592 | + $accountingaccount2->fetch('', $object->accountancy_code_buy); |
|
| 1593 | 1593 | |
| 1594 | - print $accountingaccount2->getNomUrl(0,1,1,'',1); |
|
| 1594 | + print $accountingaccount2->getNomUrl(0, 1, 1, '', 1); |
|
| 1595 | 1595 | } else { |
| 1596 | 1596 | print $object->accountancy_code_buy; |
| 1597 | 1597 | } |
@@ -1618,18 +1618,18 @@ discard block |
||
| 1618 | 1618 | */ |
| 1619 | 1619 | |
| 1620 | 1620 | // Batch number management (to batch) |
| 1621 | - if (! empty($conf->productbatch->enabled)) { |
|
| 1621 | + if (!empty($conf->productbatch->enabled)) { |
|
| 1622 | 1622 | print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="2">'; |
| 1623 | - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { |
|
| 1623 | + if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { |
|
| 1624 | 1624 | print ajax_object_onoff($object, 'status_batch', 'tobatch', 'ProductStatusOnBatch', 'ProductStatusNotOnBatch'); |
| 1625 | 1625 | } else { |
| 1626 | - print $object->getLibStatut(0,2); |
|
| 1626 | + print $object->getLibStatut(0, 2); |
|
| 1627 | 1627 | } |
| 1628 | 1628 | print '</td></tr>'; |
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | 1631 | // Description |
| 1632 | - print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="2">'.(dol_textishtml($object->description)?$object->description:dol_nl2br($object->description,1,true)).'</td></tr>'; |
|
| 1632 | + print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="2">'.(dol_textishtml($object->description) ? $object->description : dol_nl2br($object->description, 1, true)).'</td></tr>'; |
|
| 1633 | 1633 | |
| 1634 | 1634 | // Public URL |
| 1635 | 1635 | print '<tr><td>'.$langs->trans("PublicUrl").'</td><td colspan="2">'; |
@@ -1660,7 +1660,7 @@ discard block |
||
| 1660 | 1660 | print '<table class="border tableforfield" width="100%">'; |
| 1661 | 1661 | |
| 1662 | 1662 | // Nature |
| 1663 | - if($object->type!= Product::TYPE_SERVICE) |
|
| 1663 | + if ($object->type != Product::TYPE_SERVICE) |
|
| 1664 | 1664 | { |
| 1665 | 1665 | print '<tr><td class="titlefield">'.$langs->trans("Nature").'</td><td colspan="2">'; |
| 1666 | 1666 | print $object->getLibFinished(); |
@@ -1673,13 +1673,13 @@ discard block |
||
| 1673 | 1673 | print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.' '; |
| 1674 | 1674 | if ($object->duration_value > 1) |
| 1675 | 1675 | { |
| 1676 | - $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); |
|
| 1676 | + $dur = array("h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); |
|
| 1677 | 1677 | } |
| 1678 | 1678 | else if ($object->duration_value > 0) |
| 1679 | 1679 | { |
| 1680 | - $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); |
|
| 1680 | + $dur = array("h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); |
|
| 1681 | 1681 | } |
| 1682 | - print (! empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; |
|
| 1682 | + print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; |
|
| 1683 | 1683 | |
| 1684 | 1684 | print '</td></tr>'; |
| 1685 | 1685 | } |
@@ -1689,7 +1689,7 @@ discard block |
||
| 1689 | 1689 | print '<tr><td class="titlefield">'.$langs->trans("Weight").'</td><td colspan="2">'; |
| 1690 | 1690 | if ($object->weight != '') |
| 1691 | 1691 | { |
| 1692 | - print $object->weight." ".measuring_units_string($object->weight_units,"weight"); |
|
| 1692 | + print $object->weight." ".measuring_units_string($object->weight_units, "weight"); |
|
| 1693 | 1693 | } |
| 1694 | 1694 | else |
| 1695 | 1695 | { |
@@ -1705,7 +1705,7 @@ discard block |
||
| 1705 | 1705 | print $object->length; |
| 1706 | 1706 | if ($object->width) print " x ".$object->width; |
| 1707 | 1707 | if ($object->height) print " x ".$object->height; |
| 1708 | - print ' '.measuring_units_string($object->length_units,"size"); |
|
| 1708 | + print ' '.measuring_units_string($object->length_units, "size"); |
|
| 1709 | 1709 | } |
| 1710 | 1710 | else |
| 1711 | 1711 | { |
@@ -1719,7 +1719,7 @@ discard block |
||
| 1719 | 1719 | print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="2">'; |
| 1720 | 1720 | if ($object->surface != '') |
| 1721 | 1721 | { |
| 1722 | - print $object->surface." ".measuring_units_string($object->surface_units,"surface"); |
|
| 1722 | + print $object->surface." ".measuring_units_string($object->surface_units, "surface"); |
|
| 1723 | 1723 | } |
| 1724 | 1724 | else |
| 1725 | 1725 | { |
@@ -1733,7 +1733,7 @@ discard block |
||
| 1733 | 1733 | print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="2">'; |
| 1734 | 1734 | if ($object->volume != '') |
| 1735 | 1735 | { |
| 1736 | - print $object->volume." ".measuring_units_string($object->volume_units,"volume"); |
|
| 1736 | + print $object->volume." ".measuring_units_string($object->volume_units, "volume"); |
|
| 1737 | 1737 | } |
| 1738 | 1738 | else |
| 1739 | 1739 | { |
@@ -1744,7 +1744,7 @@ discard block |
||
| 1744 | 1744 | } |
| 1745 | 1745 | |
| 1746 | 1746 | // Unit |
| 1747 | - if (! empty($conf->global->PRODUCT_USE_UNITS)) |
|
| 1747 | + if (!empty($conf->global->PRODUCT_USE_UNITS)) |
|
| 1748 | 1748 | { |
| 1749 | 1749 | $unit = $object->getLabelOfUnit(); |
| 1750 | 1750 | |
@@ -1761,25 +1761,25 @@ discard block |
||
| 1761 | 1761 | print '<tr><td>'.$langs->trans("CustomCode").'</td><td colspan="2">'.$object->customcode.'</td>'; |
| 1762 | 1762 | |
| 1763 | 1763 | // Origin country code |
| 1764 | - print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td colspan="2">'.getCountry($object->country_id,0,$db).'</td>'; |
|
| 1764 | + print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td colspan="2">'.getCountry($object->country_id, 0, $db).'</td>'; |
|
| 1765 | 1765 | } |
| 1766 | 1766 | |
| 1767 | 1767 | // Other attributes |
| 1768 | - $parameters=array('colspan' => ' colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'"'); |
|
| 1769 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
| 1768 | + $parameters = array('colspan' => ' colspan="'.(2 + (($showphoto || $showbarcode) ? 1 : 0)).'"'); |
|
| 1769 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; |
|
| 1770 | 1770 | |
| 1771 | 1771 | // Categories |
| 1772 | - if($conf->categorie->enabled) { |
|
| 1772 | + if ($conf->categorie->enabled) { |
|
| 1773 | 1773 | print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td colspan="3">'; |
| 1774 | - print $form->showCategories($object->id,'product',1); |
|
| 1774 | + print $form->showCategories($object->id, 'product', 1); |
|
| 1775 | 1775 | print "</td></tr>"; |
| 1776 | 1776 | } |
| 1777 | 1777 | |
| 1778 | 1778 | // Note private |
| 1779 | - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
| 1779 | + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
| 1780 | 1780 | { |
| 1781 | 1781 | print '<!-- show Note --> '."\n"; |
| 1782 | - print '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td><td colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'">'.(dol_textishtml($object->note_private)?$object->note_private:dol_nl2br($object->note_private,1,true)).'</td></tr>'."\n"; |
|
| 1782 | + print '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td><td colspan="'.(2 + (($showphoto || $showbarcode) ? 1 : 0)).'">'.(dol_textishtml($object->note_private) ? $object->note_private : dol_nl2br($object->note_private, 1, true)).'</td></tr>'."\n"; |
|
| 1783 | 1783 | print '<!-- End show Note --> '."\n"; |
| 1784 | 1784 | } |
| 1785 | 1785 | |
@@ -1800,44 +1800,44 @@ discard block |
||
| 1800 | 1800 | } |
| 1801 | 1801 | |
| 1802 | 1802 | // Load object modCodeProduct |
| 1803 | -$module=(! empty($conf->global->PRODUCT_CODEPRODUCT_ADDON)?$conf->global->PRODUCT_CODEPRODUCT_ADDON:'mod_codeproduct_leopard'); |
|
| 1803 | +$module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard'); |
|
| 1804 | 1804 | if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') |
| 1805 | 1805 | { |
| 1806 | - $module = substr($module, 0, dol_strlen($module)-4); |
|
| 1806 | + $module = substr($module, 0, dol_strlen($module) - 4); |
|
| 1807 | 1807 | } |
| 1808 | -$result=dol_include_once('/core/modules/product/'.$module.'.php'); |
|
| 1808 | +$result = dol_include_once('/core/modules/product/'.$module.'.php'); |
|
| 1809 | 1809 | if ($result > 0) |
| 1810 | 1810 | { |
| 1811 | 1811 | $modCodeProduct = new $module(); |
| 1812 | 1812 | } |
| 1813 | 1813 | |
| 1814 | -$tmpcode=''; |
|
| 1815 | -if (! empty($modCodeProduct->code_auto)) $tmpcode=$modCodeProduct->getNextValue($object,$object->type); |
|
| 1814 | +$tmpcode = ''; |
|
| 1815 | +if (!empty($modCodeProduct->code_auto)) $tmpcode = $modCodeProduct->getNextValue($object, $object->type); |
|
| 1816 | 1816 | |
| 1817 | 1817 | // Define confirmation messages |
| 1818 | -$formquestionclone=array( |
|
| 1818 | +$formquestionclone = array( |
|
| 1819 | 1819 | 'text' => $langs->trans("ConfirmClone"), |
| 1820 | - array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24), |
|
| 1821 | - array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1), |
|
| 1820 | + array('type' => 'text', 'name' => 'clone_ref', 'label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24), |
|
| 1821 | + array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContentProduct"), 'value' => 1), |
|
| 1822 | 1822 | array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true), |
| 1823 | 1823 | ); |
| 1824 | -if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) |
|
| 1824 | +if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) |
|
| 1825 | 1825 | { |
| 1826 | - $formquestionclone[]=array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1); |
|
| 1826 | + $formquestionclone[] = array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1); |
|
| 1827 | 1827 | } |
| 1828 | 1828 | |
| 1829 | 1829 | // Confirm delete product |
| 1830 | -if (($action == 'delete' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js |
|
| 1831 | - || (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) // Always output when not jmobile nor js |
|
| 1830 | +if (($action == 'delete' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js |
|
| 1831 | + || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) // Always output when not jmobile nor js |
|
| 1832 | 1832 | { |
| 1833 | - print $form->formconfirm("card.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); |
|
| 1833 | + print $form->formconfirm("card.php?id=".$object->id, $langs->trans("DeleteProduct"), $langs->trans("ConfirmDeleteProduct"), "confirm_delete", '', 0, "action-delete"); |
|
| 1834 | 1834 | } |
| 1835 | 1835 | |
| 1836 | 1836 | // Clone confirmation |
| 1837 | -if (($action == 'clone' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js |
|
| 1838 | - || (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) // Always output when not jmobile nor js |
|
| 1837 | +if (($action == 'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js |
|
| 1838 | + || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) // Always output when not jmobile nor js |
|
| 1839 | 1839 | { |
| 1840 | - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',250,600); |
|
| 1840 | + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloneProduct'), $langs->trans('ConfirmCloneProduct', $object->ref), 'confirm_clone', $formquestionclone, 'yes', 'action-clone', 250, 600); |
|
| 1841 | 1841 | } |
| 1842 | 1842 | |
| 1843 | 1843 | |
@@ -1850,18 +1850,18 @@ discard block |
||
| 1850 | 1850 | { |
| 1851 | 1851 | print "\n".'<div class="tabsAction">'."\n"; |
| 1852 | 1852 | |
| 1853 | - $parameters=array(); |
|
| 1854 | - $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 1853 | + $parameters = array(); |
|
| 1854 | + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
| 1855 | 1855 | if (empty($reshook)) |
| 1856 | 1856 | { |
| 1857 | - if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer ) || |
|
| 1857 | + if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || |
|
| 1858 | 1858 | ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)) |
| 1859 | 1859 | { |
| 1860 | - if (! isset($object->no_button_edit) || $object->no_button_edit <> 1) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans("Modify").'</a></div>'; |
|
| 1860 | + if (!isset($object->no_button_edit) || $object->no_button_edit <> 1) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans("Modify").'</a></div>'; |
|
| 1861 | 1861 | |
| 1862 | - if (! isset($object->no_button_copy) || $object->no_button_copy <> 1) |
|
| 1862 | + if (!isset($object->no_button_copy) || $object->no_button_copy <> 1) |
|
| 1863 | 1863 | { |
| 1864 | - if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) |
|
| 1864 | + if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) |
|
| 1865 | 1865 | { |
| 1866 | 1866 | print '<div class="inline-block divButAction"><span id="action-clone" class="butAction">'.$langs->trans('ToClone').'</span></div>'."\n"; |
| 1867 | 1867 | } |
@@ -1876,9 +1876,9 @@ discard block |
||
| 1876 | 1876 | if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) |
| 1877 | 1877 | || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)) |
| 1878 | 1878 | { |
| 1879 | - if (empty($object_is_used) && (! isset($object->no_button_delete) || $object->no_button_delete <> 1)) |
|
| 1879 | + if (empty($object_is_used) && (!isset($object->no_button_delete) || $object->no_button_delete <> 1)) |
|
| 1880 | 1880 | { |
| 1881 | - if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) |
|
| 1881 | + if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) |
|
| 1882 | 1882 | { |
| 1883 | 1883 | print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n"; |
| 1884 | 1884 | } |
@@ -1905,20 +1905,20 @@ discard block |
||
| 1905 | 1905 | * All the "Add to" areas |
| 1906 | 1906 | */ |
| 1907 | 1907 | |
| 1908 | -if (! empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == '' || $action == 'view') && $object->status) |
|
| 1908 | +if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == '' || $action == 'view') && $object->status) |
|
| 1909 | 1909 | { |
| 1910 | 1910 | //Variable used to check if any text is going to be printed |
| 1911 | 1911 | $html = ''; |
| 1912 | 1912 | //print '<div class="fichecenter"><div class="fichehalfleft">'; |
| 1913 | 1913 | |
| 1914 | 1914 | // Propals |
| 1915 | - if (! empty($conf->propal->enabled) && $user->rights->propale->creer) |
|
| 1915 | + if (!empty($conf->propal->enabled) && $user->rights->propale->creer) |
|
| 1916 | 1916 | { |
| 1917 | 1917 | $propal = new Propal($db); |
| 1918 | 1918 | |
| 1919 | 1919 | $langs->load("propal"); |
| 1920 | 1920 | |
| 1921 | - $otherprop = $propal->liste_array(2,1,0); |
|
| 1921 | + $otherprop = $propal->liste_array(2, 1, 0); |
|
| 1922 | 1922 | |
| 1923 | 1923 | if (is_array($otherprop) && count($otherprop)) |
| 1924 | 1924 | { |
@@ -1937,7 +1937,7 @@ discard block |
||
| 1937 | 1937 | } |
| 1938 | 1938 | |
| 1939 | 1939 | // Commande |
| 1940 | - if (! empty($conf->commande->enabled) && $user->rights->commande->creer) |
|
| 1940 | + if (!empty($conf->commande->enabled) && $user->rights->commande->creer) |
|
| 1941 | 1941 | { |
| 1942 | 1942 | $commande = new Commande($db); |
| 1943 | 1943 | |
@@ -1961,7 +1961,7 @@ discard block |
||
| 1961 | 1961 | } |
| 1962 | 1962 | |
| 1963 | 1963 | // Factures |
| 1964 | - if (! empty($conf->facture->enabled) && $user->rights->facture->creer) |
|
| 1964 | + if (!empty($conf->facture->enabled) && $user->rights->facture->creer) |
|
| 1965 | 1965 | { |
| 1966 | 1966 | $invoice = new Facture($db); |
| 1967 | 1967 | |
@@ -1991,7 +1991,7 @@ discard block |
||
| 1991 | 1991 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 1992 | 1992 | print '<input type="hidden" name="action" value="addin">'; |
| 1993 | 1993 | |
| 1994 | - print load_fiche_titre($langs->trans("AddToDraft"),'',''); |
|
| 1994 | + print load_fiche_titre($langs->trans("AddToDraft"), '', ''); |
|
| 1995 | 1995 | |
| 1996 | 1996 | dol_fiche_head(''); |
| 1997 | 1997 | |
@@ -2027,16 +2027,16 @@ discard block |
||
| 2027 | 2027 | |
| 2028 | 2028 | // Documents |
| 2029 | 2029 | $objectref = dol_sanitizeFileName($object->ref); |
| 2030 | - $relativepath = $comref . '/' . $objectref . '.pdf'; |
|
| 2031 | - $filedir = $conf->produit->dir_output . '/' . $objectref; |
|
| 2032 | - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; |
|
| 2033 | - $genallowed=$user->rights->produit->creer; |
|
| 2034 | - $delallowed=$user->rights->produit->supprimer; |
|
| 2030 | + $relativepath = $comref.'/'.$objectref.'.pdf'; |
|
| 2031 | + $filedir = $conf->produit->dir_output.'/'.$objectref; |
|
| 2032 | + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; |
|
| 2033 | + $genallowed = $user->rights->produit->creer; |
|
| 2034 | + $delallowed = $user->rights->produit->supprimer; |
|
| 2035 | 2035 | |
| 2036 | - $var=true; |
|
| 2036 | + $var = true; |
|
| 2037 | 2037 | |
| 2038 | - print $formfile->showdocuments($modulepart,$object->ref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); |
|
| 2039 | - $somethingshown=$formfile->numoffiles; |
|
| 2038 | + print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); |
|
| 2039 | + $somethingshown = $formfile->numoffiles; |
|
| 2040 | 2040 | |
| 2041 | 2041 | print '</div><div class="fichehalfright"><div class="ficheaddleft">'; |
| 2042 | 2042 | |
@@ -48,18 +48,36 @@ discard block |
||
| 48 | 48 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
| 49 | 49 | require_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.php'; |
| 50 | 50 | |
| 51 | -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 52 | -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 53 | -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 54 | -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
| 55 | -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; |
|
| 56 | -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; |
|
| 51 | +if (! empty($conf->propal->enabled)) { |
|
| 52 | + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 53 | +} |
|
| 54 | +if (! empty($conf->facture->enabled)) { |
|
| 55 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 56 | +} |
|
| 57 | +if (! empty($conf->commande->enabled)) { |
|
| 58 | + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 59 | +} |
|
| 60 | +if (! empty($conf->accounting->enabled)) { |
|
| 61 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
| 62 | +} |
|
| 63 | +if (! empty($conf->accounting->enabled)) { |
|
| 64 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; |
|
| 65 | +} |
|
| 66 | +if (! empty($conf->accounting->enabled)) { |
|
| 67 | + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; |
|
| 68 | +} |
|
| 57 | 69 | |
| 58 | 70 | $langs->load("products"); |
| 59 | 71 | $langs->load("other"); |
| 60 | -if (! empty($conf->stock->enabled)) $langs->load("stocks"); |
|
| 61 | -if (! empty($conf->facture->enabled)) $langs->load("bills"); |
|
| 62 | -if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); |
|
| 72 | +if (! empty($conf->stock->enabled)) { |
|
| 73 | + $langs->load("stocks"); |
|
| 74 | +} |
|
| 75 | +if (! empty($conf->facture->enabled)) { |
|
| 76 | + $langs->load("bills"); |
|
| 77 | +} |
|
| 78 | +if (! empty($conf->productbatch->enabled)) { |
|
| 79 | + $langs->load("productbatch"); |
|
| 80 | +} |
|
| 63 | 81 | |
| 64 | 82 | $mesg=''; $error=0; $errors=array(); |
| 65 | 83 | |
@@ -74,7 +92,9 @@ discard block |
||
| 74 | 92 | $socid=GETPOST('socid','int'); |
| 75 | 93 | $duration_value = GETPOST('duration_value'); |
| 76 | 94 | $duration_unit = GETPOST('duration_unit'); |
| 77 | -if (! empty($user->societe_id)) $socid=$user->societe_id; |
|
| 95 | +if (! empty($user->societe_id)) { |
|
| 96 | + $socid=$user->societe_id; |
|
| 97 | +} |
|
| 78 | 98 | |
| 79 | 99 | $object = new Product($db); |
| 80 | 100 | $extrafields = new ExtraFields($db); |
@@ -86,13 +106,19 @@ discard block |
||
| 86 | 106 | { |
| 87 | 107 | $result = $object->fetch($id, $ref); |
| 88 | 108 | |
| 89 | - if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); |
|
| 90 | - elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); |
|
| 109 | + if (! empty($conf->product->enabled)) { |
|
| 110 | + $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); |
|
| 111 | + } elseif (! empty($conf->service->enabled)) { |
|
| 112 | + $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); |
|
| 113 | + } |
|
| 91 | 114 | |
| 92 | - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs |
|
| 115 | + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { |
|
| 116 | + // For backward compatiblity, we scan also old dirs |
|
| 93 | 117 | { |
| 94 | 118 | if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; |
| 95 | - else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; |
|
| 119 | + } else { |
|
| 120 | + $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; |
|
| 121 | + } |
|
| 96 | 122 | } |
| 97 | 123 | } |
| 98 | 124 | |
@@ -122,14 +148,20 @@ discard block |
||
| 122 | 148 | * Actions |
| 123 | 149 | */ |
| 124 | 150 | |
| 125 | -if ($cancel) $action = ''; |
|
| 151 | +if ($cancel) { |
|
| 152 | + $action = ''; |
|
| 153 | +} |
|
| 126 | 154 | |
| 127 | 155 | $createbarcode=empty($conf->barcode->enabled)?0:1; |
| 128 | -if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) $createbarcode=0; |
|
| 156 | +if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) { |
|
| 157 | + $createbarcode=0; |
|
| 158 | +} |
|
| 129 | 159 | |
| 130 | 160 | $parameters=array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas); |
| 131 | 161 | $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
| 132 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 162 | +if ($reshook < 0) { |
|
| 163 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 164 | +} |
|
| 133 | 165 | |
| 134 | 166 | if (empty($reshook)) |
| 135 | 167 | { |
@@ -166,14 +198,18 @@ discard block |
||
| 166 | 198 | $result = $object->setValueFrom('barcode', GETPOST('barcode')); |
| 167 | 199 | header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
| 168 | 200 | exit; |
| 169 | - } |
|
| 170 | - else |
|
| 201 | + } else |
|
| 171 | 202 | { |
| 172 | 203 | $langs->load("errors"); |
| 173 | - if ($result == -1) $errors[] = 'ErrorBadBarCodeSyntax'; |
|
| 174 | - else if ($result == -2) $errors[] = 'ErrorBarCodeRequired'; |
|
| 175 | - else if ($result == -3) $errors[] = 'ErrorBarCodeAlreadyUsed'; |
|
| 176 | - else $errors[] = 'FailedToValidateBarCode'; |
|
| 204 | + if ($result == -1) { |
|
| 205 | + $errors[] = 'ErrorBadBarCodeSyntax'; |
|
| 206 | + } else if ($result == -2) { |
|
| 207 | + $errors[] = 'ErrorBarCodeRequired'; |
|
| 208 | + } else if ($result == -3) { |
|
| 209 | + $errors[] = 'ErrorBarCodeAlreadyUsed'; |
|
| 210 | + } else { |
|
| 211 | + $errors[] = 'FailedToValidateBarCode'; |
|
| 212 | + } |
|
| 177 | 213 | |
| 178 | 214 | $error++; |
| 179 | 215 | setEventMessages($errors, null, 'errors'); |
@@ -212,14 +248,16 @@ discard block |
||
| 212 | 248 | $object->label = GETPOST('label'); |
| 213 | 249 | $object->price_base_type = GETPOST('price_base_type'); |
| 214 | 250 | |
| 215 | - if ($object->price_base_type == 'TTC') |
|
| 216 | - $object->price_ttc = GETPOST('price'); |
|
| 217 | - else |
|
| 218 | - $object->price = GETPOST('price'); |
|
| 219 | - if ($object->price_base_type == 'TTC') |
|
| 220 | - $object->price_min_ttc = GETPOST('price_min'); |
|
| 221 | - else |
|
| 222 | - $object->price_min = GETPOST('price_min'); |
|
| 251 | + if ($object->price_base_type == 'TTC') { |
|
| 252 | + $object->price_ttc = GETPOST('price'); |
|
| 253 | + } else { |
|
| 254 | + $object->price = GETPOST('price'); |
|
| 255 | + } |
|
| 256 | + if ($object->price_base_type == 'TTC') { |
|
| 257 | + $object->price_min_ttc = GETPOST('price_min'); |
|
| 258 | + } else { |
|
| 259 | + $object->price_min = GETPOST('price_min'); |
|
| 260 | + } |
|
| 223 | 261 | |
| 224 | 262 | $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' |
| 225 | 263 | |
@@ -320,8 +358,7 @@ discard block |
||
| 320 | 358 | { |
| 321 | 359 | $object->multiprices["$i"] = price2num($_POST["price_".$i],'MU'); |
| 322 | 360 | $object->multiprices_base_type["$i"] = $_POST["multiprices_base_type_".$i]; |
| 323 | - } |
|
| 324 | - else |
|
| 361 | + } else |
|
| 325 | 362 | { |
| 326 | 363 | $object->multiprices["$i"] = ""; |
| 327 | 364 | } |
@@ -330,7 +367,9 @@ discard block |
||
| 330 | 367 | |
| 331 | 368 | // Fill array 'array_options' with data from add form |
| 332 | 369 | $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
| 333 | - if ($ret < 0) $error++; |
|
| 370 | + if ($ret < 0) { |
|
| 371 | + $error++; |
|
| 372 | + } |
|
| 334 | 373 | |
| 335 | 374 | if (! $error) |
| 336 | 375 | { |
@@ -345,11 +384,13 @@ discard block |
||
| 345 | 384 | |
| 346 | 385 | header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); |
| 347 | 386 | exit; |
| 348 | - } |
|
| 349 | - else |
|
| 387 | + } else |
|
| 350 | 388 | { |
| 351 | - if (count($object->errors)) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 352 | - else setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 389 | + if (count($object->errors)) { |
|
| 390 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 391 | + } else { |
|
| 392 | + setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 393 | + } |
|
| 353 | 394 | $action = "create"; |
| 354 | 395 | } |
| 355 | 396 | } |
@@ -361,8 +402,7 @@ discard block |
||
| 361 | 402 | if (GETPOST('cancel')) |
| 362 | 403 | { |
| 363 | 404 | $action = ''; |
| 364 | - } |
|
| 365 | - else |
|
| 405 | + } else |
|
| 366 | 406 | { |
| 367 | 407 | if ($object->id > 0) |
| 368 | 408 | { |
@@ -437,7 +477,9 @@ discard block |
||
| 437 | 477 | |
| 438 | 478 | // Fill array 'array_options' with data from add form |
| 439 | 479 | $ret = $extrafields->setOptionalsFromPost($extralabels,$object); |
| 440 | - if ($ret < 0) $error++; |
|
| 480 | + if ($ret < 0) { |
|
| 481 | + $error++; |
|
| 482 | + } |
|
| 441 | 483 | |
| 442 | 484 | if (! $error && $object->check()) |
| 443 | 485 | { |
@@ -448,18 +490,22 @@ discard block |
||
| 448 | 490 | $object->setCategories($categories); |
| 449 | 491 | |
| 450 | 492 | $action = 'view'; |
| 451 | - } |
|
| 452 | - else |
|
| 493 | + } else |
|
| 453 | 494 | { |
| 454 | - if (count($object->errors)) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 455 | - else setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 495 | + if (count($object->errors)) { |
|
| 496 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 497 | + } else { |
|
| 498 | + setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 499 | + } |
|
| 456 | 500 | $action = 'edit'; |
| 457 | 501 | } |
| 458 | - } |
|
| 459 | - else |
|
| 502 | + } else |
|
| 460 | 503 | { |
| 461 | - if (count($object->errors)) setEventMessages($object->error, $object->errors, 'errors'); |
|
| 462 | - else setEventMessages($langs->trans("ErrorProductBadRefOrLabel"), null, 'errors'); |
|
| 504 | + if (count($object->errors)) { |
|
| 505 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 506 | + } else { |
|
| 507 | + setEventMessages($langs->trans("ErrorProductBadRefOrLabel"), null, 'errors'); |
|
| 508 | + } |
|
| 463 | 509 | $action = 'edit'; |
| 464 | 510 | } |
| 465 | 511 | } |
@@ -474,8 +520,7 @@ discard block |
||
| 474 | 520 | if (! GETPOST('clone_content') && ! GETPOST('clone_prices') ) |
| 475 | 521 | { |
| 476 | 522 | setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); |
| 477 | - } |
|
| 478 | - else |
|
| 523 | + } else |
|
| 479 | 524 | { |
| 480 | 525 | $db->begin(); |
| 481 | 526 | |
@@ -513,8 +558,7 @@ discard block |
||
| 513 | 558 | |
| 514 | 559 | header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); |
| 515 | 560 | exit; |
| 516 | - } |
|
| 517 | - else |
|
| 561 | + } else |
|
| 518 | 562 | { |
| 519 | 563 | $id=$originalId; |
| 520 | 564 | |
@@ -529,16 +573,14 @@ discard block |
||
| 529 | 573 | $mesg.=' <a href="'.$_SERVER["PHP_SELF"].'?ref='.$object->ref.'">'.$langs->trans("ShowCardHere").'</a>.'; |
| 530 | 574 | setEventMessages($mesg, null, 'errors'); |
| 531 | 575 | $object->fetch($id); |
| 532 | - } |
|
| 533 | - else |
|
| 576 | + } else |
|
| 534 | 577 | { |
| 535 | 578 | $db->rollback(); |
| 536 | 579 | if (count($object->errors)) |
| 537 | 580 | { |
| 538 | 581 | setEventMessages($object->error, $object->errors, 'errors'); |
| 539 | 582 | dol_print_error($db,$object->errors); |
| 540 | - } |
|
| 541 | - else |
|
| 583 | + } else |
|
| 542 | 584 | { |
| 543 | 585 | setEventMessages($langs->trans($object->error), null, 'errors'); |
| 544 | 586 | dol_print_error($db,$object->error); |
@@ -546,8 +588,7 @@ discard block |
||
| 546 | 588 | } |
| 547 | 589 | } |
| 548 | 590 | } |
| 549 | - } |
|
| 550 | - else |
|
| 591 | + } else |
|
| 551 | 592 | { |
| 552 | 593 | $db->rollback(); |
| 553 | 594 | dol_print_error($db,$object->error); |
@@ -568,8 +609,7 @@ discard block |
||
| 568 | 609 | { |
| 569 | 610 | header('Location: '.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'&delprod='.urlencode($object->ref)); |
| 570 | 611 | exit; |
| 571 | - } |
|
| 572 | - else |
|
| 612 | + } else |
|
| 573 | 613 | { |
| 574 | 614 | setEventMessages($langs->trans($object->error), null, 'errors'); |
| 575 | 615 | $reload = 0; |
@@ -592,8 +632,7 @@ discard block |
||
| 592 | 632 | exit; |
| 593 | 633 | } |
| 594 | 634 | $thirpdartyid = $propal->socid; |
| 595 | - } |
|
| 596 | - elseif (GETPOST('commandeid') > 0) |
|
| 635 | + } elseif (GETPOST('commandeid') > 0) |
|
| 597 | 636 | { |
| 598 | 637 | $commande = new Commande($db); |
| 599 | 638 | $result=$commande->fetch(GETPOST('commandeid')); |
@@ -603,8 +642,7 @@ discard block |
||
| 603 | 642 | exit; |
| 604 | 643 | } |
| 605 | 644 | $thirpdartyid = $commande->socid; |
| 606 | - } |
|
| 607 | - elseif (GETPOST('factureid') > 0) |
|
| 645 | + } elseif (GETPOST('factureid') > 0) |
|
| 608 | 646 | { |
| 609 | 647 | $facture = new Facture($db); |
| 610 | 648 | $result=$facture->fetch(GETPOST('factureid')); |
@@ -628,7 +666,9 @@ discard block |
||
| 628 | 666 | |
| 629 | 667 | $tva_tx = get_default_tva($mysoc, $soc, $object->id); |
| 630 | 668 | $tva_npr = get_default_npr($mysoc, $soc, $object->id); |
| 631 | - if (empty($tva_tx)) $tva_npr=0; |
|
| 669 | + if (empty($tva_tx)) { |
|
| 670 | + $tva_npr=0; |
|
| 671 | + } |
|
| 632 | 672 | $localtax1_tx = get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr); |
| 633 | 673 | $localtax2_tx = get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr); |
| 634 | 674 | |
@@ -679,8 +719,7 @@ discard block |
||
| 679 | 719 | { |
| 680 | 720 | dol_syslog($langs->trans('FailedToGetCostPrice')); |
| 681 | 721 | setEventMessage($langs->trans('FailedToGetCostPrice'), 'errors'); |
| 682 | - } |
|
| 683 | - else |
|
| 722 | + } else |
|
| 684 | 723 | { |
| 685 | 724 | $buyprice = $result; |
| 686 | 725 | } |
@@ -722,8 +761,7 @@ discard block |
||
| 722 | 761 | { |
| 723 | 762 | dol_syslog($langs->trans('FailedToGetCostPrice')); |
| 724 | 763 | setEventMessage($langs->trans('FailedToGetCostPrice'), 'errors'); |
| 725 | - } |
|
| 726 | - else |
|
| 764 | + } else |
|
| 727 | 765 | { |
| 728 | 766 | $buyprice = $result; |
| 729 | 767 | } |
@@ -765,8 +803,7 @@ discard block |
||
| 765 | 803 | { |
| 766 | 804 | dol_syslog($langs->trans('FailedToGetCostPrice')); |
| 767 | 805 | setEventMessage($langs->trans('FailedToGetCostPrice'), 'errors'); |
| 768 | - } |
|
| 769 | - else |
|
| 806 | + } else |
|
| 770 | 807 | { |
| 771 | 808 | $buyprice = $result; |
| 772 | 809 | } |
@@ -807,8 +844,7 @@ discard block |
||
| 807 | 844 | exit; |
| 808 | 845 | } |
| 809 | 846 | } |
| 810 | - } |
|
| 811 | - else { |
|
| 847 | + } else { |
|
| 812 | 848 | $action=""; |
| 813 | 849 | setEventMessages($langs->trans("WarningSelectOneDocument"), null, 'warnings'); |
| 814 | 850 | } |
@@ -840,7 +876,9 @@ discard block |
||
| 840 | 876 | $form = new Form($db); |
| 841 | 877 | $formfile = new FormFile($db); |
| 842 | 878 | $formproduct = new FormProduct($db); |
| 843 | -if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db); |
|
| 879 | +if (! empty($conf->accounting->enabled)) { |
|
| 880 | + $formaccounting = New FormAccounting($db); |
|
| 881 | +} |
|
| 844 | 882 | |
| 845 | 883 | // Load object modBarCodeProduct |
| 846 | 884 | $res=0; |
@@ -851,7 +889,9 @@ discard block |
||
| 851 | 889 | foreach ($dirbarcode as $dirroot) |
| 852 | 890 | { |
| 853 | 891 | $res=dol_include_once($dirroot.$module.'.php'); |
| 854 | - if ($res) break; |
|
| 892 | + if ($res) { |
|
| 893 | + break; |
|
| 894 | + } |
|
| 855 | 895 | } |
| 856 | 896 | if ($res > 0) |
| 857 | 897 | { |
@@ -869,12 +909,13 @@ discard block |
||
| 869 | 909 | { |
| 870 | 910 | $object = new Product($db); |
| 871 | 911 | $result=$object->fetch($id); |
| 872 | - if ($result <= 0) dol_print_error('',$object->error); |
|
| 912 | + if ($result <= 0) { |
|
| 913 | + dol_print_error('',$object->error); |
|
| 914 | + } |
|
| 873 | 915 | } |
| 874 | 916 | $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates |
| 875 | 917 | $objcanvas->display_canvas($action); // Show template |
| 876 | -} |
|
| 877 | -else |
|
| 918 | +} else |
|
| 878 | 919 | { |
| 879 | 920 | // ----------------------------------------- |
| 880 | 921 | // When used in standard mode |
@@ -902,13 +943,18 @@ discard block |
||
| 902 | 943 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 903 | 944 | print '<input type="hidden" name="action" value="add">'; |
| 904 | 945 | print '<input type="hidden" name="type" value="'.$type.'">'."\n"; |
| 905 | - if (! empty($modCodeProduct->code_auto)) |
|
| 906 | - print '<input type="hidden" name="code_auto" value="1">'; |
|
| 907 | - if (! empty($modBarCodeProduct->code_auto)) |
|
| 908 | - print '<input type="hidden" name="barcode_auto" value="1">'; |
|
| 946 | + if (! empty($modCodeProduct->code_auto)) { |
|
| 947 | + print '<input type="hidden" name="code_auto" value="1">'; |
|
| 948 | + } |
|
| 949 | + if (! empty($modBarCodeProduct->code_auto)) { |
|
| 950 | + print '<input type="hidden" name="barcode_auto" value="1">'; |
|
| 951 | + } |
|
| 909 | 952 | |
| 910 | - if ($type==1) $title=$langs->trans("NewService"); |
|
| 911 | - else $title=$langs->trans("NewProduct"); |
|
| 953 | + if ($type==1) { |
|
| 954 | + $title=$langs->trans("NewService"); |
|
| 955 | + } else { |
|
| 956 | + $title=$langs->trans("NewProduct"); |
|
| 957 | + } |
|
| 912 | 958 | $linkback=""; |
| 913 | 959 | print load_fiche_titre($title,$linkback,'title_products.png'); |
| 914 | 960 | |
@@ -918,7 +964,9 @@ discard block |
||
| 918 | 964 | |
| 919 | 965 | print '<tr>'; |
| 920 | 966 | $tmpcode=''; |
| 921 | - if (! empty($modCodeProduct->code_auto)) $tmpcode=$modCodeProduct->getNextValue($object,$type); |
|
| 967 | + if (! empty($modCodeProduct->code_auto)) { |
|
| 968 | + $tmpcode=$modCodeProduct->getNextValue($object,$type); |
|
| 969 | + } |
|
| 922 | 970 | print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="'.dol_escape_htmltag(GETPOST('ref')?GETPOST('ref'):$tmpcode).'">'; |
| 923 | 971 | if ($refalreadyexists) |
| 924 | 972 | { |
@@ -951,7 +999,9 @@ discard block |
||
| 951 | 999 | } |
| 952 | 1000 | |
| 953 | 1001 | $showbarcode=empty($conf->barcode->enabled)?0:1; |
| 954 | - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; |
|
| 1002 | + if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { |
|
| 1003 | + $showbarcode=0; |
|
| 1004 | + } |
|
| 955 | 1005 | |
| 956 | 1006 | if ($showbarcode) |
| 957 | 1007 | { |
@@ -959,17 +1009,20 @@ discard block |
||
| 959 | 1009 | if (isset($_POST['fk_barcode_type'])) |
| 960 | 1010 | { |
| 961 | 1011 | $fk_barcode_type=GETPOST('fk_barcode_type'); |
| 962 | - } |
|
| 963 | - else |
|
| 1012 | + } else |
|
| 964 | 1013 | { |
| 965 | - if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 1014 | + if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) { |
|
| 1015 | + $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 1016 | + } |
|
| 966 | 1017 | } |
| 967 | 1018 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; |
| 968 | 1019 | $formbarcode = new FormBarCode($db); |
| 969 | 1020 | print $formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); |
| 970 | 1021 | print '</td><td>'.$langs->trans("BarcodeValue").'</td><td>'; |
| 971 | 1022 | $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; |
| 972 | - if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
|
| 1023 | + if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) { |
|
| 1024 | + $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
|
| 1025 | + } |
|
| 973 | 1026 | print '<input class="maxwidth100" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).'">'; |
| 974 | 1027 | print '</td></tr>'; |
| 975 | 1028 | } |
@@ -997,8 +1050,7 @@ discard block |
||
| 997 | 1050 | print '<td>'.$form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1).'</td><td>'; |
| 998 | 1051 | print '<input name="desiredstock" class="maxwidth50" value="'.GETPOST('desiredstock').'">'; |
| 999 | 1052 | print '</td></tr>'; |
| 1000 | - } |
|
| 1001 | - else |
|
| 1053 | + } else |
|
| 1002 | 1054 | { |
| 1003 | 1055 | print '<input name="seuil_stock_alerte" type="hidden" value="0">'; |
| 1004 | 1056 | print '<input name="desiredstock" type="hidden" value="0">'; |
@@ -1025,10 +1077,12 @@ discard block |
||
| 1025 | 1077 | print '</td></tr>'; |
| 1026 | 1078 | } |
| 1027 | 1079 | |
| 1028 | - if ($type != 1) // Le poids et le volume ne concerne que les produits et pas les services |
|
| 1080 | + if ($type != 1) { |
|
| 1081 | + // Le poids et le volume ne concerne que les produits et pas les services |
|
| 1029 | 1082 | { |
| 1030 | 1083 | // Weight |
| 1031 | 1084 | print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="3">'; |
| 1085 | + } |
|
| 1032 | 1086 | print '<input name="weight" size="4" value="'.GETPOST('weight').'">'; |
| 1033 | 1087 | print $formproduct->select_measuring_units("weight_units","weight"); |
| 1034 | 1088 | print '</td></tr>'; |
@@ -1073,7 +1127,9 @@ discard block |
||
| 1073 | 1127 | // Origin country |
| 1074 | 1128 | print '<td>'.$langs->trans("CountryOrigin").'</td><td>'; |
| 1075 | 1129 | print $form->select_country(GETPOST('country_id','int'),'country_id'); |
| 1076 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 1130 | + if ($user->admin) { |
|
| 1131 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 1132 | + } |
|
| 1077 | 1133 | print '</td></tr>'; |
| 1078 | 1134 | } |
| 1079 | 1135 | |
@@ -1114,8 +1170,7 @@ discard block |
||
| 1114 | 1170 | { |
| 1115 | 1171 | // We do no show price array on create when multiprices enabled. |
| 1116 | 1172 | // We must set them on prices tab. |
| 1117 | - } |
|
| 1118 | - else |
|
| 1173 | + } else |
|
| 1119 | 1174 | { |
| 1120 | 1175 | print '<table class="border" width="100%">'; |
| 1121 | 1176 | |
@@ -1157,8 +1212,7 @@ discard block |
||
| 1157 | 1212 | print '<td>'; |
| 1158 | 1213 | print $formaccounting->select_account(GETPOST('accountancy_code_buy'), 'accountancy_code_buy', 1, null, 1, 1, ''); |
| 1159 | 1214 | print '</td></tr>'; |
| 1160 | - } |
|
| 1161 | - else // For external software |
|
| 1215 | + } else // For external software |
|
| 1162 | 1216 | { |
| 1163 | 1217 | // Accountancy_code_sell |
| 1164 | 1218 | print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>'; |
@@ -1196,7 +1250,9 @@ discard block |
||
| 1196 | 1250 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 1197 | 1251 | |
| 1198 | 1252 | $type = $langs->trans('Product'); |
| 1199 | - if ($object->isService()) $type = $langs->trans('Service'); |
|
| 1253 | + if ($object->isService()) { |
|
| 1254 | + $type = $langs->trans('Service'); |
|
| 1255 | + } |
|
| 1200 | 1256 | //print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), ""); |
| 1201 | 1257 | |
| 1202 | 1258 | // Main official, simple, and not duplicated code |
@@ -1226,8 +1282,7 @@ discard block |
||
| 1226 | 1282 | { |
| 1227 | 1283 | print '<option value="1" selected>'.$langs->trans("OnSell").'</option>'; |
| 1228 | 1284 | print '<option value="0">'.$langs->trans("NotOnSell").'</option>'; |
| 1229 | - } |
|
| 1230 | - else |
|
| 1285 | + } else |
|
| 1231 | 1286 | { |
| 1232 | 1287 | print '<option value="1">'.$langs->trans("OnSell").'</option>'; |
| 1233 | 1288 | print '<option value="0" selected>'.$langs->trans("NotOnSell").'</option>'; |
@@ -1242,8 +1297,7 @@ discard block |
||
| 1242 | 1297 | { |
| 1243 | 1298 | print '<option value="1" selected>'.$langs->trans("ProductStatusOnBuy").'</option>'; |
| 1244 | 1299 | print '<option value="0">'.$langs->trans("ProductStatusNotOnBuy").'</option>'; |
| 1245 | - } |
|
| 1246 | - else |
|
| 1300 | + } else |
|
| 1247 | 1301 | { |
| 1248 | 1302 | print '<option value="1">'.$langs->trans("ProductStatusOnBuy").'</option>'; |
| 1249 | 1303 | print '<option value="0" selected>'.$langs->trans("ProductStatusNotOnBuy").'</option>'; |
@@ -1261,7 +1315,9 @@ discard block |
||
| 1261 | 1315 | |
| 1262 | 1316 | // Barcode |
| 1263 | 1317 | $showbarcode=empty($conf->barcode->enabled)?0:1; |
| 1264 | - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; |
|
| 1318 | + if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { |
|
| 1319 | + $showbarcode=0; |
|
| 1320 | + } |
|
| 1265 | 1321 | |
| 1266 | 1322 | if ($showbarcode) |
| 1267 | 1323 | { |
@@ -1269,18 +1325,21 @@ discard block |
||
| 1269 | 1325 | if (isset($_POST['fk_barcode_type'])) |
| 1270 | 1326 | { |
| 1271 | 1327 | $fk_barcode_type=GETPOST('fk_barcode_type'); |
| 1272 | - } |
|
| 1273 | - else |
|
| 1328 | + } else |
|
| 1274 | 1329 | { |
| 1275 | 1330 | $fk_barcode_type=$object->barcode_type; |
| 1276 | - if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 1331 | + if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) { |
|
| 1332 | + $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 1333 | + } |
|
| 1277 | 1334 | } |
| 1278 | 1335 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; |
| 1279 | 1336 | $formbarcode = new FormBarCode($db); |
| 1280 | 1337 | print $formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); |
| 1281 | 1338 | print '</td><td>'.$langs->trans("BarcodeValue").'</td><td>'; |
| 1282 | 1339 | $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; |
| 1283 | - if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
|
| 1340 | + if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) { |
|
| 1341 | + $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
|
| 1342 | + } |
|
| 1284 | 1343 | print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).'">'; |
| 1285 | 1344 | print '</td></tr>'; |
| 1286 | 1345 | } |
@@ -1343,8 +1402,7 @@ discard block |
||
| 1343 | 1402 | print '<input name="duration_unit" type="radio" value="y"'.($object->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); |
| 1344 | 1403 | |
| 1345 | 1404 | print '</td></tr>'; |
| 1346 | - } |
|
| 1347 | - else |
|
| 1405 | + } else |
|
| 1348 | 1406 | { |
| 1349 | 1407 | // Weight |
| 1350 | 1408 | print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="3">'; |
@@ -1394,7 +1452,9 @@ discard block |
||
| 1394 | 1452 | // Origin country |
| 1395 | 1453 | print '<td>'.$langs->trans("CountryOrigin").'</td><td>'; |
| 1396 | 1454 | print $form->select_country($object->country_id, 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone'); |
| 1397 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 1455 | + if ($user->admin) { |
|
| 1456 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 1457 | + } |
|
| 1398 | 1458 | print '</td></tr>'; |
| 1399 | 1459 | } |
| 1400 | 1460 | |
@@ -1451,8 +1511,7 @@ discard block |
||
| 1451 | 1511 | print '<td>'; |
| 1452 | 1512 | print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1); |
| 1453 | 1513 | print '</td></tr>'; |
| 1454 | - } |
|
| 1455 | - else // For external software |
|
| 1514 | + } else // For external software |
|
| 1456 | 1515 | { |
| 1457 | 1516 | // Accountancy_code_sell |
| 1458 | 1517 | print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>'; |
@@ -1480,7 +1539,9 @@ discard block |
||
| 1480 | 1539 | else |
| 1481 | 1540 | { |
| 1482 | 1541 | $showbarcode=empty($conf->barcode->enabled)?0:1; |
| 1483 | - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; |
|
| 1542 | + if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { |
|
| 1543 | + $showbarcode=0; |
|
| 1544 | + } |
|
| 1484 | 1545 | |
| 1485 | 1546 | $head=product_prepare_head($object); |
| 1486 | 1547 | $titre=$langs->trans("CardProduct".$object->type); |
@@ -1492,7 +1553,9 @@ discard block |
||
| 1492 | 1553 | $object->next_prev_filter=" fk_product_type = ".$object->type; |
| 1493 | 1554 | |
| 1494 | 1555 | $shownav = 1; |
| 1495 | - if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; |
|
| 1556 | + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) { |
|
| 1557 | + $shownav=0; |
|
| 1558 | + } |
|
| 1496 | 1559 | |
| 1497 | 1560 | dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); |
| 1498 | 1561 | |
@@ -1520,7 +1583,9 @@ discard block |
||
| 1520 | 1583 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
| 1521 | 1584 | print $langs->trans("BarcodeType"); |
| 1522 | 1585 | print '</td>'; |
| 1523 | - if (($action != 'editbarcodetype') && ! empty($user->rights->produit->creer) && $createbarcode) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>'; |
|
| 1586 | + if (($action != 'editbarcodetype') && ! empty($user->rights->produit->creer) && $createbarcode) { |
|
| 1587 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>'; |
|
| 1588 | + } |
|
| 1524 | 1589 | print '</tr></table>'; |
| 1525 | 1590 | print '</td><td colspan="2">'; |
| 1526 | 1591 | if ($action == 'editbarcodetype' || $action == 'editbarcode') |
@@ -1531,8 +1596,7 @@ discard block |
||
| 1531 | 1596 | if ($action == 'editbarcodetype') |
| 1532 | 1597 | { |
| 1533 | 1598 | $formbarcode->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$object->id,$object->barcode_type,'fk_barcode_type'); |
| 1534 | - } |
|
| 1535 | - else |
|
| 1599 | + } else |
|
| 1536 | 1600 | { |
| 1537 | 1601 | $object->fetch_barcode(); |
| 1538 | 1602 | print $object->barcode_type_label?$object->barcode_type_label:($object->barcode?'<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>':''); |
@@ -1544,13 +1608,17 @@ discard block |
||
| 1544 | 1608 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
| 1545 | 1609 | print $langs->trans("BarcodeValue"); |
| 1546 | 1610 | print '</td>'; |
| 1547 | - if (($action != 'editbarcode') && ! empty($user->rights->produit->creer) && $createbarcode) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>'; |
|
| 1611 | + if (($action != 'editbarcode') && ! empty($user->rights->produit->creer) && $createbarcode) { |
|
| 1612 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>'; |
|
| 1613 | + } |
|
| 1548 | 1614 | print '</tr></table>'; |
| 1549 | 1615 | print '</td><td colspan="2">'; |
| 1550 | 1616 | if ($action == 'editbarcode') |
| 1551 | 1617 | { |
| 1552 | 1618 | $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; |
| 1553 | - if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
|
| 1619 | + if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) { |
|
| 1620 | + $tmpcode=$modBarCodeProduct->getNextValue($object,$type); |
|
| 1621 | + } |
|
| 1554 | 1622 | |
| 1555 | 1623 | print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'; |
| 1556 | 1624 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
@@ -1559,8 +1627,7 @@ discard block |
||
| 1559 | 1627 | print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$tmpcode.'">'; |
| 1560 | 1628 | print ' <input type="submit" class="button" value="'.$langs->trans("Modify").'">'; |
| 1561 | 1629 | print '</form>'; |
| 1562 | - } |
|
| 1563 | - else |
|
| 1630 | + } else |
|
| 1564 | 1631 | { |
| 1565 | 1632 | print $object->barcode; |
| 1566 | 1633 | } |
@@ -1674,24 +1741,21 @@ discard block |
||
| 1674 | 1741 | if ($object->duration_value > 1) |
| 1675 | 1742 | { |
| 1676 | 1743 | $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); |
| 1677 | - } |
|
| 1678 | - else if ($object->duration_value > 0) |
|
| 1744 | + } else if ($object->duration_value > 0) |
|
| 1679 | 1745 | { |
| 1680 | 1746 | $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); |
| 1681 | 1747 | } |
| 1682 | 1748 | print (! empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; |
| 1683 | 1749 | |
| 1684 | 1750 | print '</td></tr>'; |
| 1685 | - } |
|
| 1686 | - else |
|
| 1751 | + } else |
|
| 1687 | 1752 | { |
| 1688 | 1753 | // Weight |
| 1689 | 1754 | print '<tr><td class="titlefield">'.$langs->trans("Weight").'</td><td colspan="2">'; |
| 1690 | 1755 | if ($object->weight != '') |
| 1691 | 1756 | { |
| 1692 | 1757 | print $object->weight." ".measuring_units_string($object->weight_units,"weight"); |
| 1693 | - } |
|
| 1694 | - else |
|
| 1758 | + } else |
|
| 1695 | 1759 | { |
| 1696 | 1760 | print ' '; |
| 1697 | 1761 | } |
@@ -1703,11 +1767,14 @@ discard block |
||
| 1703 | 1767 | if ($object->length != '' || $object->width != '' || $object->height != '') |
| 1704 | 1768 | { |
| 1705 | 1769 | print $object->length; |
| 1706 | - if ($object->width) print " x ".$object->width; |
|
| 1707 | - if ($object->height) print " x ".$object->height; |
|
| 1770 | + if ($object->width) { |
|
| 1771 | + print " x ".$object->width; |
|
| 1772 | + } |
|
| 1773 | + if ($object->height) { |
|
| 1774 | + print " x ".$object->height; |
|
| 1775 | + } |
|
| 1708 | 1776 | print ' '.measuring_units_string($object->length_units,"size"); |
| 1709 | - } |
|
| 1710 | - else |
|
| 1777 | + } else |
|
| 1711 | 1778 | { |
| 1712 | 1779 | print ' '; |
| 1713 | 1780 | } |
@@ -1720,8 +1787,7 @@ discard block |
||
| 1720 | 1787 | if ($object->surface != '') |
| 1721 | 1788 | { |
| 1722 | 1789 | print $object->surface." ".measuring_units_string($object->surface_units,"surface"); |
| 1723 | - } |
|
| 1724 | - else |
|
| 1790 | + } else |
|
| 1725 | 1791 | { |
| 1726 | 1792 | print ' '; |
| 1727 | 1793 | } |
@@ -1734,8 +1800,7 @@ discard block |
||
| 1734 | 1800 | if ($object->volume != '') |
| 1735 | 1801 | { |
| 1736 | 1802 | print $object->volume." ".measuring_units_string($object->volume_units,"volume"); |
| 1737 | - } |
|
| 1738 | - else |
|
| 1803 | + } else |
|
| 1739 | 1804 | { |
| 1740 | 1805 | print ' '; |
| 1741 | 1806 | } |
@@ -1792,8 +1857,7 @@ discard block |
||
| 1792 | 1857 | dol_fiche_end(); |
| 1793 | 1858 | } |
| 1794 | 1859 | |
| 1795 | - } |
|
| 1796 | - else if ($action != 'create') |
|
| 1860 | + } else if ($action != 'create') |
|
| 1797 | 1861 | { |
| 1798 | 1862 | exit; |
| 1799 | 1863 | } |
@@ -1812,7 +1876,9 @@ discard block |
||
| 1812 | 1876 | } |
| 1813 | 1877 | |
| 1814 | 1878 | $tmpcode=''; |
| 1815 | -if (! empty($modCodeProduct->code_auto)) $tmpcode=$modCodeProduct->getNextValue($object,$object->type); |
|
| 1879 | +if (! empty($modCodeProduct->code_auto)) { |
|
| 1880 | + $tmpcode=$modCodeProduct->getNextValue($object,$object->type); |
|
| 1881 | +} |
|
| 1816 | 1882 | |
| 1817 | 1883 | // Define confirmation messages |
| 1818 | 1884 | $formquestionclone=array( |
@@ -1828,17 +1894,21 @@ discard block |
||
| 1828 | 1894 | |
| 1829 | 1895 | // Confirm delete product |
| 1830 | 1896 | if (($action == 'delete' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js |
| 1831 | - || (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) // Always output when not jmobile nor js |
|
| 1897 | + || (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { |
|
| 1898 | + // Always output when not jmobile nor js |
|
| 1832 | 1899 | { |
| 1833 | 1900 | print $form->formconfirm("card.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); |
| 1834 | 1901 | } |
| 1902 | +} |
|
| 1835 | 1903 | |
| 1836 | 1904 | // Clone confirmation |
| 1837 | 1905 | if (($action == 'clone' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js |
| 1838 | - || (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) // Always output when not jmobile nor js |
|
| 1906 | + || (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { |
|
| 1907 | + // Always output when not jmobile nor js |
|
| 1839 | 1908 | { |
| 1840 | 1909 | print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',250,600); |
| 1841 | 1910 | } |
| 1911 | +} |
|
| 1842 | 1912 | |
| 1843 | 1913 | |
| 1844 | 1914 | /* ************************************************************************** */ |
@@ -1857,15 +1927,16 @@ discard block |
||
| 1857 | 1927 | if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer ) || |
| 1858 | 1928 | ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)) |
| 1859 | 1929 | { |
| 1860 | - if (! isset($object->no_button_edit) || $object->no_button_edit <> 1) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans("Modify").'</a></div>'; |
|
| 1930 | + if (! isset($object->no_button_edit) || $object->no_button_edit <> 1) { |
|
| 1931 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans("Modify").'</a></div>'; |
|
| 1932 | + } |
|
| 1861 | 1933 | |
| 1862 | 1934 | if (! isset($object->no_button_copy) || $object->no_button_copy <> 1) |
| 1863 | 1935 | { |
| 1864 | 1936 | if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) |
| 1865 | 1937 | { |
| 1866 | 1938 | print '<div class="inline-block divButAction"><span id="action-clone" class="butAction">'.$langs->trans('ToClone').'</span></div>'."\n"; |
| 1867 | - } |
|
| 1868 | - else |
|
| 1939 | + } else |
|
| 1869 | 1940 | { |
| 1870 | 1941 | print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=clone&id='.$object->id.'">'.$langs->trans("ToClone").'</a></div>'; |
| 1871 | 1942 | } |
@@ -1881,18 +1952,15 @@ discard block |
||
| 1881 | 1952 | if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) |
| 1882 | 1953 | { |
| 1883 | 1954 | print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n"; |
| 1884 | - } |
|
| 1885 | - else |
|
| 1955 | + } else |
|
| 1886 | 1956 | { |
| 1887 | 1957 | print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans("Delete").'</a></div>'; |
| 1888 | 1958 | } |
| 1889 | - } |
|
| 1890 | - else |
|
| 1959 | + } else |
|
| 1891 | 1960 | { |
| 1892 | 1961 | print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("ProductIsUsed").'">'.$langs->trans("Delete").'</a></div>'; |
| 1893 | 1962 | } |
| 1894 | - } |
|
| 1895 | - else |
|
| 1963 | + } else |
|
| 1896 | 1964 | { |
| 1897 | 1965 | print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Delete").'</a></div>'; |
| 1898 | 1966 | } |
@@ -1926,8 +1994,7 @@ discard block |
||
| 1926 | 1994 | $html .= $langs->trans("AddToDraftProposals").'</td><td>'; |
| 1927 | 1995 | $html .= $form->selectarray("propalid", $otherprop, 0, 1); |
| 1928 | 1996 | $html .= '</td></tr>'; |
| 1929 | - } |
|
| 1930 | - else |
|
| 1997 | + } else |
|
| 1931 | 1998 | { |
| 1932 | 1999 | $html .= '<tr><td style="width: 200px;">'; |
| 1933 | 2000 | $html .= $langs->trans("AddToDraftProposals").'</td><td>'; |
@@ -1950,8 +2017,7 @@ discard block |
||
| 1950 | 2017 | $html .= $langs->trans("AddToDraftOrders").'</td><td>'; |
| 1951 | 2018 | $html .= $form->selectarray("commandeid", $othercom, 0, 1); |
| 1952 | 2019 | $html .= '</td></tr>'; |
| 1953 | - } |
|
| 1954 | - else |
|
| 2020 | + } else |
|
| 1955 | 2021 | { |
| 1956 | 2022 | $html .= '<tr><td style="width: 200px;">'; |
| 1957 | 2023 | $html .= $langs->trans("AddToDraftOrders").'</td><td>'; |
@@ -1974,8 +2040,7 @@ discard block |
||
| 1974 | 2040 | $html .= $langs->trans("AddToDraftInvoices").'</td><td>'; |
| 1975 | 2041 | $html .= $form->selectarray("factureid", $otherinvoice, 0, 1); |
| 1976 | 2042 | $html .= '</td></tr>'; |
| 1977 | - } |
|
| 1978 | - else |
|
| 2043 | + } else |
|
| 1979 | 2044 | { |
| 1980 | 2045 | $html .= '<tr><td style="width: 200px;">'; |
| 1981 | 2046 | $html .= $langs->trans("AddToDraftInvoices").'</td><td>'; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | if ($id > 0 || ! empty($ref)) |
| 83 | 83 | { |
| 84 | - $result = $object->fetch($id, $ref); |
|
| 84 | + $result = $object->fetch($id, $ref); |
|
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | $modulepart='product'; |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | $objcanvas=null; |
| 92 | 92 | if (! empty($canvas)) |
| 93 | 93 | { |
| 94 | - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; |
|
| 95 | - $objcanvas = new Canvas($db,$action); |
|
| 96 | - $objcanvas->getCanvas('stockproduct','card',$canvas); |
|
| 94 | + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; |
|
| 95 | + $objcanvas = new Canvas($db,$action); |
|
| 96 | + $objcanvas->getCanvas('stockproduct','card',$canvas); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
@@ -167,27 +167,27 @@ discard block |
||
| 167 | 167 | // Set stock limit |
| 168 | 168 | if ($action == 'setseuil_stock_alerte') |
| 169 | 169 | { |
| 170 | - $object = new Product($db); |
|
| 171 | - $result=$object->fetch($id); |
|
| 172 | - $object->seuil_stock_alerte=$stocklimit; |
|
| 173 | - $result=$object->update($object->id,$user,0,'update'); |
|
| 174 | - if ($result < 0) |
|
| 175 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
| 176 | - //else |
|
| 177 | - // setEventMessage($lans->trans("SavedRecordSuccessfully")); |
|
| 178 | - $action=''; |
|
| 170 | + $object = new Product($db); |
|
| 171 | + $result=$object->fetch($id); |
|
| 172 | + $object->seuil_stock_alerte=$stocklimit; |
|
| 173 | + $result=$object->update($object->id,$user,0,'update'); |
|
| 174 | + if ($result < 0) |
|
| 175 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 176 | + //else |
|
| 177 | + // setEventMessage($lans->trans("SavedRecordSuccessfully")); |
|
| 178 | + $action=''; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Set desired stock |
| 182 | 182 | if ($action == 'setdesiredstock') |
| 183 | 183 | { |
| 184 | - $object = new Product($db); |
|
| 185 | - $result=$object->fetch($id); |
|
| 186 | - $object->desiredstock=$desiredstock; |
|
| 187 | - $result=$object->update($object->id,$user,0,'update'); |
|
| 188 | - if ($result < 0) |
|
| 189 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
| 190 | - $action=''; |
|
| 184 | + $object = new Product($db); |
|
| 185 | + $result=$object->fetch($id); |
|
| 186 | + $object->desiredstock=$desiredstock; |
|
| 187 | + $result=$object->update($object->id,$user,0,'update'); |
|
| 188 | + if ($result < 0) |
|
| 189 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 190 | + $action=''; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
@@ -258,12 +258,12 @@ discard block |
||
| 258 | 258 | else |
| 259 | 259 | { |
| 260 | 260 | $result=$object->correct_stock( |
| 261 | - $user, |
|
| 262 | - GETPOST("id_entrepot"), |
|
| 263 | - GETPOST("nbpiece"), |
|
| 264 | - GETPOST("mouvement"), |
|
| 265 | - GETPOST("label"), |
|
| 266 | - $priceunit, |
|
| 261 | + $user, |
|
| 262 | + GETPOST("id_entrepot"), |
|
| 263 | + GETPOST("nbpiece"), |
|
| 264 | + GETPOST("mouvement"), |
|
| 265 | + GETPOST("label"), |
|
| 266 | + $priceunit, |
|
| 267 | 267 | GETPOST('inventorycode'), |
| 268 | 268 | $origin_element, |
| 269 | 269 | $origin_id |
@@ -279,14 +279,14 @@ discard block |
||
| 279 | 279 | } |
| 280 | 280 | else |
| 281 | 281 | { |
| 282 | - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); |
|
| 282 | + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); |
|
| 283 | 283 | exit; |
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | else |
| 287 | 287 | { |
| 288 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
| 289 | - $action='correction'; |
|
| 288 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 289 | + $action='correction'; |
|
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | } |
@@ -315,15 +315,15 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | if (! empty($conf->productbatch->enabled)) |
| 317 | 317 | { |
| 318 | - $object = new Product($db); |
|
| 319 | - $result=$object->fetch($id); |
|
| 320 | - |
|
| 321 | - if ($object->hasbatch() && ! $batchnumber) |
|
| 322 | - { |
|
| 323 | - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); |
|
| 324 | - $error++; |
|
| 325 | - $action='transfert'; |
|
| 326 | - } |
|
| 318 | + $object = new Product($db); |
|
| 319 | + $result=$object->fetch($id); |
|
| 320 | + |
|
| 321 | + if ($object->hasbatch() && ! $batchnumber) |
|
| 322 | + { |
|
| 323 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); |
|
| 324 | + $error++; |
|
| 325 | + $action='transfert'; |
|
| 326 | + } |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | if (! $error) |
@@ -405,31 +405,31 @@ discard block |
||
| 405 | 405 | { |
| 406 | 406 | if (! $error) |
| 407 | 407 | { |
| 408 | - // Remove stock |
|
| 409 | - $result1=$object->correct_stock( |
|
| 410 | - $user, |
|
| 411 | - GETPOST("id_entrepot"), |
|
| 412 | - GETPOST("nbpiece"), |
|
| 413 | - 1, |
|
| 414 | - GETPOST("label"), |
|
| 415 | - $pricesrc, |
|
| 416 | - GETPOST('inventorycode') |
|
| 417 | - ); |
|
| 418 | - if ($result1 < 0) $error++; |
|
| 408 | + // Remove stock |
|
| 409 | + $result1=$object->correct_stock( |
|
| 410 | + $user, |
|
| 411 | + GETPOST("id_entrepot"), |
|
| 412 | + GETPOST("nbpiece"), |
|
| 413 | + 1, |
|
| 414 | + GETPOST("label"), |
|
| 415 | + $pricesrc, |
|
| 416 | + GETPOST('inventorycode') |
|
| 417 | + ); |
|
| 418 | + if ($result1 < 0) $error++; |
|
| 419 | 419 | } |
| 420 | 420 | if (! $error) |
| 421 | 421 | { |
| 422 | - // Add stock |
|
| 423 | - $result2=$object->correct_stock( |
|
| 424 | - $user, |
|
| 425 | - GETPOST("id_entrepot_destination"), |
|
| 426 | - GETPOST("nbpiece"), |
|
| 427 | - 0, |
|
| 428 | - GETPOST("label"), |
|
| 429 | - $pricedest, |
|
| 430 | - GETPOST('inventorycode') |
|
| 431 | - ); |
|
| 432 | - if ($result2 < 0) $error++; |
|
| 422 | + // Add stock |
|
| 423 | + $result2=$object->correct_stock( |
|
| 424 | + $user, |
|
| 425 | + GETPOST("id_entrepot_destination"), |
|
| 426 | + GETPOST("nbpiece"), |
|
| 427 | + 0, |
|
| 428 | + GETPOST("label"), |
|
| 429 | + $pricedest, |
|
| 430 | + GETPOST('inventorycode') |
|
| 431 | + ); |
|
| 432 | + if ($result2 < 0) $error++; |
|
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | |
@@ -463,41 +463,41 @@ discard block |
||
| 463 | 463 | if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save')) |
| 464 | 464 | { |
| 465 | 465 | |
| 466 | - $pdluo = new Productbatch($db); |
|
| 467 | - $result=$pdluo->fetch(GETPOST('pdluoid','int')); |
|
| 468 | - |
|
| 469 | - if ($result>0) |
|
| 470 | - { |
|
| 471 | - if ($pdluo->id) |
|
| 472 | - { |
|
| 473 | - if ((! GETPOST("sellby")) && (! GETPOST("eatby")) && (! $batchnumber)) { |
|
| 474 | - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); |
|
| 475 | - } |
|
| 476 | - else |
|
| 477 | - { |
|
| 478 | - $d_eatby=dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); |
|
| 479 | - $d_sellby=dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); |
|
| 480 | - $pdluo->batch=$batchnumber; |
|
| 481 | - $pdluo->eatby=$d_eatby; |
|
| 482 | - $pdluo->sellby=$d_sellby; |
|
| 483 | - $result=$pdluo->update($user); |
|
| 484 | - if ($result<0) |
|
| 485 | - { |
|
| 486 | - setEventMessages($pdluo->error,$pdluo->errors, 'errors'); |
|
| 487 | - } |
|
| 488 | - } |
|
| 489 | - } |
|
| 490 | - else |
|
| 491 | - { |
|
| 492 | - setEventMessages($langs->trans('BatchInformationNotfound'),null, 'errors'); |
|
| 493 | - } |
|
| 494 | - } |
|
| 495 | - else |
|
| 496 | - { |
|
| 497 | - setEventMessages($pdluo->error,null, 'errors'); |
|
| 498 | - } |
|
| 499 | - header("Location: product.php?id=".$id); |
|
| 500 | - exit; |
|
| 466 | + $pdluo = new Productbatch($db); |
|
| 467 | + $result=$pdluo->fetch(GETPOST('pdluoid','int')); |
|
| 468 | + |
|
| 469 | + if ($result>0) |
|
| 470 | + { |
|
| 471 | + if ($pdluo->id) |
|
| 472 | + { |
|
| 473 | + if ((! GETPOST("sellby")) && (! GETPOST("eatby")) && (! $batchnumber)) { |
|
| 474 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); |
|
| 475 | + } |
|
| 476 | + else |
|
| 477 | + { |
|
| 478 | + $d_eatby=dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); |
|
| 479 | + $d_sellby=dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); |
|
| 480 | + $pdluo->batch=$batchnumber; |
|
| 481 | + $pdluo->eatby=$d_eatby; |
|
| 482 | + $pdluo->sellby=$d_sellby; |
|
| 483 | + $result=$pdluo->update($user); |
|
| 484 | + if ($result<0) |
|
| 485 | + { |
|
| 486 | + setEventMessages($pdluo->error,$pdluo->errors, 'errors'); |
|
| 487 | + } |
|
| 488 | + } |
|
| 489 | + } |
|
| 490 | + else |
|
| 491 | + { |
|
| 492 | + setEventMessages($langs->trans('BatchInformationNotfound'),null, 'errors'); |
|
| 493 | + } |
|
| 494 | + } |
|
| 495 | + else |
|
| 496 | + { |
|
| 497 | + setEventMessages($pdluo->error,null, 'errors'); |
|
| 498 | + } |
|
| 499 | + header("Location: product.php?id=".$id); |
|
| 500 | + exit; |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | |
@@ -543,17 +543,17 @@ discard block |
||
| 543 | 543 | |
| 544 | 544 | dol_htmloutput_events(); |
| 545 | 545 | |
| 546 | - $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php">'.$langs->trans("BackToList").'</a>'; |
|
| 546 | + $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php">'.$langs->trans("BackToList").'</a>'; |
|
| 547 | 547 | |
| 548 | - $shownav = 1; |
|
| 549 | - if ($user->societe_id && ! in_array('stock', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; |
|
| 548 | + $shownav = 1; |
|
| 549 | + if ($user->societe_id && ! in_array('stock', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; |
|
| 550 | 550 | |
| 551 | - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); |
|
| 551 | + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); |
|
| 552 | 552 | |
| 553 | - print '<div class="fichecenter">'; |
|
| 553 | + print '<div class="fichecenter">'; |
|
| 554 | 554 | |
| 555 | - print '<div class="underbanner clearboth"></div>'; |
|
| 556 | - print '<table class="border tableforfield" width="100%">'; |
|
| 555 | + print '<div class="underbanner clearboth"></div>'; |
|
| 556 | + print '<table class="border tableforfield" width="100%">'; |
|
| 557 | 557 | |
| 558 | 558 | if ($conf->productbatch->enabled) |
| 559 | 559 | { |
@@ -613,34 +613,34 @@ discard block |
||
| 613 | 613 | print '</td></tr>'; |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - // Stock alert threshold |
|
| 617 | - print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1),'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).'</td><td>'; |
|
| 618 | - print $form->editfieldval("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer,'string'); |
|
| 619 | - print '</td></tr>'; |
|
| 616 | + // Stock alert threshold |
|
| 617 | + print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1),'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).'</td><td>'; |
|
| 618 | + print $form->editfieldval("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer,'string'); |
|
| 619 | + print '</td></tr>'; |
|
| 620 | 620 | |
| 621 | 621 | // Hook formObject |
| 622 | 622 | $parameters=array(); |
| 623 | 623 | $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
| 624 | 624 | print $hookmanager->resPrint; |
| 625 | 625 | |
| 626 | - // Desired stock |
|
| 627 | - print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1),'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer); |
|
| 628 | - print '</td><td>'; |
|
| 629 | - print $form->editfieldval("DesiredStock",'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer,'string'); |
|
| 630 | - print '</td></tr>'; |
|
| 631 | - |
|
| 632 | - // Real stock |
|
| 633 | - $text_stock_options = $langs->trans("RealStockDesc").'<br>'; |
|
| 634 | - $text_stock_options.= $langs->trans("RealStockWillAutomaticallyWhen").'<br>'; |
|
| 635 | - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)?$langs->trans("DeStockOnShipment").'<br>':''); |
|
| 636 | - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)?$langs->trans("DeStockOnValidateOrder").'<br>':''); |
|
| 637 | - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_BILL)?$langs->trans("DeStockOnBill").'<br>':''); |
|
| 638 | - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)?$langs->trans("ReStockOnBill").'<br>':''); |
|
| 639 | - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)?$langs->trans("ReStockOnValidateOrder").'<br>':''); |
|
| 640 | - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)?$langs->trans("ReStockOnDispatchOrder").'<br>':''); |
|
| 641 | - print '<tr><td>'; |
|
| 642 | - print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1); |
|
| 643 | - print '</td>'; |
|
| 626 | + // Desired stock |
|
| 627 | + print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1),'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer); |
|
| 628 | + print '</td><td>'; |
|
| 629 | + print $form->editfieldval("DesiredStock",'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer,'string'); |
|
| 630 | + print '</td></tr>'; |
|
| 631 | + |
|
| 632 | + // Real stock |
|
| 633 | + $text_stock_options = $langs->trans("RealStockDesc").'<br>'; |
|
| 634 | + $text_stock_options.= $langs->trans("RealStockWillAutomaticallyWhen").'<br>'; |
|
| 635 | + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)?$langs->trans("DeStockOnShipment").'<br>':''); |
|
| 636 | + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)?$langs->trans("DeStockOnValidateOrder").'<br>':''); |
|
| 637 | + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_BILL)?$langs->trans("DeStockOnBill").'<br>':''); |
|
| 638 | + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)?$langs->trans("ReStockOnBill").'<br>':''); |
|
| 639 | + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)?$langs->trans("ReStockOnValidateOrder").'<br>':''); |
|
| 640 | + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)?$langs->trans("ReStockOnDispatchOrder").'<br>':''); |
|
| 641 | + print '<tr><td>'; |
|
| 642 | + print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1); |
|
| 643 | + print '</td>'; |
|
| 644 | 644 | print '<td>'.price2num($object->stock_reel, 'MS'); |
| 645 | 645 | if ($object->seuil_stock_alerte != '' && ($object->stock_reel < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); |
| 646 | 646 | print '</td>'; |
@@ -653,49 +653,49 @@ discard block |
||
| 653 | 653 | // Number of customer orders running |
| 654 | 654 | if (! empty($conf->commande->enabled)) |
| 655 | 655 | { |
| 656 | - if ($found) $helpondiff.='<br>'; else $found=1; |
|
| 657 | - $helpondiff.=$langs->trans("ProductQtyInCustomersOrdersRunning").': '.$object->stats_commande['qty']; |
|
| 658 | - $result=$object->load_stats_commande(0,'0', 1); |
|
| 659 | - if ($result < 0) dol_print_error($db,$object->error); |
|
| 660 | - $helpondiff.=' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; |
|
| 656 | + if ($found) $helpondiff.='<br>'; else $found=1; |
|
| 657 | + $helpondiff.=$langs->trans("ProductQtyInCustomersOrdersRunning").': '.$object->stats_commande['qty']; |
|
| 658 | + $result=$object->load_stats_commande(0,'0', 1); |
|
| 659 | + if ($result < 0) dol_print_error($db,$object->error); |
|
| 660 | + $helpondiff.=' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | // Number of product from customer order already sent (partial shipping) |
| 664 | 664 | if (! empty($conf->expedition->enabled)) |
| 665 | 665 | { |
| 666 | - if ($found) $helpondiff.='<br>'; else $found=1; |
|
| 667 | - $result=$object->load_stats_sending(0,'2', 1); |
|
| 668 | - $helpondiff.=$langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty']; |
|
| 666 | + if ($found) $helpondiff.='<br>'; else $found=1; |
|
| 667 | + $result=$object->load_stats_sending(0,'2', 1); |
|
| 668 | + $helpondiff.=$langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty']; |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | // Number of supplier order running |
| 672 | 672 | if (! empty($conf->fournisseur->enabled)) |
| 673 | 673 | { |
| 674 | - if ($found) $helpondiff.='<br>'; else $found=1; |
|
| 675 | - $result=$object->load_stats_commande_fournisseur(0,'3,4', 1); |
|
| 676 | - $helpondiff.=$langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$object->stats_commande_fournisseur['qty']; |
|
| 677 | - $result=$object->load_stats_commande_fournisseur(0,'0,1,2', 1); |
|
| 678 | - if ($result < 0) dol_print_error($db,$object->error); |
|
| 679 | - $helpondiff.=' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; |
|
| 674 | + if ($found) $helpondiff.='<br>'; else $found=1; |
|
| 675 | + $result=$object->load_stats_commande_fournisseur(0,'3,4', 1); |
|
| 676 | + $helpondiff.=$langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$object->stats_commande_fournisseur['qty']; |
|
| 677 | + $result=$object->load_stats_commande_fournisseur(0,'0,1,2', 1); |
|
| 678 | + if ($result < 0) dol_print_error($db,$object->error); |
|
| 679 | + $helpondiff.=' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | // Number of product from supplier order already received (partial receipt) |
| 683 | 683 | if (! empty($conf->fournisseur->enabled)) |
| 684 | 684 | { |
| 685 | - if ($found) $helpondiff.='<br>'; else $found=1; |
|
| 686 | - $helpondiff.=$langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty']; |
|
| 685 | + if ($found) $helpondiff.='<br>'; else $found=1; |
|
| 686 | + $helpondiff.=$langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty']; |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | - // Calculating a theorical value |
|
| 690 | - print '<tr><td>'; |
|
| 691 | - print $form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc")); |
|
| 692 | - print '</td>'; |
|
| 693 | - print "<td>"; |
|
| 694 | - //print (empty($stocktheo)?0:$stocktheo); |
|
| 695 | - print $form->textwithpicto((empty($stocktheo)?0:$stocktheo), $helpondiff); |
|
| 696 | - if ($object->seuil_stock_alerte != '' && ($object->stock_theorique < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); |
|
| 697 | - print '</td>'; |
|
| 698 | - print '</tr>'; |
|
| 689 | + // Calculating a theorical value |
|
| 690 | + print '<tr><td>'; |
|
| 691 | + print $form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc")); |
|
| 692 | + print '</td>'; |
|
| 693 | + print "<td>"; |
|
| 694 | + //print (empty($stocktheo)?0:$stocktheo); |
|
| 695 | + print $form->textwithpicto((empty($stocktheo)?0:$stocktheo), $helpondiff); |
|
| 696 | + if ($object->seuil_stock_alerte != '' && ($object->stock_theorique < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); |
|
| 697 | + print '</td>'; |
|
| 698 | + print '</tr>'; |
|
| 699 | 699 | |
| 700 | 700 | // Last movement |
| 701 | 701 | $sql = "SELECT max(m.datem) as datem"; |
@@ -714,19 +714,19 @@ discard block |
||
| 714 | 714 | print '<tr><td class="tdtop">'.$langs->trans("LastMovement").'</td><td>'; |
| 715 | 715 | if ($lastmovementdate) |
| 716 | 716 | { |
| 717 | - print dol_print_date($lastmovementdate,'dayhour').' '; |
|
| 718 | - print '(<a href="'.DOL_URL_ROOT.'/product/stock/mouvement.php?idproduct='.$object->id.'">'.$langs->trans("FullList").'</a>)'; |
|
| 717 | + print dol_print_date($lastmovementdate,'dayhour').' '; |
|
| 718 | + print '(<a href="'.DOL_URL_ROOT.'/product/stock/mouvement.php?idproduct='.$object->id.'">'.$langs->trans("FullList").'</a>)'; |
|
| 719 | 719 | } |
| 720 | 720 | else |
| 721 | 721 | { |
| 722 | - print '<a href="'.DOL_URL_ROOT.'/product/stock/mouvement.php?idproduct='.$object->id.'">'.$langs->trans("None").'</a>'; |
|
| 722 | + print '<a href="'.DOL_URL_ROOT.'/product/stock/mouvement.php?idproduct='.$object->id.'">'.$langs->trans("None").'</a>'; |
|
| 723 | 723 | } |
| 724 | 724 | print "</td></tr>"; |
| 725 | 725 | |
| 726 | 726 | print "</table>"; |
| 727 | 727 | |
| 728 | - print '</div>'; |
|
| 729 | - print '<div style="clear:both"></div>'; |
|
| 728 | + print '</div>'; |
|
| 729 | + print '<div style="clear:both"></div>'; |
|
| 730 | 730 | |
| 731 | 731 | dol_fiche_end(); |
| 732 | 732 | } |
@@ -765,15 +765,15 @@ discard block |
||
| 765 | 765 | |
| 766 | 766 | if (empty($action) && $object->id) |
| 767 | 767 | { |
| 768 | - print "<div class=\"tabsAction\">\n"; |
|
| 768 | + print "<div class=\"tabsAction\">\n"; |
|
| 769 | 769 | |
| 770 | - if ($user->rights->stock->mouvement->creer) |
|
| 771 | - { |
|
| 772 | - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=correction">'.$langs->trans("StockCorrection").'</a>'; |
|
| 773 | - } |
|
| 770 | + if ($user->rights->stock->mouvement->creer) |
|
| 771 | + { |
|
| 772 | + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=correction">'.$langs->trans("StockCorrection").'</a>'; |
|
| 773 | + } |
|
| 774 | 774 | |
| 775 | - //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) |
|
| 776 | - if ($user->rights->stock->mouvement->creer) |
|
| 775 | + //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) |
|
| 776 | + if ($user->rights->stock->mouvement->creer) |
|
| 777 | 777 | { |
| 778 | 778 | print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=transfert">'.$langs->trans("StockTransfer").'</a>'; |
| 779 | 779 | } |
@@ -846,20 +846,20 @@ discard block |
||
| 846 | 846 | print '<td align="right">'.(price2num($object->pmp)?price2num($object->pmp,'MU'):'').'</td>'; |
| 847 | 847 | // Value purchase |
| 848 | 848 | print '<td align="right">'.(price2num($object->pmp)?price(price2num($object->pmp*$obj->reel,'MT')):'').'</td>'; |
| 849 | - // Sell price |
|
| 849 | + // Sell price |
|
| 850 | + print '<td align="right">'; |
|
| 851 | + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price,'MU'),1); |
|
| 852 | + else print $langs->trans("Variable"); |
|
| 853 | + print '</td>'; |
|
| 854 | + // Value sell |
|
| 850 | 855 | print '<td align="right">'; |
| 851 | - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price,'MU'),1); |
|
| 852 | - else print $langs->trans("Variable"); |
|
| 853 | - print '</td>'; |
|
| 854 | - // Value sell |
|
| 855 | - print '<td align="right">'; |
|
| 856 | - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price*$obj->reel,'MT'),1).'</td>'; |
|
| 857 | - else print $langs->trans("Variable"); |
|
| 856 | + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price*$obj->reel,'MT'),1).'</td>'; |
|
| 857 | + else print $langs->trans("Variable"); |
|
| 858 | 858 | print '</tr>'; ; |
| 859 | 859 | $total += $obj->reel; |
| 860 | 860 | if (price2num($object->pmp)) $totalwithpmp += $obj->reel; |
| 861 | 861 | $totalvalue = $totalvalue + ($object->pmp*$obj->reel); |
| 862 | - $totalvaluesell = $totalvaluesell + ($object->price*$obj->reel); |
|
| 862 | + $totalvaluesell = $totalvaluesell + ($object->price*$obj->reel); |
|
| 863 | 863 | // Batch Detail |
| 864 | 864 | if ((! empty($conf->productbatch->enabled)) && $object->hasbatch()) |
| 865 | 865 | { |
@@ -867,41 +867,41 @@ discard block |
||
| 867 | 867 | if ($details<0) dol_print_error($db); |
| 868 | 868 | foreach ($details as $pdluo) |
| 869 | 869 | { |
| 870 | - if ($action == 'editline' && GETPOST('lineid','int') == $pdluo->id) |
|
| 871 | - { //Current line edit |
|
| 872 | - print "\n".'<tr>'; |
|
| 873 | - print '<td colspan="9">'; |
|
| 874 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
| 875 | - print '<input type="hidden" name="pdluoid" value="'.$pdluo->id.'"><input type="hidden" name="action" value="updateline"><input type="hidden" name="id" value="'.$id.'"><table class="noborder" width="100%"><tr><td width="10%"></td>'; |
|
| 876 | - print '<td align="right" width="10%"><input type="text" name="batch_number" value="'.$pdluo->batch.'"></td>'; |
|
| 877 | - print '<td align="center" width="10%">'; |
|
| 878 | - $form->select_date($pdluo->eatby,'eatby','','',1,'',1,0,1); |
|
| 879 | - print '</td>'; |
|
| 880 | - print '<td align="center" width="10%">'; |
|
| 881 | - $form->select_date($pdluo->sellby,'sellby','','',1,'',1,0,1); |
|
| 882 | - print '</td>'; |
|
| 883 | - print '<td align="right" width="10%">'.$pdluo->qty.($pdluo->qty<0?' '.img_warning():'').'</td>'; |
|
| 884 | - print '<td colspan="4"><input type="submit" class="button" id="savelinebutton" name="save" value="'.$langs->trans("Save").'">'; |
|
| 885 | - print '<input type="submit" class="button" id="cancellinebutton" name="Cancel" value="'.$langs->trans("Cancel").'"></td></tr>'; |
|
| 886 | - print '</table>'; |
|
| 887 | - print '</form>'; |
|
| 888 | - print '</td></tr>'; |
|
| 889 | - } |
|
| 890 | - else |
|
| 870 | + if ($action == 'editline' && GETPOST('lineid','int') == $pdluo->id) |
|
| 871 | + { //Current line edit |
|
| 872 | + print "\n".'<tr>'; |
|
| 873 | + print '<td colspan="9">'; |
|
| 874 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
| 875 | + print '<input type="hidden" name="pdluoid" value="'.$pdluo->id.'"><input type="hidden" name="action" value="updateline"><input type="hidden" name="id" value="'.$id.'"><table class="noborder" width="100%"><tr><td width="10%"></td>'; |
|
| 876 | + print '<td align="right" width="10%"><input type="text" name="batch_number" value="'.$pdluo->batch.'"></td>'; |
|
| 877 | + print '<td align="center" width="10%">'; |
|
| 878 | + $form->select_date($pdluo->eatby,'eatby','','',1,'',1,0,1); |
|
| 879 | + print '</td>'; |
|
| 880 | + print '<td align="center" width="10%">'; |
|
| 881 | + $form->select_date($pdluo->sellby,'sellby','','',1,'',1,0,1); |
|
| 882 | + print '</td>'; |
|
| 883 | + print '<td align="right" width="10%">'.$pdluo->qty.($pdluo->qty<0?' '.img_warning():'').'</td>'; |
|
| 884 | + print '<td colspan="4"><input type="submit" class="button" id="savelinebutton" name="save" value="'.$langs->trans("Save").'">'; |
|
| 885 | + print '<input type="submit" class="button" id="cancellinebutton" name="Cancel" value="'.$langs->trans("Cancel").'"></td></tr>'; |
|
| 886 | + print '</table>'; |
|
| 887 | + print '</form>'; |
|
| 888 | + print '</td></tr>'; |
|
| 889 | + } |
|
| 890 | + else |
|
| 891 | 891 | { |
| 892 | - print "\n".'<tr><td align="right">'; |
|
| 893 | - print img_picto($langs->trans("Tranfer"),'uparrow','class="hideonsmartphone"').' '; |
|
| 892 | + print "\n".'<tr><td align="right">'; |
|
| 893 | + print img_picto($langs->trans("Tranfer"),'uparrow','class="hideonsmartphone"').' '; |
|
| 894 | 894 | print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&id_entrepot='.$entrepotstatic->id.'&action=transfert&pdluoid='.$pdluo->id.'">'.$langs->trans("StockTransfer").'</a>'; |
| 895 | 895 | // Disabled, because edition of stock content must use the "Correct stock menu". |
| 896 | 896 | // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... |
| 897 | - //print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=editline&lineid='.$pdluo->id.'#'.$pdluo->id.'">'; |
|
| 898 | - //print img_edit().'</a></td>'; |
|
| 899 | - print '<td align="right">'.$pdluo->batch.'</td>'; |
|
| 900 | - print '<td align="center">'. dol_print_date($pdluo->eatby,'day') .'</td>'; |
|
| 901 | - print '<td align="center">'. dol_print_date($pdluo->sellby,'day') .'</td>'; |
|
| 902 | - print '<td align="right">'.$pdluo->qty.($pdluo->qty<0?' '.img_warning():'').'</td>'; |
|
| 903 | - print '<td colspan="4"></td></tr>'; |
|
| 904 | - } |
|
| 897 | + //print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=editline&lineid='.$pdluo->id.'#'.$pdluo->id.'">'; |
|
| 898 | + //print img_edit().'</a></td>'; |
|
| 899 | + print '<td align="right">'.$pdluo->batch.'</td>'; |
|
| 900 | + print '<td align="center">'. dol_print_date($pdluo->eatby,'day') .'</td>'; |
|
| 901 | + print '<td align="center">'. dol_print_date($pdluo->sellby,'day') .'</td>'; |
|
| 902 | + print '<td align="right">'.$pdluo->qty.($pdluo->qty<0?' '.img_warning():'').'</td>'; |
|
| 903 | + print '<td colspan="4"></td></tr>'; |
|
| 904 | + } |
|
| 905 | 905 | } |
| 906 | 906 | } |
| 907 | 907 | $i++; |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; |
| 37 | 37 | require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; |
| 38 | 38 | require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productstockentrepot.class.php'; |
| 39 | -if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; |
|
| 40 | -if (! empty($conf->projet->enabled)) |
|
| 39 | +if (!empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; |
|
| 40 | +if (!empty($conf->projet->enabled)) |
|
| 41 | 41 | { |
| 42 | 42 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; |
| 43 | 43 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
@@ -48,66 +48,66 @@ discard block |
||
| 48 | 48 | $langs->load("bills"); |
| 49 | 49 | $langs->load("stocks"); |
| 50 | 50 | $langs->load("sendings"); |
| 51 | -if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); |
|
| 51 | +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); |
|
| 52 | 52 | |
| 53 | -$backtopage=GETPOST('backtopage'); |
|
| 54 | -$action=GETPOST('action','aZ09'); |
|
| 55 | -$cancel=GETPOST('cancel'); |
|
| 53 | +$backtopage = GETPOST('backtopage'); |
|
| 54 | +$action = GETPOST('action', 'aZ09'); |
|
| 55 | +$cancel = GETPOST('cancel'); |
|
| 56 | 56 | |
| 57 | -$id=GETPOST('id', 'int'); |
|
| 58 | -$ref=GETPOST('ref', 'alpha'); |
|
| 57 | +$id = GETPOST('id', 'int'); |
|
| 58 | +$ref = GETPOST('ref', 'alpha'); |
|
| 59 | 59 | $stocklimit = GETPOST('seuil_stock_alerte'); |
| 60 | 60 | $desiredstock = GETPOST('desiredstock'); |
| 61 | 61 | $cancel = GETPOST('cancel'); |
| 62 | -$fieldid = isset($_GET["ref"])?'ref':'rowid'; |
|
| 63 | -$d_eatby=dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); |
|
| 64 | -$d_sellby=dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); |
|
| 65 | -$pdluoid=GETPOST('pdluoid','int'); |
|
| 66 | -$batchnumber=GETPOST('batch_number','san_alpha'); |
|
| 62 | +$fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid'; |
|
| 63 | +$d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); |
|
| 64 | +$d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); |
|
| 65 | +$pdluoid = GETPOST('pdluoid', 'int'); |
|
| 66 | +$batchnumber = GETPOST('batch_number', 'san_alpha'); |
|
| 67 | 67 | if (!empty($batchnumber)) { |
| 68 | - $batchnumber=trim($batchnumber); |
|
| 68 | + $batchnumber = trim($batchnumber); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // Security check |
| 72 | -if ($user->societe_id) $socid=$user->societe_id; |
|
| 73 | -$result=restrictedArea($user,'produit&stock',$id,'product&product','','',$fieldid); |
|
| 72 | +if ($user->societe_id) $socid = $user->societe_id; |
|
| 73 | +$result = restrictedArea($user, 'produit&stock', $id, 'product&product', '', '', $fieldid); |
|
| 74 | 74 | |
| 75 | 75 | |
| 76 | 76 | $object = new Product($db); |
| 77 | 77 | $extrafields = new ExtraFields($db); |
| 78 | 78 | |
| 79 | 79 | // fetch optionals attributes and labels |
| 80 | -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); |
|
| 80 | +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
|
| 81 | 81 | |
| 82 | -if ($id > 0 || ! empty($ref)) |
|
| 82 | +if ($id > 0 || !empty($ref)) |
|
| 83 | 83 | { |
| 84 | 84 | $result = $object->fetch($id, $ref); |
| 85 | 85 | |
| 86 | 86 | } |
| 87 | -$modulepart='product'; |
|
| 87 | +$modulepart = 'product'; |
|
| 88 | 88 | |
| 89 | 89 | // Get object canvas (By default, this is not defined, so standard usage of dolibarr) |
| 90 | -$canvas = !empty($object->canvas)?$object->canvas:GETPOST("canvas"); |
|
| 91 | -$objcanvas=null; |
|
| 92 | -if (! empty($canvas)) |
|
| 90 | +$canvas = !empty($object->canvas) ? $object->canvas : GETPOST("canvas"); |
|
| 91 | +$objcanvas = null; |
|
| 92 | +if (!empty($canvas)) |
|
| 93 | 93 | { |
| 94 | 94 | require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; |
| 95 | - $objcanvas = new Canvas($db,$action); |
|
| 96 | - $objcanvas->getCanvas('stockproduct','card',$canvas); |
|
| 95 | + $objcanvas = new Canvas($db, $action); |
|
| 96 | + $objcanvas->getCanvas('stockproduct', 'card', $canvas); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
| 100 | -$hookmanager->initHooks(array('stockproductcard','globalcard')); |
|
| 100 | +$hookmanager->initHooks(array('stockproductcard', 'globalcard')); |
|
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | /* |
| 104 | 104 | * Actions |
| 105 | 105 | */ |
| 106 | 106 | |
| 107 | -if ($cancel) $action=''; |
|
| 107 | +if ($cancel) $action = ''; |
|
| 108 | 108 | |
| 109 | -$parameters=array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas); |
|
| 110 | -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 109 | +$parameters = array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas); |
|
| 110 | +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
| 111 | 111 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
| 112 | 112 | |
| 113 | 113 | if ($action == 'addlimitstockwarehouse') { |
@@ -116,33 +116,33 @@ discard block |
||
| 116 | 116 | $desiredstock = GETPOST('desiredstock'); |
| 117 | 117 | |
| 118 | 118 | $maj_ok = true; |
| 119 | - if($seuil_stock_alerte == '') { |
|
| 119 | + if ($seuil_stock_alerte == '') { |
|
| 120 | 120 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("StockLimit")), null, 'errors'); |
| 121 | 121 | $maj_ok = false; |
| 122 | 122 | } |
| 123 | - if($desiredstock == '') { |
|
| 123 | + if ($desiredstock == '') { |
|
| 124 | 124 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DesiredStock")), null, 'errors'); |
| 125 | 125 | $maj_ok = false; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - if($maj_ok) { |
|
| 128 | + if ($maj_ok) { |
|
| 129 | 129 | |
| 130 | 130 | $pse = new ProductStockEntrepot($db); |
| 131 | - if($pse->fetch('', GETPOST('id'), GETPOST('fk_entrepot')) > 0) { |
|
| 131 | + if ($pse->fetch('', GETPOST('id'), GETPOST('fk_entrepot')) > 0) { |
|
| 132 | 132 | |
| 133 | 133 | // Update |
| 134 | 134 | $pse->seuil_stock_alerte = $seuil_stock_alerte; |
| 135 | - $pse->desiredstock = $desiredstock; |
|
| 136 | - if($pse->update($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseUpdated')); |
|
| 135 | + $pse->desiredstock = $desiredstock; |
|
| 136 | + if ($pse->update($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseUpdated')); |
|
| 137 | 137 | |
| 138 | 138 | } else { |
| 139 | 139 | |
| 140 | 140 | // Create |
| 141 | - $pse->fk_entrepot = GETPOST('fk_entrepot'); |
|
| 141 | + $pse->fk_entrepot = GETPOST('fk_entrepot'); |
|
| 142 | 142 | $pse->fk_product = GETPOST('id'); |
| 143 | 143 | $pse->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); |
| 144 | 144 | $pse->desiredstock = GETPOST('desiredstock'); |
| 145 | - if($pse->create($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseCreated')); |
|
| 145 | + if ($pse->create($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseCreated')); |
|
| 146 | 146 | |
| 147 | 147 | } |
| 148 | 148 | |
@@ -153,12 +153,12 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | -if($action == 'delete_productstockwarehouse') |
|
| 156 | +if ($action == 'delete_productstockwarehouse') |
|
| 157 | 157 | { |
| 158 | 158 | |
| 159 | 159 | $pse = new ProductStockEntrepot($db); |
| 160 | 160 | $pse->fetch(GETPOST('fk_productstockwarehouse')); |
| 161 | - if($pse->delete($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseDeleted')); |
|
| 161 | + if ($pse->delete($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseDeleted')); |
|
| 162 | 162 | |
| 163 | 163 | $action = ''; |
| 164 | 164 | |
@@ -168,61 +168,61 @@ discard block |
||
| 168 | 168 | if ($action == 'setseuil_stock_alerte') |
| 169 | 169 | { |
| 170 | 170 | $object = new Product($db); |
| 171 | - $result=$object->fetch($id); |
|
| 172 | - $object->seuil_stock_alerte=$stocklimit; |
|
| 173 | - $result=$object->update($object->id,$user,0,'update'); |
|
| 171 | + $result = $object->fetch($id); |
|
| 172 | + $object->seuil_stock_alerte = $stocklimit; |
|
| 173 | + $result = $object->update($object->id, $user, 0, 'update'); |
|
| 174 | 174 | if ($result < 0) |
| 175 | 175 | setEventMessages($object->error, $object->errors, 'errors'); |
| 176 | 176 | //else |
| 177 | 177 | // setEventMessage($lans->trans("SavedRecordSuccessfully")); |
| 178 | - $action=''; |
|
| 178 | + $action = ''; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Set desired stock |
| 182 | 182 | if ($action == 'setdesiredstock') |
| 183 | 183 | { |
| 184 | 184 | $object = new Product($db); |
| 185 | - $result=$object->fetch($id); |
|
| 186 | - $object->desiredstock=$desiredstock; |
|
| 187 | - $result=$object->update($object->id,$user,0,'update'); |
|
| 185 | + $result = $object->fetch($id); |
|
| 186 | + $object->desiredstock = $desiredstock; |
|
| 187 | + $result = $object->update($object->id, $user, 0, 'update'); |
|
| 188 | 188 | if ($result < 0) |
| 189 | 189 | setEventMessages($object->error, $object->errors, 'errors'); |
| 190 | - $action=''; |
|
| 190 | + $action = ''; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
| 194 | 194 | // Correct stock |
| 195 | -if ($action == "correct_stock" && ! $cancel) |
|
| 195 | +if ($action == "correct_stock" && !$cancel) |
|
| 196 | 196 | { |
| 197 | - if (! (GETPOST("id_entrepot") > 0)) |
|
| 197 | + if (!(GETPOST("id_entrepot") > 0)) |
|
| 198 | 198 | { |
| 199 | 199 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); |
| 200 | 200 | $error++; |
| 201 | - $action='correction'; |
|
| 201 | + $action = 'correction'; |
|
| 202 | 202 | } |
| 203 | - if (! GETPOST("nbpiece")) |
|
| 203 | + if (!GETPOST("nbpiece")) |
|
| 204 | 204 | { |
| 205 | 205 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); |
| 206 | 206 | $error++; |
| 207 | - $action='correction'; |
|
| 207 | + $action = 'correction'; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - if (! empty($conf->productbatch->enabled)) |
|
| 210 | + if (!empty($conf->productbatch->enabled)) |
|
| 211 | 211 | { |
| 212 | 212 | $object = new Product($db); |
| 213 | - $result=$object->fetch($id); |
|
| 213 | + $result = $object->fetch($id); |
|
| 214 | 214 | |
| 215 | - if ($object->hasbatch() && ! $batchnumber) |
|
| 215 | + if ($object->hasbatch() && !$batchnumber) |
|
| 216 | 216 | { |
| 217 | 217 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); |
| 218 | 218 | $error++; |
| 219 | - $action='correction'; |
|
| 219 | + $action = 'correction'; |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if (! $error) |
|
| 223 | + if (!$error) |
|
| 224 | 224 | { |
| 225 | - $priceunit=price2num(GETPOST("unitprice")); |
|
| 225 | + $priceunit = price2num(GETPOST("unitprice")); |
|
| 226 | 226 | if (is_numeric(GETPOST("nbpiece")) && $id) |
| 227 | 227 | { |
| 228 | 228 | $origin_element = ''; |
@@ -236,16 +236,16 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | if (empty($object)) { |
| 238 | 238 | $object = new Product($db); |
| 239 | - $result=$object->fetch($id); |
|
| 239 | + $result = $object->fetch($id); |
|
| 240 | 240 | } |
| 241 | 241 | if ($object->hasbatch()) |
| 242 | 242 | { |
| 243 | - $result=$object->correct_stock_batch( |
|
| 243 | + $result = $object->correct_stock_batch( |
|
| 244 | 244 | $user, |
| 245 | 245 | GETPOST("id_entrepot"), |
| 246 | 246 | GETPOST("nbpiece"), |
| 247 | 247 | GETPOST("mouvement"), |
| 248 | - GETPOST("label"), // label movement |
|
| 248 | + GETPOST("label"), // label movement |
|
| 249 | 249 | $priceunit, |
| 250 | 250 | $d_eatby, |
| 251 | 251 | $d_sellby, |
@@ -253,11 +253,11 @@ discard block |
||
| 253 | 253 | GETPOST('inventorycode'), |
| 254 | 254 | $origin_element, |
| 255 | 255 | $origin_id |
| 256 | - ); // We do not change value of stock for a correction |
|
| 256 | + ); // We do not change value of stock for a correction |
|
| 257 | 257 | } |
| 258 | 258 | else |
| 259 | 259 | { |
| 260 | - $result=$object->correct_stock( |
|
| 260 | + $result = $object->correct_stock( |
|
| 261 | 261 | $user, |
| 262 | 262 | GETPOST("id_entrepot"), |
| 263 | 263 | GETPOST("nbpiece"), |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | GETPOST('inventorycode'), |
| 268 | 268 | $origin_element, |
| 269 | 269 | $origin_id |
| 270 | - ); // We do not change value of stock for a correction |
|
| 270 | + ); // We do not change value of stock for a correction |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | if ($result > 0) |
@@ -286,61 +286,61 @@ discard block |
||
| 286 | 286 | else |
| 287 | 287 | { |
| 288 | 288 | setEventMessages($object->error, $object->errors, 'errors'); |
| 289 | - $action='correction'; |
|
| 289 | + $action = 'correction'; |
|
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // Transfer stock from a warehouse to another warehouse |
| 296 | -if ($action == "transfert_stock" && ! $cancel) |
|
| 296 | +if ($action == "transfert_stock" && !$cancel) |
|
| 297 | 297 | { |
| 298 | - if (! (GETPOST("id_entrepot",'int') > 0) || ! (GETPOST("id_entrepot_destination",'int') > 0)) |
|
| 298 | + if (!(GETPOST("id_entrepot", 'int') > 0) || !(GETPOST("id_entrepot_destination", 'int') > 0)) |
|
| 299 | 299 | { |
| 300 | 300 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); |
| 301 | 301 | $error++; |
| 302 | - $action='transfert'; |
|
| 302 | + $action = 'transfert'; |
|
| 303 | 303 | } |
| 304 | - if (! GETPOST("nbpiece",'int')) |
|
| 304 | + if (!GETPOST("nbpiece", 'int')) |
|
| 305 | 305 | { |
| 306 | 306 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); |
| 307 | 307 | $error++; |
| 308 | - $action='transfert'; |
|
| 308 | + $action = 'transfert'; |
|
| 309 | 309 | } |
| 310 | - if (GETPOST("id_entrepot",'int') == GETPOST("id_entrepot_destination",'int')) |
|
| 310 | + if (GETPOST("id_entrepot", 'int') == GETPOST("id_entrepot_destination", 'int')) |
|
| 311 | 311 | { |
| 312 | 312 | setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); |
| 313 | 313 | $error++; |
| 314 | - $action='transfert'; |
|
| 314 | + $action = 'transfert'; |
|
| 315 | 315 | } |
| 316 | - if (! empty($conf->productbatch->enabled)) |
|
| 316 | + if (!empty($conf->productbatch->enabled)) |
|
| 317 | 317 | { |
| 318 | 318 | $object = new Product($db); |
| 319 | - $result=$object->fetch($id); |
|
| 319 | + $result = $object->fetch($id); |
|
| 320 | 320 | |
| 321 | - if ($object->hasbatch() && ! $batchnumber) |
|
| 321 | + if ($object->hasbatch() && !$batchnumber) |
|
| 322 | 322 | { |
| 323 | 323 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); |
| 324 | 324 | $error++; |
| 325 | - $action='transfert'; |
|
| 325 | + $action = 'transfert'; |
|
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if (! $error) |
|
| 329 | + if (!$error) |
|
| 330 | 330 | { |
| 331 | 331 | if ($id) |
| 332 | 332 | { |
| 333 | 333 | $object = new Product($db); |
| 334 | - $result=$object->fetch($id); |
|
| 334 | + $result = $object->fetch($id); |
|
| 335 | 335 | |
| 336 | 336 | $db->begin(); |
| 337 | 337 | |
| 338 | - $object->load_stock('novirtual'); // Load array product->stock_warehouse |
|
| 338 | + $object->load_stock('novirtual'); // Load array product->stock_warehouse |
|
| 339 | 339 | |
| 340 | 340 | // Define value of products moved |
| 341 | - $pricesrc=0; |
|
| 342 | - if (isset($object->pmp)) $pricesrc=$object->pmp; |
|
| 343 | - $pricedest=$pricesrc; |
|
| 341 | + $pricesrc = 0; |
|
| 342 | + if (isset($object->pmp)) $pricesrc = $object->pmp; |
|
| 343 | + $pricedest = $pricesrc; |
|
| 344 | 344 | |
| 345 | 345 | if ($object->hasbatch()) |
| 346 | 346 | { |
@@ -348,13 +348,13 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | if ($pdluoid > 0) |
| 350 | 350 | { |
| 351 | - $result=$pdluo->fetch($pdluoid); |
|
| 351 | + $result = $pdluo->fetch($pdluoid); |
|
| 352 | 352 | if ($result) |
| 353 | 353 | { |
| 354 | - $srcwarehouseid=$pdluo->warehouseid; |
|
| 355 | - $batch=$pdluo->batch; |
|
| 356 | - $eatby=$pdluo->eatby; |
|
| 357 | - $sellby=$pdluo->sellby; |
|
| 354 | + $srcwarehouseid = $pdluo->warehouseid; |
|
| 355 | + $batch = $pdluo->batch; |
|
| 356 | + $eatby = $pdluo->eatby; |
|
| 357 | + $sellby = $pdluo->sellby; |
|
| 358 | 358 | } |
| 359 | 359 | else |
| 360 | 360 | { |
@@ -364,38 +364,38 @@ discard block |
||
| 364 | 364 | } |
| 365 | 365 | else |
| 366 | 366 | { |
| 367 | - $srcwarehouseid=GETPOST('id_entrepot','int'); |
|
| 368 | - $batch=$batchnumber; |
|
| 369 | - $eatby=$d_eatby; |
|
| 370 | - $sellby=$d_sellby; |
|
| 367 | + $srcwarehouseid = GETPOST('id_entrepot', 'int'); |
|
| 368 | + $batch = $batchnumber; |
|
| 369 | + $eatby = $d_eatby; |
|
| 370 | + $sellby = $d_sellby; |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if (! $error) |
|
| 373 | + if (!$error) |
|
| 374 | 374 | { |
| 375 | 375 | // Remove stock |
| 376 | - $result1=$object->correct_stock_batch( |
|
| 376 | + $result1 = $object->correct_stock_batch( |
|
| 377 | 377 | $user, |
| 378 | 378 | $srcwarehouseid, |
| 379 | - GETPOST("nbpiece",'int'), |
|
| 379 | + GETPOST("nbpiece", 'int'), |
|
| 380 | 380 | 1, |
| 381 | - GETPOST("label",'san_alpha'), |
|
| 381 | + GETPOST("label", 'san_alpha'), |
|
| 382 | 382 | $pricesrc, |
| 383 | - $eatby,$sellby,$batch, |
|
| 383 | + $eatby, $sellby, $batch, |
|
| 384 | 384 | GETPOST('inventorycode') |
| 385 | 385 | ); |
| 386 | 386 | if ($result1 < 0) $error++; |
| 387 | 387 | } |
| 388 | - if (! $error) |
|
| 388 | + if (!$error) |
|
| 389 | 389 | { |
| 390 | 390 | // Add stock |
| 391 | - $result2=$object->correct_stock_batch( |
|
| 391 | + $result2 = $object->correct_stock_batch( |
|
| 392 | 392 | $user, |
| 393 | - GETPOST("id_entrepot_destination",'int'), |
|
| 394 | - GETPOST("nbpiece",'int'), |
|
| 393 | + GETPOST("id_entrepot_destination", 'int'), |
|
| 394 | + GETPOST("nbpiece", 'int'), |
|
| 395 | 395 | 0, |
| 396 | - GETPOST("label",'san_alpha'), |
|
| 396 | + GETPOST("label", 'san_alpha'), |
|
| 397 | 397 | $pricedest, |
| 398 | - $eatby,$sellby,$batch, |
|
| 398 | + $eatby, $sellby, $batch, |
|
| 399 | 399 | GETPOST('inventorycode') |
| 400 | 400 | ); |
| 401 | 401 | if ($result2 < 0) $error++; |
@@ -403,10 +403,10 @@ discard block |
||
| 403 | 403 | } |
| 404 | 404 | else |
| 405 | 405 | { |
| 406 | - if (! $error) |
|
| 406 | + if (!$error) |
|
| 407 | 407 | { |
| 408 | 408 | // Remove stock |
| 409 | - $result1=$object->correct_stock( |
|
| 409 | + $result1 = $object->correct_stock( |
|
| 410 | 410 | $user, |
| 411 | 411 | GETPOST("id_entrepot"), |
| 412 | 412 | GETPOST("nbpiece"), |
@@ -417,10 +417,10 @@ discard block |
||
| 417 | 417 | ); |
| 418 | 418 | if ($result1 < 0) $error++; |
| 419 | 419 | } |
| 420 | - if (! $error) |
|
| 420 | + if (!$error) |
|
| 421 | 421 | { |
| 422 | 422 | // Add stock |
| 423 | - $result2=$object->correct_stock( |
|
| 423 | + $result2 = $object->correct_stock( |
|
| 424 | 424 | $user, |
| 425 | 425 | GETPOST("id_entrepot_destination"), |
| 426 | 426 | GETPOST("nbpiece"), |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | |
| 437 | - if (! $error && $result1 >= 0 && $result2 >= 0) |
|
| 437 | + if (!$error && $result1 >= 0 && $result2 >= 0) |
|
| 438 | 438 | { |
| 439 | 439 | $db->commit(); |
| 440 | 440 | |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | { |
| 454 | 454 | setEventMessages($object->error, $object->errors, 'errors'); |
| 455 | 455 | $db->rollback(); |
| 456 | - $action='transfert'; |
|
| 456 | + $action = 'transfert'; |
|
| 457 | 457 | } |
| 458 | 458 | } |
| 459 | 459 | } |
@@ -464,37 +464,37 @@ discard block |
||
| 464 | 464 | { |
| 465 | 465 | |
| 466 | 466 | $pdluo = new Productbatch($db); |
| 467 | - $result=$pdluo->fetch(GETPOST('pdluoid','int')); |
|
| 467 | + $result = $pdluo->fetch(GETPOST('pdluoid', 'int')); |
|
| 468 | 468 | |
| 469 | - if ($result>0) |
|
| 469 | + if ($result > 0) |
|
| 470 | 470 | { |
| 471 | 471 | if ($pdluo->id) |
| 472 | 472 | { |
| 473 | - if ((! GETPOST("sellby")) && (! GETPOST("eatby")) && (! $batchnumber)) { |
|
| 473 | + if ((!GETPOST("sellby")) && (!GETPOST("eatby")) && (!$batchnumber)) { |
|
| 474 | 474 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); |
| 475 | 475 | } |
| 476 | 476 | else |
| 477 | 477 | { |
| 478 | - $d_eatby=dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); |
|
| 479 | - $d_sellby=dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); |
|
| 480 | - $pdluo->batch=$batchnumber; |
|
| 481 | - $pdluo->eatby=$d_eatby; |
|
| 482 | - $pdluo->sellby=$d_sellby; |
|
| 483 | - $result=$pdluo->update($user); |
|
| 484 | - if ($result<0) |
|
| 478 | + $d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); |
|
| 479 | + $d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); |
|
| 480 | + $pdluo->batch = $batchnumber; |
|
| 481 | + $pdluo->eatby = $d_eatby; |
|
| 482 | + $pdluo->sellby = $d_sellby; |
|
| 483 | + $result = $pdluo->update($user); |
|
| 484 | + if ($result < 0) |
|
| 485 | 485 | { |
| 486 | - setEventMessages($pdluo->error,$pdluo->errors, 'errors'); |
|
| 486 | + setEventMessages($pdluo->error, $pdluo->errors, 'errors'); |
|
| 487 | 487 | } |
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | else |
| 491 | 491 | { |
| 492 | - setEventMessages($langs->trans('BatchInformationNotfound'),null, 'errors'); |
|
| 492 | + setEventMessages($langs->trans('BatchInformationNotfound'), null, 'errors'); |
|
| 493 | 493 | } |
| 494 | 494 | } |
| 495 | 495 | else |
| 496 | 496 | { |
| 497 | - setEventMessages($pdluo->error,null, 'errors'); |
|
| 497 | + setEventMessages($pdluo->error, null, 'errors'); |
|
| 498 | 498 | } |
| 499 | 499 | header("Location: product.php?id=".$id); |
| 500 | 500 | exit; |
@@ -507,37 +507,37 @@ discard block |
||
| 507 | 507 | */ |
| 508 | 508 | |
| 509 | 509 | $form = new Form($db); |
| 510 | -$formproduct=new FormProduct($db); |
|
| 511 | -if (! empty($conf->projet->enabled)) $formproject=new FormProjets($db); |
|
| 510 | +$formproduct = new FormProduct($db); |
|
| 511 | +if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); |
|
| 512 | 512 | |
| 513 | 513 | if ($id > 0 || $ref) |
| 514 | 514 | { |
| 515 | 515 | $object = new Product($db); |
| 516 | - $result = $object->fetch($id,$ref); |
|
| 516 | + $result = $object->fetch($id, $ref); |
|
| 517 | 517 | |
| 518 | 518 | $object->load_stock(); |
| 519 | 519 | |
| 520 | 520 | $title = $langs->trans('ProductServiceCard'); |
| 521 | 521 | $helpurl = ''; |
| 522 | - $shortlabel = dol_trunc($object->label,16); |
|
| 522 | + $shortlabel = dol_trunc($object->label, 16); |
|
| 523 | 523 | if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) |
| 524 | 524 | { |
| 525 | - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Stock'); |
|
| 526 | - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; |
|
| 525 | + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Stock'); |
|
| 526 | + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; |
|
| 527 | 527 | } |
| 528 | 528 | if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) |
| 529 | 529 | { |
| 530 | - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Stock'); |
|
| 531 | - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; |
|
| 530 | + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Stock'); |
|
| 531 | + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | llxHeader('', $title, $helpurl); |
| 535 | 535 | |
| 536 | 536 | if ($result > 0) |
| 537 | 537 | { |
| 538 | - $head=product_prepare_head($object); |
|
| 539 | - $titre=$langs->trans("CardProduct".$object->type); |
|
| 540 | - $picto=($object->type==Product::TYPE_SERVICE?'service':'product'); |
|
| 538 | + $head = product_prepare_head($object); |
|
| 539 | + $titre = $langs->trans("CardProduct".$object->type); |
|
| 540 | + $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); |
|
| 541 | 541 | |
| 542 | 542 | dol_fiche_head($head, 'stock', $titre, -1, $picto); |
| 543 | 543 | |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php">'.$langs->trans("BackToList").'</a>'; |
| 547 | 547 | |
| 548 | 548 | $shownav = 1; |
| 549 | - if ($user->societe_id && ! in_array('stock', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; |
|
| 549 | + if ($user->societe_id && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; |
|
| 550 | 550 | |
| 551 | 551 | dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); |
| 552 | 552 | |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | if ($conf->productbatch->enabled) |
| 559 | 559 | { |
| 560 | 560 | print '<tr><td class="titlefield">'.$langs->trans("ManageLotSerial").'</td><td>'; |
| 561 | - print $object->getLibStatut(0,2); |
|
| 561 | + print $object->getLibStatut(0, 2); |
|
| 562 | 562 | print '</td></tr>'; |
| 563 | 563 | } |
| 564 | 564 | |
@@ -583,61 +583,61 @@ discard block |
||
| 583 | 583 | if (empty($conf->global->PRODUIT_MULTIPRICES)) |
| 584 | 584 | { |
| 585 | 585 | // Price |
| 586 | - print '<tr><td>' . $langs->trans("SellingPrice") . '</td><td>'; |
|
| 586 | + print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'; |
|
| 587 | 587 | if ($object->price_base_type == 'TTC') { |
| 588 | - print price($object->price_ttc) . ' ' . $langs->trans($object->price_base_type); |
|
| 588 | + print price($object->price_ttc).' '.$langs->trans($object->price_base_type); |
|
| 589 | 589 | } else { |
| 590 | - print price($object->price) . ' ' . $langs->trans($object->price_base_type); |
|
| 590 | + print price($object->price).' '.$langs->trans($object->price_base_type); |
|
| 591 | 591 | } |
| 592 | 592 | print '</td></tr>'; |
| 593 | 593 | |
| 594 | 594 | // Price minimum |
| 595 | - print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>'; |
|
| 595 | + print '<tr><td>'.$langs->trans("MinPrice").'</td><td>'; |
|
| 596 | 596 | if ($object->price_base_type == 'TTC') { |
| 597 | - print price($object->price_min_ttc) . ' ' . $langs->trans($object->price_base_type); |
|
| 597 | + print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type); |
|
| 598 | 598 | } else { |
| 599 | - print price($object->price_min) . ' ' . $langs->trans($object->price_base_type); |
|
| 599 | + print price($object->price_min).' '.$langs->trans($object->price_base_type); |
|
| 600 | 600 | } |
| 601 | 601 | print '</td></tr>'; |
| 602 | 602 | } |
| 603 | 603 | else |
| 604 | 604 | { |
| 605 | 605 | // Price |
| 606 | - print '<tr><td>' . $langs->trans("SellingPrice") . '</td><td>'; |
|
| 606 | + print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'; |
|
| 607 | 607 | print $langs->trans("Variable"); |
| 608 | 608 | print '</td></tr>'; |
| 609 | 609 | |
| 610 | 610 | // Price minimum |
| 611 | - print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>'; |
|
| 611 | + print '<tr><td>'.$langs->trans("MinPrice").'</td><td>'; |
|
| 612 | 612 | print $langs->trans("Variable"); |
| 613 | 613 | print '</td></tr>'; |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | // Stock alert threshold |
| 617 | - print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1),'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).'</td><td>'; |
|
| 618 | - print $form->editfieldval("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer,'string'); |
|
| 617 | + print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer).'</td><td>'; |
|
| 618 | + print $form->editfieldval("StockLimit", 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer, 'string'); |
|
| 619 | 619 | print '</td></tr>'; |
| 620 | 620 | |
| 621 | 621 | // Hook formObject |
| 622 | - $parameters=array(); |
|
| 623 | - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 622 | + $parameters = array(); |
|
| 623 | + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
| 624 | 624 | print $hookmanager->resPrint; |
| 625 | 625 | |
| 626 | 626 | // Desired stock |
| 627 | - print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1),'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer); |
|
| 627 | + print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1), 'desiredstock', $object->desiredstock, $object, $user->rights->produit->creer); |
|
| 628 | 628 | print '</td><td>'; |
| 629 | - print $form->editfieldval("DesiredStock",'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer,'string'); |
|
| 629 | + print $form->editfieldval("DesiredStock", 'desiredstock', $object->desiredstock, $object, $user->rights->produit->creer, 'string'); |
|
| 630 | 630 | print '</td></tr>'; |
| 631 | 631 | |
| 632 | 632 | // Real stock |
| 633 | 633 | $text_stock_options = $langs->trans("RealStockDesc").'<br>'; |
| 634 | - $text_stock_options.= $langs->trans("RealStockWillAutomaticallyWhen").'<br>'; |
|
| 635 | - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)?$langs->trans("DeStockOnShipment").'<br>':''); |
|
| 636 | - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)?$langs->trans("DeStockOnValidateOrder").'<br>':''); |
|
| 637 | - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_BILL)?$langs->trans("DeStockOnBill").'<br>':''); |
|
| 638 | - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)?$langs->trans("ReStockOnBill").'<br>':''); |
|
| 639 | - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)?$langs->trans("ReStockOnValidateOrder").'<br>':''); |
|
| 640 | - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)?$langs->trans("ReStockOnDispatchOrder").'<br>':''); |
|
| 634 | + $text_stock_options .= $langs->trans("RealStockWillAutomaticallyWhen").'<br>'; |
|
| 635 | + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) ? $langs->trans("DeStockOnShipment").'<br>' : ''); |
|
| 636 | + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) ? $langs->trans("DeStockOnValidateOrder").'<br>' : ''); |
|
| 637 | + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_BILL) ? $langs->trans("DeStockOnBill").'<br>' : ''); |
|
| 638 | + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? $langs->trans("ReStockOnBill").'<br>' : ''); |
|
| 639 | + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? $langs->trans("ReStockOnValidateOrder").'<br>' : ''); |
|
| 640 | + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? $langs->trans("ReStockOnDispatchOrder").'<br>' : ''); |
|
| 641 | 641 | print '<tr><td>'; |
| 642 | 642 | print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1); |
| 643 | 643 | print '</td>'; |
@@ -648,42 +648,42 @@ discard block |
||
| 648 | 648 | |
| 649 | 649 | $stocktheo = price2num($object->stock_theorique, 'MS'); |
| 650 | 650 | |
| 651 | - $found=0; |
|
| 652 | - $helpondiff='<strong>'.$langs->trans("StockDiffPhysicTeoric").':</strong><br>'; |
|
| 651 | + $found = 0; |
|
| 652 | + $helpondiff = '<strong>'.$langs->trans("StockDiffPhysicTeoric").':</strong><br>'; |
|
| 653 | 653 | // Number of customer orders running |
| 654 | - if (! empty($conf->commande->enabled)) |
|
| 654 | + if (!empty($conf->commande->enabled)) |
|
| 655 | 655 | { |
| 656 | - if ($found) $helpondiff.='<br>'; else $found=1; |
|
| 657 | - $helpondiff.=$langs->trans("ProductQtyInCustomersOrdersRunning").': '.$object->stats_commande['qty']; |
|
| 658 | - $result=$object->load_stats_commande(0,'0', 1); |
|
| 659 | - if ($result < 0) dol_print_error($db,$object->error); |
|
| 660 | - $helpondiff.=' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; |
|
| 656 | + if ($found) $helpondiff .= '<br>'; else $found = 1; |
|
| 657 | + $helpondiff .= $langs->trans("ProductQtyInCustomersOrdersRunning").': '.$object->stats_commande['qty']; |
|
| 658 | + $result = $object->load_stats_commande(0, '0', 1); |
|
| 659 | + if ($result < 0) dol_print_error($db, $object->error); |
|
| 660 | + $helpondiff .= ' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | // Number of product from customer order already sent (partial shipping) |
| 664 | - if (! empty($conf->expedition->enabled)) |
|
| 664 | + if (!empty($conf->expedition->enabled)) |
|
| 665 | 665 | { |
| 666 | - if ($found) $helpondiff.='<br>'; else $found=1; |
|
| 667 | - $result=$object->load_stats_sending(0,'2', 1); |
|
| 668 | - $helpondiff.=$langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty']; |
|
| 666 | + if ($found) $helpondiff .= '<br>'; else $found = 1; |
|
| 667 | + $result = $object->load_stats_sending(0, '2', 1); |
|
| 668 | + $helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty']; |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | // Number of supplier order running |
| 672 | - if (! empty($conf->fournisseur->enabled)) |
|
| 672 | + if (!empty($conf->fournisseur->enabled)) |
|
| 673 | 673 | { |
| 674 | - if ($found) $helpondiff.='<br>'; else $found=1; |
|
| 675 | - $result=$object->load_stats_commande_fournisseur(0,'3,4', 1); |
|
| 676 | - $helpondiff.=$langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$object->stats_commande_fournisseur['qty']; |
|
| 677 | - $result=$object->load_stats_commande_fournisseur(0,'0,1,2', 1); |
|
| 678 | - if ($result < 0) dol_print_error($db,$object->error); |
|
| 679 | - $helpondiff.=' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; |
|
| 674 | + if ($found) $helpondiff .= '<br>'; else $found = 1; |
|
| 675 | + $result = $object->load_stats_commande_fournisseur(0, '3,4', 1); |
|
| 676 | + $helpondiff .= $langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$object->stats_commande_fournisseur['qty']; |
|
| 677 | + $result = $object->load_stats_commande_fournisseur(0, '0,1,2', 1); |
|
| 678 | + if ($result < 0) dol_print_error($db, $object->error); |
|
| 679 | + $helpondiff .= ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | // Number of product from supplier order already received (partial receipt) |
| 683 | - if (! empty($conf->fournisseur->enabled)) |
|
| 683 | + if (!empty($conf->fournisseur->enabled)) |
|
| 684 | 684 | { |
| 685 | - if ($found) $helpondiff.='<br>'; else $found=1; |
|
| 686 | - $helpondiff.=$langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty']; |
|
| 685 | + if ($found) $helpondiff .= '<br>'; else $found = 1; |
|
| 686 | + $helpondiff .= $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty']; |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | // Calculating a theorical value |
@@ -692,20 +692,20 @@ discard block |
||
| 692 | 692 | print '</td>'; |
| 693 | 693 | print "<td>"; |
| 694 | 694 | //print (empty($stocktheo)?0:$stocktheo); |
| 695 | - print $form->textwithpicto((empty($stocktheo)?0:$stocktheo), $helpondiff); |
|
| 695 | + print $form->textwithpicto((empty($stocktheo) ? 0 : $stocktheo), $helpondiff); |
|
| 696 | 696 | if ($object->seuil_stock_alerte != '' && ($object->stock_theorique < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); |
| 697 | 697 | print '</td>'; |
| 698 | 698 | print '</tr>'; |
| 699 | 699 | |
| 700 | 700 | // Last movement |
| 701 | 701 | $sql = "SELECT max(m.datem) as datem"; |
| 702 | - $sql.= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; |
|
| 703 | - $sql.= " WHERE m.fk_product = '".$object->id."'"; |
|
| 702 | + $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; |
|
| 703 | + $sql .= " WHERE m.fk_product = '".$object->id."'"; |
|
| 704 | 704 | $resqlbis = $db->query($sql); |
| 705 | 705 | if ($resqlbis) |
| 706 | 706 | { |
| 707 | 707 | $obj = $db->fetch_object($resqlbis); |
| 708 | - $lastmovementdate=$db->jdate($obj->datem); |
|
| 708 | + $lastmovementdate = $db->jdate($obj->datem); |
|
| 709 | 709 | } |
| 710 | 710 | else |
| 711 | 711 | { |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | print '<tr><td class="tdtop">'.$langs->trans("LastMovement").'</td><td>'; |
| 715 | 715 | if ($lastmovementdate) |
| 716 | 716 | { |
| 717 | - print dol_print_date($lastmovementdate,'dayhour').' '; |
|
| 717 | + print dol_print_date($lastmovementdate, 'dayhour').' '; |
|
| 718 | 718 | print '(<a href="'.DOL_URL_ROOT.'/product/stock/mouvement.php?idproduct='.$object->id.'">'.$langs->trans("FullList").'</a>)'; |
| 719 | 719 | } |
| 720 | 720 | else |
@@ -757,9 +757,9 @@ discard block |
||
| 757 | 757 | /* */ |
| 758 | 758 | /* ************************************************************************** */ |
| 759 | 759 | |
| 760 | -$parameters=array(); |
|
| 760 | +$parameters = array(); |
|
| 761 | 761 | |
| 762 | -$reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 762 | +$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
| 763 | 763 | if (empty($reshook)) |
| 764 | 764 | { |
| 765 | 765 | |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | print '<td align="right">'.$langs->trans("SellPriceMin").'</td>'; |
| 799 | 799 | print '<td align="right">'.$langs->trans("EstimatedStockValueSellShort").'</td>'; |
| 800 | 800 | print '</tr>'; |
| 801 | -if ((! empty($conf->productbatch->enabled)) && $object->hasbatch()) |
|
| 801 | +if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) |
|
| 802 | 802 | { |
| 803 | 803 | print '<tr class="liste_titre"><td width="10%"></td>'; |
| 804 | 804 | print '<td align="right" width="10%">'.$langs->trans("batch_number").'</td>'; |
@@ -813,61 +813,61 @@ discard block |
||
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | $sql = "SELECT e.rowid, e.label, e.lieu, ps.reel, ps.rowid as product_stock_id, p.pmp"; |
| 816 | -$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; |
|
| 817 | -$sql.= " ".MAIN_DB_PREFIX."product_stock as ps"; |
|
| 818 | -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; |
|
| 819 | -$sql.= " WHERE ps.reel != 0"; |
|
| 820 | -$sql.= " AND ps.fk_entrepot = e.rowid"; |
|
| 821 | -$sql.= " AND e.entity IN (".getEntity('stock').")"; |
|
| 822 | -$sql.= " AND ps.fk_product = ".$object->id; |
|
| 823 | -$sql.= " ORDER BY e.label"; |
|
| 824 | - |
|
| 825 | -$entrepotstatic=new Entrepot($db); |
|
| 826 | -$total=0; |
|
| 827 | -$totalvalue=$totalvaluesell=0; |
|
| 828 | - |
|
| 829 | -$resql=$db->query($sql); |
|
| 816 | +$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; |
|
| 817 | +$sql .= " ".MAIN_DB_PREFIX."product_stock as ps"; |
|
| 818 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; |
|
| 819 | +$sql .= " WHERE ps.reel != 0"; |
|
| 820 | +$sql .= " AND ps.fk_entrepot = e.rowid"; |
|
| 821 | +$sql .= " AND e.entity IN (".getEntity('stock').")"; |
|
| 822 | +$sql .= " AND ps.fk_product = ".$object->id; |
|
| 823 | +$sql .= " ORDER BY e.label"; |
|
| 824 | + |
|
| 825 | +$entrepotstatic = new Entrepot($db); |
|
| 826 | +$total = 0; |
|
| 827 | +$totalvalue = $totalvaluesell = 0; |
|
| 828 | + |
|
| 829 | +$resql = $db->query($sql); |
|
| 830 | 830 | if ($resql) |
| 831 | 831 | { |
| 832 | 832 | $num = $db->num_rows($resql); |
| 833 | - $total=$totalwithpmp; |
|
| 834 | - $i=0; $var=false; |
|
| 833 | + $total = $totalwithpmp; |
|
| 834 | + $i = 0; $var = false; |
|
| 835 | 835 | while ($i < $num) |
| 836 | 836 | { |
| 837 | 837 | $obj = $db->fetch_object($resql); |
| 838 | - $entrepotstatic->id=$obj->rowid; |
|
| 839 | - $entrepotstatic->libelle=$obj->label; |
|
| 840 | - $entrepotstatic->lieu=$obj->lieu; |
|
| 838 | + $entrepotstatic->id = $obj->rowid; |
|
| 839 | + $entrepotstatic->libelle = $obj->label; |
|
| 840 | + $entrepotstatic->lieu = $obj->lieu; |
|
| 841 | 841 | $stock_real = price2num($obj->reel, 'MS'); |
| 842 | 842 | print '<tr class="oddeven">'; |
| 843 | 843 | print '<td colspan="4">'.$entrepotstatic->getNomUrl(1).'</td>'; |
| 844 | - print '<td align="right">'.$stock_real.($stock_real < 0 ?' '.img_warning():'').'</td>'; |
|
| 844 | + print '<td align="right">'.$stock_real.($stock_real < 0 ? ' '.img_warning() : '').'</td>'; |
|
| 845 | 845 | // PMP |
| 846 | - print '<td align="right">'.(price2num($object->pmp)?price2num($object->pmp,'MU'):'').'</td>'; |
|
| 846 | + print '<td align="right">'.(price2num($object->pmp) ? price2num($object->pmp, 'MU') : '').'</td>'; |
|
| 847 | 847 | // Value purchase |
| 848 | - print '<td align="right">'.(price2num($object->pmp)?price(price2num($object->pmp*$obj->reel,'MT')):'').'</td>'; |
|
| 848 | + print '<td align="right">'.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').'</td>'; |
|
| 849 | 849 | // Sell price |
| 850 | 850 | print '<td align="right">'; |
| 851 | - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price,'MU'),1); |
|
| 851 | + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price, 'MU'), 1); |
|
| 852 | 852 | else print $langs->trans("Variable"); |
| 853 | 853 | print '</td>'; |
| 854 | 854 | // Value sell |
| 855 | 855 | print '<td align="right">'; |
| 856 | - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price*$obj->reel,'MT'),1).'</td>'; |
|
| 856 | + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price * $obj->reel, 'MT'), 1).'</td>'; |
|
| 857 | 857 | else print $langs->trans("Variable"); |
| 858 | 858 | print '</tr>'; ; |
| 859 | 859 | $total += $obj->reel; |
| 860 | 860 | if (price2num($object->pmp)) $totalwithpmp += $obj->reel; |
| 861 | - $totalvalue = $totalvalue + ($object->pmp*$obj->reel); |
|
| 862 | - $totalvaluesell = $totalvaluesell + ($object->price*$obj->reel); |
|
| 861 | + $totalvalue = $totalvalue + ($object->pmp * $obj->reel); |
|
| 862 | + $totalvaluesell = $totalvaluesell + ($object->price * $obj->reel); |
|
| 863 | 863 | // Batch Detail |
| 864 | - if ((! empty($conf->productbatch->enabled)) && $object->hasbatch()) |
|
| 864 | + if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) |
|
| 865 | 865 | { |
| 866 | - $details=Productbatch::findAll($db, $obj->product_stock_id, 0, $object->id); |
|
| 867 | - if ($details<0) dol_print_error($db); |
|
| 866 | + $details = Productbatch::findAll($db, $obj->product_stock_id, 0, $object->id); |
|
| 867 | + if ($details < 0) dol_print_error($db); |
|
| 868 | 868 | foreach ($details as $pdluo) |
| 869 | 869 | { |
| 870 | - if ($action == 'editline' && GETPOST('lineid','int') == $pdluo->id) |
|
| 870 | + if ($action == 'editline' && GETPOST('lineid', 'int') == $pdluo->id) |
|
| 871 | 871 | { //Current line edit |
| 872 | 872 | print "\n".'<tr>'; |
| 873 | 873 | print '<td colspan="9">'; |
@@ -875,12 +875,12 @@ discard block |
||
| 875 | 875 | print '<input type="hidden" name="pdluoid" value="'.$pdluo->id.'"><input type="hidden" name="action" value="updateline"><input type="hidden" name="id" value="'.$id.'"><table class="noborder" width="100%"><tr><td width="10%"></td>'; |
| 876 | 876 | print '<td align="right" width="10%"><input type="text" name="batch_number" value="'.$pdluo->batch.'"></td>'; |
| 877 | 877 | print '<td align="center" width="10%">'; |
| 878 | - $form->select_date($pdluo->eatby,'eatby','','',1,'',1,0,1); |
|
| 878 | + $form->select_date($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0, 1); |
|
| 879 | 879 | print '</td>'; |
| 880 | 880 | print '<td align="center" width="10%">'; |
| 881 | - $form->select_date($pdluo->sellby,'sellby','','',1,'',1,0,1); |
|
| 881 | + $form->select_date($pdluo->sellby, 'sellby', '', '', 1, '', 1, 0, 1); |
|
| 882 | 882 | print '</td>'; |
| 883 | - print '<td align="right" width="10%">'.$pdluo->qty.($pdluo->qty<0?' '.img_warning():'').'</td>'; |
|
| 883 | + print '<td align="right" width="10%">'.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').'</td>'; |
|
| 884 | 884 | print '<td colspan="4"><input type="submit" class="button" id="savelinebutton" name="save" value="'.$langs->trans("Save").'">'; |
| 885 | 885 | print '<input type="submit" class="button" id="cancellinebutton" name="Cancel" value="'.$langs->trans("Cancel").'"></td></tr>'; |
| 886 | 886 | print '</table>'; |
@@ -890,16 +890,16 @@ discard block |
||
| 890 | 890 | else |
| 891 | 891 | { |
| 892 | 892 | print "\n".'<tr><td align="right">'; |
| 893 | - print img_picto($langs->trans("Tranfer"),'uparrow','class="hideonsmartphone"').' '; |
|
| 893 | + print img_picto($langs->trans("Tranfer"), 'uparrow', 'class="hideonsmartphone"').' '; |
|
| 894 | 894 | print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&id_entrepot='.$entrepotstatic->id.'&action=transfert&pdluoid='.$pdluo->id.'">'.$langs->trans("StockTransfer").'</a>'; |
| 895 | 895 | // Disabled, because edition of stock content must use the "Correct stock menu". |
| 896 | 896 | // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... |
| 897 | 897 | //print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=editline&lineid='.$pdluo->id.'#'.$pdluo->id.'">'; |
| 898 | 898 | //print img_edit().'</a></td>'; |
| 899 | 899 | print '<td align="right">'.$pdluo->batch.'</td>'; |
| 900 | - print '<td align="center">'. dol_print_date($pdluo->eatby,'day') .'</td>'; |
|
| 901 | - print '<td align="center">'. dol_print_date($pdluo->sellby,'day') .'</td>'; |
|
| 902 | - print '<td align="right">'.$pdluo->qty.($pdluo->qty<0?' '.img_warning():'').'</td>'; |
|
| 900 | + print '<td align="center">'.dol_print_date($pdluo->eatby, 'day').'</td>'; |
|
| 901 | + print '<td align="center">'.dol_print_date($pdluo->sellby, 'day').'</td>'; |
|
| 902 | + print '<td align="right">'.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').'</td>'; |
|
| 903 | 903 | print '<td colspan="4"></td></tr>'; |
| 904 | 904 | } |
| 905 | 905 | } |
@@ -913,19 +913,19 @@ discard block |
||
| 913 | 913 | print '<tr class="liste_total"><td align="right" class="liste_total" colspan="4">'.$langs->trans("Total").':</td>'; |
| 914 | 914 | print '<td class="liste_total" align="right">'.price2num($total, 'MS').'</td>'; |
| 915 | 915 | print '<td class="liste_total" align="right">'; |
| 916 | -print ($totalwithpmp?price(price2num($totalvalue/$totalwithpmp,'MU')):' '); // This value may have rounding errors |
|
| 916 | +print ($totalwithpmp ? price(price2num($totalvalue / $totalwithpmp, 'MU')) : ' '); // This value may have rounding errors |
|
| 917 | 917 | print '</td>'; |
| 918 | 918 | // Value purchase |
| 919 | 919 | print '<td class="liste_total" align="right">'; |
| 920 | -print $totalvalue?price(price2num($totalvalue,'MT'),1):' '; |
|
| 920 | +print $totalvalue ? price(price2num($totalvalue, 'MT'), 1) : ' '; |
|
| 921 | 921 | print '</td>'; |
| 922 | 922 | print '<td class="liste_total" align="right">'; |
| 923 | -if (empty($conf->global->PRODUIT_MULTIPRICES)) print ($total?price($totalvaluesell/$total,1):' '); |
|
| 923 | +if (empty($conf->global->PRODUIT_MULTIPRICES)) print ($total ? price($totalvaluesell / $total, 1) : ' '); |
|
| 924 | 924 | else print $langs->trans("Variable"); |
| 925 | 925 | print '</td>'; |
| 926 | 926 | // Value to sell |
| 927 | 927 | print '<td class="liste_total" align="right">'; |
| 928 | -if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalvaluesell,'MT'),1); |
|
| 928 | +if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalvaluesell, 'MT'), 1); |
|
| 929 | 929 | else print $langs->trans("Variable"); |
| 930 | 930 | print '</td>'; |
| 931 | 931 | print "</tr>"; |
@@ -954,8 +954,8 @@ discard block |
||
| 954 | 954 | |
| 955 | 955 | if (!empty($lines)) |
| 956 | 956 | { |
| 957 | - $var=false; |
|
| 958 | - foreach($lines as $line) |
|
| 957 | + $var = false; |
|
| 958 | + foreach ($lines as $line) |
|
| 959 | 959 | { |
| 960 | 960 | $ent = new Entrepot($db); |
| 961 | 961 | $ent->fetch($line['fk_entrepot']); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $socid=0; |
| 100 | 100 | if ($user->societe_id > 0) |
| 101 | 101 | { |
| 102 | - //$socid = $user->societe_id; |
|
| 102 | + //$socid = $user->societe_id; |
|
| 103 | 103 | accessforbidden(); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -108,14 +108,14 @@ discard block |
||
| 108 | 108 | $search=array(); |
| 109 | 109 | foreach($object->fields as $key => $val) |
| 110 | 110 | { |
| 111 | - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
| 111 | + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | // List of fields to search into when doing a "search in all" |
| 115 | 115 | $fieldstosearchall = array(); |
| 116 | 116 | foreach($object->fields as $key => $val) |
| 117 | 117 | { |
| 118 | - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; |
|
| 118 | + if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // Definition of fields for list |
@@ -123,15 +123,15 @@ discard block |
||
| 123 | 123 | foreach($object->fields as $key => $val) |
| 124 | 124 | { |
| 125 | 125 | // If $val['visible']==0, then we never show the field |
| 126 | - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); |
|
| 126 | + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); |
|
| 127 | 127 | } |
| 128 | 128 | // Extra fields |
| 129 | 129 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 130 | 130 | { |
| 131 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 132 | - { |
|
| 133 | - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); |
|
| 134 | - } |
|
| 131 | + foreach($extrafields->attribute_label as $key => $val) |
|
| 132 | + { |
|
| 133 | + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); |
|
| 134 | + } |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | |
@@ -152,32 +152,32 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | if (empty($reshook)) |
| 154 | 154 | { |
| 155 | - // Selection of new fields |
|
| 156 | - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
|
| 157 | - |
|
| 158 | - // Purge search criteria |
|
| 159 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers |
|
| 160 | - { |
|
| 161 | - foreach($object->fields as $key => $val) |
|
| 162 | - { |
|
| 163 | - $search[$key]=''; |
|
| 164 | - } |
|
| 165 | - $toselect=''; |
|
| 166 | - $search_array_options=array(); |
|
| 167 | - } |
|
| 168 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') |
|
| 169 | - || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) |
|
| 170 | - { |
|
| 171 | - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - // Mass actions |
|
| 175 | - $objectclass='Inventory'; |
|
| 176 | - $objectlabel='Inventory'; |
|
| 177 | - $permtoread = $user->rights->inventory->read; |
|
| 178 | - $permtodelete = $user->rights->inventory->delete; |
|
| 179 | - $uploaddir = $conf->inventory->dir_output; |
|
| 180 | - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; |
|
| 155 | + // Selection of new fields |
|
| 156 | + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
|
| 157 | + |
|
| 158 | + // Purge search criteria |
|
| 159 | + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers |
|
| 160 | + { |
|
| 161 | + foreach($object->fields as $key => $val) |
|
| 162 | + { |
|
| 163 | + $search[$key]=''; |
|
| 164 | + } |
|
| 165 | + $toselect=''; |
|
| 166 | + $search_array_options=array(); |
|
| 167 | + } |
|
| 168 | + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') |
|
| 169 | + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) |
|
| 170 | + { |
|
| 171 | + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + // Mass actions |
|
| 175 | + $objectclass='Inventory'; |
|
| 176 | + $objectlabel='Inventory'; |
|
| 177 | + $permtoread = $user->rights->inventory->read; |
|
| 178 | + $permtodelete = $user->rights->inventory->delete; |
|
| 179 | + $uploaddir = $conf->inventory->dir_output; |
|
| 180 | + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $sql = 'SELECT '; |
| 203 | 203 | foreach($object->fields as $key => $val) |
| 204 | 204 | { |
| 205 | - $sql.='t.'.$key.', '; |
|
| 205 | + $sql.='t.'.$key.', '; |
|
| 206 | 206 | } |
| 207 | 207 | // Add fields from extrafields |
| 208 | 208 | foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); |
@@ -216,21 +216,21 @@ discard block |
||
| 216 | 216 | $sql.= " WHERE t.entity IN (".getEntity('inventory').")"; |
| 217 | 217 | foreach($search as $key => $val) |
| 218 | 218 | { |
| 219 | - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:($object->fields[$key]['type'] == 'integer'?1:0))); |
|
| 219 | + if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:($object->fields[$key]['type'] == 'integer'?1:0))); |
|
| 220 | 220 | } |
| 221 | 221 | if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); |
| 222 | 222 | // Add where from extra fields |
| 223 | 223 | foreach ($search_array_options as $key => $val) |
| 224 | 224 | { |
| 225 | - $crit=$val; |
|
| 226 | - $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 227 | - $typ=$extrafields->attribute_type[$tmpkey]; |
|
| 228 | - $mode=0; |
|
| 229 | - if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric |
|
| 230 | - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) |
|
| 231 | - { |
|
| 232 | - $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); |
|
| 233 | - } |
|
| 225 | + $crit=$val; |
|
| 226 | + $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 227 | + $typ=$extrafields->attribute_type[$tmpkey]; |
|
| 228 | + $mode=0; |
|
| 229 | + if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric |
|
| 230 | + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) |
|
| 231 | + { |
|
| 232 | + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); |
|
| 233 | + } |
|
| 234 | 234 | } |
| 235 | 235 | // Add where from hooks |
| 236 | 236 | $parameters=array(); |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | $resql=$db->query($sql); |
| 253 | 253 | if (! $resql) |
| 254 | 254 | { |
| 255 | - dol_print_error($db); |
|
| 256 | - exit; |
|
| 255 | + dol_print_error($db); |
|
| 256 | + exit; |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | $num = $db->num_rows($resql); |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | // Direct jump if only one record found |
| 262 | 262 | if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) |
| 263 | 263 | { |
| 264 | - $obj = $db->fetch_object($resql); |
|
| 265 | - $id = $obj->rowid; |
|
| 266 | - header("Location: ".DOL_URL_ROOT.'/inventory/inventory_card.php?id='.$id); |
|
| 267 | - exit; |
|
| 264 | + $obj = $db->fetch_object($resql); |
|
| 265 | + $id = $obj->rowid; |
|
| 266 | + header("Location: ".DOL_URL_ROOT.'/inventory/inventory_card.php?id='.$id); |
|
| 267 | + exit; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | |
@@ -295,20 +295,20 @@ discard block |
||
| 295 | 295 | if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
| 296 | 296 | foreach($search as $key => $val) |
| 297 | 297 | { |
| 298 | - $param.= '&search_'.$key.'='.urlencode($search[$key]); |
|
| 298 | + $param.= '&search_'.$key.'='.urlencode($search[$key]); |
|
| 299 | 299 | } |
| 300 | 300 | if ($optioncss != '') $param.='&optioncss='.$optioncss; |
| 301 | 301 | // Add $param from extra fields |
| 302 | 302 | foreach ($search_array_options as $key => $val) |
| 303 | 303 | { |
| 304 | - $crit=$val; |
|
| 305 | - $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 306 | - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); |
|
| 304 | + $crit=$val; |
|
| 305 | + $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 306 | + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | $arrayofmassactions = array( |
| 310 | - 'presend'=>$langs->trans("SendByMail"), |
|
| 311 | - 'builddoc'=>$langs->trans("PDFMerge"), |
|
| 310 | + 'presend'=>$langs->trans("SendByMail"), |
|
| 311 | + 'builddoc'=>$langs->trans("PDFMerge"), |
|
| 312 | 312 | ); |
| 313 | 313 | if ($user->rights->inventory->delete) $arrayofmassactions['delete']=$langs->trans("Delete"); |
| 314 | 314 | if ($massaction == 'presend') $arrayofmassactions=array(); |
@@ -328,8 +328,8 @@ discard block |
||
| 328 | 328 | |
| 329 | 329 | if ($sall) |
| 330 | 330 | { |
| 331 | - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); |
|
| 332 | - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); |
|
| 331 | + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); |
|
| 332 | + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | $moreforfilter = ''; |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | { |
| 347 | 347 | print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
| 348 | 348 | print $moreforfilter; |
| 349 | - print '</div>'; |
|
| 349 | + print '</div>'; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
@@ -362,34 +362,34 @@ discard block |
||
| 362 | 362 | print '<tr class="liste_titre">'; |
| 363 | 363 | foreach($object->fields as $key => $val) |
| 364 | 364 | { |
| 365 | - if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 366 | - $align=''; |
|
| 367 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 368 | - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; |
|
| 369 | - if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
| 365 | + if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 366 | + $align=''; |
|
| 367 | + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 368 | + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; |
|
| 369 | + if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
| 370 | 370 | } |
| 371 | 371 | // Extra fields |
| 372 | 372 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 373 | 373 | { |
| 374 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 375 | - { |
|
| 376 | - if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 377 | - { |
|
| 378 | - $align=$extrafields->getAlignFlag($key); |
|
| 379 | - $typeofextrafield=$extrafields->attribute_type[$key]; |
|
| 380 | - print '<td class="liste_titre'.($align?' '.$align:'').'">'; |
|
| 381 | - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) |
|
| 382 | - { |
|
| 383 | - $crit=$val; |
|
| 384 | - $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 385 | - $searchclass=''; |
|
| 386 | - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; |
|
| 387 | - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; |
|
| 388 | - print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">'; |
|
| 389 | - } |
|
| 390 | - print '</td>'; |
|
| 391 | - } |
|
| 392 | - } |
|
| 374 | + foreach($extrafields->attribute_label as $key => $val) |
|
| 375 | + { |
|
| 376 | + if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 377 | + { |
|
| 378 | + $align=$extrafields->getAlignFlag($key); |
|
| 379 | + $typeofextrafield=$extrafields->attribute_type[$key]; |
|
| 380 | + print '<td class="liste_titre'.($align?' '.$align:'').'">'; |
|
| 381 | + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) |
|
| 382 | + { |
|
| 383 | + $crit=$val; |
|
| 384 | + $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 385 | + $searchclass=''; |
|
| 386 | + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; |
|
| 387 | + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; |
|
| 388 | + print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">'; |
|
| 389 | + } |
|
| 390 | + print '</td>'; |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | 393 | } |
| 394 | 394 | // Fields from hook |
| 395 | 395 | $parameters=array('arrayfields'=>$arrayfields); |
@@ -398,11 +398,11 @@ discard block |
||
| 398 | 398 | // Rest of fields search |
| 399 | 399 | foreach($object->fields as $key => $val) |
| 400 | 400 | { |
| 401 | - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 402 | - $align=''; |
|
| 403 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 404 | - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; |
|
| 405 | - if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
| 401 | + if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 402 | + $align=''; |
|
| 403 | + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 404 | + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; |
|
| 405 | + if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
| 406 | 406 | } |
| 407 | 407 | // Action column |
| 408 | 408 | print '<td class="liste_titre" align="right">'; |
@@ -417,24 +417,24 @@ discard block |
||
| 417 | 417 | print '<tr class="liste_titre">'; |
| 418 | 418 | foreach($object->fields as $key => $val) |
| 419 | 419 | { |
| 420 | - if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 421 | - $align=''; |
|
| 422 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 423 | - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; |
|
| 424 | - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
| 420 | + if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 421 | + $align=''; |
|
| 422 | + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 423 | + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; |
|
| 424 | + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
| 425 | 425 | } |
| 426 | 426 | // Extra fields |
| 427 | 427 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 428 | 428 | { |
| 429 | 429 | foreach($extrafields->attribute_label as $key => $val) |
| 430 | 430 | { |
| 431 | - if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 432 | - { |
|
| 431 | + if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 432 | + { |
|
| 433 | 433 | $align=$extrafields->getAlignFlag($key); |
| 434 | 434 | $sortonfield = "ef.".$key; |
| 435 | 435 | if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; |
| 436 | 436 | print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; |
| 437 | - } |
|
| 437 | + } |
|
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | // Hook fields |
@@ -444,11 +444,11 @@ discard block |
||
| 444 | 444 | // Rest of fields title |
| 445 | 445 | foreach($object->fields as $key => $val) |
| 446 | 446 | { |
| 447 | - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 448 | - $align=''; |
|
| 449 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 450 | - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; |
|
| 451 | - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
| 447 | + if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 448 | + $align=''; |
|
| 449 | + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 450 | + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; |
|
| 451 | + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
| 452 | 452 | } |
| 453 | 453 | print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; |
| 454 | 454 | print '</tr>'."\n"; |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | $needToFetchEachLine=0; |
| 459 | 459 | foreach ($extrafields->attribute_computed as $key => $val) |
| 460 | 460 | { |
| 461 | - if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object |
|
| 461 | + if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | |
@@ -468,42 +468,42 @@ discard block |
||
| 468 | 468 | $totalarray=array(); |
| 469 | 469 | while ($i < min($num, $limit)) |
| 470 | 470 | { |
| 471 | - $obj = $db->fetch_object($resql); |
|
| 472 | - if ($obj) |
|
| 473 | - { |
|
| 474 | - // Store properties in $object |
|
| 475 | - $object->id = $obj->rowid; |
|
| 476 | - foreach($object->fields as $key => $val) |
|
| 477 | - { |
|
| 478 | - if (isset($obj->$key)) $object->$key = $obj->$key; |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - // Show here line of result |
|
| 482 | - print '<tr class="oddeven">'; |
|
| 483 | - foreach($object->fields as $key => $val) |
|
| 484 | - { |
|
| 485 | - if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 486 | - $align=''; |
|
| 487 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 488 | - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; |
|
| 489 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
| 490 | - if (! empty($arrayfields['t.'.$key]['checked'])) |
|
| 491 | - { |
|
| 492 | - print '<td'.($align?' class="'.$align.'"':'').'>'; |
|
| 493 | - if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); |
|
| 494 | - elseif ($key == 'ref') print $object->getNomUrl(1); |
|
| 495 | - elseif ($key == 'status') print $object->getLibStatut(3); |
|
| 496 | - else print $obj->$key; |
|
| 497 | - print '</td>'; |
|
| 498 | - if (! $i) $totalarray['nbfield']++; |
|
| 499 | - if (! empty($val['isameasure'])) |
|
| 500 | - { |
|
| 501 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
| 502 | - $totalarray['val']['t.'.$key] += $obj->$key; |
|
| 503 | - } |
|
| 504 | - } |
|
| 505 | - } |
|
| 506 | - // Extra fields |
|
| 471 | + $obj = $db->fetch_object($resql); |
|
| 472 | + if ($obj) |
|
| 473 | + { |
|
| 474 | + // Store properties in $object |
|
| 475 | + $object->id = $obj->rowid; |
|
| 476 | + foreach($object->fields as $key => $val) |
|
| 477 | + { |
|
| 478 | + if (isset($obj->$key)) $object->$key = $obj->$key; |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + // Show here line of result |
|
| 482 | + print '<tr class="oddeven">'; |
|
| 483 | + foreach($object->fields as $key => $val) |
|
| 484 | + { |
|
| 485 | + if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 486 | + $align=''; |
|
| 487 | + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 488 | + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; |
|
| 489 | + if ($key == 'status') $align.=($align?' ':'').'center'; |
|
| 490 | + if (! empty($arrayfields['t.'.$key]['checked'])) |
|
| 491 | + { |
|
| 492 | + print '<td'.($align?' class="'.$align.'"':'').'>'; |
|
| 493 | + if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); |
|
| 494 | + elseif ($key == 'ref') print $object->getNomUrl(1); |
|
| 495 | + elseif ($key == 'status') print $object->getLibStatut(3); |
|
| 496 | + else print $obj->$key; |
|
| 497 | + print '</td>'; |
|
| 498 | + if (! $i) $totalarray['nbfield']++; |
|
| 499 | + if (! empty($val['isameasure'])) |
|
| 500 | + { |
|
| 501 | + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
| 502 | + $totalarray['val']['t.'.$key] += $obj->$key; |
|
| 503 | + } |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | + // Extra fields |
|
| 507 | 507 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 508 | 508 | { |
| 509 | 509 | foreach($extrafields->attribute_label as $key => $val) |
@@ -517,86 +517,86 @@ discard block |
||
| 517 | 517 | $tmpkey='options_'.$key; |
| 518 | 518 | print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); |
| 519 | 519 | print '</td>'; |
| 520 | - if (! $i) $totalarray['nbfield']++; |
|
| 521 | - if (! empty($val['isameasure'])) |
|
| 522 | - { |
|
| 523 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey; |
|
| 524 | - $totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey; |
|
| 525 | - } |
|
| 520 | + if (! $i) $totalarray['nbfield']++; |
|
| 521 | + if (! empty($val['isameasure'])) |
|
| 522 | + { |
|
| 523 | + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey; |
|
| 524 | + $totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey; |
|
| 525 | + } |
|
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | } |
| 529 | - // Fields from hook |
|
| 530 | - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); |
|
| 529 | + // Fields from hook |
|
| 530 | + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); |
|
| 531 | 531 | $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook |
| 532 | - print $hookmanager->resPrint; |
|
| 533 | - // Rest of fields |
|
| 534 | - foreach($object->fields as $key => $val) |
|
| 535 | - { |
|
| 536 | - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 537 | - $align=''; |
|
| 538 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
| 539 | - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
| 540 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
| 541 | - if (! empty($arrayfields['t.'.$key]['checked'])) |
|
| 542 | - { |
|
| 543 | - print '<td'.($align?' class="'.$align.'"':'').'>'; |
|
| 544 | - if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); |
|
| 545 | - elseif ($key == 'status') print $object->getLibStatut(3); |
|
| 546 | - else print $obj->$key; |
|
| 547 | - print '</td>'; |
|
| 548 | - if (! $i) $totalarray['nbfield']++; |
|
| 549 | - if (! empty($val['isameasure'])) |
|
| 550 | - { |
|
| 551 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
| 552 | - $totalarray['val']['t.'.$key] += $obj->$key; |
|
| 553 | - } |
|
| 554 | - } |
|
| 555 | - } |
|
| 556 | - // Action column |
|
| 557 | - print '<td class="nowrap" align="center">'; |
|
| 558 | - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
| 559 | - { |
|
| 560 | - $selected=0; |
|
| 532 | + print $hookmanager->resPrint; |
|
| 533 | + // Rest of fields |
|
| 534 | + foreach($object->fields as $key => $val) |
|
| 535 | + { |
|
| 536 | + if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 537 | + $align=''; |
|
| 538 | + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
| 539 | + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
| 540 | + if ($key == 'status') $align.=($align?' ':'').'center'; |
|
| 541 | + if (! empty($arrayfields['t.'.$key]['checked'])) |
|
| 542 | + { |
|
| 543 | + print '<td'.($align?' class="'.$align.'"':'').'>'; |
|
| 544 | + if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); |
|
| 545 | + elseif ($key == 'status') print $object->getLibStatut(3); |
|
| 546 | + else print $obj->$key; |
|
| 547 | + print '</td>'; |
|
| 548 | + if (! $i) $totalarray['nbfield']++; |
|
| 549 | + if (! empty($val['isameasure'])) |
|
| 550 | + { |
|
| 551 | + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
| 552 | + $totalarray['val']['t.'.$key] += $obj->$key; |
|
| 553 | + } |
|
| 554 | + } |
|
| 555 | + } |
|
| 556 | + // Action column |
|
| 557 | + print '<td class="nowrap" align="center">'; |
|
| 558 | + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
| 559 | + { |
|
| 560 | + $selected=0; |
|
| 561 | 561 | if (in_array($obj->rowid, $arrayofselected)) $selected=1; |
| 562 | 562 | print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; |
| 563 | - } |
|
| 564 | - print '</td>'; |
|
| 565 | - if (! $i) $totalarray['nbfield']++; |
|
| 563 | + } |
|
| 564 | + print '</td>'; |
|
| 565 | + if (! $i) $totalarray['nbfield']++; |
|
| 566 | 566 | |
| 567 | - print '</tr>'; |
|
| 568 | - } |
|
| 569 | - $i++; |
|
| 567 | + print '</tr>'; |
|
| 568 | + } |
|
| 569 | + $i++; |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | // Show total line |
| 573 | 573 | if (isset($totalarray['pos'])) |
| 574 | 574 | { |
| 575 | - print '<tr class="liste_total">'; |
|
| 576 | - $i=0; |
|
| 577 | - while ($i < $totalarray['nbfield']) |
|
| 578 | - { |
|
| 579 | - $i++; |
|
| 580 | - if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
| 581 | - else |
|
| 582 | - { |
|
| 583 | - if ($i == 1) |
|
| 584 | - { |
|
| 585 | - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
| 586 | - else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
| 587 | - } |
|
| 588 | - print '<td></td>'; |
|
| 589 | - } |
|
| 590 | - } |
|
| 591 | - print '</tr>'; |
|
| 575 | + print '<tr class="liste_total">'; |
|
| 576 | + $i=0; |
|
| 577 | + while ($i < $totalarray['nbfield']) |
|
| 578 | + { |
|
| 579 | + $i++; |
|
| 580 | + if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
| 581 | + else |
|
| 582 | + { |
|
| 583 | + if ($i == 1) |
|
| 584 | + { |
|
| 585 | + if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
| 586 | + else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
| 587 | + } |
|
| 588 | + print '<td></td>'; |
|
| 589 | + } |
|
| 590 | + } |
|
| 591 | + print '</tr>'; |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | // If no record found |
| 595 | 595 | if ($num == 0) |
| 596 | 596 | { |
| 597 | - $colspan=1; |
|
| 598 | - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } |
|
| 599 | - print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
|
| 597 | + $colspan=1; |
|
| 598 | + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } |
|
| 599 | + print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | |
@@ -613,25 +613,25 @@ discard block |
||
| 613 | 613 | |
| 614 | 614 | if ($nbtotalofrecords === '' || $nbtotalofrecords) |
| 615 | 615 | { |
| 616 | - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) |
|
| 617 | - { |
|
| 618 | - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); |
|
| 619 | - $formfile = new FormFile($db); |
|
| 620 | - |
|
| 621 | - // Show list of available documents |
|
| 622 | - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; |
|
| 623 | - $urlsource.=str_replace('&','&',$param); |
|
| 624 | - |
|
| 625 | - $filedir=$diroutputmassaction; |
|
| 626 | - $genallowed=$user->rights->inventory->read; |
|
| 627 | - $delallowed=$user->rights->inventory->read; |
|
| 628 | - |
|
| 629 | - print $formfile->showdocuments('massfilesarea_inventory','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); |
|
| 630 | - } |
|
| 631 | - else |
|
| 632 | - { |
|
| 633 | - print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>'; |
|
| 634 | - } |
|
| 616 | + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) |
|
| 617 | + { |
|
| 618 | + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); |
|
| 619 | + $formfile = new FormFile($db); |
|
| 620 | + |
|
| 621 | + // Show list of available documents |
|
| 622 | + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; |
|
| 623 | + $urlsource.=str_replace('&','&',$param); |
|
| 624 | + |
|
| 625 | + $filedir=$diroutputmassaction; |
|
| 626 | + $genallowed=$user->rights->inventory->read; |
|
| 627 | + $delallowed=$user->rights->inventory->read; |
|
| 628 | + |
|
| 629 | + print $formfile->showdocuments('massfilesarea_inventory','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); |
|
| 630 | + } |
|
| 631 | + else |
|
| 632 | + { |
|
| 633 | + print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>'; |
|
| 634 | + } |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | // End of page |
@@ -38,19 +38,19 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | // Load Dolibarr environment |
| 41 | -$res=0; |
|
| 41 | +$res = 0; |
|
| 42 | 42 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) |
| 43 | -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); |
|
| 43 | +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); |
|
| 44 | 44 | // Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME |
| 45 | -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; |
|
| 46 | -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } |
|
| 47 | -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); |
|
| 48 | -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); |
|
| 45 | +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; |
|
| 46 | +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } |
|
| 47 | +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include(substr($tmp, 0, ($i + 1))."/main.inc.php"); |
|
| 48 | +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"); |
|
| 49 | 49 | // Try main.inc.php using relative path |
| 50 | -if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); |
|
| 51 | -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); |
|
| 52 | -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); |
|
| 53 | -if (! $res) die("Include of main fails"); |
|
| 50 | +if (!$res && file_exists("../main.inc.php")) $res = @include("../main.inc.php"); |
|
| 51 | +if (!$res && file_exists("../../main.inc.php")) $res = @include("../../main.inc.php"); |
|
| 52 | +if (!$res && file_exists("../../../main.inc.php")) $res = @include("../../../main.inc.php"); |
|
| 53 | +if (!$res) die("Include of main fails"); |
|
| 54 | 54 | |
| 55 | 55 | require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); |
| 56 | 56 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
@@ -58,45 +58,45 @@ discard block |
||
| 58 | 58 | dol_include_once('/inventory/class/inventory.class.php'); |
| 59 | 59 | |
| 60 | 60 | // Load traductions files requiredby by page |
| 61 | -$langs->loadLangs(array("inventory","other")); |
|
| 61 | +$langs->loadLangs(array("inventory", "other")); |
|
| 62 | 62 | |
| 63 | -$action = GETPOST('action','alpha'); |
|
| 64 | -$massaction = GETPOST('massaction','alpha'); |
|
| 65 | -$show_files = GETPOST('show_files','int'); |
|
| 66 | -$confirm = GETPOST('confirm','alpha'); |
|
| 63 | +$action = GETPOST('action', 'alpha'); |
|
| 64 | +$massaction = GETPOST('massaction', 'alpha'); |
|
| 65 | +$show_files = GETPOST('show_files', 'int'); |
|
| 66 | +$confirm = GETPOST('confirm', 'alpha'); |
|
| 67 | 67 | $cancel = GETPOST('cancel', 'alpha'); |
| 68 | 68 | $toselect = GETPOST('toselect', 'array'); |
| 69 | -$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'inventorylist'; // To manage different context of search |
|
| 69 | +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'inventorylist'; // To manage different context of search |
|
| 70 | 70 | |
| 71 | -$id = GETPOST('id','int'); |
|
| 71 | +$id = GETPOST('id', 'int'); |
|
| 72 | 72 | $backtopage = GETPOST('backtopage'); |
| 73 | -$optioncss = GETPOST('optioncss','alpha'); |
|
| 73 | +$optioncss = GETPOST('optioncss', 'alpha'); |
|
| 74 | 74 | |
| 75 | 75 | // Load variable for pagination |
| 76 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
| 77 | -$sortfield = GETPOST('sortfield','alpha'); |
|
| 78 | -$sortorder = GETPOST('sortorder','alpha'); |
|
| 79 | -$page = GETPOST('page','int'); |
|
| 76 | +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; |
|
| 77 | +$sortfield = GETPOST('sortfield', 'alpha'); |
|
| 78 | +$sortorder = GETPOST('sortorder', 'alpha'); |
|
| 79 | +$page = GETPOST('page', 'int'); |
|
| 80 | 80 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
| 81 | 81 | $offset = $limit * $page; |
| 82 | 82 | $pageprev = $page - 1; |
| 83 | 83 | $pagenext = $page + 1; |
| 84 | 84 | |
| 85 | 85 | // Initialize technical objects |
| 86 | -$object=new Inventory($db); |
|
| 86 | +$object = new Inventory($db); |
|
| 87 | 87 | $extrafields = new ExtraFields($db); |
| 88 | -$diroutputmassaction=$conf->inventory->dir_output . '/temp/massgeneration/'.$user->id; |
|
| 89 | -$hookmanager->initHooks(array('inventorylist')); // Note that conf->hooks_modules contains array |
|
| 88 | +$diroutputmassaction = $conf->inventory->dir_output.'/temp/massgeneration/'.$user->id; |
|
| 89 | +$hookmanager->initHooks(array('inventorylist')); // Note that conf->hooks_modules contains array |
|
| 90 | 90 | // Fetch optionals attributes and labels |
| 91 | 91 | $extralabels = $extrafields->fetch_name_optionals_label('inventory'); |
| 92 | -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); |
|
| 92 | +$search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_'); |
|
| 93 | 93 | |
| 94 | 94 | // Default sort order (if not yet defined by previous GETPOST) |
| 95 | -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. |
|
| 96 | -if (! $sortorder) $sortorder="ASC"; |
|
| 95 | +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. |
|
| 96 | +if (!$sortorder) $sortorder = "ASC"; |
|
| 97 | 97 | |
| 98 | 98 | // Protection if external user |
| 99 | -$socid=0; |
|
| 99 | +$socid = 0; |
|
| 100 | 100 | if ($user->societe_id > 0) |
| 101 | 101 | { |
| 102 | 102 | //$socid = $user->societe_id; |
@@ -104,33 +104,33 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // Initialize array of search criterias |
| 107 | -$search_all=trim(GETPOST("search_all",'alpha')); |
|
| 108 | -$search=array(); |
|
| 109 | -foreach($object->fields as $key => $val) |
|
| 107 | +$search_all = trim(GETPOST("search_all", 'alpha')); |
|
| 108 | +$search = array(); |
|
| 109 | +foreach ($object->fields as $key => $val) |
|
| 110 | 110 | { |
| 111 | - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
| 111 | + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | // List of fields to search into when doing a "search in all" |
| 115 | 115 | $fieldstosearchall = array(); |
| 116 | -foreach($object->fields as $key => $val) |
|
| 116 | +foreach ($object->fields as $key => $val) |
|
| 117 | 117 | { |
| 118 | - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; |
|
| 118 | + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // Definition of fields for list |
| 122 | -$arrayfields=array(); |
|
| 123 | -foreach($object->fields as $key => $val) |
|
| 122 | +$arrayfields = array(); |
|
| 123 | +foreach ($object->fields as $key => $val) |
|
| 124 | 124 | { |
| 125 | 125 | // If $val['visible']==0, then we never show the field |
| 126 | - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); |
|
| 126 | + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled']); |
|
| 127 | 127 | } |
| 128 | 128 | // Extra fields |
| 129 | 129 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 130 | 130 | { |
| 131 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 131 | + foreach ($extrafields->attribute_label as $key => $val) |
|
| 132 | 132 | { |
| 133 | - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); |
|
| 133 | + $arrayfields["ef.".$key] = array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | * Put here all code to do according to value of "$action" parameter |
| 144 | 144 | */ |
| 145 | 145 | |
| 146 | -if (GETPOST('cancel')) { $action='list'; $massaction=''; } |
|
| 147 | -if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } |
|
| 146 | +if (GETPOST('cancel')) { $action = 'list'; $massaction = ''; } |
|
| 147 | +if (!GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } |
|
| 148 | 148 | |
| 149 | -$parameters=array(); |
|
| 150 | -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 149 | +$parameters = array(); |
|
| 150 | +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
| 151 | 151 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
| 152 | 152 | |
| 153 | 153 | if (empty($reshook)) |
@@ -156,24 +156,24 @@ discard block |
||
| 156 | 156 | include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
| 157 | 157 | |
| 158 | 158 | // Purge search criteria |
| 159 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers |
|
| 159 | + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers |
|
| 160 | 160 | { |
| 161 | - foreach($object->fields as $key => $val) |
|
| 161 | + foreach ($object->fields as $key => $val) |
|
| 162 | 162 | { |
| 163 | - $search[$key]=''; |
|
| 163 | + $search[$key] = ''; |
|
| 164 | 164 | } |
| 165 | - $toselect=''; |
|
| 166 | - $search_array_options=array(); |
|
| 165 | + $toselect = ''; |
|
| 166 | + $search_array_options = array(); |
|
| 167 | 167 | } |
| 168 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') |
|
| 169 | - || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) |
|
| 168 | + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') |
|
| 169 | + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) |
|
| 170 | 170 | { |
| 171 | - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation |
|
| 171 | + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Mass actions |
| 175 | - $objectclass='Inventory'; |
|
| 176 | - $objectlabel='Inventory'; |
|
| 175 | + $objectclass = 'Inventory'; |
|
| 176 | + $objectlabel = 'Inventory'; |
|
| 177 | 177 | $permtoread = $user->rights->inventory->read; |
| 178 | 178 | $permtodelete = $user->rights->inventory->delete; |
| 179 | 179 | $uploaddir = $conf->inventory->dir_output; |
@@ -188,55 +188,55 @@ discard block |
||
| 188 | 188 | * Put here all code to build page |
| 189 | 189 | */ |
| 190 | 190 | |
| 191 | -$form=new Form($db); |
|
| 191 | +$form = new Form($db); |
|
| 192 | 192 | |
| 193 | -$now=dol_now(); |
|
| 193 | +$now = dol_now(); |
|
| 194 | 194 | |
| 195 | 195 | //$help_url="EN:Module_Inventory|FR:Module_Inventory_FR|ES:Módulo_Inventory"; |
| 196 | -$help_url=''; |
|
| 196 | +$help_url = ''; |
|
| 197 | 197 | $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Inventorys")); |
| 198 | 198 | |
| 199 | 199 | |
| 200 | 200 | // Build and execute select |
| 201 | 201 | // -------------------------------------------------------------------- |
| 202 | 202 | $sql = 'SELECT '; |
| 203 | -foreach($object->fields as $key => $val) |
|
| 203 | +foreach ($object->fields as $key => $val) |
|
| 204 | 204 | { |
| 205 | - $sql.='t.'.$key.', '; |
|
| 205 | + $sql .= 't.'.$key.', '; |
|
| 206 | 206 | } |
| 207 | 207 | // Add fields from extrafields |
| 208 | -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); |
|
| 208 | +foreach ($extrafields->attribute_label as $key => $val) $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); |
|
| 209 | 209 | // Add fields from hooks |
| 210 | -$parameters=array(); |
|
| 211 | -$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook |
|
| 212 | -$sql.=$hookmanager->resPrint; |
|
| 213 | -$sql=preg_replace('/, $/','', $sql); |
|
| 214 | -$sql.= " FROM ".MAIN_DB_PREFIX."inventory as t"; |
|
| 215 | -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."inventory_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
| 216 | -$sql.= " WHERE t.entity IN (".getEntity('inventory').")"; |
|
| 217 | -foreach($search as $key => $val) |
|
| 210 | +$parameters = array(); |
|
| 211 | +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook |
|
| 212 | +$sql .= $hookmanager->resPrint; |
|
| 213 | +$sql = preg_replace('/, $/', '', $sql); |
|
| 214 | +$sql .= " FROM ".MAIN_DB_PREFIX."inventory as t"; |
|
| 215 | +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."inventory_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
| 216 | +$sql .= " WHERE t.entity IN (".getEntity('inventory').")"; |
|
| 217 | +foreach ($search as $key => $val) |
|
| 218 | 218 | { |
| 219 | - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:($object->fields[$key]['type'] == 'integer'?1:0))); |
|
| 219 | + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : ($object->fields[$key]['type'] == 'integer' ? 1 : 0))); |
|
| 220 | 220 | } |
| 221 | -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); |
|
| 221 | +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); |
|
| 222 | 222 | // Add where from extra fields |
| 223 | 223 | foreach ($search_array_options as $key => $val) |
| 224 | 224 | { |
| 225 | - $crit=$val; |
|
| 226 | - $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 227 | - $typ=$extrafields->attribute_type[$tmpkey]; |
|
| 228 | - $mode=0; |
|
| 229 | - if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric |
|
| 230 | - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) |
|
| 225 | + $crit = $val; |
|
| 226 | + $tmpkey = preg_replace('/search_options_/', '', $key); |
|
| 227 | + $typ = $extrafields->attribute_type[$tmpkey]; |
|
| 228 | + $mode = 0; |
|
| 229 | + if (in_array($typ, array('int', 'double', 'real'))) $mode = 1; // Search on a numeric |
|
| 230 | + if ($val && (($crit != '' && !in_array($typ, array('select'))) || !empty($crit))) |
|
| 231 | 231 | { |
| 232 | 232 | $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | // Add where from hooks |
| 236 | -$parameters=array(); |
|
| 237 | -$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook |
|
| 238 | -$sql.=$hookmanager->resPrint; |
|
| 239 | -$sql.=$db->order($sortfield,$sortorder); |
|
| 236 | +$parameters = array(); |
|
| 237 | +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook |
|
| 238 | +$sql .= $hookmanager->resPrint; |
|
| 239 | +$sql .= $db->order($sortfield, $sortorder); |
|
| 240 | 240 | |
| 241 | 241 | // Count total nb of records |
| 242 | 242 | $nbtotalofrecords = ''; |
@@ -246,11 +246,11 @@ discard block |
||
| 246 | 246 | $nbtotalofrecords = $db->num_rows($result); |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | -$sql.= $db->plimit($limit+1, $offset); |
|
| 249 | +$sql .= $db->plimit($limit + 1, $offset); |
|
| 250 | 250 | |
| 251 | 251 | dol_syslog($script_file, LOG_DEBUG); |
| 252 | -$resql=$db->query($sql); |
|
| 253 | -if (! $resql) |
|
| 252 | +$resql = $db->query($sql); |
|
| 253 | +if (!$resql) |
|
| 254 | 254 | { |
| 255 | 255 | dol_print_error($db); |
| 256 | 256 | exit; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | $num = $db->num_rows($resql); |
| 260 | 260 | |
| 261 | 261 | // Direct jump if only one record found |
| 262 | -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) |
|
| 262 | +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) |
|
| 263 | 263 | { |
| 264 | 264 | $obj = $db->fetch_object($resql); |
| 265 | 265 | $id = $obj->rowid; |
@@ -288,31 +288,31 @@ discard block |
||
| 288 | 288 | }); |
| 289 | 289 | </script>'; |
| 290 | 290 | |
| 291 | -$arrayofselected=is_array($toselect)?$toselect:array(); |
|
| 291 | +$arrayofselected = is_array($toselect) ? $toselect : array(); |
|
| 292 | 292 | |
| 293 | -$param=''; |
|
| 294 | -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; |
|
| 295 | -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
|
| 296 | -foreach($search as $key => $val) |
|
| 293 | +$param = ''; |
|
| 294 | +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; |
|
| 295 | +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; |
|
| 296 | +foreach ($search as $key => $val) |
|
| 297 | 297 | { |
| 298 | - $param.= '&search_'.$key.'='.urlencode($search[$key]); |
|
| 298 | + $param .= '&search_'.$key.'='.urlencode($search[$key]); |
|
| 299 | 299 | } |
| 300 | -if ($optioncss != '') $param.='&optioncss='.$optioncss; |
|
| 300 | +if ($optioncss != '') $param .= '&optioncss='.$optioncss; |
|
| 301 | 301 | // Add $param from extra fields |
| 302 | 302 | foreach ($search_array_options as $key => $val) |
| 303 | 303 | { |
| 304 | - $crit=$val; |
|
| 305 | - $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 306 | - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); |
|
| 304 | + $crit = $val; |
|
| 305 | + $tmpkey = preg_replace('/search_options_/', '', $key); |
|
| 306 | + if ($val != '') $param .= '&search_options_'.$tmpkey.'='.urlencode($val); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | -$arrayofmassactions = array( |
|
| 309 | +$arrayofmassactions = array( |
|
| 310 | 310 | 'presend'=>$langs->trans("SendByMail"), |
| 311 | 311 | 'builddoc'=>$langs->trans("PDFMerge"), |
| 312 | 312 | ); |
| 313 | -if ($user->rights->inventory->delete) $arrayofmassactions['delete']=$langs->trans("Delete"); |
|
| 314 | -if ($massaction == 'presend') $arrayofmassactions=array(); |
|
| 315 | -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); |
|
| 313 | +if ($user->rights->inventory->delete) $arrayofmassactions['delete'] = $langs->trans("Delete"); |
|
| 314 | +if ($massaction == 'presend') $arrayofmassactions = array(); |
|
| 315 | +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); |
|
| 316 | 316 | |
| 317 | 317 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
| 318 | 318 | if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
@@ -328,85 +328,85 @@ discard block |
||
| 328 | 328 | |
| 329 | 329 | if ($sall) |
| 330 | 330 | { |
| 331 | - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); |
|
| 332 | - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); |
|
| 331 | + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); |
|
| 332 | + print $langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | $moreforfilter = ''; |
| 336 | -$moreforfilter.='<div class="divsearchfield">'; |
|
| 337 | -$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; |
|
| 338 | -$moreforfilter.= '</div>'; |
|
| 336 | +$moreforfilter .= '<div class="divsearchfield">'; |
|
| 337 | +$moreforfilter .= $langs->trans('MyFilter').': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; |
|
| 338 | +$moreforfilter .= '</div>'; |
|
| 339 | 339 | |
| 340 | -$parameters=array(); |
|
| 341 | -$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook |
|
| 340 | +$parameters = array(); |
|
| 341 | +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook |
|
| 342 | 342 | if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; |
| 343 | 343 | else $moreforfilter = $hookmanager->resPrint; |
| 344 | 344 | |
| 345 | -if (! empty($moreforfilter)) |
|
| 345 | +if (!empty($moreforfilter)) |
|
| 346 | 346 | { |
| 347 | 347 | print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
| 348 | 348 | print $moreforfilter; |
| 349 | 349 | print '</div>'; |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
|
| 353 | -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
| 354 | -$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); |
|
| 352 | +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; |
|
| 353 | +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
| 354 | +$selectedfields .= $form->showCheckAddButtons('checkforselect', 1); |
|
| 355 | 355 | |
| 356 | 356 | print '<div class="div-table-responsive">'; |
| 357 | -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
|
| 357 | +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; |
|
| 358 | 358 | |
| 359 | 359 | |
| 360 | 360 | // Fields title search |
| 361 | 361 | // -------------------------------------------------------------------- |
| 362 | 362 | print '<tr class="liste_titre">'; |
| 363 | -foreach($object->fields as $key => $val) |
|
| 363 | +foreach ($object->fields as $key => $val) |
|
| 364 | 364 | { |
| 365 | 365 | if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
| 366 | - $align=''; |
|
| 367 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 368 | - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; |
|
| 369 | - if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
| 366 | + $align = ''; |
|
| 367 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; |
|
| 368 | + if (in_array($val['type'], array('timestamp'))) $align .= ' nowrap'; |
|
| 369 | + if (!empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
| 370 | 370 | } |
| 371 | 371 | // Extra fields |
| 372 | 372 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 373 | 373 | { |
| 374 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 374 | + foreach ($extrafields->attribute_label as $key => $val) |
|
| 375 | 375 | { |
| 376 | - if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 376 | + if (!empty($arrayfields["ef.".$key]['checked'])) |
|
| 377 | 377 | { |
| 378 | - $align=$extrafields->getAlignFlag($key); |
|
| 379 | - $typeofextrafield=$extrafields->attribute_type[$key]; |
|
| 380 | - print '<td class="liste_titre'.($align?' '.$align:'').'">'; |
|
| 378 | + $align = $extrafields->getAlignFlag($key); |
|
| 379 | + $typeofextrafield = $extrafields->attribute_type[$key]; |
|
| 380 | + print '<td class="liste_titre'.($align ? ' '.$align : '').'">'; |
|
| 381 | 381 | if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) |
| 382 | 382 | { |
| 383 | - $crit=$val; |
|
| 384 | - $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 385 | - $searchclass=''; |
|
| 386 | - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; |
|
| 387 | - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; |
|
| 388 | - print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">'; |
|
| 383 | + $crit = $val; |
|
| 384 | + $tmpkey = preg_replace('/search_options_/', '', $key); |
|
| 385 | + $searchclass = ''; |
|
| 386 | + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass = 'searchstring'; |
|
| 387 | + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass = 'searchnum'; |
|
| 388 | + print '<input class="flat'.($searchclass ? ' '.$searchclass : '').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">'; |
|
| 389 | 389 | } |
| 390 | 390 | print '</td>'; |
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | 394 | // Fields from hook |
| 395 | -$parameters=array('arrayfields'=>$arrayfields); |
|
| 396 | -$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook |
|
| 395 | +$parameters = array('arrayfields'=>$arrayfields); |
|
| 396 | +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook |
|
| 397 | 397 | print $hookmanager->resPrint; |
| 398 | 398 | // Rest of fields search |
| 399 | -foreach($object->fields as $key => $val) |
|
| 399 | +foreach ($object->fields as $key => $val) |
|
| 400 | 400 | { |
| 401 | - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 402 | - $align=''; |
|
| 403 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 404 | - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; |
|
| 405 | - if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
| 401 | + if (!in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 402 | + $align = ''; |
|
| 403 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; |
|
| 404 | + if (in_array($val['type'], array('timestamp'))) $align .= ' nowrap'; |
|
| 405 | + if (!empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
| 406 | 406 | } |
| 407 | 407 | // Action column |
| 408 | 408 | print '<td class="liste_titre" align="right">'; |
| 409 | -$searchpicto=$form->showFilterButtons(); |
|
| 409 | +$searchpicto = $form->showFilterButtons(); |
|
| 410 | 410 | print $searchpicto; |
| 411 | 411 | print '</td>'; |
| 412 | 412 | print '</tr>'."\n"; |
@@ -415,57 +415,57 @@ discard block |
||
| 415 | 415 | // Fields title label |
| 416 | 416 | // -------------------------------------------------------------------- |
| 417 | 417 | print '<tr class="liste_titre">'; |
| 418 | -foreach($object->fields as $key => $val) |
|
| 418 | +foreach ($object->fields as $key => $val) |
|
| 419 | 419 | { |
| 420 | 420 | if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
| 421 | - $align=''; |
|
| 422 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 423 | - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; |
|
| 424 | - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
| 421 | + $align = ''; |
|
| 422 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; |
|
| 423 | + if (in_array($val['type'], array('timestamp'))) $align .= 'nowrap'; |
|
| 424 | + if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; |
|
| 425 | 425 | } |
| 426 | 426 | // Extra fields |
| 427 | 427 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 428 | 428 | { |
| 429 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 429 | + foreach ($extrafields->attribute_label as $key => $val) |
|
| 430 | 430 | { |
| 431 | - if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 431 | + if (!empty($arrayfields["ef.".$key]['checked'])) |
|
| 432 | 432 | { |
| 433 | - $align=$extrafields->getAlignFlag($key); |
|
| 433 | + $align = $extrafields->getAlignFlag($key); |
|
| 434 | 434 | $sortonfield = "ef.".$key; |
| 435 | - if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; |
|
| 436 | - print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; |
|
| 435 | + if (!empty($extrafields->attribute_computed[$key])) $sortonfield = ''; |
|
| 436 | + print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align ? 'align="'.$align.'"' : ''), $sortfield, $sortorder)."\n"; |
|
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | // Hook fields |
| 441 | -$parameters=array('arrayfields'=>$arrayfields); |
|
| 442 | -$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook |
|
| 441 | +$parameters = array('arrayfields'=>$arrayfields); |
|
| 442 | +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook |
|
| 443 | 443 | print $hookmanager->resPrint; |
| 444 | 444 | // Rest of fields title |
| 445 | -foreach($object->fields as $key => $val) |
|
| 445 | +foreach ($object->fields as $key => $val) |
|
| 446 | 446 | { |
| 447 | - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 448 | - $align=''; |
|
| 449 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 450 | - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; |
|
| 451 | - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
| 447 | + if (!in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 448 | + $align = ''; |
|
| 449 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; |
|
| 450 | + if (in_array($val['type'], array('timestamp'))) $align .= ' nowrap'; |
|
| 451 | + if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; |
|
| 452 | 452 | } |
| 453 | -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; |
|
| 453 | +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; |
|
| 454 | 454 | print '</tr>'."\n"; |
| 455 | 455 | |
| 456 | 456 | |
| 457 | 457 | // Detect if we need a fetch on each output line |
| 458 | -$needToFetchEachLine=0; |
|
| 458 | +$needToFetchEachLine = 0; |
|
| 459 | 459 | foreach ($extrafields->attribute_computed as $key => $val) |
| 460 | 460 | { |
| 461 | - if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object |
|
| 461 | + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | |
| 465 | 465 | // Loop on record |
| 466 | 466 | // -------------------------------------------------------------------- |
| 467 | -$i=0; |
|
| 468 | -$totalarray=array(); |
|
| 467 | +$i = 0; |
|
| 468 | +$totalarray = array(); |
|
| 469 | 469 | while ($i < min($num, $limit)) |
| 470 | 470 | { |
| 471 | 471 | $obj = $db->fetch_object($resql); |
@@ -473,32 +473,32 @@ discard block |
||
| 473 | 473 | { |
| 474 | 474 | // Store properties in $object |
| 475 | 475 | $object->id = $obj->rowid; |
| 476 | - foreach($object->fields as $key => $val) |
|
| 476 | + foreach ($object->fields as $key => $val) |
|
| 477 | 477 | { |
| 478 | 478 | if (isset($obj->$key)) $object->$key = $obj->$key; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | // Show here line of result |
| 482 | 482 | print '<tr class="oddeven">'; |
| 483 | - foreach($object->fields as $key => $val) |
|
| 483 | + foreach ($object->fields as $key => $val) |
|
| 484 | 484 | { |
| 485 | 485 | if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
| 486 | - $align=''; |
|
| 487 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 488 | - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; |
|
| 489 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
| 490 | - if (! empty($arrayfields['t.'.$key]['checked'])) |
|
| 486 | + $align = ''; |
|
| 487 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; |
|
| 488 | + if (in_array($val['type'], array('timestamp'))) $align .= 'nowrap'; |
|
| 489 | + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; |
|
| 490 | + if (!empty($arrayfields['t.'.$key]['checked'])) |
|
| 491 | 491 | { |
| 492 | - print '<td'.($align?' class="'.$align.'"':'').'>'; |
|
| 493 | - if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); |
|
| 492 | + print '<td'.($align ? ' class="'.$align.'"' : '').'>'; |
|
| 493 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); |
|
| 494 | 494 | elseif ($key == 'ref') print $object->getNomUrl(1); |
| 495 | 495 | elseif ($key == 'status') print $object->getLibStatut(3); |
| 496 | 496 | else print $obj->$key; |
| 497 | 497 | print '</td>'; |
| 498 | - if (! $i) $totalarray['nbfield']++; |
|
| 499 | - if (! empty($val['isameasure'])) |
|
| 498 | + if (!$i) $totalarray['nbfield']++; |
|
| 499 | + if (!empty($val['isameasure'])) |
|
| 500 | 500 | { |
| 501 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
| 501 | + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
| 502 | 502 | $totalarray['val']['t.'.$key] += $obj->$key; |
| 503 | 503 | } |
| 504 | 504 | } |
@@ -506,49 +506,49 @@ discard block |
||
| 506 | 506 | // Extra fields |
| 507 | 507 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 508 | 508 | { |
| 509 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 509 | + foreach ($extrafields->attribute_label as $key => $val) |
|
| 510 | 510 | { |
| 511 | - if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 511 | + if (!empty($arrayfields["ef.".$key]['checked'])) |
|
| 512 | 512 | { |
| 513 | 513 | print '<td'; |
| 514 | - $align=$extrafields->getAlignFlag($key); |
|
| 514 | + $align = $extrafields->getAlignFlag($key); |
|
| 515 | 515 | if ($align) print ' align="'.$align.'"'; |
| 516 | 516 | print '>'; |
| 517 | - $tmpkey='options_'.$key; |
|
| 517 | + $tmpkey = 'options_'.$key; |
|
| 518 | 518 | print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); |
| 519 | 519 | print '</td>'; |
| 520 | - if (! $i) $totalarray['nbfield']++; |
|
| 521 | - if (! empty($val['isameasure'])) |
|
| 520 | + if (!$i) $totalarray['nbfield']++; |
|
| 521 | + if (!empty($val['isameasure'])) |
|
| 522 | 522 | { |
| 523 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey; |
|
| 523 | + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'ef.'.$tmpkey; |
|
| 524 | 524 | $totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey; |
| 525 | 525 | } |
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | } |
| 529 | 529 | // Fields from hook |
| 530 | - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); |
|
| 531 | - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook |
|
| 530 | + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); |
|
| 531 | + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook |
|
| 532 | 532 | print $hookmanager->resPrint; |
| 533 | 533 | // Rest of fields |
| 534 | - foreach($object->fields as $key => $val) |
|
| 534 | + foreach ($object->fields as $key => $val) |
|
| 535 | 535 | { |
| 536 | - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 537 | - $align=''; |
|
| 538 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
| 539 | - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
| 540 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
| 541 | - if (! empty($arrayfields['t.'.$key]['checked'])) |
|
| 536 | + if (!in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 537 | + $align = ''; |
|
| 538 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; |
|
| 539 | + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; |
|
| 540 | + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; |
|
| 541 | + if (!empty($arrayfields['t.'.$key]['checked'])) |
|
| 542 | 542 | { |
| 543 | - print '<td'.($align?' class="'.$align.'"':'').'>'; |
|
| 544 | - if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); |
|
| 543 | + print '<td'.($align ? ' class="'.$align.'"' : '').'>'; |
|
| 544 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); |
|
| 545 | 545 | elseif ($key == 'status') print $object->getLibStatut(3); |
| 546 | 546 | else print $obj->$key; |
| 547 | 547 | print '</td>'; |
| 548 | - if (! $i) $totalarray['nbfield']++; |
|
| 549 | - if (! empty($val['isameasure'])) |
|
| 548 | + if (!$i) $totalarray['nbfield']++; |
|
| 549 | + if (!empty($val['isameasure'])) |
|
| 550 | 550 | { |
| 551 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
| 551 | + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
| 552 | 552 | $totalarray['val']['t.'.$key] += $obj->$key; |
| 553 | 553 | } |
| 554 | 554 | } |
@@ -557,12 +557,12 @@ discard block |
||
| 557 | 557 | print '<td class="nowrap" align="center">'; |
| 558 | 558 | if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
| 559 | 559 | { |
| 560 | - $selected=0; |
|
| 561 | - if (in_array($obj->rowid, $arrayofselected)) $selected=1; |
|
| 562 | - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; |
|
| 560 | + $selected = 0; |
|
| 561 | + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; |
|
| 562 | + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; |
|
| 563 | 563 | } |
| 564 | 564 | print '</td>'; |
| 565 | - if (! $i) $totalarray['nbfield']++; |
|
| 565 | + if (!$i) $totalarray['nbfield']++; |
|
| 566 | 566 | |
| 567 | 567 | print '</tr>'; |
| 568 | 568 | } |
@@ -573,11 +573,11 @@ discard block |
||
| 573 | 573 | if (isset($totalarray['pos'])) |
| 574 | 574 | { |
| 575 | 575 | print '<tr class="liste_total">'; |
| 576 | - $i=0; |
|
| 576 | + $i = 0; |
|
| 577 | 577 | while ($i < $totalarray['nbfield']) |
| 578 | 578 | { |
| 579 | 579 | $i++; |
| 580 | - if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
| 580 | + if (!empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
| 581 | 581 | else |
| 582 | 582 | { |
| 583 | 583 | if ($i == 1) |
@@ -594,16 +594,16 @@ discard block |
||
| 594 | 594 | // If no record found |
| 595 | 595 | if ($num == 0) |
| 596 | 596 | { |
| 597 | - $colspan=1; |
|
| 598 | - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } |
|
| 597 | + $colspan = 1; |
|
| 598 | + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } |
|
| 599 | 599 | print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | |
| 603 | 603 | $db->free($resql); |
| 604 | 604 | |
| 605 | -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); |
|
| 606 | -$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook |
|
| 605 | +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); |
|
| 606 | +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook |
|
| 607 | 607 | print $hookmanager->resPrint; |
| 608 | 608 | |
| 609 | 609 | print '</table>'."\n"; |
@@ -619,14 +619,14 @@ discard block |
||
| 619 | 619 | $formfile = new FormFile($db); |
| 620 | 620 | |
| 621 | 621 | // Show list of available documents |
| 622 | - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; |
|
| 623 | - $urlsource.=str_replace('&','&',$param); |
|
| 622 | + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; |
|
| 623 | + $urlsource .= str_replace('&', '&', $param); |
|
| 624 | 624 | |
| 625 | - $filedir=$diroutputmassaction; |
|
| 626 | - $genallowed=$user->rights->inventory->read; |
|
| 627 | - $delallowed=$user->rights->inventory->read; |
|
| 625 | + $filedir = $diroutputmassaction; |
|
| 626 | + $genallowed = $user->rights->inventory->read; |
|
| 627 | + $delallowed = $user->rights->inventory->read; |
|
| 628 | 628 | |
| 629 | - print $formfile->showdocuments('massfilesarea_inventory','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); |
|
| 629 | + print $formfile->showdocuments('massfilesarea_inventory', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, ''); |
|
| 630 | 630 | } |
| 631 | 631 | else |
| 632 | 632 | { |
@@ -40,17 +40,31 @@ discard block |
||
| 40 | 40 | // Load Dolibarr environment |
| 41 | 41 | $res=0; |
| 42 | 42 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) |
| 43 | -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); |
|
| 43 | +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { |
|
| 44 | + $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); |
|
| 45 | +} |
|
| 44 | 46 | // Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME |
| 45 | 47 | $tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; |
| 46 | 48 | while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } |
| 47 | -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); |
|
| 48 | -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); |
|
| 49 | +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) { |
|
| 50 | + $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); |
|
| 51 | +} |
|
| 52 | +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) { |
|
| 53 | + $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); |
|
| 54 | +} |
|
| 49 | 55 | // Try main.inc.php using relative path |
| 50 | -if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); |
|
| 51 | -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); |
|
| 52 | -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); |
|
| 53 | -if (! $res) die("Include of main fails"); |
|
| 56 | +if (! $res && file_exists("../main.inc.php")) { |
|
| 57 | + $res=@include("../main.inc.php"); |
|
| 58 | +} |
|
| 59 | +if (! $res && file_exists("../../main.inc.php")) { |
|
| 60 | + $res=@include("../../main.inc.php"); |
|
| 61 | +} |
|
| 62 | +if (! $res && file_exists("../../../main.inc.php")) { |
|
| 63 | + $res=@include("../../../main.inc.php"); |
|
| 64 | +} |
|
| 65 | +if (! $res) { |
|
| 66 | + die("Include of main fails"); |
|
| 67 | +} |
|
| 54 | 68 | |
| 55 | 69 | require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); |
| 56 | 70 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
@@ -92,8 +106,13 @@ discard block |
||
| 92 | 106 | $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); |
| 93 | 107 | |
| 94 | 108 | // Default sort order (if not yet defined by previous GETPOST) |
| 95 | -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. |
|
| 96 | -if (! $sortorder) $sortorder="ASC"; |
|
| 109 | +if (! $sortfield) { |
|
| 110 | + $sortfield="t.".key($object->fields); |
|
| 111 | +} |
|
| 112 | +// Set here default search field. By default 1st field in definition. |
|
| 113 | +if (! $sortorder) { |
|
| 114 | + $sortorder="ASC"; |
|
| 115 | +} |
|
| 97 | 116 | |
| 98 | 117 | // Protection if external user |
| 99 | 118 | $socid=0; |
@@ -108,23 +127,29 @@ discard block |
||
| 108 | 127 | $search=array(); |
| 109 | 128 | foreach($object->fields as $key => $val) |
| 110 | 129 | { |
| 111 | - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
| 112 | -} |
|
| 130 | + if (GETPOST('search_'.$key,'alpha')) { |
|
| 131 | + $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
| 132 | + } |
|
| 133 | + } |
|
| 113 | 134 | |
| 114 | 135 | // List of fields to search into when doing a "search in all" |
| 115 | 136 | $fieldstosearchall = array(); |
| 116 | 137 | foreach($object->fields as $key => $val) |
| 117 | 138 | { |
| 118 | - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; |
|
| 119 | -} |
|
| 139 | + if ($val['searchall']) { |
|
| 140 | + $fieldstosearchall['t.'.$key]=$val['label']; |
|
| 141 | + } |
|
| 142 | + } |
|
| 120 | 143 | |
| 121 | 144 | // Definition of fields for list |
| 122 | 145 | $arrayfields=array(); |
| 123 | 146 | foreach($object->fields as $key => $val) |
| 124 | 147 | { |
| 125 | 148 | // If $val['visible']==0, then we never show the field |
| 126 | - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); |
|
| 127 | -} |
|
| 149 | + if (! empty($val['visible'])) { |
|
| 150 | + $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); |
|
| 151 | + } |
|
| 152 | + } |
|
| 128 | 153 | // Extra fields |
| 129 | 154 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 130 | 155 | { |
@@ -148,7 +173,9 @@ discard block |
||
| 148 | 173 | |
| 149 | 174 | $parameters=array(); |
| 150 | 175 | $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
| 151 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 176 | +if ($reshook < 0) { |
|
| 177 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 178 | +} |
|
| 152 | 179 | |
| 153 | 180 | if (empty($reshook)) |
| 154 | 181 | { |
@@ -156,11 +183,13 @@ discard block |
||
| 156 | 183 | include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
| 157 | 184 | |
| 158 | 185 | // Purge search criteria |
| 159 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers |
|
| 186 | + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) { |
|
| 187 | + // All tests are required to be compatible with all browsers |
|
| 160 | 188 | { |
| 161 | 189 | foreach($object->fields as $key => $val) |
| 162 | 190 | { |
| 163 | 191 | $search[$key]=''; |
| 192 | + } |
|
| 164 | 193 | } |
| 165 | 194 | $toselect=''; |
| 166 | 195 | $search_array_options=array(); |
@@ -205,20 +234,28 @@ discard block |
||
| 205 | 234 | $sql.='t.'.$key.', '; |
| 206 | 235 | } |
| 207 | 236 | // Add fields from extrafields |
| 208 | -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); |
|
| 237 | +foreach ($extrafields->attribute_label as $key => $val) { |
|
| 238 | + $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); |
|
| 239 | +} |
|
| 209 | 240 | // Add fields from hooks |
| 210 | 241 | $parameters=array(); |
| 211 | 242 | $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook |
| 212 | 243 | $sql.=$hookmanager->resPrint; |
| 213 | 244 | $sql=preg_replace('/, $/','', $sql); |
| 214 | 245 | $sql.= " FROM ".MAIN_DB_PREFIX."inventory as t"; |
| 215 | -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."inventory_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
| 246 | +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { |
|
| 247 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."inventory_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
| 248 | +} |
|
| 216 | 249 | $sql.= " WHERE t.entity IN (".getEntity('inventory').")"; |
| 217 | 250 | foreach($search as $key => $val) |
| 218 | 251 | { |
| 219 | - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:($object->fields[$key]['type'] == 'integer'?1:0))); |
|
| 252 | + if ($search[$key] != '') { |
|
| 253 | + $sql.=natural_search($key, $search[$key], (($key == 'status')?2:($object->fields[$key]['type'] == 'integer'?1:0))); |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | +if ($search_all) { |
|
| 257 | + $sql.= natural_search(array_keys($fieldstosearchall), $search_all); |
|
| 220 | 258 | } |
| 221 | -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); |
|
| 222 | 259 | // Add where from extra fields |
| 223 | 260 | foreach ($search_array_options as $key => $val) |
| 224 | 261 | { |
@@ -226,7 +263,10 @@ discard block |
||
| 226 | 263 | $tmpkey=preg_replace('/search_options_/','',$key); |
| 227 | 264 | $typ=$extrafields->attribute_type[$tmpkey]; |
| 228 | 265 | $mode=0; |
| 229 | - if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric |
|
| 266 | + if (in_array($typ, array('int','double','real'))) { |
|
| 267 | + $mode=1; |
|
| 268 | + } |
|
| 269 | + // Search on a numeric |
|
| 230 | 270 | if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) |
| 231 | 271 | { |
| 232 | 272 | $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); |
@@ -291,31 +331,45 @@ discard block |
||
| 291 | 331 | $arrayofselected=is_array($toselect)?$toselect:array(); |
| 292 | 332 | |
| 293 | 333 | $param=''; |
| 294 | -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; |
|
| 295 | -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
|
| 334 | +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
|
| 335 | + $param.='&contextpage='.$contextpage; |
|
| 336 | +} |
|
| 337 | +if ($limit > 0 && $limit != $conf->liste_limit) { |
|
| 338 | + $param.='&limit='.$limit; |
|
| 339 | +} |
|
| 296 | 340 | foreach($search as $key => $val) |
| 297 | 341 | { |
| 298 | 342 | $param.= '&search_'.$key.'='.urlencode($search[$key]); |
| 299 | 343 | } |
| 300 | -if ($optioncss != '') $param.='&optioncss='.$optioncss; |
|
| 344 | +if ($optioncss != '') { |
|
| 345 | + $param.='&optioncss='.$optioncss; |
|
| 346 | +} |
|
| 301 | 347 | // Add $param from extra fields |
| 302 | 348 | foreach ($search_array_options as $key => $val) |
| 303 | 349 | { |
| 304 | 350 | $crit=$val; |
| 305 | 351 | $tmpkey=preg_replace('/search_options_/','',$key); |
| 306 | - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); |
|
| 307 | -} |
|
| 352 | + if ($val != '') { |
|
| 353 | + $param.='&search_options_'.$tmpkey.'='.urlencode($val); |
|
| 354 | + } |
|
| 355 | + } |
|
| 308 | 356 | |
| 309 | 357 | $arrayofmassactions = array( |
| 310 | 358 | 'presend'=>$langs->trans("SendByMail"), |
| 311 | 359 | 'builddoc'=>$langs->trans("PDFMerge"), |
| 312 | 360 | ); |
| 313 | -if ($user->rights->inventory->delete) $arrayofmassactions['delete']=$langs->trans("Delete"); |
|
| 314 | -if ($massaction == 'presend') $arrayofmassactions=array(); |
|
| 361 | +if ($user->rights->inventory->delete) { |
|
| 362 | + $arrayofmassactions['delete']=$langs->trans("Delete"); |
|
| 363 | +} |
|
| 364 | +if ($massaction == 'presend') { |
|
| 365 | + $arrayofmassactions=array(); |
|
| 366 | +} |
|
| 315 | 367 | $massactionbutton=$form->selectMassAction('', $arrayofmassactions); |
| 316 | 368 | |
| 317 | 369 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
| 318 | -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 370 | +if ($optioncss != '') { |
|
| 371 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 372 | +} |
|
| 319 | 373 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 320 | 374 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
| 321 | 375 | print '<input type="hidden" name="action" value="list">'; |
@@ -328,7 +382,9 @@ discard block |
||
| 328 | 382 | |
| 329 | 383 | if ($sall) |
| 330 | 384 | { |
| 331 | - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); |
|
| 385 | + foreach($fieldstosearchall as $key => $val) { |
|
| 386 | + $fieldstosearchall[$key]=$langs->trans($val); |
|
| 387 | + } |
|
| 332 | 388 | print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); |
| 333 | 389 | } |
| 334 | 390 | |
@@ -339,8 +395,11 @@ discard block |
||
| 339 | 395 | |
| 340 | 396 | $parameters=array(); |
| 341 | 397 | $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook |
| 342 | -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; |
|
| 343 | -else $moreforfilter = $hookmanager->resPrint; |
|
| 398 | +if (empty($reshook)) { |
|
| 399 | + $moreforfilter .= $hookmanager->resPrint; |
|
| 400 | +} else { |
|
| 401 | + $moreforfilter = $hookmanager->resPrint; |
|
| 402 | +} |
|
| 344 | 403 | |
| 345 | 404 | if (! empty($moreforfilter)) |
| 346 | 405 | { |
@@ -362,12 +421,20 @@ discard block |
||
| 362 | 421 | print '<tr class="liste_titre">'; |
| 363 | 422 | foreach($object->fields as $key => $val) |
| 364 | 423 | { |
| 365 | - if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 424 | + if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) { |
|
| 425 | + continue; |
|
| 426 | + } |
|
| 366 | 427 | $align=''; |
| 367 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 368 | - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; |
|
| 369 | - if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
| 370 | -} |
|
| 428 | + if (in_array($val['type'], array('date','datetime','timestamp'))) { |
|
| 429 | + $align='center'; |
|
| 430 | + } |
|
| 431 | + if (in_array($val['type'], array('timestamp'))) { |
|
| 432 | + $align.=' nowrap'; |
|
| 433 | + } |
|
| 434 | + if (! empty($arrayfields['t.'.$key]['checked'])) { |
|
| 435 | + print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
| 436 | + } |
|
| 437 | + } |
|
| 371 | 438 | // Extra fields |
| 372 | 439 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 373 | 440 | { |
@@ -383,8 +450,12 @@ discard block |
||
| 383 | 450 | $crit=$val; |
| 384 | 451 | $tmpkey=preg_replace('/search_options_/','',$key); |
| 385 | 452 | $searchclass=''; |
| 386 | - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; |
|
| 387 | - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; |
|
| 453 | + if (in_array($typeofextrafield, array('varchar', 'select'))) { |
|
| 454 | + $searchclass='searchstring'; |
|
| 455 | + } |
|
| 456 | + if (in_array($typeofextrafield, array('int', 'double'))) { |
|
| 457 | + $searchclass='searchnum'; |
|
| 458 | + } |
|
| 388 | 459 | print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">'; |
| 389 | 460 | } |
| 390 | 461 | print '</td>'; |
@@ -398,12 +469,20 @@ discard block |
||
| 398 | 469 | // Rest of fields search |
| 399 | 470 | foreach($object->fields as $key => $val) |
| 400 | 471 | { |
| 401 | - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 472 | + if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) { |
|
| 473 | + continue; |
|
| 474 | + } |
|
| 402 | 475 | $align=''; |
| 403 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 404 | - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; |
|
| 405 | - if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
| 406 | -} |
|
| 476 | + if (in_array($val['type'], array('date','datetime','timestamp'))) { |
|
| 477 | + $align='center'; |
|
| 478 | + } |
|
| 479 | + if (in_array($val['type'], array('timestamp'))) { |
|
| 480 | + $align.=' nowrap'; |
|
| 481 | + } |
|
| 482 | + if (! empty($arrayfields['t.'.$key]['checked'])) { |
|
| 483 | + print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; |
|
| 484 | + } |
|
| 485 | + } |
|
| 407 | 486 | // Action column |
| 408 | 487 | print '<td class="liste_titre" align="right">'; |
| 409 | 488 | $searchpicto=$form->showFilterButtons(); |
@@ -417,12 +496,20 @@ discard block |
||
| 417 | 496 | print '<tr class="liste_titre">'; |
| 418 | 497 | foreach($object->fields as $key => $val) |
| 419 | 498 | { |
| 420 | - if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 499 | + if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) { |
|
| 500 | + continue; |
|
| 501 | + } |
|
| 421 | 502 | $align=''; |
| 422 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 423 | - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; |
|
| 424 | - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
| 425 | -} |
|
| 503 | + if (in_array($val['type'], array('date','datetime','timestamp'))) { |
|
| 504 | + $align='center'; |
|
| 505 | + } |
|
| 506 | + if (in_array($val['type'], array('timestamp'))) { |
|
| 507 | + $align.='nowrap'; |
|
| 508 | + } |
|
| 509 | + if (! empty($arrayfields['t.'.$key]['checked'])) { |
|
| 510 | + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
| 511 | + } |
|
| 512 | + } |
|
| 426 | 513 | // Extra fields |
| 427 | 514 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 428 | 515 | { |
@@ -432,7 +519,9 @@ discard block |
||
| 432 | 519 | { |
| 433 | 520 | $align=$extrafields->getAlignFlag($key); |
| 434 | 521 | $sortonfield = "ef.".$key; |
| 435 | - if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; |
|
| 522 | + if (! empty($extrafields->attribute_computed[$key])) { |
|
| 523 | + $sortonfield=''; |
|
| 524 | + } |
|
| 436 | 525 | print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; |
| 437 | 526 | } |
| 438 | 527 | } |
@@ -444,12 +533,20 @@ discard block |
||
| 444 | 533 | // Rest of fields title |
| 445 | 534 | foreach($object->fields as $key => $val) |
| 446 | 535 | { |
| 447 | - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 536 | + if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) { |
|
| 537 | + continue; |
|
| 538 | + } |
|
| 448 | 539 | $align=''; |
| 449 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 450 | - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; |
|
| 451 | - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
| 452 | -} |
|
| 540 | + if (in_array($val['type'], array('date','datetime','timestamp'))) { |
|
| 541 | + $align='center'; |
|
| 542 | + } |
|
| 543 | + if (in_array($val['type'], array('timestamp'))) { |
|
| 544 | + $align.=' nowrap'; |
|
| 545 | + } |
|
| 546 | + if (! empty($arrayfields['t.'.$key]['checked'])) { |
|
| 547 | + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; |
|
| 548 | + } |
|
| 549 | + } |
|
| 453 | 550 | print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; |
| 454 | 551 | print '</tr>'."\n"; |
| 455 | 552 | |
@@ -458,7 +555,10 @@ discard block |
||
| 458 | 555 | $needToFetchEachLine=0; |
| 459 | 556 | foreach ($extrafields->attribute_computed as $key => $val) |
| 460 | 557 | { |
| 461 | - if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object |
|
| 558 | + if (preg_match('/\$object/',$val)) { |
|
| 559 | + $needToFetchEachLine++; |
|
| 560 | + } |
|
| 561 | + // There is at least one compute field that use $object |
|
| 462 | 562 | } |
| 463 | 563 | |
| 464 | 564 | |
@@ -475,30 +575,49 @@ discard block |
||
| 475 | 575 | $object->id = $obj->rowid; |
| 476 | 576 | foreach($object->fields as $key => $val) |
| 477 | 577 | { |
| 478 | - if (isset($obj->$key)) $object->$key = $obj->$key; |
|
| 578 | + if (isset($obj->$key)) { |
|
| 579 | + $object->$key = $obj->$key; |
|
| 580 | + } |
|
| 479 | 581 | } |
| 480 | 582 | |
| 481 | 583 | // Show here line of result |
| 482 | 584 | print '<tr class="oddeven">'; |
| 483 | 585 | foreach($object->fields as $key => $val) |
| 484 | 586 | { |
| 485 | - if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 587 | + if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) { |
|
| 588 | + continue; |
|
| 589 | + } |
|
| 486 | 590 | $align=''; |
| 487 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; |
|
| 488 | - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; |
|
| 489 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
| 591 | + if (in_array($val['type'], array('date','datetime','timestamp'))) { |
|
| 592 | + $align='center'; |
|
| 593 | + } |
|
| 594 | + if (in_array($val['type'], array('timestamp'))) { |
|
| 595 | + $align.='nowrap'; |
|
| 596 | + } |
|
| 597 | + if ($key == 'status') { |
|
| 598 | + $align.=($align?' ':'').'center'; |
|
| 599 | + } |
|
| 490 | 600 | if (! empty($arrayfields['t.'.$key]['checked'])) |
| 491 | 601 | { |
| 492 | 602 | print '<td'.($align?' class="'.$align.'"':'').'>'; |
| 493 | - if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); |
|
| 494 | - elseif ($key == 'ref') print $object->getNomUrl(1); |
|
| 495 | - elseif ($key == 'status') print $object->getLibStatut(3); |
|
| 496 | - else print $obj->$key; |
|
| 603 | + if (in_array($val['type'], array('date','datetime','timestamp'))) { |
|
| 604 | + print dol_print_date($db->jdate($obj->$key), 'dayhour'); |
|
| 605 | + } elseif ($key == 'ref') { |
|
| 606 | + print $object->getNomUrl(1); |
|
| 607 | + } elseif ($key == 'status') { |
|
| 608 | + print $object->getLibStatut(3); |
|
| 609 | + } else { |
|
| 610 | + print $obj->$key; |
|
| 611 | + } |
|
| 497 | 612 | print '</td>'; |
| 498 | - if (! $i) $totalarray['nbfield']++; |
|
| 613 | + if (! $i) { |
|
| 614 | + $totalarray['nbfield']++; |
|
| 615 | + } |
|
| 499 | 616 | if (! empty($val['isameasure'])) |
| 500 | 617 | { |
| 501 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
| 618 | + if (! $i) { |
|
| 619 | + $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
| 620 | + } |
|
| 502 | 621 | $totalarray['val']['t.'.$key] += $obj->$key; |
| 503 | 622 | } |
| 504 | 623 | } |
@@ -512,15 +631,21 @@ discard block |
||
| 512 | 631 | { |
| 513 | 632 | print '<td'; |
| 514 | 633 | $align=$extrafields->getAlignFlag($key); |
| 515 | - if ($align) print ' align="'.$align.'"'; |
|
| 634 | + if ($align) { |
|
| 635 | + print ' align="'.$align.'"'; |
|
| 636 | + } |
|
| 516 | 637 | print '>'; |
| 517 | 638 | $tmpkey='options_'.$key; |
| 518 | 639 | print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); |
| 519 | 640 | print '</td>'; |
| 520 | - if (! $i) $totalarray['nbfield']++; |
|
| 641 | + if (! $i) { |
|
| 642 | + $totalarray['nbfield']++; |
|
| 643 | + } |
|
| 521 | 644 | if (! empty($val['isameasure'])) |
| 522 | 645 | { |
| 523 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey; |
|
| 646 | + if (! $i) { |
|
| 647 | + $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey; |
|
| 648 | + } |
|
| 524 | 649 | $totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey; |
| 525 | 650 | } |
| 526 | 651 | } |
@@ -533,36 +658,58 @@ discard block |
||
| 533 | 658 | // Rest of fields |
| 534 | 659 | foreach($object->fields as $key => $val) |
| 535 | 660 | { |
| 536 | - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; |
|
| 661 | + if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) { |
|
| 662 | + continue; |
|
| 663 | + } |
|
| 537 | 664 | $align=''; |
| 538 | - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; |
|
| 539 | - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; |
|
| 540 | - if ($key == 'status') $align.=($align?' ':'').'center'; |
|
| 665 | + if (in_array($val['type'], array('date','datetime','timestamp'))) { |
|
| 666 | + $align.=($align?' ':'').'center'; |
|
| 667 | + } |
|
| 668 | + if (in_array($val['type'], array('timestamp'))) { |
|
| 669 | + $align.=($align?' ':'').'nowrap'; |
|
| 670 | + } |
|
| 671 | + if ($key == 'status') { |
|
| 672 | + $align.=($align?' ':'').'center'; |
|
| 673 | + } |
|
| 541 | 674 | if (! empty($arrayfields['t.'.$key]['checked'])) |
| 542 | 675 | { |
| 543 | 676 | print '<td'.($align?' class="'.$align.'"':'').'>'; |
| 544 | - if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); |
|
| 545 | - elseif ($key == 'status') print $object->getLibStatut(3); |
|
| 546 | - else print $obj->$key; |
|
| 677 | + if (in_array($val['type'], array('date','datetime','timestamp'))) { |
|
| 678 | + print dol_print_date($db->jdate($obj->$key), 'dayhour'); |
|
| 679 | + } elseif ($key == 'status') { |
|
| 680 | + print $object->getLibStatut(3); |
|
| 681 | + } else { |
|
| 682 | + print $obj->$key; |
|
| 683 | + } |
|
| 547 | 684 | print '</td>'; |
| 548 | - if (! $i) $totalarray['nbfield']++; |
|
| 685 | + if (! $i) { |
|
| 686 | + $totalarray['nbfield']++; |
|
| 687 | + } |
|
| 549 | 688 | if (! empty($val['isameasure'])) |
| 550 | 689 | { |
| 551 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
| 690 | + if (! $i) { |
|
| 691 | + $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; |
|
| 692 | + } |
|
| 552 | 693 | $totalarray['val']['t.'.$key] += $obj->$key; |
| 553 | 694 | } |
| 554 | 695 | } |
| 555 | 696 | } |
| 556 | 697 | // Action column |
| 557 | 698 | print '<td class="nowrap" align="center">'; |
| 558 | - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
| 699 | + if ($massactionbutton || $massaction) { |
|
| 700 | + // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
| 559 | 701 | { |
| 560 | 702 | $selected=0; |
| 561 | - if (in_array($obj->rowid, $arrayofselected)) $selected=1; |
|
| 703 | + } |
|
| 704 | + if (in_array($obj->rowid, $arrayofselected)) { |
|
| 705 | + $selected=1; |
|
| 706 | + } |
|
| 562 | 707 | print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; |
| 563 | 708 | } |
| 564 | 709 | print '</td>'; |
| 565 | - if (! $i) $totalarray['nbfield']++; |
|
| 710 | + if (! $i) { |
|
| 711 | + $totalarray['nbfield']++; |
|
| 712 | + } |
|
| 566 | 713 | |
| 567 | 714 | print '</tr>'; |
| 568 | 715 | } |
@@ -577,13 +724,17 @@ discard block |
||
| 577 | 724 | while ($i < $totalarray['nbfield']) |
| 578 | 725 | { |
| 579 | 726 | $i++; |
| 580 | - if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
| 581 | - else |
|
| 727 | + if (! empty($totalarray['pos'][$i])) { |
|
| 728 | + print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
| 729 | + } else |
|
| 582 | 730 | { |
| 583 | 731 | if ($i == 1) |
| 584 | 732 | { |
| 585 | - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
| 586 | - else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
| 733 | + if ($num < $limit) { |
|
| 734 | + print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
| 735 | + } else { |
|
| 736 | + print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
| 737 | + } |
|
| 587 | 738 | } |
| 588 | 739 | print '<td></td>'; |
| 589 | 740 | } |
@@ -595,7 +746,10 @@ discard block |
||
| 595 | 746 | if ($num == 0) |
| 596 | 747 | { |
| 597 | 748 | $colspan=1; |
| 598 | - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } |
|
| 749 | + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) { |
|
| 750 | + $colspan++; |
|
| 751 | + } |
|
| 752 | + } |
|
| 599 | 753 | print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
| 600 | 754 | } |
| 601 | 755 | |
@@ -627,8 +781,7 @@ discard block |
||
| 627 | 781 | $delallowed=$user->rights->inventory->read; |
| 628 | 782 | |
| 629 | 783 | print $formfile->showdocuments('massfilesarea_inventory','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); |
| 630 | - } |
|
| 631 | - else |
|
| 784 | + } else |
|
| 632 | 785 | { |
| 633 | 786 | print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>'; |
| 634 | 787 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $search=array(); |
| 79 | 79 | foreach($object->fields as $key => $val) |
| 80 | 80 | { |
| 81 | - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
| 81 | + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | if (empty($action) && empty($id) && empty($ref)) $action='view'; |
@@ -127,17 +127,17 @@ discard block |
||
| 127 | 127 | // Action to add record |
| 128 | 128 | if ($action == 'add' && ! empty($user->rights->inventory->create)) |
| 129 | 129 | { |
| 130 | - foreach ($object->fields as $key => $val) |
|
| 131 | - { |
|
| 132 | - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; // Ignore special fields |
|
| 133 | - |
|
| 134 | - $object->$key=GETPOST($key,'alpha'); |
|
| 135 | - if ($val['notnull'] && $object->$key == '') |
|
| 136 | - { |
|
| 137 | - $error++; |
|
| 138 | - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); |
|
| 139 | - } |
|
| 140 | - } |
|
| 130 | + foreach ($object->fields as $key => $val) |
|
| 131 | + { |
|
| 132 | + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; // Ignore special fields |
|
| 133 | + |
|
| 134 | + $object->$key=GETPOST($key,'alpha'); |
|
| 135 | + if ($val['notnull'] && $object->$key == '') |
|
| 136 | + { |
|
| 137 | + $error++; |
|
| 138 | + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | 142 | if (! $error) |
| 143 | 143 | { |
@@ -166,16 +166,16 @@ discard block |
||
| 166 | 166 | // Action to update record |
| 167 | 167 | if ($action == 'update' && ! empty($user->rights->inventory->create)) |
| 168 | 168 | { |
| 169 | - foreach ($object->fields as $key => $val) |
|
| 170 | - { |
|
| 171 | - $object->$key=GETPOST($key,'alpha'); |
|
| 172 | - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; |
|
| 173 | - if ($val['notnull'] && $object->$key == '') |
|
| 174 | - { |
|
| 175 | - $error++; |
|
| 176 | - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); |
|
| 177 | - } |
|
| 178 | - } |
|
| 169 | + foreach ($object->fields as $key => $val) |
|
| 170 | + { |
|
| 171 | + $object->$key=GETPOST($key,'alpha'); |
|
| 172 | + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; |
|
| 173 | + if ($val['notnull'] && $object->$key == '') |
|
| 174 | + { |
|
| 175 | + $error++; |
|
| 176 | + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | 180 | if (! $error) |
| 181 | 181 | { |
@@ -261,12 +261,12 @@ discard block |
||
| 261 | 261 | print '<table class="border centpercent">'."\n"; |
| 262 | 262 | foreach($object->fields as $key => $val) |
| 263 | 263 | { |
| 264 | - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; |
|
| 265 | - print '<tr><td'; |
|
| 266 | - print ' class="titlefieldcreate'; |
|
| 267 | - if ($val['notnull']) print ' fieldrequired'; |
|
| 268 | - print '"'; |
|
| 269 | - print '>'.$langs->trans($val['label']).'</td><td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td></tr>'; |
|
| 264 | + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; |
|
| 265 | + print '<tr><td'; |
|
| 266 | + print ' class="titlefieldcreate'; |
|
| 267 | + if ($val['notnull']) print ' fieldrequired'; |
|
| 268 | + print '"'; |
|
| 269 | + print '>'.$langs->trans($val['label']).'</td><td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td></tr>'; |
|
| 270 | 270 | } |
| 271 | 271 | print '</table>'."\n"; |
| 272 | 272 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | // Part to show record |
| 311 | 311 | if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) |
| 312 | 312 | { |
| 313 | - $res = $object->fetch_optionals($object->id, $extralabels); |
|
| 313 | + $res = $object->fetch_optionals($object->id, $extralabels); |
|
| 314 | 314 | |
| 315 | 315 | $head = inventory_prepare_head($object); |
| 316 | 316 | dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), -1, 'order'); |
@@ -319,28 +319,28 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | // Confirmation to delete |
| 321 | 321 | if ($action == 'delete') { |
| 322 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); |
|
| 322 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | // Confirmation of action xxxx |
| 326 | 326 | if ($action == 'xxx') |
| 327 | 327 | { |
| 328 | - $formquestion=array(); |
|
| 329 | - /* |
|
| 328 | + $formquestion=array(); |
|
| 329 | + /* |
|
| 330 | 330 | $formquestion = array( |
| 331 | 331 | // 'text' => $langs->trans("ConfirmClone"), |
| 332 | 332 | // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), |
| 333 | 333 | // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), |
| 334 | 334 | // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); |
| 335 | 335 | }*/ |
| 336 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); |
|
| 336 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | if (! $formconfirm) { |
| 340 | - $parameters = array('lineid' => $lineid); |
|
| 341 | - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
| 342 | - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; |
|
| 343 | - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; |
|
| 340 | + $parameters = array('lineid' => $lineid); |
|
| 341 | + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
| 342 | + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; |
|
| 343 | + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | // Print form confirm |
@@ -434,69 +434,69 @@ discard block |
||
| 434 | 434 | |
| 435 | 435 | // Buttons for actions |
| 436 | 436 | if ($action != 'presend' && $action != 'editline') { |
| 437 | - print '<div class="tabsAction">'."\n"; |
|
| 438 | - $parameters=array(); |
|
| 439 | - $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 440 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 441 | - |
|
| 442 | - if (empty($reshook)) |
|
| 443 | - { |
|
| 444 | - // Send |
|
| 445 | - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendByMail') . '</a></div>'."\n"; |
|
| 446 | - |
|
| 447 | - if ($user->rights->inventory->write) |
|
| 448 | - { |
|
| 449 | - print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a></div>'."\n"; |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - if ($user->rights->inventory->delete) |
|
| 453 | - { |
|
| 454 | - print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>'."\n"; |
|
| 455 | - } |
|
| 456 | - } |
|
| 457 | - print '</div>'."\n"; |
|
| 437 | + print '<div class="tabsAction">'."\n"; |
|
| 438 | + $parameters=array(); |
|
| 439 | + $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 440 | + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 441 | + |
|
| 442 | + if (empty($reshook)) |
|
| 443 | + { |
|
| 444 | + // Send |
|
| 445 | + print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendByMail') . '</a></div>'."\n"; |
|
| 446 | + |
|
| 447 | + if ($user->rights->inventory->write) |
|
| 448 | + { |
|
| 449 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a></div>'."\n"; |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + if ($user->rights->inventory->delete) |
|
| 453 | + { |
|
| 454 | + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>'."\n"; |
|
| 455 | + } |
|
| 456 | + } |
|
| 457 | + print '</div>'."\n"; |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | |
| 461 | 461 | // Select mail models is same action as presend |
| 462 | 462 | if (GETPOST('modelselected')) { |
| 463 | - $action = 'presend'; |
|
| 463 | + $action = 'presend'; |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | if ($action != 'presend') |
| 467 | 467 | { |
| 468 | - print '<div class="fichecenter"><div class="fichehalfleft">'; |
|
| 469 | - print '<a name="builddoc"></a>'; // ancre |
|
| 470 | - // Documents |
|
| 471 | - $comref = dol_sanitizeFileName($object->ref); |
|
| 472 | - $relativepath = $comref . '/' . $comref . '.pdf'; |
|
| 473 | - $filedir = $conf->inventory->dir_output . '/' . $comref; |
|
| 474 | - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; |
|
| 475 | - $genallowed = $user->rights->inventory->creer; |
|
| 476 | - $delallowed = $user->rights->inventory->supprimer; |
|
| 477 | - print $formfile->showdocuments('inventory', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); |
|
| 468 | + print '<div class="fichecenter"><div class="fichehalfleft">'; |
|
| 469 | + print '<a name="builddoc"></a>'; // ancre |
|
| 470 | + // Documents |
|
| 471 | + $comref = dol_sanitizeFileName($object->ref); |
|
| 472 | + $relativepath = $comref . '/' . $comref . '.pdf'; |
|
| 473 | + $filedir = $conf->inventory->dir_output . '/' . $comref; |
|
| 474 | + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; |
|
| 475 | + $genallowed = $user->rights->inventory->creer; |
|
| 476 | + $delallowed = $user->rights->inventory->supprimer; |
|
| 477 | + print $formfile->showdocuments('inventory', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); |
|
| 478 | 478 | |
| 479 | 479 | |
| 480 | - // Show links to link elements |
|
| 481 | - $linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); |
|
| 482 | - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); |
|
| 480 | + // Show links to link elements |
|
| 481 | + $linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); |
|
| 482 | + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); |
|
| 483 | 483 | |
| 484 | 484 | |
| 485 | - print '</div><div class="fichehalfright"><div class="ficheaddleft">'; |
|
| 485 | + print '</div><div class="fichehalfright"><div class="ficheaddleft">'; |
|
| 486 | 486 | |
| 487 | - // List of actions on element |
|
| 488 | - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; |
|
| 489 | - $formactions = new FormActions($db); |
|
| 490 | - $somethingshown = $formactions->showactions($object, 'order', $socid); |
|
| 487 | + // List of actions on element |
|
| 488 | + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; |
|
| 489 | + $formactions = new FormActions($db); |
|
| 490 | + $somethingshown = $formactions->showactions($object, 'order', $socid); |
|
| 491 | 491 | |
| 492 | - print '</div></div></div>'; |
|
| 492 | + print '</div></div></div>'; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | |
| 496 | 496 | /* |
| 497 | 497 | * Action presend |
| 498 | 498 | */ |
| 499 | - /* |
|
| 499 | + /* |
|
| 500 | 500 | if ($action == 'presend') |
| 501 | 501 | { |
| 502 | 502 | $object->fetch_projet(); |
@@ -38,50 +38,50 @@ discard block |
||
| 38 | 38 | //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
| 39 | 39 | |
| 40 | 40 | // Load Dolibarr environment |
| 41 | -$res=0; |
|
| 41 | +$res = 0; |
|
| 42 | 42 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) |
| 43 | -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); |
|
| 43 | +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); |
|
| 44 | 44 | // Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME |
| 45 | -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; |
|
| 46 | -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } |
|
| 47 | -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); |
|
| 48 | -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); |
|
| 45 | +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; |
|
| 46 | +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } |
|
| 47 | +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include(substr($tmp, 0, ($i + 1))."/main.inc.php"); |
|
| 48 | +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"); |
|
| 49 | 49 | // Try main.inc.php using relative path |
| 50 | -if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); |
|
| 51 | -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); |
|
| 52 | -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); |
|
| 53 | -if (! $res) die("Include of main fails"); |
|
| 50 | +if (!$res && file_exists("../main.inc.php")) $res = @include("../main.inc.php"); |
|
| 51 | +if (!$res && file_exists("../../main.inc.php")) $res = @include("../../main.inc.php"); |
|
| 52 | +if (!$res && file_exists("../../../main.inc.php")) $res = @include("../../../main.inc.php"); |
|
| 53 | +if (!$res) die("Include of main fails"); |
|
| 54 | 54 | |
| 55 | 55 | include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); |
| 56 | 56 | dol_include_once('/inventory/class/inventory.class.php'); |
| 57 | 57 | |
| 58 | 58 | // Load traductions files requiredby by page |
| 59 | -$langs->loadLangs(array("inventory","other")); |
|
| 59 | +$langs->loadLangs(array("inventory", "other")); |
|
| 60 | 60 | |
| 61 | 61 | // Get parameters |
| 62 | -$id = GETPOST('id', 'int'); |
|
| 63 | -$action = GETPOST('action', 'alpha'); |
|
| 62 | +$id = GETPOST('id', 'int'); |
|
| 63 | +$action = GETPOST('action', 'alpha'); |
|
| 64 | 64 | $cancel = GETPOST('cancel', 'aZ09'); |
| 65 | 65 | $backtopage = GETPOST('backtopage', 'alpha'); |
| 66 | 66 | |
| 67 | 67 | // Initialize technical objects |
| 68 | -$object=new Inventory($db); |
|
| 68 | +$object = new Inventory($db); |
|
| 69 | 69 | $extrafields = new ExtraFields($db); |
| 70 | -$diroutputmassaction=$conf->inventory->dir_output . '/temp/massgeneration/'.$user->id; |
|
| 71 | -$hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array |
|
| 70 | +$diroutputmassaction = $conf->inventory->dir_output.'/temp/massgeneration/'.$user->id; |
|
| 71 | +$hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array |
|
| 72 | 72 | // Fetch optionals attributes and labels |
| 73 | 73 | $extralabels = $extrafields->fetch_name_optionals_label('inventory'); |
| 74 | -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); |
|
| 74 | +$search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_'); |
|
| 75 | 75 | |
| 76 | 76 | // Initialize array of search criterias |
| 77 | -$search_all=trim(GETPOST("search_all",'alpha')); |
|
| 78 | -$search=array(); |
|
| 79 | -foreach($object->fields as $key => $val) |
|
| 77 | +$search_all = trim(GETPOST("search_all", 'alpha')); |
|
| 78 | +$search = array(); |
|
| 79 | +foreach ($object->fields as $key => $val) |
|
| 80 | 80 | { |
| 81 | - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
| 81 | + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | -if (empty($action) && empty($id) && empty($ref)) $action='view'; |
|
| 84 | +if (empty($action) && empty($id) && empty($ref)) $action = 'view'; |
|
| 85 | 85 | |
| 86 | 86 | // Protection if external user |
| 87 | 87 | if ($user->societe_id > 0) |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
| 95 | 95 | |
| 96 | 96 | // Load object |
| 97 | -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals |
|
| 97 | +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals |
|
| 98 | 98 | |
| 99 | 99 | |
| 100 | 100 | |
@@ -104,114 +104,114 @@ discard block |
||
| 104 | 104 | * Put here all code to do according to value of "action" parameter |
| 105 | 105 | */ |
| 106 | 106 | |
| 107 | -$parameters=array(); |
|
| 108 | -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 107 | +$parameters = array(); |
|
| 108 | +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
| 109 | 109 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
| 110 | 110 | |
| 111 | 111 | if (empty($reshook)) |
| 112 | 112 | { |
| 113 | - $error=0; |
|
| 113 | + $error = 0; |
|
| 114 | 114 | |
| 115 | 115 | if ($cancel) |
| 116 | 116 | { |
| 117 | 117 | if ($action != 'addlink') |
| 118 | 118 | { |
| 119 | - $urltogo=$backtopage?$backtopage:dol_buildpath('/inventory/inventory_list.php',1); |
|
| 119 | + $urltogo = $backtopage ? $backtopage : dol_buildpath('/inventory/inventory_list.php', 1); |
|
| 120 | 120 | header("Location: ".$urltogo); |
| 121 | 121 | exit; |
| 122 | 122 | } |
| 123 | - if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); |
|
| 124 | - $action=''; |
|
| 123 | + if ($id > 0 || !empty($ref)) $ret = $object->fetch($id, $ref); |
|
| 124 | + $action = ''; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // Action to add record |
| 128 | - if ($action == 'add' && ! empty($user->rights->inventory->create)) |
|
| 128 | + if ($action == 'add' && !empty($user->rights->inventory->create)) |
|
| 129 | 129 | { |
| 130 | 130 | foreach ($object->fields as $key => $val) |
| 131 | 131 | { |
| 132 | - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; // Ignore special fields |
|
| 132 | + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; // Ignore special fields |
|
| 133 | 133 | |
| 134 | - $object->$key=GETPOST($key,'alpha'); |
|
| 134 | + $object->$key = GETPOST($key, 'alpha'); |
|
| 135 | 135 | if ($val['notnull'] && $object->$key == '') |
| 136 | 136 | { |
| 137 | 137 | $error++; |
| 138 | - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); |
|
| 138 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors'); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - if (! $error) |
|
| 142 | + if (!$error) |
|
| 143 | 143 | { |
| 144 | - $result=$object->createCommon($user); |
|
| 144 | + $result = $object->createCommon($user); |
|
| 145 | 145 | if ($result > 0) |
| 146 | 146 | { |
| 147 | 147 | // Creation OK |
| 148 | - $urltogo=$backtopage?$backtopage:dol_buildpath('/inventory/inventory_list.php',1); |
|
| 148 | + $urltogo = $backtopage ? $backtopage : dol_buildpath('/inventory/inventory_list.php', 1); |
|
| 149 | 149 | header("Location: ".$urltogo); |
| 150 | 150 | exit; |
| 151 | 151 | } |
| 152 | 152 | else |
| 153 | 153 | { |
| 154 | 154 | // Creation KO |
| 155 | - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); |
|
| 155 | + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); |
|
| 156 | 156 | else setEventMessages($object->error, null, 'errors'); |
| 157 | - $action='create'; |
|
| 157 | + $action = 'create'; |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | else |
| 161 | 161 | { |
| 162 | - $action='create'; |
|
| 162 | + $action = 'create'; |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // Action to update record |
| 167 | - if ($action == 'update' && ! empty($user->rights->inventory->create)) |
|
| 167 | + if ($action == 'update' && !empty($user->rights->inventory->create)) |
|
| 168 | 168 | { |
| 169 | 169 | foreach ($object->fields as $key => $val) |
| 170 | 170 | { |
| 171 | - $object->$key=GETPOST($key,'alpha'); |
|
| 171 | + $object->$key = GETPOST($key, 'alpha'); |
|
| 172 | 172 | if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; |
| 173 | 173 | if ($val['notnull'] && $object->$key == '') |
| 174 | 174 | { |
| 175 | 175 | $error++; |
| 176 | - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); |
|
| 176 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors'); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if (! $error) |
|
| 180 | + if (!$error) |
|
| 181 | 181 | { |
| 182 | - $result=$object->updateCommon($user); |
|
| 182 | + $result = $object->updateCommon($user); |
|
| 183 | 183 | if ($result > 0) |
| 184 | 184 | { |
| 185 | - $action='view'; |
|
| 185 | + $action = 'view'; |
|
| 186 | 186 | } |
| 187 | 187 | else |
| 188 | 188 | { |
| 189 | 189 | // Creation KO |
| 190 | - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); |
|
| 190 | + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); |
|
| 191 | 191 | else setEventMessages($object->error, null, 'errors'); |
| 192 | - $action='edit'; |
|
| 192 | + $action = 'edit'; |
|
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | else |
| 196 | 196 | { |
| 197 | - $action='edit'; |
|
| 197 | + $action = 'edit'; |
|
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | // Action to delete |
| 202 | - if ($action == 'confirm_delete' && ! empty($user->rights->inventory->delete)) |
|
| 202 | + if ($action == 'confirm_delete' && !empty($user->rights->inventory->delete)) |
|
| 203 | 203 | { |
| 204 | - $result=$object->deleteCommon($user); |
|
| 204 | + $result = $object->deleteCommon($user); |
|
| 205 | 205 | if ($result > 0) |
| 206 | 206 | { |
| 207 | 207 | // Delete OK |
| 208 | 208 | setEventMessages("RecordDeleted", null, 'mesgs'); |
| 209 | - header("Location: ".dol_buildpath('/inventory/inventory_list.php',1)); |
|
| 209 | + header("Location: ".dol_buildpath('/inventory/inventory_list.php', 1)); |
|
| 210 | 210 | exit; |
| 211 | 211 | } |
| 212 | 212 | else |
| 213 | 213 | { |
| 214 | - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); |
|
| 214 | + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); |
|
| 215 | 215 | else setEventMessages($object->error, null, 'errors'); |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -226,9 +226,9 @@ discard block |
||
| 226 | 226 | * Put here all code to build page |
| 227 | 227 | */ |
| 228 | 228 | |
| 229 | -$form=new Form($db); |
|
| 229 | +$form = new Form($db); |
|
| 230 | 230 | |
| 231 | -llxHeader('','Inventory',''); |
|
| 231 | +llxHeader('', 'Inventory', ''); |
|
| 232 | 232 | |
| 233 | 233 | // Example : Adding jquery code |
| 234 | 234 | print '<script type="text/javascript" language="javascript"> |
@@ -259,14 +259,14 @@ discard block |
||
| 259 | 259 | dol_fiche_head(array(), ''); |
| 260 | 260 | |
| 261 | 261 | print '<table class="border centpercent">'."\n"; |
| 262 | - foreach($object->fields as $key => $val) |
|
| 262 | + foreach ($object->fields as $key => $val) |
|
| 263 | 263 | { |
| 264 | 264 | if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; |
| 265 | 265 | print '<tr><td'; |
| 266 | 266 | print ' class="titlefieldcreate'; |
| 267 | 267 | if ($val['notnull']) print ' fieldrequired'; |
| 268 | 268 | print '"'; |
| 269 | - print '>'.$langs->trans($val['label']).'</td><td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td></tr>'; |
|
| 269 | + print '>'.$langs->trans($val['label']).'</td><td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key, 'alpha') ? GETPOST($key, 'alpha') : '').'"></td></tr>'; |
|
| 270 | 270 | } |
| 271 | 271 | print '</table>'."\n"; |
| 272 | 272 | |
@@ -319,13 +319,13 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | // Confirmation to delete |
| 321 | 321 | if ($action == 'delete') { |
| 322 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); |
|
| 322 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | // Confirmation of action xxxx |
| 326 | 326 | if ($action == 'xxx') |
| 327 | 327 | { |
| 328 | - $formquestion=array(); |
|
| 328 | + $formquestion = array(); |
|
| 329 | 329 | /* |
| 330 | 330 | $formquestion = array( |
| 331 | 331 | // 'text' => $langs->trans("ConfirmClone"), |
@@ -333,14 +333,14 @@ discard block |
||
| 333 | 333 | // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), |
| 334 | 334 | // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); |
| 335 | 335 | }*/ |
| 336 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); |
|
| 336 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - if (! $formconfirm) { |
|
| 339 | + if (!$formconfirm) { |
|
| 340 | 340 | $parameters = array('lineid' => $lineid); |
| 341 | 341 | $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
| 342 | - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; |
|
| 343 | - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; |
|
| 342 | + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; |
|
| 343 | + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | // Print form confirm |
@@ -351,10 +351,10 @@ discard block |
||
| 351 | 351 | // Object card |
| 352 | 352 | // ------------------------------------------------------------ |
| 353 | 353 | |
| 354 | - $linkback = '<a href="' . DOL_URL_ROOT . '/inventory/inventory_list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
| 354 | + $linkback = '<a href="'.DOL_URL_ROOT.'/inventory/inventory_list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; |
|
| 355 | 355 | |
| 356 | 356 | |
| 357 | - $morehtmlref='<div class="refidno">'; |
|
| 357 | + $morehtmlref = '<div class="refidno">'; |
|
| 358 | 358 | /* |
| 359 | 359 | // Ref bis |
| 360 | 360 | $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->inventory->creer, 'string', '', 0, 1); |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | 398 | */ |
| 399 | - $morehtmlref.='</div>'; |
|
| 399 | + $morehtmlref .= '</div>'; |
|
| 400 | 400 | |
| 401 | 401 | |
| 402 | 402 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | |
| 412 | 412 | |
| 413 | 413 | // Other attributes |
| 414 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
| 414 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; |
|
| 415 | 415 | |
| 416 | 416 | print '</table>'; |
| 417 | 417 | print '</div>'; |
@@ -435,14 +435,14 @@ discard block |
||
| 435 | 435 | // Buttons for actions |
| 436 | 436 | if ($action != 'presend' && $action != 'editline') { |
| 437 | 437 | print '<div class="tabsAction">'."\n"; |
| 438 | - $parameters=array(); |
|
| 439 | - $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 438 | + $parameters = array(); |
|
| 439 | + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
| 440 | 440 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
| 441 | 441 | |
| 442 | 442 | if (empty($reshook)) |
| 443 | 443 | { |
| 444 | 444 | // Send |
| 445 | - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendByMail') . '</a></div>'."\n"; |
|
| 445 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendByMail').'</a></div>'."\n"; |
|
| 446 | 446 | |
| 447 | 447 | if ($user->rights->inventory->write) |
| 448 | 448 | { |
@@ -469,9 +469,9 @@ discard block |
||
| 469 | 469 | print '<a name="builddoc"></a>'; // ancre |
| 470 | 470 | // Documents |
| 471 | 471 | $comref = dol_sanitizeFileName($object->ref); |
| 472 | - $relativepath = $comref . '/' . $comref . '.pdf'; |
|
| 473 | - $filedir = $conf->inventory->dir_output . '/' . $comref; |
|
| 474 | - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; |
|
| 472 | + $relativepath = $comref.'/'.$comref.'.pdf'; |
|
| 473 | + $filedir = $conf->inventory->dir_output.'/'.$comref; |
|
| 474 | + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; |
|
| 475 | 475 | $genallowed = $user->rights->inventory->creer; |
| 476 | 476 | $delallowed = $user->rights->inventory->supprimer; |
| 477 | 477 | print $formfile->showdocuments('inventory', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | print '</div><div class="fichehalfright"><div class="ficheaddleft">'; |
| 486 | 486 | |
| 487 | 487 | // List of actions on element |
| 488 | - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; |
|
| 488 | + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; |
|
| 489 | 489 | $formactions = new FormActions($db); |
| 490 | 490 | $somethingshown = $formactions->showactions($object, 'order', $socid); |
| 491 | 491 | |
@@ -40,17 +40,31 @@ discard block |
||
| 40 | 40 | // Load Dolibarr environment |
| 41 | 41 | $res=0; |
| 42 | 42 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) |
| 43 | -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); |
|
| 43 | +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { |
|
| 44 | + $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); |
|
| 45 | +} |
|
| 44 | 46 | // Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME |
| 45 | 47 | $tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; |
| 46 | 48 | while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } |
| 47 | -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); |
|
| 48 | -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); |
|
| 49 | +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) { |
|
| 50 | + $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); |
|
| 51 | +} |
|
| 52 | +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) { |
|
| 53 | + $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); |
|
| 54 | +} |
|
| 49 | 55 | // Try main.inc.php using relative path |
| 50 | -if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); |
|
| 51 | -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); |
|
| 52 | -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); |
|
| 53 | -if (! $res) die("Include of main fails"); |
|
| 56 | +if (! $res && file_exists("../main.inc.php")) { |
|
| 57 | + $res=@include("../main.inc.php"); |
|
| 58 | +} |
|
| 59 | +if (! $res && file_exists("../../main.inc.php")) { |
|
| 60 | + $res=@include("../../main.inc.php"); |
|
| 61 | +} |
|
| 62 | +if (! $res && file_exists("../../../main.inc.php")) { |
|
| 63 | + $res=@include("../../../main.inc.php"); |
|
| 64 | +} |
|
| 65 | +if (! $res) { |
|
| 66 | + die("Include of main fails"); |
|
| 67 | +} |
|
| 54 | 68 | |
| 55 | 69 | include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); |
| 56 | 70 | dol_include_once('/inventory/class/inventory.class.php'); |
@@ -78,10 +92,14 @@ discard block |
||
| 78 | 92 | $search=array(); |
| 79 | 93 | foreach($object->fields as $key => $val) |
| 80 | 94 | { |
| 81 | - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
| 82 | -} |
|
| 95 | + if (GETPOST('search_'.$key,'alpha')) { |
|
| 96 | + $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
| 97 | + } |
|
| 98 | + } |
|
| 83 | 99 | |
| 84 | -if (empty($action) && empty($id) && empty($ref)) $action='view'; |
|
| 100 | +if (empty($action) && empty($id) && empty($ref)) { |
|
| 101 | + $action='view'; |
|
| 102 | +} |
|
| 85 | 103 | |
| 86 | 104 | // Protection if external user |
| 87 | 105 | if ($user->societe_id > 0) |
@@ -106,7 +124,9 @@ discard block |
||
| 106 | 124 | |
| 107 | 125 | $parameters=array(); |
| 108 | 126 | $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
| 109 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 127 | +if ($reshook < 0) { |
|
| 128 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 129 | +} |
|
| 110 | 130 | |
| 111 | 131 | if (empty($reshook)) |
| 112 | 132 | { |
@@ -120,7 +140,9 @@ discard block |
||
| 120 | 140 | header("Location: ".$urltogo); |
| 121 | 141 | exit; |
| 122 | 142 | } |
| 123 | - if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); |
|
| 143 | + if ($id > 0 || ! empty($ref)) { |
|
| 144 | + $ret = $object->fetch($id,$ref); |
|
| 145 | + } |
|
| 124 | 146 | $action=''; |
| 125 | 147 | } |
| 126 | 148 | |
@@ -129,7 +151,10 @@ discard block |
||
| 129 | 151 | { |
| 130 | 152 | foreach ($object->fields as $key => $val) |
| 131 | 153 | { |
| 132 | - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; // Ignore special fields |
|
| 154 | + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) { |
|
| 155 | + continue; |
|
| 156 | + } |
|
| 157 | + // Ignore special fields |
|
| 133 | 158 | |
| 134 | 159 | $object->$key=GETPOST($key,'alpha'); |
| 135 | 160 | if ($val['notnull'] && $object->$key == '') |
@@ -148,16 +173,17 @@ discard block |
||
| 148 | 173 | $urltogo=$backtopage?$backtopage:dol_buildpath('/inventory/inventory_list.php',1); |
| 149 | 174 | header("Location: ".$urltogo); |
| 150 | 175 | exit; |
| 151 | - } |
|
| 152 | - else |
|
| 176 | + } else |
|
| 153 | 177 | { |
| 154 | 178 | // Creation KO |
| 155 | - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); |
|
| 156 | - else setEventMessages($object->error, null, 'errors'); |
|
| 179 | + if (! empty($object->errors)) { |
|
| 180 | + setEventMessages(null, $object->errors, 'errors'); |
|
| 181 | + } else { |
|
| 182 | + setEventMessages($object->error, null, 'errors'); |
|
| 183 | + } |
|
| 157 | 184 | $action='create'; |
| 158 | 185 | } |
| 159 | - } |
|
| 160 | - else |
|
| 186 | + } else |
|
| 161 | 187 | { |
| 162 | 188 | $action='create'; |
| 163 | 189 | } |
@@ -169,7 +195,9 @@ discard block |
||
| 169 | 195 | foreach ($object->fields as $key => $val) |
| 170 | 196 | { |
| 171 | 197 | $object->$key=GETPOST($key,'alpha'); |
| 172 | - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; |
|
| 198 | + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) { |
|
| 199 | + continue; |
|
| 200 | + } |
|
| 173 | 201 | if ($val['notnull'] && $object->$key == '') |
| 174 | 202 | { |
| 175 | 203 | $error++; |
@@ -183,16 +211,17 @@ discard block |
||
| 183 | 211 | if ($result > 0) |
| 184 | 212 | { |
| 185 | 213 | $action='view'; |
| 186 | - } |
|
| 187 | - else |
|
| 214 | + } else |
|
| 188 | 215 | { |
| 189 | 216 | // Creation KO |
| 190 | - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); |
|
| 191 | - else setEventMessages($object->error, null, 'errors'); |
|
| 217 | + if (! empty($object->errors)) { |
|
| 218 | + setEventMessages(null, $object->errors, 'errors'); |
|
| 219 | + } else { |
|
| 220 | + setEventMessages($object->error, null, 'errors'); |
|
| 221 | + } |
|
| 192 | 222 | $action='edit'; |
| 193 | 223 | } |
| 194 | - } |
|
| 195 | - else |
|
| 224 | + } else |
|
| 196 | 225 | { |
| 197 | 226 | $action='edit'; |
| 198 | 227 | } |
@@ -208,11 +237,13 @@ discard block |
||
| 208 | 237 | setEventMessages("RecordDeleted", null, 'mesgs'); |
| 209 | 238 | header("Location: ".dol_buildpath('/inventory/inventory_list.php',1)); |
| 210 | 239 | exit; |
| 211 | - } |
|
| 212 | - else |
|
| 240 | + } else |
|
| 213 | 241 | { |
| 214 | - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); |
|
| 215 | - else setEventMessages($object->error, null, 'errors'); |
|
| 242 | + if (! empty($object->errors)) { |
|
| 243 | + setEventMessages(null, $object->errors, 'errors'); |
|
| 244 | + } else { |
|
| 245 | + setEventMessages($object->error, null, 'errors'); |
|
| 246 | + } |
|
| 216 | 247 | } |
| 217 | 248 | } |
| 218 | 249 | } |
@@ -261,10 +292,14 @@ discard block |
||
| 261 | 292 | print '<table class="border centpercent">'."\n"; |
| 262 | 293 | foreach($object->fields as $key => $val) |
| 263 | 294 | { |
| 264 | - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue; |
|
| 295 | + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) { |
|
| 296 | + continue; |
|
| 297 | + } |
|
| 265 | 298 | print '<tr><td'; |
| 266 | 299 | print ' class="titlefieldcreate'; |
| 267 | - if ($val['notnull']) print ' fieldrequired'; |
|
| 300 | + if ($val['notnull']) { |
|
| 301 | + print ' fieldrequired'; |
|
| 302 | + } |
|
| 268 | 303 | print '"'; |
| 269 | 304 | print '>'.$langs->trans($val['label']).'</td><td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td></tr>'; |
| 270 | 305 | } |
@@ -339,8 +374,11 @@ discard block |
||
| 339 | 374 | if (! $formconfirm) { |
| 340 | 375 | $parameters = array('lineid' => $lineid); |
| 341 | 376 | $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
| 342 | - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; |
|
| 343 | - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; |
|
| 377 | + if (empty($reshook)) { |
|
| 378 | + $formconfirm.=$hookmanager->resPrint; |
|
| 379 | + } elseif ($reshook > 0) { |
|
| 380 | + $formconfirm=$hookmanager->resPrint; |
|
| 381 | + } |
|
| 344 | 382 | } |
| 345 | 383 | |
| 346 | 384 | // Print form confirm |
@@ -437,7 +475,9 @@ discard block |
||
| 437 | 475 | print '<div class="tabsAction">'."\n"; |
| 438 | 476 | $parameters=array(); |
| 439 | 477 | $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
| 440 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 478 | + if ($reshook < 0) { |
|
| 479 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 480 | + } |
|
| 441 | 481 | |
| 442 | 482 | if (empty($reshook)) |
| 443 | 483 | { |
@@ -149,48 +149,48 @@ |
||
| 149 | 149 | * |
| 150 | 150 | * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) |
| 151 | 151 | * @param string $option On what the link point to |
| 152 | - * @param int $notooltip 1=Disable tooltip |
|
| 153 | - * @param string $morecss Add more css on link |
|
| 152 | + * @param int $notooltip 1=Disable tooltip |
|
| 153 | + * @param string $morecss Add more css on link |
|
| 154 | 154 | * @return string String with URL |
| 155 | 155 | */ |
| 156 | 156 | function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='') |
| 157 | 157 | { |
| 158 | 158 | global $db, $conf, $langs; |
| 159 | - global $dolibarr_main_authentication, $dolibarr_main_demo; |
|
| 160 | - global $menumanager; |
|
| 159 | + global $dolibarr_main_authentication, $dolibarr_main_demo; |
|
| 160 | + global $menumanager; |
|
| 161 | 161 | |
| 162 | - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
| 162 | + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
| 163 | 163 | |
| 164 | - $result = ''; |
|
| 165 | - $companylink = ''; |
|
| 164 | + $result = ''; |
|
| 165 | + $companylink = ''; |
|
| 166 | 166 | |
| 167 | - $label = '<u>' . $langs->trans("Inventory") . '</u>'; |
|
| 168 | - $label.= '<br>'; |
|
| 169 | - $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; |
|
| 167 | + $label = '<u>' . $langs->trans("Inventory") . '</u>'; |
|
| 168 | + $label.= '<br>'; |
|
| 169 | + $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; |
|
| 170 | 170 | |
| 171 | - $url = $url = dol_buildpath('/inventory/m_card.php',1).'?id='.$this->id; |
|
| 171 | + $url = $url = dol_buildpath('/inventory/m_card.php',1).'?id='.$this->id; |
|
| 172 | 172 | |
| 173 | - $linkclose=''; |
|
| 174 | - if (empty($notooltip)) |
|
| 175 | - { |
|
| 176 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 177 | - { |
|
| 178 | - $label=$langs->trans("ShowInventory"); |
|
| 179 | - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 180 | - } |
|
| 181 | - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 182 | - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; |
|
| 183 | - } |
|
| 184 | - else $linkclose = ($morecss?' class="'.$morecss.'"':''); |
|
| 173 | + $linkclose=''; |
|
| 174 | + if (empty($notooltip)) |
|
| 175 | + { |
|
| 176 | + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 177 | + { |
|
| 178 | + $label=$langs->trans("ShowInventory"); |
|
| 179 | + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 180 | + } |
|
| 181 | + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 182 | + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; |
|
| 183 | + } |
|
| 184 | + else $linkclose = ($morecss?' class="'.$morecss.'"':''); |
|
| 185 | 185 | |
| 186 | 186 | $linkstart = '<a href="'.$url.'"'; |
| 187 | 187 | $linkstart.=$linkclose.'>'; |
| 188 | 188 | $linkend='</a>'; |
| 189 | 189 | |
| 190 | - if ($withpicto) |
|
| 191 | - { |
|
| 192 | - $result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend); |
|
| 193 | - if ($withpicto != 2) $result.=' '; |
|
| 190 | + if ($withpicto) |
|
| 191 | + { |
|
| 192 | + $result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend); |
|
| 193 | + if ($withpicto != 2) $result.=' '; |
|
| 194 | 194 | } |
| 195 | 195 | $result.= $linkstart . $this->ref . $linkend; |
| 196 | 196 | return $result; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | 28 | // Put here all includes required by your class file |
| 29 | -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; |
|
| 29 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; |
|
| 30 | 30 | //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
| 31 | 31 | //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; |
| 32 | 32 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | /** |
| 74 | 74 | * @var array Array with all fields and their property |
| 75 | 75 | */ |
| 76 | - public $fields=array( |
|
| 76 | + public $fields = array( |
|
| 77 | 77 | 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), |
| 78 | 78 | 'ref' => array('type'=>'varchar(64)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Reference of object',), |
| 79 | 79 | 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), |
@@ -153,46 +153,46 @@ discard block |
||
| 153 | 153 | * @param string $morecss Add more css on link |
| 154 | 154 | * @return string String with URL |
| 155 | 155 | */ |
| 156 | - function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='') |
|
| 156 | + function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '') |
|
| 157 | 157 | { |
| 158 | 158 | global $db, $conf, $langs; |
| 159 | 159 | global $dolibarr_main_authentication, $dolibarr_main_demo; |
| 160 | 160 | global $menumanager; |
| 161 | 161 | |
| 162 | - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
| 162 | + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips |
|
| 163 | 163 | |
| 164 | 164 | $result = ''; |
| 165 | 165 | $companylink = ''; |
| 166 | 166 | |
| 167 | - $label = '<u>' . $langs->trans("Inventory") . '</u>'; |
|
| 168 | - $label.= '<br>'; |
|
| 169 | - $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; |
|
| 167 | + $label = '<u>'.$langs->trans("Inventory").'</u>'; |
|
| 168 | + $label .= '<br>'; |
|
| 169 | + $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref; |
|
| 170 | 170 | |
| 171 | - $url = $url = dol_buildpath('/inventory/m_card.php',1).'?id='.$this->id; |
|
| 171 | + $url = $url = dol_buildpath('/inventory/m_card.php', 1).'?id='.$this->id; |
|
| 172 | 172 | |
| 173 | - $linkclose=''; |
|
| 173 | + $linkclose = ''; |
|
| 174 | 174 | if (empty($notooltip)) |
| 175 | 175 | { |
| 176 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 176 | + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 177 | 177 | { |
| 178 | - $label=$langs->trans("ShowInventory"); |
|
| 179 | - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 178 | + $label = $langs->trans("ShowInventory"); |
|
| 179 | + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 180 | 180 | } |
| 181 | - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 182 | - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; |
|
| 181 | + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; |
|
| 182 | + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; |
|
| 183 | 183 | } |
| 184 | - else $linkclose = ($morecss?' class="'.$morecss.'"':''); |
|
| 184 | + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
| 185 | 185 | |
| 186 | 186 | $linkstart = '<a href="'.$url.'"'; |
| 187 | - $linkstart.=$linkclose.'>'; |
|
| 188 | - $linkend='</a>'; |
|
| 187 | + $linkstart .= $linkclose.'>'; |
|
| 188 | + $linkend = '</a>'; |
|
| 189 | 189 | |
| 190 | 190 | if ($withpicto) |
| 191 | 191 | { |
| 192 | - $result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend); |
|
| 193 | - if ($withpicto != 2) $result.=' '; |
|
| 192 | + $result .= ($linkstart.img_object(($notooltip ? '' : $label), 'label', ($notooltip ? '' : 'class="classfortooltip"')).$linkend); |
|
| 193 | + if ($withpicto != 2) $result .= ' '; |
|
| 194 | 194 | } |
| 195 | - $result.= $linkstart . $this->ref . $linkend; |
|
| 195 | + $result .= $linkstart.$this->ref.$linkend; |
|
| 196 | 196 | return $result; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -202,9 +202,9 @@ discard block |
||
| 202 | 202 | * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto |
| 203 | 203 | * @return string Label of status |
| 204 | 204 | */ |
| 205 | - function getLibStatut($mode=0) |
|
| 205 | + function getLibStatut($mode = 0) |
|
| 206 | 206 | { |
| 207 | - return $this->LibStatut($this->status,$mode); |
|
| 207 | + return $this->LibStatut($this->status, $mode); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -214,13 +214,13 @@ discard block |
||
| 214 | 214 | * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto |
| 215 | 215 | * @return string Label of status |
| 216 | 216 | */ |
| 217 | - static function LibStatut($status,$mode=0) |
|
| 217 | + static function LibStatut($status, $mode = 0) |
|
| 218 | 218 | { |
| 219 | 219 | global $langs; |
| 220 | 220 | |
| 221 | 221 | if ($mode == 0) |
| 222 | 222 | { |
| 223 | - $prefix=''; |
|
| 223 | + $prefix = ''; |
|
| 224 | 224 | if ($status == 1) return $langs->trans('Enabled'); |
| 225 | 225 | if ($status == 0) return $langs->trans('Disabled'); |
| 226 | 226 | } |
@@ -231,28 +231,28 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | if ($mode == 2) |
| 233 | 233 | { |
| 234 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
| 235 | - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
| 234 | + if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); |
|
| 235 | + if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); |
|
| 236 | 236 | } |
| 237 | 237 | if ($mode == 3) |
| 238 | 238 | { |
| 239 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); |
|
| 240 | - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); |
|
| 239 | + if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); |
|
| 240 | + if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); |
|
| 241 | 241 | } |
| 242 | 242 | if ($mode == 4) |
| 243 | 243 | { |
| 244 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
| 245 | - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
| 244 | + if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); |
|
| 245 | + if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); |
|
| 246 | 246 | } |
| 247 | 247 | if ($mode == 5) |
| 248 | 248 | { |
| 249 | - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
| 250 | - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
| 249 | + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); |
|
| 250 | + if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); |
|
| 251 | 251 | } |
| 252 | 252 | if ($mode == 6) |
| 253 | 253 | { |
| 254 | - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
| 255 | - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
| 254 | + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); |
|
| 255 | + if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | if ($user->societe_id > 0) |
| 62 | 62 | { |
| 63 | 63 | $action=''; |
| 64 | - $_GET["action"] = ''; |
|
| 64 | + $_GET["action"] = ''; |
|
| 65 | 65 | $socid = $user->societe_id; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -135,47 +135,47 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | // List of fields to search into when doing a "search in all" |
| 137 | 137 | $fieldstosearchall = array( |
| 138 | - 'f.ref'=>'Ref', |
|
| 139 | - 'f.ref_supplier'=>'RefSupplier', |
|
| 140 | - 'pd.description'=>'Description', |
|
| 141 | - 's.nom'=>"ThirdParty", |
|
| 142 | - 'f.note_public'=>'NotePublic', |
|
| 138 | + 'f.ref'=>'Ref', |
|
| 139 | + 'f.ref_supplier'=>'RefSupplier', |
|
| 140 | + 'pd.description'=>'Description', |
|
| 141 | + 's.nom'=>"ThirdParty", |
|
| 142 | + 'f.note_public'=>'NotePublic', |
|
| 143 | 143 | ); |
| 144 | 144 | if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate"; |
| 145 | 145 | |
| 146 | 146 | $checkedtypetiers=0; |
| 147 | 147 | $arrayfields=array( |
| 148 | - 'f.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), |
|
| 149 | - 'f.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1), |
|
| 150 | - 'f.label'=>array('label'=>$langs->trans("Label"), 'checked'=>0), |
|
| 151 | - 'f.datef'=>array('label'=>$langs->trans("DateInvoice"), 'checked'=>1), |
|
| 152 | - 'f.date_lim_reglement'=>array('label'=>$langs->trans("DateDue"), 'checked'=>1), |
|
| 148 | + 'f.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), |
|
| 149 | + 'f.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1), |
|
| 150 | + 'f.label'=>array('label'=>$langs->trans("Label"), 'checked'=>0), |
|
| 151 | + 'f.datef'=>array('label'=>$langs->trans("DateInvoice"), 'checked'=>1), |
|
| 152 | + 'f.date_lim_reglement'=>array('label'=>$langs->trans("DateDue"), 'checked'=>1), |
|
| 153 | 153 | 'p.ref'=>array('label'=>$langs->trans("Project"), 'checked'=>0), |
| 154 | - 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), |
|
| 155 | - 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), |
|
| 156 | - 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), |
|
| 157 | - 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0), |
|
| 158 | - 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), |
|
| 159 | - 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), |
|
| 160 | - 'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), |
|
| 161 | - 'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), |
|
| 162 | - 'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), |
|
| 163 | - 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax1_assuj=="1"), |
|
| 164 | - 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax2_assuj=="1"), |
|
| 165 | - 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), |
|
| 166 | - 'dynamount_payed'=>array('label'=>$langs->trans("Payed"), 'checked'=>0), |
|
| 167 | - 'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0), |
|
| 168 | - 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), |
|
| 169 | - 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), |
|
| 170 | - 'f.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), |
|
| 154 | + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), |
|
| 155 | + 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), |
|
| 156 | + 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), |
|
| 157 | + 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0), |
|
| 158 | + 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), |
|
| 159 | + 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), |
|
| 160 | + 'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), |
|
| 161 | + 'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), |
|
| 162 | + 'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), |
|
| 163 | + 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax1_assuj=="1"), |
|
| 164 | + 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax2_assuj=="1"), |
|
| 165 | + 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), |
|
| 166 | + 'dynamount_payed'=>array('label'=>$langs->trans("Payed"), 'checked'=>0), |
|
| 167 | + 'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0), |
|
| 168 | + 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), |
|
| 169 | + 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), |
|
| 170 | + 'f.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), |
|
| 171 | 171 | ); |
| 172 | 172 | // Extra fields |
| 173 | 173 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 174 | 174 | { |
| 175 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 176 | - { |
|
| 177 | - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); |
|
| 178 | - } |
|
| 175 | + foreach($extrafields->attribute_label as $key => $val) |
|
| 176 | + { |
|
| 177 | + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); |
|
| 178 | + } |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | |
@@ -192,55 +192,55 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | if (empty($reshook)) |
| 194 | 194 | { |
| 195 | - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
|
| 195 | + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
|
| 196 | 196 | |
| 197 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha') || GETPOST('button_removefilter.x','alpha')) // All tests must be present to be compatible with all browsers |
|
| 198 | - { |
|
| 199 | - $search_all=""; |
|
| 200 | - $search_user=''; |
|
| 201 | - $search_sale=''; |
|
| 202 | - $search_product_category=''; |
|
| 203 | - $search_ref=""; |
|
| 204 | - $search_refsupplier=""; |
|
| 205 | - $search_label=""; |
|
| 206 | - $search_project=''; |
|
| 207 | - $search_societe=""; |
|
| 208 | - $search_company=""; |
|
| 209 | - $search_amount_no_tax=""; |
|
| 210 | - $search_amount_all_tax=""; |
|
| 211 | - $search_montant_ht=''; |
|
| 212 | - $search_montant_vat=''; |
|
| 213 | - $search_montant_localtax1=''; |
|
| 214 | - $search_montant_localtax2=''; |
|
| 215 | - $search_montant_ttc=''; |
|
| 216 | - $search_status=''; |
|
| 217 | - $search_paymentmode=''; |
|
| 218 | - $search_town=''; |
|
| 219 | - $search_zip=""; |
|
| 220 | - $search_state=""; |
|
| 221 | - $search_type=''; |
|
| 222 | - $search_country=''; |
|
| 223 | - $search_type_thirdparty=''; |
|
| 224 | - $year=""; |
|
| 225 | - $month=""; |
|
| 226 | - $day=""; |
|
| 227 | - $year_lim=""; |
|
| 228 | - $month_lim=""; |
|
| 229 | - $day_lim=""; |
|
| 230 | - $toselect=''; |
|
| 231 | - $search_array_options=array(); |
|
| 232 | - $filter=''; |
|
| 233 | - $option=''; |
|
| 234 | - } |
|
| 197 | + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha') || GETPOST('button_removefilter.x','alpha')) // All tests must be present to be compatible with all browsers |
|
| 198 | + { |
|
| 199 | + $search_all=""; |
|
| 200 | + $search_user=''; |
|
| 201 | + $search_sale=''; |
|
| 202 | + $search_product_category=''; |
|
| 203 | + $search_ref=""; |
|
| 204 | + $search_refsupplier=""; |
|
| 205 | + $search_label=""; |
|
| 206 | + $search_project=''; |
|
| 207 | + $search_societe=""; |
|
| 208 | + $search_company=""; |
|
| 209 | + $search_amount_no_tax=""; |
|
| 210 | + $search_amount_all_tax=""; |
|
| 211 | + $search_montant_ht=''; |
|
| 212 | + $search_montant_vat=''; |
|
| 213 | + $search_montant_localtax1=''; |
|
| 214 | + $search_montant_localtax2=''; |
|
| 215 | + $search_montant_ttc=''; |
|
| 216 | + $search_status=''; |
|
| 217 | + $search_paymentmode=''; |
|
| 218 | + $search_town=''; |
|
| 219 | + $search_zip=""; |
|
| 220 | + $search_state=""; |
|
| 221 | + $search_type=''; |
|
| 222 | + $search_country=''; |
|
| 223 | + $search_type_thirdparty=''; |
|
| 224 | + $year=""; |
|
| 225 | + $month=""; |
|
| 226 | + $day=""; |
|
| 227 | + $year_lim=""; |
|
| 228 | + $month_lim=""; |
|
| 229 | + $day_lim=""; |
|
| 230 | + $toselect=''; |
|
| 231 | + $search_array_options=array(); |
|
| 232 | + $filter=''; |
|
| 233 | + $option=''; |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - // Mass actions |
|
| 237 | - $objectclass='FactureFournisseur'; |
|
| 238 | - $objectlabel='SupplierInvoices'; |
|
| 239 | - $permtoread = $user->rights->fournisseur->facture->lire; |
|
| 240 | - $permtocreate = $user->rights->fournisseur->facture->creer; |
|
| 241 | - $permtodelete = $user->rights->fournisseur->facture->supprimer; |
|
| 242 | - $uploaddir = $conf->fournisseur->facture->dir_output; |
|
| 243 | - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; |
|
| 236 | + // Mass actions |
|
| 237 | + $objectclass='FactureFournisseur'; |
|
| 238 | + $objectlabel='SupplierInvoices'; |
|
| 239 | + $permtoread = $user->rights->fournisseur->facture->lire; |
|
| 240 | + $permtocreate = $user->rights->fournisseur->facture->creer; |
|
| 241 | + $permtodelete = $user->rights->fournisseur->facture->supprimer; |
|
| 242 | + $uploaddir = $conf->fournisseur->facture->dir_output; |
|
| 243 | + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
| 290 | 290 | if ($search_user > 0) |
| 291 | 291 | { |
| 292 | - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; |
|
| 293 | - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 292 | + $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; |
|
| 293 | + $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 294 | 294 | } |
| 295 | 295 | $sql.= ' WHERE f.fk_soc = s.rowid'; |
| 296 | 296 | $sql.= ' AND f.entity IN ('.getEntity('facture_fourn').')'; |
@@ -364,20 +364,20 @@ discard block |
||
| 364 | 364 | if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; |
| 365 | 365 | if ($search_user > 0) |
| 366 | 366 | { |
| 367 | - $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; |
|
| 367 | + $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; |
|
| 368 | 368 | } |
| 369 | 369 | // Add where from extra fields |
| 370 | 370 | foreach ($search_array_options as $key => $val) |
| 371 | 371 | { |
| 372 | - $crit=$val; |
|
| 373 | - $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 374 | - $typ=$extrafields->attribute_type[$tmpkey]; |
|
| 375 | - $mode=0; |
|
| 376 | - if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric |
|
| 377 | - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) |
|
| 378 | - { |
|
| 379 | - $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); |
|
| 380 | - } |
|
| 372 | + $crit=$val; |
|
| 373 | + $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 374 | + $typ=$extrafields->attribute_type[$tmpkey]; |
|
| 375 | + $mode=0; |
|
| 376 | + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric |
|
| 377 | + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) |
|
| 378 | + { |
|
| 379 | + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); |
|
| 380 | + } |
|
| 381 | 381 | } |
| 382 | 382 | // Add where from hooks |
| 383 | 383 | $parameters=array(); |
@@ -386,22 +386,22 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | if (! $search_all) |
| 388 | 388 | { |
| 389 | - $sql.= " GROUP BY f.rowid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement, f.fk_mode_reglement,"; |
|
| 390 | - $sql.= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; |
|
| 391 | - $sql.= " f.localtax1, f.localtax2,"; |
|
| 392 | - $sql.= " s.rowid, s.nom, s.town, s.zip, s.fk_pays, s.client, s.code_client,"; |
|
| 393 | - $sql.= " typent.code,"; |
|
| 394 | - $sql.= " state.code_departement, state.nom,"; |
|
| 395 | - $sql.= " p.rowid, p.ref"; |
|
| 396 | - |
|
| 397 | - foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by |
|
| 398 | - { |
|
| 399 | - $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); |
|
| 400 | - } |
|
| 389 | + $sql.= " GROUP BY f.rowid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement, f.fk_mode_reglement,"; |
|
| 390 | + $sql.= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; |
|
| 391 | + $sql.= " f.localtax1, f.localtax2,"; |
|
| 392 | + $sql.= " s.rowid, s.nom, s.town, s.zip, s.fk_pays, s.client, s.code_client,"; |
|
| 393 | + $sql.= " typent.code,"; |
|
| 394 | + $sql.= " state.code_departement, state.nom,"; |
|
| 395 | + $sql.= " p.rowid, p.ref"; |
|
| 396 | + |
|
| 397 | + foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by |
|
| 398 | + { |
|
| 399 | + $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); |
|
| 400 | + } |
|
| 401 | 401 | } |
| 402 | 402 | else |
| 403 | 403 | { |
| 404 | - $sql.= natural_search(array_keys($fieldstosearchall), $search_all); |
|
| 404 | + $sql.= natural_search(array_keys($fieldstosearchall), $search_all); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | $sql.= $db->order($sortfield,$sortorder); |
@@ -431,10 +431,10 @@ discard block |
||
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | $param='&socid='.$socid; |
| 434 | - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; |
|
| 435 | - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
|
| 434 | + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; |
|
| 435 | + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
|
| 436 | 436 | if ($search_all) $param.='&search_all='.urlencode($search_all); |
| 437 | - if ($day) $param.='&day='.urlencode($day); |
|
| 437 | + if ($day) $param.='&day='.urlencode($day); |
|
| 438 | 438 | if ($month) $param.='&month='.urlencode($month); |
| 439 | 439 | if ($year) $param.='&year=' .urlencode($year); |
| 440 | 440 | if ($day_lim) $param.='&day_lim='.urlencode($day_lim); |
@@ -444,30 +444,30 @@ discard block |
||
| 444 | 444 | if ($search_refsupplier) $param.='&search_refsupplier='.urlencode($search_refsupplier); |
| 445 | 445 | if ($search_label) $param.='&search_label='.urlencode($search_label); |
| 446 | 446 | if ($search_company) $param.='&search_company='.urlencode($search_company); |
| 447 | - if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht); |
|
| 448 | - if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); |
|
| 449 | - if ($search_montant_localtax1 != '') $param.='&search_montant_localtax1='.urlencode($search_montant_localtax1); |
|
| 450 | - if ($search_montant_localtax2 != '') $param.='&search_montant_localtax2='.urlencode($search_montant_localtax2); |
|
| 451 | - if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); |
|
| 447 | + if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht); |
|
| 448 | + if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); |
|
| 449 | + if ($search_montant_localtax1 != '') $param.='&search_montant_localtax1='.urlencode($search_montant_localtax1); |
|
| 450 | + if ($search_montant_localtax2 != '') $param.='&search_montant_localtax2='.urlencode($search_montant_localtax2); |
|
| 451 | + if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); |
|
| 452 | 452 | if ($search_amount_no_tax) $param.='&search_amount_no_tax='.urlencode($search_amount_no_tax); |
| 453 | 453 | if ($search_amount_all_tax) $param.='&search_amount_all_tax='.urlencode($search_amount_all_tax); |
| 454 | 454 | if ($search_status >= 0) $param.="&search_status=".urlencode($search_status); |
| 455 | - if ($show_files) $param.='&show_files=' .$show_files; |
|
| 455 | + if ($show_files) $param.='&show_files=' .$show_files; |
|
| 456 | 456 | if ($option) $param.="&option=".$option; |
| 457 | 457 | if ($optioncss != '') $param.='&optioncss='.$optioncss; |
| 458 | 458 | // Add $param from extra fields |
| 459 | 459 | foreach ($search_array_options as $key => $val) |
| 460 | 460 | { |
| 461 | - $crit=$val; |
|
| 462 | - $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 463 | - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); |
|
| 461 | + $crit=$val; |
|
| 462 | + $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 463 | + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | // List of mass actions available |
| 467 | 467 | $arrayofmassactions = array( |
| 468 | - 'validate'=>$langs->trans("Validate"), |
|
| 468 | + 'validate'=>$langs->trans("Validate"), |
|
| 469 | 469 | //'presend'=>$langs->trans("SendByMail"), |
| 470 | - //'builddoc'=>$langs->trans("PDFMerge"), |
|
| 470 | + //'builddoc'=>$langs->trans("PDFMerge"), |
|
| 471 | 471 | ); |
| 472 | 472 | //if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); |
| 473 | 473 | if ($user->rights->fournisseur->facture->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); |
@@ -476,13 +476,13 @@ discard block |
||
| 476 | 476 | |
| 477 | 477 | $i = 0; |
| 478 | 478 | print '<form method="POST" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; |
| 479 | - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 479 | + if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 480 | 480 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 481 | 481 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
| 482 | 482 | print '<input type="hidden" name="action" value="list">'; |
| 483 | 483 | print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
| 484 | 484 | print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; |
| 485 | - print '<input type="hidden" name="page" value="'.$page.'">'; |
|
| 485 | + print '<input type="hidden" name="page" value="'.$page.'">'; |
|
| 486 | 486 | print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">'; |
| 487 | 487 | print '<input type="hidden" name="socid" value="'.$socid.'">'; |
| 488 | 488 | |
@@ -490,149 +490,149 @@ discard block |
||
| 490 | 490 | |
| 491 | 491 | if ($massaction == 'presend') |
| 492 | 492 | { |
| 493 | - $langs->load("mails"); |
|
| 494 | - |
|
| 495 | - if (! GETPOST('cancel')) |
|
| 496 | - { |
|
| 497 | - $objecttmp=new FactureFournisseur($db); |
|
| 498 | - $listofselectedid=array(); |
|
| 499 | - $listofselectedthirdparties=array(); |
|
| 500 | - $listofselectedref=array(); |
|
| 501 | - foreach($arrayofselected as $toselectid) |
|
| 502 | - { |
|
| 503 | - $result=$objecttmp->fetch($toselectid); |
|
| 504 | - if ($result > 0) |
|
| 505 | - { |
|
| 506 | - $listofselectedid[$toselectid]=$toselectid; |
|
| 507 | - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; |
|
| 508 | - $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; |
|
| 509 | - $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; |
|
| 510 | - } |
|
| 511 | - } |
|
| 512 | - } |
|
| 513 | - |
|
| 514 | - print '<input type="hidden" name="massaction" value="confirm_presend">'; |
|
| 515 | - |
|
| 516 | - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
|
| 517 | - $formmail = new FormMail($db); |
|
| 518 | - |
|
| 519 | - dol_fiche_head(null, '', ''); |
|
| 520 | - |
|
| 521 | - $topicmail="SendBillRef"; |
|
| 522 | - $modelmail="supplier_invoice_send"; |
|
| 523 | - |
|
| 524 | - // Cree l'objet formulaire mail |
|
| 525 | - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
|
| 526 | - $formmail = new FormMail($db); |
|
| 527 | - $formmail->withform=-1; |
|
| 528 | - $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); |
|
| 529 | - |
|
| 530 | - if($formmail->fromtype === 'user'){ |
|
| 531 | - $formmail->fromid = $user->id; |
|
| 532 | - |
|
| 533 | - } |
|
| 534 | - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set |
|
| 535 | - { |
|
| 536 | - $formmail->trackid='sinv'.$object->id; |
|
| 537 | - } |
|
| 538 | - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set |
|
| 539 | - { |
|
| 540 | - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
| 541 | - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'sinv'.$object->id); |
|
| 542 | - } |
|
| 543 | - $formmail->withfrom=1; |
|
| 544 | - $liste=$langs->trans("AllRecipientSelected"); |
|
| 545 | - if (count($listofselectedthirdparties) == 1) |
|
| 546 | - { |
|
| 547 | - $liste=array(); |
|
| 548 | - $thirdpartyid=array_shift($listofselectedthirdparties); |
|
| 549 | - $soc=new Societe($db); |
|
| 550 | - $soc->fetch($thirdpartyid); |
|
| 551 | - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) |
|
| 552 | - { |
|
| 553 | - $liste[$key]=$value; |
|
| 554 | - } |
|
| 555 | - $formmail->withtoreadonly=0; |
|
| 556 | - } |
|
| 557 | - else |
|
| 558 | - { |
|
| 559 | - $formmail->withtoreadonly=1; |
|
| 560 | - } |
|
| 561 | - $formmail->withto=$liste; |
|
| 562 | - $formmail->withtofree=0; |
|
| 563 | - $formmail->withtocc=1; |
|
| 564 | - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; |
|
| 565 | - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); |
|
| 566 | - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); |
|
| 567 | - $formmail->withbody=1; |
|
| 568 | - $formmail->withdeliveryreceipt=1; |
|
| 569 | - $formmail->withcancel=1; |
|
| 570 | - // Tableau des substitutions |
|
| 571 | - $formmail->substit['__REF__']='__REF__'; // We want to keep the tag |
|
| 572 | - $formmail->substit['__SIGNATURE__']=$user->signature; |
|
| 573 | - $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag |
|
| 574 | - $formmail->substit['__PERSONALIZED__']=''; |
|
| 575 | - $formmail->substit['__CONTACTCIVNAME__']=''; |
|
| 576 | - |
|
| 577 | - // Tableau des parametres complementaires du post |
|
| 578 | - $formmail->param['action']=$action; |
|
| 579 | - $formmail->param['models']=$modelmail; |
|
| 580 | - $formmail->param['models_id']=GETPOST('modelmailselected','int'); |
|
| 581 | - $formmail->param['id']=join(',',$arrayofselected); |
|
| 582 | - //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; |
|
| 583 | - |
|
| 584 | - print $formmail->get_form(); |
|
| 585 | - |
|
| 586 | - dol_fiche_end(); |
|
| 493 | + $langs->load("mails"); |
|
| 494 | + |
|
| 495 | + if (! GETPOST('cancel')) |
|
| 496 | + { |
|
| 497 | + $objecttmp=new FactureFournisseur($db); |
|
| 498 | + $listofselectedid=array(); |
|
| 499 | + $listofselectedthirdparties=array(); |
|
| 500 | + $listofselectedref=array(); |
|
| 501 | + foreach($arrayofselected as $toselectid) |
|
| 502 | + { |
|
| 503 | + $result=$objecttmp->fetch($toselectid); |
|
| 504 | + if ($result > 0) |
|
| 505 | + { |
|
| 506 | + $listofselectedid[$toselectid]=$toselectid; |
|
| 507 | + $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; |
|
| 508 | + $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; |
|
| 509 | + $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; |
|
| 510 | + } |
|
| 511 | + } |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + print '<input type="hidden" name="massaction" value="confirm_presend">'; |
|
| 515 | + |
|
| 516 | + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
|
| 517 | + $formmail = new FormMail($db); |
|
| 518 | + |
|
| 519 | + dol_fiche_head(null, '', ''); |
|
| 520 | + |
|
| 521 | + $topicmail="SendBillRef"; |
|
| 522 | + $modelmail="supplier_invoice_send"; |
|
| 523 | + |
|
| 524 | + // Cree l'objet formulaire mail |
|
| 525 | + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
|
| 526 | + $formmail = new FormMail($db); |
|
| 527 | + $formmail->withform=-1; |
|
| 528 | + $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); |
|
| 529 | + |
|
| 530 | + if($formmail->fromtype === 'user'){ |
|
| 531 | + $formmail->fromid = $user->id; |
|
| 532 | + |
|
| 533 | + } |
|
| 534 | + if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set |
|
| 535 | + { |
|
| 536 | + $formmail->trackid='sinv'.$object->id; |
|
| 537 | + } |
|
| 538 | + if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set |
|
| 539 | + { |
|
| 540 | + include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
| 541 | + $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'sinv'.$object->id); |
|
| 542 | + } |
|
| 543 | + $formmail->withfrom=1; |
|
| 544 | + $liste=$langs->trans("AllRecipientSelected"); |
|
| 545 | + if (count($listofselectedthirdparties) == 1) |
|
| 546 | + { |
|
| 547 | + $liste=array(); |
|
| 548 | + $thirdpartyid=array_shift($listofselectedthirdparties); |
|
| 549 | + $soc=new Societe($db); |
|
| 550 | + $soc->fetch($thirdpartyid); |
|
| 551 | + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) |
|
| 552 | + { |
|
| 553 | + $liste[$key]=$value; |
|
| 554 | + } |
|
| 555 | + $formmail->withtoreadonly=0; |
|
| 556 | + } |
|
| 557 | + else |
|
| 558 | + { |
|
| 559 | + $formmail->withtoreadonly=1; |
|
| 560 | + } |
|
| 561 | + $formmail->withto=$liste; |
|
| 562 | + $formmail->withtofree=0; |
|
| 563 | + $formmail->withtocc=1; |
|
| 564 | + $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; |
|
| 565 | + $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); |
|
| 566 | + $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); |
|
| 567 | + $formmail->withbody=1; |
|
| 568 | + $formmail->withdeliveryreceipt=1; |
|
| 569 | + $formmail->withcancel=1; |
|
| 570 | + // Tableau des substitutions |
|
| 571 | + $formmail->substit['__REF__']='__REF__'; // We want to keep the tag |
|
| 572 | + $formmail->substit['__SIGNATURE__']=$user->signature; |
|
| 573 | + $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag |
|
| 574 | + $formmail->substit['__PERSONALIZED__']=''; |
|
| 575 | + $formmail->substit['__CONTACTCIVNAME__']=''; |
|
| 576 | + |
|
| 577 | + // Tableau des parametres complementaires du post |
|
| 578 | + $formmail->param['action']=$action; |
|
| 579 | + $formmail->param['models']=$modelmail; |
|
| 580 | + $formmail->param['models_id']=GETPOST('modelmailselected','int'); |
|
| 581 | + $formmail->param['id']=join(',',$arrayofselected); |
|
| 582 | + //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; |
|
| 583 | + |
|
| 584 | + print $formmail->get_form(); |
|
| 585 | + |
|
| 586 | + dol_fiche_end(); |
|
| 587 | 587 | } |
| 588 | 588 | elseif ($massaction == 'createbills') |
| 589 | 589 | { |
| 590 | - //var_dump($_REQUEST); |
|
| 591 | - print '<input type="hidden" name="massaction" value="confirm_createbills">'; |
|
| 592 | - |
|
| 593 | - print '<table class="border" width="100%" >'; |
|
| 594 | - print '<tr>'; |
|
| 595 | - print '<td class="titlefieldmiddle">'; |
|
| 596 | - print $langs->trans('DateInvoice'); |
|
| 597 | - print '</td>'; |
|
| 598 | - print '<td>'; |
|
| 599 | - print $form->select_date('', '', '', '', '', '', 1, 1); |
|
| 600 | - print '</td>'; |
|
| 601 | - print '</tr>'; |
|
| 602 | - print '<tr>'; |
|
| 603 | - print '<td>'; |
|
| 604 | - print $langs->trans('CreateOneBillByThird'); |
|
| 605 | - print '</td>'; |
|
| 606 | - print '<td>'; |
|
| 607 | - print $form->selectyesno('createbills_onebythird', '', 1); |
|
| 608 | - print '</td>'; |
|
| 609 | - print '</tr>'; |
|
| 610 | - print '<tr>'; |
|
| 611 | - print '<td>'; |
|
| 612 | - print $langs->trans('ValidateInvoices'); |
|
| 613 | - print '</td>'; |
|
| 614 | - print '<td>'; |
|
| 615 | - print $form->selectyesno('valdate_invoices', 1, 1); |
|
| 616 | - print '</td>'; |
|
| 617 | - print '</tr>'; |
|
| 618 | - print '</table>'; |
|
| 619 | - |
|
| 620 | - print '<br>'; |
|
| 621 | - print '<div class="center">'; |
|
| 622 | - print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisCustomer').'"> '; |
|
| 623 | - print '<input type="submit" class="button" id="cancel" name="cancel" value="'.$langs->trans('Cancel').'">'; |
|
| 624 | - print '</div>'; |
|
| 625 | - print '<br>'; |
|
| 590 | + //var_dump($_REQUEST); |
|
| 591 | + print '<input type="hidden" name="massaction" value="confirm_createbills">'; |
|
| 592 | + |
|
| 593 | + print '<table class="border" width="100%" >'; |
|
| 594 | + print '<tr>'; |
|
| 595 | + print '<td class="titlefieldmiddle">'; |
|
| 596 | + print $langs->trans('DateInvoice'); |
|
| 597 | + print '</td>'; |
|
| 598 | + print '<td>'; |
|
| 599 | + print $form->select_date('', '', '', '', '', '', 1, 1); |
|
| 600 | + print '</td>'; |
|
| 601 | + print '</tr>'; |
|
| 602 | + print '<tr>'; |
|
| 603 | + print '<td>'; |
|
| 604 | + print $langs->trans('CreateOneBillByThird'); |
|
| 605 | + print '</td>'; |
|
| 606 | + print '<td>'; |
|
| 607 | + print $form->selectyesno('createbills_onebythird', '', 1); |
|
| 608 | + print '</td>'; |
|
| 609 | + print '</tr>'; |
|
| 610 | + print '<tr>'; |
|
| 611 | + print '<td>'; |
|
| 612 | + print $langs->trans('ValidateInvoices'); |
|
| 613 | + print '</td>'; |
|
| 614 | + print '<td>'; |
|
| 615 | + print $form->selectyesno('valdate_invoices', 1, 1); |
|
| 616 | + print '</td>'; |
|
| 617 | + print '</tr>'; |
|
| 618 | + print '</table>'; |
|
| 619 | + |
|
| 620 | + print '<br>'; |
|
| 621 | + print '<div class="center">'; |
|
| 622 | + print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisCustomer').'"> '; |
|
| 623 | + print '<input type="submit" class="button" id="cancel" name="cancel" value="'.$langs->trans('Cancel').'">'; |
|
| 624 | + print '</div>'; |
|
| 625 | + print '<br>'; |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | if ($search_all) |
| 629 | - { |
|
| 630 | - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); |
|
| 631 | - print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); |
|
| 632 | - } |
|
| 629 | + { |
|
| 630 | + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); |
|
| 631 | + print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); |
|
| 632 | + } |
|
| 633 | 633 | |
| 634 | 634 | // If the user can view prospects other than his' |
| 635 | - $moreforfilter=''; |
|
| 635 | + $moreforfilter=''; |
|
| 636 | 636 | if ($user->rights->societe->client->voir || $socid) |
| 637 | 637 | { |
| 638 | 638 | $langs->load("commercial"); |
@@ -641,14 +641,14 @@ discard block |
||
| 641 | 641 | $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); |
| 642 | 642 | $moreforfilter.='</div>'; |
| 643 | 643 | } |
| 644 | - // If the user can view prospects other than his' |
|
| 645 | - if ($user->rights->societe->client->voir || $socid) |
|
| 646 | - { |
|
| 644 | + // If the user can view prospects other than his' |
|
| 645 | + if ($user->rights->societe->client->voir || $socid) |
|
| 646 | + { |
|
| 647 | 647 | $moreforfilter.='<div class="divsearchfield">'; |
| 648 | - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; |
|
| 649 | - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); |
|
| 648 | + $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; |
|
| 649 | + $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); |
|
| 650 | 650 | $moreforfilter.='</div>'; |
| 651 | - } |
|
| 651 | + } |
|
| 652 | 652 | // If the user can view prospects other than his' |
| 653 | 653 | if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) |
| 654 | 654 | { |
@@ -659,76 +659,76 @@ discard block |
||
| 659 | 659 | $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); |
| 660 | 660 | $moreforfilter.='</div>'; |
| 661 | 661 | } |
| 662 | - $parameters=array(); |
|
| 663 | - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook |
|
| 662 | + $parameters=array(); |
|
| 663 | + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook |
|
| 664 | 664 | if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; |
| 665 | 665 | else $moreforfilter = $hookmanager->resPrint; |
| 666 | 666 | |
| 667 | - if ($moreforfilter) |
|
| 668 | - { |
|
| 667 | + if ($moreforfilter) |
|
| 668 | + { |
|
| 669 | 669 | print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
| 670 | - print $moreforfilter; |
|
| 671 | - print '</div>'; |
|
| 672 | - } |
|
| 670 | + print $moreforfilter; |
|
| 671 | + print '</div>'; |
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
|
| 675 | - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
| 676 | - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); |
|
| 674 | + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
|
| 675 | + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
| 676 | + if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); |
|
| 677 | 677 | |
| 678 | - print '<div class="div-table-responsive">'; |
|
| 679 | - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
|
| 678 | + print '<div class="div-table-responsive">'; |
|
| 679 | + print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
|
| 680 | 680 | |
| 681 | 681 | // Line for filters |
| 682 | 682 | print '<tr class="liste_titre_filter">'; |
| 683 | 683 | // Ref |
| 684 | 684 | if (! empty($arrayfields['f.ref']['checked'])) |
| 685 | 685 | { |
| 686 | - print '<td class="liste_titre" align="left">'; |
|
| 687 | - print '<input class="flat" size="6" type="text" name="search_ref" value="'.$search_ref.'">'; |
|
| 688 | - print '</td>'; |
|
| 686 | + print '<td class="liste_titre" align="left">'; |
|
| 687 | + print '<input class="flat" size="6" type="text" name="search_ref" value="'.$search_ref.'">'; |
|
| 688 | + print '</td>'; |
|
| 689 | 689 | } |
| 690 | 690 | // Ref supplier |
| 691 | 691 | if (! empty($arrayfields['f.ref_supplier']['checked'])) |
| 692 | 692 | { |
| 693 | - print '<td class="liste_titre">'; |
|
| 694 | - print '<input class="flat" size="6" type="text" name="search_refsupplier" value="'.$search_refsupplier.'">'; |
|
| 695 | - print '</td>'; |
|
| 693 | + print '<td class="liste_titre">'; |
|
| 694 | + print '<input class="flat" size="6" type="text" name="search_refsupplier" value="'.$search_refsupplier.'">'; |
|
| 695 | + print '</td>'; |
|
| 696 | 696 | } |
| 697 | 697 | // Label |
| 698 | 698 | if (! empty($arrayfields['f.label']['checked'])) |
| 699 | 699 | { |
| 700 | - print '<td class="liste_titre">'; |
|
| 701 | - print '<input class="flat" size="6" type="text" name="search_label" value="'.$search_label.'">'; |
|
| 702 | - print '</td>'; |
|
| 700 | + print '<td class="liste_titre">'; |
|
| 701 | + print '<input class="flat" size="6" type="text" name="search_label" value="'.$search_label.'">'; |
|
| 702 | + print '</td>'; |
|
| 703 | 703 | } |
| 704 | 704 | // Date invoice |
| 705 | 705 | if (! empty($arrayfields['f.datef']['checked'])) |
| 706 | 706 | { |
| 707 | - print '<td class="liste_titre" align="center">'; |
|
| 708 | - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">'; |
|
| 709 | - print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">'; |
|
| 710 | - $formother->select_year($year?$year:-1,'year',1, 20, 5); |
|
| 711 | - print '</td>'; |
|
| 707 | + print '<td class="liste_titre" align="center">'; |
|
| 708 | + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">'; |
|
| 709 | + print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">'; |
|
| 710 | + $formother->select_year($year?$year:-1,'year',1, 20, 5); |
|
| 711 | + print '</td>'; |
|
| 712 | 712 | } |
| 713 | 713 | // Date due |
| 714 | 714 | if (! empty($arrayfields['f.date_lim_reglement']['checked'])) |
| 715 | 715 | { |
| 716 | - print '<td class="liste_titre" align="center">'; |
|
| 717 | - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_lim" value="'.dol_escape_htmltag($day_lim).'">'; |
|
| 718 | - print '<input class="flat" type="text" size="1" maxlength="2" name="month_lim" value="'.$month_lim.'">'; |
|
| 719 | - $formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5); |
|
| 720 | - print '<br><input type="checkbox" name="option" value="late"'.($option == 'late'?' checked':'').'> '.$langs->trans("Late"); |
|
| 721 | - print '</td>'; |
|
| 716 | + print '<td class="liste_titre" align="center">'; |
|
| 717 | + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_lim" value="'.dol_escape_htmltag($day_lim).'">'; |
|
| 718 | + print '<input class="flat" type="text" size="1" maxlength="2" name="month_lim" value="'.$month_lim.'">'; |
|
| 719 | + $formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5); |
|
| 720 | + print '<br><input type="checkbox" name="option" value="late"'.($option == 'late'?' checked':'').'> '.$langs->trans("Late"); |
|
| 721 | + print '</td>'; |
|
| 722 | 722 | } |
| 723 | 723 | // Project |
| 724 | 724 | if (! empty($arrayfields['p.ref']['checked'])) |
| 725 | 725 | { |
| 726 | - print '<td class="liste_titre" align="left"><input class="flat" type="text" size="6" name="search_project" value="'.$search_project.'"></td>'; |
|
| 726 | + print '<td class="liste_titre" align="left"><input class="flat" type="text" size="6" name="search_project" value="'.$search_project.'"></td>'; |
|
| 727 | 727 | } |
| 728 | 728 | // Thirpdarty |
| 729 | 729 | if (! empty($arrayfields['s.nom']['checked'])) |
| 730 | 730 | { |
| 731 | - print '<td class="liste_titre" align="left"><input class="flat" type="text" size="6" name="search_societe" value="'.$search_societe.'"></td>'; |
|
| 731 | + print '<td class="liste_titre" align="left"><input class="flat" type="text" size="6" name="search_societe" value="'.$search_societe.'"></td>'; |
|
| 732 | 732 | } |
| 733 | 733 | // Town |
| 734 | 734 | if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>'; |
@@ -737,98 +737,98 @@ discard block |
||
| 737 | 737 | // State |
| 738 | 738 | if (! empty($arrayfields['state.nom']['checked'])) |
| 739 | 739 | { |
| 740 | - print '<td class="liste_titre">'; |
|
| 741 | - print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; |
|
| 742 | - print '</td>'; |
|
| 740 | + print '<td class="liste_titre">'; |
|
| 741 | + print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; |
|
| 742 | + print '</td>'; |
|
| 743 | 743 | } |
| 744 | 744 | // Country |
| 745 | 745 | if (! empty($arrayfields['country.code_iso']['checked'])) |
| 746 | 746 | { |
| 747 | - print '<td class="liste_titre" align="center">'; |
|
| 748 | - print $form->select_country($search_country,'search_country','',0,'maxwidth100'); |
|
| 749 | - print '</td>'; |
|
| 747 | + print '<td class="liste_titre" align="center">'; |
|
| 748 | + print $form->select_country($search_country,'search_country','',0,'maxwidth100'); |
|
| 749 | + print '</td>'; |
|
| 750 | 750 | } |
| 751 | 751 | // Company type |
| 752 | 752 | if (! empty($arrayfields['typent.code']['checked'])) |
| 753 | 753 | { |
| 754 | - print '<td class="liste_titre maxwidthonsmartphone" align="center">'; |
|
| 755 | - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); |
|
| 756 | - print '</td>'; |
|
| 754 | + print '<td class="liste_titre maxwidthonsmartphone" align="center">'; |
|
| 755 | + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); |
|
| 756 | + print '</td>'; |
|
| 757 | 757 | } |
| 758 | 758 | // Payment mode |
| 759 | 759 | if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) |
| 760 | 760 | { |
| 761 | - print '<td class="liste_titre" align="left">'; |
|
| 762 | - $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 0, 1, 10); |
|
| 763 | - print '</td>'; |
|
| 761 | + print '<td class="liste_titre" align="left">'; |
|
| 762 | + $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 0, 1, 10); |
|
| 763 | + print '</td>'; |
|
| 764 | 764 | } |
| 765 | 765 | if (! empty($arrayfields['f.total_ht']['checked'])) |
| 766 | 766 | { |
| 767 | - // Amount |
|
| 768 | - print '<td class="liste_titre" align="right">'; |
|
| 769 | - print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">'; |
|
| 770 | - print '</td>'; |
|
| 767 | + // Amount |
|
| 768 | + print '<td class="liste_titre" align="right">'; |
|
| 769 | + print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">'; |
|
| 770 | + print '</td>'; |
|
| 771 | 771 | } |
| 772 | 772 | if (! empty($arrayfields['f.total_vat']['checked'])) |
| 773 | 773 | { |
| 774 | - // Amount |
|
| 775 | - print '<td class="liste_titre" align="right">'; |
|
| 776 | - print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">'; |
|
| 777 | - print '</td>'; |
|
| 774 | + // Amount |
|
| 775 | + print '<td class="liste_titre" align="right">'; |
|
| 776 | + print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">'; |
|
| 777 | + print '</td>'; |
|
| 778 | 778 | } |
| 779 | 779 | if (! empty($arrayfields['f.total_localtax1']['checked'])) |
| 780 | 780 | { |
| 781 | - // Amount |
|
| 782 | - print '<td class="liste_titre" align="right">'; |
|
| 783 | - print '<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.$search_montant_localtax1.'">'; |
|
| 784 | - print '</td>'; |
|
| 781 | + // Amount |
|
| 782 | + print '<td class="liste_titre" align="right">'; |
|
| 783 | + print '<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.$search_montant_localtax1.'">'; |
|
| 784 | + print '</td>'; |
|
| 785 | 785 | } |
| 786 | 786 | if (! empty($arrayfields['f.total_localtax2']['checked'])) |
| 787 | 787 | { |
| 788 | - // Amount |
|
| 789 | - print '<td class="liste_titre" align="right">'; |
|
| 790 | - print '<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.$search_montant_localtax2.'">'; |
|
| 791 | - print '</td>'; |
|
| 788 | + // Amount |
|
| 789 | + print '<td class="liste_titre" align="right">'; |
|
| 790 | + print '<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.$search_montant_localtax2.'">'; |
|
| 791 | + print '</td>'; |
|
| 792 | 792 | } |
| 793 | 793 | if (! empty($arrayfields['f.total_ttc']['checked'])) |
| 794 | 794 | { |
| 795 | - // Amount |
|
| 796 | - print '<td class="liste_titre" align="right">'; |
|
| 797 | - print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">'; |
|
| 798 | - print '</td>'; |
|
| 795 | + // Amount |
|
| 796 | + print '<td class="liste_titre" align="right">'; |
|
| 797 | + print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">'; |
|
| 798 | + print '</td>'; |
|
| 799 | + } |
|
| 800 | + if (! empty($arrayfields['dynamount_payed']['checked'])) |
|
| 801 | + { |
|
| 802 | + print '<td class="liste_titre" align="right">'; |
|
| 803 | + print '</td>'; |
|
| 804 | + } |
|
| 805 | + if (! empty($arrayfields['rtp']['checked'])) |
|
| 806 | + { |
|
| 807 | + print '<td class="liste_titre" align="right">'; |
|
| 808 | + print '</td>'; |
|
| 799 | 809 | } |
| 800 | - if (! empty($arrayfields['dynamount_payed']['checked'])) |
|
| 801 | - { |
|
| 802 | - print '<td class="liste_titre" align="right">'; |
|
| 803 | - print '</td>'; |
|
| 804 | - } |
|
| 805 | - if (! empty($arrayfields['rtp']['checked'])) |
|
| 806 | - { |
|
| 807 | - print '<td class="liste_titre" align="right">'; |
|
| 808 | - print '</td>'; |
|
| 809 | - } |
|
| 810 | 810 | // Extra fields |
| 811 | 811 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 812 | 812 | { |
| 813 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 814 | - { |
|
| 815 | - if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 816 | - { |
|
| 817 | - $align=$extrafields->getAlignFlag($key); |
|
| 818 | - $typeofextrafield=$extrafields->attribute_type[$key]; |
|
| 819 | - print '<td class="liste_titre'.($align?' '.$align:'').'">'; |
|
| 820 | - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) |
|
| 821 | - { |
|
| 822 | - $crit=$val; |
|
| 823 | - $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 824 | - $searchclass=''; |
|
| 825 | - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; |
|
| 826 | - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; |
|
| 827 | - print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">'; |
|
| 828 | - } |
|
| 829 | - print '</td>'; |
|
| 830 | - } |
|
| 831 | - } |
|
| 813 | + foreach($extrafields->attribute_label as $key => $val) |
|
| 814 | + { |
|
| 815 | + if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 816 | + { |
|
| 817 | + $align=$extrafields->getAlignFlag($key); |
|
| 818 | + $typeofextrafield=$extrafields->attribute_type[$key]; |
|
| 819 | + print '<td class="liste_titre'.($align?' '.$align:'').'">'; |
|
| 820 | + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) |
|
| 821 | + { |
|
| 822 | + $crit=$val; |
|
| 823 | + $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 824 | + $searchclass=''; |
|
| 825 | + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; |
|
| 826 | + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; |
|
| 827 | + print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">'; |
|
| 828 | + } |
|
| 829 | + print '</td>'; |
|
| 830 | + } |
|
| 831 | + } |
|
| 832 | 832 | } |
| 833 | 833 | // Fields from hook |
| 834 | 834 | $parameters=array('arrayfields'=>$arrayfields); |
@@ -837,22 +837,22 @@ discard block |
||
| 837 | 837 | // Date creation |
| 838 | 838 | if (! empty($arrayfields['f.datec']['checked'])) |
| 839 | 839 | { |
| 840 | - print '<td class="liste_titre">'; |
|
| 841 | - print '</td>'; |
|
| 840 | + print '<td class="liste_titre">'; |
|
| 841 | + print '</td>'; |
|
| 842 | 842 | } |
| 843 | 843 | // Date modification |
| 844 | 844 | if (! empty($arrayfields['f.tms']['checked'])) |
| 845 | 845 | { |
| 846 | - print '<td class="liste_titre">'; |
|
| 847 | - print '</td>'; |
|
| 846 | + print '<td class="liste_titre">'; |
|
| 847 | + print '</td>'; |
|
| 848 | 848 | } |
| 849 | 849 | // Status |
| 850 | 850 | if (! empty($arrayfields['f.fk_statut']['checked'])) |
| 851 | 851 | { |
| 852 | - print '<td class="liste_titre maxwidthonsmartphone" align="right">'; |
|
| 853 | - $liststatus=array('0'=>$langs->trans("Draft"),'1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); |
|
| 854 | - print $form->selectarray('search_status', $liststatus, $search_status, 1); |
|
| 855 | - print '</td>'; |
|
| 852 | + print '<td class="liste_titre maxwidthonsmartphone" align="right">'; |
|
| 853 | + $liststatus=array('0'=>$langs->trans("Draft"),'1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); |
|
| 854 | + print $form->selectarray('search_status', $liststatus, $search_status, 1); |
|
| 855 | + print '</td>'; |
|
| 856 | 856 | } |
| 857 | 857 | // Action column |
| 858 | 858 | print '<td class="liste_titre" align="middle">'; |
@@ -881,21 +881,21 @@ discard block |
||
| 881 | 881 | if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'],$_SERVER['PHP_SELF'],'f.localtax1','',$param,'align="right"',$sortfield,$sortorder); |
| 882 | 882 | if (! empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'],$_SERVER['PHP_SELF'],'f.localtax2','',$param,'align="right"',$sortfield,$sortorder); |
| 883 | 883 | if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],'f.total_ttc','',$param,'align="right"',$sortfield,$sortorder); |
| 884 | - if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); |
|
| 885 | - if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); |
|
| 884 | + if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); |
|
| 885 | + if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); |
|
| 886 | 886 | // Extra fields |
| 887 | 887 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 888 | 888 | { |
| 889 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 890 | - { |
|
| 891 | - if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 892 | - { |
|
| 893 | - $align=$extrafields->getAlignFlag($key); |
|
| 894 | - $sortonfield = "ef.".$key; |
|
| 895 | - if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; |
|
| 896 | - print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); |
|
| 897 | - } |
|
| 898 | - } |
|
| 889 | + foreach($extrafields->attribute_label as $key => $val) |
|
| 890 | + { |
|
| 891 | + if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 892 | + { |
|
| 893 | + $align=$extrafields->getAlignFlag($key); |
|
| 894 | + $sortonfield = "ef.".$key; |
|
| 895 | + if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; |
|
| 896 | + print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); |
|
| 897 | + } |
|
| 898 | + } |
|
| 899 | 899 | } |
| 900 | 900 | // Hook fields |
| 901 | 901 | $parameters=array('arrayfields'=>$arrayfields); |
@@ -907,16 +907,16 @@ discard block |
||
| 907 | 907 | print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); |
| 908 | 908 | print "</tr>\n"; |
| 909 | 909 | |
| 910 | - $facturestatic=new FactureFournisseur($db); |
|
| 910 | + $facturestatic=new FactureFournisseur($db); |
|
| 911 | 911 | $supplierstatic=new Fournisseur($db); |
| 912 | 912 | $projectstatic=new Project($db); |
| 913 | 913 | |
| 914 | 914 | if ($num > 0) |
| 915 | - { |
|
| 915 | + { |
|
| 916 | 916 | $i=0; |
| 917 | 917 | |
| 918 | 918 | $var=true; |
| 919 | - $totalarray=array(); |
|
| 919 | + $totalarray=array(); |
|
| 920 | 920 | while ($i < min($num,$limit)) |
| 921 | 921 | { |
| 922 | 922 | $obj = $db->fetch_object($resql); |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | $datelimit=$db->jdate($obj->datelimite); |
| 925 | 925 | $facturestatic->id=$obj->facid; |
| 926 | 926 | $facturestatic->ref=$obj->ref; |
| 927 | - $facturestatic->type=$obj->type; |
|
| 927 | + $facturestatic->type=$obj->type; |
|
| 928 | 928 | $facturestatic->ref_supplier=$obj->ref_supplier; |
| 929 | 929 | $facturestatic->date_echeance = $db->jdate($obj->datelimite); |
| 930 | 930 | $facturestatic->statut = $obj->fk_statut; |
@@ -935,271 +935,271 @@ discard block |
||
| 935 | 935 | $totalpay = $paiement + $totalcreditnotes + $totaldeposits; |
| 936 | 936 | $remaintopay = $obj->total_ttc - $totalpay; |
| 937 | 937 | |
| 938 | - print '<tr class="oddeven">'; |
|
| 939 | - if (! empty($arrayfields['f.ref']['checked'])) |
|
| 940 | - { |
|
| 941 | - print '<td class="nowrap">'; |
|
| 942 | - |
|
| 943 | - print '<table class="nobordernopadding"><tr class="nocellnopadd">'; |
|
| 944 | - // Picto + Ref |
|
| 945 | - print '<td class="nobordernopadding nowrap">'; |
|
| 946 | - print $facturestatic->getNomUrl(1); |
|
| 947 | - print '</td>'; |
|
| 948 | - // Warning |
|
| 949 | - //print '<td style="min-width: 20px" class="nobordernopadding nowrap">'; |
|
| 950 | - //print '</td>'; |
|
| 951 | - // Other picto tool |
|
| 952 | - print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">'; |
|
| 953 | - $filename=dol_sanitizeFileName($obj->ref); |
|
| 954 | - $filedir=$conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref); |
|
| 938 | + print '<tr class="oddeven">'; |
|
| 939 | + if (! empty($arrayfields['f.ref']['checked'])) |
|
| 940 | + { |
|
| 941 | + print '<td class="nowrap">'; |
|
| 942 | + |
|
| 943 | + print '<table class="nobordernopadding"><tr class="nocellnopadd">'; |
|
| 944 | + // Picto + Ref |
|
| 945 | + print '<td class="nobordernopadding nowrap">'; |
|
| 946 | + print $facturestatic->getNomUrl(1); |
|
| 947 | + print '</td>'; |
|
| 948 | + // Warning |
|
| 949 | + //print '<td style="min-width: 20px" class="nobordernopadding nowrap">'; |
|
| 950 | + //print '</td>'; |
|
| 951 | + // Other picto tool |
|
| 952 | + print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">'; |
|
| 953 | + $filename=dol_sanitizeFileName($obj->ref); |
|
| 954 | + $filedir=$conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref); |
|
| 955 | 955 | $subdir = get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref); |
| 956 | 956 | print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir); |
| 957 | 957 | print '</td></tr></table>'; |
| 958 | 958 | |
| 959 | - print "</td>\n"; |
|
| 959 | + print "</td>\n"; |
|
| 960 | 960 | if (! $i) $totalarray['nbfield']++; |
| 961 | - } |
|
| 961 | + } |
|
| 962 | 962 | |
| 963 | 963 | // Customer ref |
| 964 | - if (! empty($arrayfields['f.ref_supplier']['checked'])) |
|
| 965 | - { |
|
| 966 | - print '<td class="nowrap">'; |
|
| 967 | - print $obj->ref_supplier; |
|
| 968 | - print '</td>'; |
|
| 969 | - if (! $i) $totalarray['nbfield']++; |
|
| 970 | - } |
|
| 964 | + if (! empty($arrayfields['f.ref_supplier']['checked'])) |
|
| 965 | + { |
|
| 966 | + print '<td class="nowrap">'; |
|
| 967 | + print $obj->ref_supplier; |
|
| 968 | + print '</td>'; |
|
| 969 | + if (! $i) $totalarray['nbfield']++; |
|
| 970 | + } |
|
| 971 | 971 | |
| 972 | 972 | // Label |
| 973 | - if (! empty($arrayfields['f.label']['checked'])) |
|
| 974 | - { |
|
| 975 | - print '<td class="nowrap">'; |
|
| 976 | - print $obj->label; |
|
| 977 | - print '</td>'; |
|
| 978 | - if (! $i) $totalarray['nbfield']++; |
|
| 979 | - } |
|
| 973 | + if (! empty($arrayfields['f.label']['checked'])) |
|
| 974 | + { |
|
| 975 | + print '<td class="nowrap">'; |
|
| 976 | + print $obj->label; |
|
| 977 | + print '</td>'; |
|
| 978 | + if (! $i) $totalarray['nbfield']++; |
|
| 979 | + } |
|
| 980 | 980 | |
| 981 | 981 | // Date |
| 982 | - if (! empty($arrayfields['f.datef']['checked'])) |
|
| 983 | - { |
|
| 984 | - print '<td align="center" class="nowrap">'; |
|
| 985 | - print dol_print_date($db->jdate($obj->datef),'day'); |
|
| 986 | - print '</td>'; |
|
| 987 | - if (! $i) $totalarray['nbfield']++; |
|
| 988 | - } |
|
| 989 | - |
|
| 990 | - // Date limit |
|
| 991 | - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) |
|
| 992 | - { |
|
| 993 | - print '<td align="center" class="nowrap">'.dol_print_date($datelimit,'day'); |
|
| 994 | - if ($facturestatic->hasDelay()) |
|
| 995 | - { |
|
| 996 | - print img_warning($langs->trans('Late')); |
|
| 997 | - } |
|
| 998 | - print '</td>'; |
|
| 999 | - if (! $i) $totalarray['nbfield']++; |
|
| 1000 | - } |
|
| 1001 | - |
|
| 1002 | - // Project |
|
| 1003 | - if (! empty($arrayfields['p.ref']['checked'])) |
|
| 1004 | - { |
|
| 1005 | - print '<td class="nowrap">'; |
|
| 1006 | - if ($obj->project_id > 0) |
|
| 1007 | - { |
|
| 1008 | - $projectstatic->id=$obj->project_id; |
|
| 1009 | - $projectstatic->ref=$obj->project_ref; |
|
| 1010 | - print $projectstatic->getNomUrl(1); |
|
| 1011 | - } |
|
| 1012 | - print '</td>'; |
|
| 1013 | - if (! $i) $totalarray['nbfield']++; |
|
| 1014 | - } |
|
| 1015 | - |
|
| 1016 | - // Third party |
|
| 1017 | - if (! empty($arrayfields['s.nom']['checked'])) |
|
| 1018 | - { |
|
| 1019 | - print '<td class="tdoverflowmax200">'; |
|
| 1020 | - $thirdparty=new Societe($db); |
|
| 1021 | - $thirdparty->id=$obj->socid; |
|
| 1022 | - $thirdparty->name=$obj->name; |
|
| 1023 | - $thirdparty->client=$obj->client; |
|
| 1024 | - $thirdparty->code_client=$obj->code_client; |
|
| 1025 | - print $thirdparty->getNomUrl(1,'supplier'); |
|
| 1026 | - print '</td>'; |
|
| 1027 | - if (! $i) $totalarray['nbfield']++; |
|
| 1028 | - } |
|
| 1029 | - // Town |
|
| 1030 | - if (! empty($arrayfields['s.town']['checked'])) |
|
| 1031 | - { |
|
| 1032 | - print '<td class="nocellnopadd">'; |
|
| 1033 | - print $obj->town; |
|
| 1034 | - print '</td>'; |
|
| 1035 | - if (! $i) $totalarray['nbfield']++; |
|
| 1036 | - } |
|
| 1037 | - // Zip |
|
| 1038 | - if (! empty($arrayfields['s.zip']['checked'])) |
|
| 1039 | - { |
|
| 1040 | - print '<td class="nocellnopadd">'; |
|
| 1041 | - print $obj->zip; |
|
| 1042 | - print '</td>'; |
|
| 1043 | - if (! $i) $totalarray['nbfield']++; |
|
| 1044 | - } |
|
| 1045 | - // State |
|
| 1046 | - if (! empty($arrayfields['state.nom']['checked'])) |
|
| 1047 | - { |
|
| 1048 | - print "<td>".$obj->state_name."</td>\n"; |
|
| 1049 | - if (! $i) $totalarray['nbfield']++; |
|
| 1050 | - } |
|
| 1051 | - // Country |
|
| 1052 | - if (! empty($arrayfields['country.code_iso']['checked'])) |
|
| 1053 | - { |
|
| 1054 | - print '<td align="center">'; |
|
| 1055 | - $tmparray=getCountry($obj->fk_pays,'all'); |
|
| 1056 | - print $tmparray['label']; |
|
| 1057 | - print '</td>'; |
|
| 1058 | - if (! $i) $totalarray['nbfield']++; |
|
| 1059 | - } |
|
| 1060 | - // Type ent |
|
| 1061 | - if (! empty($arrayfields['typent.code']['checked'])) |
|
| 1062 | - { |
|
| 1063 | - print '<td align="center">'; |
|
| 1064 | - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); |
|
| 1065 | - print $typenArray[$obj->typent_code]; |
|
| 1066 | - print '</td>'; |
|
| 1067 | - if (! $i) $totalarray['nbfield']++; |
|
| 1068 | - } |
|
| 1069 | - |
|
| 1070 | - // Payment mode |
|
| 1071 | - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
| 1072 | - { |
|
| 1073 | - print '<td>'; |
|
| 1074 | - $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); |
|
| 1075 | - print '</td>'; |
|
| 1076 | - if (! $i) $totalarray['nbfield']++; |
|
| 1077 | - } |
|
| 1078 | - |
|
| 1079 | - // Amount HT |
|
| 1080 | - if (! empty($arrayfields['f.total_ht']['checked'])) |
|
| 1081 | - { |
|
| 1082 | - print '<td align="right">'.price($obj->total_ht)."</td>\n"; |
|
| 1083 | - if (! $i) $totalarray['nbfield']++; |
|
| 1084 | - if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield']; |
|
| 1085 | - $totalarray['totalht'] += $obj->total_ht; |
|
| 1086 | - } |
|
| 1087 | - // Amount VAT |
|
| 1088 | - if (! empty($arrayfields['f.total_vat']['checked'])) |
|
| 1089 | - { |
|
| 1090 | - print '<td align="right">'.price($obj->total_vat)."</td>\n"; |
|
| 1091 | - if (! $i) $totalarray['nbfield']++; |
|
| 1092 | - if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield']; |
|
| 1093 | - $totalarray['totalvat'] += $obj->total_vat; |
|
| 1094 | - } |
|
| 1095 | - // Amount LocalTax1 |
|
| 1096 | - if (! empty($arrayfields['f.total_localtax1']['checked'])) |
|
| 1097 | - { |
|
| 1098 | - print '<td align="right">'.price($obj->total_localtax1)."</td>\n"; |
|
| 1099 | - if (! $i) $totalarray['nbfield']++; |
|
| 1100 | - if (! $i) $totalarray['totallocaltax1field']=$totalarray['nbfield']; |
|
| 1101 | - $totalarray['totallocaltax1'] += $obj->total_localtax1; |
|
| 1102 | - } |
|
| 1103 | - // Amount LocalTax2 |
|
| 1104 | - if (! empty($arrayfields['f.total_localtax2']['checked'])) |
|
| 1105 | - { |
|
| 1106 | - print '<td align="right">'.price($obj->total_localtax2)."</td>\n"; |
|
| 1107 | - if (! $i) $totalarray['nbfield']++; |
|
| 1108 | - if (! $i) $totalarray['totallocaltax2field']=$totalarray['nbfield']; |
|
| 1109 | - $totalarray['totallocaltax2'] += $obj->total_localtax2; |
|
| 1110 | - } |
|
| 1111 | - // Amount TTC |
|
| 1112 | - if (! empty($arrayfields['f.total_ttc']['checked'])) |
|
| 1113 | - { |
|
| 1114 | - print '<td align="right">'.price($obj->total_ttc)."</td>\n"; |
|
| 1115 | - if (! $i) $totalarray['nbfield']++; |
|
| 1116 | - if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; |
|
| 1117 | - $totalarray['totalttc'] += $obj->total_ttc; |
|
| 1118 | - } |
|
| 1119 | - |
|
| 1120 | - if (! empty($arrayfields['dynamount_payed']['checked'])) |
|
| 1121 | - { |
|
| 1122 | - print '<td align="right">'.(! empty($totalpay)?price($totalpay,0,$langs):' ').'</td>'; // TODO Use a denormalized field |
|
| 1123 | - if (! $i) $totalarray['nbfield']++; |
|
| 1124 | - if (! $i) $totalarray['totalamfield']=$totalarray['nbfield']; |
|
| 1125 | - $totalarray['totalam'] += $totalpay; |
|
| 1126 | - } |
|
| 1127 | - |
|
| 1128 | - if (! empty($arrayfields['rtp']['checked'])) |
|
| 1129 | - { |
|
| 1130 | - print '<td align="right">'.(! empty($remaintopay)?price($remaintopay,0,$langs):' ').'</td>'; // TODO Use a denormalized field |
|
| 1131 | - if (! $i) $totalarray['nbfield']++; |
|
| 1132 | - if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield']; |
|
| 1133 | - $totalarray['totalrtp'] += $remaintopay; |
|
| 1134 | - } |
|
| 1135 | - |
|
| 1136 | - |
|
| 1137 | - // Extra fields |
|
| 1138 | - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
|
| 1139 | - { |
|
| 1140 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 1141 | - { |
|
| 1142 | - if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 1143 | - { |
|
| 1144 | - print '<td'; |
|
| 1145 | - $align=$extrafields->getAlignFlag($key); |
|
| 1146 | - if ($align) print ' align="'.$align.'"'; |
|
| 1147 | - print '>'; |
|
| 1148 | - $tmpkey='options_'.$key; |
|
| 1149 | - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); |
|
| 1150 | - print '</td>'; |
|
| 1151 | - if (! $i) $totalarray['nbfield']++; |
|
| 1152 | - } |
|
| 1153 | - } |
|
| 1154 | - } |
|
| 1155 | - // Fields from hook |
|
| 1156 | - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); |
|
| 1157 | - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook |
|
| 1158 | - print $hookmanager->resPrint; |
|
| 1159 | - // Date creation |
|
| 1160 | - if (! empty($arrayfields['f.datec']['checked'])) |
|
| 1161 | - { |
|
| 1162 | - print '<td align="center" class="nowrap">'; |
|
| 1163 | - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); |
|
| 1164 | - print '</td>'; |
|
| 1165 | - if (! $i) $totalarray['nbfield']++; |
|
| 1166 | - } |
|
| 1167 | - // Date modification |
|
| 1168 | - if (! empty($arrayfields['f.tms']['checked'])) |
|
| 1169 | - { |
|
| 1170 | - print '<td align="center" class="nowrap">'; |
|
| 1171 | - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); |
|
| 1172 | - print '</td>'; |
|
| 1173 | - if (! $i) $totalarray['nbfield']++; |
|
| 1174 | - } |
|
| 1175 | - // Status |
|
| 1176 | - if (! empty($arrayfields['f.fk_statut']['checked'])) |
|
| 1177 | - { |
|
| 1178 | - print '<td align="right" class="nowrap">'; |
|
| 1179 | - // TODO $paiement is not yet defined |
|
| 1180 | - print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type); |
|
| 1181 | - print "</td>"; |
|
| 1182 | - if (! $i) $totalarray['nbfield']++; |
|
| 1183 | - } |
|
| 1184 | - |
|
| 1185 | - // Action column |
|
| 1186 | - print '<td class="nowrap" align="center">'; |
|
| 1187 | - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
| 1188 | - { |
|
| 1189 | - $selected=0; |
|
| 1190 | - if (in_array($obj->facid, $arrayofselected)) $selected=1; |
|
| 1191 | - print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected?' checked="checked"':'').'>'; |
|
| 1192 | - } |
|
| 1193 | - print '</td>'; |
|
| 1194 | - if (! $i) $totalarray['nbfield']++; |
|
| 982 | + if (! empty($arrayfields['f.datef']['checked'])) |
|
| 983 | + { |
|
| 984 | + print '<td align="center" class="nowrap">'; |
|
| 985 | + print dol_print_date($db->jdate($obj->datef),'day'); |
|
| 986 | + print '</td>'; |
|
| 987 | + if (! $i) $totalarray['nbfield']++; |
|
| 988 | + } |
|
| 989 | + |
|
| 990 | + // Date limit |
|
| 991 | + if (! empty($arrayfields['f.date_lim_reglement']['checked'])) |
|
| 992 | + { |
|
| 993 | + print '<td align="center" class="nowrap">'.dol_print_date($datelimit,'day'); |
|
| 994 | + if ($facturestatic->hasDelay()) |
|
| 995 | + { |
|
| 996 | + print img_warning($langs->trans('Late')); |
|
| 997 | + } |
|
| 998 | + print '</td>'; |
|
| 999 | + if (! $i) $totalarray['nbfield']++; |
|
| 1000 | + } |
|
| 1001 | + |
|
| 1002 | + // Project |
|
| 1003 | + if (! empty($arrayfields['p.ref']['checked'])) |
|
| 1004 | + { |
|
| 1005 | + print '<td class="nowrap">'; |
|
| 1006 | + if ($obj->project_id > 0) |
|
| 1007 | + { |
|
| 1008 | + $projectstatic->id=$obj->project_id; |
|
| 1009 | + $projectstatic->ref=$obj->project_ref; |
|
| 1010 | + print $projectstatic->getNomUrl(1); |
|
| 1011 | + } |
|
| 1012 | + print '</td>'; |
|
| 1013 | + if (! $i) $totalarray['nbfield']++; |
|
| 1014 | + } |
|
| 1015 | + |
|
| 1016 | + // Third party |
|
| 1017 | + if (! empty($arrayfields['s.nom']['checked'])) |
|
| 1018 | + { |
|
| 1019 | + print '<td class="tdoverflowmax200">'; |
|
| 1020 | + $thirdparty=new Societe($db); |
|
| 1021 | + $thirdparty->id=$obj->socid; |
|
| 1022 | + $thirdparty->name=$obj->name; |
|
| 1023 | + $thirdparty->client=$obj->client; |
|
| 1024 | + $thirdparty->code_client=$obj->code_client; |
|
| 1025 | + print $thirdparty->getNomUrl(1,'supplier'); |
|
| 1026 | + print '</td>'; |
|
| 1027 | + if (! $i) $totalarray['nbfield']++; |
|
| 1028 | + } |
|
| 1029 | + // Town |
|
| 1030 | + if (! empty($arrayfields['s.town']['checked'])) |
|
| 1031 | + { |
|
| 1032 | + print '<td class="nocellnopadd">'; |
|
| 1033 | + print $obj->town; |
|
| 1034 | + print '</td>'; |
|
| 1035 | + if (! $i) $totalarray['nbfield']++; |
|
| 1036 | + } |
|
| 1037 | + // Zip |
|
| 1038 | + if (! empty($arrayfields['s.zip']['checked'])) |
|
| 1039 | + { |
|
| 1040 | + print '<td class="nocellnopadd">'; |
|
| 1041 | + print $obj->zip; |
|
| 1042 | + print '</td>'; |
|
| 1043 | + if (! $i) $totalarray['nbfield']++; |
|
| 1044 | + } |
|
| 1045 | + // State |
|
| 1046 | + if (! empty($arrayfields['state.nom']['checked'])) |
|
| 1047 | + { |
|
| 1048 | + print "<td>".$obj->state_name."</td>\n"; |
|
| 1049 | + if (! $i) $totalarray['nbfield']++; |
|
| 1050 | + } |
|
| 1051 | + // Country |
|
| 1052 | + if (! empty($arrayfields['country.code_iso']['checked'])) |
|
| 1053 | + { |
|
| 1054 | + print '<td align="center">'; |
|
| 1055 | + $tmparray=getCountry($obj->fk_pays,'all'); |
|
| 1056 | + print $tmparray['label']; |
|
| 1057 | + print '</td>'; |
|
| 1058 | + if (! $i) $totalarray['nbfield']++; |
|
| 1059 | + } |
|
| 1060 | + // Type ent |
|
| 1061 | + if (! empty($arrayfields['typent.code']['checked'])) |
|
| 1062 | + { |
|
| 1063 | + print '<td align="center">'; |
|
| 1064 | + if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); |
|
| 1065 | + print $typenArray[$obj->typent_code]; |
|
| 1066 | + print '</td>'; |
|
| 1067 | + if (! $i) $totalarray['nbfield']++; |
|
| 1068 | + } |
|
| 1069 | + |
|
| 1070 | + // Payment mode |
|
| 1071 | + if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
| 1072 | + { |
|
| 1073 | + print '<td>'; |
|
| 1074 | + $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); |
|
| 1075 | + print '</td>'; |
|
| 1076 | + if (! $i) $totalarray['nbfield']++; |
|
| 1077 | + } |
|
| 1078 | + |
|
| 1079 | + // Amount HT |
|
| 1080 | + if (! empty($arrayfields['f.total_ht']['checked'])) |
|
| 1081 | + { |
|
| 1082 | + print '<td align="right">'.price($obj->total_ht)."</td>\n"; |
|
| 1083 | + if (! $i) $totalarray['nbfield']++; |
|
| 1084 | + if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield']; |
|
| 1085 | + $totalarray['totalht'] += $obj->total_ht; |
|
| 1086 | + } |
|
| 1087 | + // Amount VAT |
|
| 1088 | + if (! empty($arrayfields['f.total_vat']['checked'])) |
|
| 1089 | + { |
|
| 1090 | + print '<td align="right">'.price($obj->total_vat)."</td>\n"; |
|
| 1091 | + if (! $i) $totalarray['nbfield']++; |
|
| 1092 | + if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield']; |
|
| 1093 | + $totalarray['totalvat'] += $obj->total_vat; |
|
| 1094 | + } |
|
| 1095 | + // Amount LocalTax1 |
|
| 1096 | + if (! empty($arrayfields['f.total_localtax1']['checked'])) |
|
| 1097 | + { |
|
| 1098 | + print '<td align="right">'.price($obj->total_localtax1)."</td>\n"; |
|
| 1099 | + if (! $i) $totalarray['nbfield']++; |
|
| 1100 | + if (! $i) $totalarray['totallocaltax1field']=$totalarray['nbfield']; |
|
| 1101 | + $totalarray['totallocaltax1'] += $obj->total_localtax1; |
|
| 1102 | + } |
|
| 1103 | + // Amount LocalTax2 |
|
| 1104 | + if (! empty($arrayfields['f.total_localtax2']['checked'])) |
|
| 1105 | + { |
|
| 1106 | + print '<td align="right">'.price($obj->total_localtax2)."</td>\n"; |
|
| 1107 | + if (! $i) $totalarray['nbfield']++; |
|
| 1108 | + if (! $i) $totalarray['totallocaltax2field']=$totalarray['nbfield']; |
|
| 1109 | + $totalarray['totallocaltax2'] += $obj->total_localtax2; |
|
| 1110 | + } |
|
| 1111 | + // Amount TTC |
|
| 1112 | + if (! empty($arrayfields['f.total_ttc']['checked'])) |
|
| 1113 | + { |
|
| 1114 | + print '<td align="right">'.price($obj->total_ttc)."</td>\n"; |
|
| 1115 | + if (! $i) $totalarray['nbfield']++; |
|
| 1116 | + if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; |
|
| 1117 | + $totalarray['totalttc'] += $obj->total_ttc; |
|
| 1118 | + } |
|
| 1119 | + |
|
| 1120 | + if (! empty($arrayfields['dynamount_payed']['checked'])) |
|
| 1121 | + { |
|
| 1122 | + print '<td align="right">'.(! empty($totalpay)?price($totalpay,0,$langs):' ').'</td>'; // TODO Use a denormalized field |
|
| 1123 | + if (! $i) $totalarray['nbfield']++; |
|
| 1124 | + if (! $i) $totalarray['totalamfield']=$totalarray['nbfield']; |
|
| 1125 | + $totalarray['totalam'] += $totalpay; |
|
| 1126 | + } |
|
| 1127 | + |
|
| 1128 | + if (! empty($arrayfields['rtp']['checked'])) |
|
| 1129 | + { |
|
| 1130 | + print '<td align="right">'.(! empty($remaintopay)?price($remaintopay,0,$langs):' ').'</td>'; // TODO Use a denormalized field |
|
| 1131 | + if (! $i) $totalarray['nbfield']++; |
|
| 1132 | + if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield']; |
|
| 1133 | + $totalarray['totalrtp'] += $remaintopay; |
|
| 1134 | + } |
|
| 1135 | + |
|
| 1136 | + |
|
| 1137 | + // Extra fields |
|
| 1138 | + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
|
| 1139 | + { |
|
| 1140 | + foreach($extrafields->attribute_label as $key => $val) |
|
| 1141 | + { |
|
| 1142 | + if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 1143 | + { |
|
| 1144 | + print '<td'; |
|
| 1145 | + $align=$extrafields->getAlignFlag($key); |
|
| 1146 | + if ($align) print ' align="'.$align.'"'; |
|
| 1147 | + print '>'; |
|
| 1148 | + $tmpkey='options_'.$key; |
|
| 1149 | + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); |
|
| 1150 | + print '</td>'; |
|
| 1151 | + if (! $i) $totalarray['nbfield']++; |
|
| 1152 | + } |
|
| 1153 | + } |
|
| 1154 | + } |
|
| 1155 | + // Fields from hook |
|
| 1156 | + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); |
|
| 1157 | + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook |
|
| 1158 | + print $hookmanager->resPrint; |
|
| 1159 | + // Date creation |
|
| 1160 | + if (! empty($arrayfields['f.datec']['checked'])) |
|
| 1161 | + { |
|
| 1162 | + print '<td align="center" class="nowrap">'; |
|
| 1163 | + print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); |
|
| 1164 | + print '</td>'; |
|
| 1165 | + if (! $i) $totalarray['nbfield']++; |
|
| 1166 | + } |
|
| 1167 | + // Date modification |
|
| 1168 | + if (! empty($arrayfields['f.tms']['checked'])) |
|
| 1169 | + { |
|
| 1170 | + print '<td align="center" class="nowrap">'; |
|
| 1171 | + print dol_print_date($db->jdate($obj->date_update), 'dayhour'); |
|
| 1172 | + print '</td>'; |
|
| 1173 | + if (! $i) $totalarray['nbfield']++; |
|
| 1174 | + } |
|
| 1175 | + // Status |
|
| 1176 | + if (! empty($arrayfields['f.fk_statut']['checked'])) |
|
| 1177 | + { |
|
| 1178 | + print '<td align="right" class="nowrap">'; |
|
| 1179 | + // TODO $paiement is not yet defined |
|
| 1180 | + print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type); |
|
| 1181 | + print "</td>"; |
|
| 1182 | + if (! $i) $totalarray['nbfield']++; |
|
| 1183 | + } |
|
| 1184 | + |
|
| 1185 | + // Action column |
|
| 1186 | + print '<td class="nowrap" align="center">'; |
|
| 1187 | + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
| 1188 | + { |
|
| 1189 | + $selected=0; |
|
| 1190 | + if (in_array($obj->facid, $arrayofselected)) $selected=1; |
|
| 1191 | + print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected?' checked="checked"':'').'>'; |
|
| 1192 | + } |
|
| 1193 | + print '</td>'; |
|
| 1194 | + if (! $i) $totalarray['nbfield']++; |
|
| 1195 | 1195 | |
| 1196 | 1196 | print "</tr>\n"; |
| 1197 | 1197 | |
| 1198 | 1198 | $i++; |
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | - // Show total line |
|
| 1202 | - if (isset($totalarray['totalhtfield']) |
|
| 1201 | + // Show total line |
|
| 1202 | + if (isset($totalarray['totalhtfield']) |
|
| 1203 | 1203 | || isset($totalarray['totalvatfield']) |
| 1204 | 1204 | || isset($totalarray['totallocaltax1field']) |
| 1205 | 1205 | || isset($totalarray['totallocaltax2field']) |
@@ -1207,29 +1207,29 @@ discard block |
||
| 1207 | 1207 | || isset($totalarray['totalamfield']) |
| 1208 | 1208 | || isset($totalarray['totalrtpfield']) |
| 1209 | 1209 | ) |
| 1210 | - { |
|
| 1211 | - print '<tr class="liste_total">'; |
|
| 1212 | - $i=0; |
|
| 1213 | - while ($i < $totalarray['nbfield']) |
|
| 1214 | - { |
|
| 1215 | - $i++; |
|
| 1216 | - if ($i == 1) |
|
| 1217 | - { |
|
| 1218 | - if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
| 1219 | - else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
| 1220 | - } |
|
| 1221 | - elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>'; |
|
| 1222 | - elseif ($totalarray['totalvatfield'] == $i) print '<td align="right">'.price($totalarray['totalvat']).'</td>'; |
|
| 1223 | - elseif ($totalarray['totallocaltax1field'] == $i) print '<td align="right">'.price($totalarray['totallocaltax1']).'</td>'; |
|
| 1224 | - elseif ($totalarray['totallocaltax2field'] == $i) print '<td align="right">'.price($totalarray['totallocaltax2']).'</td>'; |
|
| 1225 | - elseif ($totalarray['totalttcfield'] == $i) print '<td align="right">'.price($totalarray['totalttc']).'</td>'; |
|
| 1226 | - elseif ($totalarray['totalamfield'] == $i) print '<td align="right">'.price($totalarray['totalam']).'</td>'; |
|
| 1227 | - elseif ($totalarray['totalrtpfield'] == $i) print '<td align="right">'.price($totalarray['totalrtp']).'</td>'; |
|
| 1228 | - else print '<td></td>'; |
|
| 1229 | - } |
|
| 1230 | - print '</tr>'; |
|
| 1231 | - |
|
| 1232 | - } |
|
| 1210 | + { |
|
| 1211 | + print '<tr class="liste_total">'; |
|
| 1212 | + $i=0; |
|
| 1213 | + while ($i < $totalarray['nbfield']) |
|
| 1214 | + { |
|
| 1215 | + $i++; |
|
| 1216 | + if ($i == 1) |
|
| 1217 | + { |
|
| 1218 | + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
| 1219 | + else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
| 1220 | + } |
|
| 1221 | + elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>'; |
|
| 1222 | + elseif ($totalarray['totalvatfield'] == $i) print '<td align="right">'.price($totalarray['totalvat']).'</td>'; |
|
| 1223 | + elseif ($totalarray['totallocaltax1field'] == $i) print '<td align="right">'.price($totalarray['totallocaltax1']).'</td>'; |
|
| 1224 | + elseif ($totalarray['totallocaltax2field'] == $i) print '<td align="right">'.price($totalarray['totallocaltax2']).'</td>'; |
|
| 1225 | + elseif ($totalarray['totalttcfield'] == $i) print '<td align="right">'.price($totalarray['totalttc']).'</td>'; |
|
| 1226 | + elseif ($totalarray['totalamfield'] == $i) print '<td align="right">'.price($totalarray['totalam']).'</td>'; |
|
| 1227 | + elseif ($totalarray['totalrtpfield'] == $i) print '<td align="right">'.price($totalarray['totalrtp']).'</td>'; |
|
| 1228 | + else print '<td></td>'; |
|
| 1229 | + } |
|
| 1230 | + print '</tr>'; |
|
| 1231 | + |
|
| 1232 | + } |
|
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | $db->free($resql); |
@@ -1239,11 +1239,11 @@ discard block |
||
| 1239 | 1239 | print $hookmanager->resPrint; |
| 1240 | 1240 | |
| 1241 | 1241 | print "</table>\n"; |
| 1242 | - print '</div>'; |
|
| 1242 | + print '</div>'; |
|
| 1243 | 1243 | |
| 1244 | 1244 | print "</form>\n"; |
| 1245 | 1245 | |
| 1246 | - /* |
|
| 1246 | + /* |
|
| 1247 | 1247 | if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) |
| 1248 | 1248 | { |
| 1249 | 1249 | // Show list of available documents |
@@ -49,81 +49,81 @@ discard block |
||
| 49 | 49 | $langs->load('products'); |
| 50 | 50 | $langs->load('projects'); |
| 51 | 51 | |
| 52 | -$action=GETPOST('action','alpha'); |
|
| 53 | -$massaction=GETPOST('massaction','alpha'); |
|
| 54 | -$show_files=GETPOST('show_files','int'); |
|
| 55 | -$confirm=GETPOST('confirm','alpha'); |
|
| 52 | +$action = GETPOST('action', 'alpha'); |
|
| 53 | +$massaction = GETPOST('massaction', 'alpha'); |
|
| 54 | +$show_files = GETPOST('show_files', 'int'); |
|
| 55 | +$confirm = GETPOST('confirm', 'alpha'); |
|
| 56 | 56 | $toselect = GETPOST('toselect', 'array'); |
| 57 | 57 | |
| 58 | -$socid = GETPOST('socid','int'); |
|
| 58 | +$socid = GETPOST('socid', 'int'); |
|
| 59 | 59 | |
| 60 | 60 | // Security check |
| 61 | 61 | if ($user->societe_id > 0) |
| 62 | 62 | { |
| 63 | - $action=''; |
|
| 63 | + $action = ''; |
|
| 64 | 64 | $_GET["action"] = ''; |
| 65 | 65 | $socid = $user->societe_id; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | -$mode=GETPOST("mode"); |
|
| 69 | - |
|
| 70 | -$search_product_category=GETPOST('search_product_category','int'); |
|
| 71 | -$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha'); |
|
| 72 | -$search_refsupplier=GETPOST('search_refsupplier','alpha'); |
|
| 73 | -$search_project=GETPOST('search_project','alpha'); |
|
| 74 | -$search_societe=GETPOST('search_societe','alpha'); |
|
| 75 | -$search_montant_ht=GETPOST('search_montant_ht','alpha'); |
|
| 76 | -$search_montant_vat=GETPOST('search_montant_vat','alpha'); |
|
| 77 | -$search_montant_localtax1=GETPOST('search_montant_localtax1','alpha'); |
|
| 78 | -$search_montant_localtax2=GETPOST('search_montant_localtax2','alpha'); |
|
| 79 | -$search_montant_ttc=GETPOST('search_montant_ttc','alpha'); |
|
| 80 | -$search_status=GETPOST('search_status','int'); |
|
| 81 | -$search_paymentmode=GETPOST('search_paymentmode','int'); |
|
| 82 | -$search_town=GETPOST('search_town','alpha'); |
|
| 83 | -$search_zip=GETPOST('search_zip','alpha'); |
|
| 84 | -$search_state=trim(GETPOST("search_state")); |
|
| 85 | -$search_country=GETPOST("search_country",'int'); |
|
| 86 | -$search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); |
|
| 87 | -$search_user = GETPOST('search_user','int'); |
|
| 88 | -$search_sale = GETPOST('search_sale','int'); |
|
| 89 | -$day = GETPOST('day','int'); |
|
| 90 | -$month = GETPOST('month','int'); |
|
| 91 | -$year = GETPOST('year','int'); |
|
| 92 | -$day_lim = GETPOST('day_lim','int'); |
|
| 93 | -$month_lim = GETPOST('month_lim','int'); |
|
| 94 | -$year_lim = GETPOST('year_lim','int'); |
|
| 68 | +$mode = GETPOST("mode"); |
|
| 69 | + |
|
| 70 | +$search_product_category = GETPOST('search_product_category', 'int'); |
|
| 71 | +$search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); |
|
| 72 | +$search_refsupplier = GETPOST('search_refsupplier', 'alpha'); |
|
| 73 | +$search_project = GETPOST('search_project', 'alpha'); |
|
| 74 | +$search_societe = GETPOST('search_societe', 'alpha'); |
|
| 75 | +$search_montant_ht = GETPOST('search_montant_ht', 'alpha'); |
|
| 76 | +$search_montant_vat = GETPOST('search_montant_vat', 'alpha'); |
|
| 77 | +$search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha'); |
|
| 78 | +$search_montant_localtax2 = GETPOST('search_montant_localtax2', 'alpha'); |
|
| 79 | +$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); |
|
| 80 | +$search_status = GETPOST('search_status', 'int'); |
|
| 81 | +$search_paymentmode = GETPOST('search_paymentmode', 'int'); |
|
| 82 | +$search_town = GETPOST('search_town', 'alpha'); |
|
| 83 | +$search_zip = GETPOST('search_zip', 'alpha'); |
|
| 84 | +$search_state = trim(GETPOST("search_state")); |
|
| 85 | +$search_country = GETPOST("search_country", 'int'); |
|
| 86 | +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); |
|
| 87 | +$search_user = GETPOST('search_user', 'int'); |
|
| 88 | +$search_sale = GETPOST('search_sale', 'int'); |
|
| 89 | +$day = GETPOST('day', 'int'); |
|
| 90 | +$month = GETPOST('month', 'int'); |
|
| 91 | +$year = GETPOST('year', 'int'); |
|
| 92 | +$day_lim = GETPOST('day_lim', 'int'); |
|
| 93 | +$month_lim = GETPOST('month_lim', 'int'); |
|
| 94 | +$year_lim = GETPOST('year_lim', 'int'); |
|
| 95 | 95 | $toselect = GETPOST('toselect', 'array'); |
| 96 | 96 | |
| 97 | 97 | $option = GETPOST('option'); |
| 98 | 98 | if ($option == 'late') $filter = 'paye:0'; |
| 99 | 99 | |
| 100 | 100 | $search_all = GETPOST('sall', 'alphanohtml'); |
| 101 | -$search_label = GETPOST("search_label","alpha"); |
|
| 102 | -$search_company = GETPOST("search_company","alpha"); |
|
| 103 | -$search_amount_no_tax = GETPOST("search_amount_no_tax","alpha"); |
|
| 104 | -$search_amount_all_tax = GETPOST("search_amount_all_tax","alpha"); |
|
| 105 | -$search_status=GETPOST('search_status','alpha'); |
|
| 106 | -$optioncss = GETPOST('optioncss','alpha'); |
|
| 107 | - |
|
| 108 | -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; |
|
| 109 | -$sortfield = GETPOST("sortfield",'alpha'); |
|
| 110 | -$sortorder = GETPOST("sortorder",'alpha'); |
|
| 111 | -$page=GETPOST("page",'int'); |
|
| 112 | -if ($page == -1 || $page == null) { $page = 0 ; } |
|
| 113 | -$offset = $limit * $page ; |
|
| 101 | +$search_label = GETPOST("search_label", "alpha"); |
|
| 102 | +$search_company = GETPOST("search_company", "alpha"); |
|
| 103 | +$search_amount_no_tax = GETPOST("search_amount_no_tax", "alpha"); |
|
| 104 | +$search_amount_all_tax = GETPOST("search_amount_all_tax", "alpha"); |
|
| 105 | +$search_status = GETPOST('search_status', 'alpha'); |
|
| 106 | +$optioncss = GETPOST('optioncss', 'alpha'); |
|
| 107 | + |
|
| 108 | +$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; |
|
| 109 | +$sortfield = GETPOST("sortfield", 'alpha'); |
|
| 110 | +$sortorder = GETPOST("sortorder", 'alpha'); |
|
| 111 | +$page = GETPOST("page", 'int'); |
|
| 112 | +if ($page == -1 || $page == null) { $page = 0; } |
|
| 113 | +$offset = $limit * $page; |
|
| 114 | 114 | $pageprev = $page - 1; |
| 115 | 115 | $pagenext = $page + 1; |
| 116 | -if (! $sortorder) $sortorder="DESC"; |
|
| 117 | -if (! $sortfield) $sortfield="f.datef,f.rowid"; |
|
| 116 | +if (!$sortorder) $sortorder = "DESC"; |
|
| 117 | +if (!$sortfield) $sortfield = "f.datef,f.rowid"; |
|
| 118 | 118 | |
| 119 | 119 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
| 120 | -$contextpage='supplierinvoicelist'; |
|
| 120 | +$contextpage = 'supplierinvoicelist'; |
|
| 121 | 121 | |
| 122 | -$diroutputmassaction=$conf->fournisseur->facture->dir_output . '/temp/massgeneration/'.$user->id; |
|
| 122 | +$diroutputmassaction = $conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id; |
|
| 123 | 123 | |
| 124 | -$object=new FactureFournisseur($db); |
|
| 124 | +$object = new FactureFournisseur($db); |
|
| 125 | 125 | |
| 126 | -$now=dol_now(); |
|
| 126 | +$now = dol_now(); |
|
| 127 | 127 | |
| 128 | 128 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
| 129 | 129 | $hookmanager->initHooks(array('supplierinvoicelist')); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | // fetch optionals attributes and labels |
| 133 | 133 | $extralabels = $extrafields->fetch_name_optionals_label('facture_fourn'); |
| 134 | -$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); |
|
| 134 | +$search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_'); |
|
| 135 | 135 | |
| 136 | 136 | // List of fields to search into when doing a "search in all" |
| 137 | 137 | $fieldstosearchall = array( |
@@ -141,10 +141,10 @@ discard block |
||
| 141 | 141 | 's.nom'=>"ThirdParty", |
| 142 | 142 | 'f.note_public'=>'NotePublic', |
| 143 | 143 | ); |
| 144 | -if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate"; |
|
| 144 | +if (empty($user->socid)) $fieldstosearchall["f.note_private"] = "NotePrivate"; |
|
| 145 | 145 | |
| 146 | -$checkedtypetiers=0; |
|
| 147 | -$arrayfields=array( |
|
| 146 | +$checkedtypetiers = 0; |
|
| 147 | +$arrayfields = array( |
|
| 148 | 148 | 'f.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), |
| 149 | 149 | 'f.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1), |
| 150 | 150 | 'f.label'=>array('label'=>$langs->trans("Label"), 'checked'=>0), |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | 'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), |
| 161 | 161 | 'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), |
| 162 | 162 | 'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), |
| 163 | - 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax1_assuj=="1"), |
|
| 164 | - 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax2_assuj=="1"), |
|
| 163 | + 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax1_assuj == "1"), |
|
| 164 | + 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax2_assuj == "1"), |
|
| 165 | 165 | 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), |
| 166 | 166 | 'dynamount_payed'=>array('label'=>$langs->trans("Payed"), 'checked'=>0), |
| 167 | 167 | 'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0), |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | // Extra fields |
| 173 | 173 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 174 | 174 | { |
| 175 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 175 | + foreach ($extrafields->attribute_label as $key => $val) |
|
| 176 | 176 | { |
| 177 | - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); |
|
| 177 | + $arrayfields["ef.".$key] = array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
@@ -183,59 +183,59 @@ discard block |
||
| 183 | 183 | * Actions |
| 184 | 184 | */ |
| 185 | 185 | |
| 186 | -if (GETPOST('cancel')) { $action='list'; $massaction=''; } |
|
| 187 | -if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } |
|
| 186 | +if (GETPOST('cancel')) { $action = 'list'; $massaction = ''; } |
|
| 187 | +if (!GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } |
|
| 188 | 188 | |
| 189 | -$parameters=array('socid'=>$socid); |
|
| 190 | -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 189 | +$parameters = array('socid'=>$socid); |
|
| 190 | +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
| 191 | 191 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
| 192 | 192 | |
| 193 | 193 | if (empty($reshook)) |
| 194 | 194 | { |
| 195 | 195 | include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
| 196 | 196 | |
| 197 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha') || GETPOST('button_removefilter.x','alpha')) // All tests must be present to be compatible with all browsers |
|
| 197 | + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha')) // All tests must be present to be compatible with all browsers |
|
| 198 | 198 | { |
| 199 | - $search_all=""; |
|
| 200 | - $search_user=''; |
|
| 201 | - $search_sale=''; |
|
| 202 | - $search_product_category=''; |
|
| 203 | - $search_ref=""; |
|
| 204 | - $search_refsupplier=""; |
|
| 205 | - $search_label=""; |
|
| 206 | - $search_project=''; |
|
| 207 | - $search_societe=""; |
|
| 208 | - $search_company=""; |
|
| 209 | - $search_amount_no_tax=""; |
|
| 210 | - $search_amount_all_tax=""; |
|
| 211 | - $search_montant_ht=''; |
|
| 212 | - $search_montant_vat=''; |
|
| 213 | - $search_montant_localtax1=''; |
|
| 214 | - $search_montant_localtax2=''; |
|
| 215 | - $search_montant_ttc=''; |
|
| 216 | - $search_status=''; |
|
| 217 | - $search_paymentmode=''; |
|
| 218 | - $search_town=''; |
|
| 219 | - $search_zip=""; |
|
| 220 | - $search_state=""; |
|
| 221 | - $search_type=''; |
|
| 222 | - $search_country=''; |
|
| 223 | - $search_type_thirdparty=''; |
|
| 224 | - $year=""; |
|
| 225 | - $month=""; |
|
| 226 | - $day=""; |
|
| 227 | - $year_lim=""; |
|
| 228 | - $month_lim=""; |
|
| 229 | - $day_lim=""; |
|
| 230 | - $toselect=''; |
|
| 231 | - $search_array_options=array(); |
|
| 232 | - $filter=''; |
|
| 233 | - $option=''; |
|
| 199 | + $search_all = ""; |
|
| 200 | + $search_user = ''; |
|
| 201 | + $search_sale = ''; |
|
| 202 | + $search_product_category = ''; |
|
| 203 | + $search_ref = ""; |
|
| 204 | + $search_refsupplier = ""; |
|
| 205 | + $search_label = ""; |
|
| 206 | + $search_project = ''; |
|
| 207 | + $search_societe = ""; |
|
| 208 | + $search_company = ""; |
|
| 209 | + $search_amount_no_tax = ""; |
|
| 210 | + $search_amount_all_tax = ""; |
|
| 211 | + $search_montant_ht = ''; |
|
| 212 | + $search_montant_vat = ''; |
|
| 213 | + $search_montant_localtax1 = ''; |
|
| 214 | + $search_montant_localtax2 = ''; |
|
| 215 | + $search_montant_ttc = ''; |
|
| 216 | + $search_status = ''; |
|
| 217 | + $search_paymentmode = ''; |
|
| 218 | + $search_town = ''; |
|
| 219 | + $search_zip = ""; |
|
| 220 | + $search_state = ""; |
|
| 221 | + $search_type = ''; |
|
| 222 | + $search_country = ''; |
|
| 223 | + $search_type_thirdparty = ''; |
|
| 224 | + $year = ""; |
|
| 225 | + $month = ""; |
|
| 226 | + $day = ""; |
|
| 227 | + $year_lim = ""; |
|
| 228 | + $month_lim = ""; |
|
| 229 | + $day_lim = ""; |
|
| 230 | + $toselect = ''; |
|
| 231 | + $search_array_options = array(); |
|
| 232 | + $filter = ''; |
|
| 233 | + $option = ''; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // Mass actions |
| 237 | - $objectclass='FactureFournisseur'; |
|
| 238 | - $objectlabel='SupplierInvoices'; |
|
| 237 | + $objectclass = 'FactureFournisseur'; |
|
| 238 | + $objectlabel = 'SupplierInvoices'; |
|
| 239 | 239 | $permtoread = $user->rights->fournisseur->facture->lire; |
| 240 | 240 | $permtocreate = $user->rights->fournisseur->facture->creer; |
| 241 | 241 | $permtodelete = $user->rights->fournisseur->facture->supprimer; |
@@ -248,54 +248,54 @@ discard block |
||
| 248 | 248 | * View |
| 249 | 249 | */ |
| 250 | 250 | |
| 251 | -$form=new Form($db); |
|
| 252 | -$formother=new FormOther($db); |
|
| 251 | +$form = new Form($db); |
|
| 252 | +$formother = new FormOther($db); |
|
| 253 | 253 | $formfile = new FormFile($db); |
| 254 | -$bankaccountstatic=new Account($db); |
|
| 255 | -$facturestatic=new FactureFournisseur($db); |
|
| 256 | -$formcompany=new FormCompany($db); |
|
| 254 | +$bankaccountstatic = new Account($db); |
|
| 255 | +$facturestatic = new FactureFournisseur($db); |
|
| 256 | +$formcompany = new FormCompany($db); |
|
| 257 | 257 | |
| 258 | -llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); |
|
| 258 | +llxHeader('', $langs->trans("SuppliersInvoices"), 'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); |
|
| 259 | 259 | |
| 260 | 260 | $sql = "SELECT"; |
| 261 | 261 | if ($search_all || $search_product_category > 0) $sql = 'SELECT DISTINCT'; |
| 262 | -$sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement,"; |
|
| 263 | -$sql.= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_update,"; |
|
| 264 | -$sql.= " f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,"; |
|
| 265 | -$sql.= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,"; |
|
| 266 | -$sql.= " typent.code as typent_code,"; |
|
| 267 | -$sql.= " state.code_departement as state_code, state.nom as state_name,"; |
|
| 268 | -$sql.= " p.rowid as project_id, p.ref as project_ref"; |
|
| 262 | +$sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement,"; |
|
| 263 | +$sql .= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_update,"; |
|
| 264 | +$sql .= " f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,"; |
|
| 265 | +$sql .= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,"; |
|
| 266 | +$sql .= " typent.code as typent_code,"; |
|
| 267 | +$sql .= " state.code_departement as state_code, state.nom as state_name,"; |
|
| 268 | +$sql .= " p.rowid as project_id, p.ref as project_ref"; |
|
| 269 | 269 | // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) |
| 270 | 270 | // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. |
| 271 | -if (! $search_all) $sql.= ', SUM(pf.amount) as dynamount_payed'; |
|
| 271 | +if (!$search_all) $sql .= ', SUM(pf.amount) as dynamount_payed'; |
|
| 272 | 272 | // Add fields from extrafields |
| 273 | -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); |
|
| 273 | +foreach ($extrafields->attribute_label as $key => $val) $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); |
|
| 274 | 274 | // Add fields from hooks |
| 275 | -$parameters=array(); |
|
| 276 | -$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook |
|
| 277 | -$sql.=$hookmanager->resPrint; |
|
| 278 | -$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; |
|
| 279 | -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; |
|
| 280 | -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; |
|
| 281 | -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; |
|
| 282 | -$sql.= ', '.MAIN_DB_PREFIX.'facture_fourn as f'; |
|
| 283 | -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn_extrafields as ef on (f.rowid = ef.fk_object)"; |
|
| 284 | -if (! $search_all) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; |
|
| 285 | -if ($search_all || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn'; |
|
| 286 | -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; |
|
| 287 | -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; |
|
| 275 | +$parameters = array(); |
|
| 276 | +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook |
|
| 277 | +$sql .= $hookmanager->resPrint; |
|
| 278 | +$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; |
|
| 279 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; |
|
| 280 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; |
|
| 281 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; |
|
| 282 | +$sql .= ', '.MAIN_DB_PREFIX.'facture_fourn as f'; |
|
| 283 | +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn_extrafields as ef on (f.rowid = ef.fk_object)"; |
|
| 284 | +if (!$search_all) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; |
|
| 285 | +if ($search_all || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn'; |
|
| 286 | +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; |
|
| 287 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; |
|
| 288 | 288 | // We'll need this table joined to the select in order to filter by sale |
| 289 | -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 289 | +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 290 | 290 | if ($search_user > 0) |
| 291 | 291 | { |
| 292 | - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; |
|
| 293 | - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 292 | + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; |
|
| 293 | + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; |
|
| 294 | 294 | } |
| 295 | -$sql.= ' WHERE f.fk_soc = s.rowid'; |
|
| 296 | -$sql.= ' AND f.entity IN ('.getEntity('facture_fourn').')'; |
|
| 297 | -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 298 | -if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; |
|
| 295 | +$sql .= ' WHERE f.fk_soc = s.rowid'; |
|
| 296 | +$sql .= ' AND f.entity IN ('.getEntity('facture_fourn').')'; |
|
| 297 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 298 | +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; |
|
| 299 | 299 | if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; |
| 300 | 300 | if ($search_ref) |
| 301 | 301 | { |
@@ -306,51 +306,51 @@ discard block |
||
| 306 | 306 | if ($search_refsupplier) $sql .= natural_search('f.ref_supplier', $search_refsupplier); |
| 307 | 307 | if ($search_project) $sql .= natural_search('p.ref', $search_project); |
| 308 | 308 | if ($search_societe) $sql .= natural_search('s.nom', $search_societe); |
| 309 | -if ($search_town) $sql.= natural_search('s.town', $search_town); |
|
| 310 | -if ($search_zip) $sql.= natural_search("s.zip",$search_zip); |
|
| 311 | -if ($search_state) $sql.= natural_search("state.nom",$search_state); |
|
| 309 | +if ($search_town) $sql .= natural_search('s.town', $search_town); |
|
| 310 | +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); |
|
| 311 | +if ($search_state) $sql .= natural_search("state.nom", $search_state); |
|
| 312 | 312 | if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; |
| 313 | 313 | if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; |
| 314 | 314 | if ($search_company) $sql .= natural_search('s.nom', $search_company); |
| 315 | -if ($search_montant_ht != '') $sql.= natural_search('f.total_ht', $search_montant_ht, 1); |
|
| 316 | -if ($search_montant_vat != '') $sql.= natural_search('f.total_tva', $search_montant_vat, 1); |
|
| 317 | -if ($search_montant_localtax1 != '') $sql.= natural_search('f.localtax1', $search_montant_localtax1, 1); |
|
| 318 | -if ($search_montant_localtax2 != '') $sql.= natural_search('f.localtax2', $search_montant_localtax2, 1); |
|
| 319 | -if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); |
|
| 320 | -if ($search_status != '' && $search_status >= 0) $sql.= " AND f.fk_statut = ".$db->escape($search_status); |
|
| 315 | +if ($search_montant_ht != '') $sql .= natural_search('f.total_ht', $search_montant_ht, 1); |
|
| 316 | +if ($search_montant_vat != '') $sql .= natural_search('f.total_tva', $search_montant_vat, 1); |
|
| 317 | +if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1); |
|
| 318 | +if ($search_montant_localtax2 != '') $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1); |
|
| 319 | +if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); |
|
| 320 | +if ($search_status != '' && $search_status >= 0) $sql .= " AND f.fk_statut = ".$db->escape($search_status); |
|
| 321 | 321 | if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode.""; |
| 322 | 322 | if ($month > 0) |
| 323 | 323 | { |
| 324 | 324 | if ($year > 0 && empty($day)) |
| 325 | - $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; |
|
| 326 | - else if ($year > 0 && ! empty($day)) |
|
| 327 | - $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; |
|
| 325 | + $sql .= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year, $month, false))."' AND '".$db->idate(dol_get_last_day($year, $month, false))."'"; |
|
| 326 | + else if ($year > 0 && !empty($day)) |
|
| 327 | + $sql .= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; |
|
| 328 | 328 | else |
| 329 | - $sql.= " AND date_format(f.datef, '%m') = '".$month."'"; |
|
| 329 | + $sql .= " AND date_format(f.datef, '%m') = '".$month."'"; |
|
| 330 | 330 | } |
| 331 | 331 | else if ($year > 0) |
| 332 | 332 | { |
| 333 | - $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; |
|
| 333 | + $sql .= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; |
|
| 334 | 334 | } |
| 335 | 335 | if ($month_lim > 0) |
| 336 | 336 | { |
| 337 | 337 | if ($year_lim > 0 && empty($day_lim)) |
| 338 | - $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,$month_lim,false))."' AND '".$db->idate(dol_get_last_day($year_lim,$month_lim,false))."'"; |
|
| 339 | - else if ($year_lim > 0 && ! empty($day_lim)) |
|
| 340 | - $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_lim, $day_lim, $year_lim))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_lim, $day_lim, $year_lim))."'"; |
|
| 338 | + $sql .= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim, $month_lim, false))."' AND '".$db->idate(dol_get_last_day($year_lim, $month_lim, false))."'"; |
|
| 339 | + else if ($year_lim > 0 && !empty($day_lim)) |
|
| 340 | + $sql .= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_lim, $day_lim, $year_lim))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_lim, $day_lim, $year_lim))."'"; |
|
| 341 | 341 | else |
| 342 | - $sql.= " AND date_format(f.date_lim_reglement, '%m') = '".$db->escape($month_lim)."'"; |
|
| 342 | + $sql .= " AND date_format(f.date_lim_reglement, '%m') = '".$db->escape($month_lim)."'"; |
|
| 343 | 343 | } |
| 344 | 344 | else if ($year_lim > 0) |
| 345 | 345 | { |
| 346 | - $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($year_lim,12,false))."'"; |
|
| 346 | + $sql .= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim, 1, false))."' AND '".$db->idate(dol_get_last_day($year_lim, 12, false))."'"; |
|
| 347 | 347 | } |
| 348 | -if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'"; |
|
| 349 | -if ($filter == 'paye:0') $sql.= " AND f.fk_statut = 1"; |
|
| 348 | +if ($option == 'late') $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'"; |
|
| 349 | +if ($filter == 'paye:0') $sql .= " AND f.fk_statut = 1"; |
|
| 350 | 350 | if ($search_label) $sql .= natural_search('f.libelle', $search_label); |
| 351 | 351 | if ($search_status != '' && $search_status >= 0) |
| 352 | 352 | { |
| 353 | - $sql.= " AND f.fk_statut = ".$search_status; |
|
| 353 | + $sql .= " AND f.fk_statut = ".$search_status; |
|
| 354 | 354 | } |
| 355 | 355 | if ($filter && $filter != -1) |
| 356 | 356 | { |
@@ -358,53 +358,53 @@ discard block |
||
| 358 | 358 | foreach ($aFilter as $fil) |
| 359 | 359 | { |
| 360 | 360 | $filt = explode(':', $fil); |
| 361 | - $sql .= ' AND ' . trim($filt[0]) . ' = ' . trim($filt[1]); |
|
| 361 | + $sql .= ' AND '.trim($filt[0]).' = '.trim($filt[1]); |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; |
|
| 364 | +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; |
|
| 365 | 365 | if ($search_user > 0) |
| 366 | 366 | { |
| 367 | - $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; |
|
| 367 | + $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; |
|
| 368 | 368 | } |
| 369 | 369 | // Add where from extra fields |
| 370 | 370 | foreach ($search_array_options as $key => $val) |
| 371 | 371 | { |
| 372 | - $crit=$val; |
|
| 373 | - $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 374 | - $typ=$extrafields->attribute_type[$tmpkey]; |
|
| 375 | - $mode=0; |
|
| 376 | - if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric |
|
| 377 | - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) |
|
| 372 | + $crit = $val; |
|
| 373 | + $tmpkey = preg_replace('/search_options_/', '', $key); |
|
| 374 | + $typ = $extrafields->attribute_type[$tmpkey]; |
|
| 375 | + $mode = 0; |
|
| 376 | + if (in_array($typ, array('int', 'double'))) $mode = 1; // Search on a numeric |
|
| 377 | + if ($val && (($crit != '' && !in_array($typ, array('select'))) || !empty($crit))) |
|
| 378 | 378 | { |
| 379 | 379 | $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); |
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | // Add where from hooks |
| 383 | -$parameters=array(); |
|
| 384 | -$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook |
|
| 385 | -$sql.=$hookmanager->resPrint; |
|
| 383 | +$parameters = array(); |
|
| 384 | +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook |
|
| 385 | +$sql .= $hookmanager->resPrint; |
|
| 386 | 386 | |
| 387 | -if (! $search_all) |
|
| 387 | +if (!$search_all) |
|
| 388 | 388 | { |
| 389 | - $sql.= " GROUP BY f.rowid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement, f.fk_mode_reglement,"; |
|
| 390 | - $sql.= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; |
|
| 391 | - $sql.= " f.localtax1, f.localtax2,"; |
|
| 392 | - $sql.= " s.rowid, s.nom, s.town, s.zip, s.fk_pays, s.client, s.code_client,"; |
|
| 393 | - $sql.= " typent.code,"; |
|
| 394 | - $sql.= " state.code_departement, state.nom,"; |
|
| 395 | - $sql.= " p.rowid, p.ref"; |
|
| 389 | + $sql .= " GROUP BY f.rowid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement, f.fk_mode_reglement,"; |
|
| 390 | + $sql .= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; |
|
| 391 | + $sql .= " f.localtax1, f.localtax2,"; |
|
| 392 | + $sql .= " s.rowid, s.nom, s.town, s.zip, s.fk_pays, s.client, s.code_client,"; |
|
| 393 | + $sql .= " typent.code,"; |
|
| 394 | + $sql .= " state.code_departement, state.nom,"; |
|
| 395 | + $sql .= " p.rowid, p.ref"; |
|
| 396 | 396 | |
| 397 | 397 | foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by |
| 398 | 398 | { |
| 399 | - $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); |
|
| 399 | + $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | else |
| 403 | 403 | { |
| 404 | - $sql.= natural_search(array_keys($fieldstosearchall), $search_all); |
|
| 404 | + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | -$sql.= $db->order($sortfield,$sortorder); |
|
| 407 | +$sql .= $db->order($sortfield, $sortorder); |
|
| 408 | 408 | |
| 409 | 409 | $nbtotalofrecords = ''; |
| 410 | 410 | if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | $nbtotalofrecords = $db->num_rows($result); |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | -$sql.= $db->plimit($limit+1, $offset); |
|
| 416 | +$sql .= $db->plimit($limit + 1, $offset); |
|
| 417 | 417 | //print $sql; |
| 418 | 418 | |
| 419 | 419 | $resql = $db->query($sql); |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | { |
| 422 | 422 | $num = $db->num_rows($resql); |
| 423 | 423 | |
| 424 | - $arrayofselected=is_array($toselect)?$toselect:array(); |
|
| 424 | + $arrayofselected = is_array($toselect) ? $toselect : array(); |
|
| 425 | 425 | |
| 426 | 426 | if ($socid) |
| 427 | 427 | { |
@@ -430,49 +430,49 @@ discard block |
||
| 430 | 430 | if (empty($search_societe)) $search_societe = $soc->name; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - $param='&socid='.$socid; |
|
| 434 | - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; |
|
| 435 | - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
|
| 436 | - if ($search_all) $param.='&search_all='.urlencode($search_all); |
|
| 437 | - if ($day) $param.='&day='.urlencode($day); |
|
| 438 | - if ($month) $param.='&month='.urlencode($month); |
|
| 439 | - if ($year) $param.='&year=' .urlencode($year); |
|
| 440 | - if ($day_lim) $param.='&day_lim='.urlencode($day_lim); |
|
| 441 | - if ($month_lim) $param.='&month_lim='.urlencode($month_lim); |
|
| 442 | - if ($year_lim) $param.='&year_lim=' .urlencode($year_lim); |
|
| 443 | - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); |
|
| 444 | - if ($search_refsupplier) $param.='&search_refsupplier='.urlencode($search_refsupplier); |
|
| 445 | - if ($search_label) $param.='&search_label='.urlencode($search_label); |
|
| 446 | - if ($search_company) $param.='&search_company='.urlencode($search_company); |
|
| 447 | - if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht); |
|
| 448 | - if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); |
|
| 449 | - if ($search_montant_localtax1 != '') $param.='&search_montant_localtax1='.urlencode($search_montant_localtax1); |
|
| 450 | - if ($search_montant_localtax2 != '') $param.='&search_montant_localtax2='.urlencode($search_montant_localtax2); |
|
| 451 | - if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); |
|
| 452 | - if ($search_amount_no_tax) $param.='&search_amount_no_tax='.urlencode($search_amount_no_tax); |
|
| 453 | - if ($search_amount_all_tax) $param.='&search_amount_all_tax='.urlencode($search_amount_all_tax); |
|
| 454 | - if ($search_status >= 0) $param.="&search_status=".urlencode($search_status); |
|
| 455 | - if ($show_files) $param.='&show_files=' .$show_files; |
|
| 456 | - if ($option) $param.="&option=".$option; |
|
| 457 | - if ($optioncss != '') $param.='&optioncss='.$optioncss; |
|
| 433 | + $param = '&socid='.$socid; |
|
| 434 | + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; |
|
| 435 | + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; |
|
| 436 | + if ($search_all) $param .= '&search_all='.urlencode($search_all); |
|
| 437 | + if ($day) $param .= '&day='.urlencode($day); |
|
| 438 | + if ($month) $param .= '&month='.urlencode($month); |
|
| 439 | + if ($year) $param .= '&year='.urlencode($year); |
|
| 440 | + if ($day_lim) $param .= '&day_lim='.urlencode($day_lim); |
|
| 441 | + if ($month_lim) $param .= '&month_lim='.urlencode($month_lim); |
|
| 442 | + if ($year_lim) $param .= '&year_lim='.urlencode($year_lim); |
|
| 443 | + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); |
|
| 444 | + if ($search_refsupplier) $param .= '&search_refsupplier='.urlencode($search_refsupplier); |
|
| 445 | + if ($search_label) $param .= '&search_label='.urlencode($search_label); |
|
| 446 | + if ($search_company) $param .= '&search_company='.urlencode($search_company); |
|
| 447 | + if ($search_montant_ht != '') $param .= '&search_montant_ht='.urlencode($search_montant_ht); |
|
| 448 | + if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat); |
|
| 449 | + if ($search_montant_localtax1 != '') $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1); |
|
| 450 | + if ($search_montant_localtax2 != '') $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2); |
|
| 451 | + if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); |
|
| 452 | + if ($search_amount_no_tax) $param .= '&search_amount_no_tax='.urlencode($search_amount_no_tax); |
|
| 453 | + if ($search_amount_all_tax) $param .= '&search_amount_all_tax='.urlencode($search_amount_all_tax); |
|
| 454 | + if ($search_status >= 0) $param .= "&search_status=".urlencode($search_status); |
|
| 455 | + if ($show_files) $param .= '&show_files='.$show_files; |
|
| 456 | + if ($option) $param .= "&option=".$option; |
|
| 457 | + if ($optioncss != '') $param .= '&optioncss='.$optioncss; |
|
| 458 | 458 | // Add $param from extra fields |
| 459 | 459 | foreach ($search_array_options as $key => $val) |
| 460 | 460 | { |
| 461 | - $crit=$val; |
|
| 462 | - $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 463 | - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); |
|
| 461 | + $crit = $val; |
|
| 462 | + $tmpkey = preg_replace('/search_options_/', '', $key); |
|
| 463 | + if ($val != '') $param .= '&search_options_'.$tmpkey.'='.urlencode($val); |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | // List of mass actions available |
| 467 | - $arrayofmassactions = array( |
|
| 467 | + $arrayofmassactions = array( |
|
| 468 | 468 | 'validate'=>$langs->trans("Validate"), |
| 469 | 469 | //'presend'=>$langs->trans("SendByMail"), |
| 470 | 470 | //'builddoc'=>$langs->trans("PDFMerge"), |
| 471 | 471 | ); |
| 472 | 472 | //if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); |
| 473 | - if ($user->rights->fournisseur->facture->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); |
|
| 473 | + if ($user->rights->fournisseur->facture->supprimer) $arrayofmassactions['delete'] = $langs->trans("Delete"); |
|
| 474 | 474 | //if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); |
| 475 | - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); |
|
| 475 | + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); |
|
| 476 | 476 | |
| 477 | 477 | $i = 0; |
| 478 | 478 | print '<form method="POST" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; |
@@ -486,27 +486,27 @@ discard block |
||
| 486 | 486 | print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">'; |
| 487 | 487 | print '<input type="hidden" name="socid" value="'.$socid.'">'; |
| 488 | 488 | |
| 489 | - print_barre_liste($langs->trans("BillsSuppliers").($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); |
|
| 489 | + print_barre_liste($langs->trans("BillsSuppliers").($socid ? ' '.$soc->name : ''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); |
|
| 490 | 490 | |
| 491 | 491 | if ($massaction == 'presend') |
| 492 | 492 | { |
| 493 | 493 | $langs->load("mails"); |
| 494 | 494 | |
| 495 | - if (! GETPOST('cancel')) |
|
| 495 | + if (!GETPOST('cancel')) |
|
| 496 | 496 | { |
| 497 | - $objecttmp=new FactureFournisseur($db); |
|
| 498 | - $listofselectedid=array(); |
|
| 499 | - $listofselectedthirdparties=array(); |
|
| 500 | - $listofselectedref=array(); |
|
| 501 | - foreach($arrayofselected as $toselectid) |
|
| 497 | + $objecttmp = new FactureFournisseur($db); |
|
| 498 | + $listofselectedid = array(); |
|
| 499 | + $listofselectedthirdparties = array(); |
|
| 500 | + $listofselectedref = array(); |
|
| 501 | + foreach ($arrayofselected as $toselectid) |
|
| 502 | 502 | { |
| 503 | - $result=$objecttmp->fetch($toselectid); |
|
| 503 | + $result = $objecttmp->fetch($toselectid); |
|
| 504 | 504 | if ($result > 0) |
| 505 | 505 | { |
| 506 | - $listofselectedid[$toselectid]=$toselectid; |
|
| 507 | - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; |
|
| 508 | - $listofselectedthirdparties[$thirdpartyid]=$thirdpartyid; |
|
| 509 | - $listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref; |
|
| 506 | + $listofselectedid[$toselectid] = $toselectid; |
|
| 507 | + $thirdpartyid = $objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid; |
|
| 508 | + $listofselectedthirdparties[$thirdpartyid] = $thirdpartyid; |
|
| 509 | + $listofselectedref[$thirdpartyid][$toselectid] = $objecttmp->ref; |
|
| 510 | 510 | } |
| 511 | 511 | } |
| 512 | 512 | } |
@@ -518,67 +518,67 @@ discard block |
||
| 518 | 518 | |
| 519 | 519 | dol_fiche_head(null, '', ''); |
| 520 | 520 | |
| 521 | - $topicmail="SendBillRef"; |
|
| 522 | - $modelmail="supplier_invoice_send"; |
|
| 521 | + $topicmail = "SendBillRef"; |
|
| 522 | + $modelmail = "supplier_invoice_send"; |
|
| 523 | 523 | |
| 524 | 524 | // Cree l'objet formulaire mail |
| 525 | 525 | include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
| 526 | 526 | $formmail = new FormMail($db); |
| 527 | - $formmail->withform=-1; |
|
| 528 | - $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); |
|
| 527 | + $formmail->withform = -1; |
|
| 528 | + $formmail->fromtype = (GETPOST('fromtype') ? GETPOST('fromtype') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user')); |
|
| 529 | 529 | |
| 530 | - if($formmail->fromtype === 'user'){ |
|
| 530 | + if ($formmail->fromtype === 'user') { |
|
| 531 | 531 | $formmail->fromid = $user->id; |
| 532 | 532 | |
| 533 | 533 | } |
| 534 | - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set |
|
| 534 | + if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set |
|
| 535 | 535 | { |
| 536 | - $formmail->trackid='sinv'.$object->id; |
|
| 536 | + $formmail->trackid = 'sinv'.$object->id; |
|
| 537 | 537 | } |
| 538 | - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set |
|
| 538 | + if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set |
|
| 539 | 539 | { |
| 540 | 540 | include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
| 541 | - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'sinv'.$object->id); |
|
| 541 | + $formmail->frommail = dolAddEmailTrackId($formmail->frommail, 'sinv'.$object->id); |
|
| 542 | 542 | } |
| 543 | - $formmail->withfrom=1; |
|
| 544 | - $liste=$langs->trans("AllRecipientSelected"); |
|
| 543 | + $formmail->withfrom = 1; |
|
| 544 | + $liste = $langs->trans("AllRecipientSelected"); |
|
| 545 | 545 | if (count($listofselectedthirdparties) == 1) |
| 546 | 546 | { |
| 547 | - $liste=array(); |
|
| 548 | - $thirdpartyid=array_shift($listofselectedthirdparties); |
|
| 549 | - $soc=new Societe($db); |
|
| 547 | + $liste = array(); |
|
| 548 | + $thirdpartyid = array_shift($listofselectedthirdparties); |
|
| 549 | + $soc = new Societe($db); |
|
| 550 | 550 | $soc->fetch($thirdpartyid); |
| 551 | 551 | foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) |
| 552 | 552 | { |
| 553 | - $liste[$key]=$value; |
|
| 553 | + $liste[$key] = $value; |
|
| 554 | 554 | } |
| 555 | - $formmail->withtoreadonly=0; |
|
| 555 | + $formmail->withtoreadonly = 0; |
|
| 556 | 556 | } |
| 557 | 557 | else |
| 558 | 558 | { |
| 559 | - $formmail->withtoreadonly=1; |
|
| 559 | + $formmail->withtoreadonly = 1; |
|
| 560 | 560 | } |
| 561 | - $formmail->withto=$liste; |
|
| 562 | - $formmail->withtofree=0; |
|
| 563 | - $formmail->withtocc=1; |
|
| 564 | - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; |
|
| 565 | - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); |
|
| 566 | - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); |
|
| 567 | - $formmail->withbody=1; |
|
| 568 | - $formmail->withdeliveryreceipt=1; |
|
| 569 | - $formmail->withcancel=1; |
|
| 561 | + $formmail->withto = $liste; |
|
| 562 | + $formmail->withtofree = 0; |
|
| 563 | + $formmail->withtocc = 1; |
|
| 564 | + $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; |
|
| 565 | + $formmail->withtopic = $langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); |
|
| 566 | + $formmail->withfile = $langs->trans("OnlyPDFattachmentSupported"); |
|
| 567 | + $formmail->withbody = 1; |
|
| 568 | + $formmail->withdeliveryreceipt = 1; |
|
| 569 | + $formmail->withcancel = 1; |
|
| 570 | 570 | // Tableau des substitutions |
| 571 | - $formmail->substit['__REF__']='__REF__'; // We want to keep the tag |
|
| 572 | - $formmail->substit['__SIGNATURE__']=$user->signature; |
|
| 573 | - $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag |
|
| 574 | - $formmail->substit['__PERSONALIZED__']=''; |
|
| 575 | - $formmail->substit['__CONTACTCIVNAME__']=''; |
|
| 571 | + $formmail->substit['__REF__'] = '__REF__'; // We want to keep the tag |
|
| 572 | + $formmail->substit['__SIGNATURE__'] = $user->signature; |
|
| 573 | + $formmail->substit['__REFCLIENT__'] = '__REFCLIENT__'; // We want to keep the tag |
|
| 574 | + $formmail->substit['__PERSONALIZED__'] = ''; |
|
| 575 | + $formmail->substit['__CONTACTCIVNAME__'] = ''; |
|
| 576 | 576 | |
| 577 | 577 | // Tableau des parametres complementaires du post |
| 578 | - $formmail->param['action']=$action; |
|
| 579 | - $formmail->param['models']=$modelmail; |
|
| 580 | - $formmail->param['models_id']=GETPOST('modelmailselected','int'); |
|
| 581 | - $formmail->param['id']=join(',',$arrayofselected); |
|
| 578 | + $formmail->param['action'] = $action; |
|
| 579 | + $formmail->param['models'] = $modelmail; |
|
| 580 | + $formmail->param['models_id'] = GETPOST('modelmailselected', 'int'); |
|
| 581 | + $formmail->param['id'] = join(',', $arrayofselected); |
|
| 582 | 582 | //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; |
| 583 | 583 | |
| 584 | 584 | print $formmail->get_form(); |
@@ -627,40 +627,40 @@ discard block |
||
| 627 | 627 | |
| 628 | 628 | if ($search_all) |
| 629 | 629 | { |
| 630 | - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); |
|
| 631 | - print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); |
|
| 630 | + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); |
|
| 631 | + print $langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall); |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | // If the user can view prospects other than his' |
| 635 | - $moreforfilter=''; |
|
| 635 | + $moreforfilter = ''; |
|
| 636 | 636 | if ($user->rights->societe->client->voir || $socid) |
| 637 | 637 | { |
| 638 | 638 | $langs->load("commercial"); |
| 639 | - $moreforfilter.='<div class="divsearchfield">'; |
|
| 640 | - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; |
|
| 641 | - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); |
|
| 642 | - $moreforfilter.='</div>'; |
|
| 639 | + $moreforfilter .= '<div class="divsearchfield">'; |
|
| 640 | + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; |
|
| 641 | + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); |
|
| 642 | + $moreforfilter .= '</div>'; |
|
| 643 | 643 | } |
| 644 | 644 | // If the user can view prospects other than his' |
| 645 | 645 | if ($user->rights->societe->client->voir || $socid) |
| 646 | 646 | { |
| 647 | - $moreforfilter.='<div class="divsearchfield">'; |
|
| 648 | - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; |
|
| 649 | - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); |
|
| 650 | - $moreforfilter.='</div>'; |
|
| 647 | + $moreforfilter .= '<div class="divsearchfield">'; |
|
| 648 | + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; |
|
| 649 | + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); |
|
| 650 | + $moreforfilter .= '</div>'; |
|
| 651 | 651 | } |
| 652 | 652 | // If the user can view prospects other than his' |
| 653 | 653 | if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) |
| 654 | 654 | { |
| 655 | 655 | include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
| 656 | - $moreforfilter.='<div class="divsearchfield">'; |
|
| 657 | - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; |
|
| 656 | + $moreforfilter .= '<div class="divsearchfield">'; |
|
| 657 | + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; |
|
| 658 | 658 | $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); |
| 659 | - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); |
|
| 660 | - $moreforfilter.='</div>'; |
|
| 659 | + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); |
|
| 660 | + $moreforfilter .= '</div>'; |
|
| 661 | 661 | } |
| 662 | - $parameters=array(); |
|
| 663 | - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook |
|
| 662 | + $parameters = array(); |
|
| 663 | + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook |
|
| 664 | 664 | if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; |
| 665 | 665 | else $moreforfilter = $hookmanager->resPrint; |
| 666 | 666 | |
@@ -671,138 +671,138 @@ discard block |
||
| 671 | 671 | print '</div>'; |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
|
| 675 | - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
| 676 | - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); |
|
| 674 | + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; |
|
| 675 | + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
| 676 | + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); |
|
| 677 | 677 | |
| 678 | 678 | print '<div class="div-table-responsive">'; |
| 679 | - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
|
| 679 | + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; |
|
| 680 | 680 | |
| 681 | 681 | // Line for filters |
| 682 | 682 | print '<tr class="liste_titre_filter">'; |
| 683 | 683 | // Ref |
| 684 | - if (! empty($arrayfields['f.ref']['checked'])) |
|
| 684 | + if (!empty($arrayfields['f.ref']['checked'])) |
|
| 685 | 685 | { |
| 686 | 686 | print '<td class="liste_titre" align="left">'; |
| 687 | 687 | print '<input class="flat" size="6" type="text" name="search_ref" value="'.$search_ref.'">'; |
| 688 | 688 | print '</td>'; |
| 689 | 689 | } |
| 690 | 690 | // Ref supplier |
| 691 | - if (! empty($arrayfields['f.ref_supplier']['checked'])) |
|
| 691 | + if (!empty($arrayfields['f.ref_supplier']['checked'])) |
|
| 692 | 692 | { |
| 693 | 693 | print '<td class="liste_titre">'; |
| 694 | 694 | print '<input class="flat" size="6" type="text" name="search_refsupplier" value="'.$search_refsupplier.'">'; |
| 695 | 695 | print '</td>'; |
| 696 | 696 | } |
| 697 | 697 | // Label |
| 698 | - if (! empty($arrayfields['f.label']['checked'])) |
|
| 698 | + if (!empty($arrayfields['f.label']['checked'])) |
|
| 699 | 699 | { |
| 700 | 700 | print '<td class="liste_titre">'; |
| 701 | 701 | print '<input class="flat" size="6" type="text" name="search_label" value="'.$search_label.'">'; |
| 702 | 702 | print '</td>'; |
| 703 | 703 | } |
| 704 | 704 | // Date invoice |
| 705 | - if (! empty($arrayfields['f.datef']['checked'])) |
|
| 705 | + if (!empty($arrayfields['f.datef']['checked'])) |
|
| 706 | 706 | { |
| 707 | 707 | print '<td class="liste_titre" align="center">'; |
| 708 | - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">'; |
|
| 708 | + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">'; |
|
| 709 | 709 | print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">'; |
| 710 | - $formother->select_year($year?$year:-1,'year',1, 20, 5); |
|
| 710 | + $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); |
|
| 711 | 711 | print '</td>'; |
| 712 | 712 | } |
| 713 | 713 | // Date due |
| 714 | - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) |
|
| 714 | + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) |
|
| 715 | 715 | { |
| 716 | 716 | print '<td class="liste_titre" align="center">'; |
| 717 | - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_lim" value="'.dol_escape_htmltag($day_lim).'">'; |
|
| 717 | + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_lim" value="'.dol_escape_htmltag($day_lim).'">'; |
|
| 718 | 718 | print '<input class="flat" type="text" size="1" maxlength="2" name="month_lim" value="'.$month_lim.'">'; |
| 719 | - $formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5); |
|
| 720 | - print '<br><input type="checkbox" name="option" value="late"'.($option == 'late'?' checked':'').'> '.$langs->trans("Late"); |
|
| 719 | + $formother->select_year($year_lim ? $year_lim : -1, 'year_lim', 1, 20, 5); |
|
| 720 | + print '<br><input type="checkbox" name="option" value="late"'.($option == 'late' ? ' checked' : '').'> '.$langs->trans("Late"); |
|
| 721 | 721 | print '</td>'; |
| 722 | 722 | } |
| 723 | 723 | // Project |
| 724 | - if (! empty($arrayfields['p.ref']['checked'])) |
|
| 724 | + if (!empty($arrayfields['p.ref']['checked'])) |
|
| 725 | 725 | { |
| 726 | 726 | print '<td class="liste_titre" align="left"><input class="flat" type="text" size="6" name="search_project" value="'.$search_project.'"></td>'; |
| 727 | 727 | } |
| 728 | 728 | // Thirpdarty |
| 729 | - if (! empty($arrayfields['s.nom']['checked'])) |
|
| 729 | + if (!empty($arrayfields['s.nom']['checked'])) |
|
| 730 | 730 | { |
| 731 | 731 | print '<td class="liste_titre" align="left"><input class="flat" type="text" size="6" name="search_societe" value="'.$search_societe.'"></td>'; |
| 732 | 732 | } |
| 733 | 733 | // Town |
| 734 | - if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>'; |
|
| 734 | + if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>'; |
|
| 735 | 735 | // Zip |
| 736 | - if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>'; |
|
| 736 | + if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>'; |
|
| 737 | 737 | // State |
| 738 | - if (! empty($arrayfields['state.nom']['checked'])) |
|
| 738 | + if (!empty($arrayfields['state.nom']['checked'])) |
|
| 739 | 739 | { |
| 740 | 740 | print '<td class="liste_titre">'; |
| 741 | 741 | print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; |
| 742 | 742 | print '</td>'; |
| 743 | 743 | } |
| 744 | 744 | // Country |
| 745 | - if (! empty($arrayfields['country.code_iso']['checked'])) |
|
| 745 | + if (!empty($arrayfields['country.code_iso']['checked'])) |
|
| 746 | 746 | { |
| 747 | 747 | print '<td class="liste_titre" align="center">'; |
| 748 | - print $form->select_country($search_country,'search_country','',0,'maxwidth100'); |
|
| 748 | + print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100'); |
|
| 749 | 749 | print '</td>'; |
| 750 | 750 | } |
| 751 | 751 | // Company type |
| 752 | - if (! empty($arrayfields['typent.code']['checked'])) |
|
| 752 | + if (!empty($arrayfields['typent.code']['checked'])) |
|
| 753 | 753 | { |
| 754 | 754 | print '<td class="liste_titre maxwidthonsmartphone" align="center">'; |
| 755 | - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); |
|
| 755 | + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); |
|
| 756 | 756 | print '</td>'; |
| 757 | 757 | } |
| 758 | 758 | // Payment mode |
| 759 | - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
| 759 | + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
| 760 | 760 | { |
| 761 | 761 | print '<td class="liste_titre" align="left">'; |
| 762 | 762 | $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 0, 1, 10); |
| 763 | 763 | print '</td>'; |
| 764 | 764 | } |
| 765 | - if (! empty($arrayfields['f.total_ht']['checked'])) |
|
| 765 | + if (!empty($arrayfields['f.total_ht']['checked'])) |
|
| 766 | 766 | { |
| 767 | 767 | // Amount |
| 768 | 768 | print '<td class="liste_titre" align="right">'; |
| 769 | 769 | print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">'; |
| 770 | 770 | print '</td>'; |
| 771 | 771 | } |
| 772 | - if (! empty($arrayfields['f.total_vat']['checked'])) |
|
| 772 | + if (!empty($arrayfields['f.total_vat']['checked'])) |
|
| 773 | 773 | { |
| 774 | 774 | // Amount |
| 775 | 775 | print '<td class="liste_titre" align="right">'; |
| 776 | 776 | print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">'; |
| 777 | 777 | print '</td>'; |
| 778 | 778 | } |
| 779 | - if (! empty($arrayfields['f.total_localtax1']['checked'])) |
|
| 779 | + if (!empty($arrayfields['f.total_localtax1']['checked'])) |
|
| 780 | 780 | { |
| 781 | 781 | // Amount |
| 782 | 782 | print '<td class="liste_titre" align="right">'; |
| 783 | 783 | print '<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.$search_montant_localtax1.'">'; |
| 784 | 784 | print '</td>'; |
| 785 | 785 | } |
| 786 | - if (! empty($arrayfields['f.total_localtax2']['checked'])) |
|
| 786 | + if (!empty($arrayfields['f.total_localtax2']['checked'])) |
|
| 787 | 787 | { |
| 788 | 788 | // Amount |
| 789 | 789 | print '<td class="liste_titre" align="right">'; |
| 790 | 790 | print '<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.$search_montant_localtax2.'">'; |
| 791 | 791 | print '</td>'; |
| 792 | 792 | } |
| 793 | - if (! empty($arrayfields['f.total_ttc']['checked'])) |
|
| 793 | + if (!empty($arrayfields['f.total_ttc']['checked'])) |
|
| 794 | 794 | { |
| 795 | 795 | // Amount |
| 796 | 796 | print '<td class="liste_titre" align="right">'; |
| 797 | 797 | print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">'; |
| 798 | 798 | print '</td>'; |
| 799 | 799 | } |
| 800 | - if (! empty($arrayfields['dynamount_payed']['checked'])) |
|
| 800 | + if (!empty($arrayfields['dynamount_payed']['checked'])) |
|
| 801 | 801 | { |
| 802 | 802 | print '<td class="liste_titre" align="right">'; |
| 803 | 803 | print '</td>'; |
| 804 | 804 | } |
| 805 | - if (! empty($arrayfields['rtp']['checked'])) |
|
| 805 | + if (!empty($arrayfields['rtp']['checked'])) |
|
| 806 | 806 | { |
| 807 | 807 | print '<td class="liste_titre" align="right">'; |
| 808 | 808 | print '</td>'; |
@@ -810,122 +810,122 @@ discard block |
||
| 810 | 810 | // Extra fields |
| 811 | 811 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 812 | 812 | { |
| 813 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 813 | + foreach ($extrafields->attribute_label as $key => $val) |
|
| 814 | 814 | { |
| 815 | - if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 815 | + if (!empty($arrayfields["ef.".$key]['checked'])) |
|
| 816 | 816 | { |
| 817 | - $align=$extrafields->getAlignFlag($key); |
|
| 818 | - $typeofextrafield=$extrafields->attribute_type[$key]; |
|
| 819 | - print '<td class="liste_titre'.($align?' '.$align:'').'">'; |
|
| 817 | + $align = $extrafields->getAlignFlag($key); |
|
| 818 | + $typeofextrafield = $extrafields->attribute_type[$key]; |
|
| 819 | + print '<td class="liste_titre'.($align ? ' '.$align : '').'">'; |
|
| 820 | 820 | if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) |
| 821 | 821 | { |
| 822 | - $crit=$val; |
|
| 823 | - $tmpkey=preg_replace('/search_options_/','',$key); |
|
| 824 | - $searchclass=''; |
|
| 825 | - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; |
|
| 826 | - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; |
|
| 827 | - print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">'; |
|
| 822 | + $crit = $val; |
|
| 823 | + $tmpkey = preg_replace('/search_options_/', '', $key); |
|
| 824 | + $searchclass = ''; |
|
| 825 | + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass = 'searchstring'; |
|
| 826 | + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass = 'searchnum'; |
|
| 827 | + print '<input class="flat'.($searchclass ? ' '.$searchclass : '').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">'; |
|
| 828 | 828 | } |
| 829 | 829 | print '</td>'; |
| 830 | 830 | } |
| 831 | 831 | } |
| 832 | 832 | } |
| 833 | 833 | // Fields from hook |
| 834 | - $parameters=array('arrayfields'=>$arrayfields); |
|
| 835 | - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook |
|
| 834 | + $parameters = array('arrayfields'=>$arrayfields); |
|
| 835 | + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook |
|
| 836 | 836 | print $hookmanager->resPrint; |
| 837 | 837 | // Date creation |
| 838 | - if (! empty($arrayfields['f.datec']['checked'])) |
|
| 838 | + if (!empty($arrayfields['f.datec']['checked'])) |
|
| 839 | 839 | { |
| 840 | 840 | print '<td class="liste_titre">'; |
| 841 | 841 | print '</td>'; |
| 842 | 842 | } |
| 843 | 843 | // Date modification |
| 844 | - if (! empty($arrayfields['f.tms']['checked'])) |
|
| 844 | + if (!empty($arrayfields['f.tms']['checked'])) |
|
| 845 | 845 | { |
| 846 | 846 | print '<td class="liste_titre">'; |
| 847 | 847 | print '</td>'; |
| 848 | 848 | } |
| 849 | 849 | // Status |
| 850 | - if (! empty($arrayfields['f.fk_statut']['checked'])) |
|
| 850 | + if (!empty($arrayfields['f.fk_statut']['checked'])) |
|
| 851 | 851 | { |
| 852 | 852 | print '<td class="liste_titre maxwidthonsmartphone" align="right">'; |
| 853 | - $liststatus=array('0'=>$langs->trans("Draft"),'1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); |
|
| 853 | + $liststatus = array('0'=>$langs->trans("Draft"), '1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); |
|
| 854 | 854 | print $form->selectarray('search_status', $liststatus, $search_status, 1); |
| 855 | 855 | print '</td>'; |
| 856 | 856 | } |
| 857 | 857 | // Action column |
| 858 | 858 | print '<td class="liste_titre" align="middle">'; |
| 859 | - $searchpicto=$form->showFilterButtons(); |
|
| 859 | + $searchpicto = $form->showFilterButtons(); |
|
| 860 | 860 | print $searchpicto; |
| 861 | 861 | print '</td>'; |
| 862 | 862 | |
| 863 | 863 | print "</tr>\n"; |
| 864 | 864 | |
| 865 | 865 | print '<tr class="liste_titre">'; |
| 866 | - if (! empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'],$_SERVER['PHP_SELF'],'f.ref,f.rowid','',$param,'',$sortfield,$sortorder); |
|
| 867 | - if (! empty($arrayfields['f.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['f.ref_supplier']['label'],$_SERVER["PHP_SELF"],'f.ref_supplier','',$param,'',$sortfield,$sortorder); |
|
| 868 | - if (! empty($arrayfields['f.label']['checked'])) print_liste_field_titre($arrayfields['f.label']['label'],$_SERVER['PHP_SELF'],"f.libelle,f.rowid",'',$param,'',$sortfield,$sortorder); |
|
| 869 | - if (! empty($arrayfields['f.datef']['checked'])) print_liste_field_titre($arrayfields['f.datef']['label'],$_SERVER['PHP_SELF'],'f.datef,f.rowid','',$param,'align="center"',$sortfield,$sortorder); |
|
| 870 | - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'],$_SERVER['PHP_SELF'],"f.date_lim_reglement",'',$param,'align="center"',$sortfield,$sortorder); |
|
| 871 | - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER['PHP_SELF'],"p.ref",'',$param,'align="center"',$sortfield,$sortorder); |
|
| 872 | - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],'s.nom','',$param,'',$sortfield,$sortorder); |
|
| 873 | - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder); |
|
| 874 | - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder); |
|
| 875 | - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); |
|
| 876 | - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); |
|
| 877 | - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); |
|
| 878 | - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'],$_SERVER["PHP_SELF"],"f.fk_mode_reglement","",$param,"",$sortfield,$sortorder); |
|
| 879 | - if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'],$_SERVER['PHP_SELF'],'f.total','',$param,'align="right"',$sortfield,$sortorder); |
|
| 880 | - if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'],$_SERVER['PHP_SELF'],'f.tva','',$param,'align="right"',$sortfield,$sortorder); |
|
| 881 | - if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'],$_SERVER['PHP_SELF'],'f.localtax1','',$param,'align="right"',$sortfield,$sortorder); |
|
| 882 | - if (! empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'],$_SERVER['PHP_SELF'],'f.localtax2','',$param,'align="right"',$sortfield,$sortorder); |
|
| 883 | - if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],'f.total_ttc','',$param,'align="right"',$sortfield,$sortorder); |
|
| 884 | - if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); |
|
| 885 | - if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); |
|
| 866 | + if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref,f.rowid', '', $param, '', $sortfield, $sortorder); |
|
| 867 | + if (!empty($arrayfields['f.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['f.ref_supplier']['label'], $_SERVER["PHP_SELF"], 'f.ref_supplier', '', $param, '', $sortfield, $sortorder); |
|
| 868 | + if (!empty($arrayfields['f.label']['checked'])) print_liste_field_titre($arrayfields['f.label']['label'], $_SERVER['PHP_SELF'], "f.libelle,f.rowid", '', $param, '', $sortfield, $sortorder); |
|
| 869 | + if (!empty($arrayfields['f.datef']['checked'])) print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER['PHP_SELF'], 'f.datef,f.rowid', '', $param, 'align="center"', $sortfield, $sortorder); |
|
| 870 | + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, 'align="center"', $sortfield, $sortorder); |
|
| 871 | + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, 'align="center"', $sortfield, $sortorder); |
|
| 872 | + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); |
|
| 873 | + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); |
|
| 874 | + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); |
|
| 875 | + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); |
|
| 876 | + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); |
|
| 877 | + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); |
|
| 878 | + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); |
|
| 879 | + if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'align="right"', $sortfield, $sortorder); |
|
| 880 | + if (!empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'align="right"', $sortfield, $sortorder); |
|
| 881 | + if (!empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'align="right"', $sortfield, $sortorder); |
|
| 882 | + if (!empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'align="right"', $sortfield, $sortorder); |
|
| 883 | + if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'align="right"', $sortfield, $sortorder); |
|
| 884 | + if (!empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); |
|
| 885 | + if (!empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); |
|
| 886 | 886 | // Extra fields |
| 887 | 887 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 888 | 888 | { |
| 889 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 889 | + foreach ($extrafields->attribute_label as $key => $val) |
|
| 890 | 890 | { |
| 891 | - if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 891 | + if (!empty($arrayfields["ef.".$key]['checked'])) |
|
| 892 | 892 | { |
| 893 | - $align=$extrafields->getAlignFlag($key); |
|
| 893 | + $align = $extrafields->getAlignFlag($key); |
|
| 894 | 894 | $sortonfield = "ef.".$key; |
| 895 | - if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; |
|
| 896 | - print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); |
|
| 895 | + if (!empty($extrafields->attribute_computed[$key])) $sortonfield = ''; |
|
| 896 | + print_liste_field_titre($langs->trans($extralabels[$key]), $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align ? 'align="'.$align.'"' : ''), $sortfield, $sortorder); |
|
| 897 | 897 | } |
| 898 | 898 | } |
| 899 | 899 | } |
| 900 | 900 | // Hook fields |
| 901 | - $parameters=array('arrayfields'=>$arrayfields); |
|
| 902 | - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook |
|
| 901 | + $parameters = array('arrayfields'=>$arrayfields); |
|
| 902 | + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook |
|
| 903 | 903 | print $hookmanager->resPrint; |
| 904 | - if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); |
|
| 905 | - if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); |
|
| 906 | - if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'],$_SERVER["PHP_SELF"],"fk_statut,paye","",$param,'align="right"',$sortfield,$sortorder); |
|
| 907 | - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); |
|
| 904 | + if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); |
|
| 905 | + if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); |
|
| 906 | + if (!empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "fk_statut,paye", "", $param, 'align="right"', $sortfield, $sortorder); |
|
| 907 | + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); |
|
| 908 | 908 | print "</tr>\n"; |
| 909 | 909 | |
| 910 | - $facturestatic=new FactureFournisseur($db); |
|
| 911 | - $supplierstatic=new Fournisseur($db); |
|
| 912 | - $projectstatic=new Project($db); |
|
| 910 | + $facturestatic = new FactureFournisseur($db); |
|
| 911 | + $supplierstatic = new Fournisseur($db); |
|
| 912 | + $projectstatic = new Project($db); |
|
| 913 | 913 | |
| 914 | 914 | if ($num > 0) |
| 915 | 915 | { |
| 916 | - $i=0; |
|
| 916 | + $i = 0; |
|
| 917 | 917 | |
| 918 | - $var=true; |
|
| 919 | - $totalarray=array(); |
|
| 920 | - while ($i < min($num,$limit)) |
|
| 918 | + $var = true; |
|
| 919 | + $totalarray = array(); |
|
| 920 | + while ($i < min($num, $limit)) |
|
| 921 | 921 | { |
| 922 | 922 | $obj = $db->fetch_object($resql); |
| 923 | 923 | |
| 924 | - $datelimit=$db->jdate($obj->datelimite); |
|
| 925 | - $facturestatic->id=$obj->facid; |
|
| 926 | - $facturestatic->ref=$obj->ref; |
|
| 927 | - $facturestatic->type=$obj->type; |
|
| 928 | - $facturestatic->ref_supplier=$obj->ref_supplier; |
|
| 924 | + $datelimit = $db->jdate($obj->datelimite); |
|
| 925 | + $facturestatic->id = $obj->facid; |
|
| 926 | + $facturestatic->ref = $obj->ref; |
|
| 927 | + $facturestatic->type = $obj->type; |
|
| 928 | + $facturestatic->ref_supplier = $obj->ref_supplier; |
|
| 929 | 929 | $facturestatic->date_echeance = $db->jdate($obj->datelimite); |
| 930 | 930 | $facturestatic->statut = $obj->fk_statut; |
| 931 | 931 | |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | $remaintopay = $obj->total_ttc - $totalpay; |
| 937 | 937 | |
| 938 | 938 | print '<tr class="oddeven">'; |
| 939 | - if (! empty($arrayfields['f.ref']['checked'])) |
|
| 939 | + if (!empty($arrayfields['f.ref']['checked'])) |
|
| 940 | 940 | { |
| 941 | 941 | print '<td class="nowrap">'; |
| 942 | 942 | |
@@ -950,186 +950,186 @@ discard block |
||
| 950 | 950 | //print '</td>'; |
| 951 | 951 | // Other picto tool |
| 952 | 952 | print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">'; |
| 953 | - $filename=dol_sanitizeFileName($obj->ref); |
|
| 954 | - $filedir=$conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref); |
|
| 955 | - $subdir = get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref); |
|
| 953 | + $filename = dol_sanitizeFileName($obj->ref); |
|
| 954 | + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); |
|
| 955 | + $subdir = get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); |
|
| 956 | 956 | print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir); |
| 957 | 957 | print '</td></tr></table>'; |
| 958 | 958 | |
| 959 | 959 | print "</td>\n"; |
| 960 | - if (! $i) $totalarray['nbfield']++; |
|
| 960 | + if (!$i) $totalarray['nbfield']++; |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | // Customer ref |
| 964 | - if (! empty($arrayfields['f.ref_supplier']['checked'])) |
|
| 964 | + if (!empty($arrayfields['f.ref_supplier']['checked'])) |
|
| 965 | 965 | { |
| 966 | 966 | print '<td class="nowrap">'; |
| 967 | 967 | print $obj->ref_supplier; |
| 968 | 968 | print '</td>'; |
| 969 | - if (! $i) $totalarray['nbfield']++; |
|
| 969 | + if (!$i) $totalarray['nbfield']++; |
|
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | // Label |
| 973 | - if (! empty($arrayfields['f.label']['checked'])) |
|
| 973 | + if (!empty($arrayfields['f.label']['checked'])) |
|
| 974 | 974 | { |
| 975 | 975 | print '<td class="nowrap">'; |
| 976 | 976 | print $obj->label; |
| 977 | 977 | print '</td>'; |
| 978 | - if (! $i) $totalarray['nbfield']++; |
|
| 978 | + if (!$i) $totalarray['nbfield']++; |
|
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | // Date |
| 982 | - if (! empty($arrayfields['f.datef']['checked'])) |
|
| 982 | + if (!empty($arrayfields['f.datef']['checked'])) |
|
| 983 | 983 | { |
| 984 | 984 | print '<td align="center" class="nowrap">'; |
| 985 | - print dol_print_date($db->jdate($obj->datef),'day'); |
|
| 985 | + print dol_print_date($db->jdate($obj->datef), 'day'); |
|
| 986 | 986 | print '</td>'; |
| 987 | - if (! $i) $totalarray['nbfield']++; |
|
| 987 | + if (!$i) $totalarray['nbfield']++; |
|
| 988 | 988 | } |
| 989 | 989 | |
| 990 | 990 | // Date limit |
| 991 | - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) |
|
| 991 | + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) |
|
| 992 | 992 | { |
| 993 | - print '<td align="center" class="nowrap">'.dol_print_date($datelimit,'day'); |
|
| 993 | + print '<td align="center" class="nowrap">'.dol_print_date($datelimit, 'day'); |
|
| 994 | 994 | if ($facturestatic->hasDelay()) |
| 995 | 995 | { |
| 996 | 996 | print img_warning($langs->trans('Late')); |
| 997 | 997 | } |
| 998 | 998 | print '</td>'; |
| 999 | - if (! $i) $totalarray['nbfield']++; |
|
| 999 | + if (!$i) $totalarray['nbfield']++; |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | // Project |
| 1003 | - if (! empty($arrayfields['p.ref']['checked'])) |
|
| 1003 | + if (!empty($arrayfields['p.ref']['checked'])) |
|
| 1004 | 1004 | { |
| 1005 | 1005 | print '<td class="nowrap">'; |
| 1006 | 1006 | if ($obj->project_id > 0) |
| 1007 | 1007 | { |
| 1008 | - $projectstatic->id=$obj->project_id; |
|
| 1009 | - $projectstatic->ref=$obj->project_ref; |
|
| 1008 | + $projectstatic->id = $obj->project_id; |
|
| 1009 | + $projectstatic->ref = $obj->project_ref; |
|
| 1010 | 1010 | print $projectstatic->getNomUrl(1); |
| 1011 | 1011 | } |
| 1012 | 1012 | print '</td>'; |
| 1013 | - if (! $i) $totalarray['nbfield']++; |
|
| 1013 | + if (!$i) $totalarray['nbfield']++; |
|
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | // Third party |
| 1017 | - if (! empty($arrayfields['s.nom']['checked'])) |
|
| 1017 | + if (!empty($arrayfields['s.nom']['checked'])) |
|
| 1018 | 1018 | { |
| 1019 | 1019 | print '<td class="tdoverflowmax200">'; |
| 1020 | - $thirdparty=new Societe($db); |
|
| 1021 | - $thirdparty->id=$obj->socid; |
|
| 1022 | - $thirdparty->name=$obj->name; |
|
| 1023 | - $thirdparty->client=$obj->client; |
|
| 1024 | - $thirdparty->code_client=$obj->code_client; |
|
| 1025 | - print $thirdparty->getNomUrl(1,'supplier'); |
|
| 1020 | + $thirdparty = new Societe($db); |
|
| 1021 | + $thirdparty->id = $obj->socid; |
|
| 1022 | + $thirdparty->name = $obj->name; |
|
| 1023 | + $thirdparty->client = $obj->client; |
|
| 1024 | + $thirdparty->code_client = $obj->code_client; |
|
| 1025 | + print $thirdparty->getNomUrl(1, 'supplier'); |
|
| 1026 | 1026 | print '</td>'; |
| 1027 | - if (! $i) $totalarray['nbfield']++; |
|
| 1027 | + if (!$i) $totalarray['nbfield']++; |
|
| 1028 | 1028 | } |
| 1029 | 1029 | // Town |
| 1030 | - if (! empty($arrayfields['s.town']['checked'])) |
|
| 1030 | + if (!empty($arrayfields['s.town']['checked'])) |
|
| 1031 | 1031 | { |
| 1032 | 1032 | print '<td class="nocellnopadd">'; |
| 1033 | 1033 | print $obj->town; |
| 1034 | 1034 | print '</td>'; |
| 1035 | - if (! $i) $totalarray['nbfield']++; |
|
| 1035 | + if (!$i) $totalarray['nbfield']++; |
|
| 1036 | 1036 | } |
| 1037 | 1037 | // Zip |
| 1038 | - if (! empty($arrayfields['s.zip']['checked'])) |
|
| 1038 | + if (!empty($arrayfields['s.zip']['checked'])) |
|
| 1039 | 1039 | { |
| 1040 | 1040 | print '<td class="nocellnopadd">'; |
| 1041 | 1041 | print $obj->zip; |
| 1042 | 1042 | print '</td>'; |
| 1043 | - if (! $i) $totalarray['nbfield']++; |
|
| 1043 | + if (!$i) $totalarray['nbfield']++; |
|
| 1044 | 1044 | } |
| 1045 | 1045 | // State |
| 1046 | - if (! empty($arrayfields['state.nom']['checked'])) |
|
| 1046 | + if (!empty($arrayfields['state.nom']['checked'])) |
|
| 1047 | 1047 | { |
| 1048 | 1048 | print "<td>".$obj->state_name."</td>\n"; |
| 1049 | - if (! $i) $totalarray['nbfield']++; |
|
| 1049 | + if (!$i) $totalarray['nbfield']++; |
|
| 1050 | 1050 | } |
| 1051 | 1051 | // Country |
| 1052 | - if (! empty($arrayfields['country.code_iso']['checked'])) |
|
| 1052 | + if (!empty($arrayfields['country.code_iso']['checked'])) |
|
| 1053 | 1053 | { |
| 1054 | 1054 | print '<td align="center">'; |
| 1055 | - $tmparray=getCountry($obj->fk_pays,'all'); |
|
| 1055 | + $tmparray = getCountry($obj->fk_pays, 'all'); |
|
| 1056 | 1056 | print $tmparray['label']; |
| 1057 | 1057 | print '</td>'; |
| 1058 | - if (! $i) $totalarray['nbfield']++; |
|
| 1058 | + if (!$i) $totalarray['nbfield']++; |
|
| 1059 | 1059 | } |
| 1060 | 1060 | // Type ent |
| 1061 | - if (! empty($arrayfields['typent.code']['checked'])) |
|
| 1061 | + if (!empty($arrayfields['typent.code']['checked'])) |
|
| 1062 | 1062 | { |
| 1063 | 1063 | print '<td align="center">'; |
| 1064 | - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); |
|
| 1064 | + if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); |
|
| 1065 | 1065 | print $typenArray[$obj->typent_code]; |
| 1066 | 1066 | print '</td>'; |
| 1067 | - if (! $i) $totalarray['nbfield']++; |
|
| 1067 | + if (!$i) $totalarray['nbfield']++; |
|
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | // Payment mode |
| 1071 | - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
| 1071 | + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
| 1072 | 1072 | { |
| 1073 | 1073 | print '<td>'; |
| 1074 | 1074 | $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); |
| 1075 | 1075 | print '</td>'; |
| 1076 | - if (! $i) $totalarray['nbfield']++; |
|
| 1076 | + if (!$i) $totalarray['nbfield']++; |
|
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | // Amount HT |
| 1080 | - if (! empty($arrayfields['f.total_ht']['checked'])) |
|
| 1080 | + if (!empty($arrayfields['f.total_ht']['checked'])) |
|
| 1081 | 1081 | { |
| 1082 | 1082 | print '<td align="right">'.price($obj->total_ht)."</td>\n"; |
| 1083 | - if (! $i) $totalarray['nbfield']++; |
|
| 1084 | - if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield']; |
|
| 1083 | + if (!$i) $totalarray['nbfield']++; |
|
| 1084 | + if (!$i) $totalarray['totalhtfield'] = $totalarray['nbfield']; |
|
| 1085 | 1085 | $totalarray['totalht'] += $obj->total_ht; |
| 1086 | 1086 | } |
| 1087 | 1087 | // Amount VAT |
| 1088 | - if (! empty($arrayfields['f.total_vat']['checked'])) |
|
| 1088 | + if (!empty($arrayfields['f.total_vat']['checked'])) |
|
| 1089 | 1089 | { |
| 1090 | 1090 | print '<td align="right">'.price($obj->total_vat)."</td>\n"; |
| 1091 | - if (! $i) $totalarray['nbfield']++; |
|
| 1092 | - if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield']; |
|
| 1091 | + if (!$i) $totalarray['nbfield']++; |
|
| 1092 | + if (!$i) $totalarray['totalvatfield'] = $totalarray['nbfield']; |
|
| 1093 | 1093 | $totalarray['totalvat'] += $obj->total_vat; |
| 1094 | 1094 | } |
| 1095 | 1095 | // Amount LocalTax1 |
| 1096 | - if (! empty($arrayfields['f.total_localtax1']['checked'])) |
|
| 1096 | + if (!empty($arrayfields['f.total_localtax1']['checked'])) |
|
| 1097 | 1097 | { |
| 1098 | 1098 | print '<td align="right">'.price($obj->total_localtax1)."</td>\n"; |
| 1099 | - if (! $i) $totalarray['nbfield']++; |
|
| 1100 | - if (! $i) $totalarray['totallocaltax1field']=$totalarray['nbfield']; |
|
| 1099 | + if (!$i) $totalarray['nbfield']++; |
|
| 1100 | + if (!$i) $totalarray['totallocaltax1field'] = $totalarray['nbfield']; |
|
| 1101 | 1101 | $totalarray['totallocaltax1'] += $obj->total_localtax1; |
| 1102 | 1102 | } |
| 1103 | 1103 | // Amount LocalTax2 |
| 1104 | - if (! empty($arrayfields['f.total_localtax2']['checked'])) |
|
| 1104 | + if (!empty($arrayfields['f.total_localtax2']['checked'])) |
|
| 1105 | 1105 | { |
| 1106 | 1106 | print '<td align="right">'.price($obj->total_localtax2)."</td>\n"; |
| 1107 | - if (! $i) $totalarray['nbfield']++; |
|
| 1108 | - if (! $i) $totalarray['totallocaltax2field']=$totalarray['nbfield']; |
|
| 1107 | + if (!$i) $totalarray['nbfield']++; |
|
| 1108 | + if (!$i) $totalarray['totallocaltax2field'] = $totalarray['nbfield']; |
|
| 1109 | 1109 | $totalarray['totallocaltax2'] += $obj->total_localtax2; |
| 1110 | 1110 | } |
| 1111 | 1111 | // Amount TTC |
| 1112 | - if (! empty($arrayfields['f.total_ttc']['checked'])) |
|
| 1112 | + if (!empty($arrayfields['f.total_ttc']['checked'])) |
|
| 1113 | 1113 | { |
| 1114 | 1114 | print '<td align="right">'.price($obj->total_ttc)."</td>\n"; |
| 1115 | - if (! $i) $totalarray['nbfield']++; |
|
| 1116 | - if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; |
|
| 1115 | + if (!$i) $totalarray['nbfield']++; |
|
| 1116 | + if (!$i) $totalarray['totalttcfield'] = $totalarray['nbfield']; |
|
| 1117 | 1117 | $totalarray['totalttc'] += $obj->total_ttc; |
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | - if (! empty($arrayfields['dynamount_payed']['checked'])) |
|
| 1120 | + if (!empty($arrayfields['dynamount_payed']['checked'])) |
|
| 1121 | 1121 | { |
| 1122 | - print '<td align="right">'.(! empty($totalpay)?price($totalpay,0,$langs):' ').'</td>'; // TODO Use a denormalized field |
|
| 1123 | - if (! $i) $totalarray['nbfield']++; |
|
| 1124 | - if (! $i) $totalarray['totalamfield']=$totalarray['nbfield']; |
|
| 1122 | + print '<td align="right">'.(!empty($totalpay) ? price($totalpay, 0, $langs) : ' ').'</td>'; // TODO Use a denormalized field |
|
| 1123 | + if (!$i) $totalarray['nbfield']++; |
|
| 1124 | + if (!$i) $totalarray['totalamfield'] = $totalarray['nbfield']; |
|
| 1125 | 1125 | $totalarray['totalam'] += $totalpay; |
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | - if (! empty($arrayfields['rtp']['checked'])) |
|
| 1128 | + if (!empty($arrayfields['rtp']['checked'])) |
|
| 1129 | 1129 | { |
| 1130 | - print '<td align="right">'.(! empty($remaintopay)?price($remaintopay,0,$langs):' ').'</td>'; // TODO Use a denormalized field |
|
| 1131 | - if (! $i) $totalarray['nbfield']++; |
|
| 1132 | - if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield']; |
|
| 1130 | + print '<td align="right">'.(!empty($remaintopay) ? price($remaintopay, 0, $langs) : ' ').'</td>'; // TODO Use a denormalized field |
|
| 1131 | + if (!$i) $totalarray['nbfield']++; |
|
| 1132 | + if (!$i) $totalarray['totalrtpfield'] = $totalarray['nbfield']; |
|
| 1133 | 1133 | $totalarray['totalrtp'] += $remaintopay; |
| 1134 | 1134 | } |
| 1135 | 1135 | |
@@ -1137,61 +1137,61 @@ discard block |
||
| 1137 | 1137 | // Extra fields |
| 1138 | 1138 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 1139 | 1139 | { |
| 1140 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 1140 | + foreach ($extrafields->attribute_label as $key => $val) |
|
| 1141 | 1141 | { |
| 1142 | - if (! empty($arrayfields["ef.".$key]['checked'])) |
|
| 1142 | + if (!empty($arrayfields["ef.".$key]['checked'])) |
|
| 1143 | 1143 | { |
| 1144 | 1144 | print '<td'; |
| 1145 | - $align=$extrafields->getAlignFlag($key); |
|
| 1145 | + $align = $extrafields->getAlignFlag($key); |
|
| 1146 | 1146 | if ($align) print ' align="'.$align.'"'; |
| 1147 | 1147 | print '>'; |
| 1148 | - $tmpkey='options_'.$key; |
|
| 1148 | + $tmpkey = 'options_'.$key; |
|
| 1149 | 1149 | print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); |
| 1150 | 1150 | print '</td>'; |
| 1151 | - if (! $i) $totalarray['nbfield']++; |
|
| 1151 | + if (!$i) $totalarray['nbfield']++; |
|
| 1152 | 1152 | } |
| 1153 | 1153 | } |
| 1154 | 1154 | } |
| 1155 | 1155 | // Fields from hook |
| 1156 | - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); |
|
| 1157 | - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook |
|
| 1156 | + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); |
|
| 1157 | + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook |
|
| 1158 | 1158 | print $hookmanager->resPrint; |
| 1159 | 1159 | // Date creation |
| 1160 | - if (! empty($arrayfields['f.datec']['checked'])) |
|
| 1160 | + if (!empty($arrayfields['f.datec']['checked'])) |
|
| 1161 | 1161 | { |
| 1162 | 1162 | print '<td align="center" class="nowrap">'; |
| 1163 | 1163 | print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); |
| 1164 | 1164 | print '</td>'; |
| 1165 | - if (! $i) $totalarray['nbfield']++; |
|
| 1165 | + if (!$i) $totalarray['nbfield']++; |
|
| 1166 | 1166 | } |
| 1167 | 1167 | // Date modification |
| 1168 | - if (! empty($arrayfields['f.tms']['checked'])) |
|
| 1168 | + if (!empty($arrayfields['f.tms']['checked'])) |
|
| 1169 | 1169 | { |
| 1170 | 1170 | print '<td align="center" class="nowrap">'; |
| 1171 | 1171 | print dol_print_date($db->jdate($obj->date_update), 'dayhour'); |
| 1172 | 1172 | print '</td>'; |
| 1173 | - if (! $i) $totalarray['nbfield']++; |
|
| 1173 | + if (!$i) $totalarray['nbfield']++; |
|
| 1174 | 1174 | } |
| 1175 | 1175 | // Status |
| 1176 | - if (! empty($arrayfields['f.fk_statut']['checked'])) |
|
| 1176 | + if (!empty($arrayfields['f.fk_statut']['checked'])) |
|
| 1177 | 1177 | { |
| 1178 | 1178 | print '<td align="right" class="nowrap">'; |
| 1179 | 1179 | // TODO $paiement is not yet defined |
| 1180 | - print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type); |
|
| 1180 | + print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type); |
|
| 1181 | 1181 | print "</td>"; |
| 1182 | - if (! $i) $totalarray['nbfield']++; |
|
| 1182 | + if (!$i) $totalarray['nbfield']++; |
|
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | // Action column |
| 1186 | 1186 | print '<td class="nowrap" align="center">'; |
| 1187 | 1187 | if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
| 1188 | 1188 | { |
| 1189 | - $selected=0; |
|
| 1190 | - if (in_array($obj->facid, $arrayofselected)) $selected=1; |
|
| 1191 | - print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected?' checked="checked"':'').'>'; |
|
| 1189 | + $selected = 0; |
|
| 1190 | + if (in_array($obj->facid, $arrayofselected)) $selected = 1; |
|
| 1191 | + print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected ? ' checked="checked"' : '').'>'; |
|
| 1192 | 1192 | } |
| 1193 | 1193 | print '</td>'; |
| 1194 | - if (! $i) $totalarray['nbfield']++; |
|
| 1194 | + if (!$i) $totalarray['nbfield']++; |
|
| 1195 | 1195 | |
| 1196 | 1196 | print "</tr>\n"; |
| 1197 | 1197 | |
@@ -1209,7 +1209,7 @@ discard block |
||
| 1209 | 1209 | ) |
| 1210 | 1210 | { |
| 1211 | 1211 | print '<tr class="liste_total">'; |
| 1212 | - $i=0; |
|
| 1212 | + $i = 0; |
|
| 1213 | 1213 | while ($i < $totalarray['nbfield']) |
| 1214 | 1214 | { |
| 1215 | 1215 | $i++; |
@@ -1234,8 +1234,8 @@ discard block |
||
| 1234 | 1234 | |
| 1235 | 1235 | $db->free($resql); |
| 1236 | 1236 | |
| 1237 | - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); |
|
| 1238 | - $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook |
|
| 1237 | + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); |
|
| 1238 | + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook |
|
| 1239 | 1239 | print $hookmanager->resPrint; |
| 1240 | 1240 | |
| 1241 | 1241 | print "</table>\n"; |
@@ -56,7 +56,10 @@ discard block |
||
| 56 | 56 | $conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation; |
| 57 | 57 | $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; |
| 58 | 58 | $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; |
| 59 | -if (defined('TEST_DB_FORCE_TYPE')) $conf->db->type=constant('TEST_DB_FORCE_TYPE'); // Force db type (for test purpose, by PHP unit for example) |
|
| 59 | +if (defined('TEST_DB_FORCE_TYPE')) { |
|
| 60 | + $conf->db->type=constant('TEST_DB_FORCE_TYPE'); |
|
| 61 | +} |
|
| 62 | +// Force db type (for test purpose, by PHP unit for example) |
|
| 60 | 63 | |
| 61 | 64 | // Set properties specific to conf file |
| 62 | 65 | $conf->file->main_limit_users = $dolibarr_main_limit_users; |
@@ -73,7 +76,9 @@ discard block |
||
| 73 | 76 | // dolibarr_main_document_root_alt can contains several directories |
| 74 | 77 | $values=preg_split('/[;,]/',$dolibarr_main_document_root_alt); |
| 75 | 78 | $i=0; |
| 76 | - foreach($values as $value) $conf->file->dol_document_root['alt'.($i++)]=(string) $value; |
|
| 79 | + foreach($values as $value) { |
|
| 80 | + $conf->file->dol_document_root['alt'.($i++)]=(string) $value; |
|
| 81 | + } |
|
| 77 | 82 | $values=preg_split('/[;,]/',$dolibarr_main_url_root_alt); |
| 78 | 83 | $i=0; |
| 79 | 84 | foreach($values as $value) |
@@ -99,9 +104,16 @@ discard block |
||
| 99 | 104 | } |
| 100 | 105 | |
| 101 | 106 | // Chargement des includes principaux de librairies communes |
| 102 | -if (! defined('NOREQUIREUSER')) require_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; // Need 500ko memory |
|
| 103 | -if (! defined('NOREQUIRETRAN')) require_once DOL_DOCUMENT_ROOT .'/core/class/translate.class.php'; |
|
| 104 | -if (! defined('NOREQUIRESOC')) require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; |
|
| 107 | +if (! defined('NOREQUIREUSER')) { |
|
| 108 | + require_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; |
|
| 109 | +} |
|
| 110 | +// Need 500ko memory |
|
| 111 | +if (! defined('NOREQUIRETRAN')) { |
|
| 112 | + require_once DOL_DOCUMENT_ROOT .'/core/class/translate.class.php'; |
|
| 113 | +} |
|
| 114 | +if (! defined('NOREQUIRESOC')) { |
|
| 115 | + require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; |
|
| 116 | +} |
|
| 105 | 117 | |
| 106 | 118 | |
| 107 | 119 | /* |
@@ -144,25 +156,32 @@ discard block |
||
| 144 | 156 | */ |
| 145 | 157 | |
| 146 | 158 | // By default conf->entity is 1, but we change this if we ask another value. |
| 147 | -if (session_id() && ! empty($_SESSION["dol_entity"])) // Entity inside an opened session |
|
| 159 | +if (session_id() && ! empty($_SESSION["dol_entity"])) { |
|
| 160 | + // Entity inside an opened session |
|
| 148 | 161 | { |
| 149 | 162 | $conf->entity = $_SESSION["dol_entity"]; |
| 150 | 163 | } |
| 151 | -else if (! empty($_ENV["dol_entity"])) // Entity inside a CLI script |
|
| 164 | +} else if (! empty($_ENV["dol_entity"])) { |
|
| 165 | + // Entity inside a CLI script |
|
| 152 | 166 | { |
| 153 | 167 | $conf->entity = $_ENV["dol_entity"]; |
| 154 | 168 | } |
| 155 | -else if (isset($_POST["loginfunction"]) && GETPOST("entity")) // Just after a login page |
|
| 169 | +} else if (isset($_POST["loginfunction"]) && GETPOST("entity")) { |
|
| 170 | + // Just after a login page |
|
| 156 | 171 | { |
| 157 | 172 | $conf->entity = GETPOST("entity",'int'); |
| 158 | 173 | } |
| 159 | -else if (defined('DOLENTITY') && is_numeric(DOLENTITY)) // For public page with MultiCompany module |
|
| 174 | +} else if (defined('DOLENTITY') && is_numeric(DOLENTITY)) { |
|
| 175 | + // For public page with MultiCompany module |
|
| 160 | 176 | { |
| 161 | 177 | $conf->entity = DOLENTITY; |
| 162 | 178 | } |
| 179 | +} |
|
| 163 | 180 | |
| 164 | 181 | // Sanitize entity |
| 165 | -if (! is_numeric($conf->entity)) $conf->entity=1; |
|
| 182 | +if (! is_numeric($conf->entity)) { |
|
| 183 | + $conf->entity=1; |
|
| 184 | +} |
|
| 166 | 185 | |
| 167 | 186 | if (! defined('NOREQUIREDB')) |
| 168 | 187 | { |
@@ -194,11 +213,26 @@ discard block |
||
| 194 | 213 | if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) |
| 195 | 214 | { |
| 196 | 215 | $ok=0; |
| 197 | - if ((! session_id() || ! isset($_SESSION["dol_login"])) && ! isset($_POST["username"]) && ! empty($_SERVER["GATEWAY_INTERFACE"])) $ok=1; // We let working pages if not logged and inside a web browser (login form, to allow login by admin) |
|
| 198 | - elseif (isset($_POST["username"]) && $_POST["username"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) $ok=1; // We let working pages that is a login submission (login submit, to allow login by admin) |
|
| 199 | - elseif (defined('NOREQUIREDB')) $ok=1; // We let working pages that don't need database access (xxx.css.php) |
|
| 200 | - elseif (defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) $ok=1; // We let working pages that ask to work even if only login enabled (logout.php) |
|
| 201 | - elseif (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) $ok=1; // We let working if user is allowed admin |
|
| 216 | + if ((! session_id() || ! isset($_SESSION["dol_login"])) && ! isset($_POST["username"]) && ! empty($_SERVER["GATEWAY_INTERFACE"])) { |
|
| 217 | + $ok=1; |
|
| 218 | + } |
|
| 219 | + // We let working pages if not logged and inside a web browser (login form, to allow login by admin) |
|
| 220 | + elseif (isset($_POST["username"]) && $_POST["username"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) { |
|
| 221 | + $ok=1; |
|
| 222 | + } |
|
| 223 | + // We let working pages that is a login submission (login submit, to allow login by admin) |
|
| 224 | + elseif (defined('NOREQUIREDB')) { |
|
| 225 | + $ok=1; |
|
| 226 | + } |
|
| 227 | + // We let working pages that don't need database access (xxx.css.php) |
|
| 228 | + elseif (defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) { |
|
| 229 | + $ok=1; |
|
| 230 | + } |
|
| 231 | + // We let working pages that ask to work even if only login enabled (logout.php) |
|
| 232 | + elseif (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) { |
|
| 233 | + $ok=1; |
|
| 234 | + } |
|
| 235 | + // We let working if user is allowed admin |
|
| 202 | 236 | if (! $ok) |
| 203 | 237 | { |
| 204 | 238 | if (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] != $conf->global->MAIN_ONLY_LOGIN_ALLOWED) |
@@ -207,8 +241,7 @@ discard block |
||
| 207 | 241 | print 'You are logged with user "'.$_SESSION["dol_login"].'" and only administrator user "'.$conf->global->MAIN_ONLY_LOGIN_ALLOWED.'" is allowed to connect for the moment.'."\n"; |
| 208 | 242 | $nexturl=DOL_URL_ROOT.'/user/logout.php'; |
| 209 | 243 | print 'Please try later or <a href="'.$nexturl.'">click here to disconnect and change login user</a>...'."\n"; |
| 210 | - } |
|
| 211 | - else |
|
| 244 | + } else |
|
| 212 | 245 | { |
| 213 | 246 | print 'Sorry, your application is offline. Only administrator user "'.$conf->global->MAIN_ONLY_LOGIN_ALLOWED.'" is allowed to connect for the moment.'."\n"; |
| 214 | 247 | $nexturl=DOL_URL_ROOT.'/'; |
@@ -227,8 +260,10 @@ discard block |
||
| 227 | 260 | $mysoc->setMysoc($conf); |
| 228 | 261 | |
| 229 | 262 | // For some countries, we need to invert our address with customer address |
| 230 | - if ($mysoc->country_code == 'DE' && ! isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $conf->global->MAIN_INVERT_SENDER_RECIPIENT=1; |
|
| 231 | -} |
|
| 263 | + if ($mysoc->country_code == 'DE' && ! isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
| 264 | + $conf->global->MAIN_INVERT_SENDER_RECIPIENT=1; |
|
| 265 | + } |
|
| 266 | + } |
|
| 232 | 267 | |
| 233 | 268 | |
| 234 | 269 | // Set default language (must be after the setValues setting global $conf->global->MAIN_LANG_DEFAULT. Page main.inc.php will overwrite langs->defaultlang with user value later) |
@@ -244,5 +279,7 @@ discard block |
||
| 244 | 279 | $hookmanager=new HookManager($db); |
| 245 | 280 | |
| 246 | 281 | |
| 247 | -if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR'); |
|
| 282 | +if (! defined('MAIN_LABEL_MENTION_NPR') ) { |
|
| 283 | + define('MAIN_LABEL_MENTION_NPR','NPR'); |
|
| 284 | +} |
|
| 248 | 285 | |