@@ -30,243 +30,243 @@ discard block |
||
| 30 | 30 | class Proposals extends DolibarrApi |
| 31 | 31 | { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var array $FIELDS Mandatory fields, checked when create and update object |
|
| 35 | - */ |
|
| 36 | - static $FIELDS = array( |
|
| 37 | - 'socid' |
|
| 38 | - ); |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var Propal $propal {@type Propal} |
|
| 42 | - */ |
|
| 43 | - public $propal; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Constructor |
|
| 47 | - */ |
|
| 48 | - function __construct() |
|
| 49 | - { |
|
| 50 | - global $db, $conf; |
|
| 51 | - $this->db = $db; |
|
| 52 | - $this->propal = new Propal($this->db); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Get properties of a commercial proposal object |
|
| 57 | - * |
|
| 58 | - * Return an array with commercial proposal informations |
|
| 59 | - * |
|
| 60 | - * @param int $id ID of commercial proposal |
|
| 61 | - * @return array|mixed data without useless information |
|
| 62 | - * |
|
| 63 | - * @throws RestException |
|
| 64 | - */ |
|
| 65 | - function get($id) |
|
| 66 | - { |
|
| 67 | - if(! DolibarrApiAccess::$user->rights->propal->lire) { |
|
| 68 | - throw new RestException(401); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $result = $this->propal->fetch($id); |
|
| 72 | - if( ! $result ) { |
|
| 73 | - throw new RestException(404, 'Commercial Proposal not found'); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 77 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // Add external contacts ids |
|
| 81 | - $this->propal->contacts_ids = $this->propal->liste_contact(-1,'external',1); |
|
| 82 | - |
|
| 83 | - $this->propal->fetchObjectLinked(); |
|
| 84 | - return $this->_cleanObjectDatas($this->propal); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * List commercial proposals |
|
| 89 | - * |
|
| 90 | - * Get a list of commercial proposals |
|
| 91 | - * |
|
| 92 | - * @param string $sortfield Sort field |
|
| 93 | - * @param string $sortorder Sort order |
|
| 94 | - * @param int $limit Limit for list |
|
| 95 | - * @param int $page Page number |
|
| 96 | - * @param string $thirdparty_ids Thirdparty ids to filter commercial proposals. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} |
|
| 97 | - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" |
|
| 98 | - * @return array Array of order objects |
|
| 99 | - */ |
|
| 33 | + /** |
|
| 34 | + * @var array $FIELDS Mandatory fields, checked when create and update object |
|
| 35 | + */ |
|
| 36 | + static $FIELDS = array( |
|
| 37 | + 'socid' |
|
| 38 | + ); |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var Propal $propal {@type Propal} |
|
| 42 | + */ |
|
| 43 | + public $propal; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Constructor |
|
| 47 | + */ |
|
| 48 | + function __construct() |
|
| 49 | + { |
|
| 50 | + global $db, $conf; |
|
| 51 | + $this->db = $db; |
|
| 52 | + $this->propal = new Propal($this->db); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Get properties of a commercial proposal object |
|
| 57 | + * |
|
| 58 | + * Return an array with commercial proposal informations |
|
| 59 | + * |
|
| 60 | + * @param int $id ID of commercial proposal |
|
| 61 | + * @return array|mixed data without useless information |
|
| 62 | + * |
|
| 63 | + * @throws RestException |
|
| 64 | + */ |
|
| 65 | + function get($id) |
|
| 66 | + { |
|
| 67 | + if(! DolibarrApiAccess::$user->rights->propal->lire) { |
|
| 68 | + throw new RestException(401); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $result = $this->propal->fetch($id); |
|
| 72 | + if( ! $result ) { |
|
| 73 | + throw new RestException(404, 'Commercial Proposal not found'); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 77 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // Add external contacts ids |
|
| 81 | + $this->propal->contacts_ids = $this->propal->liste_contact(-1,'external',1); |
|
| 82 | + |
|
| 83 | + $this->propal->fetchObjectLinked(); |
|
| 84 | + return $this->_cleanObjectDatas($this->propal); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * List commercial proposals |
|
| 89 | + * |
|
| 90 | + * Get a list of commercial proposals |
|
| 91 | + * |
|
| 92 | + * @param string $sortfield Sort field |
|
| 93 | + * @param string $sortorder Sort order |
|
| 94 | + * @param int $limit Limit for list |
|
| 95 | + * @param int $page Page number |
|
| 96 | + * @param string $thirdparty_ids Thirdparty ids to filter commercial proposals. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} |
|
| 97 | + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" |
|
| 98 | + * @return array Array of order objects |
|
| 99 | + */ |
|
| 100 | 100 | function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') |
| 101 | 101 | { |
| 102 | - global $db, $conf; |
|
| 103 | - |
|
| 104 | - $obj_ret = array(); |
|
| 105 | - |
|
| 106 | - // case of external user, $thirdparty_ids param is ignored and replaced by user's socid |
|
| 107 | - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; |
|
| 108 | - |
|
| 109 | - // If the internal user must only see his customers, force searching by him |
|
| 110 | - $search_sale = 0; |
|
| 111 | - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; |
|
| 112 | - |
|
| 113 | - $sql = "SELECT t.rowid"; |
|
| 114 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
| 115 | - $sql.= " FROM ".MAIN_DB_PREFIX."propal as t"; |
|
| 116 | - |
|
| 117 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 118 | - |
|
| 119 | - $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; |
|
| 120 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 121 | - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; |
|
| 122 | - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale |
|
| 123 | - // Insert sale filter |
|
| 124 | - if ($search_sale > 0) |
|
| 125 | - { |
|
| 126 | - $sql .= " AND sc.fk_user = ".$search_sale; |
|
| 127 | - } |
|
| 128 | - // Add sql filters |
|
| 129 | - if ($sqlfilters) |
|
| 130 | - { |
|
| 131 | - if (! DolibarrApi::_checkFilters($sqlfilters)) |
|
| 132 | - { |
|
| 133 | - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); |
|
| 134 | - } |
|
| 135 | - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 136 | - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - $sql.= $db->order($sortfield, $sortorder); |
|
| 140 | - if ($limit) { |
|
| 141 | - if ($page < 0) |
|
| 142 | - { |
|
| 143 | - $page = 0; |
|
| 144 | - } |
|
| 145 | - $offset = $limit * $page; |
|
| 146 | - |
|
| 147 | - $sql.= $db->plimit($limit + 1, $offset); |
|
| 148 | - } |
|
| 102 | + global $db, $conf; |
|
| 103 | + |
|
| 104 | + $obj_ret = array(); |
|
| 105 | + |
|
| 106 | + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid |
|
| 107 | + $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; |
|
| 108 | + |
|
| 109 | + // If the internal user must only see his customers, force searching by him |
|
| 110 | + $search_sale = 0; |
|
| 111 | + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; |
|
| 112 | + |
|
| 113 | + $sql = "SELECT t.rowid"; |
|
| 114 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
| 115 | + $sql.= " FROM ".MAIN_DB_PREFIX."propal as t"; |
|
| 116 | + |
|
| 117 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 118 | + |
|
| 119 | + $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; |
|
| 120 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 121 | + if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; |
|
| 122 | + if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale |
|
| 123 | + // Insert sale filter |
|
| 124 | + if ($search_sale > 0) |
|
| 125 | + { |
|
| 126 | + $sql .= " AND sc.fk_user = ".$search_sale; |
|
| 127 | + } |
|
| 128 | + // Add sql filters |
|
| 129 | + if ($sqlfilters) |
|
| 130 | + { |
|
| 131 | + if (! DolibarrApi::_checkFilters($sqlfilters)) |
|
| 132 | + { |
|
| 133 | + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); |
|
| 134 | + } |
|
| 135 | + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 136 | + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + $sql.= $db->order($sortfield, $sortorder); |
|
| 140 | + if ($limit) { |
|
| 141 | + if ($page < 0) |
|
| 142 | + { |
|
| 143 | + $page = 0; |
|
| 144 | + } |
|
| 145 | + $offset = $limit * $page; |
|
| 146 | + |
|
| 147 | + $sql.= $db->plimit($limit + 1, $offset); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | 150 | dol_syslog("API Rest request"); |
| 151 | - $result = $db->query($sql); |
|
| 152 | - |
|
| 153 | - if ($result) |
|
| 154 | - { |
|
| 155 | - $num = $db->num_rows($result); |
|
| 156 | - $min = min($num, ($limit <= 0 ? $num : $limit)); |
|
| 157 | - $i = 0; |
|
| 158 | - while ($i < $min) |
|
| 159 | - { |
|
| 160 | - $obj = $db->fetch_object($result); |
|
| 161 | - $proposal_static = new Propal($db); |
|
| 162 | - if($proposal_static->fetch($obj->rowid)) { |
|
| 163 | - // Add external contacts ids |
|
| 164 | - $proposal_static->contacts_ids = $proposal_static->liste_contact(-1,'external',1); |
|
| 165 | - $obj_ret[] = $this->_cleanObjectDatas($proposal_static); |
|
| 166 | - } |
|
| 167 | - $i++; |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - else { |
|
| 171 | - throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror()); |
|
| 172 | - } |
|
| 173 | - if( ! count($obj_ret)) { |
|
| 174 | - throw new RestException(404, 'No proposal found'); |
|
| 175 | - } |
|
| 176 | - return $obj_ret; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * Create commercial proposal object |
|
| 181 | - * |
|
| 182 | - * @param array $request_data Request data |
|
| 183 | - * @return int ID of proposal |
|
| 184 | - */ |
|
| 185 | - function post($request_data = null) |
|
| 186 | - { |
|
| 187 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 188 | - throw new RestException(401, "Insuffisant rights"); |
|
| 189 | - } |
|
| 190 | - // Check mandatory fields |
|
| 191 | - $result = $this->_validate($request_data); |
|
| 192 | - |
|
| 193 | - foreach($request_data as $field => $value) { |
|
| 194 | - $this->propal->$field = $value; |
|
| 195 | - } |
|
| 196 | - /*if (isset($request_data["lines"])) { |
|
| 151 | + $result = $db->query($sql); |
|
| 152 | + |
|
| 153 | + if ($result) |
|
| 154 | + { |
|
| 155 | + $num = $db->num_rows($result); |
|
| 156 | + $min = min($num, ($limit <= 0 ? $num : $limit)); |
|
| 157 | + $i = 0; |
|
| 158 | + while ($i < $min) |
|
| 159 | + { |
|
| 160 | + $obj = $db->fetch_object($result); |
|
| 161 | + $proposal_static = new Propal($db); |
|
| 162 | + if($proposal_static->fetch($obj->rowid)) { |
|
| 163 | + // Add external contacts ids |
|
| 164 | + $proposal_static->contacts_ids = $proposal_static->liste_contact(-1,'external',1); |
|
| 165 | + $obj_ret[] = $this->_cleanObjectDatas($proposal_static); |
|
| 166 | + } |
|
| 167 | + $i++; |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + else { |
|
| 171 | + throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror()); |
|
| 172 | + } |
|
| 173 | + if( ! count($obj_ret)) { |
|
| 174 | + throw new RestException(404, 'No proposal found'); |
|
| 175 | + } |
|
| 176 | + return $obj_ret; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * Create commercial proposal object |
|
| 181 | + * |
|
| 182 | + * @param array $request_data Request data |
|
| 183 | + * @return int ID of proposal |
|
| 184 | + */ |
|
| 185 | + function post($request_data = null) |
|
| 186 | + { |
|
| 187 | + if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 188 | + throw new RestException(401, "Insuffisant rights"); |
|
| 189 | + } |
|
| 190 | + // Check mandatory fields |
|
| 191 | + $result = $this->_validate($request_data); |
|
| 192 | + |
|
| 193 | + foreach($request_data as $field => $value) { |
|
| 194 | + $this->propal->$field = $value; |
|
| 195 | + } |
|
| 196 | + /*if (isset($request_data["lines"])) { |
|
| 197 | 197 | $lines = array(); |
| 198 | 198 | foreach ($request_data["lines"] as $line) { |
| 199 | 199 | array_push($lines, (object) $line); |
| 200 | 200 | } |
| 201 | 201 | $this->propal->lines = $lines; |
| 202 | 202 | }*/ |
| 203 | - if ($this->propal->create(DolibarrApiAccess::$user) < 0) { |
|
| 204 | - throw new RestException(500, "Error creating order", array_merge(array($this->propal->error), $this->propal->errors)); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - return $this->propal->id; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * Get lines of a commercial proposal |
|
| 212 | - * |
|
| 213 | - * @param int $id Id of commercial proposal |
|
| 214 | - * |
|
| 215 | - * @url GET {id}/lines |
|
| 216 | - * |
|
| 217 | - * @return int |
|
| 218 | - */ |
|
| 203 | + if ($this->propal->create(DolibarrApiAccess::$user) < 0) { |
|
| 204 | + throw new RestException(500, "Error creating order", array_merge(array($this->propal->error), $this->propal->errors)); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + return $this->propal->id; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * Get lines of a commercial proposal |
|
| 212 | + * |
|
| 213 | + * @param int $id Id of commercial proposal |
|
| 214 | + * |
|
| 215 | + * @url GET {id}/lines |
|
| 216 | + * |
|
| 217 | + * @return int |
|
| 218 | + */ |
|
| 219 | 219 | function getLines($id) |
| 220 | 220 | { |
| 221 | - if(! DolibarrApiAccess::$user->rights->propal->lire) { |
|
| 222 | - throw new RestException(401); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - $result = $this->propal->fetch($id); |
|
| 226 | - if( ! $result ) { |
|
| 227 | - throw new RestException(404, 'Commercial Proposal not found'); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 231 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 232 | - } |
|
| 233 | - $this->propal->getLinesArray(); |
|
| 234 | - $result = array(); |
|
| 235 | - foreach ($this->propal->lines as $line) { |
|
| 236 | - array_push($result,$this->_cleanObjectDatas($line)); |
|
| 237 | - } |
|
| 238 | - return $result; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * Add a line to given commercial proposal |
|
| 243 | - * |
|
| 244 | - * @param int $id Id of commercial proposal to update |
|
| 245 | - * @param array $request_data Commercial proposal line data |
|
| 246 | - * |
|
| 247 | - * @url POST {id}/lines |
|
| 248 | - * |
|
| 249 | - * @return int |
|
| 250 | - */ |
|
| 251 | - function postLine($id, $request_data = null) |
|
| 252 | - { |
|
| 253 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 254 | - throw new RestException(401); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - $result = $this->propal->fetch($id); |
|
| 258 | - if (! $result) { |
|
| 259 | - throw new RestException(404, 'Commercial Proposal not found'); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - if (! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) |
|
| 263 | - { |
|
| 264 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - $request_data = (object) $request_data; |
|
| 268 | - |
|
| 269 | - $updateRes = $this->propal->addline( |
|
| 221 | + if(! DolibarrApiAccess::$user->rights->propal->lire) { |
|
| 222 | + throw new RestException(401); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + $result = $this->propal->fetch($id); |
|
| 226 | + if( ! $result ) { |
|
| 227 | + throw new RestException(404, 'Commercial Proposal not found'); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 231 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 232 | + } |
|
| 233 | + $this->propal->getLinesArray(); |
|
| 234 | + $result = array(); |
|
| 235 | + foreach ($this->propal->lines as $line) { |
|
| 236 | + array_push($result,$this->_cleanObjectDatas($line)); |
|
| 237 | + } |
|
| 238 | + return $result; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * Add a line to given commercial proposal |
|
| 243 | + * |
|
| 244 | + * @param int $id Id of commercial proposal to update |
|
| 245 | + * @param array $request_data Commercial proposal line data |
|
| 246 | + * |
|
| 247 | + * @url POST {id}/lines |
|
| 248 | + * |
|
| 249 | + * @return int |
|
| 250 | + */ |
|
| 251 | + function postLine($id, $request_data = null) |
|
| 252 | + { |
|
| 253 | + if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 254 | + throw new RestException(401); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + $result = $this->propal->fetch($id); |
|
| 258 | + if (! $result) { |
|
| 259 | + throw new RestException(404, 'Commercial Proposal not found'); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + if (! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) |
|
| 263 | + { |
|
| 264 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + $request_data = (object) $request_data; |
|
| 268 | + |
|
| 269 | + $updateRes = $this->propal->addline( |
|
| 270 | 270 | $request_data->desc, |
| 271 | 271 | $request_data->subprice, |
| 272 | 272 | $request_data->qty, |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $request_data->product_type, |
| 282 | 282 | $request_data->rang, |
| 283 | 283 | $request_data->special_code, |
| 284 | - $request_data->fk_parent_line, |
|
| 284 | + $request_data->fk_parent_line, |
|
| 285 | 285 | $request_data->fk_fournprice, |
| 286 | 286 | $request_data->pa_ht, |
| 287 | 287 | $request_data->label, |
@@ -293,293 +293,293 @@ discard block |
||
| 293 | 293 | $request_data->origin_id, |
| 294 | 294 | $request_data->multicurrency_subprice, |
| 295 | 295 | $request_data->fk_remise_except |
| 296 | - ); |
|
| 296 | + ); |
|
| 297 | 297 | |
| 298 | - if ($updateRes > 0) { |
|
| 298 | + if ($updateRes > 0) { |
|
| 299 | 299 | return $updateRes; |
| 300 | - } |
|
| 301 | - else { |
|
| 302 | - throw new RestException(400, $this->propal->error); |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * Update a line of given commercial proposal |
|
| 308 | - * |
|
| 309 | - * @param int $id Id of commercial proposal to update |
|
| 310 | - * @param int $lineid Id of line to update |
|
| 311 | - * @param array $request_data Commercial proposal line data |
|
| 312 | - * |
|
| 313 | - * @url PUT {id}/lines/{lineid} |
|
| 314 | - * |
|
| 315 | - * @return object |
|
| 316 | - */ |
|
| 317 | - function putLine($id, $lineid, $request_data = null) |
|
| 318 | - { |
|
| 319 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 320 | - throw new RestException(401); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - $result = $this->propal->fetch($id); |
|
| 324 | - if($result <= 0) { |
|
| 325 | - throw new RestException(404, 'Proposal not found'); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 329 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - $request_data = (object) $request_data; |
|
| 333 | - |
|
| 334 | - $propalline = new PropaleLigne($this->db); |
|
| 335 | - $result = $propalline->fetch($lineid); |
|
| 336 | - if ($result <= 0) { |
|
| 337 | - throw new RestException(404, 'Proposal line not found'); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - $updateRes = $this->propal->updateline( |
|
| 341 | - $lineid, |
|
| 342 | - isset($request_data->subprice)?$request_data->subprice:$propalline->subprice, |
|
| 343 | - isset($request_data->qty)?$request_data->qty:$propalline->qty, |
|
| 344 | - isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent, |
|
| 345 | - isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx, |
|
| 346 | - isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx, |
|
| 347 | - isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx, |
|
| 348 | - isset($request_data->desc)?$request_data->desc:$propalline->desc, |
|
| 349 | - 'HT', |
|
| 350 | - isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits, |
|
| 351 | - isset($request_data->special_code)?$request_data->special_code:$propalline->special_code, |
|
| 352 | - isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line, |
|
| 353 | - 0, |
|
| 354 | - isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice, |
|
| 355 | - isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht, |
|
| 356 | - isset($request_data->label)?$request_data->label:$propalline->label, |
|
| 357 | - isset($request_data->product_type)?$request_data->product_type:$propalline->product_type, |
|
| 358 | - isset($request_data->date_start)?$request_data->date_start:$propalline->date_start, |
|
| 359 | - isset($request_data->date_end)?$request_data->date_end:$propalline->date_end, |
|
| 360 | - isset($request_data->array_options)?$request_data->array_options:$propalline->array_options, |
|
| 361 | - isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit, |
|
| 362 | - isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice |
|
| 363 | - ); |
|
| 364 | - |
|
| 365 | - if ($updateRes > 0) { |
|
| 366 | - $result = $this->get($id); |
|
| 367 | - unset($result->line); |
|
| 368 | - return $this->_cleanObjectDatas($result); |
|
| 369 | - } |
|
| 370 | - return false; |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - /** |
|
| 374 | - * Delete a line of given commercial proposal |
|
| 375 | - * |
|
| 376 | - * |
|
| 377 | - * @param int $id Id of commercial proposal to update |
|
| 378 | - * @param int $lineid Id of line to delete |
|
| 379 | - * |
|
| 380 | - * @url DELETE {id}/lines/{lineid} |
|
| 381 | - * |
|
| 382 | - * @return int |
|
| 300 | + } |
|
| 301 | + else { |
|
| 302 | + throw new RestException(400, $this->propal->error); |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * Update a line of given commercial proposal |
|
| 308 | + * |
|
| 309 | + * @param int $id Id of commercial proposal to update |
|
| 310 | + * @param int $lineid Id of line to update |
|
| 311 | + * @param array $request_data Commercial proposal line data |
|
| 312 | + * |
|
| 313 | + * @url PUT {id}/lines/{lineid} |
|
| 314 | + * |
|
| 315 | + * @return object |
|
| 316 | + */ |
|
| 317 | + function putLine($id, $lineid, $request_data = null) |
|
| 318 | + { |
|
| 319 | + if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 320 | + throw new RestException(401); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + $result = $this->propal->fetch($id); |
|
| 324 | + if($result <= 0) { |
|
| 325 | + throw new RestException(404, 'Proposal not found'); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 329 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + $request_data = (object) $request_data; |
|
| 333 | + |
|
| 334 | + $propalline = new PropaleLigne($this->db); |
|
| 335 | + $result = $propalline->fetch($lineid); |
|
| 336 | + if ($result <= 0) { |
|
| 337 | + throw new RestException(404, 'Proposal line not found'); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + $updateRes = $this->propal->updateline( |
|
| 341 | + $lineid, |
|
| 342 | + isset($request_data->subprice)?$request_data->subprice:$propalline->subprice, |
|
| 343 | + isset($request_data->qty)?$request_data->qty:$propalline->qty, |
|
| 344 | + isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent, |
|
| 345 | + isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx, |
|
| 346 | + isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx, |
|
| 347 | + isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx, |
|
| 348 | + isset($request_data->desc)?$request_data->desc:$propalline->desc, |
|
| 349 | + 'HT', |
|
| 350 | + isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits, |
|
| 351 | + isset($request_data->special_code)?$request_data->special_code:$propalline->special_code, |
|
| 352 | + isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line, |
|
| 353 | + 0, |
|
| 354 | + isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice, |
|
| 355 | + isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht, |
|
| 356 | + isset($request_data->label)?$request_data->label:$propalline->label, |
|
| 357 | + isset($request_data->product_type)?$request_data->product_type:$propalline->product_type, |
|
| 358 | + isset($request_data->date_start)?$request_data->date_start:$propalline->date_start, |
|
| 359 | + isset($request_data->date_end)?$request_data->date_end:$propalline->date_end, |
|
| 360 | + isset($request_data->array_options)?$request_data->array_options:$propalline->array_options, |
|
| 361 | + isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit, |
|
| 362 | + isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice |
|
| 363 | + ); |
|
| 364 | + |
|
| 365 | + if ($updateRes > 0) { |
|
| 366 | + $result = $this->get($id); |
|
| 367 | + unset($result->line); |
|
| 368 | + return $this->_cleanObjectDatas($result); |
|
| 369 | + } |
|
| 370 | + return false; |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + /** |
|
| 374 | + * Delete a line of given commercial proposal |
|
| 375 | + * |
|
| 376 | + * |
|
| 377 | + * @param int $id Id of commercial proposal to update |
|
| 378 | + * @param int $lineid Id of line to delete |
|
| 379 | + * |
|
| 380 | + * @url DELETE {id}/lines/{lineid} |
|
| 381 | + * |
|
| 382 | + * @return int |
|
| 383 | 383 | * @throws 401 |
| 384 | 384 | * @throws 404 |
| 385 | - */ |
|
| 385 | + */ |
|
| 386 | 386 | function deleteLine($id, $lineid) |
| 387 | 387 | { |
| 388 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 389 | - throw new RestException(401); |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - $result = $this->propal->fetch($id); |
|
| 393 | - if( ! $result ) { |
|
| 394 | - throw new RestException(404, 'Proposal not found'); |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 398 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - // TODO Check the lineid $lineid is a line of ojbect |
|
| 402 | - |
|
| 403 | - $updateRes = $this->propal->deleteline($lineid); |
|
| 404 | - if ($updateRes > 0) { |
|
| 405 | - return $this->get($id); |
|
| 406 | - } |
|
| 407 | - else |
|
| 408 | - { |
|
| 409 | - throw new RestException(405, $this->propal->error); |
|
| 410 | - } |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - /** |
|
| 414 | - * Update commercial proposal general fields (won't touch lines of commercial proposal) |
|
| 415 | - * |
|
| 416 | - * @param int $id Id of commercial proposal to update |
|
| 417 | - * @param array $request_data Datas |
|
| 418 | - * |
|
| 419 | - * @return int |
|
| 420 | - */ |
|
| 388 | + if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 389 | + throw new RestException(401); |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + $result = $this->propal->fetch($id); |
|
| 393 | + if( ! $result ) { |
|
| 394 | + throw new RestException(404, 'Proposal not found'); |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 398 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + // TODO Check the lineid $lineid is a line of ojbect |
|
| 402 | + |
|
| 403 | + $updateRes = $this->propal->deleteline($lineid); |
|
| 404 | + if ($updateRes > 0) { |
|
| 405 | + return $this->get($id); |
|
| 406 | + } |
|
| 407 | + else |
|
| 408 | + { |
|
| 409 | + throw new RestException(405, $this->propal->error); |
|
| 410 | + } |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * Update commercial proposal general fields (won't touch lines of commercial proposal) |
|
| 415 | + * |
|
| 416 | + * @param int $id Id of commercial proposal to update |
|
| 417 | + * @param array $request_data Datas |
|
| 418 | + * |
|
| 419 | + * @return int |
|
| 420 | + */ |
|
| 421 | 421 | function put($id, $request_data = null) |
| 422 | 422 | { |
| 423 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 424 | - throw new RestException(401); |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - $result = $this->propal->fetch($id); |
|
| 428 | - if( ! $result ) { |
|
| 429 | - throw new RestException(404, 'Proposal not found'); |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 433 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 434 | - } |
|
| 435 | - foreach($request_data as $field => $value) { |
|
| 436 | - if ($field == 'id') continue; |
|
| 437 | - $this->propal->$field = $value; |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - // update end of validity date |
|
| 441 | - if (empty($this->propal->fin_validite) && !empty($this->propal->duree_validite) && !empty($this->propal->date_creation)) |
|
| 442 | - { |
|
| 443 | - $this->propal->fin_validite = $this->propal->date_creation + ($this->propal->duree_validite * 24 * 3600); |
|
| 444 | - } |
|
| 445 | - if (!empty($this->propal->fin_validite)) |
|
| 446 | - { |
|
| 447 | - if($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite)<0) |
|
| 448 | - { |
|
| 449 | - throw new RestException(500, $this->propal->error); |
|
| 450 | - } |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - if ($this->propal->update(DolibarrApiAccess::$user) > 0) |
|
| 454 | - { |
|
| 455 | - return $this->get($id); |
|
| 456 | - } |
|
| 457 | - else |
|
| 458 | - { |
|
| 459 | - throw new RestException(500, $this->propal->error); |
|
| 460 | - } |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - /** |
|
| 464 | - * Delete commercial proposal |
|
| 465 | - * |
|
| 466 | - * @param int $id Commercial proposal ID |
|
| 467 | - * |
|
| 468 | - * @return array |
|
| 469 | - */ |
|
| 470 | - function delete($id) |
|
| 471 | - { |
|
| 472 | - if(! DolibarrApiAccess::$user->rights->propal->supprimer) { |
|
| 473 | - throw new RestException(401); |
|
| 474 | - } |
|
| 475 | - $result = $this->propal->fetch($id); |
|
| 476 | - if( ! $result ) { |
|
| 477 | - throw new RestException(404, 'Commercial Proposal not found'); |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 481 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - if( ! $this->propal->delete(DolibarrApiAccess::$user)) { |
|
| 485 | - throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error); |
|
| 486 | - } |
|
| 487 | - |
|
| 488 | - return array( |
|
| 489 | - 'success' => array( |
|
| 490 | - 'code' => 200, |
|
| 491 | - 'message' => 'Commercial Proposal deleted' |
|
| 492 | - ) |
|
| 493 | - ); |
|
| 494 | - } |
|
| 495 | - |
|
| 496 | - /** |
|
| 497 | - * Set a proposal to draft |
|
| 498 | - * |
|
| 499 | - * @param int $id Order ID |
|
| 500 | - * |
|
| 501 | - * @url POST {id}/settodraft |
|
| 502 | - * |
|
| 503 | - * @return array |
|
| 504 | - */ |
|
| 505 | - function settodraft($id) |
|
| 506 | - { |
|
| 507 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 508 | - throw new RestException(401); |
|
| 509 | - } |
|
| 510 | - $result = $this->propal->fetch($id); |
|
| 511 | - if( ! $result ) { |
|
| 512 | - throw new RestException(404, 'Proposal not found'); |
|
| 513 | - } |
|
| 514 | - |
|
| 515 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 516 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - $result = $this->propal->set_draft(DolibarrApiAccess::$user); |
|
| 520 | - if ($result == 0) { |
|
| 521 | - throw new RestException(304, 'Nothing done. May be object is already draft'); |
|
| 522 | - } |
|
| 523 | - if ($result < 0) { |
|
| 524 | - throw new RestException(500, 'Error : '.$this->propal->error); |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - $result = $this->propal->fetch($id); |
|
| 528 | - if( ! $result ) { |
|
| 529 | - throw new RestException(404, 'Proposal not found'); |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 533 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - $this->propal->fetchObjectLinked(); |
|
| 537 | - |
|
| 538 | - return $this->_cleanObjectDatas($this->propal); |
|
| 539 | - } |
|
| 540 | - |
|
| 541 | - |
|
| 542 | - /** |
|
| 543 | - * Validate a commercial proposal |
|
| 544 | - * |
|
| 545 | - * If you get a bad value for param notrigger check that ou provide this in body |
|
| 546 | - * { |
|
| 547 | - * "notrigger": 0 |
|
| 548 | - * } |
|
| 549 | - * |
|
| 550 | - * @param int $id Commercial proposal ID |
|
| 551 | - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers |
|
| 552 | - * |
|
| 553 | - * @url POST {id}/validate |
|
| 554 | - * |
|
| 555 | - * @throws 304 |
|
| 423 | + if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 424 | + throw new RestException(401); |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + $result = $this->propal->fetch($id); |
|
| 428 | + if( ! $result ) { |
|
| 429 | + throw new RestException(404, 'Proposal not found'); |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 433 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 434 | + } |
|
| 435 | + foreach($request_data as $field => $value) { |
|
| 436 | + if ($field == 'id') continue; |
|
| 437 | + $this->propal->$field = $value; |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + // update end of validity date |
|
| 441 | + if (empty($this->propal->fin_validite) && !empty($this->propal->duree_validite) && !empty($this->propal->date_creation)) |
|
| 442 | + { |
|
| 443 | + $this->propal->fin_validite = $this->propal->date_creation + ($this->propal->duree_validite * 24 * 3600); |
|
| 444 | + } |
|
| 445 | + if (!empty($this->propal->fin_validite)) |
|
| 446 | + { |
|
| 447 | + if($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite)<0) |
|
| 448 | + { |
|
| 449 | + throw new RestException(500, $this->propal->error); |
|
| 450 | + } |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + if ($this->propal->update(DolibarrApiAccess::$user) > 0) |
|
| 454 | + { |
|
| 455 | + return $this->get($id); |
|
| 456 | + } |
|
| 457 | + else |
|
| 458 | + { |
|
| 459 | + throw new RestException(500, $this->propal->error); |
|
| 460 | + } |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + /** |
|
| 464 | + * Delete commercial proposal |
|
| 465 | + * |
|
| 466 | + * @param int $id Commercial proposal ID |
|
| 467 | + * |
|
| 468 | + * @return array |
|
| 469 | + */ |
|
| 470 | + function delete($id) |
|
| 471 | + { |
|
| 472 | + if(! DolibarrApiAccess::$user->rights->propal->supprimer) { |
|
| 473 | + throw new RestException(401); |
|
| 474 | + } |
|
| 475 | + $result = $this->propal->fetch($id); |
|
| 476 | + if( ! $result ) { |
|
| 477 | + throw new RestException(404, 'Commercial Proposal not found'); |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 481 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + if( ! $this->propal->delete(DolibarrApiAccess::$user)) { |
|
| 485 | + throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error); |
|
| 486 | + } |
|
| 487 | + |
|
| 488 | + return array( |
|
| 489 | + 'success' => array( |
|
| 490 | + 'code' => 200, |
|
| 491 | + 'message' => 'Commercial Proposal deleted' |
|
| 492 | + ) |
|
| 493 | + ); |
|
| 494 | + } |
|
| 495 | + |
|
| 496 | + /** |
|
| 497 | + * Set a proposal to draft |
|
| 498 | + * |
|
| 499 | + * @param int $id Order ID |
|
| 500 | + * |
|
| 501 | + * @url POST {id}/settodraft |
|
| 502 | + * |
|
| 503 | + * @return array |
|
| 504 | + */ |
|
| 505 | + function settodraft($id) |
|
| 506 | + { |
|
| 507 | + if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 508 | + throw new RestException(401); |
|
| 509 | + } |
|
| 510 | + $result = $this->propal->fetch($id); |
|
| 511 | + if( ! $result ) { |
|
| 512 | + throw new RestException(404, 'Proposal not found'); |
|
| 513 | + } |
|
| 514 | + |
|
| 515 | + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 516 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + $result = $this->propal->set_draft(DolibarrApiAccess::$user); |
|
| 520 | + if ($result == 0) { |
|
| 521 | + throw new RestException(304, 'Nothing done. May be object is already draft'); |
|
| 522 | + } |
|
| 523 | + if ($result < 0) { |
|
| 524 | + throw new RestException(500, 'Error : '.$this->propal->error); |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + $result = $this->propal->fetch($id); |
|
| 528 | + if( ! $result ) { |
|
| 529 | + throw new RestException(404, 'Proposal not found'); |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 533 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + $this->propal->fetchObjectLinked(); |
|
| 537 | + |
|
| 538 | + return $this->_cleanObjectDatas($this->propal); |
|
| 539 | + } |
|
| 540 | + |
|
| 541 | + |
|
| 542 | + /** |
|
| 543 | + * Validate a commercial proposal |
|
| 544 | + * |
|
| 545 | + * If you get a bad value for param notrigger check that ou provide this in body |
|
| 546 | + * { |
|
| 547 | + * "notrigger": 0 |
|
| 548 | + * } |
|
| 549 | + * |
|
| 550 | + * @param int $id Commercial proposal ID |
|
| 551 | + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers |
|
| 552 | + * |
|
| 553 | + * @url POST {id}/validate |
|
| 554 | + * |
|
| 555 | + * @throws 304 |
|
| 556 | 556 | * @throws 401 |
| 557 | 557 | * @throws 404 |
| 558 | 558 | * @throws 500 |
| 559 | 559 | * |
| 560 | 560 | * @return array |
| 561 | - */ |
|
| 562 | - function validate($id, $notrigger=0) |
|
| 563 | - { |
|
| 564 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 565 | - throw new RestException(401); |
|
| 566 | - } |
|
| 567 | - $result = $this->propal->fetch($id); |
|
| 568 | - if( ! $result ) { |
|
| 569 | - throw new RestException(404, 'Commercial Proposal not found'); |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 573 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 574 | - } |
|
| 575 | - |
|
| 576 | - $result = $this->propal->valid(DolibarrApiAccess::$user, $notrigger); |
|
| 577 | - if ($result == 0) { |
|
| 578 | - throw new RestException(304, 'Error nothing done. May be object is already validated'); |
|
| 579 | - } |
|
| 580 | - if ($result < 0) { |
|
| 581 | - throw new RestException(500, 'Error when validating Commercial Proposal: '.$this->propal->error); |
|
| 582 | - } |
|
| 561 | + */ |
|
| 562 | + function validate($id, $notrigger=0) |
|
| 563 | + { |
|
| 564 | + if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 565 | + throw new RestException(401); |
|
| 566 | + } |
|
| 567 | + $result = $this->propal->fetch($id); |
|
| 568 | + if( ! $result ) { |
|
| 569 | + throw new RestException(404, 'Commercial Proposal not found'); |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 573 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 574 | + } |
|
| 575 | + |
|
| 576 | + $result = $this->propal->valid(DolibarrApiAccess::$user, $notrigger); |
|
| 577 | + if ($result == 0) { |
|
| 578 | + throw new RestException(304, 'Error nothing done. May be object is already validated'); |
|
| 579 | + } |
|
| 580 | + if ($result < 0) { |
|
| 581 | + throw new RestException(500, 'Error when validating Commercial Proposal: '.$this->propal->error); |
|
| 582 | + } |
|
| 583 | 583 | |
| 584 | 584 | $result = $this->propal->fetch($id); |
| 585 | 585 | if( ! $result ) { |
@@ -593,55 +593,55 @@ discard block |
||
| 593 | 593 | $this->propal->fetchObjectLinked(); |
| 594 | 594 | |
| 595 | 595 | return $this->_cleanObjectDatas($this->propal); |
| 596 | - } |
|
| 597 | - |
|
| 598 | - /** |
|
| 599 | - * Close (Accept or refuse) a quote / commercial proposal |
|
| 600 | - * |
|
| 601 | - * @param int $id Commercial proposal ID |
|
| 602 | - * @param int $status Must be 2 (accepted) or 3 (refused) {@min 2}{@max 3} |
|
| 603 | - * @param string $note_private Add this mention at end of private note |
|
| 604 | - * @param int $notrigger Disabled triggers |
|
| 605 | - * |
|
| 606 | - * @url POST {id}/close |
|
| 607 | - * |
|
| 608 | - * @return array |
|
| 609 | - */ |
|
| 610 | - function close($id, $status, $note_private='', $notrigger=0) |
|
| 611 | - { |
|
| 612 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 613 | - throw new RestException(401); |
|
| 614 | - } |
|
| 615 | - $result = $this->propal->fetch($id); |
|
| 616 | - if( ! $result ) { |
|
| 617 | - throw new RestException(404, 'Commercial Proposal not found'); |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 621 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 622 | - } |
|
| 623 | - |
|
| 624 | - $result = $this->propal->cloture(DolibarrApiAccess::$user, $status, $note_private, $notrigger); |
|
| 625 | - if ($result == 0) { |
|
| 626 | - throw new RestException(304, 'Error nothing done. May be object is already closed'); |
|
| 627 | - } |
|
| 628 | - if ($result < 0) { |
|
| 629 | - throw new RestException(500, 'Error when closing Commercial Proposal: '.$this->propal->error); |
|
| 630 | - } |
|
| 631 | - |
|
| 632 | - $result = $this->propal->fetch($id); |
|
| 633 | - if( ! $result ) { |
|
| 634 | - throw new RestException(404, 'Proposal not found'); |
|
| 635 | - } |
|
| 636 | - |
|
| 637 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 638 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 639 | - } |
|
| 640 | - |
|
| 641 | - $this->propal->fetchObjectLinked(); |
|
| 642 | - |
|
| 643 | - return $this->_cleanObjectDatas($this->propal); |
|
| 644 | - } |
|
| 596 | + } |
|
| 597 | + |
|
| 598 | + /** |
|
| 599 | + * Close (Accept or refuse) a quote / commercial proposal |
|
| 600 | + * |
|
| 601 | + * @param int $id Commercial proposal ID |
|
| 602 | + * @param int $status Must be 2 (accepted) or 3 (refused) {@min 2}{@max 3} |
|
| 603 | + * @param string $note_private Add this mention at end of private note |
|
| 604 | + * @param int $notrigger Disabled triggers |
|
| 605 | + * |
|
| 606 | + * @url POST {id}/close |
|
| 607 | + * |
|
| 608 | + * @return array |
|
| 609 | + */ |
|
| 610 | + function close($id, $status, $note_private='', $notrigger=0) |
|
| 611 | + { |
|
| 612 | + if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 613 | + throw new RestException(401); |
|
| 614 | + } |
|
| 615 | + $result = $this->propal->fetch($id); |
|
| 616 | + if( ! $result ) { |
|
| 617 | + throw new RestException(404, 'Commercial Proposal not found'); |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 621 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + $result = $this->propal->cloture(DolibarrApiAccess::$user, $status, $note_private, $notrigger); |
|
| 625 | + if ($result == 0) { |
|
| 626 | + throw new RestException(304, 'Error nothing done. May be object is already closed'); |
|
| 627 | + } |
|
| 628 | + if ($result < 0) { |
|
| 629 | + throw new RestException(500, 'Error when closing Commercial Proposal: '.$this->propal->error); |
|
| 630 | + } |
|
| 631 | + |
|
| 632 | + $result = $this->propal->fetch($id); |
|
| 633 | + if( ! $result ) { |
|
| 634 | + throw new RestException(404, 'Proposal not found'); |
|
| 635 | + } |
|
| 636 | + |
|
| 637 | + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 638 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 639 | + } |
|
| 640 | + |
|
| 641 | + $this->propal->fetchObjectLinked(); |
|
| 642 | + |
|
| 643 | + return $this->_cleanObjectDatas($this->propal); |
|
| 644 | + } |
|
| 645 | 645 | |
| 646 | 646 | /** |
| 647 | 647 | * Set a commercial proposal billed. Could be also called setbilled |
@@ -673,11 +673,11 @@ discard block |
||
| 673 | 673 | |
| 674 | 674 | $result = $this->propal->fetch($id); |
| 675 | 675 | if( ! $result ) { |
| 676 | - throw new RestException(404, 'Proposal not found'); |
|
| 676 | + throw new RestException(404, 'Proposal not found'); |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
| 680 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 680 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | $this->propal->fetchObjectLinked(); |
@@ -686,23 +686,23 @@ discard block |
||
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | |
| 689 | - /** |
|
| 690 | - * Validate fields before create or update object |
|
| 691 | - * |
|
| 692 | - * @param array $data Array with data to verify |
|
| 693 | - * @return array |
|
| 694 | - * @throws RestException |
|
| 695 | - */ |
|
| 696 | - function _validate($data) |
|
| 697 | - { |
|
| 698 | - $propal = array(); |
|
| 699 | - foreach (Proposals::$FIELDS as $field) { |
|
| 700 | - if (!isset($data[$field])) |
|
| 701 | - throw new RestException(400, "$field field missing"); |
|
| 702 | - $propal[$field] = $data[$field]; |
|
| 703 | - } |
|
| 704 | - return $propal; |
|
| 705 | - } |
|
| 689 | + /** |
|
| 690 | + * Validate fields before create or update object |
|
| 691 | + * |
|
| 692 | + * @param array $data Array with data to verify |
|
| 693 | + * @return array |
|
| 694 | + * @throws RestException |
|
| 695 | + */ |
|
| 696 | + function _validate($data) |
|
| 697 | + { |
|
| 698 | + $propal = array(); |
|
| 699 | + foreach (Proposals::$FIELDS as $field) { |
|
| 700 | + if (!isset($data[$field])) |
|
| 701 | + throw new RestException(400, "$field field missing"); |
|
| 702 | + $propal[$field] = $data[$field]; |
|
| 703 | + } |
|
| 704 | + return $propal; |
|
| 705 | + } |
|
| 706 | 706 | |
| 707 | 707 | |
| 708 | 708 | /** |
@@ -64,21 +64,21 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | function get($id) |
| 66 | 66 | { |
| 67 | - if(! DolibarrApiAccess::$user->rights->propal->lire) { |
|
| 67 | + if (!DolibarrApiAccess::$user->rights->propal->lire) { |
|
| 68 | 68 | throw new RestException(401); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $result = $this->propal->fetch($id); |
| 72 | - if( ! $result ) { |
|
| 72 | + if (!$result) { |
|
| 73 | 73 | throw new RestException(404, 'Commercial Proposal not found'); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 76 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 77 | 77 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // Add external contacts ids |
| 81 | - $this->propal->contacts_ids = $this->propal->liste_contact(-1,'external',1); |
|
| 81 | + $this->propal->contacts_ids = $this->propal->liste_contact(-1, 'external', 1); |
|
| 82 | 82 | |
| 83 | 83 | $this->propal->fetchObjectLinked(); |
| 84 | 84 | return $this->_cleanObjectDatas($this->propal); |
@@ -108,18 +108,18 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | // If the internal user must only see his customers, force searching by him |
| 110 | 110 | $search_sale = 0; |
| 111 | - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; |
|
| 111 | + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; |
|
| 112 | 112 | |
| 113 | 113 | $sql = "SELECT t.rowid"; |
| 114 | 114 | if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
| 115 | - $sql.= " FROM ".MAIN_DB_PREFIX."propal as t"; |
|
| 115 | + $sql .= " FROM ".MAIN_DB_PREFIX."propal as t"; |
|
| 116 | 116 | |
| 117 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 117 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 118 | 118 | |
| 119 | - $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; |
|
| 120 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 121 | - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; |
|
| 122 | - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale |
|
| 119 | + $sql .= ' WHERE t.entity IN ('.getEntity('propal').')'; |
|
| 120 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; |
|
| 121 | + if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; |
|
| 122 | + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale |
|
| 123 | 123 | // Insert sale filter |
| 124 | 124 | if ($search_sale > 0) |
| 125 | 125 | { |
@@ -128,23 +128,23 @@ discard block |
||
| 128 | 128 | // Add sql filters |
| 129 | 129 | if ($sqlfilters) |
| 130 | 130 | { |
| 131 | - if (! DolibarrApi::_checkFilters($sqlfilters)) |
|
| 131 | + if (!DolibarrApi::_checkFilters($sqlfilters)) |
|
| 132 | 132 | { |
| 133 | 133 | throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); |
| 134 | 134 | } |
| 135 | - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 136 | - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
| 135 | + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 136 | + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - $sql.= $db->order($sortfield, $sortorder); |
|
| 140 | - if ($limit) { |
|
| 139 | + $sql .= $db->order($sortfield, $sortorder); |
|
| 140 | + if ($limit) { |
|
| 141 | 141 | if ($page < 0) |
| 142 | 142 | { |
| 143 | 143 | $page = 0; |
| 144 | 144 | } |
| 145 | 145 | $offset = $limit * $page; |
| 146 | 146 | |
| 147 | - $sql.= $db->plimit($limit + 1, $offset); |
|
| 147 | + $sql .= $db->plimit($limit + 1, $offset); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | dol_syslog("API Rest request"); |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | $obj = $db->fetch_object($result); |
| 161 | 161 | $proposal_static = new Propal($db); |
| 162 | - if($proposal_static->fetch($obj->rowid)) { |
|
| 162 | + if ($proposal_static->fetch($obj->rowid)) { |
|
| 163 | 163 | // Add external contacts ids |
| 164 | - $proposal_static->contacts_ids = $proposal_static->liste_contact(-1,'external',1); |
|
| 164 | + $proposal_static->contacts_ids = $proposal_static->liste_contact(-1, 'external', 1); |
|
| 165 | 165 | $obj_ret[] = $this->_cleanObjectDatas($proposal_static); |
| 166 | 166 | } |
| 167 | 167 | $i++; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | else { |
| 171 | 171 | throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror()); |
| 172 | 172 | } |
| 173 | - if( ! count($obj_ret)) { |
|
| 173 | + if (!count($obj_ret)) { |
|
| 174 | 174 | throw new RestException(404, 'No proposal found'); |
| 175 | 175 | } |
| 176 | 176 | return $obj_ret; |
@@ -184,13 +184,13 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | function post($request_data = null) |
| 186 | 186 | { |
| 187 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 187 | + if (!DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 188 | 188 | throw new RestException(401, "Insuffisant rights"); |
| 189 | 189 | } |
| 190 | 190 | // Check mandatory fields |
| 191 | 191 | $result = $this->_validate($request_data); |
| 192 | 192 | |
| 193 | - foreach($request_data as $field => $value) { |
|
| 193 | + foreach ($request_data as $field => $value) { |
|
| 194 | 194 | $this->propal->$field = $value; |
| 195 | 195 | } |
| 196 | 196 | /*if (isset($request_data["lines"])) { |
@@ -218,22 +218,22 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | function getLines($id) |
| 220 | 220 | { |
| 221 | - if(! DolibarrApiAccess::$user->rights->propal->lire) { |
|
| 221 | + if (!DolibarrApiAccess::$user->rights->propal->lire) { |
|
| 222 | 222 | throw new RestException(401); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | $result = $this->propal->fetch($id); |
| 226 | - if( ! $result ) { |
|
| 226 | + if (!$result) { |
|
| 227 | 227 | throw new RestException(404, 'Commercial Proposal not found'); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 230 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 231 | 231 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 232 | 232 | } |
| 233 | 233 | $this->propal->getLinesArray(); |
| 234 | 234 | $result = array(); |
| 235 | 235 | foreach ($this->propal->lines as $line) { |
| 236 | - array_push($result,$this->_cleanObjectDatas($line)); |
|
| 236 | + array_push($result, $this->_cleanObjectDatas($line)); |
|
| 237 | 237 | } |
| 238 | 238 | return $result; |
| 239 | 239 | } |
@@ -250,16 +250,16 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | function postLine($id, $request_data = null) |
| 252 | 252 | { |
| 253 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 253 | + if (!DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 254 | 254 | throw new RestException(401); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | $result = $this->propal->fetch($id); |
| 258 | - if (! $result) { |
|
| 258 | + if (!$result) { |
|
| 259 | 259 | throw new RestException(404, 'Commercial Proposal not found'); |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - if (! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) |
|
| 262 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) |
|
| 263 | 263 | { |
| 264 | 264 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 265 | 265 | } |
@@ -316,16 +316,16 @@ discard block |
||
| 316 | 316 | */ |
| 317 | 317 | function putLine($id, $lineid, $request_data = null) |
| 318 | 318 | { |
| 319 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 319 | + if (!DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 320 | 320 | throw new RestException(401); |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | $result = $this->propal->fetch($id); |
| 324 | - if($result <= 0) { |
|
| 324 | + if ($result <= 0) { |
|
| 325 | 325 | throw new RestException(404, 'Proposal not found'); |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 328 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 329 | 329 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 330 | 330 | } |
| 331 | 331 | |
@@ -339,27 +339,27 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | $updateRes = $this->propal->updateline( |
| 341 | 341 | $lineid, |
| 342 | - isset($request_data->subprice)?$request_data->subprice:$propalline->subprice, |
|
| 343 | - isset($request_data->qty)?$request_data->qty:$propalline->qty, |
|
| 344 | - isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent, |
|
| 345 | - isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx, |
|
| 346 | - isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx, |
|
| 347 | - isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx, |
|
| 348 | - isset($request_data->desc)?$request_data->desc:$propalline->desc, |
|
| 342 | + isset($request_data->subprice) ? $request_data->subprice : $propalline->subprice, |
|
| 343 | + isset($request_data->qty) ? $request_data->qty : $propalline->qty, |
|
| 344 | + isset($request_data->remise_percent) ? $request_data->remise_percent : $propalline->remise_percent, |
|
| 345 | + isset($request_data->tva_tx) ? $request_data->tva_tx : $propalline->tva_tx, |
|
| 346 | + isset($request_data->localtax1_tx) ? $request_data->localtax1_tx : $propalline->localtax1_tx, |
|
| 347 | + isset($request_data->localtax2_tx) ? $request_data->localtax2_tx : $propalline->localtax2_tx, |
|
| 348 | + isset($request_data->desc) ? $request_data->desc : $propalline->desc, |
|
| 349 | 349 | 'HT', |
| 350 | - isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits, |
|
| 351 | - isset($request_data->special_code)?$request_data->special_code:$propalline->special_code, |
|
| 352 | - isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line, |
|
| 350 | + isset($request_data->info_bits) ? $request_data->info_bits : $propalline->info_bits, |
|
| 351 | + isset($request_data->special_code) ? $request_data->special_code : $propalline->special_code, |
|
| 352 | + isset($request_data->fk_parent_line) ? $request_data->fk_parent_line : $propalline->fk_parent_line, |
|
| 353 | 353 | 0, |
| 354 | - isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice, |
|
| 355 | - isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht, |
|
| 356 | - isset($request_data->label)?$request_data->label:$propalline->label, |
|
| 357 | - isset($request_data->product_type)?$request_data->product_type:$propalline->product_type, |
|
| 358 | - isset($request_data->date_start)?$request_data->date_start:$propalline->date_start, |
|
| 359 | - isset($request_data->date_end)?$request_data->date_end:$propalline->date_end, |
|
| 360 | - isset($request_data->array_options)?$request_data->array_options:$propalline->array_options, |
|
| 361 | - isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit, |
|
| 362 | - isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice |
|
| 354 | + isset($request_data->fk_fournprice) ? $request_data->fk_fournprice : $propalline->fk_fournprice, |
|
| 355 | + isset($request_data->pa_ht) ? $request_data->pa_ht : $propalline->pa_ht, |
|
| 356 | + isset($request_data->label) ? $request_data->label : $propalline->label, |
|
| 357 | + isset($request_data->product_type) ? $request_data->product_type : $propalline->product_type, |
|
| 358 | + isset($request_data->date_start) ? $request_data->date_start : $propalline->date_start, |
|
| 359 | + isset($request_data->date_end) ? $request_data->date_end : $propalline->date_end, |
|
| 360 | + isset($request_data->array_options) ? $request_data->array_options : $propalline->array_options, |
|
| 361 | + isset($request_data->fk_unit) ? $request_data->fk_unit : $propalline->fk_unit, |
|
| 362 | + isset($request_data->multicurrency_subprice) ? $request_data->multicurrency_subprice : $propalline->subprice |
|
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | 365 | if ($updateRes > 0) { |
@@ -385,16 +385,16 @@ discard block |
||
| 385 | 385 | */ |
| 386 | 386 | function deleteLine($id, $lineid) |
| 387 | 387 | { |
| 388 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 388 | + if (!DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 389 | 389 | throw new RestException(401); |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | $result = $this->propal->fetch($id); |
| 393 | - if( ! $result ) { |
|
| 393 | + if (!$result) { |
|
| 394 | 394 | throw new RestException(404, 'Proposal not found'); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 397 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 398 | 398 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 399 | 399 | } |
| 400 | 400 | |
@@ -420,19 +420,19 @@ discard block |
||
| 420 | 420 | */ |
| 421 | 421 | function put($id, $request_data = null) |
| 422 | 422 | { |
| 423 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 423 | + if (!DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 424 | 424 | throw new RestException(401); |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | $result = $this->propal->fetch($id); |
| 428 | - if( ! $result ) { |
|
| 428 | + if (!$result) { |
|
| 429 | 429 | throw new RestException(404, 'Proposal not found'); |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 432 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 433 | 433 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 434 | 434 | } |
| 435 | - foreach($request_data as $field => $value) { |
|
| 435 | + foreach ($request_data as $field => $value) { |
|
| 436 | 436 | if ($field == 'id') continue; |
| 437 | 437 | $this->propal->$field = $value; |
| 438 | 438 | } |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | } |
| 445 | 445 | if (!empty($this->propal->fin_validite)) |
| 446 | 446 | { |
| 447 | - if($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite)<0) |
|
| 447 | + if ($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite) < 0) |
|
| 448 | 448 | { |
| 449 | 449 | throw new RestException(500, $this->propal->error); |
| 450 | 450 | } |
@@ -469,19 +469,19 @@ discard block |
||
| 469 | 469 | */ |
| 470 | 470 | function delete($id) |
| 471 | 471 | { |
| 472 | - if(! DolibarrApiAccess::$user->rights->propal->supprimer) { |
|
| 472 | + if (!DolibarrApiAccess::$user->rights->propal->supprimer) { |
|
| 473 | 473 | throw new RestException(401); |
| 474 | 474 | } |
| 475 | 475 | $result = $this->propal->fetch($id); |
| 476 | - if( ! $result ) { |
|
| 476 | + if (!$result) { |
|
| 477 | 477 | throw new RestException(404, 'Commercial Proposal not found'); |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 480 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 481 | 481 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - if( ! $this->propal->delete(DolibarrApiAccess::$user)) { |
|
| 484 | + if (!$this->propal->delete(DolibarrApiAccess::$user)) { |
|
| 485 | 485 | throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error); |
| 486 | 486 | } |
| 487 | 487 | |
@@ -504,15 +504,15 @@ discard block |
||
| 504 | 504 | */ |
| 505 | 505 | function settodraft($id) |
| 506 | 506 | { |
| 507 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 507 | + if (!DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 508 | 508 | throw new RestException(401); |
| 509 | 509 | } |
| 510 | 510 | $result = $this->propal->fetch($id); |
| 511 | - if( ! $result ) { |
|
| 511 | + if (!$result) { |
|
| 512 | 512 | throw new RestException(404, 'Proposal not found'); |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 515 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 516 | 516 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 517 | 517 | } |
| 518 | 518 | |
@@ -525,11 +525,11 @@ discard block |
||
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | $result = $this->propal->fetch($id); |
| 528 | - if( ! $result ) { |
|
| 528 | + if (!$result) { |
|
| 529 | 529 | throw new RestException(404, 'Proposal not found'); |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 532 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 533 | 533 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 534 | 534 | } |
| 535 | 535 | |
@@ -559,17 +559,17 @@ discard block |
||
| 559 | 559 | * |
| 560 | 560 | * @return array |
| 561 | 561 | */ |
| 562 | - function validate($id, $notrigger=0) |
|
| 562 | + function validate($id, $notrigger = 0) |
|
| 563 | 563 | { |
| 564 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 564 | + if (!DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 565 | 565 | throw new RestException(401); |
| 566 | 566 | } |
| 567 | 567 | $result = $this->propal->fetch($id); |
| 568 | - if( ! $result ) { |
|
| 568 | + if (!$result) { |
|
| 569 | 569 | throw new RestException(404, 'Commercial Proposal not found'); |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 572 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 573 | 573 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 574 | 574 | } |
| 575 | 575 | |
@@ -582,11 +582,11 @@ discard block |
||
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | $result = $this->propal->fetch($id); |
| 585 | - if( ! $result ) { |
|
| 585 | + if (!$result) { |
|
| 586 | 586 | throw new RestException(404, 'Commercial Proposal not found'); |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 589 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 590 | 590 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 591 | 591 | } |
| 592 | 592 | |
@@ -607,17 +607,17 @@ discard block |
||
| 607 | 607 | * |
| 608 | 608 | * @return array |
| 609 | 609 | */ |
| 610 | - function close($id, $status, $note_private='', $notrigger=0) |
|
| 610 | + function close($id, $status, $note_private = '', $notrigger = 0) |
|
| 611 | 611 | { |
| 612 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 612 | + if (!DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 613 | 613 | throw new RestException(401); |
| 614 | 614 | } |
| 615 | 615 | $result = $this->propal->fetch($id); |
| 616 | - if( ! $result ) { |
|
| 616 | + if (!$result) { |
|
| 617 | 617 | throw new RestException(404, 'Commercial Proposal not found'); |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 620 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 621 | 621 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 622 | 622 | } |
| 623 | 623 | |
@@ -630,11 +630,11 @@ discard block |
||
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | $result = $this->propal->fetch($id); |
| 633 | - if( ! $result ) { |
|
| 633 | + if (!$result) { |
|
| 634 | 634 | throw new RestException(404, 'Proposal not found'); |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 637 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 638 | 638 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 639 | 639 | } |
| 640 | 640 | |
@@ -654,29 +654,29 @@ discard block |
||
| 654 | 654 | */ |
| 655 | 655 | function setinvoiced($id) |
| 656 | 656 | { |
| 657 | - if(! DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 657 | + if (!DolibarrApiAccess::$user->rights->propal->creer) { |
|
| 658 | 658 | throw new RestException(401); |
| 659 | 659 | } |
| 660 | 660 | $result = $this->propal->fetch($id); |
| 661 | - if( ! $result ) { |
|
| 661 | + if (!$result) { |
|
| 662 | 662 | throw new RestException(404, 'Commercial Proposal not found'); |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 665 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 666 | 666 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - $result = $this->propal->classifyBilled(DolibarrApiAccess::$user ); |
|
| 669 | + $result = $this->propal->classifyBilled(DolibarrApiAccess::$user); |
|
| 670 | 670 | if ($result < 0) { |
| 671 | 671 | throw new RestException(500, 'Error : '.$this->propal->error); |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | $result = $this->propal->fetch($id); |
| 675 | - if( ! $result ) { |
|
| 675 | + if (!$result) { |
|
| 676 | 676 | throw new RestException(404, 'Proposal not found'); |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { |
|
| 679 | + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { |
|
| 680 | 680 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 681 | 681 | } |
| 682 | 682 | |
@@ -108,18 +108,33 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | // If the internal user must only see his customers, force searching by him |
| 110 | 110 | $search_sale = 0; |
| 111 | - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; |
|
| 111 | + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { |
|
| 112 | + $search_sale = DolibarrApiAccess::$user->id; |
|
| 113 | + } |
|
| 112 | 114 | |
| 113 | 115 | $sql = "SELECT t.rowid"; |
| 114 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
| 116 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { |
|
| 117 | + $sql .= ", sc.fk_soc, sc.fk_user"; |
|
| 118 | + } |
|
| 119 | + // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
| 115 | 120 | $sql.= " FROM ".MAIN_DB_PREFIX."propal as t"; |
| 116 | 121 | |
| 117 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 122 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { |
|
| 123 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 124 | + } |
|
| 125 | + // We need this table joined to the select in order to filter by sale |
|
| 118 | 126 | |
| 119 | 127 | $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; |
| 120 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 121 | - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; |
|
| 122 | - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale |
|
| 128 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { |
|
| 129 | + $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 130 | + } |
|
| 131 | + if ($socids) { |
|
| 132 | + $sql.= " AND t.fk_soc IN (".$socids.")"; |
|
| 133 | + } |
|
| 134 | + if ($search_sale > 0) { |
|
| 135 | + $sql.= " AND t.rowid = sc.fk_soc"; |
|
| 136 | + } |
|
| 137 | + // Join for the needed table to filter by sale |
|
| 123 | 138 | // Insert sale filter |
| 124 | 139 | if ($search_sale > 0) |
| 125 | 140 | { |
@@ -166,8 +181,7 @@ discard block |
||
| 166 | 181 | } |
| 167 | 182 | $i++; |
| 168 | 183 | } |
| 169 | - } |
|
| 170 | - else { |
|
| 184 | + } else { |
|
| 171 | 185 | throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror()); |
| 172 | 186 | } |
| 173 | 187 | if( ! count($obj_ret)) { |
@@ -297,8 +311,7 @@ discard block |
||
| 297 | 311 | |
| 298 | 312 | if ($updateRes > 0) { |
| 299 | 313 | return $updateRes; |
| 300 | - } |
|
| 301 | - else { |
|
| 314 | + } else { |
|
| 302 | 315 | throw new RestException(400, $this->propal->error); |
| 303 | 316 | } |
| 304 | 317 | } |
@@ -403,8 +416,7 @@ discard block |
||
| 403 | 416 | $updateRes = $this->propal->deleteline($lineid); |
| 404 | 417 | if ($updateRes > 0) { |
| 405 | 418 | return $this->get($id); |
| 406 | - } |
|
| 407 | - else |
|
| 419 | + } else |
|
| 408 | 420 | { |
| 409 | 421 | throw new RestException(405, $this->propal->error); |
| 410 | 422 | } |
@@ -433,7 +445,9 @@ discard block |
||
| 433 | 445 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 434 | 446 | } |
| 435 | 447 | foreach($request_data as $field => $value) { |
| 436 | - if ($field == 'id') continue; |
|
| 448 | + if ($field == 'id') { |
|
| 449 | + continue; |
|
| 450 | + } |
|
| 437 | 451 | $this->propal->$field = $value; |
| 438 | 452 | } |
| 439 | 453 | |
@@ -453,8 +467,7 @@ discard block |
||
| 453 | 467 | if ($this->propal->update(DolibarrApiAccess::$user) > 0) |
| 454 | 468 | { |
| 455 | 469 | return $this->get($id); |
| 456 | - } |
|
| 457 | - else |
|
| 470 | + } else |
|
| 458 | 471 | { |
| 459 | 472 | throw new RestException(500, $this->propal->error); |
| 460 | 473 | } |
@@ -697,8 +710,9 @@ discard block |
||
| 697 | 710 | { |
| 698 | 711 | $propal = array(); |
| 699 | 712 | foreach (Proposals::$FIELDS as $field) { |
| 700 | - if (!isset($data[$field])) |
|
| 701 | - throw new RestException(400, "$field field missing"); |
|
| 713 | + if (!isset($data[$field])) { |
|
| 714 | + throw new RestException(400, "$field field missing"); |
|
| 715 | + } |
|
| 702 | 716 | $propal[$field] = $data[$field]; |
| 703 | 717 | } |
| 704 | 718 | return $propal; |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | // Protection to avoid direct call of template |
| 27 | 27 | if (empty($conf) || ! is_object($conf)) |
| 28 | 28 | { |
| 29 | - print "Error, template page can't be called as URL"; |
|
| 30 | - exit; |
|
| 29 | + print "Error, template page can't be called as URL"; |
|
| 30 | + exit; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | ?> |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | <td class="linkedcol-ref" ><?php echo $objectlink->ref_client; ?></td> |
| 66 | 66 | <td class="linkedcol-date" align="center"><?php echo dol_print_date($objectlink->date,'day'); ?></td> |
| 67 | 67 | <td class="linkedcol-amount" align="right"><?php |
| 68 | - if ($user->rights->propale->lire) { |
|
| 69 | - $total = $total + $objectlink->total_ht; |
|
| 70 | - echo price($objectlink->total_ht); |
|
| 71 | - } ?></td> |
|
| 68 | + if ($user->rights->propale->lire) { |
|
| 69 | + $total = $total + $objectlink->total_ht; |
|
| 70 | + echo price($objectlink->total_ht); |
|
| 71 | + } ?></td> |
|
| 72 | 72 | <td class="linkedcol-statut" align="right"><?php echo $objectlink->getLibStatut(3); ?></td> |
| 73 | 73 | <td class="linkedcol-action" align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td> |
| 74 | 74 | </tr> |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | 26 | // Protection to avoid direct call of template |
| 27 | -if (empty($conf) || ! is_object($conf)) |
|
| 27 | +if (empty($conf) || !is_object($conf)) |
|
| 28 | 28 | { |
| 29 | 29 | print "Error, template page can't be called as URL"; |
| 30 | 30 | exit; |
@@ -44,17 +44,17 @@ discard block |
||
| 44 | 44 | // Load translation files required by the page |
| 45 | 45 | $langs->load("propal"); |
| 46 | 46 | |
| 47 | -$total=0; $ilink=0; |
|
| 48 | -foreach($linkedObjectBlock as $key => $objectlink) |
|
| 47 | +$total = 0; $ilink = 0; |
|
| 48 | +foreach ($linkedObjectBlock as $key => $objectlink) |
|
| 49 | 49 | { |
| 50 | 50 | $ilink++; |
| 51 | 51 | |
| 52 | - $trclass='oddeven'; |
|
| 53 | - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; |
|
| 52 | + $trclass = 'oddeven'; |
|
| 53 | + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; |
|
| 54 | 54 | ?> |
| 55 | 55 | <tr class="<?php echo $trclass; ?>" data-element="<?php echo $objectlink->element; ?>" data-id="<?php echo $objectlink->id; ?>" > |
| 56 | 56 | <td class="linkedcol-element" ><?php echo $langs->trans("Proposal"); ?> |
| 57 | - <?php if(!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) |
|
| 57 | + <?php if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) |
|
| 58 | 58 | { |
| 59 | 59 | $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; |
| 60 | 60 | print '<a class="objectlinked_importbtn" href="'.$url.'&action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a>'; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | </td> |
| 64 | 64 | <td class="linkedcol-name" ><?php echo $objectlink->getNomUrl(1); ?></td> |
| 65 | 65 | <td class="linkedcol-ref" ><?php echo $objectlink->ref_client; ?></td> |
| 66 | - <td class="linkedcol-date" align="center"><?php echo dol_print_date($objectlink->date,'day'); ?></td> |
|
| 66 | + <td class="linkedcol-date" align="center"><?php echo dol_print_date($objectlink->date, 'day'); ?></td> |
|
| 67 | 67 | <td class="linkedcol-amount" align="right"><?php |
| 68 | 68 | if ($user->rights->propale->lire) { |
| 69 | 69 | $total = $total + $objectlink->total_ht; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | if (count($linkedObjectBlock) > 1) |
| 78 | 78 | { |
| 79 | 79 | ?> |
| 80 | - <tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter)?'liste_sub_total':''); ?>"> |
|
| 80 | + <tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>"> |
|
| 81 | 81 | <td><?php echo $langs->trans("Total"); ?></td> |
| 82 | 82 | <td></td> |
| 83 | 83 | <td align="center"></td> |
@@ -50,8 +50,10 @@ |
||
| 50 | 50 | $ilink++; |
| 51 | 51 | |
| 52 | 52 | $trclass='oddeven'; |
| 53 | - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; |
|
| 54 | -?> |
|
| 53 | + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { |
|
| 54 | + $trclass.=' liste_sub_total'; |
|
| 55 | + } |
|
| 56 | + ?> |
|
| 55 | 57 | <tr class="<?php echo $trclass; ?>" data-element="<?php echo $objectlink->element; ?>" data-id="<?php echo $objectlink->id; ?>" > |
| 56 | 58 | <td class="linkedcol-element" ><?php echo $langs->trans("Proposal"); ?> |
| 57 | 59 | <?php if(!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
| 30 | 30 | require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; |
| 31 | 31 | if (! empty($conf->projet->enabled)) { |
| 32 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
| 32 | + require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // Load translation files required by the page |
@@ -40,7 +40,9 @@ discard block |
||
| 40 | 40 | $socid=GETPOST('socid','int'); |
| 41 | 41 | |
| 42 | 42 | // Security check |
| 43 | -if (! empty($user->societe_id)) $socid=$user->societe_id; |
|
| 43 | +if (! empty($user->societe_id)) { |
|
| 44 | + $socid=$user->societe_id; |
|
| 45 | +} |
|
| 44 | 46 | $result = restrictedArea($user, 'propal', $id); |
| 45 | 47 | |
| 46 | 48 | $object = new Propal($db); |
@@ -86,9 +88,10 @@ discard block |
||
| 86 | 88 | $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
| 87 | 89 | if ($user->rights->propal->creer) |
| 88 | 90 | { |
| 89 | - if ($action != 'classify') |
|
| 90 | - //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; |
|
| 91 | + if ($action != 'classify') { |
|
| 92 | + //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; |
|
| 91 | 93 | $morehtmlref.=' : '; |
| 94 | + } |
|
| 92 | 95 | if ($action == 'classify') { |
| 93 | 96 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
| 94 | 97 | $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
@@ -27,27 +27,27 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 29 | 29 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 30 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 30 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
| 32 | 32 | require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
| 33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; |
| 34 | -if (! empty($conf->projet->enabled)) { |
|
| 35 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
| 34 | +if (!empty($conf->projet->enabled)) { |
|
| 35 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Load translation files required by the page |
| 39 | 39 | $langs->loadLangs(array('propal', 'compta')); |
| 40 | 40 | |
| 41 | -$id=GETPOST('id','int'); |
|
| 42 | -$ref=GETPOST('ref','alpha'); |
|
| 43 | -$socid=GETPOST('socid','int'); |
|
| 41 | +$id = GETPOST('id', 'int'); |
|
| 42 | +$ref = GETPOST('ref', 'alpha'); |
|
| 43 | +$socid = GETPOST('socid', 'int'); |
|
| 44 | 44 | |
| 45 | 45 | // Security check |
| 46 | -if (! empty($user->societe_id)) $socid=$user->societe_id; |
|
| 46 | +if (!empty($user->societe_id)) $socid = $user->societe_id; |
|
| 47 | 47 | $result = restrictedArea($user, 'propal', $id); |
| 48 | 48 | |
| 49 | 49 | $object = new Propal($db); |
| 50 | -if (! $object->fetch($id, $ref) > 0) |
|
| 50 | +if (!$object->fetch($id, $ref) > 0) |
|
| 51 | 51 | { |
| 52 | 52 | dol_print_error($db); |
| 53 | 53 | exit; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $form = new Form($db); |
| 63 | 63 | |
| 64 | -llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); |
|
| 64 | +llxHeader('', $langs->trans('Proposal'), 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); |
|
| 65 | 65 | |
| 66 | 66 | $object->fetch_thirdparty(); |
| 67 | 67 | |
@@ -73,49 +73,49 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | // Proposal card |
| 75 | 75 | |
| 76 | -$linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
| 76 | +$linkback = '<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; |
|
| 77 | 77 | |
| 78 | 78 | |
| 79 | -$morehtmlref='<div class="refidno">'; |
|
| 79 | +$morehtmlref = '<div class="refidno">'; |
|
| 80 | 80 | // Ref customer |
| 81 | -$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
| 82 | -$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
| 81 | +$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
| 82 | +$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
| 83 | 83 | // Thirdparty |
| 84 | -$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); |
|
| 84 | +$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); |
|
| 85 | 85 | // Project |
| 86 | -if (! empty($conf->projet->enabled)) |
|
| 86 | +if (!empty($conf->projet->enabled)) |
|
| 87 | 87 | { |
| 88 | 88 | $langs->load("projects"); |
| 89 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
| 89 | + $morehtmlref .= '<br>'.$langs->trans('Project').' '; |
|
| 90 | 90 | if ($user->rights->propal->creer) |
| 91 | 91 | { |
| 92 | 92 | if ($action != 'classify') |
| 93 | 93 | //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; |
| 94 | - $morehtmlref.=' : '; |
|
| 94 | + $morehtmlref .= ' : '; |
|
| 95 | 95 | if ($action == 'classify') { |
| 96 | 96 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
| 97 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
| 98 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
| 99 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 100 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
| 101 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 102 | - $morehtmlref.='</form>'; |
|
| 97 | + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
| 98 | + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; |
|
| 99 | + $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 100 | + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
| 101 | + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 102 | + $morehtmlref .= '</form>'; |
|
| 103 | 103 | } else { |
| 104 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
| 104 | + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
| 105 | 105 | } |
| 106 | 106 | } else { |
| 107 | - if (! empty($object->fk_project)) { |
|
| 107 | + if (!empty($object->fk_project)) { |
|
| 108 | 108 | $proj = new Project($db); |
| 109 | 109 | $proj->fetch($object->fk_project); |
| 110 | - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
| 111 | - $morehtmlref.=$proj->ref; |
|
| 112 | - $morehtmlref.='</a>'; |
|
| 110 | + $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; |
|
| 111 | + $morehtmlref .= $proj->ref; |
|
| 112 | + $morehtmlref .= '</a>'; |
|
| 113 | 113 | } else { |
| 114 | - $morehtmlref.=''; |
|
| 114 | + $morehtmlref .= ''; |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | -$morehtmlref.='</div>'; |
|
| 118 | +$morehtmlref .= '</div>'; |
|
| 119 | 119 | |
| 120 | 120 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
| 121 | 121 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
| 34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
| 35 | 35 | if (! empty($conf->projet->enabled)) { |
| 36 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
| 36 | + require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Load translation files required by the page |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $socid=''; |
| 49 | 49 | if (! empty($user->societe_id)) |
| 50 | 50 | { |
| 51 | - $socid = $user->societe_id; |
|
| 51 | + $socid = $user->societe_id; |
|
| 52 | 52 | } |
| 53 | 53 | $result = restrictedArea($user, 'propal', $id); |
| 54 | 54 | |
@@ -89,94 +89,94 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | if ($object->id > 0) |
| 91 | 91 | { |
| 92 | - $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
|
| 93 | - |
|
| 94 | - $head = propal_prepare_head($object); |
|
| 95 | - dol_fiche_head($head, 'document', $langs->trans('Proposal'), -1, 'propal'); |
|
| 96 | - |
|
| 97 | - // Build file list |
|
| 98 | - $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); |
|
| 99 | - $totalsize=0; |
|
| 100 | - foreach($filearray as $key => $file) |
|
| 101 | - { |
|
| 102 | - $totalsize+=$file['size']; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - // Proposal card |
|
| 107 | - |
|
| 108 | - $linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
| 109 | - |
|
| 110 | - |
|
| 111 | - $morehtmlref='<div class="refidno">'; |
|
| 112 | - // Ref customer |
|
| 113 | - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
| 114 | - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
| 115 | - // Thirdparty |
|
| 116 | - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); |
|
| 117 | - // Project |
|
| 118 | - if (! empty($conf->projet->enabled)) |
|
| 119 | - { |
|
| 120 | - $langs->load("projects"); |
|
| 121 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
| 122 | - if ($user->rights->propal->creer) |
|
| 123 | - { |
|
| 124 | - if ($action != 'classify') |
|
| 125 | - //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; |
|
| 126 | - $morehtmlref.=' : '; |
|
| 127 | - if ($action == 'classify') { |
|
| 128 | - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
| 129 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
| 130 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
| 131 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 132 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
| 133 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 134 | - $morehtmlref.='</form>'; |
|
| 135 | - } else { |
|
| 136 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
| 137 | - } |
|
| 138 | - } else { |
|
| 139 | - if (! empty($object->fk_project)) { |
|
| 140 | - $proj = new Project($db); |
|
| 141 | - $proj->fetch($object->fk_project); |
|
| 142 | - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
| 143 | - $morehtmlref.=$proj->ref; |
|
| 144 | - $morehtmlref.='</a>'; |
|
| 145 | - } else { |
|
| 146 | - $morehtmlref.=''; |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - $morehtmlref.='</div>'; |
|
| 151 | - |
|
| 152 | - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - print '<div class="fichecenter">'; |
|
| 156 | - print '<div class="underbanner clearboth"></div>'; |
|
| 157 | - |
|
| 158 | - print '<table class="border" width="100%">'; |
|
| 159 | - |
|
| 160 | - // Files infos |
|
| 161 | - print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td>'.count($filearray).'</td></tr>'; |
|
| 162 | - print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>'.dol_print_size($totalsize,1,1).'</td></tr>'; |
|
| 163 | - |
|
| 164 | - print "</table>\n"; |
|
| 165 | - |
|
| 166 | - print '</div>'; |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - dol_fiche_end(); |
|
| 170 | - |
|
| 171 | - $modulepart = 'propal'; |
|
| 172 | - $permission = $user->rights->propal->creer; |
|
| 173 | - $permtoedit = $user->rights->propal->creer; |
|
| 174 | - $param = '&id=' . $object->id; |
|
| 175 | - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
|
| 92 | + $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
|
| 93 | + |
|
| 94 | + $head = propal_prepare_head($object); |
|
| 95 | + dol_fiche_head($head, 'document', $langs->trans('Proposal'), -1, 'propal'); |
|
| 96 | + |
|
| 97 | + // Build file list |
|
| 98 | + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); |
|
| 99 | + $totalsize=0; |
|
| 100 | + foreach($filearray as $key => $file) |
|
| 101 | + { |
|
| 102 | + $totalsize+=$file['size']; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + // Proposal card |
|
| 107 | + |
|
| 108 | + $linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
| 109 | + |
|
| 110 | + |
|
| 111 | + $morehtmlref='<div class="refidno">'; |
|
| 112 | + // Ref customer |
|
| 113 | + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
| 114 | + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
| 115 | + // Thirdparty |
|
| 116 | + $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); |
|
| 117 | + // Project |
|
| 118 | + if (! empty($conf->projet->enabled)) |
|
| 119 | + { |
|
| 120 | + $langs->load("projects"); |
|
| 121 | + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
| 122 | + if ($user->rights->propal->creer) |
|
| 123 | + { |
|
| 124 | + if ($action != 'classify') |
|
| 125 | + //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; |
|
| 126 | + $morehtmlref.=' : '; |
|
| 127 | + if ($action == 'classify') { |
|
| 128 | + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
| 129 | + $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
| 130 | + $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
| 131 | + $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 132 | + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
| 133 | + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 134 | + $morehtmlref.='</form>'; |
|
| 135 | + } else { |
|
| 136 | + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
| 137 | + } |
|
| 138 | + } else { |
|
| 139 | + if (! empty($object->fk_project)) { |
|
| 140 | + $proj = new Project($db); |
|
| 141 | + $proj->fetch($object->fk_project); |
|
| 142 | + $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
| 143 | + $morehtmlref.=$proj->ref; |
|
| 144 | + $morehtmlref.='</a>'; |
|
| 145 | + } else { |
|
| 146 | + $morehtmlref.=''; |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + $morehtmlref.='</div>'; |
|
| 151 | + |
|
| 152 | + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + print '<div class="fichecenter">'; |
|
| 156 | + print '<div class="underbanner clearboth"></div>'; |
|
| 157 | + |
|
| 158 | + print '<table class="border" width="100%">'; |
|
| 159 | + |
|
| 160 | + // Files infos |
|
| 161 | + print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td>'.count($filearray).'</td></tr>'; |
|
| 162 | + print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>'.dol_print_size($totalsize,1,1).'</td></tr>'; |
|
| 163 | + |
|
| 164 | + print "</table>\n"; |
|
| 165 | + |
|
| 166 | + print '</div>'; |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + dol_fiche_end(); |
|
| 170 | + |
|
| 171 | + $modulepart = 'propal'; |
|
| 172 | + $permission = $user->rights->propal->creer; |
|
| 173 | + $permtoedit = $user->rights->propal->creer; |
|
| 174 | + $param = '&id=' . $object->id; |
|
| 175 | + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
|
| 176 | 176 | } |
| 177 | 177 | else |
| 178 | 178 | { |
| 179 | - print $langs->trans("ErrorUnknown"); |
|
| 179 | + print $langs->trans("ErrorUnknown"); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // End of page |
@@ -60,8 +60,12 @@ discard block |
||
| 60 | 60 | $offset = $conf->liste_limit * $page; |
| 61 | 61 | $pageprev = $page - 1; |
| 62 | 62 | $pagenext = $page + 1; |
| 63 | -if (! $sortorder) $sortorder="ASC"; |
|
| 64 | -if (! $sortfield) $sortfield="name"; |
|
| 63 | +if (! $sortorder) { |
|
| 64 | + $sortorder="ASC"; |
|
| 65 | +} |
|
| 66 | +if (! $sortfield) { |
|
| 67 | + $sortfield="name"; |
|
| 68 | +} |
|
| 65 | 69 | |
| 66 | 70 | $object = new Propal($db); |
| 67 | 71 | $object->fetch($id,$ref); |
@@ -121,9 +125,10 @@ discard block |
||
| 121 | 125 | $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
| 122 | 126 | if ($user->rights->propal->creer) |
| 123 | 127 | { |
| 124 | - if ($action != 'classify') |
|
| 125 | - //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; |
|
| 128 | + if ($action != 'classify') { |
|
| 129 | + //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; |
|
| 126 | 130 | $morehtmlref.=' : '; |
| 131 | + } |
|
| 127 | 132 | if ($action == 'classify') { |
| 128 | 133 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
| 129 | 134 | $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
@@ -173,8 +178,7 @@ discard block |
||
| 173 | 178 | $permtoedit = $user->rights->propal->creer; |
| 174 | 179 | $param = '&id=' . $object->id; |
| 175 | 180 | include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
| 176 | -} |
|
| 177 | -else |
|
| 181 | +} else |
|
| 178 | 182 | { |
| 179 | 183 | print $langs->trans("ErrorUnknown"); |
| 180 | 184 | } |
@@ -29,45 +29,45 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 31 | 31 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 32 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 32 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 33 | 33 | require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
| 34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; |
| 35 | 35 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 36 | 36 | require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
| 37 | 37 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
| 38 | -if (! empty($conf->projet->enabled)) { |
|
| 39 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
| 38 | +if (!empty($conf->projet->enabled)) { |
|
| 39 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // Load translation files required by the page |
| 43 | 43 | $langs->loadLangs(array('compta', 'other', 'companies')); |
| 44 | 44 | |
| 45 | -$action = GETPOST('action','alpha'); |
|
| 46 | -$confirm = GETPOST('confirm','alpha'); |
|
| 47 | -$id = GETPOST('id','int'); |
|
| 48 | -$ref = GETPOST('ref','alpha'); |
|
| 45 | +$action = GETPOST('action', 'alpha'); |
|
| 46 | +$confirm = GETPOST('confirm', 'alpha'); |
|
| 47 | +$id = GETPOST('id', 'int'); |
|
| 48 | +$ref = GETPOST('ref', 'alpha'); |
|
| 49 | 49 | |
| 50 | 50 | // Security check |
| 51 | -$socid=''; |
|
| 52 | -if (! empty($user->societe_id)) |
|
| 51 | +$socid = ''; |
|
| 52 | +if (!empty($user->societe_id)) |
|
| 53 | 53 | { |
| 54 | 54 | $socid = $user->societe_id; |
| 55 | 55 | } |
| 56 | 56 | $result = restrictedArea($user, 'propal', $id); |
| 57 | 57 | |
| 58 | 58 | // Get parameters |
| 59 | -$sortfield = GETPOST("sortfield",'alpha'); |
|
| 60 | -$sortorder = GETPOST("sortorder",'alpha'); |
|
| 61 | -$page = GETPOST("page",'int'); |
|
| 59 | +$sortfield = GETPOST("sortfield", 'alpha'); |
|
| 60 | +$sortorder = GETPOST("sortorder", 'alpha'); |
|
| 61 | +$page = GETPOST("page", 'int'); |
|
| 62 | 62 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
| 63 | 63 | $offset = $conf->liste_limit * $page; |
| 64 | 64 | $pageprev = $page - 1; |
| 65 | 65 | $pagenext = $page + 1; |
| 66 | -if (! $sortorder) $sortorder="ASC"; |
|
| 67 | -if (! $sortfield) $sortfield="name"; |
|
| 66 | +if (!$sortorder) $sortorder = "ASC"; |
|
| 67 | +if (!$sortfield) $sortfield = "name"; |
|
| 68 | 68 | |
| 69 | 69 | $object = new Propal($db); |
| 70 | -$object->fetch($id,$ref); |
|
| 70 | +$object->fetch($id, $ref); |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | 73 | /* |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $object->fetch_thirdparty(); |
| 80 | 80 | $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
| 81 | - include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; |
|
| 81 | + include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * View |
| 87 | 87 | */ |
| 88 | 88 | |
| 89 | -llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); |
|
| 89 | +llxHeader('', $langs->trans('Proposal'), 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); |
|
| 90 | 90 | |
| 91 | 91 | $form = new Form($db); |
| 92 | 92 | |
@@ -98,59 +98,59 @@ discard block |
||
| 98 | 98 | dol_fiche_head($head, 'document', $langs->trans('Proposal'), -1, 'propal'); |
| 99 | 99 | |
| 100 | 100 | // Build file list |
| 101 | - $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); |
|
| 102 | - $totalsize=0; |
|
| 103 | - foreach($filearray as $key => $file) |
|
| 101 | + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); |
|
| 102 | + $totalsize = 0; |
|
| 103 | + foreach ($filearray as $key => $file) |
|
| 104 | 104 | { |
| 105 | - $totalsize+=$file['size']; |
|
| 105 | + $totalsize += $file['size']; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | // Proposal card |
| 110 | 110 | |
| 111 | - $linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
| 111 | + $linkback = '<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; |
|
| 112 | 112 | |
| 113 | 113 | |
| 114 | - $morehtmlref='<div class="refidno">'; |
|
| 114 | + $morehtmlref = '<div class="refidno">'; |
|
| 115 | 115 | // Ref customer |
| 116 | - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
| 117 | - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
| 116 | + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
| 117 | + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
| 118 | 118 | // Thirdparty |
| 119 | - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); |
|
| 119 | + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); |
|
| 120 | 120 | // Project |
| 121 | - if (! empty($conf->projet->enabled)) |
|
| 121 | + if (!empty($conf->projet->enabled)) |
|
| 122 | 122 | { |
| 123 | 123 | $langs->load("projects"); |
| 124 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
| 124 | + $morehtmlref .= '<br>'.$langs->trans('Project').' '; |
|
| 125 | 125 | if ($user->rights->propal->creer) |
| 126 | 126 | { |
| 127 | 127 | if ($action != 'classify') |
| 128 | 128 | //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; |
| 129 | - $morehtmlref.=' : '; |
|
| 129 | + $morehtmlref .= ' : '; |
|
| 130 | 130 | if ($action == 'classify') { |
| 131 | 131 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
| 132 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
| 133 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
| 134 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 135 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
| 136 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 137 | - $morehtmlref.='</form>'; |
|
| 132 | + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
| 133 | + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; |
|
| 134 | + $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 135 | + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
| 136 | + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 137 | + $morehtmlref .= '</form>'; |
|
| 138 | 138 | } else { |
| 139 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
| 139 | + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
| 140 | 140 | } |
| 141 | 141 | } else { |
| 142 | - if (! empty($object->fk_project)) { |
|
| 142 | + if (!empty($object->fk_project)) { |
|
| 143 | 143 | $proj = new Project($db); |
| 144 | 144 | $proj->fetch($object->fk_project); |
| 145 | - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
| 146 | - $morehtmlref.=$proj->ref; |
|
| 147 | - $morehtmlref.='</a>'; |
|
| 145 | + $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; |
|
| 146 | + $morehtmlref .= $proj->ref; |
|
| 147 | + $morehtmlref .= '</a>'; |
|
| 148 | 148 | } else { |
| 149 | - $morehtmlref.=''; |
|
| 149 | + $morehtmlref .= ''; |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | - $morehtmlref.='</div>'; |
|
| 153 | + $morehtmlref .= '</div>'; |
|
| 154 | 154 | |
| 155 | 155 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
| 156 | 156 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | // Files infos |
| 164 | 164 | print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td>'.count($filearray).'</td></tr>'; |
| 165 | - print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>'.dol_print_size($totalsize,1,1).'</td></tr>'; |
|
| 165 | + print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>'.dol_print_size($totalsize, 1, 1).'</td></tr>'; |
|
| 166 | 166 | |
| 167 | 167 | print "</table>\n"; |
| 168 | 168 | |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | $modulepart = 'propal'; |
| 175 | 175 | $permission = $user->rights->propal->creer; |
| 176 | 176 | $permtoedit = $user->rights->propal->creer; |
| 177 | - $param = '&id=' . $object->id; |
|
| 178 | - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
|
| 177 | + $param = '&id='.$object->id; |
|
| 178 | + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; |
|
| 179 | 179 | } |
| 180 | 180 | else |
| 181 | 181 | { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
| 31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; |
| 32 | 32 | if (! empty($conf->projet->enabled)) { |
| 33 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
| 33 | + require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | // Load translation files required by the page |
@@ -67,81 +67,81 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | if ($id > 0 || ! empty($ref)) |
| 69 | 69 | { |
| 70 | - if ($mesg) print $mesg; |
|
| 71 | - |
|
| 72 | - $now=dol_now(); |
|
| 73 | - |
|
| 74 | - if ($object->fetch($id, $ref) > 0) |
|
| 75 | - { |
|
| 76 | - if ($object->fetch_thirdparty() > 0) |
|
| 77 | - { |
|
| 78 | - $head = propal_prepare_head($object); |
|
| 79 | - dol_fiche_head($head, 'note', $langs->trans('Proposal'), -1, 'propal'); |
|
| 80 | - |
|
| 81 | - $cssclass='titlefield'; |
|
| 82 | - //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; |
|
| 83 | - //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; |
|
| 84 | - |
|
| 85 | - |
|
| 86 | - // Proposal card |
|
| 87 | - |
|
| 88 | - $linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - $morehtmlref='<div class="refidno">'; |
|
| 92 | - // Ref customer |
|
| 93 | - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
| 94 | - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
| 95 | - // Thirdparty |
|
| 96 | - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); |
|
| 97 | - // Project |
|
| 98 | - if (! empty($conf->projet->enabled)) |
|
| 99 | - { |
|
| 100 | - $langs->load("projects"); |
|
| 101 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
| 102 | - if ($user->rights->propal->creer) |
|
| 103 | - { |
|
| 104 | - if ($action != 'classify') |
|
| 105 | - //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; |
|
| 106 | - $morehtmlref.=' : '; |
|
| 107 | - if ($action == 'classify') { |
|
| 108 | - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
| 109 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
| 110 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
| 111 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 112 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
| 113 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 114 | - $morehtmlref.='</form>'; |
|
| 115 | - } else { |
|
| 116 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
| 117 | - } |
|
| 118 | - } else { |
|
| 119 | - if (! empty($object->fk_project)) { |
|
| 120 | - $proj = new Project($db); |
|
| 121 | - $proj->fetch($object->fk_project); |
|
| 122 | - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
| 123 | - $morehtmlref.=$proj->ref; |
|
| 124 | - $morehtmlref.='</a>'; |
|
| 125 | - } else { |
|
| 126 | - $morehtmlref.=''; |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - $morehtmlref.='</div>'; |
|
| 131 | - |
|
| 132 | - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
|
| 133 | - |
|
| 134 | - print '<div class="fichecenter">'; |
|
| 135 | - print '<div class="underbanner clearboth"></div>'; |
|
| 136 | - |
|
| 137 | - $cssclass="titlefield"; |
|
| 138 | - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; |
|
| 139 | - |
|
| 140 | - print '</div>'; |
|
| 141 | - |
|
| 142 | - dol_fiche_end(); |
|
| 143 | - } |
|
| 144 | - } |
|
| 70 | + if ($mesg) print $mesg; |
|
| 71 | + |
|
| 72 | + $now=dol_now(); |
|
| 73 | + |
|
| 74 | + if ($object->fetch($id, $ref) > 0) |
|
| 75 | + { |
|
| 76 | + if ($object->fetch_thirdparty() > 0) |
|
| 77 | + { |
|
| 78 | + $head = propal_prepare_head($object); |
|
| 79 | + dol_fiche_head($head, 'note', $langs->trans('Proposal'), -1, 'propal'); |
|
| 80 | + |
|
| 81 | + $cssclass='titlefield'; |
|
| 82 | + //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; |
|
| 83 | + //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; |
|
| 84 | + |
|
| 85 | + |
|
| 86 | + // Proposal card |
|
| 87 | + |
|
| 88 | + $linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + $morehtmlref='<div class="refidno">'; |
|
| 92 | + // Ref customer |
|
| 93 | + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
| 94 | + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
| 95 | + // Thirdparty |
|
| 96 | + $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); |
|
| 97 | + // Project |
|
| 98 | + if (! empty($conf->projet->enabled)) |
|
| 99 | + { |
|
| 100 | + $langs->load("projects"); |
|
| 101 | + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
| 102 | + if ($user->rights->propal->creer) |
|
| 103 | + { |
|
| 104 | + if ($action != 'classify') |
|
| 105 | + //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; |
|
| 106 | + $morehtmlref.=' : '; |
|
| 107 | + if ($action == 'classify') { |
|
| 108 | + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
| 109 | + $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
| 110 | + $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
| 111 | + $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 112 | + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
| 113 | + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 114 | + $morehtmlref.='</form>'; |
|
| 115 | + } else { |
|
| 116 | + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
| 117 | + } |
|
| 118 | + } else { |
|
| 119 | + if (! empty($object->fk_project)) { |
|
| 120 | + $proj = new Project($db); |
|
| 121 | + $proj->fetch($object->fk_project); |
|
| 122 | + $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
| 123 | + $morehtmlref.=$proj->ref; |
|
| 124 | + $morehtmlref.='</a>'; |
|
| 125 | + } else { |
|
| 126 | + $morehtmlref.=''; |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + $morehtmlref.='</div>'; |
|
| 131 | + |
|
| 132 | + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
|
| 133 | + |
|
| 134 | + print '<div class="fichecenter">'; |
|
| 135 | + print '<div class="underbanner clearboth"></div>'; |
|
| 136 | + |
|
| 137 | + $cssclass="titlefield"; |
|
| 138 | + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; |
|
| 139 | + |
|
| 140 | + print '</div>'; |
|
| 141 | + |
|
| 142 | + dol_fiche_end(); |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // End of page |
@@ -41,7 +41,9 @@ discard block |
||
| 41 | 41 | $action=GETPOST('action','alpha'); |
| 42 | 42 | |
| 43 | 43 | // Security check |
| 44 | -if ($user->societe_id) $socid=$user->societe_id; |
|
| 44 | +if ($user->societe_id) { |
|
| 45 | + $socid=$user->societe_id; |
|
| 46 | +} |
|
| 45 | 47 | $result = restrictedArea($user, 'propale', $id, 'propal'); |
| 46 | 48 | |
| 47 | 49 | $object = new Propal($db); |
@@ -67,7 +69,9 @@ discard block |
||
| 67 | 69 | |
| 68 | 70 | if ($id > 0 || ! empty($ref)) |
| 69 | 71 | { |
| 70 | - if ($mesg) print $mesg; |
|
| 72 | + if ($mesg) { |
|
| 73 | + print $mesg; |
|
| 74 | + } |
|
| 71 | 75 | |
| 72 | 76 | $now=dol_now(); |
| 73 | 77 | |
@@ -101,9 +105,10 @@ discard block |
||
| 101 | 105 | $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
| 102 | 106 | if ($user->rights->propal->creer) |
| 103 | 107 | { |
| 104 | - if ($action != 'classify') |
|
| 105 | - //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; |
|
| 108 | + if ($action != 'classify') { |
|
| 109 | + //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; |
|
| 106 | 110 | $morehtmlref.=' : '; |
| 111 | + } |
|
| 107 | 112 | if ($action == 'classify') { |
| 108 | 113 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
| 109 | 114 | $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
@@ -27,23 +27,23 @@ discard block |
||
| 27 | 27 | * \ingroup propal |
| 28 | 28 | * \brief Fiche d'information sur une proposition commerciale |
| 29 | 29 | */ |
| 30 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 30 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 31 | 31 | |
| 32 | 32 | require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
| 33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; |
| 34 | -if (! empty($conf->projet->enabled)) { |
|
| 35 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
| 34 | +if (!empty($conf->projet->enabled)) { |
|
| 35 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Load translation files required by the page |
| 39 | 39 | $langs->loadLangs(array('propal', 'compta', 'bills', 'companies')); |
| 40 | 40 | |
| 41 | -$id = GETPOST('id','int'); |
|
| 42 | -$ref=GETPOST('ref','alpha'); |
|
| 43 | -$action=GETPOST('action','alpha'); |
|
| 41 | +$id = GETPOST('id', 'int'); |
|
| 42 | +$ref = GETPOST('ref', 'alpha'); |
|
| 43 | +$action = GETPOST('action', 'alpha'); |
|
| 44 | 44 | |
| 45 | 45 | // Security check |
| 46 | -if ($user->societe_id) $socid=$user->societe_id; |
|
| 46 | +if ($user->societe_id) $socid = $user->societe_id; |
|
| 47 | 47 | $result = restrictedArea($user, 'propale', $id, 'propal'); |
| 48 | 48 | |
| 49 | 49 | $object = new Propal($db); |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * Actions |
| 54 | 54 | */ |
| 55 | 55 | |
| 56 | -$permissionnote=$user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php |
|
| 56 | +$permissionnote = $user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php |
|
| 57 | 57 | |
| 58 | -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once |
|
| 58 | +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once |
|
| 59 | 59 | |
| 60 | 60 | |
| 61 | 61 | |
@@ -63,15 +63,15 @@ discard block |
||
| 63 | 63 | * View |
| 64 | 64 | */ |
| 65 | 65 | |
| 66 | -llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); |
|
| 66 | +llxHeader('', $langs->trans('Proposal'), 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); |
|
| 67 | 67 | |
| 68 | 68 | $form = new Form($db); |
| 69 | 69 | |
| 70 | -if ($id > 0 || ! empty($ref)) |
|
| 70 | +if ($id > 0 || !empty($ref)) |
|
| 71 | 71 | { |
| 72 | 72 | if ($mesg) print $mesg; |
| 73 | 73 | |
| 74 | - $now=dol_now(); |
|
| 74 | + $now = dol_now(); |
|
| 75 | 75 | |
| 76 | 76 | if ($object->fetch($id, $ref) > 0) |
| 77 | 77 | { |
@@ -80,63 +80,63 @@ discard block |
||
| 80 | 80 | $head = propal_prepare_head($object); |
| 81 | 81 | dol_fiche_head($head, 'note', $langs->trans('Proposal'), -1, 'propal'); |
| 82 | 82 | |
| 83 | - $cssclass='titlefield'; |
|
| 83 | + $cssclass = 'titlefield'; |
|
| 84 | 84 | //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; |
| 85 | 85 | //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; |
| 86 | 86 | |
| 87 | 87 | |
| 88 | 88 | // Proposal card |
| 89 | 89 | |
| 90 | - $linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
| 90 | + $linkback = '<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; |
|
| 91 | 91 | |
| 92 | 92 | |
| 93 | - $morehtmlref='<div class="refidno">'; |
|
| 93 | + $morehtmlref = '<div class="refidno">'; |
|
| 94 | 94 | // Ref customer |
| 95 | - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
| 96 | - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
| 95 | + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
| 96 | + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
| 97 | 97 | // Thirdparty |
| 98 | - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); |
|
| 98 | + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); |
|
| 99 | 99 | // Project |
| 100 | - if (! empty($conf->projet->enabled)) |
|
| 100 | + if (!empty($conf->projet->enabled)) |
|
| 101 | 101 | { |
| 102 | 102 | $langs->load("projects"); |
| 103 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
| 103 | + $morehtmlref .= '<br>'.$langs->trans('Project').' '; |
|
| 104 | 104 | if ($user->rights->propal->creer) |
| 105 | 105 | { |
| 106 | 106 | if ($action != 'classify') |
| 107 | 107 | //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; |
| 108 | - $morehtmlref.=' : '; |
|
| 108 | + $morehtmlref .= ' : '; |
|
| 109 | 109 | if ($action == 'classify') { |
| 110 | 110 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
| 111 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
| 112 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
| 113 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 114 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
| 115 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 116 | - $morehtmlref.='</form>'; |
|
| 111 | + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
| 112 | + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; |
|
| 113 | + $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 114 | + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
| 115 | + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 116 | + $morehtmlref .= '</form>'; |
|
| 117 | 117 | } else { |
| 118 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
| 118 | + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
| 119 | 119 | } |
| 120 | 120 | } else { |
| 121 | - if (! empty($object->fk_project)) { |
|
| 121 | + if (!empty($object->fk_project)) { |
|
| 122 | 122 | $proj = new Project($db); |
| 123 | 123 | $proj->fetch($object->fk_project); |
| 124 | - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
| 125 | - $morehtmlref.=$proj->ref; |
|
| 126 | - $morehtmlref.='</a>'; |
|
| 124 | + $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; |
|
| 125 | + $morehtmlref .= $proj->ref; |
|
| 126 | + $morehtmlref .= '</a>'; |
|
| 127 | 127 | } else { |
| 128 | - $morehtmlref.=''; |
|
| 128 | + $morehtmlref .= ''; |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | - $morehtmlref.='</div>'; |
|
| 132 | + $morehtmlref .= '</div>'; |
|
| 133 | 133 | |
| 134 | 134 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
| 135 | 135 | |
| 136 | 136 | print '<div class="fichecenter">'; |
| 137 | 137 | print '<div class="underbanner clearboth"></div>'; |
| 138 | 138 | |
| 139 | - $cssclass="titlefield"; |
|
| 139 | + $cssclass = "titlefield"; |
|
| 140 | 140 | include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; |
| 141 | 141 | |
| 142 | 142 | print '</div>'; |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | $socid=GETPOST('socid','int'); |
| 35 | 35 | if (isset($user->societe_id) && $user->societe_id > 0) |
| 36 | 36 | { |
| 37 | - $action = ''; |
|
| 38 | - $socid = $user->societe_id; |
|
| 37 | + $action = ''; |
|
| 38 | + $socid = $user->societe_id; |
|
| 39 | 39 | } |
| 40 | 40 | $result = restrictedArea($user, 'propal'); |
| 41 | 41 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $listofstatus=array(0,1,2,3,4); |
| 118 | 118 | foreach ($listofstatus as $status) |
| 119 | 119 | { |
| 120 | - $dataseries[]=array($propalstatic->LibStatut($status,1), (isset($vals[$status])?(int) $vals[$status]:0)); |
|
| 120 | + $dataseries[]=array($propalstatic->LibStatut($status,1), (isset($vals[$status])?(int) $vals[$status]:0)); |
|
| 121 | 121 | if (! $conf->use_javascript_ajax) |
| 122 | 122 | { |
| 123 | 123 | |
@@ -159,50 +159,50 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | if (! empty($conf->propal->enabled)) |
| 161 | 161 | { |
| 162 | - $sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client"; |
|
| 163 | - $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; |
|
| 164 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 165 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 166 | - $sql.= " WHERE c.fk_soc = s.rowid"; |
|
| 167 | - $sql.= " AND c.entity IN (".getEntity('propal').")"; |
|
| 168 | - $sql.= " AND c.fk_statut = 0"; |
|
| 169 | - if ($socid) $sql.= " AND c.fk_soc = ".$socid; |
|
| 170 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 171 | - |
|
| 172 | - $resql=$db->query($sql); |
|
| 173 | - if ($resql) |
|
| 174 | - { |
|
| 175 | - print '<div class="div-table-responsive-no-min">'; |
|
| 176 | - print '<table class="noborder" width="100%">'; |
|
| 177 | - print '<tr class="liste_titre">'; |
|
| 178 | - print '<td colspan="2">'.$langs->trans("DraftPropals").'</td></tr>'; |
|
| 179 | - $langs->load("propal"); |
|
| 180 | - $num = $db->num_rows($resql); |
|
| 181 | - if ($num) |
|
| 182 | - { |
|
| 183 | - $i = 0; |
|
| 184 | - while ($i < $num) |
|
| 185 | - { |
|
| 186 | - $obj = $db->fetch_object($resql); |
|
| 187 | - print '<tr class="oddeven">'; |
|
| 162 | + $sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client"; |
|
| 163 | + $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; |
|
| 164 | + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 165 | + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 166 | + $sql.= " WHERE c.fk_soc = s.rowid"; |
|
| 167 | + $sql.= " AND c.entity IN (".getEntity('propal').")"; |
|
| 168 | + $sql.= " AND c.fk_statut = 0"; |
|
| 169 | + if ($socid) $sql.= " AND c.fk_soc = ".$socid; |
|
| 170 | + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 171 | + |
|
| 172 | + $resql=$db->query($sql); |
|
| 173 | + if ($resql) |
|
| 174 | + { |
|
| 175 | + print '<div class="div-table-responsive-no-min">'; |
|
| 176 | + print '<table class="noborder" width="100%">'; |
|
| 177 | + print '<tr class="liste_titre">'; |
|
| 178 | + print '<td colspan="2">'.$langs->trans("DraftPropals").'</td></tr>'; |
|
| 179 | + $langs->load("propal"); |
|
| 180 | + $num = $db->num_rows($resql); |
|
| 181 | + if ($num) |
|
| 182 | + { |
|
| 183 | + $i = 0; |
|
| 184 | + while ($i < $num) |
|
| 185 | + { |
|
| 186 | + $obj = $db->fetch_object($resql); |
|
| 187 | + print '<tr class="oddeven">'; |
|
| 188 | 188 | |
| 189 | - $propalstatic->id=$obj->rowid; |
|
| 190 | - $propalstatic->ref=$obj->ref; |
|
| 191 | - print '<td class="nowrap">'.$propalstatic->getNomUrl(1).'</td>'; |
|
| 189 | + $propalstatic->id=$obj->rowid; |
|
| 190 | + $propalstatic->ref=$obj->ref; |
|
| 191 | + print '<td class="nowrap">'.$propalstatic->getNomUrl(1).'</td>'; |
|
| 192 | 192 | |
| 193 | - $companystatic->id=$obj->socid; |
|
| 194 | - $companystatic->name=$obj->socname; |
|
| 195 | - $companystatic->client=$obj->client; |
|
| 196 | - $companystatic->canvas=$obj->canvas; |
|
| 197 | - print '<td>'.$companystatic->getNomUrl(1,'customer',24).'</td>'; |
|
| 193 | + $companystatic->id=$obj->socid; |
|
| 194 | + $companystatic->name=$obj->socname; |
|
| 195 | + $companystatic->client=$obj->client; |
|
| 196 | + $companystatic->canvas=$obj->canvas; |
|
| 197 | + print '<td>'.$companystatic->getNomUrl(1,'customer',24).'</td>'; |
|
| 198 | 198 | |
| 199 | - print '</tr>'; |
|
| 200 | - $i++; |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - print "</table>"; |
|
| 204 | - print "</div><br>"; |
|
| 205 | - } |
|
| 199 | + print '</tr>'; |
|
| 200 | + $i++; |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + print "</table>"; |
|
| 204 | + print "</div><br>"; |
|
| 205 | + } |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | |
@@ -232,57 +232,57 @@ discard block |
||
| 232 | 232 | $resql=$db->query($sql); |
| 233 | 233 | if ($resql) |
| 234 | 234 | { |
| 235 | - print '<div class="div-table-responsive-no-min">'; |
|
| 236 | - print '<table class="noborder" width="100%">'; |
|
| 237 | - print '<tr class="liste_titre">'; |
|
| 238 | - print '<td colspan="4">'.$langs->trans("LastModifiedProposals",$max).'</td></tr>'; |
|
| 235 | + print '<div class="div-table-responsive-no-min">'; |
|
| 236 | + print '<table class="noborder" width="100%">'; |
|
| 237 | + print '<tr class="liste_titre">'; |
|
| 238 | + print '<td colspan="4">'.$langs->trans("LastModifiedProposals",$max).'</td></tr>'; |
|
| 239 | 239 | |
| 240 | - $num = $db->num_rows($resql); |
|
| 241 | - if ($num) |
|
| 242 | - { |
|
| 243 | - $i = 0; |
|
| 244 | - while ($i < $num) |
|
| 245 | - { |
|
| 246 | - $obj = $db->fetch_object($resql); |
|
| 247 | - |
|
| 248 | - print '<tr class="oddeven">'; |
|
| 249 | - print '<td width="20%" class="nowrap">'; |
|
| 250 | - |
|
| 251 | - $propalstatic->id=$obj->rowid; |
|
| 252 | - $propalstatic->ref=$obj->ref; |
|
| 253 | - |
|
| 254 | - print '<table class="nobordernopadding"><tr class="nocellnopadd">'; |
|
| 255 | - print '<td width="96" class="nobordernopadding nowrap">'; |
|
| 256 | - print $propalstatic->getNomUrl(1); |
|
| 257 | - print '</td>'; |
|
| 258 | - |
|
| 259 | - print '<td width="16" class="nobordernopadding nowrap">'; |
|
| 260 | - print ' '; |
|
| 261 | - print '</td>'; |
|
| 262 | - |
|
| 263 | - print '<td width="16" align="right" class="nobordernopadding">'; |
|
| 264 | - $filename=dol_sanitizeFileName($obj->ref); |
|
| 265 | - $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); |
|
| 266 | - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; |
|
| 267 | - print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); |
|
| 268 | - print '</td></tr></table>'; |
|
| 269 | - |
|
| 270 | - print '</td>'; |
|
| 271 | - |
|
| 272 | - $companystatic->id=$obj->socid; |
|
| 273 | - $companystatic->name=$obj->socname; |
|
| 274 | - $companystatic->client=$obj->client; |
|
| 275 | - $companystatic->canvas=$obj->canvas; |
|
| 276 | - print '<td>'.$companystatic->getNomUrl(1,'customer').'</td>'; |
|
| 277 | - |
|
| 278 | - print '<td>'.dol_print_date($db->jdate($obj->datec),'day').'</td>'; |
|
| 279 | - print '<td align="right">'.$propalstatic->LibStatut($obj->fk_statut,5).'</td>'; |
|
| 280 | - print '</tr>'; |
|
| 281 | - $i++; |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - print "</table>"; |
|
| 285 | - print "</div><br>"; |
|
| 240 | + $num = $db->num_rows($resql); |
|
| 241 | + if ($num) |
|
| 242 | + { |
|
| 243 | + $i = 0; |
|
| 244 | + while ($i < $num) |
|
| 245 | + { |
|
| 246 | + $obj = $db->fetch_object($resql); |
|
| 247 | + |
|
| 248 | + print '<tr class="oddeven">'; |
|
| 249 | + print '<td width="20%" class="nowrap">'; |
|
| 250 | + |
|
| 251 | + $propalstatic->id=$obj->rowid; |
|
| 252 | + $propalstatic->ref=$obj->ref; |
|
| 253 | + |
|
| 254 | + print '<table class="nobordernopadding"><tr class="nocellnopadd">'; |
|
| 255 | + print '<td width="96" class="nobordernopadding nowrap">'; |
|
| 256 | + print $propalstatic->getNomUrl(1); |
|
| 257 | + print '</td>'; |
|
| 258 | + |
|
| 259 | + print '<td width="16" class="nobordernopadding nowrap">'; |
|
| 260 | + print ' '; |
|
| 261 | + print '</td>'; |
|
| 262 | + |
|
| 263 | + print '<td width="16" align="right" class="nobordernopadding">'; |
|
| 264 | + $filename=dol_sanitizeFileName($obj->ref); |
|
| 265 | + $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); |
|
| 266 | + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; |
|
| 267 | + print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); |
|
| 268 | + print '</td></tr></table>'; |
|
| 269 | + |
|
| 270 | + print '</td>'; |
|
| 271 | + |
|
| 272 | + $companystatic->id=$obj->socid; |
|
| 273 | + $companystatic->name=$obj->socname; |
|
| 274 | + $companystatic->client=$obj->client; |
|
| 275 | + $companystatic->canvas=$obj->canvas; |
|
| 276 | + print '<td>'.$companystatic->getNomUrl(1,'customer').'</td>'; |
|
| 277 | + |
|
| 278 | + print '<td>'.dol_print_date($db->jdate($obj->datec),'day').'</td>'; |
|
| 279 | + print '<td align="right">'.$propalstatic->LibStatut($obj->fk_statut,5).'</td>'; |
|
| 280 | + print '</tr>'; |
|
| 281 | + $i++; |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + print "</table>"; |
|
| 285 | + print "</div><br>"; |
|
| 286 | 286 | } |
| 287 | 287 | else dol_print_error($db); |
| 288 | 288 | |
@@ -292,93 +292,93 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | if (! empty($conf->propal->enabled) && $user->rights->propale->lire) |
| 294 | 294 | { |
| 295 | - $langs->load("propal"); |
|
| 296 | - |
|
| 297 | - $now=dol_now(); |
|
| 298 | - |
|
| 299 | - $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client"; |
|
| 300 | - $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; |
|
| 301 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
| 302 | - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; |
|
| 303 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 304 | - $sql.= " WHERE p.fk_soc = s.rowid"; |
|
| 305 | - $sql.= " AND p.entity IN (".getEntity('propal').")"; |
|
| 306 | - $sql.= " AND p.fk_statut = 1"; |
|
| 307 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 308 | - if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
| 309 | - $sql.= " ORDER BY p.rowid DESC"; |
|
| 310 | - |
|
| 311 | - $result=$db->query($sql); |
|
| 312 | - if ($result) |
|
| 313 | - { |
|
| 314 | - $total = 0; |
|
| 315 | - $num = $db->num_rows($result); |
|
| 316 | - $i = 0; |
|
| 317 | - if ($num > 0) |
|
| 318 | - { |
|
| 319 | - print '<div class="div-table-responsive-no-min">'; |
|
| 320 | - print '<table class="noborder" width="100%">'; |
|
| 321 | - print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("ProposalsOpened").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=1"><span class="badge">'.$num.'</span></a></td></tr>'; |
|
| 322 | - |
|
| 323 | - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); |
|
| 324 | - while ($i < $nbofloop) |
|
| 325 | - { |
|
| 326 | - $obj = $db->fetch_object($result); |
|
| 327 | - |
|
| 328 | - print '<tr class="oddeven">'; |
|
| 329 | - |
|
| 330 | - // Ref |
|
| 331 | - print '<td class="nowrap" width="140">'; |
|
| 332 | - |
|
| 333 | - $propalstatic->id=$obj->propalid; |
|
| 334 | - $propalstatic->ref=$obj->ref; |
|
| 335 | - |
|
| 336 | - print '<table class="nobordernopadding"><tr class="nocellnopadd">'; |
|
| 337 | - print '<td class="nobordernopadding nowrap">'; |
|
| 338 | - print $propalstatic->getNomUrl(1); |
|
| 339 | - print '</td>'; |
|
| 340 | - print '<td width="18" class="nobordernopadding nowrap">'; |
|
| 341 | - if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); |
|
| 342 | - print '</td>'; |
|
| 343 | - print '<td width="16" align="center" class="nobordernopadding">'; |
|
| 344 | - $filename=dol_sanitizeFileName($obj->ref); |
|
| 345 | - $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); |
|
| 346 | - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; |
|
| 347 | - print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); |
|
| 348 | - print '</td></tr></table>'; |
|
| 349 | - |
|
| 350 | - print "</td>"; |
|
| 351 | - |
|
| 352 | - $companystatic->id=$obj->socid; |
|
| 353 | - $companystatic->name=$obj->socname; |
|
| 354 | - $companystatic->client=$obj->client; |
|
| 355 | - $companystatic->canvas=$obj->canvas; |
|
| 356 | - print '<td align="left">'.$companystatic->getNomUrl(1,'customer',44).'</td>'."\n"; |
|
| 295 | + $langs->load("propal"); |
|
| 296 | + |
|
| 297 | + $now=dol_now(); |
|
| 298 | + |
|
| 299 | + $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client"; |
|
| 300 | + $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; |
|
| 301 | + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
| 302 | + $sql.= ", ".MAIN_DB_PREFIX."propal as p"; |
|
| 303 | + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 304 | + $sql.= " WHERE p.fk_soc = s.rowid"; |
|
| 305 | + $sql.= " AND p.entity IN (".getEntity('propal').")"; |
|
| 306 | + $sql.= " AND p.fk_statut = 1"; |
|
| 307 | + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 308 | + if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
| 309 | + $sql.= " ORDER BY p.rowid DESC"; |
|
| 310 | + |
|
| 311 | + $result=$db->query($sql); |
|
| 312 | + if ($result) |
|
| 313 | + { |
|
| 314 | + $total = 0; |
|
| 315 | + $num = $db->num_rows($result); |
|
| 316 | + $i = 0; |
|
| 317 | + if ($num > 0) |
|
| 318 | + { |
|
| 319 | + print '<div class="div-table-responsive-no-min">'; |
|
| 320 | + print '<table class="noborder" width="100%">'; |
|
| 321 | + print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("ProposalsOpened").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=1"><span class="badge">'.$num.'</span></a></td></tr>'; |
|
| 357 | 322 | |
| 358 | - print '<td align="right">'; |
|
| 359 | - print dol_print_date($db->jdate($obj->dp),'day').'</td>'."\n"; |
|
| 360 | - print '<td align="right">'.price($obj->total_ttc).'</td>'; |
|
| 361 | - print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut,3).'</td>'."\n"; |
|
| 362 | - print '</tr>'."\n"; |
|
| 363 | - $i++; |
|
| 364 | - $total += $obj->total_ttc; |
|
| 365 | - } |
|
| 366 | - if ($num > $nbofloop) |
|
| 367 | - { |
|
| 368 | - print '<tr class="liste_total"><td colspan="5">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>"; |
|
| 369 | - } |
|
| 370 | - else if ($total>0) |
|
| 371 | - { |
|
| 372 | - print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td> </td></tr>"; |
|
| 373 | - } |
|
| 374 | - print "</table>"; |
|
| 375 | - print "</div><br>"; |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - else |
|
| 379 | - { |
|
| 380 | - dol_print_error($db); |
|
| 381 | - } |
|
| 323 | + $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); |
|
| 324 | + while ($i < $nbofloop) |
|
| 325 | + { |
|
| 326 | + $obj = $db->fetch_object($result); |
|
| 327 | + |
|
| 328 | + print '<tr class="oddeven">'; |
|
| 329 | + |
|
| 330 | + // Ref |
|
| 331 | + print '<td class="nowrap" width="140">'; |
|
| 332 | + |
|
| 333 | + $propalstatic->id=$obj->propalid; |
|
| 334 | + $propalstatic->ref=$obj->ref; |
|
| 335 | + |
|
| 336 | + print '<table class="nobordernopadding"><tr class="nocellnopadd">'; |
|
| 337 | + print '<td class="nobordernopadding nowrap">'; |
|
| 338 | + print $propalstatic->getNomUrl(1); |
|
| 339 | + print '</td>'; |
|
| 340 | + print '<td width="18" class="nobordernopadding nowrap">'; |
|
| 341 | + if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); |
|
| 342 | + print '</td>'; |
|
| 343 | + print '<td width="16" align="center" class="nobordernopadding">'; |
|
| 344 | + $filename=dol_sanitizeFileName($obj->ref); |
|
| 345 | + $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); |
|
| 346 | + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; |
|
| 347 | + print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); |
|
| 348 | + print '</td></tr></table>'; |
|
| 349 | + |
|
| 350 | + print "</td>"; |
|
| 351 | + |
|
| 352 | + $companystatic->id=$obj->socid; |
|
| 353 | + $companystatic->name=$obj->socname; |
|
| 354 | + $companystatic->client=$obj->client; |
|
| 355 | + $companystatic->canvas=$obj->canvas; |
|
| 356 | + print '<td align="left">'.$companystatic->getNomUrl(1,'customer',44).'</td>'."\n"; |
|
| 357 | + |
|
| 358 | + print '<td align="right">'; |
|
| 359 | + print dol_print_date($db->jdate($obj->dp),'day').'</td>'."\n"; |
|
| 360 | + print '<td align="right">'.price($obj->total_ttc).'</td>'; |
|
| 361 | + print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut,3).'</td>'."\n"; |
|
| 362 | + print '</tr>'."\n"; |
|
| 363 | + $i++; |
|
| 364 | + $total += $obj->total_ttc; |
|
| 365 | + } |
|
| 366 | + if ($num > $nbofloop) |
|
| 367 | + { |
|
| 368 | + print '<tr class="liste_total"><td colspan="5">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>"; |
|
| 369 | + } |
|
| 370 | + else if ($total>0) |
|
| 371 | + { |
|
| 372 | + print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td> </td></tr>"; |
|
| 373 | + } |
|
| 374 | + print "</table>"; |
|
| 375 | + print "</div><br>"; |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | + else |
|
| 379 | + { |
|
| 380 | + dol_print_error($db); |
|
| 381 | + } |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | /* |
@@ -59,9 +59,11 @@ discard block |
||
| 59 | 59 | print '<div class="fichecenter"><div class="fichethirdleft">'; |
| 60 | 60 | |
| 61 | 61 | |
| 62 | -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo |
|
| 62 | +if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { |
|
| 63 | + // This is useless due to the global search combo |
|
| 63 | 64 | { |
| 64 | 65 | print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/list.php">'; |
| 66 | +} |
|
| 65 | 67 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 66 | 68 | print '<table class="noborder nohover" width="100%">'; |
| 67 | 69 | print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; |
@@ -78,11 +80,17 @@ discard block |
||
| 78 | 80 | $sql = "SELECT count(p.rowid), p.fk_statut"; |
| 79 | 81 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
| 80 | 82 | $sql.= ", ".MAIN_DB_PREFIX."propal as p"; |
| 81 | -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 83 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
| 84 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 85 | +} |
|
| 82 | 86 | $sql.= " WHERE p.fk_soc = s.rowid"; |
| 83 | 87 | $sql.= " AND p.entity IN (".getEntity('propal').")"; |
| 84 | -if ($user->societe_id) $sql.=' AND p.fk_soc = '.$user->societe_id; |
|
| 85 | -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 88 | +if ($user->societe_id) { |
|
| 89 | + $sql.=' AND p.fk_soc = '.$user->societe_id; |
|
| 90 | +} |
|
| 91 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
| 92 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 93 | +} |
|
| 86 | 94 | $sql.= " AND p.fk_statut IN (0,1,2,3,4)"; |
| 87 | 95 | $sql.= " GROUP BY p.fk_statut"; |
| 88 | 96 | $resql = $db->query($sql); |
@@ -147,8 +155,7 @@ discard block |
||
| 147 | 155 | //print '<tr class="liste_total"><td>'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')</td><td align="right">'.$totalinprocess.'</td></tr>'; |
| 148 | 156 | print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td align="right">'.$total.'</td></tr>'; |
| 149 | 157 | print "</table><br>"; |
| 150 | -} |
|
| 151 | -else |
|
| 158 | +} else |
|
| 152 | 159 | { |
| 153 | 160 | dol_print_error($db); |
| 154 | 161 | } |
@@ -162,12 +169,18 @@ discard block |
||
| 162 | 169 | $sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client"; |
| 163 | 170 | $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; |
| 164 | 171 | $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
| 165 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 172 | + if (!$user->rights->societe->client->voir && !$socid) { |
|
| 173 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 174 | + } |
|
| 166 | 175 | $sql.= " WHERE c.fk_soc = s.rowid"; |
| 167 | 176 | $sql.= " AND c.entity IN (".getEntity('propal').")"; |
| 168 | 177 | $sql.= " AND c.fk_statut = 0"; |
| 169 | - if ($socid) $sql.= " AND c.fk_soc = ".$socid; |
|
| 170 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 178 | + if ($socid) { |
|
| 179 | + $sql.= " AND c.fk_soc = ".$socid; |
|
| 180 | + } |
|
| 181 | + if (!$user->rights->societe->client->voir && !$socid) { |
|
| 182 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 183 | + } |
|
| 171 | 184 | |
| 172 | 185 | $resql=$db->query($sql); |
| 173 | 186 | if ($resql) |
@@ -220,12 +233,18 @@ discard block |
||
| 220 | 233 | $sql.= " date_cloture as datec"; |
| 221 | 234 | $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; |
| 222 | 235 | $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
| 223 | -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 236 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
| 237 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 238 | +} |
|
| 224 | 239 | $sql.= " WHERE c.fk_soc = s.rowid"; |
| 225 | 240 | $sql.= " AND c.entity IN (".getEntity('propal').")"; |
| 226 | 241 | //$sql.= " AND c.fk_statut > 2"; |
| 227 | -if ($socid) $sql .= " AND c.fk_soc = ".$socid; |
|
| 228 | -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 242 | +if ($socid) { |
|
| 243 | + $sql .= " AND c.fk_soc = ".$socid; |
|
| 244 | +} |
|
| 245 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
| 246 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 247 | +} |
|
| 229 | 248 | $sql.= " ORDER BY c.tms DESC"; |
| 230 | 249 | $sql.= $db->plimit($max, 0); |
| 231 | 250 | |
@@ -283,8 +302,9 @@ discard block |
||
| 283 | 302 | } |
| 284 | 303 | print "</table>"; |
| 285 | 304 | print "</div><br>"; |
| 305 | +} else { |
|
| 306 | + dol_print_error($db); |
|
| 286 | 307 | } |
| 287 | -else dol_print_error($db); |
|
| 288 | 308 | |
| 289 | 309 | |
| 290 | 310 | /* |
@@ -300,12 +320,18 @@ discard block |
||
| 300 | 320 | $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; |
| 301 | 321 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
| 302 | 322 | $sql.= ", ".MAIN_DB_PREFIX."propal as p"; |
| 303 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 323 | + if (!$user->rights->societe->client->voir && !$socid) { |
|
| 324 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 325 | + } |
|
| 304 | 326 | $sql.= " WHERE p.fk_soc = s.rowid"; |
| 305 | 327 | $sql.= " AND p.entity IN (".getEntity('propal').")"; |
| 306 | 328 | $sql.= " AND p.fk_statut = 1"; |
| 307 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 308 | - if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
| 329 | + if (!$user->rights->societe->client->voir && !$socid) { |
|
| 330 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 331 | + } |
|
| 332 | + if ($socid) { |
|
| 333 | + $sql.= " AND s.rowid = ".$socid; |
|
| 334 | + } |
|
| 309 | 335 | $sql.= " ORDER BY p.rowid DESC"; |
| 310 | 336 | |
| 311 | 337 | $result=$db->query($sql); |
@@ -338,7 +364,9 @@ discard block |
||
| 338 | 364 | print $propalstatic->getNomUrl(1); |
| 339 | 365 | print '</td>'; |
| 340 | 366 | print '<td width="18" class="nobordernopadding nowrap">'; |
| 341 | - if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); |
|
| 367 | + if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) { |
|
| 368 | + print img_warning($langs->trans("Late")); |
|
| 369 | + } |
|
| 342 | 370 | print '</td>'; |
| 343 | 371 | print '<td width="16" align="center" class="nobordernopadding">'; |
| 344 | 372 | $filename=dol_sanitizeFileName($obj->ref); |
@@ -366,16 +394,14 @@ discard block |
||
| 366 | 394 | if ($num > $nbofloop) |
| 367 | 395 | { |
| 368 | 396 | print '<tr class="liste_total"><td colspan="5">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>"; |
| 369 | - } |
|
| 370 | - else if ($total>0) |
|
| 397 | + } else if ($total>0) |
|
| 371 | 398 | { |
| 372 | 399 | print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td> </td></tr>"; |
| 373 | 400 | } |
| 374 | 401 | print "</table>"; |
| 375 | 402 | print "</div><br>"; |
| 376 | 403 | } |
| 377 | - } |
|
| 378 | - else |
|
| 404 | + } else |
|
| 379 | 405 | { |
| 380 | 406 | dol_print_error($db); |
| 381 | 407 | } |
@@ -26,16 +26,16 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 28 | 28 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 29 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 29 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 30 | 30 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
| 31 | -require_once DOL_DOCUMENT_ROOT .'/comm/propal/class/propal.class.php'; |
|
| 31 | +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 32 | 32 | |
| 33 | 33 | // Load translation files required by the page |
| 34 | 34 | $langs->loadLangs(array('propal', 'companies')); |
| 35 | 35 | |
| 36 | 36 | // Security check |
| 37 | -$socid=GETPOST('socid','int'); |
|
| 38 | -if (isset($user->societe_id) && $user->societe_id > 0) |
|
| 37 | +$socid = GETPOST('socid', 'int'); |
|
| 38 | +if (isset($user->societe_id) && $user->societe_id > 0) |
|
| 39 | 39 | { |
| 40 | 40 | $action = ''; |
| 41 | 41 | $socid = $user->societe_id; |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | /* |
| 47 | 47 | * View |
| 48 | 48 | */ |
| 49 | -$now=dol_now(); |
|
| 50 | -$propalstatic=new Propal($db); |
|
| 51 | -$companystatic=new Societe($db); |
|
| 49 | +$now = dol_now(); |
|
| 50 | +$propalstatic = new Propal($db); |
|
| 51 | +$companystatic = new Societe($db); |
|
| 52 | 52 | $form = new Form($db); |
| 53 | 53 | $formfile = new FormFile($db); |
| 54 | -$help_url="EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos"; |
|
| 54 | +$help_url = "EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos"; |
|
| 55 | 55 | |
| 56 | -llxHeader("",$langs->trans("ProspectionArea"),$help_url); |
|
| 56 | +llxHeader("", $langs->trans("ProspectionArea"), $help_url); |
|
| 57 | 57 | |
| 58 | 58 | print load_fiche_titre($langs->trans("ProspectionArea")); |
| 59 | 59 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | print '<div class="fichecenter"><div class="fichethirdleft">'; |
| 63 | 63 | |
| 64 | 64 | |
| 65 | -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo |
|
| 65 | +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo |
|
| 66 | 66 | { |
| 67 | 67 | print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/list.php">'; |
| 68 | 68 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
@@ -79,25 +79,25 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | |
| 81 | 81 | $sql = "SELECT count(p.rowid), p.fk_statut"; |
| 82 | -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
| 83 | -$sql.= ", ".MAIN_DB_PREFIX."propal as p"; |
|
| 84 | -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 85 | -$sql.= " WHERE p.fk_soc = s.rowid"; |
|
| 86 | -$sql.= " AND p.entity IN (".getEntity('propal').")"; |
|
| 87 | -if ($user->societe_id) $sql.=' AND p.fk_soc = '.$user->societe_id; |
|
| 88 | -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 89 | -$sql.= " AND p.fk_statut IN (0,1,2,3,4)"; |
|
| 90 | -$sql.= " GROUP BY p.fk_statut"; |
|
| 82 | +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
| 83 | +$sql .= ", ".MAIN_DB_PREFIX."propal as p"; |
|
| 84 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 85 | +$sql .= " WHERE p.fk_soc = s.rowid"; |
|
| 86 | +$sql .= " AND p.entity IN (".getEntity('propal').")"; |
|
| 87 | +if ($user->societe_id) $sql .= ' AND p.fk_soc = '.$user->societe_id; |
|
| 88 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 89 | +$sql .= " AND p.fk_statut IN (0,1,2,3,4)"; |
|
| 90 | +$sql .= " GROUP BY p.fk_statut"; |
|
| 91 | 91 | $resql = $db->query($sql); |
| 92 | 92 | if ($resql) |
| 93 | 93 | { |
| 94 | 94 | $num = $db->num_rows($resql); |
| 95 | 95 | $i = 0; |
| 96 | 96 | |
| 97 | - $total=0; |
|
| 98 | - $totalinprocess=0; |
|
| 99 | - $dataseries=array(); |
|
| 100 | - $vals=array(); |
|
| 97 | + $total = 0; |
|
| 98 | + $totalinprocess = 0; |
|
| 99 | + $dataseries = array(); |
|
| 100 | + $vals = array(); |
|
| 101 | 101 | // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) |
| 102 | 102 | while ($i < $num) |
| 103 | 103 | { |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) |
| 108 | 108 | { |
| 109 | - $vals[$row[1]]=$row[0]; |
|
| 110 | - $totalinprocess+=$row[0]; |
|
| 109 | + $vals[$row[1]] = $row[0]; |
|
| 110 | + $totalinprocess += $row[0]; |
|
| 111 | 111 | } |
| 112 | - $total+=$row[0]; |
|
| 112 | + $total += $row[0]; |
|
| 113 | 113 | } |
| 114 | 114 | $i++; |
| 115 | 115 | } |
@@ -117,16 +117,16 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | print '<table class="noborder nohover" width="100%">'; |
| 119 | 119 | print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'</td></tr>'."\n"; |
| 120 | - $listofstatus=array(0,1,2,3,4); |
|
| 120 | + $listofstatus = array(0, 1, 2, 3, 4); |
|
| 121 | 121 | foreach ($listofstatus as $status) |
| 122 | 122 | { |
| 123 | - $dataseries[]=array($propalstatic->LibStatut($status,1), (isset($vals[$status])?(int) $vals[$status]:0)); |
|
| 124 | - if (! $conf->use_javascript_ajax) |
|
| 123 | + $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); |
|
| 124 | + if (!$conf->use_javascript_ajax) |
|
| 125 | 125 | { |
| 126 | 126 | |
| 127 | 127 | print '<tr class="oddeven">'; |
| 128 | - print '<td>'.$propalstatic->LibStatut($status,0).'</td>'; |
|
| 129 | - print '<td align="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status])?$vals[$status]:0).'</a></td>'; |
|
| 128 | + print '<td>'.$propalstatic->LibStatut($status, 0).'</td>'; |
|
| 129 | + print '<td align="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>'; |
|
| 130 | 130 | print "</tr>\n"; |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $dolgraph->SetType(array('pie')); |
| 143 | 143 | $dolgraph->setWidth('100%'); |
| 144 | 144 | $dolgraph->draw('idgraphthirdparties'); |
| 145 | - print $dolgraph->show($total?0:1); |
|
| 145 | + print $dolgraph->show($total ? 0 : 1); |
|
| 146 | 146 | |
| 147 | 147 | print '</td></tr>'; |
| 148 | 148 | } |
@@ -160,19 +160,19 @@ discard block |
||
| 160 | 160 | /* |
| 161 | 161 | * Draft proposals |
| 162 | 162 | */ |
| 163 | -if (! empty($conf->propal->enabled)) |
|
| 163 | +if (!empty($conf->propal->enabled)) |
|
| 164 | 164 | { |
| 165 | 165 | $sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client"; |
| 166 | - $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; |
|
| 167 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 168 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 169 | - $sql.= " WHERE c.fk_soc = s.rowid"; |
|
| 170 | - $sql.= " AND c.entity IN (".getEntity('propal').")"; |
|
| 171 | - $sql.= " AND c.fk_statut = 0"; |
|
| 172 | - if ($socid) $sql.= " AND c.fk_soc = ".$socid; |
|
| 173 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 174 | - |
|
| 175 | - $resql=$db->query($sql); |
|
| 166 | + $sql .= " FROM ".MAIN_DB_PREFIX."propal as c"; |
|
| 167 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 168 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 169 | + $sql .= " WHERE c.fk_soc = s.rowid"; |
|
| 170 | + $sql .= " AND c.entity IN (".getEntity('propal').")"; |
|
| 171 | + $sql .= " AND c.fk_statut = 0"; |
|
| 172 | + if ($socid) $sql .= " AND c.fk_soc = ".$socid; |
|
| 173 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 174 | + |
|
| 175 | + $resql = $db->query($sql); |
|
| 176 | 176 | if ($resql) |
| 177 | 177 | { |
| 178 | 178 | print '<div class="div-table-responsive-no-min">'; |
@@ -189,15 +189,15 @@ discard block |
||
| 189 | 189 | $obj = $db->fetch_object($resql); |
| 190 | 190 | print '<tr class="oddeven">'; |
| 191 | 191 | |
| 192 | - $propalstatic->id=$obj->rowid; |
|
| 193 | - $propalstatic->ref=$obj->ref; |
|
| 192 | + $propalstatic->id = $obj->rowid; |
|
| 193 | + $propalstatic->ref = $obj->ref; |
|
| 194 | 194 | print '<td class="nowrap">'.$propalstatic->getNomUrl(1).'</td>'; |
| 195 | 195 | |
| 196 | - $companystatic->id=$obj->socid; |
|
| 197 | - $companystatic->name=$obj->socname; |
|
| 198 | - $companystatic->client=$obj->client; |
|
| 199 | - $companystatic->canvas=$obj->canvas; |
|
| 200 | - print '<td>'.$companystatic->getNomUrl(1,'customer',24).'</td>'; |
|
| 196 | + $companystatic->id = $obj->socid; |
|
| 197 | + $companystatic->name = $obj->socname; |
|
| 198 | + $companystatic->client = $obj->client; |
|
| 199 | + $companystatic->canvas = $obj->canvas; |
|
| 200 | + print '<td>'.$companystatic->getNomUrl(1, 'customer', 24).'</td>'; |
|
| 201 | 201 | |
| 202 | 202 | print '</tr>'; |
| 203 | 203 | $i++; |
@@ -213,32 +213,32 @@ discard block |
||
| 213 | 213 | print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; |
| 214 | 214 | |
| 215 | 215 | |
| 216 | -$max=5; |
|
| 216 | +$max = 5; |
|
| 217 | 217 | |
| 218 | 218 | /* |
| 219 | 219 | * Last modified proposals |
| 220 | 220 | */ |
| 221 | 221 | |
| 222 | 222 | $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,"; |
| 223 | -$sql.= " date_cloture as datec"; |
|
| 224 | -$sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; |
|
| 225 | -$sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 226 | -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 227 | -$sql.= " WHERE c.fk_soc = s.rowid"; |
|
| 228 | -$sql.= " AND c.entity IN (".getEntity('propal').")"; |
|
| 223 | +$sql .= " date_cloture as datec"; |
|
| 224 | +$sql .= " FROM ".MAIN_DB_PREFIX."propal as c"; |
|
| 225 | +$sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 226 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 227 | +$sql .= " WHERE c.fk_soc = s.rowid"; |
|
| 228 | +$sql .= " AND c.entity IN (".getEntity('propal').")"; |
|
| 229 | 229 | //$sql.= " AND c.fk_statut > 2"; |
| 230 | 230 | if ($socid) $sql .= " AND c.fk_soc = ".$socid; |
| 231 | -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 232 | -$sql.= " ORDER BY c.tms DESC"; |
|
| 233 | -$sql.= $db->plimit($max, 0); |
|
| 231 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 232 | +$sql .= " ORDER BY c.tms DESC"; |
|
| 233 | +$sql .= $db->plimit($max, 0); |
|
| 234 | 234 | |
| 235 | -$resql=$db->query($sql); |
|
| 235 | +$resql = $db->query($sql); |
|
| 236 | 236 | if ($resql) |
| 237 | 237 | { |
| 238 | 238 | print '<div class="div-table-responsive-no-min">'; |
| 239 | 239 | print '<table class="noborder" width="100%">'; |
| 240 | 240 | print '<tr class="liste_titre">'; |
| 241 | - print '<td colspan="4">'.$langs->trans("LastModifiedProposals",$max).'</td></tr>'; |
|
| 241 | + print '<td colspan="4">'.$langs->trans("LastModifiedProposals", $max).'</td></tr>'; |
|
| 242 | 242 | |
| 243 | 243 | $num = $db->num_rows($resql); |
| 244 | 244 | if ($num) |
@@ -251,8 +251,8 @@ discard block |
||
| 251 | 251 | print '<tr class="oddeven">'; |
| 252 | 252 | print '<td width="20%" class="nowrap">'; |
| 253 | 253 | |
| 254 | - $propalstatic->id=$obj->rowid; |
|
| 255 | - $propalstatic->ref=$obj->ref; |
|
| 254 | + $propalstatic->id = $obj->rowid; |
|
| 255 | + $propalstatic->ref = $obj->ref; |
|
| 256 | 256 | |
| 257 | 257 | print '<table class="nobordernopadding"><tr class="nocellnopadd">'; |
| 258 | 258 | print '<td width="96" class="nobordernopadding nowrap">'; |
@@ -264,22 +264,22 @@ discard block |
||
| 264 | 264 | print '</td>'; |
| 265 | 265 | |
| 266 | 266 | print '<td width="16" align="right" class="nobordernopadding">'; |
| 267 | - $filename=dol_sanitizeFileName($obj->ref); |
|
| 268 | - $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); |
|
| 269 | - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; |
|
| 267 | + $filename = dol_sanitizeFileName($obj->ref); |
|
| 268 | + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); |
|
| 269 | + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; |
|
| 270 | 270 | print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); |
| 271 | 271 | print '</td></tr></table>'; |
| 272 | 272 | |
| 273 | 273 | print '</td>'; |
| 274 | 274 | |
| 275 | - $companystatic->id=$obj->socid; |
|
| 276 | - $companystatic->name=$obj->socname; |
|
| 277 | - $companystatic->client=$obj->client; |
|
| 278 | - $companystatic->canvas=$obj->canvas; |
|
| 279 | - print '<td>'.$companystatic->getNomUrl(1,'customer').'</td>'; |
|
| 275 | + $companystatic->id = $obj->socid; |
|
| 276 | + $companystatic->name = $obj->socname; |
|
| 277 | + $companystatic->client = $obj->client; |
|
| 278 | + $companystatic->canvas = $obj->canvas; |
|
| 279 | + print '<td>'.$companystatic->getNomUrl(1, 'customer').'</td>'; |
|
| 280 | 280 | |
| 281 | - print '<td>'.dol_print_date($db->jdate($obj->datec),'day').'</td>'; |
|
| 282 | - print '<td align="right">'.$propalstatic->LibStatut($obj->fk_statut,5).'</td>'; |
|
| 281 | + print '<td>'.dol_print_date($db->jdate($obj->datec), 'day').'</td>'; |
|
| 282 | + print '<td align="right">'.$propalstatic->LibStatut($obj->fk_statut, 5).'</td>'; |
|
| 283 | 283 | print '</tr>'; |
| 284 | 284 | $i++; |
| 285 | 285 | } |
@@ -293,25 +293,25 @@ discard block |
||
| 293 | 293 | /* |
| 294 | 294 | * Opened proposals |
| 295 | 295 | */ |
| 296 | -if (! empty($conf->propal->enabled) && $user->rights->propale->lire) |
|
| 296 | +if (!empty($conf->propal->enabled) && $user->rights->propale->lire) |
|
| 297 | 297 | { |
| 298 | 298 | $langs->load("propal"); |
| 299 | 299 | |
| 300 | - $now=dol_now(); |
|
| 300 | + $now = dol_now(); |
|
| 301 | 301 | |
| 302 | 302 | $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client"; |
| 303 | - $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; |
|
| 304 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
| 305 | - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; |
|
| 306 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 307 | - $sql.= " WHERE p.fk_soc = s.rowid"; |
|
| 308 | - $sql.= " AND p.entity IN (".getEntity('propal').")"; |
|
| 309 | - $sql.= " AND p.fk_statut = 1"; |
|
| 310 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 311 | - if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
| 312 | - $sql.= " ORDER BY p.rowid DESC"; |
|
| 313 | - |
|
| 314 | - $result=$db->query($sql); |
|
| 303 | + $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; |
|
| 304 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
| 305 | + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; |
|
| 306 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 307 | + $sql .= " WHERE p.fk_soc = s.rowid"; |
|
| 308 | + $sql .= " AND p.entity IN (".getEntity('propal').")"; |
|
| 309 | + $sql .= " AND p.fk_statut = 1"; |
|
| 310 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 311 | + if ($socid) $sql .= " AND s.rowid = ".$socid; |
|
| 312 | + $sql .= " ORDER BY p.rowid DESC"; |
|
| 313 | + |
|
| 314 | + $result = $db->query($sql); |
|
| 315 | 315 | if ($result) |
| 316 | 316 | { |
| 317 | 317 | $total = 0; |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | print '<table class="noborder" width="100%">'; |
| 324 | 324 | print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("ProposalsOpened").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=1"><span class="badge">'.$num.'</span></a></td></tr>'; |
| 325 | 325 | |
| 326 | - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); |
|
| 326 | + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); |
|
| 327 | 327 | while ($i < $nbofloop) |
| 328 | 328 | { |
| 329 | 329 | $obj = $db->fetch_object($result); |
@@ -333,8 +333,8 @@ discard block |
||
| 333 | 333 | // Ref |
| 334 | 334 | print '<td class="nowrap" width="140">'; |
| 335 | 335 | |
| 336 | - $propalstatic->id=$obj->propalid; |
|
| 337 | - $propalstatic->ref=$obj->ref; |
|
| 336 | + $propalstatic->id = $obj->propalid; |
|
| 337 | + $propalstatic->ref = $obj->ref; |
|
| 338 | 338 | |
| 339 | 339 | print '<table class="nobordernopadding"><tr class="nocellnopadd">'; |
| 340 | 340 | print '<td class="nobordernopadding nowrap">'; |
@@ -344,24 +344,24 @@ discard block |
||
| 344 | 344 | if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); |
| 345 | 345 | print '</td>'; |
| 346 | 346 | print '<td width="16" align="center" class="nobordernopadding">'; |
| 347 | - $filename=dol_sanitizeFileName($obj->ref); |
|
| 348 | - $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); |
|
| 349 | - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; |
|
| 347 | + $filename = dol_sanitizeFileName($obj->ref); |
|
| 348 | + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); |
|
| 349 | + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; |
|
| 350 | 350 | print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); |
| 351 | 351 | print '</td></tr></table>'; |
| 352 | 352 | |
| 353 | 353 | print "</td>"; |
| 354 | 354 | |
| 355 | - $companystatic->id=$obj->socid; |
|
| 356 | - $companystatic->name=$obj->socname; |
|
| 357 | - $companystatic->client=$obj->client; |
|
| 358 | - $companystatic->canvas=$obj->canvas; |
|
| 359 | - print '<td align="left">'.$companystatic->getNomUrl(1,'customer',44).'</td>'."\n"; |
|
| 355 | + $companystatic->id = $obj->socid; |
|
| 356 | + $companystatic->name = $obj->socname; |
|
| 357 | + $companystatic->client = $obj->client; |
|
| 358 | + $companystatic->canvas = $obj->canvas; |
|
| 359 | + print '<td align="left">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>'."\n"; |
|
| 360 | 360 | |
| 361 | 361 | print '<td align="right">'; |
| 362 | - print dol_print_date($db->jdate($obj->dp),'day').'</td>'."\n"; |
|
| 362 | + print dol_print_date($db->jdate($obj->dp), 'day').'</td>'."\n"; |
|
| 363 | 363 | print '<td align="right">'.price($obj->total_ttc).'</td>'; |
| 364 | - print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut,3).'</td>'."\n"; |
|
| 364 | + print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).'</td>'."\n"; |
|
| 365 | 365 | print '</tr>'."\n"; |
| 366 | 366 | $i++; |
| 367 | 367 | $total += $obj->total_ttc; |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | { |
| 371 | 371 | print '<tr class="liste_total"><td colspan="5">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>"; |
| 372 | 372 | } |
| 373 | - else if ($total>0) |
|
| 373 | + else if ($total > 0) |
|
| 374 | 374 | { |
| 375 | 375 | print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td> </td></tr>"; |
| 376 | 376 | } |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | $data = $stats->getAllByYear(); |
| 222 | 222 | $arrayyears=array(); |
| 223 | 223 | foreach($data as $val) { |
| 224 | - if (! empty($val['year'])) { |
|
| 225 | - $arrayyears[$val['year']]=$val['year']; |
|
| 226 | - } |
|
| 224 | + if (! empty($val['year'])) { |
|
| 225 | + $arrayyears[$val['year']]=$val['year']; |
|
| 226 | + } |
|
| 227 | 227 | } |
| 228 | 228 | if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; |
| 229 | 229 | |
@@ -245,35 +245,35 @@ discard block |
||
| 245 | 245 | |
| 246 | 246 | //if (empty($socid)) |
| 247 | 247 | //{ |
| 248 | - // Show filter box |
|
| 249 | - print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
| 250 | - print '<input type="hidden" name="mode" value="'.$mode.'">'; |
|
| 251 | - print '<table class="noborder" width="100%">'; |
|
| 252 | - print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>'; |
|
| 253 | - // Company |
|
| 254 | - print '<tr><td align="left">'.$langs->trans("ThirdParty").'</td><td align="left">'; |
|
| 255 | - $filter='s.client in (1,2,3)'; |
|
| 256 | - print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"'); |
|
| 257 | - print '</td></tr>'; |
|
| 258 | - // User |
|
| 259 | - print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">'; |
|
| 260 | - print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); |
|
| 261 | - print '</td></tr>'; |
|
| 262 | - // Status |
|
| 263 | - print '<tr><td align="left">'.$langs->trans("Status").'</td><td align="left">'; |
|
| 248 | + // Show filter box |
|
| 249 | + print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
| 250 | + print '<input type="hidden" name="mode" value="'.$mode.'">'; |
|
| 251 | + print '<table class="noborder" width="100%">'; |
|
| 252 | + print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>'; |
|
| 253 | + // Company |
|
| 254 | + print '<tr><td align="left">'.$langs->trans("ThirdParty").'</td><td align="left">'; |
|
| 255 | + $filter='s.client in (1,2,3)'; |
|
| 256 | + print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"'); |
|
| 257 | + print '</td></tr>'; |
|
| 258 | + // User |
|
| 259 | + print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">'; |
|
| 260 | + print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); |
|
| 261 | + print '</td></tr>'; |
|
| 262 | + // Status |
|
| 263 | + print '<tr><td align="left">'.$langs->trans("Status").'</td><td align="left">'; |
|
| 264 | 264 | $formpropal->selectProposalStatus(($object_status!=''?$object_status:-1),0,0,1,$mode,'object_status'); |
| 265 | - print '</td></tr>'; |
|
| 266 | - // Year |
|
| 267 | - print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">'; |
|
| 268 | - if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; |
|
| 269 | - if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear; |
|
| 270 | - arsort($arrayyears); |
|
| 271 | - print $form->selectarray('year',$arrayyears,$year,0); |
|
| 272 | - print '</td></tr>'; |
|
| 273 | - print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>'; |
|
| 274 | - print '</table>'; |
|
| 275 | - print '</form>'; |
|
| 276 | - print '<br><br>'; |
|
| 265 | + print '</td></tr>'; |
|
| 266 | + // Year |
|
| 267 | + print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">'; |
|
| 268 | + if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; |
|
| 269 | + if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear; |
|
| 270 | + arsort($arrayyears); |
|
| 271 | + print $form->selectarray('year',$arrayyears,$year,0); |
|
| 272 | + print '</td></tr>'; |
|
| 273 | + print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>'; |
|
| 274 | + print '</table>'; |
|
| 275 | + print '</form>'; |
|
| 276 | + print '<br><br>'; |
|
| 277 | 277 | //} |
| 278 | 278 | |
| 279 | 279 | print '<div class="div-table-responsive-no-min">'; |
@@ -309,11 +309,11 @@ discard block |
||
| 309 | 309 | print '<tr class="oddeven" height="24">'; |
| 310 | 310 | print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.($socid>0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$year.'</a></td>'; |
| 311 | 311 | print '<td align="right">'.$val['nb'].'</td>'; |
| 312 | - print '<td align="right" style="'.(($val['nb_diff'] >= 0) ? 'color: green;':'color: red;').'">'.round($val['nb_diff']).'</td>'; |
|
| 312 | + print '<td align="right" style="'.(($val['nb_diff'] >= 0) ? 'color: green;':'color: red;').'">'.round($val['nb_diff']).'</td>'; |
|
| 313 | 313 | print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>'; |
| 314 | - print '<td align="right" style="'.(($val['total_diff'] >= 0) ? 'color: green;':'color: red;').'">'.round($val['total_diff']).'</td>'; |
|
| 314 | + print '<td align="right" style="'.(($val['total_diff'] >= 0) ? 'color: green;':'color: red;').'">'.round($val['total_diff']).'</td>'; |
|
| 315 | 315 | print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>'; |
| 316 | - print '<td align="right" style="'.(($val['avg_diff'] >= 0) ? 'color: green;':'color: red;').'">'.round($val['avg_diff']).'</td>'; |
|
| 316 | + print '<td align="right" style="'.(($val['avg_diff'] >= 0) ? 'color: green;':'color: red;').'">'.round($val['avg_diff']).'</td>'; |
|
| 317 | 317 | print '</tr>'; |
| 318 | 318 | $oldyear=$year; |
| 319 | 319 | } |
@@ -34,8 +34,12 @@ discard block |
||
| 34 | 34 | $HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); |
| 35 | 35 | |
| 36 | 36 | $mode=GETPOST("mode")?GETPOST("mode"):'customer'; |
| 37 | -if ($mode == 'customer' && ! $user->rights->propale->lire) accessforbidden(); |
|
| 38 | -if ($mode == 'supplier' && ! $user->rights->supplier_proposal->lire) accessforbidden(); |
|
| 37 | +if ($mode == 'customer' && ! $user->rights->propale->lire) { |
|
| 38 | + accessforbidden(); |
|
| 39 | +} |
|
| 40 | +if ($mode == 'supplier' && ! $user->rights->supplier_proposal->lire) { |
|
| 41 | + accessforbidden(); |
|
| 42 | +} |
|
| 39 | 43 | |
| 40 | 44 | $object_status=GETPOST('object_status'); |
| 41 | 45 | |
@@ -87,7 +91,9 @@ discard block |
||
| 87 | 91 | |
| 88 | 92 | |
| 89 | 93 | $stats = new PropaleStats($db, $socid, ($userid>0?$userid:0), $mode); |
| 90 | -if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND p.fk_statut IN ('.$db->escape($object_status).')'; |
|
| 94 | +if ($object_status != '' && $object_status >= 0) { |
|
| 95 | + $stats->where .= ' AND p.fk_statut IN ('.$db->escape($object_status).')'; |
|
| 96 | +} |
|
| 91 | 97 | |
| 92 | 98 | // Build graphic number of object |
| 93 | 99 | $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear); |
@@ -98,8 +104,7 @@ discard block |
||
| 98 | 104 | { |
| 99 | 105 | $filenamenb = $dir.'/proposalsnbinyear-'.$user->id.'-'.$year.'.png'; |
| 100 | 106 | $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$user->id.'-'.$year.'.png'; |
| 101 | -} |
|
| 102 | -else |
|
| 107 | +} else |
|
| 103 | 108 | { |
| 104 | 109 | $filenamenb = $dir.'/proposalsnbinyear-'.$year.'.png'; |
| 105 | 110 | $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$year.'.png'; |
@@ -140,8 +145,7 @@ discard block |
||
| 140 | 145 | { |
| 141 | 146 | $filenameamount = $dir.'/proposalsamountinyear-'.$user->id.'-'.$year.'.png'; |
| 142 | 147 | $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$user->id.'-'.$year.'.png'; |
| 143 | -} |
|
| 144 | -else |
|
| 148 | +} else |
|
| 145 | 149 | { |
| 146 | 150 | $filenameamount = $dir.'/proposalsamountinyear-'.$year.'.png'; |
| 147 | 151 | $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$year.'.png'; |
@@ -180,15 +184,22 @@ discard block |
||
| 180 | 184 | if (!$user->rights->societe->client->voir || $user->societe_id) |
| 181 | 185 | { |
| 182 | 186 | $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; |
| 183 | - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; |
|
| 184 | - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; |
|
| 185 | -} |
|
| 186 | -else |
|
| 187 | + if ($mode == 'customer') { |
|
| 188 | + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; |
|
| 189 | + } |
|
| 190 | + if ($mode == 'supplier') { |
|
| 191 | + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; |
|
| 192 | + } |
|
| 193 | + } else |
|
| 187 | 194 | { |
| 188 | 195 | $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; |
| 189 | - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; |
|
| 190 | - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; |
|
| 191 | -} |
|
| 196 | + if ($mode == 'customer') { |
|
| 197 | + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; |
|
| 198 | + } |
|
| 199 | + if ($mode == 'supplier') { |
|
| 200 | + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; |
|
| 201 | + } |
|
| 202 | + } |
|
| 192 | 203 | |
| 193 | 204 | $px3 = new DolGraph(); |
| 194 | 205 | $mesg = $px3->isGraphKo(); |
@@ -225,7 +236,9 @@ discard block |
||
| 225 | 236 | $arrayyears[$val['year']]=$val['year']; |
| 226 | 237 | } |
| 227 | 238 | } |
| 228 | -if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; |
|
| 239 | +if (! count($arrayyears)) { |
|
| 240 | + $arrayyears[$nowyear]=$nowyear; |
|
| 241 | +} |
|
| 229 | 242 | |
| 230 | 243 | |
| 231 | 244 | $h=0; |
@@ -265,8 +278,12 @@ discard block |
||
| 265 | 278 | print '</td></tr>'; |
| 266 | 279 | // Year |
| 267 | 280 | print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">'; |
| 268 | - if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; |
|
| 269 | - if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear; |
|
| 281 | + if (! in_array($year,$arrayyears)) { |
|
| 282 | + $arrayyears[$year]=$year; |
|
| 283 | + } |
|
| 284 | + if (! in_array($nowyear,$arrayyears)) { |
|
| 285 | + $arrayyears[$nowyear]=$nowyear; |
|
| 286 | + } |
|
| 270 | 287 | arsort($arrayyears); |
| 271 | 288 | print $form->selectarray('year',$arrayyears,$year,0); |
| 272 | 289 | print '</td></tr>'; |
@@ -326,8 +343,7 @@ discard block |
||
| 326 | 343 | |
| 327 | 344 | // Show graphs |
| 328 | 345 | print '<table class="border" width="100%"><tr class="pair nohover"><td align="center">'; |
| 329 | -if ($mesg) { print $mesg; } |
|
| 330 | -else { |
|
| 346 | +if ($mesg) { print $mesg; } else { |
|
| 331 | 347 | print $px1->show(); |
| 332 | 348 | print "<br>\n"; |
| 333 | 349 | print $px2->show(); |
@@ -28,22 +28,22 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 30 | 30 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 31 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 31 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 32 | 32 | require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; |
| 33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; |
| 34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php'; |
| 35 | 35 | |
| 36 | -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); |
|
| 37 | -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); |
|
| 36 | +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); |
|
| 37 | +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); |
|
| 38 | 38 | |
| 39 | -$mode=GETPOST("mode")?GETPOST("mode"):'customer'; |
|
| 40 | -if ($mode == 'customer' && ! $user->rights->propale->lire) accessforbidden(); |
|
| 41 | -if ($mode == 'supplier' && ! $user->rights->supplier_proposal->lire) accessforbidden(); |
|
| 39 | +$mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; |
|
| 40 | +if ($mode == 'customer' && !$user->rights->propale->lire) accessforbidden(); |
|
| 41 | +if ($mode == 'supplier' && !$user->rights->supplier_proposal->lire) accessforbidden(); |
|
| 42 | 42 | |
| 43 | -$object_status=GETPOST('object_status'); |
|
| 43 | +$object_status = GETPOST('object_status'); |
|
| 44 | 44 | |
| 45 | -$userid=GETPOST('userid','int'); |
|
| 46 | -$socid=GETPOST('socid','int'); |
|
| 45 | +$userid = GETPOST('userid', 'int'); |
|
| 46 | +$socid = GETPOST('socid', 'int'); |
|
| 47 | 47 | // Security check |
| 48 | 48 | if ($user->societe_id > 0) |
| 49 | 49 | { |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | $socid = $user->societe_id; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | -$nowyear=strftime("%Y", dol_now()); |
|
| 55 | -$year = GETPOST('year')>0?GETPOST('year'):$nowyear; |
|
| 54 | +$nowyear = strftime("%Y", dol_now()); |
|
| 55 | +$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; |
|
| 56 | 56 | //$startyear=$year-2; |
| 57 | -$startyear=$year-1; |
|
| 58 | -$endyear=$year; |
|
| 57 | +$startyear = $year - 1; |
|
| 58 | +$endyear = $year; |
|
| 59 | 59 | |
| 60 | 60 | // Load translation files required by the page |
| 61 | 61 | $langs->loadLangs(array('orders', 'companies', 'other', 'suppliers', 'supplier_proposal')); |
@@ -65,35 +65,35 @@ discard block |
||
| 65 | 65 | * View |
| 66 | 66 | */ |
| 67 | 67 | |
| 68 | -$form=new Form($db); |
|
| 69 | -$formpropal=new FormPropal($db); |
|
| 68 | +$form = new Form($db); |
|
| 69 | +$formpropal = new FormPropal($db); |
|
| 70 | 70 | |
| 71 | 71 | $langs->loadLangs(array('propal', 'other', 'companies')); |
| 72 | 72 | |
| 73 | 73 | if ($mode == 'customer') |
| 74 | 74 | { |
| 75 | - $title=$langs->trans("ProposalsStatistics"); |
|
| 76 | - $dir=$conf->propale->dir_temp; |
|
| 75 | + $title = $langs->trans("ProposalsStatistics"); |
|
| 76 | + $dir = $conf->propale->dir_temp; |
|
| 77 | 77 | } |
| 78 | 78 | if ($mode == 'supplier') |
| 79 | 79 | { |
| 80 | - $title=$langs->trans("ProposalsStatisticsSuppliers").' ('.$langs->trans("SentToSuppliers").")"; |
|
| 81 | - $dir=$conf->supplier_proposal->dir_temp; |
|
| 80 | + $title = $langs->trans("ProposalsStatisticsSuppliers").' ('.$langs->trans("SentToSuppliers").")"; |
|
| 81 | + $dir = $conf->supplier_proposal->dir_temp; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | llxHeader('', $title); |
| 85 | 85 | |
| 86 | -print load_fiche_titre($title,'','title_commercial.png'); |
|
| 86 | +print load_fiche_titre($title, '', 'title_commercial.png'); |
|
| 87 | 87 | |
| 88 | 88 | |
| 89 | 89 | dol_mkdir($dir); |
| 90 | 90 | |
| 91 | 91 | |
| 92 | -$stats = new PropaleStats($db, $socid, ($userid>0?$userid:0), $mode); |
|
| 92 | +$stats = new PropaleStats($db, $socid, ($userid > 0 ? $userid : 0), $mode); |
|
| 93 | 93 | if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND p.fk_statut IN ('.$db->escape($object_status).')'; |
| 94 | 94 | |
| 95 | 95 | // Build graphic number of object |
| 96 | -$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear); |
|
| 96 | +$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); |
|
| 97 | 97 | // $data = array(array('Lib',val1,val2,val3),...) |
| 98 | 98 | |
| 99 | 99 | |
@@ -110,33 +110,33 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | $px1 = new DolGraph(); |
| 112 | 112 | $mesg = $px1->isGraphKo(); |
| 113 | -if (! $mesg) |
|
| 113 | +if (!$mesg) |
|
| 114 | 114 | { |
| 115 | 115 | $px1->SetData($data); |
| 116 | 116 | $px1->SetPrecisionY(0); |
| 117 | - $i=$startyear;$legend=array(); |
|
| 117 | + $i = $startyear; $legend = array(); |
|
| 118 | 118 | while ($i <= $endyear) |
| 119 | 119 | { |
| 120 | - $legend[]=$i; |
|
| 120 | + $legend[] = $i; |
|
| 121 | 121 | $i++; |
| 122 | 122 | } |
| 123 | 123 | $px1->SetLegend($legend); |
| 124 | 124 | $px1->SetMaxValue($px1->GetCeilMaxValue()); |
| 125 | - $px1->SetMinValue(min(0,$px1->GetFloorMinValue())); |
|
| 125 | + $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); |
|
| 126 | 126 | $px1->SetWidth($WIDTH); |
| 127 | 127 | $px1->SetHeight($HEIGHT); |
| 128 | 128 | $px1->SetYLabel($langs->trans("NbOfProposals")); |
| 129 | 129 | $px1->SetShading(3); |
| 130 | 130 | $px1->SetHorizTickIncrement(1); |
| 131 | 131 | $px1->SetPrecisionY(0); |
| 132 | - $px1->mode='depth'; |
|
| 132 | + $px1->mode = 'depth'; |
|
| 133 | 133 | $px1->SetTitle($langs->trans("NumberOfProposalsByMonth")); |
| 134 | 134 | |
| 135 | - $px1->draw($filenamenb,$fileurlnb); |
|
| 135 | + $px1->draw($filenamenb, $fileurlnb); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Build graphic amount of object |
| 139 | -$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear,0); |
|
| 139 | +$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, 0); |
|
| 140 | 140 | // $data = array(array('Lib',val1,val2,val3),...) |
| 141 | 141 | |
| 142 | 142 | if (!$user->rights->societe->client->voir || $user->societe_id) |
@@ -152,34 +152,34 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | $px2 = new DolGraph(); |
| 154 | 154 | $mesg = $px2->isGraphKo(); |
| 155 | -if (! $mesg) |
|
| 155 | +if (!$mesg) |
|
| 156 | 156 | { |
| 157 | 157 | $px2->SetData($data); |
| 158 | 158 | $px2->SetPrecisionY(0); |
| 159 | - $i=$startyear;$legend=array(); |
|
| 159 | + $i = $startyear; $legend = array(); |
|
| 160 | 160 | while ($i <= $endyear) |
| 161 | 161 | { |
| 162 | - $legend[]=$i; |
|
| 162 | + $legend[] = $i; |
|
| 163 | 163 | $i++; |
| 164 | 164 | } |
| 165 | 165 | $px2->SetLegend($legend); |
| 166 | 166 | $px2->SetMaxValue($px2->GetCeilMaxValue()); |
| 167 | - $px2->SetMinValue(min(0,$px2->GetFloorMinValue())); |
|
| 167 | + $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); |
|
| 168 | 168 | $px2->SetWidth($WIDTH); |
| 169 | 169 | $px2->SetHeight($HEIGHT); |
| 170 | 170 | $px2->SetYLabel($langs->trans("AmountOfProposals")); |
| 171 | 171 | $px2->SetShading(3); |
| 172 | 172 | $px2->SetHorizTickIncrement(1); |
| 173 | 173 | $px2->SetPrecisionY(0); |
| 174 | - $px2->mode='depth'; |
|
| 174 | + $px2->mode = 'depth'; |
|
| 175 | 175 | $px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT")); |
| 176 | 176 | |
| 177 | - $px2->draw($filenameamount,$fileurlamount); |
|
| 177 | + $px2->draw($filenameamount, $fileurlamount); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); |
| 181 | 181 | |
| 182 | -$fileurl_avg=''; |
|
| 182 | +$fileurl_avg = ''; |
|
| 183 | 183 | if (!$user->rights->societe->client->voir || $user->societe_id) |
| 184 | 184 | { |
| 185 | 185 | $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; |
@@ -195,13 +195,13 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | $px3 = new DolGraph(); |
| 197 | 197 | $mesg = $px3->isGraphKo(); |
| 198 | -if (! $mesg) |
|
| 198 | +if (!$mesg) |
|
| 199 | 199 | { |
| 200 | 200 | $px3->SetData($data); |
| 201 | - $i=$startyear;$legend=array(); |
|
| 201 | + $i = $startyear; $legend = array(); |
|
| 202 | 202 | while ($i <= $endyear) |
| 203 | 203 | { |
| 204 | - $legend[]=$i; |
|
| 204 | + $legend[] = $i; |
|
| 205 | 205 | $i++; |
| 206 | 206 | } |
| 207 | 207 | $px3->SetLegend($legend); |
@@ -213,32 +213,32 @@ discard block |
||
| 213 | 213 | $px3->SetShading(3); |
| 214 | 214 | $px3->SetHorizTickIncrement(1); |
| 215 | 215 | $px3->SetPrecisionY(0); |
| 216 | - $px3->mode='depth'; |
|
| 216 | + $px3->mode = 'depth'; |
|
| 217 | 217 | $px3->SetTitle($langs->trans("AmountAverage")); |
| 218 | 218 | |
| 219 | - $px3->draw($filename_avg,$fileurl_avg); |
|
| 219 | + $px3->draw($filename_avg, $fileurl_avg); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | |
| 223 | 223 | // Show array |
| 224 | 224 | $data = $stats->getAllByYear(); |
| 225 | -$arrayyears=array(); |
|
| 226 | -foreach($data as $val) { |
|
| 227 | - if (! empty($val['year'])) { |
|
| 228 | - $arrayyears[$val['year']]=$val['year']; |
|
| 225 | +$arrayyears = array(); |
|
| 226 | +foreach ($data as $val) { |
|
| 227 | + if (!empty($val['year'])) { |
|
| 228 | + $arrayyears[$val['year']] = $val['year']; |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | -if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; |
|
| 231 | +if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; |
|
| 232 | 232 | |
| 233 | 233 | |
| 234 | -$h=0; |
|
| 234 | +$h = 0; |
|
| 235 | 235 | $head = array(); |
| 236 | -$head[$h][0] = DOL_URL_ROOT . '/comm/propal/stats/index.php'; |
|
| 236 | +$head[$h][0] = DOL_URL_ROOT.'/comm/propal/stats/index.php'; |
|
| 237 | 237 | $head[$h][1] = $langs->trans("ByMonthYear"); |
| 238 | 238 | $head[$h][2] = 'byyear'; |
| 239 | 239 | $h++; |
| 240 | 240 | |
| 241 | -complete_head_from_modules($conf,$langs,null,$head,$h,'propal_stats'); |
|
| 241 | +complete_head_from_modules($conf, $langs, null, $head, $h, 'propal_stats'); |
|
| 242 | 242 | |
| 243 | 243 | dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); |
| 244 | 244 | |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>'; |
| 256 | 256 | // Company |
| 257 | 257 | print '<tr><td align="left">'.$langs->trans("ThirdParty").'</td><td align="left">'; |
| 258 | - $filter='s.client in (1,2,3)'; |
|
| 259 | - print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"'); |
|
| 258 | + $filter = 's.client in (1,2,3)'; |
|
| 259 | + print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, '', 'style="width: 95%"'); |
|
| 260 | 260 | print '</td></tr>'; |
| 261 | 261 | // User |
| 262 | 262 | print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">'; |
@@ -264,14 +264,14 @@ discard block |
||
| 264 | 264 | print '</td></tr>'; |
| 265 | 265 | // Status |
| 266 | 266 | print '<tr><td align="left">'.$langs->trans("Status").'</td><td align="left">'; |
| 267 | - $formpropal->selectProposalStatus(($object_status!=''?$object_status:-1),0,0,1,$mode,'object_status'); |
|
| 267 | + $formpropal->selectProposalStatus(($object_status != '' ? $object_status : -1), 0, 0, 1, $mode, 'object_status'); |
|
| 268 | 268 | print '</td></tr>'; |
| 269 | 269 | // Year |
| 270 | 270 | print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">'; |
| 271 | - if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; |
|
| 272 | - if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear; |
|
| 271 | + if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; |
|
| 272 | + if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; |
|
| 273 | 273 | arsort($arrayyears); |
| 274 | - print $form->selectarray('year',$arrayyears,$year,0); |
|
| 274 | + print $form->selectarray('year', $arrayyears, $year, 0); |
|
| 275 | 275 | print '</td></tr>'; |
| 276 | 276 | print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>'; |
| 277 | 277 | print '</table>'; |
@@ -291,16 +291,16 @@ discard block |
||
| 291 | 291 | print '<td align="right">%</td>'; |
| 292 | 292 | print '</tr>'; |
| 293 | 293 | |
| 294 | -$oldyear=0; |
|
| 294 | +$oldyear = 0; |
|
| 295 | 295 | foreach ($data as $val) |
| 296 | 296 | { |
| 297 | 297 | $year = $val['year']; |
| 298 | - while (! empty($year) && $oldyear > $year+1) |
|
| 298 | + while (!empty($year) && $oldyear > $year + 1) |
|
| 299 | 299 | { // If we have empty year |
| 300 | 300 | $oldyear--; |
| 301 | 301 | |
| 302 | 302 | print '<tr class="oddeven" height="24">'; |
| 303 | - print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'&mode='.$mode.($socid>0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$oldyear.'</a></td>'; |
|
| 303 | + print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'&mode='.$mode.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$oldyear.'</a></td>'; |
|
| 304 | 304 | print '<td align="right">0</td>'; |
| 305 | 305 | print '<td align="right"></td>'; |
| 306 | 306 | print '<td align="right">0</td>'; |
@@ -310,15 +310,15 @@ discard block |
||
| 310 | 310 | print '</tr>'; |
| 311 | 311 | } |
| 312 | 312 | print '<tr class="oddeven" height="24">'; |
| 313 | - print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.($socid>0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$year.'</a></td>'; |
|
| 313 | + print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$year.'</a></td>'; |
|
| 314 | 314 | print '<td align="right">'.$val['nb'].'</td>'; |
| 315 | - print '<td align="right" style="'.(($val['nb_diff'] >= 0) ? 'color: green;':'color: red;').'">'.round($val['nb_diff']).'</td>'; |
|
| 316 | - print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>'; |
|
| 317 | - print '<td align="right" style="'.(($val['total_diff'] >= 0) ? 'color: green;':'color: red;').'">'.round($val['total_diff']).'</td>'; |
|
| 318 | - print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>'; |
|
| 319 | - print '<td align="right" style="'.(($val['avg_diff'] >= 0) ? 'color: green;':'color: red;').'">'.round($val['avg_diff']).'</td>'; |
|
| 315 | + print '<td align="right" style="'.(($val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['nb_diff']).'</td>'; |
|
| 316 | + print '<td align="right">'.price(price2num($val['total'], 'MT'), 1).'</td>'; |
|
| 317 | + print '<td align="right" style="'.(($val['total_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['total_diff']).'</td>'; |
|
| 318 | + print '<td align="right">'.price(price2num($val['avg'], 'MT'), 1).'</td>'; |
|
| 319 | + print '<td align="right" style="'.(($val['avg_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['avg_diff']).'</td>'; |
|
| 320 | 320 | print '</tr>'; |
| 321 | - $oldyear=$year; |
|
| 321 | + $oldyear = $year; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | print '</table>'; |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | if ($type == "c" || $type == "p") |
| 61 | 61 | { |
| 62 | - $label = $langs->trans("Customers"); |
|
| 63 | - $urlfiche="card.php"; |
|
| 62 | + $label = $langs->trans("Customers"); |
|
| 63 | + $urlfiche="card.php"; |
|
| 64 | 64 | } |
| 65 | 65 | if ($type == "f") |
| 66 | 66 | { |
| 67 | - $label = $langs->trans("Suppliers"); |
|
| 68 | - $urlfiche="card.php"; |
|
| 67 | + $label = $langs->trans("Suppliers"); |
|
| 68 | + $urlfiche="card.php"; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /* |
@@ -88,29 +88,29 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | if (dol_strlen($stcomm)) |
| 90 | 90 | { |
| 91 | - $sql.= " AND s.fk_stcomm=".$db->escape($stcomm); |
|
| 91 | + $sql.= " AND s.fk_stcomm=".$db->escape($stcomm); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | if (! empty($search_lastname)) |
| 95 | 95 | { |
| 96 | - $sql.= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; |
|
| 96 | + $sql.= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | if (! empty($search_firstname)) |
| 100 | 100 | { |
| 101 | - $sql.= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; |
|
| 101 | + $sql.= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | if (! empty($search_company)) |
| 105 | 105 | { |
| 106 | - $sql.= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; |
|
| 106 | + $sql.= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | if (! empty($contactname)) // acces a partir du module de recherche |
| 110 | 110 | { |
| 111 | - $sql.= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; |
|
| 112 | - $sortfield = "p.name"; |
|
| 113 | - $sortorder = "ASC"; |
|
| 111 | + $sql.= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; |
|
| 112 | + $sortfield = "p.name"; |
|
| 113 | + $sortorder = "ASC"; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $sql.= $db->order($sortfield,$sortorder); |
@@ -119,57 +119,57 @@ discard block |
||
| 119 | 119 | $resql = $db->query($sql); |
| 120 | 120 | if ($resql) |
| 121 | 121 | { |
| 122 | - $num = $db->num_rows($resql); |
|
| 122 | + $num = $db->num_rows($resql); |
|
| 123 | 123 | |
| 124 | - $param="&type=".$type; |
|
| 124 | + $param="&type=".$type; |
|
| 125 | 125 | |
| 126 | - $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); |
|
| 127 | - print_barre_liste($title.($label?" (".$label.")":""),$page, $_SERVER["PHP_SELF"], $param,$sortfield,$sortorder,"",$num); |
|
| 126 | + $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); |
|
| 127 | + print_barre_liste($title.($label?" (".$label.")":""),$page, $_SERVER["PHP_SELF"], $param,$sortfield,$sortorder,"",$num); |
|
| 128 | 128 | |
| 129 | - print '<form action="'.$_SERVER["PHP_SELF"].'?type='.GETPOST("type", "alpha").'" method="GET">'; |
|
| 129 | + print '<form action="'.$_SERVER["PHP_SELF"].'?type='.GETPOST("type", "alpha").'" method="GET">'; |
|
| 130 | 130 | |
| 131 | - print '<table class="liste" width="100%">'; |
|
| 132 | - print '<tr class="liste_titre">'; |
|
| 133 | - print_liste_field_titre("Lastname",$_SERVER["PHP_SELF"],"p.name", $begin, $param,"",$sortfield,$sortorder); |
|
| 134 | - print_liste_field_titre("Firstname",$_SERVER["PHP_SELF"],"p.firstname", $begin, $param,"",$sortfield,$sortorder); |
|
| 135 | - print_liste_field_titre("Company",$_SERVER["PHP_SELF"],"s.nom", $begin, $param,"",$sortfield,$sortorder); |
|
| 136 | - print_liste_field_titre("Email"); |
|
| 137 | - print_liste_field_titre("Phone"); |
|
| 138 | - print "</tr>\n"; |
|
| 131 | + print '<table class="liste" width="100%">'; |
|
| 132 | + print '<tr class="liste_titre">'; |
|
| 133 | + print_liste_field_titre("Lastname",$_SERVER["PHP_SELF"],"p.name", $begin, $param,"",$sortfield,$sortorder); |
|
| 134 | + print_liste_field_titre("Firstname",$_SERVER["PHP_SELF"],"p.firstname", $begin, $param,"",$sortfield,$sortorder); |
|
| 135 | + print_liste_field_titre("Company",$_SERVER["PHP_SELF"],"s.nom", $begin, $param,"",$sortfield,$sortorder); |
|
| 136 | + print_liste_field_titre("Email"); |
|
| 137 | + print_liste_field_titre("Phone"); |
|
| 138 | + print "</tr>\n"; |
|
| 139 | 139 | |
| 140 | - print '<tr class="liste_titre">'; |
|
| 141 | - print '<td class="liste_titre"><input class="flat" name="search_lastname" size="12" value="'.$search_lastname.'"></td>'; |
|
| 142 | - print '<td class="liste_titre"><input class="flat" name="search_firstname" size="12" value="'.$search_firstname.'"></td>'; |
|
| 143 | - print '<td class="liste_titre"><input class="flat" name="search_company" size="12" value="'.$search_company.'"></td>'; |
|
| 144 | - print '<td class="liste_titre"> </td>'; |
|
| 145 | - print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>'; |
|
| 146 | - print "</tr>\n"; |
|
| 140 | + print '<tr class="liste_titre">'; |
|
| 141 | + print '<td class="liste_titre"><input class="flat" name="search_lastname" size="12" value="'.$search_lastname.'"></td>'; |
|
| 142 | + print '<td class="liste_titre"><input class="flat" name="search_firstname" size="12" value="'.$search_firstname.'"></td>'; |
|
| 143 | + print '<td class="liste_titre"><input class="flat" name="search_company" size="12" value="'.$search_company.'"></td>'; |
|
| 144 | + print '<td class="liste_titre"> </td>'; |
|
| 145 | + print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>'; |
|
| 146 | + print "</tr>\n"; |
|
| 147 | 147 | |
| 148 | - $i = 0; |
|
| 149 | - while ($i < min($num,$limit)) |
|
| 150 | - { |
|
| 151 | - $obj = $db->fetch_object($resql); |
|
| 148 | + $i = 0; |
|
| 149 | + while ($i < min($num,$limit)) |
|
| 150 | + { |
|
| 151 | + $obj = $db->fetch_object($resql); |
|
| 152 | 152 | |
| 153 | - print '<tr class="oddeven">'; |
|
| 154 | - print '<td><a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$obj->cidp.'&socid='.$obj->rowid.'">'.img_object($langs->trans("ShowContact"),"contact"); |
|
| 155 | - print '</a> <a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$obj->cidp.'&socid='.$obj->rowid.'">'.$obj->name.'</a></td>'; |
|
| 156 | - print "<td>$obj->firstname</TD>"; |
|
| 153 | + print '<tr class="oddeven">'; |
|
| 154 | + print '<td><a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$obj->cidp.'&socid='.$obj->rowid.'">'.img_object($langs->trans("ShowContact"),"contact"); |
|
| 155 | + print '</a> <a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$obj->cidp.'&socid='.$obj->rowid.'">'.$obj->name.'</a></td>'; |
|
| 156 | + print "<td>$obj->firstname</TD>"; |
|
| 157 | 157 | |
| 158 | - print '<td><a href="'.$_SERVER["PHP_SELF"].'?type='.$type.'&socid='.$obj->rowid.'">'.img_object($langs->trans("ShowCompany"),"company").'</a> '; |
|
| 159 | - print "<a href=\"".$urlfiche."?socid=".$obj->rowid."\">$obj->name</a></td>\n"; |
|
| 158 | + print '<td><a href="'.$_SERVER["PHP_SELF"].'?type='.$type.'&socid='.$obj->rowid.'">'.img_object($langs->trans("ShowCompany"),"company").'</a> '; |
|
| 159 | + print "<a href=\"".$urlfiche."?socid=".$obj->rowid."\">$obj->name</a></td>\n"; |
|
| 160 | 160 | |
| 161 | - print '<td>'.dol_print_phone($obj->email,$obj->cidp,$obj->rowid,'AC_EMAIL').'</td>'; |
|
| 161 | + print '<td>'.dol_print_phone($obj->email,$obj->cidp,$obj->rowid,'AC_EMAIL').'</td>'; |
|
| 162 | 162 | |
| 163 | - print '<td>'.dol_print_phone($obj->phone,$obj->country_code,$obj->cidp,$obj->rowid,'AC_TEL').' </td>'; |
|
| 163 | + print '<td>'.dol_print_phone($obj->phone,$obj->country_code,$obj->cidp,$obj->rowid,'AC_TEL').' </td>'; |
|
| 164 | 164 | |
| 165 | - print "</tr>\n"; |
|
| 166 | - $i++; |
|
| 167 | - } |
|
| 168 | - print "</table>"; |
|
| 165 | + print "</tr>\n"; |
|
| 166 | + $i++; |
|
| 167 | + } |
|
| 168 | + print "</table>"; |
|
| 169 | 169 | |
| 170 | - print '</form>'; |
|
| 170 | + print '</form>'; |
|
| 171 | 171 | |
| 172 | - $db->free($resql); |
|
| 172 | + $db->free($resql); |
|
| 173 | 173 | } |
| 174 | 174 | else |
| 175 | 175 | { |
@@ -32,8 +32,12 @@ discard block |
||
| 32 | 32 | $sortfield=GETPOST('sortfield', 'alpha'); |
| 33 | 33 | $sortorder=GETPOST('sortorder', 'alpha'); |
| 34 | 34 | $page=GETPOST('page', 'int'); |
| 35 | -if (! $sortorder) $sortorder="ASC"; |
|
| 36 | -if (! $sortfield) $sortfield="p.name"; |
|
| 35 | +if (! $sortorder) { |
|
| 36 | + $sortorder="ASC"; |
|
| 37 | +} |
|
| 38 | +if (! $sortfield) { |
|
| 39 | + $sortfield="p.name"; |
|
| 40 | +} |
|
| 37 | 41 | if ($page < 0) { $page = 0; } |
| 38 | 42 | $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
| 39 | 43 | $offset = $limit * $page ; |
@@ -47,7 +51,9 @@ discard block |
||
| 47 | 51 | |
| 48 | 52 | // Security check |
| 49 | 53 | $socid = GETPOST('socid','int'); |
| 50 | -if ($user->societe_id) $socid=$user->societe_id; |
|
| 54 | +if ($user->societe_id) { |
|
| 55 | + $socid=$user->societe_id; |
|
| 56 | +} |
|
| 51 | 57 | $result = restrictedArea($user, 'societe',$socid,''); |
| 52 | 58 | |
| 53 | 59 | |
@@ -75,16 +81,28 @@ discard block |
||
| 75 | 81 | $sql = "SELECT s.rowid, s.nom as name, st.libelle as stcomm"; |
| 76 | 82 | $sql.= ", p.rowid as cidp, p.name, p.firstname, p.email, p.phone"; |
| 77 | 83 | $sql.= " FROM ".MAIN_DB_PREFIX."c_stcomm as st,"; |
| 78 | -if (! $user->rights->societe->client->voir && ! $socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; |
|
| 84 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
| 85 | + $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; |
|
| 86 | +} |
|
| 79 | 87 | $sql.= " ".MAIN_DB_PREFIX."socpeople as p"; |
| 80 | 88 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; |
| 81 | 89 | $sql.= " WHERE s.fk_stcomm = st.id"; |
| 82 | 90 | $sql.= " AND p.entity IN (".getEntity('socpeople').")"; |
| 83 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 84 | -if ($type == "c") $sql.= " AND s.client IN (1, 3)"; |
|
| 85 | -if ($type == "p") $sql.= " AND s.client IN (2, 3)"; |
|
| 86 | -if ($type == "f") $sql.= " AND s.fournisseur = 1"; |
|
| 87 | -if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
| 91 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
| 92 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 93 | +} |
|
| 94 | +if ($type == "c") { |
|
| 95 | + $sql.= " AND s.client IN (1, 3)"; |
|
| 96 | +} |
|
| 97 | +if ($type == "p") { |
|
| 98 | + $sql.= " AND s.client IN (2, 3)"; |
|
| 99 | +} |
|
| 100 | +if ($type == "f") { |
|
| 101 | + $sql.= " AND s.fournisseur = 1"; |
|
| 102 | +} |
|
| 103 | +if ($socid) { |
|
| 104 | + $sql.= " AND s.rowid = ".$socid; |
|
| 105 | +} |
|
| 88 | 106 | |
| 89 | 107 | if (dol_strlen($stcomm)) |
| 90 | 108 | { |
@@ -106,9 +124,11 @@ discard block |
||
| 106 | 124 | $sql.= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; |
| 107 | 125 | } |
| 108 | 126 | |
| 109 | -if (! empty($contactname)) // acces a partir du module de recherche |
|
| 127 | +if (! empty($contactname)) { |
|
| 128 | + // acces a partir du module de recherche |
|
| 110 | 129 | { |
| 111 | 130 | $sql.= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; |
| 131 | +} |
|
| 112 | 132 | $sortfield = "p.name"; |
| 113 | 133 | $sortorder = "ASC"; |
| 114 | 134 | } |
@@ -170,8 +190,7 @@ discard block |
||
| 170 | 190 | print '</form>'; |
| 171 | 191 | |
| 172 | 192 | $db->free($resql); |
| 173 | -} |
|
| 174 | -else |
|
| 193 | +} else |
|
| 175 | 194 | { |
| 176 | 195 | dol_print_error($db); |
| 177 | 196 | } |
@@ -27,49 +27,49 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 29 | 29 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 30 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 30 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | // Load translation files required by the page |
| 34 | 34 | $langs->load("companies"); |
| 35 | 35 | |
| 36 | -$sortfield=GETPOST('sortfield', 'alpha'); |
|
| 37 | -$sortorder=GETPOST('sortorder', 'alpha'); |
|
| 38 | -$page=GETPOST('page', 'int'); |
|
| 39 | -if (! $sortorder) $sortorder="ASC"; |
|
| 40 | -if (! $sortfield) $sortfield="p.name"; |
|
| 36 | +$sortfield = GETPOST('sortfield', 'alpha'); |
|
| 37 | +$sortorder = GETPOST('sortorder', 'alpha'); |
|
| 38 | +$page = GETPOST('page', 'int'); |
|
| 39 | +if (!$sortorder) $sortorder = "ASC"; |
|
| 40 | +if (!$sortfield) $sortfield = "p.name"; |
|
| 41 | 41 | if ($page < 0) { $page = 0; } |
| 42 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
| 43 | -$offset = $limit * $page ; |
|
| 42 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
| 43 | +$offset = $limit * $page; |
|
| 44 | 44 | |
| 45 | -$type=GETPOST('type', 'alpha'); |
|
| 46 | -$search_lastname=GETPOST('search_nom')?GETPOST('search_nom'):GETPOST('search_lastname'); // For backward compatibility |
|
| 47 | -$search_firstname=GETPOST('search_firstname')?GETPOST('search_firstname'):GETPOST('search_firstname'); // For backward compatibility |
|
| 48 | -$search_company=GETPOST('search_societe')?GETPOST('search_societe'):GETPOST('search_company'); // For backward compatibility |
|
| 49 | -$contactname=GETPOST('contactname'); |
|
| 50 | -$begin=GETPOST('begin','alpha'); |
|
| 45 | +$type = GETPOST('type', 'alpha'); |
|
| 46 | +$search_lastname = GETPOST('search_nom') ?GETPOST('search_nom') : GETPOST('search_lastname'); // For backward compatibility |
|
| 47 | +$search_firstname = GETPOST('search_firstname') ?GETPOST('search_firstname') : GETPOST('search_firstname'); // For backward compatibility |
|
| 48 | +$search_company = GETPOST('search_societe') ?GETPOST('search_societe') : GETPOST('search_company'); // For backward compatibility |
|
| 49 | +$contactname = GETPOST('contactname'); |
|
| 50 | +$begin = GETPOST('begin', 'alpha'); |
|
| 51 | 51 | |
| 52 | 52 | // Security check |
| 53 | -$socid = GETPOST('socid','int'); |
|
| 54 | -if ($user->societe_id) $socid=$user->societe_id; |
|
| 55 | -$result = restrictedArea($user, 'societe',$socid,''); |
|
| 53 | +$socid = GETPOST('socid', 'int'); |
|
| 54 | +if ($user->societe_id) $socid = $user->societe_id; |
|
| 55 | +$result = restrictedArea($user, 'societe', $socid, ''); |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | /* |
| 59 | 59 | * View |
| 60 | 60 | */ |
| 61 | 61 | |
| 62 | -llxHeader('',$langs->trans("Contacts")); |
|
| 62 | +llxHeader('', $langs->trans("Contacts")); |
|
| 63 | 63 | |
| 64 | 64 | if ($type == "c" || $type == "p") |
| 65 | 65 | { |
| 66 | 66 | $label = $langs->trans("Customers"); |
| 67 | - $urlfiche="card.php"; |
|
| 67 | + $urlfiche = "card.php"; |
|
| 68 | 68 | } |
| 69 | 69 | if ($type == "f") |
| 70 | 70 | { |
| 71 | 71 | $label = $langs->trans("Suppliers"); |
| 72 | - $urlfiche="card.php"; |
|
| 72 | + $urlfiche = "card.php"; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /* |
@@ -77,66 +77,66 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | |
| 79 | 79 | $sql = "SELECT s.rowid, s.nom as name, st.libelle as stcomm"; |
| 80 | -$sql.= ", p.rowid as cidp, p.name, p.firstname, p.email, p.phone"; |
|
| 81 | -$sql.= " FROM ".MAIN_DB_PREFIX."c_stcomm as st,"; |
|
| 82 | -if (! $user->rights->societe->client->voir && ! $socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; |
|
| 83 | -$sql.= " ".MAIN_DB_PREFIX."socpeople as p"; |
|
| 84 | -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; |
|
| 85 | -$sql.= " WHERE s.fk_stcomm = st.id"; |
|
| 86 | -$sql.= " AND p.entity IN (".getEntity('socpeople').")"; |
|
| 87 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 88 | -if ($type == "c") $sql.= " AND s.client IN (1, 3)"; |
|
| 89 | -if ($type == "p") $sql.= " AND s.client IN (2, 3)"; |
|
| 90 | -if ($type == "f") $sql.= " AND s.fournisseur = 1"; |
|
| 91 | -if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
| 80 | +$sql .= ", p.rowid as cidp, p.name, p.firstname, p.email, p.phone"; |
|
| 81 | +$sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm as st,"; |
|
| 82 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; |
|
| 83 | +$sql .= " ".MAIN_DB_PREFIX."socpeople as p"; |
|
| 84 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; |
|
| 85 | +$sql .= " WHERE s.fk_stcomm = st.id"; |
|
| 86 | +$sql .= " AND p.entity IN (".getEntity('socpeople').")"; |
|
| 87 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 88 | +if ($type == "c") $sql .= " AND s.client IN (1, 3)"; |
|
| 89 | +if ($type == "p") $sql .= " AND s.client IN (2, 3)"; |
|
| 90 | +if ($type == "f") $sql .= " AND s.fournisseur = 1"; |
|
| 91 | +if ($socid) $sql .= " AND s.rowid = ".$socid; |
|
| 92 | 92 | |
| 93 | 93 | if (dol_strlen($stcomm)) |
| 94 | 94 | { |
| 95 | - $sql.= " AND s.fk_stcomm=".$db->escape($stcomm); |
|
| 95 | + $sql .= " AND s.fk_stcomm=".$db->escape($stcomm); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | -if (! empty($search_lastname)) |
|
| 98 | +if (!empty($search_lastname)) |
|
| 99 | 99 | { |
| 100 | - $sql.= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; |
|
| 100 | + $sql .= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | -if (! empty($search_firstname)) |
|
| 103 | +if (!empty($search_firstname)) |
|
| 104 | 104 | { |
| 105 | - $sql.= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; |
|
| 105 | + $sql .= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | -if (! empty($search_company)) |
|
| 108 | +if (!empty($search_company)) |
|
| 109 | 109 | { |
| 110 | - $sql.= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; |
|
| 110 | + $sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | -if (! empty($contactname)) // acces a partir du module de recherche |
|
| 113 | +if (!empty($contactname)) // acces a partir du module de recherche |
|
| 114 | 114 | { |
| 115 | - $sql.= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; |
|
| 115 | + $sql .= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; |
|
| 116 | 116 | $sortfield = "p.name"; |
| 117 | 117 | $sortorder = "ASC"; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | -$sql.= $db->order($sortfield,$sortorder); |
|
| 121 | -$sql.= $db->plimit($limit+1, $offset); |
|
| 120 | +$sql .= $db->order($sortfield, $sortorder); |
|
| 121 | +$sql .= $db->plimit($limit + 1, $offset); |
|
| 122 | 122 | |
| 123 | 123 | $resql = $db->query($sql); |
| 124 | 124 | if ($resql) |
| 125 | 125 | { |
| 126 | 126 | $num = $db->num_rows($resql); |
| 127 | 127 | |
| 128 | - $param="&type=".$type; |
|
| 128 | + $param = "&type=".$type; |
|
| 129 | 129 | |
| 130 | - $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); |
|
| 131 | - print_barre_liste($title.($label?" (".$label.")":""),$page, $_SERVER["PHP_SELF"], $param,$sortfield,$sortorder,"",$num); |
|
| 130 | + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); |
|
| 131 | + print_barre_liste($title.($label ? " (".$label.")" : ""), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num); |
|
| 132 | 132 | |
| 133 | 133 | print '<form action="'.$_SERVER["PHP_SELF"].'?type='.GETPOST("type", "alpha").'" method="GET">'; |
| 134 | 134 | |
| 135 | 135 | print '<table class="liste" width="100%">'; |
| 136 | 136 | print '<tr class="liste_titre">'; |
| 137 | - print_liste_field_titre("Lastname",$_SERVER["PHP_SELF"],"p.name", $begin, $param,"",$sortfield,$sortorder); |
|
| 138 | - print_liste_field_titre("Firstname",$_SERVER["PHP_SELF"],"p.firstname", $begin, $param,"",$sortfield,$sortorder); |
|
| 139 | - print_liste_field_titre("Company",$_SERVER["PHP_SELF"],"s.nom", $begin, $param,"",$sortfield,$sortorder); |
|
| 137 | + print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "p.name", $begin, $param, "", $sortfield, $sortorder); |
|
| 138 | + print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "p.firstname", $begin, $param, "", $sortfield, $sortorder); |
|
| 139 | + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", $begin, $param, "", $sortfield, $sortorder); |
|
| 140 | 140 | print_liste_field_titre("Email"); |
| 141 | 141 | print_liste_field_titre("Phone"); |
| 142 | 142 | print "</tr>\n"; |
@@ -146,25 +146,25 @@ discard block |
||
| 146 | 146 | print '<td class="liste_titre"><input class="flat" name="search_firstname" size="12" value="'.$search_firstname.'"></td>'; |
| 147 | 147 | print '<td class="liste_titre"><input class="flat" name="search_company" size="12" value="'.$search_company.'"></td>'; |
| 148 | 148 | print '<td class="liste_titre"> </td>'; |
| 149 | - print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>'; |
|
| 149 | + print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"), 'search.png', '', '', 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>'; |
|
| 150 | 150 | print "</tr>\n"; |
| 151 | 151 | |
| 152 | 152 | $i = 0; |
| 153 | - while ($i < min($num,$limit)) |
|
| 153 | + while ($i < min($num, $limit)) |
|
| 154 | 154 | { |
| 155 | 155 | $obj = $db->fetch_object($resql); |
| 156 | 156 | |
| 157 | 157 | print '<tr class="oddeven">'; |
| 158 | - print '<td><a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$obj->cidp.'&socid='.$obj->rowid.'">'.img_object($langs->trans("ShowContact"),"contact"); |
|
| 158 | + print '<td><a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$obj->cidp.'&socid='.$obj->rowid.'">'.img_object($langs->trans("ShowContact"), "contact"); |
|
| 159 | 159 | print '</a> <a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$obj->cidp.'&socid='.$obj->rowid.'">'.$obj->name.'</a></td>'; |
| 160 | 160 | print "<td>$obj->firstname</TD>"; |
| 161 | 161 | |
| 162 | - print '<td><a href="'.$_SERVER["PHP_SELF"].'?type='.$type.'&socid='.$obj->rowid.'">'.img_object($langs->trans("ShowCompany"),"company").'</a> '; |
|
| 162 | + print '<td><a href="'.$_SERVER["PHP_SELF"].'?type='.$type.'&socid='.$obj->rowid.'">'.img_object($langs->trans("ShowCompany"), "company").'</a> '; |
|
| 163 | 163 | print "<a href=\"".$urlfiche."?socid=".$obj->rowid."\">$obj->name</a></td>\n"; |
| 164 | 164 | |
| 165 | - print '<td>'.dol_print_phone($obj->email,$obj->cidp,$obj->rowid,'AC_EMAIL').'</td>'; |
|
| 165 | + print '<td>'.dol_print_phone($obj->email, $obj->cidp, $obj->rowid, 'AC_EMAIL').'</td>'; |
|
| 166 | 166 | |
| 167 | - print '<td>'.dol_print_phone($obj->phone,$obj->country_code,$obj->cidp,$obj->rowid,'AC_TEL').' </td>'; |
|
| 167 | + print '<td>'.dol_print_phone($obj->phone, $obj->country_code, $obj->cidp, $obj->rowid, 'AC_TEL').' </td>'; |
|
| 168 | 168 | |
| 169 | 169 | print "</tr>\n"; |
| 170 | 170 | $i++; |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | $socid = $_GET["socid"]; |
| 35 | 35 | if ($user->societe_id > 0) |
| 36 | 36 | { |
| 37 | - $action = ''; |
|
| 38 | - $socid = $user->societe_id; |
|
| 37 | + $action = ''; |
|
| 38 | + $socid = $user->societe_id; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | /* |
| 55 | 55 | * Affichage onglets |
| 56 | 56 | */ |
| 57 | - $head = societe_prepare_head($societe); |
|
| 57 | + $head = societe_prepare_head($societe); |
|
| 58 | 58 | |
| 59 | 59 | dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); |
| 60 | 60 | |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | print '</div>'; |
| 83 | 83 | |
| 84 | 84 | |
| 85 | - print $langs->trans("FeatureNotYetAvailable"); |
|
| 85 | + print $langs->trans("FeatureNotYetAvailable"); |
|
| 86 | 86 | } |
| 87 | 87 | else |
| 88 | 88 | { |
| 89 | - dol_print_error($db); |
|
| 89 | + dol_print_error($db); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // End of page |
@@ -28,7 +28,9 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | // Load translation files required by the page |
| 30 | 30 | $langs->load("companies"); |
| 31 | -if (! empty($conf->facture->enabled)) $langs->load("bills"); |
|
| 31 | +if (! empty($conf->facture->enabled)) { |
|
| 32 | + $langs->load("bills"); |
|
| 33 | +} |
|
| 32 | 34 | |
| 33 | 35 | // Security check |
| 34 | 36 | $socid = $_GET["socid"]; |
@@ -68,9 +70,11 @@ discard block |
||
| 68 | 70 | print '<tr><td width="20%">'.$langs->trans("ThirdParty").'</td><td width="80%" colspan="3">'.$societe->getNomUrl(1).'</td></tr>'; |
| 69 | 71 | |
| 70 | 72 | // Prefix |
| 71 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
| 73 | + if (! empty($conf->global->SOCIETE_USEPREFIX)) { |
|
| 74 | + // Old not used prefix field |
|
| 72 | 75 | { |
| 73 | 76 | print '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">'; |
| 77 | + } |
|
| 74 | 78 | print ($societe->prefix_comm?$societe->prefix_comm:' '); |
| 75 | 79 | print '</td></tr>'; |
| 76 | 80 | } |
@@ -83,8 +87,7 @@ discard block |
||
| 83 | 87 | |
| 84 | 88 | |
| 85 | 89 | print $langs->trans("FeatureNotYetAvailable"); |
| 86 | -} |
|
| 87 | -else |
|
| 90 | +} else |
|
| 88 | 91 | { |
| 89 | 92 | dol_print_error($db); |
| 90 | 93 | } |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 27 | 27 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 28 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 28 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 29 | 29 | |
| 30 | 30 | require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
| 31 | 31 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
| 32 | 32 | |
| 33 | 33 | // Load translation files required by the page |
| 34 | 34 | $langs->load("companies"); |
| 35 | -if (! empty($conf->facture->enabled)) $langs->load("bills"); |
|
| 35 | +if (!empty($conf->facture->enabled)) $langs->load("bills"); |
|
| 36 | 36 | |
| 37 | 37 | // Security check |
| 38 | 38 | $socid = $_GET["socid"]; |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | print '<tr><td width="20%">'.$langs->trans("ThirdParty").'</td><td width="80%" colspan="3">'.$societe->getNomUrl(1).'</td></tr>'; |
| 73 | 73 | |
| 74 | 74 | // Prefix |
| 75 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
| 75 | + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
| 76 | 76 | { |
| 77 | 77 | print '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">'; |
| 78 | - print ($societe->prefix_comm?$societe->prefix_comm:' '); |
|
| 78 | + print ($societe->prefix_comm ? $societe->prefix_comm : ' '); |
|
| 79 | 79 | print '</td></tr>'; |
| 80 | 80 | } |
| 81 | 81 | |