@@ -26,63 +26,63 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class GoogleAPI |
| 28 | 28 | { |
| 29 | - /** |
|
| 29 | + /** |
|
| 30 | 30 | * @var DoliDB Database handler. |
| 31 | 31 | */ |
| 32 | 32 | public $db; |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var string Error code (or message) |
|
| 36 | - */ |
|
| 37 | - public $error=''; |
|
| 34 | + /** |
|
| 35 | + * @var string Error code (or message) |
|
| 36 | + */ |
|
| 37 | + public $error=''; |
|
| 38 | 38 | |
| 39 | - public $key; |
|
| 39 | + public $key; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Constructor |
|
| 43 | - * |
|
| 44 | - * @param DoliDB $db Database handler |
|
| 45 | - * @param string $key Google key |
|
| 46 | - */ |
|
| 47 | - function __construct($db,$key) |
|
| 48 | - { |
|
| 49 | - $this->db=$db; |
|
| 50 | - $this->key=$key; |
|
| 51 | - } |
|
| 41 | + /** |
|
| 42 | + * Constructor |
|
| 43 | + * |
|
| 44 | + * @param DoliDB $db Database handler |
|
| 45 | + * @param string $key Google key |
|
| 46 | + */ |
|
| 47 | + function __construct($db,$key) |
|
| 48 | + { |
|
| 49 | + $this->db=$db; |
|
| 50 | + $this->key=$key; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Return geo coordinates of an address |
|
| 56 | - * |
|
| 57 | - * @param string $address Address |
|
| 58 | - * Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France |
|
| 59 | - * Example: 188, rue de Fontenay,+94300,+Vincennes,+France |
|
| 60 | - * @return string Coordinates |
|
| 61 | - */ |
|
| 62 | - function getGeoCoordinatesOfAddress($address) |
|
| 63 | - { |
|
| 64 | - global $conf; |
|
| 54 | + /** |
|
| 55 | + * Return geo coordinates of an address |
|
| 56 | + * |
|
| 57 | + * @param string $address Address |
|
| 58 | + * Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France |
|
| 59 | + * Example: 188, rue de Fontenay,+94300,+Vincennes,+France |
|
| 60 | + * @return string Coordinates |
|
| 61 | + */ |
|
| 62 | + function getGeoCoordinatesOfAddress($address) |
|
| 63 | + { |
|
| 64 | + global $conf; |
|
| 65 | 65 | |
| 66 | - $i=0; |
|
| 66 | + $i=0; |
|
| 67 | 67 | |
| 68 | - // Desired address |
|
| 69 | - $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; |
|
| 68 | + // Desired address |
|
| 69 | + $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; |
|
| 70 | 70 | |
| 71 | - // Retrieve the URL contents |
|
| 72 | - $page = file_get_contents($urladdress); |
|
| 71 | + // Retrieve the URL contents |
|
| 72 | + $page = file_get_contents($urladdress); |
|
| 73 | 73 | |
| 74 | - $code = strstr($page, '<coordinates>'); |
|
| 75 | - $code = strstr($code, '>'); |
|
| 76 | - $val=strpos($code, "<"); |
|
| 77 | - $code = substr($code, 1, $val-1); |
|
| 78 | - //print $code; |
|
| 79 | - //print "<br>"; |
|
| 80 | - $latitude = substr($code, 0, strpos($code, ",")); |
|
| 81 | - $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); |
|
| 74 | + $code = strstr($page, '<coordinates>'); |
|
| 75 | + $code = strstr($code, '>'); |
|
| 76 | + $val=strpos($code, "<"); |
|
| 77 | + $code = substr($code, 1, $val-1); |
|
| 78 | + //print $code; |
|
| 79 | + //print "<br>"; |
|
| 80 | + $latitude = substr($code, 0, strpos($code, ",")); |
|
| 81 | + $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); |
|
| 82 | 82 | |
| 83 | - // Output the coordinates |
|
| 84 | - //echo "Longitude: $longitude ',' Latitude: $latitude"; |
|
| 83 | + // Output the coordinates |
|
| 84 | + //echo "Longitude: $longitude ',' Latitude: $latitude"; |
|
| 85 | 85 | |
| 86 | - $i++; |
|
| 87 | - } |
|
| 86 | + $i++; |
|
| 87 | + } |
|
| 88 | 88 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @var string Error code (or message) |
| 36 | 36 | */ |
| 37 | - public $error=''; |
|
| 37 | + public $error = ''; |
|
| 38 | 38 | |
| 39 | 39 | public $key; |
| 40 | 40 | |
@@ -44,10 +44,10 @@ discard block |
||
| 44 | 44 | * @param DoliDB $db Database handler |
| 45 | 45 | * @param string $key Google key |
| 46 | 46 | */ |
| 47 | - function __construct($db,$key) |
|
| 47 | + function __construct($db, $key) |
|
| 48 | 48 | { |
| 49 | - $this->db=$db; |
|
| 50 | - $this->key=$key; |
|
| 49 | + $this->db = $db; |
|
| 50 | + $this->key = $key; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | { |
| 64 | 64 | global $conf; |
| 65 | 65 | |
| 66 | - $i=0; |
|
| 66 | + $i = 0; |
|
| 67 | 67 | |
| 68 | 68 | // Desired address |
| 69 | 69 | $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | $code = strstr($page, '<coordinates>'); |
| 75 | 75 | $code = strstr($code, '>'); |
| 76 | - $val=strpos($code, "<"); |
|
| 77 | - $code = substr($code, 1, $val-1); |
|
| 76 | + $val = strpos($code, "<"); |
|
| 77 | + $code = substr($code, 1, $val - 1); |
|
| 78 | 78 | //print $code; |
| 79 | 79 | //print "<br>"; |
| 80 | 80 | $latitude = substr($code, 0, strpos($code, ",")); |
| 81 | - $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); |
|
| 81 | + $longitude = substr($code, strpos($code, ",") + 1, dol_strlen(strpos($code, ",")) - 3); |
|
| 82 | 82 | |
| 83 | 83 | // Output the coordinates |
| 84 | 84 | //echo "Longitude: $longitude ',' Latitude: $latitude"; |
@@ -61,624 +61,624 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | const TYPE_SITUATION = 5; |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Draft status |
|
| 66 | - */ |
|
| 67 | - const STATUS_DRAFT = 0; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Validated (need to be paid) |
|
| 71 | - */ |
|
| 72 | - const STATUS_VALIDATED = 1; |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * Classified paid. |
|
| 76 | - * If paid partially, $this->close_code can be: |
|
| 77 | - * - CLOSECODE_DISCOUNTVAT |
|
| 78 | - * - CLOSECODE_BADDEBT |
|
| 79 | - * If paid completelly, this->close_code will be null |
|
| 80 | - */ |
|
| 81 | - const STATUS_CLOSED = 2; |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Classified abandoned and no payment done. |
|
| 85 | - * $this->close_code can be: |
|
| 86 | - * - CLOSECODE_BADDEBT |
|
| 87 | - * - CLOSECODE_ABANDONED |
|
| 88 | - * - CLOSECODE_REPLACED |
|
| 89 | - */ |
|
| 90 | - const STATUS_ABANDONED = 3; |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Return remain amount to pay. Property ->id and ->total_ttc must be set. |
|
| 95 | - * This does not include open direct debit requests. |
|
| 96 | - * |
|
| 97 | - * @param int $multicurrency Return multicurrency_amount instead of amount |
|
| 98 | - * @return double Remain of amount to pay |
|
| 99 | - */ |
|
| 100 | - function getRemainToPay($multicurrency=0) |
|
| 101 | - { |
|
| 102 | - $alreadypaid=0; |
|
| 103 | - $alreadypaid+=$this->getSommePaiement($multicurrency); |
|
| 104 | - $alreadypaid+=$this->getSumDepositsUsed($multicurrency); |
|
| 105 | - $alreadypaid+=$this->getSumCreditNotesUsed($multicurrency); |
|
| 106 | - return $this->total_ttc - $alreadypaid; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Return amount of payments already done |
|
| 111 | - * |
|
| 112 | - * @param int $multicurrency Return multicurrency_amount instead of amount |
|
| 113 | - * @return int Amount of payment already done, <0 if KO |
|
| 114 | - */ |
|
| 115 | - function getSommePaiement($multicurrency=0) |
|
| 116 | - { |
|
| 117 | - $table='paiement_facture'; |
|
| 118 | - $field='fk_facture'; |
|
| 119 | - if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
|
| 120 | - { |
|
| 121 | - $table='paiementfourn_facturefourn'; |
|
| 122 | - $field='fk_facturefourn'; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - $sql = 'SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount'; |
|
| 126 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table; |
|
| 127 | - $sql.= ' WHERE '.$field.' = '.$this->id; |
|
| 128 | - |
|
| 129 | - dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); |
|
| 130 | - $resql=$this->db->query($sql); |
|
| 131 | - if ($resql) |
|
| 132 | - { |
|
| 133 | - $obj = $this->db->fetch_object($resql); |
|
| 134 | - $this->db->free($resql); |
|
| 135 | - if ($multicurrency) return $obj->multicurrency_amount; |
|
| 136 | - else return $obj->amount; |
|
| 137 | - } |
|
| 138 | - else |
|
| 139 | - { |
|
| 140 | - $this->error=$this->db->lasterror(); |
|
| 141 | - return -1; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Return amount (with tax) of all deposits invoices used by invoice. |
|
| 64 | + /** |
|
| 65 | + * Draft status |
|
| 66 | + */ |
|
| 67 | + const STATUS_DRAFT = 0; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Validated (need to be paid) |
|
| 71 | + */ |
|
| 72 | + const STATUS_VALIDATED = 1; |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * Classified paid. |
|
| 76 | + * If paid partially, $this->close_code can be: |
|
| 77 | + * - CLOSECODE_DISCOUNTVAT |
|
| 78 | + * - CLOSECODE_BADDEBT |
|
| 79 | + * If paid completelly, this->close_code will be null |
|
| 80 | + */ |
|
| 81 | + const STATUS_CLOSED = 2; |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Classified abandoned and no payment done. |
|
| 85 | + * $this->close_code can be: |
|
| 86 | + * - CLOSECODE_BADDEBT |
|
| 87 | + * - CLOSECODE_ABANDONED |
|
| 88 | + * - CLOSECODE_REPLACED |
|
| 89 | + */ |
|
| 90 | + const STATUS_ABANDONED = 3; |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Return remain amount to pay. Property ->id and ->total_ttc must be set. |
|
| 95 | + * This does not include open direct debit requests. |
|
| 96 | + * |
|
| 97 | + * @param int $multicurrency Return multicurrency_amount instead of amount |
|
| 98 | + * @return double Remain of amount to pay |
|
| 99 | + */ |
|
| 100 | + function getRemainToPay($multicurrency=0) |
|
| 101 | + { |
|
| 102 | + $alreadypaid=0; |
|
| 103 | + $alreadypaid+=$this->getSommePaiement($multicurrency); |
|
| 104 | + $alreadypaid+=$this->getSumDepositsUsed($multicurrency); |
|
| 105 | + $alreadypaid+=$this->getSumCreditNotesUsed($multicurrency); |
|
| 106 | + return $this->total_ttc - $alreadypaid; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Return amount of payments already done |
|
| 111 | + * |
|
| 112 | + * @param int $multicurrency Return multicurrency_amount instead of amount |
|
| 113 | + * @return int Amount of payment already done, <0 if KO |
|
| 114 | + */ |
|
| 115 | + function getSommePaiement($multicurrency=0) |
|
| 116 | + { |
|
| 117 | + $table='paiement_facture'; |
|
| 118 | + $field='fk_facture'; |
|
| 119 | + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
|
| 120 | + { |
|
| 121 | + $table='paiementfourn_facturefourn'; |
|
| 122 | + $field='fk_facturefourn'; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + $sql = 'SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount'; |
|
| 126 | + $sql.= ' FROM '.MAIN_DB_PREFIX.$table; |
|
| 127 | + $sql.= ' WHERE '.$field.' = '.$this->id; |
|
| 128 | + |
|
| 129 | + dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); |
|
| 130 | + $resql=$this->db->query($sql); |
|
| 131 | + if ($resql) |
|
| 132 | + { |
|
| 133 | + $obj = $this->db->fetch_object($resql); |
|
| 134 | + $this->db->free($resql); |
|
| 135 | + if ($multicurrency) return $obj->multicurrency_amount; |
|
| 136 | + else return $obj->amount; |
|
| 137 | + } |
|
| 138 | + else |
|
| 139 | + { |
|
| 140 | + $this->error=$this->db->lasterror(); |
|
| 141 | + return -1; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Return amount (with tax) of all deposits invoices used by invoice. |
|
| 147 | 147 | * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). |
| 148 | - * |
|
| 149 | - * @param int $multicurrency Return multicurrency_amount instead of amount |
|
| 150 | - * @return int <0 if KO, Sum of deposits amount otherwise |
|
| 151 | - */ |
|
| 152 | - function getSumDepositsUsed($multicurrency=0) |
|
| 153 | - { |
|
| 154 | - if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
|
| 155 | - { |
|
| 156 | - // TODO |
|
| 157 | - return 0; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
|
| 161 | - |
|
| 162 | - $discountstatic=new DiscountAbsolute($this->db); |
|
| 163 | - $result=$discountstatic->getSumDepositsUsed($this, $multicurrency); |
|
| 164 | - if ($result >= 0) |
|
| 165 | - { |
|
| 166 | - return $result; |
|
| 167 | - } |
|
| 168 | - else |
|
| 169 | - { |
|
| 170 | - $this->error=$discountstatic->error; |
|
| 171 | - return -1; |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Return amount (with tax) of all credit notes invoices + excess received used by invoice |
|
| 177 | - * |
|
| 178 | - * @param int $multicurrency Return multicurrency_amount instead of amount |
|
| 179 | - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise |
|
| 180 | - */ |
|
| 181 | - function getSumCreditNotesUsed($multicurrency=0) |
|
| 182 | - { |
|
| 183 | - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
|
| 184 | - |
|
| 185 | - $discountstatic=new DiscountAbsolute($this->db); |
|
| 186 | - $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency); |
|
| 187 | - if ($result >= 0) |
|
| 188 | - { |
|
| 189 | - return $result; |
|
| 190 | - } |
|
| 191 | - else |
|
| 192 | - { |
|
| 193 | - $this->error=$discountstatic->error; |
|
| 194 | - return -1; |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * Renvoie tableau des ids de facture avoir issus de la facture |
|
| 200 | - * |
|
| 201 | - * @return array Tableau d'id de factures avoirs |
|
| 202 | - */ |
|
| 203 | - function getListIdAvoirFromInvoice() |
|
| 204 | - { |
|
| 205 | - $idarray=array(); |
|
| 206 | - |
|
| 207 | - $sql = 'SELECT rowid'; |
|
| 208 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
| 209 | - $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
| 210 | - $sql.= ' AND type = 2'; |
|
| 211 | - $resql=$this->db->query($sql); |
|
| 212 | - if ($resql) |
|
| 213 | - { |
|
| 214 | - $num = $this->db->num_rows($resql); |
|
| 215 | - $i = 0; |
|
| 216 | - while ($i < $num) |
|
| 217 | - { |
|
| 218 | - $row = $this->db->fetch_row($resql); |
|
| 219 | - $idarray[]=$row[0]; |
|
| 220 | - $i++; |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - else |
|
| 224 | - { |
|
| 225 | - dol_print_error($this->db); |
|
| 226 | - } |
|
| 227 | - return $idarray; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * Renvoie l'id de la facture qui la remplace |
|
| 232 | - * |
|
| 233 | - * @param string $option filtre sur statut ('', 'validated', ...) |
|
| 234 | - * @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon |
|
| 235 | - */ |
|
| 236 | - function getIdReplacingInvoice($option='') |
|
| 237 | - { |
|
| 238 | - $sql = 'SELECT rowid'; |
|
| 239 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
| 240 | - $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
| 241 | - $sql.= ' AND type < 2'; |
|
| 242 | - if ($option == 'validated') $sql.= ' AND fk_statut = 1'; |
|
| 243 | - // PROTECTION BAD DATA |
|
| 244 | - // Au cas ou base corrompue et qu'il y a une facture de remplacement validee |
|
| 245 | - // et une autre non, on donne priorite a la validee. |
|
| 246 | - // Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes |
|
| 247 | - // ont cree en meme temps une facture de remplacement pour la meme facture) |
|
| 248 | - $sql.= ' ORDER BY fk_statut DESC'; |
|
| 249 | - |
|
| 250 | - $resql=$this->db->query($sql); |
|
| 251 | - if ($resql) |
|
| 252 | - { |
|
| 253 | - $obj = $this->db->fetch_object($resql); |
|
| 254 | - if ($obj) |
|
| 255 | - { |
|
| 256 | - // Si il y en a |
|
| 257 | - return $obj->rowid; |
|
| 258 | - } |
|
| 259 | - else |
|
| 260 | - { |
|
| 261 | - // Si aucune facture ne remplace |
|
| 262 | - return 0; |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - else |
|
| 266 | - { |
|
| 267 | - return -1; |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * Return list of payments |
|
| 273 | - * |
|
| 274 | - * @param string $filtertype 1 to filter on type of payment == 'PRE' |
|
| 275 | - * @return array Array with list of payments |
|
| 276 | - */ |
|
| 277 | - function getListOfPayments($filtertype='') |
|
| 278 | - { |
|
| 279 | - $retarray=array(); |
|
| 280 | - |
|
| 281 | - $table='paiement_facture'; |
|
| 282 | - $table2='paiement'; |
|
| 283 | - $field='fk_facture'; |
|
| 284 | - $field2='fk_paiement'; |
|
| 285 | - $sharedentity='facture'; |
|
| 286 | - if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
|
| 287 | - { |
|
| 288 | - $table='paiementfourn_facturefourn'; |
|
| 289 | - $table2='paiementfourn'; |
|
| 290 | - $field='fk_facturefourn'; |
|
| 291 | - $field2='fk_paiementfourn'; |
|
| 292 | - $sharedentity='facture_fourn'; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'; |
|
| 296 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
| 297 | - $sql.= ' WHERE pf.'.$field.' = '.$this->id; |
|
| 298 | - //$sql.= ' WHERE pf.'.$field.' = 1'; |
|
| 299 | - $sql.= ' AND pf.'.$field2.' = p.rowid'; |
|
| 300 | - $sql.= ' AND p.fk_paiement = t.id'; |
|
| 301 | - $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; |
|
| 302 | - if ($filtertype) $sql.=" AND t.code='PRE'"; |
|
| 303 | - |
|
| 304 | - dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); |
|
| 305 | - $resql=$this->db->query($sql); |
|
| 306 | - if ($resql) |
|
| 307 | - { |
|
| 308 | - $num = $this->db->num_rows($resql); |
|
| 309 | - $i=0; |
|
| 310 | - while ($i < $num) |
|
| 311 | - { |
|
| 312 | - $obj = $this->db->fetch_object($resql); |
|
| 313 | - $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
| 314 | - $i++; |
|
| 315 | - } |
|
| 316 | - $this->db->free($resql); |
|
| 317 | - return $retarray; |
|
| 318 | - } |
|
| 319 | - else |
|
| 320 | - { |
|
| 321 | - $this->error=$this->db->lasterror(); |
|
| 322 | - dol_print_error($this->db); |
|
| 323 | - return array(); |
|
| 324 | - } |
|
| 325 | - } |
|
| 148 | + * |
|
| 149 | + * @param int $multicurrency Return multicurrency_amount instead of amount |
|
| 150 | + * @return int <0 if KO, Sum of deposits amount otherwise |
|
| 151 | + */ |
|
| 152 | + function getSumDepositsUsed($multicurrency=0) |
|
| 153 | + { |
|
| 154 | + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
|
| 155 | + { |
|
| 156 | + // TODO |
|
| 157 | + return 0; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
|
| 161 | + |
|
| 162 | + $discountstatic=new DiscountAbsolute($this->db); |
|
| 163 | + $result=$discountstatic->getSumDepositsUsed($this, $multicurrency); |
|
| 164 | + if ($result >= 0) |
|
| 165 | + { |
|
| 166 | + return $result; |
|
| 167 | + } |
|
| 168 | + else |
|
| 169 | + { |
|
| 170 | + $this->error=$discountstatic->error; |
|
| 171 | + return -1; |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Return amount (with tax) of all credit notes invoices + excess received used by invoice |
|
| 177 | + * |
|
| 178 | + * @param int $multicurrency Return multicurrency_amount instead of amount |
|
| 179 | + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise |
|
| 180 | + */ |
|
| 181 | + function getSumCreditNotesUsed($multicurrency=0) |
|
| 182 | + { |
|
| 183 | + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
|
| 184 | + |
|
| 185 | + $discountstatic=new DiscountAbsolute($this->db); |
|
| 186 | + $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency); |
|
| 187 | + if ($result >= 0) |
|
| 188 | + { |
|
| 189 | + return $result; |
|
| 190 | + } |
|
| 191 | + else |
|
| 192 | + { |
|
| 193 | + $this->error=$discountstatic->error; |
|
| 194 | + return -1; |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * Renvoie tableau des ids de facture avoir issus de la facture |
|
| 200 | + * |
|
| 201 | + * @return array Tableau d'id de factures avoirs |
|
| 202 | + */ |
|
| 203 | + function getListIdAvoirFromInvoice() |
|
| 204 | + { |
|
| 205 | + $idarray=array(); |
|
| 206 | + |
|
| 207 | + $sql = 'SELECT rowid'; |
|
| 208 | + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
| 209 | + $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
| 210 | + $sql.= ' AND type = 2'; |
|
| 211 | + $resql=$this->db->query($sql); |
|
| 212 | + if ($resql) |
|
| 213 | + { |
|
| 214 | + $num = $this->db->num_rows($resql); |
|
| 215 | + $i = 0; |
|
| 216 | + while ($i < $num) |
|
| 217 | + { |
|
| 218 | + $row = $this->db->fetch_row($resql); |
|
| 219 | + $idarray[]=$row[0]; |
|
| 220 | + $i++; |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + else |
|
| 224 | + { |
|
| 225 | + dol_print_error($this->db); |
|
| 226 | + } |
|
| 227 | + return $idarray; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * Renvoie l'id de la facture qui la remplace |
|
| 232 | + * |
|
| 233 | + * @param string $option filtre sur statut ('', 'validated', ...) |
|
| 234 | + * @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon |
|
| 235 | + */ |
|
| 236 | + function getIdReplacingInvoice($option='') |
|
| 237 | + { |
|
| 238 | + $sql = 'SELECT rowid'; |
|
| 239 | + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
| 240 | + $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
| 241 | + $sql.= ' AND type < 2'; |
|
| 242 | + if ($option == 'validated') $sql.= ' AND fk_statut = 1'; |
|
| 243 | + // PROTECTION BAD DATA |
|
| 244 | + // Au cas ou base corrompue et qu'il y a une facture de remplacement validee |
|
| 245 | + // et une autre non, on donne priorite a la validee. |
|
| 246 | + // Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes |
|
| 247 | + // ont cree en meme temps une facture de remplacement pour la meme facture) |
|
| 248 | + $sql.= ' ORDER BY fk_statut DESC'; |
|
| 249 | + |
|
| 250 | + $resql=$this->db->query($sql); |
|
| 251 | + if ($resql) |
|
| 252 | + { |
|
| 253 | + $obj = $this->db->fetch_object($resql); |
|
| 254 | + if ($obj) |
|
| 255 | + { |
|
| 256 | + // Si il y en a |
|
| 257 | + return $obj->rowid; |
|
| 258 | + } |
|
| 259 | + else |
|
| 260 | + { |
|
| 261 | + // Si aucune facture ne remplace |
|
| 262 | + return 0; |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + else |
|
| 266 | + { |
|
| 267 | + return -1; |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * Return list of payments |
|
| 273 | + * |
|
| 274 | + * @param string $filtertype 1 to filter on type of payment == 'PRE' |
|
| 275 | + * @return array Array with list of payments |
|
| 276 | + */ |
|
| 277 | + function getListOfPayments($filtertype='') |
|
| 278 | + { |
|
| 279 | + $retarray=array(); |
|
| 280 | + |
|
| 281 | + $table='paiement_facture'; |
|
| 282 | + $table2='paiement'; |
|
| 283 | + $field='fk_facture'; |
|
| 284 | + $field2='fk_paiement'; |
|
| 285 | + $sharedentity='facture'; |
|
| 286 | + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
|
| 287 | + { |
|
| 288 | + $table='paiementfourn_facturefourn'; |
|
| 289 | + $table2='paiementfourn'; |
|
| 290 | + $field='fk_facturefourn'; |
|
| 291 | + $field2='fk_paiementfourn'; |
|
| 292 | + $sharedentity='facture_fourn'; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'; |
|
| 296 | + $sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
| 297 | + $sql.= ' WHERE pf.'.$field.' = '.$this->id; |
|
| 298 | + //$sql.= ' WHERE pf.'.$field.' = 1'; |
|
| 299 | + $sql.= ' AND pf.'.$field2.' = p.rowid'; |
|
| 300 | + $sql.= ' AND p.fk_paiement = t.id'; |
|
| 301 | + $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; |
|
| 302 | + if ($filtertype) $sql.=" AND t.code='PRE'"; |
|
| 303 | + |
|
| 304 | + dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); |
|
| 305 | + $resql=$this->db->query($sql); |
|
| 306 | + if ($resql) |
|
| 307 | + { |
|
| 308 | + $num = $this->db->num_rows($resql); |
|
| 309 | + $i=0; |
|
| 310 | + while ($i < $num) |
|
| 311 | + { |
|
| 312 | + $obj = $this->db->fetch_object($resql); |
|
| 313 | + $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
| 314 | + $i++; |
|
| 315 | + } |
|
| 316 | + $this->db->free($resql); |
|
| 317 | + return $retarray; |
|
| 318 | + } |
|
| 319 | + else |
|
| 320 | + { |
|
| 321 | + $this->error=$this->db->lasterror(); |
|
| 322 | + dol_print_error($this->db); |
|
| 323 | + return array(); |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | 326 | |
| 327 | 327 | |
| 328 | 328 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 329 | - /** |
|
| 330 | - * Return if an invoice can be deleted |
|
| 331 | - * Rule is: |
|
| 332 | - * If invoice is draft and has a temporary ref -> yes (1) |
|
| 333 | - * If hidden option INVOICE_CAN_NEVER_BE_REMOVED is on -> no (0) |
|
| 334 | - * If invoice is dispatched in bookkeeping -> no (-1) |
|
| 335 | - * If invoice has a definitive ref, is not last and INVOICE_CAN_ALWAYS_BE_REMOVED off -> no (-2) |
|
| 336 | - * If invoice not last in a cycle -> no (-3) |
|
| 337 | - * If there is payment -> no (-4) |
|
| 338 | - * Otherwise -> yes (2) |
|
| 339 | - * |
|
| 340 | - * @return int <=0 if no, >0 if yes |
|
| 341 | - */ |
|
| 342 | - function is_erasable() |
|
| 343 | - { |
|
| 329 | + /** |
|
| 330 | + * Return if an invoice can be deleted |
|
| 331 | + * Rule is: |
|
| 332 | + * If invoice is draft and has a temporary ref -> yes (1) |
|
| 333 | + * If hidden option INVOICE_CAN_NEVER_BE_REMOVED is on -> no (0) |
|
| 334 | + * If invoice is dispatched in bookkeeping -> no (-1) |
|
| 335 | + * If invoice has a definitive ref, is not last and INVOICE_CAN_ALWAYS_BE_REMOVED off -> no (-2) |
|
| 336 | + * If invoice not last in a cycle -> no (-3) |
|
| 337 | + * If there is payment -> no (-4) |
|
| 338 | + * Otherwise -> yes (2) |
|
| 339 | + * |
|
| 340 | + * @return int <=0 if no, >0 if yes |
|
| 341 | + */ |
|
| 342 | + function is_erasable() |
|
| 343 | + { |
|
| 344 | 344 | // phpcs:enable |
| 345 | - global $conf; |
|
| 346 | - |
|
| 347 | - // We check if invoice is a temporary number (PROVxxxx) |
|
| 348 | - $tmppart = substr($this->ref, 1, 4); |
|
| 349 | - |
|
| 350 | - if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') // If draft invoice and ref not yet defined |
|
| 351 | - { |
|
| 352 | - return 1; |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
| 356 | - |
|
| 357 | - // If not a draft invoice and not temporary invoice |
|
| 358 | - if ($tmppart !== 'PROV') |
|
| 359 | - { |
|
| 360 | - $ventilExportCompta = $this->getVentilExportCompta(); |
|
| 361 | - if ($ventilExportCompta != 0) return -1; |
|
| 362 | - |
|
| 363 | - // Get last number of validated invoice |
|
| 364 | - if ($this->element != 'invoice_supplier') |
|
| 365 | - { |
|
| 366 | - if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
| 367 | - $maxref = $this->getNextNumRef($this->thirdparty,'last'); |
|
| 368 | - |
|
| 369 | - // If there is no invoice into the reset range and not already dispatched, we can delete |
|
| 370 | - // If invoice to delete is last one and not already dispatched, we can delete |
|
| 371 | - if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxref != '' && $maxref != $this->ref) return -2; |
|
| 372 | - |
|
| 373 | - // TODO If there is payment in bookkeeping, check payment is not dispatched in accounting |
|
| 374 | - // ... |
|
| 375 | - |
|
| 376 | - if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle')) |
|
| 377 | - { |
|
| 378 | - $last = $this->is_last_in_cycle(); |
|
| 379 | - if (! $last) return -3; |
|
| 380 | - } |
|
| 381 | - } |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - // Test if there is at least one payment. If yes, refuse to delete. |
|
| 385 | - if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) return -4; |
|
| 386 | - |
|
| 387 | - return 2; |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - /** |
|
| 391 | - * Return if an invoice was dispatched into bookkeeping |
|
| 392 | - * |
|
| 393 | - * @return int <0 if KO, 0=no, 1=yes |
|
| 394 | - */ |
|
| 395 | - public function getVentilExportCompta() |
|
| 396 | - { |
|
| 397 | - $alreadydispatched = 0; |
|
| 398 | - |
|
| 399 | - $type = 'customer_invoice'; |
|
| 400 | - if ($this->element == 'invoice_supplier') $type = 'supplier_invoice'; |
|
| 401 | - |
|
| 402 | - $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$type."' AND ab.fk_doc = ".$this->id; |
|
| 403 | - $resql = $this->db->query($sql); |
|
| 404 | - if ($resql) |
|
| 405 | - { |
|
| 406 | - $obj = $this->db->fetch_object($resql); |
|
| 407 | - if ($obj) |
|
| 408 | - { |
|
| 409 | - $alreadydispatched = $obj->nb; |
|
| 410 | - } |
|
| 411 | - } |
|
| 412 | - else |
|
| 413 | - { |
|
| 414 | - $this->error = $this->db->lasterror(); |
|
| 415 | - return -1; |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - if ($alreadydispatched) |
|
| 419 | - { |
|
| 420 | - return 1; |
|
| 421 | - } |
|
| 422 | - return 0; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - |
|
| 426 | - /** |
|
| 427 | - * Return label of type of invoice |
|
| 428 | - * |
|
| 429 | - * @return string Label of type of invoice |
|
| 430 | - */ |
|
| 431 | - function getLibType() |
|
| 432 | - { |
|
| 433 | - global $langs; |
|
| 345 | + global $conf; |
|
| 346 | + |
|
| 347 | + // We check if invoice is a temporary number (PROVxxxx) |
|
| 348 | + $tmppart = substr($this->ref, 1, 4); |
|
| 349 | + |
|
| 350 | + if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') // If draft invoice and ref not yet defined |
|
| 351 | + { |
|
| 352 | + return 1; |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
| 356 | + |
|
| 357 | + // If not a draft invoice and not temporary invoice |
|
| 358 | + if ($tmppart !== 'PROV') |
|
| 359 | + { |
|
| 360 | + $ventilExportCompta = $this->getVentilExportCompta(); |
|
| 361 | + if ($ventilExportCompta != 0) return -1; |
|
| 362 | + |
|
| 363 | + // Get last number of validated invoice |
|
| 364 | + if ($this->element != 'invoice_supplier') |
|
| 365 | + { |
|
| 366 | + if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
| 367 | + $maxref = $this->getNextNumRef($this->thirdparty,'last'); |
|
| 368 | + |
|
| 369 | + // If there is no invoice into the reset range and not already dispatched, we can delete |
|
| 370 | + // If invoice to delete is last one and not already dispatched, we can delete |
|
| 371 | + if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxref != '' && $maxref != $this->ref) return -2; |
|
| 372 | + |
|
| 373 | + // TODO If there is payment in bookkeeping, check payment is not dispatched in accounting |
|
| 374 | + // ... |
|
| 375 | + |
|
| 376 | + if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle')) |
|
| 377 | + { |
|
| 378 | + $last = $this->is_last_in_cycle(); |
|
| 379 | + if (! $last) return -3; |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + // Test if there is at least one payment. If yes, refuse to delete. |
|
| 385 | + if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) return -4; |
|
| 386 | + |
|
| 387 | + return 2; |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | + * Return if an invoice was dispatched into bookkeeping |
|
| 392 | + * |
|
| 393 | + * @return int <0 if KO, 0=no, 1=yes |
|
| 394 | + */ |
|
| 395 | + public function getVentilExportCompta() |
|
| 396 | + { |
|
| 397 | + $alreadydispatched = 0; |
|
| 398 | + |
|
| 399 | + $type = 'customer_invoice'; |
|
| 400 | + if ($this->element == 'invoice_supplier') $type = 'supplier_invoice'; |
|
| 401 | + |
|
| 402 | + $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$type."' AND ab.fk_doc = ".$this->id; |
|
| 403 | + $resql = $this->db->query($sql); |
|
| 404 | + if ($resql) |
|
| 405 | + { |
|
| 406 | + $obj = $this->db->fetch_object($resql); |
|
| 407 | + if ($obj) |
|
| 408 | + { |
|
| 409 | + $alreadydispatched = $obj->nb; |
|
| 410 | + } |
|
| 411 | + } |
|
| 412 | + else |
|
| 413 | + { |
|
| 414 | + $this->error = $this->db->lasterror(); |
|
| 415 | + return -1; |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + if ($alreadydispatched) |
|
| 419 | + { |
|
| 420 | + return 1; |
|
| 421 | + } |
|
| 422 | + return 0; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + |
|
| 426 | + /** |
|
| 427 | + * Return label of type of invoice |
|
| 428 | + * |
|
| 429 | + * @return string Label of type of invoice |
|
| 430 | + */ |
|
| 431 | + function getLibType() |
|
| 432 | + { |
|
| 433 | + global $langs; |
|
| 434 | 434 | if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); |
| 435 | 435 | elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); |
| 436 | 436 | elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); |
| 437 | 437 | elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); |
| 438 | 438 | elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. |
| 439 | 439 | elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); |
| 440 | - return $langs->trans("Unknown"); |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - /** |
|
| 444 | - * Return label of object status |
|
| 445 | - * |
|
| 446 | - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto |
|
| 447 | - * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
|
| 448 | - * @return string Label of status |
|
| 449 | - */ |
|
| 450 | - function getLibStatut($mode=0, $alreadypaid=-1) |
|
| 451 | - { |
|
| 452 | - return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); |
|
| 453 | - } |
|
| 440 | + return $langs->trans("Unknown"); |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + /** |
|
| 444 | + * Return label of object status |
|
| 445 | + * |
|
| 446 | + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto |
|
| 447 | + * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
|
| 448 | + * @return string Label of status |
|
| 449 | + */ |
|
| 450 | + function getLibStatut($mode=0, $alreadypaid=-1) |
|
| 451 | + { |
|
| 452 | + return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | 455 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 456 | - /** |
|
| 457 | - * Return label of a status |
|
| 458 | - * |
|
| 459 | - * @param int $paye Status field paye |
|
| 460 | - * @param int $status Id status |
|
| 461 | - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto |
|
| 462 | - * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, -1 otherwise) |
|
| 463 | - * @param int $type Type invoice |
|
| 464 | - * @return string Label of status |
|
| 465 | - */ |
|
| 466 | - function LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=0) |
|
| 467 | - { |
|
| 456 | + /** |
|
| 457 | + * Return label of a status |
|
| 458 | + * |
|
| 459 | + * @param int $paye Status field paye |
|
| 460 | + * @param int $status Id status |
|
| 461 | + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto |
|
| 462 | + * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, -1 otherwise) |
|
| 463 | + * @param int $type Type invoice |
|
| 464 | + * @return string Label of status |
|
| 465 | + */ |
|
| 466 | + function LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=0) |
|
| 467 | + { |
|
| 468 | 468 | // phpcs:enable |
| 469 | - global $langs; |
|
| 470 | - $langs->load('bills'); |
|
| 471 | - |
|
| 472 | - //print "$paye,$status,$mode,$alreadypaid,$type"; |
|
| 473 | - if ($mode == 0) |
|
| 474 | - { |
|
| 475 | - $prefix=''; |
|
| 476 | - if (! $paye) |
|
| 477 | - { |
|
| 478 | - if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 479 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); |
|
| 480 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 481 | - elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 482 | - else return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 483 | - } |
|
| 484 | - else |
|
| 485 | - { |
|
| 486 | - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
| 487 | - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
| 488 | - else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 489 | - } |
|
| 490 | - } |
|
| 491 | - elseif ($mode == 1) |
|
| 492 | - { |
|
| 493 | - $prefix='Short'; |
|
| 494 | - if (! $paye) |
|
| 495 | - { |
|
| 496 | - if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 497 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 498 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 499 | - elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 500 | - else return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 501 | - } |
|
| 502 | - else |
|
| 503 | - { |
|
| 504 | - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
| 505 | - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); |
|
| 506 | - else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 507 | - } |
|
| 508 | - } |
|
| 509 | - elseif ($mode == 2) |
|
| 510 | - { |
|
| 511 | - $prefix='Short'; |
|
| 512 | - if (! $paye) |
|
| 513 | - { |
|
| 514 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 515 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 516 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 517 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 518 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 519 | - } |
|
| 520 | - else |
|
| 521 | - { |
|
| 522 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
| 523 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
| 524 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 525 | - } |
|
| 526 | - } |
|
| 527 | - elseif ($mode == 3) |
|
| 528 | - { |
|
| 529 | - $prefix='Short'; |
|
| 530 | - if (! $paye) |
|
| 531 | - { |
|
| 532 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
| 533 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
| 534 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
| 535 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
| 536 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
| 537 | - } |
|
| 538 | - else |
|
| 539 | - { |
|
| 540 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
| 541 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
| 542 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
| 543 | - } |
|
| 544 | - } |
|
| 545 | - elseif ($mode == 4) |
|
| 546 | - { |
|
| 547 | - $prefix=''; |
|
| 548 | - if (! $paye) |
|
| 549 | - { |
|
| 550 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); |
|
| 551 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 552 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 553 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
| 554 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); |
|
| 555 | - } |
|
| 556 | - else |
|
| 557 | - { |
|
| 558 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
| 559 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted'); |
|
| 560 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid'); |
|
| 561 | - } |
|
| 562 | - } |
|
| 563 | - elseif ($mode == 5 || $mode == 6) |
|
| 564 | - { |
|
| 565 | - $prefix=''; |
|
| 566 | - if ($mode == 5) $prefix='Short'; |
|
| 567 | - if (! $paye) |
|
| 568 | - { |
|
| 569 | - if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
| 570 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
| 571 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
| 572 | - elseif ($alreadypaid <= 0) |
|
| 573 | - { |
|
| 574 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1'); |
|
| 575 | - return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
| 576 | - } |
|
| 577 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
| 578 | - } |
|
| 579 | - else |
|
| 580 | - { |
|
| 581 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
| 582 | - elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
| 583 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
| 584 | - } |
|
| 585 | - } |
|
| 586 | - } |
|
| 469 | + global $langs; |
|
| 470 | + $langs->load('bills'); |
|
| 471 | + |
|
| 472 | + //print "$paye,$status,$mode,$alreadypaid,$type"; |
|
| 473 | + if ($mode == 0) |
|
| 474 | + { |
|
| 475 | + $prefix=''; |
|
| 476 | + if (! $paye) |
|
| 477 | + { |
|
| 478 | + if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 479 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); |
|
| 480 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 481 | + elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 482 | + else return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 483 | + } |
|
| 484 | + else |
|
| 485 | + { |
|
| 486 | + if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
| 487 | + elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
| 488 | + else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | + elseif ($mode == 1) |
|
| 492 | + { |
|
| 493 | + $prefix='Short'; |
|
| 494 | + if (! $paye) |
|
| 495 | + { |
|
| 496 | + if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 497 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 498 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 499 | + elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 500 | + else return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 501 | + } |
|
| 502 | + else |
|
| 503 | + { |
|
| 504 | + if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
| 505 | + elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); |
|
| 506 | + else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 507 | + } |
|
| 508 | + } |
|
| 509 | + elseif ($mode == 2) |
|
| 510 | + { |
|
| 511 | + $prefix='Short'; |
|
| 512 | + if (! $paye) |
|
| 513 | + { |
|
| 514 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 515 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 516 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 517 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 518 | + else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 519 | + } |
|
| 520 | + else |
|
| 521 | + { |
|
| 522 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
| 523 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
| 524 | + else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + elseif ($mode == 3) |
|
| 528 | + { |
|
| 529 | + $prefix='Short'; |
|
| 530 | + if (! $paye) |
|
| 531 | + { |
|
| 532 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
| 533 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
| 534 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
| 535 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
| 536 | + else return img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
| 537 | + } |
|
| 538 | + else |
|
| 539 | + { |
|
| 540 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
| 541 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
| 542 | + else return img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
| 543 | + } |
|
| 544 | + } |
|
| 545 | + elseif ($mode == 4) |
|
| 546 | + { |
|
| 547 | + $prefix=''; |
|
| 548 | + if (! $paye) |
|
| 549 | + { |
|
| 550 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); |
|
| 551 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 552 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 553 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
| 554 | + else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); |
|
| 555 | + } |
|
| 556 | + else |
|
| 557 | + { |
|
| 558 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
| 559 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted'); |
|
| 560 | + else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid'); |
|
| 561 | + } |
|
| 562 | + } |
|
| 563 | + elseif ($mode == 5 || $mode == 6) |
|
| 564 | + { |
|
| 565 | + $prefix=''; |
|
| 566 | + if ($mode == 5) $prefix='Short'; |
|
| 567 | + if (! $paye) |
|
| 568 | + { |
|
| 569 | + if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
| 570 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
| 571 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
| 572 | + elseif ($alreadypaid <= 0) |
|
| 573 | + { |
|
| 574 | + if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1'); |
|
| 575 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
| 576 | + } |
|
| 577 | + else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
| 578 | + } |
|
| 579 | + else |
|
| 580 | + { |
|
| 581 | + if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
| 582 | + elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
| 583 | + else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
| 584 | + } |
|
| 585 | + } |
|
| 586 | + } |
|
| 587 | 587 | |
| 588 | 588 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 589 | - /** |
|
| 590 | - * Renvoi une date limite de reglement de facture en fonction des |
|
| 591 | - * conditions de reglements de la facture et date de facturation. |
|
| 592 | - * |
|
| 593 | - * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. |
|
| 594 | - * @return date Date limite de reglement si ok, <0 si ko |
|
| 595 | - */ |
|
| 596 | - function calculate_date_lim_reglement($cond_reglement=0) |
|
| 597 | - { |
|
| 589 | + /** |
|
| 590 | + * Renvoi une date limite de reglement de facture en fonction des |
|
| 591 | + * conditions de reglements de la facture et date de facturation. |
|
| 592 | + * |
|
| 593 | + * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. |
|
| 594 | + * @return date Date limite de reglement si ok, <0 si ko |
|
| 595 | + */ |
|
| 596 | + function calculate_date_lim_reglement($cond_reglement=0) |
|
| 597 | + { |
|
| 598 | 598 | // phpcs:enable |
| 599 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; |
|
| 600 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; |
|
| 599 | + if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; |
|
| 600 | + if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; |
|
| 601 | 601 | |
| 602 | - $cdr_nbjour=0; |
|
| 602 | + $cdr_nbjour=0; |
|
| 603 | 603 | $cdr_type=0; |
| 604 | 604 | $cdr_decalage=0; |
| 605 | 605 | |
| 606 | - $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; |
|
| 607 | - $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
|
| 608 | - if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; |
|
| 609 | - else { |
|
| 610 | - $sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
|
| 611 | - $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG); |
|
| 615 | - $resqltemp=$this->db->query($sqltemp); |
|
| 616 | - if ($resqltemp) |
|
| 617 | - { |
|
| 618 | - if ($this->db->num_rows($resqltemp)) |
|
| 619 | - { |
|
| 620 | - $obj = $this->db->fetch_object($resqltemp); |
|
| 621 | - $cdr_nbjour = $obj->nbjour; |
|
| 622 | - $cdr_type = $obj->type_cdr; |
|
| 623 | - $cdr_decalage = $obj->decalage; |
|
| 624 | - } |
|
| 625 | - } |
|
| 626 | - else |
|
| 627 | - { |
|
| 628 | - $this->error=$this->db->error(); |
|
| 629 | - return -1; |
|
| 630 | - } |
|
| 631 | - $this->db->free($resqltemp); |
|
| 632 | - |
|
| 633 | - /* Definition de la date limite */ |
|
| 634 | - |
|
| 635 | - // 0 : ajout du nombre de jours |
|
| 636 | - if ($cdr_type == 0) |
|
| 637 | - { |
|
| 638 | - $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
|
| 639 | - |
|
| 640 | - $datelim += ($cdr_decalage * 3600 * 24); |
|
| 641 | - } |
|
| 642 | - // 1 : application de la regle "fin de mois" |
|
| 643 | - elseif ($cdr_type == 1) |
|
| 644 | - { |
|
| 645 | - $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
|
| 646 | - |
|
| 647 | - $mois=date('m', $datelim); |
|
| 648 | - $annee=date('Y', $datelim); |
|
| 649 | - if ($mois == 12) |
|
| 650 | - { |
|
| 651 | - $mois = 1; |
|
| 652 | - $annee += 1; |
|
| 653 | - } |
|
| 654 | - else |
|
| 655 | - { |
|
| 656 | - $mois += 1; |
|
| 657 | - } |
|
| 658 | - // On se deplace au debut du mois suivant, et on retire un jour |
|
| 659 | - $datelim=dol_mktime(12,0,0,$mois,1,$annee); |
|
| 660 | - $datelim -= (3600 * 24); |
|
| 661 | - |
|
| 662 | - $datelim += ($cdr_decalage * 3600 * 24); |
|
| 663 | - } |
|
| 664 | - // 2 : application de la règle, le N du mois courant ou suivant |
|
| 665 | - elseif ($cdr_type == 2 && !empty($cdr_decalage)) |
|
| 666 | - { |
|
| 667 | - $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
|
| 668 | - |
|
| 669 | - $date_piece = dol_mktime(0, 0, 0, date('m', $datelim),date('d', $datelim),date('Y', $datelim)); // Sans les heures minutes et secondes |
|
| 670 | - $date_lim_current = dol_mktime(0, 0, 0, date('m', $datelim), $cdr_decalage, date('Y', $datelim)); // Sans les heures minutes et secondes |
|
| 671 | - $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month |
|
| 672 | - |
|
| 673 | - $diff = $date_piece - $date_lim_current; |
|
| 674 | - |
|
| 675 | - if ($diff < 0) $datelim = $date_lim_current; |
|
| 676 | - else $datelim = $date_lim_next; |
|
| 677 | - } |
|
| 678 | - else return 'Bad value for type_cdr in database for record cond_reglement = '.$cond_reglement; |
|
| 679 | - |
|
| 680 | - return $datelim; |
|
| 681 | - } |
|
| 606 | + $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; |
|
| 607 | + $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
|
| 608 | + if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; |
|
| 609 | + else { |
|
| 610 | + $sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
|
| 611 | + $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG); |
|
| 615 | + $resqltemp=$this->db->query($sqltemp); |
|
| 616 | + if ($resqltemp) |
|
| 617 | + { |
|
| 618 | + if ($this->db->num_rows($resqltemp)) |
|
| 619 | + { |
|
| 620 | + $obj = $this->db->fetch_object($resqltemp); |
|
| 621 | + $cdr_nbjour = $obj->nbjour; |
|
| 622 | + $cdr_type = $obj->type_cdr; |
|
| 623 | + $cdr_decalage = $obj->decalage; |
|
| 624 | + } |
|
| 625 | + } |
|
| 626 | + else |
|
| 627 | + { |
|
| 628 | + $this->error=$this->db->error(); |
|
| 629 | + return -1; |
|
| 630 | + } |
|
| 631 | + $this->db->free($resqltemp); |
|
| 632 | + |
|
| 633 | + /* Definition de la date limite */ |
|
| 634 | + |
|
| 635 | + // 0 : ajout du nombre de jours |
|
| 636 | + if ($cdr_type == 0) |
|
| 637 | + { |
|
| 638 | + $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
|
| 639 | + |
|
| 640 | + $datelim += ($cdr_decalage * 3600 * 24); |
|
| 641 | + } |
|
| 642 | + // 1 : application de la regle "fin de mois" |
|
| 643 | + elseif ($cdr_type == 1) |
|
| 644 | + { |
|
| 645 | + $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
|
| 646 | + |
|
| 647 | + $mois=date('m', $datelim); |
|
| 648 | + $annee=date('Y', $datelim); |
|
| 649 | + if ($mois == 12) |
|
| 650 | + { |
|
| 651 | + $mois = 1; |
|
| 652 | + $annee += 1; |
|
| 653 | + } |
|
| 654 | + else |
|
| 655 | + { |
|
| 656 | + $mois += 1; |
|
| 657 | + } |
|
| 658 | + // On se deplace au debut du mois suivant, et on retire un jour |
|
| 659 | + $datelim=dol_mktime(12,0,0,$mois,1,$annee); |
|
| 660 | + $datelim -= (3600 * 24); |
|
| 661 | + |
|
| 662 | + $datelim += ($cdr_decalage * 3600 * 24); |
|
| 663 | + } |
|
| 664 | + // 2 : application de la règle, le N du mois courant ou suivant |
|
| 665 | + elseif ($cdr_type == 2 && !empty($cdr_decalage)) |
|
| 666 | + { |
|
| 667 | + $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
|
| 668 | + |
|
| 669 | + $date_piece = dol_mktime(0, 0, 0, date('m', $datelim),date('d', $datelim),date('Y', $datelim)); // Sans les heures minutes et secondes |
|
| 670 | + $date_lim_current = dol_mktime(0, 0, 0, date('m', $datelim), $cdr_decalage, date('Y', $datelim)); // Sans les heures minutes et secondes |
|
| 671 | + $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month |
|
| 672 | + |
|
| 673 | + $diff = $date_piece - $date_lim_current; |
|
| 674 | + |
|
| 675 | + if ($diff < 0) $datelim = $date_lim_current; |
|
| 676 | + else $datelim = $date_lim_next; |
|
| 677 | + } |
|
| 678 | + else return 'Bad value for type_cdr in database for record cond_reglement = '.$cond_reglement; |
|
| 679 | + |
|
| 680 | + return $datelim; |
|
| 681 | + } |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | |
@@ -690,105 +690,105 @@ discard block |
||
| 690 | 690 | */ |
| 691 | 691 | abstract class CommonInvoiceLine extends CommonObjectLine |
| 692 | 692 | { |
| 693 | - /** |
|
| 694 | - * Quantity |
|
| 695 | - * @var double |
|
| 696 | - */ |
|
| 697 | - public $qty; |
|
| 698 | - |
|
| 699 | - /** |
|
| 700 | - * Unit price before taxes |
|
| 701 | - * @var float |
|
| 702 | - */ |
|
| 703 | - public $subprice; |
|
| 704 | - |
|
| 705 | - /** |
|
| 706 | - * Type of the product. 0 for product 1 for service |
|
| 707 | - * @var int |
|
| 708 | - */ |
|
| 709 | - public $product_type = 0; |
|
| 710 | - |
|
| 711 | - /** |
|
| 712 | - * Id of corresponding product |
|
| 713 | - * @var int |
|
| 714 | - */ |
|
| 715 | - public $fk_product; |
|
| 716 | - |
|
| 717 | - /** |
|
| 718 | - * VAT code |
|
| 719 | - * @var string |
|
| 720 | - */ |
|
| 721 | - public $vat_src_code; |
|
| 722 | - |
|
| 723 | - /** |
|
| 724 | - * VAT % |
|
| 725 | - * @var float |
|
| 726 | - */ |
|
| 727 | - public $tva_tx; |
|
| 728 | - |
|
| 729 | - /** |
|
| 730 | - * Local tax 1 % |
|
| 731 | - * @var float |
|
| 732 | - */ |
|
| 733 | - public $localtax1_tx; |
|
| 734 | - |
|
| 735 | - /** |
|
| 736 | - * Local tax 2 % |
|
| 737 | - * @var float |
|
| 738 | - */ |
|
| 739 | - public $localtax2_tx; |
|
| 740 | - |
|
| 741 | - /** |
|
| 742 | - * Percent of discount |
|
| 743 | - * @var float |
|
| 744 | - */ |
|
| 745 | - public $remise_percent; |
|
| 746 | - |
|
| 747 | - /** |
|
| 748 | - * Total amount before taxes |
|
| 749 | - * @var float |
|
| 750 | - */ |
|
| 751 | - public $total_ht; |
|
| 752 | - |
|
| 753 | - /** |
|
| 754 | - * Total VAT amount |
|
| 755 | - * @var float |
|
| 756 | - */ |
|
| 757 | - public $total_tva; |
|
| 758 | - |
|
| 759 | - /** |
|
| 760 | - * Total local tax 1 amount |
|
| 761 | - * @var float |
|
| 762 | - */ |
|
| 763 | - public $total_localtax1; |
|
| 764 | - |
|
| 765 | - /** |
|
| 766 | - * Total local tax 2 amount |
|
| 767 | - * @var float |
|
| 768 | - */ |
|
| 769 | - public $total_localtax2; |
|
| 770 | - |
|
| 771 | - /** |
|
| 772 | - * Total amount with taxes |
|
| 773 | - * @var float |
|
| 774 | - */ |
|
| 775 | - public $total_ttc; |
|
| 776 | - |
|
| 777 | - /** |
|
| 778 | - * Liste d'options cumulables: |
|
| 779 | - * Bit 0: 0 si TVA normal - 1 si TVA NPR |
|
| 780 | - * Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) |
|
| 781 | - * @var int |
|
| 782 | - */ |
|
| 783 | - public $info_bits = 0; |
|
| 784 | - |
|
| 785 | - /** |
|
| 786 | - * Constructor |
|
| 787 | - * |
|
| 788 | - * @param DoliDB $db Database handler |
|
| 789 | - */ |
|
| 790 | - public function __construct(DoliDB $db) |
|
| 791 | - { |
|
| 792 | - $this->db = $db; |
|
| 793 | - } |
|
| 693 | + /** |
|
| 694 | + * Quantity |
|
| 695 | + * @var double |
|
| 696 | + */ |
|
| 697 | + public $qty; |
|
| 698 | + |
|
| 699 | + /** |
|
| 700 | + * Unit price before taxes |
|
| 701 | + * @var float |
|
| 702 | + */ |
|
| 703 | + public $subprice; |
|
| 704 | + |
|
| 705 | + /** |
|
| 706 | + * Type of the product. 0 for product 1 for service |
|
| 707 | + * @var int |
|
| 708 | + */ |
|
| 709 | + public $product_type = 0; |
|
| 710 | + |
|
| 711 | + /** |
|
| 712 | + * Id of corresponding product |
|
| 713 | + * @var int |
|
| 714 | + */ |
|
| 715 | + public $fk_product; |
|
| 716 | + |
|
| 717 | + /** |
|
| 718 | + * VAT code |
|
| 719 | + * @var string |
|
| 720 | + */ |
|
| 721 | + public $vat_src_code; |
|
| 722 | + |
|
| 723 | + /** |
|
| 724 | + * VAT % |
|
| 725 | + * @var float |
|
| 726 | + */ |
|
| 727 | + public $tva_tx; |
|
| 728 | + |
|
| 729 | + /** |
|
| 730 | + * Local tax 1 % |
|
| 731 | + * @var float |
|
| 732 | + */ |
|
| 733 | + public $localtax1_tx; |
|
| 734 | + |
|
| 735 | + /** |
|
| 736 | + * Local tax 2 % |
|
| 737 | + * @var float |
|
| 738 | + */ |
|
| 739 | + public $localtax2_tx; |
|
| 740 | + |
|
| 741 | + /** |
|
| 742 | + * Percent of discount |
|
| 743 | + * @var float |
|
| 744 | + */ |
|
| 745 | + public $remise_percent; |
|
| 746 | + |
|
| 747 | + /** |
|
| 748 | + * Total amount before taxes |
|
| 749 | + * @var float |
|
| 750 | + */ |
|
| 751 | + public $total_ht; |
|
| 752 | + |
|
| 753 | + /** |
|
| 754 | + * Total VAT amount |
|
| 755 | + * @var float |
|
| 756 | + */ |
|
| 757 | + public $total_tva; |
|
| 758 | + |
|
| 759 | + /** |
|
| 760 | + * Total local tax 1 amount |
|
| 761 | + * @var float |
|
| 762 | + */ |
|
| 763 | + public $total_localtax1; |
|
| 764 | + |
|
| 765 | + /** |
|
| 766 | + * Total local tax 2 amount |
|
| 767 | + * @var float |
|
| 768 | + */ |
|
| 769 | + public $total_localtax2; |
|
| 770 | + |
|
| 771 | + /** |
|
| 772 | + * Total amount with taxes |
|
| 773 | + * @var float |
|
| 774 | + */ |
|
| 775 | + public $total_ttc; |
|
| 776 | + |
|
| 777 | + /** |
|
| 778 | + * Liste d'options cumulables: |
|
| 779 | + * Bit 0: 0 si TVA normal - 1 si TVA NPR |
|
| 780 | + * Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) |
|
| 781 | + * @var int |
|
| 782 | + */ |
|
| 783 | + public $info_bits = 0; |
|
| 784 | + |
|
| 785 | + /** |
|
| 786 | + * Constructor |
|
| 787 | + * |
|
| 788 | + * @param DoliDB $db Database handler |
|
| 789 | + */ |
|
| 790 | + public function __construct(DoliDB $db) |
|
| 791 | + { |
|
| 792 | + $this->db = $db; |
|
| 793 | + } |
|
| 794 | 794 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \brief File of the superclass of invoices classes (customer and supplier) |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; |
|
| 26 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Superclass for invoices classes |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | * @param int $multicurrency Return multicurrency_amount instead of amount |
| 98 | 98 | * @return double Remain of amount to pay |
| 99 | 99 | */ |
| 100 | - function getRemainToPay($multicurrency=0) |
|
| 100 | + function getRemainToPay($multicurrency = 0) |
|
| 101 | 101 | { |
| 102 | - $alreadypaid=0; |
|
| 103 | - $alreadypaid+=$this->getSommePaiement($multicurrency); |
|
| 104 | - $alreadypaid+=$this->getSumDepositsUsed($multicurrency); |
|
| 105 | - $alreadypaid+=$this->getSumCreditNotesUsed($multicurrency); |
|
| 102 | + $alreadypaid = 0; |
|
| 103 | + $alreadypaid += $this->getSommePaiement($multicurrency); |
|
| 104 | + $alreadypaid += $this->getSumDepositsUsed($multicurrency); |
|
| 105 | + $alreadypaid += $this->getSumCreditNotesUsed($multicurrency); |
|
| 106 | 106 | return $this->total_ttc - $alreadypaid; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -112,22 +112,22 @@ discard block |
||
| 112 | 112 | * @param int $multicurrency Return multicurrency_amount instead of amount |
| 113 | 113 | * @return int Amount of payment already done, <0 if KO |
| 114 | 114 | */ |
| 115 | - function getSommePaiement($multicurrency=0) |
|
| 115 | + function getSommePaiement($multicurrency = 0) |
|
| 116 | 116 | { |
| 117 | - $table='paiement_facture'; |
|
| 118 | - $field='fk_facture'; |
|
| 117 | + $table = 'paiement_facture'; |
|
| 118 | + $field = 'fk_facture'; |
|
| 119 | 119 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
| 120 | 120 | { |
| 121 | - $table='paiementfourn_facturefourn'; |
|
| 122 | - $field='fk_facturefourn'; |
|
| 121 | + $table = 'paiementfourn_facturefourn'; |
|
| 122 | + $field = 'fk_facturefourn'; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $sql = 'SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount'; |
| 126 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table; |
|
| 127 | - $sql.= ' WHERE '.$field.' = '.$this->id; |
|
| 126 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; |
|
| 127 | + $sql .= ' WHERE '.$field.' = '.$this->id; |
|
| 128 | 128 | |
| 129 | 129 | dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); |
| 130 | - $resql=$this->db->query($sql); |
|
| 130 | + $resql = $this->db->query($sql); |
|
| 131 | 131 | if ($resql) |
| 132 | 132 | { |
| 133 | 133 | $obj = $this->db->fetch_object($resql); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | else |
| 139 | 139 | { |
| 140 | - $this->error=$this->db->lasterror(); |
|
| 140 | + $this->error = $this->db->lasterror(); |
|
| 141 | 141 | return -1; |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @param int $multicurrency Return multicurrency_amount instead of amount |
| 150 | 150 | * @return int <0 if KO, Sum of deposits amount otherwise |
| 151 | 151 | */ |
| 152 | - function getSumDepositsUsed($multicurrency=0) |
|
| 152 | + function getSumDepositsUsed($multicurrency = 0) |
|
| 153 | 153 | { |
| 154 | 154 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
| 155 | 155 | { |
@@ -159,15 +159,15 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
| 161 | 161 | |
| 162 | - $discountstatic=new DiscountAbsolute($this->db); |
|
| 163 | - $result=$discountstatic->getSumDepositsUsed($this, $multicurrency); |
|
| 162 | + $discountstatic = new DiscountAbsolute($this->db); |
|
| 163 | + $result = $discountstatic->getSumDepositsUsed($this, $multicurrency); |
|
| 164 | 164 | if ($result >= 0) |
| 165 | 165 | { |
| 166 | 166 | return $result; |
| 167 | 167 | } |
| 168 | 168 | else |
| 169 | 169 | { |
| 170 | - $this->error=$discountstatic->error; |
|
| 170 | + $this->error = $discountstatic->error; |
|
| 171 | 171 | return -1; |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -178,19 +178,19 @@ discard block |
||
| 178 | 178 | * @param int $multicurrency Return multicurrency_amount instead of amount |
| 179 | 179 | * @return int <0 if KO, Sum of credit notes and deposits amount otherwise |
| 180 | 180 | */ |
| 181 | - function getSumCreditNotesUsed($multicurrency=0) |
|
| 181 | + function getSumCreditNotesUsed($multicurrency = 0) |
|
| 182 | 182 | { |
| 183 | 183 | require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
| 184 | 184 | |
| 185 | - $discountstatic=new DiscountAbsolute($this->db); |
|
| 186 | - $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency); |
|
| 185 | + $discountstatic = new DiscountAbsolute($this->db); |
|
| 186 | + $result = $discountstatic->getSumCreditNotesUsed($this, $multicurrency); |
|
| 187 | 187 | if ($result >= 0) |
| 188 | 188 | { |
| 189 | 189 | return $result; |
| 190 | 190 | } |
| 191 | 191 | else |
| 192 | 192 | { |
| 193 | - $this->error=$discountstatic->error; |
|
| 193 | + $this->error = $discountstatic->error; |
|
| 194 | 194 | return -1; |
| 195 | 195 | } |
| 196 | 196 | } |
@@ -202,13 +202,13 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | function getListIdAvoirFromInvoice() |
| 204 | 204 | { |
| 205 | - $idarray=array(); |
|
| 205 | + $idarray = array(); |
|
| 206 | 206 | |
| 207 | 207 | $sql = 'SELECT rowid'; |
| 208 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
| 209 | - $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
| 210 | - $sql.= ' AND type = 2'; |
|
| 211 | - $resql=$this->db->query($sql); |
|
| 208 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
| 209 | + $sql .= ' WHERE fk_facture_source = '.$this->id; |
|
| 210 | + $sql .= ' AND type = 2'; |
|
| 211 | + $resql = $this->db->query($sql); |
|
| 212 | 212 | if ($resql) |
| 213 | 213 | { |
| 214 | 214 | $num = $this->db->num_rows($resql); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | while ($i < $num) |
| 217 | 217 | { |
| 218 | 218 | $row = $this->db->fetch_row($resql); |
| 219 | - $idarray[]=$row[0]; |
|
| 219 | + $idarray[] = $row[0]; |
|
| 220 | 220 | $i++; |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -233,21 +233,21 @@ discard block |
||
| 233 | 233 | * @param string $option filtre sur statut ('', 'validated', ...) |
| 234 | 234 | * @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon |
| 235 | 235 | */ |
| 236 | - function getIdReplacingInvoice($option='') |
|
| 236 | + function getIdReplacingInvoice($option = '') |
|
| 237 | 237 | { |
| 238 | 238 | $sql = 'SELECT rowid'; |
| 239 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
| 240 | - $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
| 241 | - $sql.= ' AND type < 2'; |
|
| 242 | - if ($option == 'validated') $sql.= ' AND fk_statut = 1'; |
|
| 239 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
| 240 | + $sql .= ' WHERE fk_facture_source = '.$this->id; |
|
| 241 | + $sql .= ' AND type < 2'; |
|
| 242 | + if ($option == 'validated') $sql .= ' AND fk_statut = 1'; |
|
| 243 | 243 | // PROTECTION BAD DATA |
| 244 | 244 | // Au cas ou base corrompue et qu'il y a une facture de remplacement validee |
| 245 | 245 | // et une autre non, on donne priorite a la validee. |
| 246 | 246 | // Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes |
| 247 | 247 | // ont cree en meme temps une facture de remplacement pour la meme facture) |
| 248 | - $sql.= ' ORDER BY fk_statut DESC'; |
|
| 248 | + $sql .= ' ORDER BY fk_statut DESC'; |
|
| 249 | 249 | |
| 250 | - $resql=$this->db->query($sql); |
|
| 250 | + $resql = $this->db->query($sql); |
|
| 251 | 251 | if ($resql) |
| 252 | 252 | { |
| 253 | 253 | $obj = $this->db->fetch_object($resql); |
@@ -274,43 +274,43 @@ discard block |
||
| 274 | 274 | * @param string $filtertype 1 to filter on type of payment == 'PRE' |
| 275 | 275 | * @return array Array with list of payments |
| 276 | 276 | */ |
| 277 | - function getListOfPayments($filtertype='') |
|
| 277 | + function getListOfPayments($filtertype = '') |
|
| 278 | 278 | { |
| 279 | - $retarray=array(); |
|
| 279 | + $retarray = array(); |
|
| 280 | 280 | |
| 281 | - $table='paiement_facture'; |
|
| 282 | - $table2='paiement'; |
|
| 283 | - $field='fk_facture'; |
|
| 284 | - $field2='fk_paiement'; |
|
| 285 | - $sharedentity='facture'; |
|
| 281 | + $table = 'paiement_facture'; |
|
| 282 | + $table2 = 'paiement'; |
|
| 283 | + $field = 'fk_facture'; |
|
| 284 | + $field2 = 'fk_paiement'; |
|
| 285 | + $sharedentity = 'facture'; |
|
| 286 | 286 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
| 287 | 287 | { |
| 288 | - $table='paiementfourn_facturefourn'; |
|
| 289 | - $table2='paiementfourn'; |
|
| 290 | - $field='fk_facturefourn'; |
|
| 291 | - $field2='fk_paiementfourn'; |
|
| 292 | - $sharedentity='facture_fourn'; |
|
| 288 | + $table = 'paiementfourn_facturefourn'; |
|
| 289 | + $table2 = 'paiementfourn'; |
|
| 290 | + $field = 'fk_facturefourn'; |
|
| 291 | + $field2 = 'fk_paiementfourn'; |
|
| 292 | + $sharedentity = 'facture_fourn'; |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'; |
| 296 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
| 297 | - $sql.= ' WHERE pf.'.$field.' = '.$this->id; |
|
| 296 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
| 297 | + $sql .= ' WHERE pf.'.$field.' = '.$this->id; |
|
| 298 | 298 | //$sql.= ' WHERE pf.'.$field.' = 1'; |
| 299 | - $sql.= ' AND pf.'.$field2.' = p.rowid'; |
|
| 300 | - $sql.= ' AND p.fk_paiement = t.id'; |
|
| 301 | - $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; |
|
| 302 | - if ($filtertype) $sql.=" AND t.code='PRE'"; |
|
| 299 | + $sql .= ' AND pf.'.$field2.' = p.rowid'; |
|
| 300 | + $sql .= ' AND p.fk_paiement = t.id'; |
|
| 301 | + $sql .= ' AND p.entity IN ('.getEntity($sharedentity).')'; |
|
| 302 | + if ($filtertype) $sql .= " AND t.code='PRE'"; |
|
| 303 | 303 | |
| 304 | 304 | dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); |
| 305 | - $resql=$this->db->query($sql); |
|
| 305 | + $resql = $this->db->query($sql); |
|
| 306 | 306 | if ($resql) |
| 307 | 307 | { |
| 308 | 308 | $num = $this->db->num_rows($resql); |
| 309 | - $i=0; |
|
| 309 | + $i = 0; |
|
| 310 | 310 | while ($i < $num) |
| 311 | 311 | { |
| 312 | 312 | $obj = $this->db->fetch_object($resql); |
| 313 | - $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
| 313 | + $retarray[] = array('amount'=>$obj->amount, 'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
| 314 | 314 | $i++; |
| 315 | 315 | } |
| 316 | 316 | $this->db->free($resql); |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | else |
| 320 | 320 | { |
| 321 | - $this->error=$this->db->lasterror(); |
|
| 321 | + $this->error = $this->db->lasterror(); |
|
| 322 | 322 | dol_print_error($this->db); |
| 323 | 323 | return array(); |
| 324 | 324 | } |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | return 1; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
| 355 | + if (!empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
| 356 | 356 | |
| 357 | 357 | // If not a draft invoice and not temporary invoice |
| 358 | 358 | if ($tmppart !== 'PROV') |
@@ -363,8 +363,8 @@ discard block |
||
| 363 | 363 | // Get last number of validated invoice |
| 364 | 364 | if ($this->element != 'invoice_supplier') |
| 365 | 365 | { |
| 366 | - if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
| 367 | - $maxref = $this->getNextNumRef($this->thirdparty,'last'); |
|
| 366 | + if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
| 367 | + $maxref = $this->getNextNumRef($this->thirdparty, 'last'); |
|
| 368 | 368 | |
| 369 | 369 | // If there is no invoice into the reset range and not already dispatched, we can delete |
| 370 | 370 | // If invoice to delete is last one and not already dispatched, we can delete |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle')) |
| 377 | 377 | { |
| 378 | 378 | $last = $this->is_last_in_cycle(); |
| 379 | - if (! $last) return -3; |
|
| 379 | + if (!$last) return -3; |
|
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | } |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); |
| 436 | 436 | elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); |
| 437 | 437 | elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); |
| 438 | - elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. |
|
| 438 | + elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. |
|
| 439 | 439 | elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); |
| 440 | 440 | return $langs->trans("Unknown"); |
| 441 | 441 | } |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
| 448 | 448 | * @return string Label of status |
| 449 | 449 | */ |
| 450 | - function getLibStatut($mode=0, $alreadypaid=-1) |
|
| 450 | + function getLibStatut($mode = 0, $alreadypaid = -1) |
|
| 451 | 451 | { |
| 452 | 452 | return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); |
| 453 | 453 | } |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | * @param int $type Type invoice |
| 464 | 464 | * @return string Label of status |
| 465 | 465 | */ |
| 466 | - function LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=0) |
|
| 466 | + function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) |
|
| 467 | 467 | { |
| 468 | 468 | // phpcs:enable |
| 469 | 469 | global $langs; |
@@ -472,8 +472,8 @@ discard block |
||
| 472 | 472 | //print "$paye,$status,$mode,$alreadypaid,$type"; |
| 473 | 473 | if ($mode == 0) |
| 474 | 474 | { |
| 475 | - $prefix=''; |
|
| 476 | - if (! $paye) |
|
| 475 | + $prefix = ''; |
|
| 476 | + if (!$paye) |
|
| 477 | 477 | { |
| 478 | 478 | if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
| 479 | 479 | elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); |
@@ -483,15 +483,15 @@ discard block |
||
| 483 | 483 | } |
| 484 | 484 | else |
| 485 | 485 | { |
| 486 | - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
| 487 | - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
| 486 | + if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
| 487 | + elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
| 488 | 488 | else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | elseif ($mode == 1) |
| 492 | 492 | { |
| 493 | - $prefix='Short'; |
|
| 494 | - if (! $paye) |
|
| 493 | + $prefix = 'Short'; |
|
| 494 | + if (!$paye) |
|
| 495 | 495 | { |
| 496 | 496 | if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
| 497 | 497 | elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); |
@@ -508,79 +508,79 @@ discard block |
||
| 508 | 508 | } |
| 509 | 509 | elseif ($mode == 2) |
| 510 | 510 | { |
| 511 | - $prefix='Short'; |
|
| 512 | - if (! $paye) |
|
| 511 | + $prefix = 'Short'; |
|
| 512 | + if (!$paye) |
|
| 513 | 513 | { |
| 514 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 515 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 516 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 517 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 518 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 514 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 515 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'), 'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 516 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 517 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 518 | + else return img_picto($langs->trans('BillStatusStarted'), 'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 519 | 519 | } |
| 520 | 520 | else |
| 521 | 521 | { |
| 522 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
| 523 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
| 524 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 522 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
| 523 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
| 524 | + else return img_picto($langs->trans('BillStatusPaid'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 525 | 525 | } |
| 526 | 526 | } |
| 527 | 527 | elseif ($mode == 3) |
| 528 | 528 | { |
| 529 | - $prefix='Short'; |
|
| 530 | - if (! $paye) |
|
| 529 | + $prefix = 'Short'; |
|
| 530 | + if (!$paye) |
|
| 531 | 531 | { |
| 532 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
| 533 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
| 534 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
| 535 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
| 536 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
| 532 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0'); |
|
| 533 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'), 'statut5'); |
|
| 534 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9'); |
|
| 535 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1'); |
|
| 536 | + else return img_picto($langs->trans('BillStatusStarted'), 'statut3'); |
|
| 537 | 537 | } |
| 538 | 538 | else |
| 539 | 539 | { |
| 540 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
| 541 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
| 542 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
| 540 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6'); |
|
| 541 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6'); |
|
| 542 | + else return img_picto($langs->trans('BillStatusPaid'), 'statut6'); |
|
| 543 | 543 | } |
| 544 | 544 | } |
| 545 | 545 | elseif ($mode == 4) |
| 546 | 546 | { |
| 547 | - $prefix=''; |
|
| 548 | - if (! $paye) |
|
| 547 | + $prefix = ''; |
|
| 548 | + if (!$paye) |
|
| 549 | 549 | { |
| 550 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); |
|
| 551 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 552 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 553 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
| 554 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); |
|
| 550 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0').' '.$langs->trans('BillStatusDraft'); |
|
| 551 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'), 'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 552 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 553 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
| 554 | + else return img_picto($langs->trans('BillStatusStarted'), 'statut3').' '.$langs->trans('BillStatusStarted'); |
|
| 555 | 555 | } |
| 556 | 556 | else |
| 557 | 557 | { |
| 558 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
| 559 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted'); |
|
| 560 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid'); |
|
| 558 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
| 559 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6').' '.$langs->trans('BillStatusConverted'); |
|
| 560 | + else return img_picto($langs->trans('BillStatusPaid'), 'statut6').' '.$langs->trans('BillStatusPaid'); |
|
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | elseif ($mode == 5 || $mode == 6) |
| 564 | 564 | { |
| 565 | - $prefix=''; |
|
| 566 | - if ($mode == 5) $prefix='Short'; |
|
| 567 | - if (! $paye) |
|
| 565 | + $prefix = ''; |
|
| 566 | + if ($mode == 5) $prefix = 'Short'; |
|
| 567 | + if (!$paye) |
|
| 568 | 568 | { |
| 569 | - if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
| 570 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
| 571 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
| 569 | + if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'), 'statut0'); |
|
| 570 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'), 'statut5'); |
|
| 571 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9'); |
|
| 572 | 572 | elseif ($alreadypaid <= 0) |
| 573 | 573 | { |
| 574 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1'); |
|
| 575 | - return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
| 574 | + if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'), 'statut1'); |
|
| 575 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'), 'statut1'); |
|
| 576 | 576 | } |
| 577 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
| 577 | + else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'), 'statut3'); |
|
| 578 | 578 | } |
| 579 | 579 | else |
| 580 | 580 | { |
| 581 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
| 582 | - elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
| 583 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
| 581 | + if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6'); |
|
| 582 | + elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'), 'statut6'); |
|
| 583 | + else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'), 'statut6'); |
|
| 584 | 584 | } |
| 585 | 585 | } |
| 586 | 586 | } |
@@ -593,26 +593,26 @@ discard block |
||
| 593 | 593 | * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. |
| 594 | 594 | * @return date Date limite de reglement si ok, <0 si ko |
| 595 | 595 | */ |
| 596 | - function calculate_date_lim_reglement($cond_reglement=0) |
|
| 596 | + function calculate_date_lim_reglement($cond_reglement = 0) |
|
| 597 | 597 | { |
| 598 | 598 | // phpcs:enable |
| 599 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; |
|
| 600 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; |
|
| 599 | + if (!$cond_reglement) $cond_reglement = $this->cond_reglement_code; |
|
| 600 | + if (!$cond_reglement) $cond_reglement = $this->cond_reglement_id; |
|
| 601 | 601 | |
| 602 | - $cdr_nbjour=0; |
|
| 603 | - $cdr_type=0; |
|
| 604 | - $cdr_decalage=0; |
|
| 602 | + $cdr_nbjour = 0; |
|
| 603 | + $cdr_type = 0; |
|
| 604 | + $cdr_decalage = 0; |
|
| 605 | 605 | |
| 606 | 606 | $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; |
| 607 | - $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
|
| 608 | - if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; |
|
| 607 | + $sqltemp .= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
|
| 608 | + if (is_numeric($cond_reglement)) $sqltemp .= " WHERE c.rowid=".$cond_reglement; |
|
| 609 | 609 | else { |
| 610 | - $sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
|
| 611 | - $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
|
| 610 | + $sqltemp .= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
|
| 611 | + $sqltemp .= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG); |
| 615 | - $resqltemp=$this->db->query($sqltemp); |
|
| 615 | + $resqltemp = $this->db->query($sqltemp); |
|
| 616 | 616 | if ($resqltemp) |
| 617 | 617 | { |
| 618 | 618 | if ($this->db->num_rows($resqltemp)) |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | } |
| 626 | 626 | else |
| 627 | 627 | { |
| 628 | - $this->error=$this->db->error(); |
|
| 628 | + $this->error = $this->db->error(); |
|
| 629 | 629 | return -1; |
| 630 | 630 | } |
| 631 | 631 | $this->db->free($resqltemp); |
@@ -644,8 +644,8 @@ discard block |
||
| 644 | 644 | { |
| 645 | 645 | $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
| 646 | 646 | |
| 647 | - $mois=date('m', $datelim); |
|
| 648 | - $annee=date('Y', $datelim); |
|
| 647 | + $mois = date('m', $datelim); |
|
| 648 | + $annee = date('Y', $datelim); |
|
| 649 | 649 | if ($mois == 12) |
| 650 | 650 | { |
| 651 | 651 | $mois = 1; |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | $mois += 1; |
| 657 | 657 | } |
| 658 | 658 | // On se deplace au debut du mois suivant, et on retire un jour |
| 659 | - $datelim=dol_mktime(12,0,0,$mois,1,$annee); |
|
| 659 | + $datelim = dol_mktime(12, 0, 0, $mois, 1, $annee); |
|
| 660 | 660 | $datelim -= (3600 * 24); |
| 661 | 661 | |
| 662 | 662 | $datelim += ($cdr_decalage * 3600 * 24); |
@@ -666,9 +666,9 @@ discard block |
||
| 666 | 666 | { |
| 667 | 667 | $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
| 668 | 668 | |
| 669 | - $date_piece = dol_mktime(0, 0, 0, date('m', $datelim),date('d', $datelim),date('Y', $datelim)); // Sans les heures minutes et secondes |
|
| 669 | + $date_piece = dol_mktime(0, 0, 0, date('m', $datelim), date('d', $datelim), date('Y', $datelim)); // Sans les heures minutes et secondes |
|
| 670 | 670 | $date_lim_current = dol_mktime(0, 0, 0, date('m', $datelim), $cdr_decalage, date('Y', $datelim)); // Sans les heures minutes et secondes |
| 671 | - $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month |
|
| 671 | + $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month |
|
| 672 | 672 | |
| 673 | 673 | $diff = $date_piece - $date_lim_current; |
| 674 | 674 | |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | |
| 684 | 684 | |
| 685 | 685 | |
| 686 | -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; |
|
| 686 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; |
|
| 687 | 687 | |
| 688 | 688 | /** |
| 689 | 689 | * Parent class of all other business classes for details of elements (invoices, contracts, proposals, orders, ...) |
@@ -132,10 +132,12 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | $obj = $this->db->fetch_object($resql); |
| 134 | 134 | $this->db->free($resql); |
| 135 | - if ($multicurrency) return $obj->multicurrency_amount; |
|
| 136 | - else return $obj->amount; |
|
| 137 | - } |
|
| 138 | - else |
|
| 135 | + if ($multicurrency) { |
|
| 136 | + return $obj->multicurrency_amount; |
|
| 137 | + } else { |
|
| 138 | + return $obj->amount; |
|
| 139 | + } |
|
| 140 | + } else |
|
| 139 | 141 | { |
| 140 | 142 | $this->error=$this->db->lasterror(); |
| 141 | 143 | return -1; |
@@ -164,8 +166,7 @@ discard block |
||
| 164 | 166 | if ($result >= 0) |
| 165 | 167 | { |
| 166 | 168 | return $result; |
| 167 | - } |
|
| 168 | - else |
|
| 169 | + } else |
|
| 169 | 170 | { |
| 170 | 171 | $this->error=$discountstatic->error; |
| 171 | 172 | return -1; |
@@ -187,8 +188,7 @@ discard block |
||
| 187 | 188 | if ($result >= 0) |
| 188 | 189 | { |
| 189 | 190 | return $result; |
| 190 | - } |
|
| 191 | - else |
|
| 191 | + } else |
|
| 192 | 192 | { |
| 193 | 193 | $this->error=$discountstatic->error; |
| 194 | 194 | return -1; |
@@ -219,8 +219,7 @@ discard block |
||
| 219 | 219 | $idarray[]=$row[0]; |
| 220 | 220 | $i++; |
| 221 | 221 | } |
| 222 | - } |
|
| 223 | - else |
|
| 222 | + } else |
|
| 224 | 223 | { |
| 225 | 224 | dol_print_error($this->db); |
| 226 | 225 | } |
@@ -239,7 +238,9 @@ discard block |
||
| 239 | 238 | $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
| 240 | 239 | $sql.= ' WHERE fk_facture_source = '.$this->id; |
| 241 | 240 | $sql.= ' AND type < 2'; |
| 242 | - if ($option == 'validated') $sql.= ' AND fk_statut = 1'; |
|
| 241 | + if ($option == 'validated') { |
|
| 242 | + $sql.= ' AND fk_statut = 1'; |
|
| 243 | + } |
|
| 243 | 244 | // PROTECTION BAD DATA |
| 244 | 245 | // Au cas ou base corrompue et qu'il y a une facture de remplacement validee |
| 245 | 246 | // et une autre non, on donne priorite a la validee. |
@@ -255,14 +256,12 @@ discard block |
||
| 255 | 256 | { |
| 256 | 257 | // Si il y en a |
| 257 | 258 | return $obj->rowid; |
| 258 | - } |
|
| 259 | - else |
|
| 259 | + } else |
|
| 260 | 260 | { |
| 261 | 261 | // Si aucune facture ne remplace |
| 262 | 262 | return 0; |
| 263 | 263 | } |
| 264 | - } |
|
| 265 | - else |
|
| 264 | + } else |
|
| 266 | 265 | { |
| 267 | 266 | return -1; |
| 268 | 267 | } |
@@ -299,7 +298,9 @@ discard block |
||
| 299 | 298 | $sql.= ' AND pf.'.$field2.' = p.rowid'; |
| 300 | 299 | $sql.= ' AND p.fk_paiement = t.id'; |
| 301 | 300 | $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; |
| 302 | - if ($filtertype) $sql.=" AND t.code='PRE'"; |
|
| 301 | + if ($filtertype) { |
|
| 302 | + $sql.=" AND t.code='PRE'"; |
|
| 303 | + } |
|
| 303 | 304 | |
| 304 | 305 | dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); |
| 305 | 306 | $resql=$this->db->query($sql); |
@@ -315,8 +316,7 @@ discard block |
||
| 315 | 316 | } |
| 316 | 317 | $this->db->free($resql); |
| 317 | 318 | return $retarray; |
| 318 | - } |
|
| 319 | - else |
|
| 319 | + } else |
|
| 320 | 320 | { |
| 321 | 321 | $this->error=$this->db->lasterror(); |
| 322 | 322 | dol_print_error($this->db); |
@@ -347,28 +347,39 @@ discard block |
||
| 347 | 347 | // We check if invoice is a temporary number (PROVxxxx) |
| 348 | 348 | $tmppart = substr($this->ref, 1, 4); |
| 349 | 349 | |
| 350 | - if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') // If draft invoice and ref not yet defined |
|
| 350 | + if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') { |
|
| 351 | + // If draft invoice and ref not yet defined |
|
| 351 | 352 | { |
| 352 | 353 | return 1; |
| 353 | 354 | } |
| 355 | + } |
|
| 354 | 356 | |
| 355 | - if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
| 357 | + if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) { |
|
| 358 | + return 0; |
|
| 359 | + } |
|
| 356 | 360 | |
| 357 | 361 | // If not a draft invoice and not temporary invoice |
| 358 | 362 | if ($tmppart !== 'PROV') |
| 359 | 363 | { |
| 360 | 364 | $ventilExportCompta = $this->getVentilExportCompta(); |
| 361 | - if ($ventilExportCompta != 0) return -1; |
|
| 365 | + if ($ventilExportCompta != 0) { |
|
| 366 | + return -1; |
|
| 367 | + } |
|
| 362 | 368 | |
| 363 | 369 | // Get last number of validated invoice |
| 364 | 370 | if ($this->element != 'invoice_supplier') |
| 365 | 371 | { |
| 366 | - if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
| 372 | + if (empty($this->thirdparty)) { |
|
| 373 | + $this->fetch_thirdparty(); |
|
| 374 | + } |
|
| 375 | + // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
| 367 | 376 | $maxref = $this->getNextNumRef($this->thirdparty,'last'); |
| 368 | 377 | |
| 369 | 378 | // If there is no invoice into the reset range and not already dispatched, we can delete |
| 370 | 379 | // If invoice to delete is last one and not already dispatched, we can delete |
| 371 | - if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxref != '' && $maxref != $this->ref) return -2; |
|
| 380 | + if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxref != '' && $maxref != $this->ref) { |
|
| 381 | + return -2; |
|
| 382 | + } |
|
| 372 | 383 | |
| 373 | 384 | // TODO If there is payment in bookkeeping, check payment is not dispatched in accounting |
| 374 | 385 | // ... |
@@ -376,13 +387,17 @@ discard block |
||
| 376 | 387 | if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle')) |
| 377 | 388 | { |
| 378 | 389 | $last = $this->is_last_in_cycle(); |
| 379 | - if (! $last) return -3; |
|
| 390 | + if (! $last) { |
|
| 391 | + return -3; |
|
| 392 | + } |
|
| 380 | 393 | } |
| 381 | 394 | } |
| 382 | 395 | } |
| 383 | 396 | |
| 384 | 397 | // Test if there is at least one payment. If yes, refuse to delete. |
| 385 | - if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) return -4; |
|
| 398 | + if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) { |
|
| 399 | + return -4; |
|
| 400 | + } |
|
| 386 | 401 | |
| 387 | 402 | return 2; |
| 388 | 403 | } |
@@ -397,7 +412,9 @@ discard block |
||
| 397 | 412 | $alreadydispatched = 0; |
| 398 | 413 | |
| 399 | 414 | $type = 'customer_invoice'; |
| 400 | - if ($this->element == 'invoice_supplier') $type = 'supplier_invoice'; |
|
| 415 | + if ($this->element == 'invoice_supplier') { |
|
| 416 | + $type = 'supplier_invoice'; |
|
| 417 | + } |
|
| 401 | 418 | |
| 402 | 419 | $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$type."' AND ab.fk_doc = ".$this->id; |
| 403 | 420 | $resql = $this->db->query($sql); |
@@ -408,8 +425,7 @@ discard block |
||
| 408 | 425 | { |
| 409 | 426 | $alreadydispatched = $obj->nb; |
| 410 | 427 | } |
| 411 | - } |
|
| 412 | - else |
|
| 428 | + } else |
|
| 413 | 429 | { |
| 414 | 430 | $this->error = $this->db->lasterror(); |
| 415 | 431 | return -1; |
@@ -431,12 +447,21 @@ discard block |
||
| 431 | 447 | function getLibType() |
| 432 | 448 | { |
| 433 | 449 | global $langs; |
| 434 | - if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); |
|
| 435 | - elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); |
|
| 436 | - elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); |
|
| 437 | - elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); |
|
| 438 | - elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. |
|
| 439 | - elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); |
|
| 450 | + if ($this->type == CommonInvoice::TYPE_STANDARD) { |
|
| 451 | + return $langs->trans("InvoiceStandard"); |
|
| 452 | + } elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) { |
|
| 453 | + return $langs->trans("InvoiceReplacement"); |
|
| 454 | + } elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) { |
|
| 455 | + return $langs->trans("InvoiceAvoir"); |
|
| 456 | + } elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) { |
|
| 457 | + return $langs->trans("InvoiceDeposit"); |
|
| 458 | + } elseif ($this->type == CommonInvoice::TYPE_PROFORMA) { |
|
| 459 | + return $langs->trans("InvoiceProForma"); |
|
| 460 | + } |
|
| 461 | + // Not used. |
|
| 462 | + elseif ($this->type == CommonInvoice::TYPE_SITUATION) { |
|
| 463 | + return $langs->trans("InvoiceSituation"); |
|
| 464 | + } |
|
| 440 | 465 | return $langs->trans("Unknown"); |
| 441 | 466 | } |
| 442 | 467 | |
@@ -475,112 +500,167 @@ discard block |
||
| 475 | 500 | $prefix=''; |
| 476 | 501 | if (! $paye) |
| 477 | 502 | { |
| 478 | - if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 479 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); |
|
| 480 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 481 | - elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 482 | - else return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 483 | - } |
|
| 484 | - else |
|
| 503 | + if ($status == 0) { |
|
| 504 | + return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 505 | + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { |
|
| 506 | + return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); |
|
| 507 | + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { |
|
| 508 | + return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 509 | + } elseif ($alreadypaid <= 0) { |
|
| 510 | + return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 511 | + } else { |
|
| 512 | + return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 513 | + } |
|
| 514 | + } else |
|
| 485 | 515 | { |
| 486 | - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
| 487 | - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
| 488 | - else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 516 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
| 517 | + return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
| 518 | + } |
|
| 519 | + // credit note |
|
| 520 | + elseif ($type == self::TYPE_DEPOSIT) { |
|
| 521 | + return $langs->trans('Bill'.$prefix.'StatusConverted'); |
|
| 522 | + } |
|
| 523 | + // deposit invoice |
|
| 524 | + else { |
|
| 525 | + return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 526 | + } |
|
| 489 | 527 | } |
| 490 | - } |
|
| 491 | - elseif ($mode == 1) |
|
| 528 | + } elseif ($mode == 1) |
|
| 492 | 529 | { |
| 493 | 530 | $prefix='Short'; |
| 494 | 531 | if (! $paye) |
| 495 | 532 | { |
| 496 | - if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 497 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 498 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 499 | - elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 500 | - else return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 501 | - } |
|
| 502 | - else |
|
| 533 | + if ($status == 0) { |
|
| 534 | + return $langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 535 | + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { |
|
| 536 | + return $langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 537 | + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { |
|
| 538 | + return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 539 | + } elseif ($alreadypaid <= 0) { |
|
| 540 | + return $langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 541 | + } else { |
|
| 542 | + return $langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 543 | + } |
|
| 544 | + } else |
|
| 503 | 545 | { |
| 504 | - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
| 505 | - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); |
|
| 506 | - else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 546 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
| 547 | + return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
| 548 | + } elseif ($type == self::TYPE_DEPOSIT) { |
|
| 549 | + return $langs->trans('Bill'.$prefix.'StatusConverted'); |
|
| 550 | + } else { |
|
| 551 | + return $langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 552 | + } |
|
| 507 | 553 | } |
| 508 | - } |
|
| 509 | - elseif ($mode == 2) |
|
| 554 | + } elseif ($mode == 2) |
|
| 510 | 555 | { |
| 511 | 556 | $prefix='Short'; |
| 512 | 557 | if (! $paye) |
| 513 | 558 | { |
| 514 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 515 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 516 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 517 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 518 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 519 | - } |
|
| 520 | - else |
|
| 559 | + if ($status == 0) { |
|
| 560 | + return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
| 561 | + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { |
|
| 562 | + return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 563 | + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { |
|
| 564 | + return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 565 | + } elseif ($alreadypaid <= 0) { |
|
| 566 | + return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
| 567 | + } else { |
|
| 568 | + return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
| 569 | + } |
|
| 570 | + } else |
|
| 521 | 571 | { |
| 522 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
| 523 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
| 524 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 572 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
| 573 | + return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
| 574 | + } elseif ($type == self::TYPE_DEPOSIT) { |
|
| 575 | + return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
| 576 | + } else { |
|
| 577 | + return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
| 578 | + } |
|
| 525 | 579 | } |
| 526 | - } |
|
| 527 | - elseif ($mode == 3) |
|
| 580 | + } elseif ($mode == 3) |
|
| 528 | 581 | { |
| 529 | 582 | $prefix='Short'; |
| 530 | 583 | if (! $paye) |
| 531 | 584 | { |
| 532 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
| 533 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
| 534 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
| 535 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
| 536 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
| 537 | - } |
|
| 538 | - else |
|
| 585 | + if ($status == 0) { |
|
| 586 | + return img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
| 587 | + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { |
|
| 588 | + return img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
| 589 | + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { |
|
| 590 | + return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
| 591 | + } elseif ($alreadypaid <= 0) { |
|
| 592 | + return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
| 593 | + } else { |
|
| 594 | + return img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
| 595 | + } |
|
| 596 | + } else |
|
| 539 | 597 | { |
| 540 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
| 541 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
| 542 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
| 598 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
| 599 | + return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
| 600 | + } elseif ($type == self::TYPE_DEPOSIT) { |
|
| 601 | + return img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
| 602 | + } else { |
|
| 603 | + return img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
| 604 | + } |
|
| 543 | 605 | } |
| 544 | - } |
|
| 545 | - elseif ($mode == 4) |
|
| 606 | + } elseif ($mode == 4) |
|
| 546 | 607 | { |
| 547 | 608 | $prefix=''; |
| 548 | 609 | if (! $paye) |
| 549 | 610 | { |
| 550 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); |
|
| 551 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 552 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 553 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
| 554 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); |
|
| 555 | - } |
|
| 556 | - else |
|
| 611 | + if ($status == 0) { |
|
| 612 | + return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); |
|
| 613 | + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { |
|
| 614 | + return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
| 615 | + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { |
|
| 616 | + return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
| 617 | + } elseif ($alreadypaid <= 0) { |
|
| 618 | + return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
| 619 | + } else { |
|
| 620 | + return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); |
|
| 621 | + } |
|
| 622 | + } else |
|
| 557 | 623 | { |
| 558 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
| 559 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted'); |
|
| 560 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid'); |
|
| 624 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
| 625 | + return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
| 626 | + } elseif ($type == self::TYPE_DEPOSIT) { |
|
| 627 | + return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted'); |
|
| 628 | + } else { |
|
| 629 | + return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid'); |
|
| 630 | + } |
|
| 561 | 631 | } |
| 562 | - } |
|
| 563 | - elseif ($mode == 5 || $mode == 6) |
|
| 632 | + } elseif ($mode == 5 || $mode == 6) |
|
| 564 | 633 | { |
| 565 | 634 | $prefix=''; |
| 566 | - if ($mode == 5) $prefix='Short'; |
|
| 635 | + if ($mode == 5) { |
|
| 636 | + $prefix='Short'; |
|
| 637 | + } |
|
| 567 | 638 | if (! $paye) |
| 568 | 639 | { |
| 569 | - if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
| 570 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
| 571 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
| 572 | - elseif ($alreadypaid <= 0) |
|
| 640 | + if ($status == 0) { |
|
| 641 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
| 642 | + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { |
|
| 643 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
| 644 | + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { |
|
| 645 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
| 646 | + } elseif ($alreadypaid <= 0) |
|
| 573 | 647 | { |
| 574 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1'); |
|
| 648 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
| 649 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1'); |
|
| 650 | + } |
|
| 575 | 651 | return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
| 652 | + } else { |
|
| 653 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
| 576 | 654 | } |
| 577 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
| 578 | - } |
|
| 579 | - else |
|
| 655 | + } else |
|
| 580 | 656 | { |
| 581 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
| 582 | - elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
| 583 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
| 657 | + if ($type == self::TYPE_CREDIT_NOTE) { |
|
| 658 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
| 659 | + } elseif ($type == self::TYPE_DEPOSIT) { |
|
| 660 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
| 661 | + } else { |
|
| 662 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
| 663 | + } |
|
| 584 | 664 | } |
| 585 | 665 | } |
| 586 | 666 | } |
@@ -596,8 +676,12 @@ discard block |
||
| 596 | 676 | function calculate_date_lim_reglement($cond_reglement=0) |
| 597 | 677 | { |
| 598 | 678 | // phpcs:enable |
| 599 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; |
|
| 600 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; |
|
| 679 | + if (! $cond_reglement) { |
|
| 680 | + $cond_reglement=$this->cond_reglement_code; |
|
| 681 | + } |
|
| 682 | + if (! $cond_reglement) { |
|
| 683 | + $cond_reglement=$this->cond_reglement_id; |
|
| 684 | + } |
|
| 601 | 685 | |
| 602 | 686 | $cdr_nbjour=0; |
| 603 | 687 | $cdr_type=0; |
@@ -605,8 +689,9 @@ discard block |
||
| 605 | 689 | |
| 606 | 690 | $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; |
| 607 | 691 | $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
| 608 | - if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; |
|
| 609 | - else { |
|
| 692 | + if (is_numeric($cond_reglement)) { |
|
| 693 | + $sqltemp.= " WHERE c.rowid=".$cond_reglement; |
|
| 694 | + } else { |
|
| 610 | 695 | $sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
| 611 | 696 | $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
| 612 | 697 | } |
@@ -622,8 +707,7 @@ discard block |
||
| 622 | 707 | $cdr_type = $obj->type_cdr; |
| 623 | 708 | $cdr_decalage = $obj->decalage; |
| 624 | 709 | } |
| 625 | - } |
|
| 626 | - else |
|
| 710 | + } else |
|
| 627 | 711 | { |
| 628 | 712 | $this->error=$this->db->error(); |
| 629 | 713 | return -1; |
@@ -650,8 +734,7 @@ discard block |
||
| 650 | 734 | { |
| 651 | 735 | $mois = 1; |
| 652 | 736 | $annee += 1; |
| 653 | - } |
|
| 654 | - else |
|
| 737 | + } else |
|
| 655 | 738 | { |
| 656 | 739 | $mois += 1; |
| 657 | 740 | } |
@@ -672,10 +755,14 @@ discard block |
||
| 672 | 755 | |
| 673 | 756 | $diff = $date_piece - $date_lim_current; |
| 674 | 757 | |
| 675 | - if ($diff < 0) $datelim = $date_lim_current; |
|
| 676 | - else $datelim = $date_lim_next; |
|
| 758 | + if ($diff < 0) { |
|
| 759 | + $datelim = $date_lim_current; |
|
| 760 | + } else { |
|
| 761 | + $datelim = $date_lim_next; |
|
| 762 | + } |
|
| 763 | + } else { |
|
| 764 | + return 'Bad value for type_cdr in database for record cond_reglement = '.$cond_reglement; |
|
| 677 | 765 | } |
| 678 | - else return 'Bad value for type_cdr in database for record cond_reglement = '.$cond_reglement; |
|
| 679 | 766 | |
| 680 | 767 | return $datelim; |
| 681 | 768 | } |
@@ -21,347 +21,347 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class Comment extends CommonObject |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * @var string ID to identify managed object |
|
| 26 | - */ |
|
| 27 | - public $element='comment'; |
|
| 24 | + /** |
|
| 25 | + * @var string ID to identify managed object |
|
| 26 | + */ |
|
| 27 | + public $element='comment'; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var string Name of table without prefix where object is stored |
|
| 31 | - */ |
|
| 32 | - public $table_element='comment'; |
|
| 29 | + /** |
|
| 30 | + * @var string Name of table without prefix where object is stored |
|
| 31 | + */ |
|
| 32 | + public $table_element='comment'; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var int Field with ID of parent key if this field has a parent |
|
| 36 | - */ |
|
| 37 | - public $fk_element =''; |
|
| 34 | + /** |
|
| 35 | + * @var int Field with ID of parent key if this field has a parent |
|
| 36 | + */ |
|
| 37 | + public $fk_element =''; |
|
| 38 | 38 | |
| 39 | - public $element_type; |
|
| 39 | + public $element_type; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var string description |
|
| 43 | - */ |
|
| 44 | - public $description; |
|
| 41 | + /** |
|
| 42 | + * @var string description |
|
| 43 | + */ |
|
| 44 | + public $description; |
|
| 45 | 45 | |
| 46 | - public $tms; |
|
| 46 | + public $tms; |
|
| 47 | 47 | |
| 48 | - public $datec; |
|
| 48 | + public $datec; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | + /** |
|
| 51 | 51 | * @var int ID |
| 52 | 52 | */ |
| 53 | - public $fk_user_author; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @var int Entity |
|
| 57 | - */ |
|
| 58 | - public $entity; |
|
| 59 | - |
|
| 60 | - public $import_key; |
|
| 61 | - |
|
| 62 | - public $comments = array(); |
|
| 63 | - |
|
| 64 | - public $oldcopy; |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Constructor |
|
| 69 | - * |
|
| 70 | - * @param DoliDB $db Database handler |
|
| 71 | - */ |
|
| 72 | - function __construct($db) |
|
| 73 | - { |
|
| 74 | - $this->db = $db; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Create into database |
|
| 80 | - * |
|
| 81 | - * @param User $user User that create |
|
| 82 | - * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
| 83 | - * @return int <0 if KO, Id of created object if OK |
|
| 84 | - */ |
|
| 85 | - function create($user, $notrigger=0) |
|
| 86 | - { |
|
| 87 | - global $conf, $langs; |
|
| 88 | - |
|
| 89 | - $error=0; |
|
| 90 | - |
|
| 91 | - // Insert request |
|
| 92 | - $sql = "INSERT INTO ".MAIN_DB_PREFIX."comment ("; |
|
| 93 | - $sql.= "description"; |
|
| 94 | - $sql.= ", datec"; |
|
| 95 | - $sql.= ", fk_element"; |
|
| 96 | - $sql.= ", element_type"; |
|
| 97 | - $sql.= ", fk_user_author"; |
|
| 98 | - $sql.= ", entity"; |
|
| 99 | - $sql.= ", import_key"; |
|
| 100 | - $sql.= ") VALUES ("; |
|
| 101 | - $sql.= "'".$this->db->escape($this->description)."'"; |
|
| 102 | - $sql.= ", ".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null'); |
|
| 103 | - $sql.= ", '".(isset($this->fk_element)?$this->fk_element:"null")."'"; |
|
| 104 | - $sql.= ", '".$this->db->escape($this->element_type)."'"; |
|
| 105 | - $sql.= ", '".(isset($this->fk_user_author)?$this->fk_user_author:"null")."'"; |
|
| 106 | - $sql.= ", ".(!empty($this->entity)?$this->entity:'1'); |
|
| 107 | - $sql.= ", ".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
| 108 | - $sql.= ")"; |
|
| 109 | - |
|
| 110 | - //var_dump($this->db); |
|
| 111 | - //echo $sql; |
|
| 112 | - |
|
| 113 | - $this->db->begin(); |
|
| 114 | - |
|
| 115 | - dol_syslog(get_class($this)."::create", LOG_DEBUG); |
|
| 116 | - $resql=$this->db->query($sql); |
|
| 117 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
| 118 | - |
|
| 119 | - if (! $error) |
|
| 120 | - { |
|
| 121 | - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment"); |
|
| 122 | - |
|
| 123 | - if (! $notrigger) |
|
| 124 | - { |
|
| 125 | - // Call trigger |
|
| 126 | - $result=$this->call_trigger('TASK_COMMENT_CREATE',$user); |
|
| 127 | - if ($result < 0) { $error++; } |
|
| 128 | - // End call triggers |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - // Commit or rollback |
|
| 133 | - if ($error) |
|
| 134 | - { |
|
| 135 | - foreach($this->errors as $errmsg) |
|
| 136 | - { |
|
| 137 | - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
|
| 138 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 139 | - } |
|
| 140 | - $this->db->rollback(); |
|
| 141 | - return -1*$error; |
|
| 142 | - } |
|
| 143 | - else |
|
| 144 | - { |
|
| 145 | - $this->db->commit(); |
|
| 146 | - return $this->id; |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Load object in memory from database |
|
| 153 | - * |
|
| 154 | - * @param int $id Id object |
|
| 155 | - * @param int $ref ref object |
|
| 156 | - * @return int <0 if KO, 0 if not found, >0 if OK |
|
| 157 | - */ |
|
| 158 | - function fetch($id, $ref='') |
|
| 159 | - { |
|
| 160 | - global $langs; |
|
| 161 | - |
|
| 162 | - $sql = "SELECT"; |
|
| 163 | - $sql.= " c.rowid,"; |
|
| 164 | - $sql.= " c.description,"; |
|
| 165 | - $sql.= " c.datec,"; |
|
| 166 | - $sql.= " c.tms,"; |
|
| 167 | - $sql.= " c.fk_element,"; |
|
| 168 | - $sql.= " c.element_type,"; |
|
| 169 | - $sql.= " c.fk_user_author,"; |
|
| 170 | - $sql.= " c.entity,"; |
|
| 171 | - $sql.= " c.import_key"; |
|
| 172 | - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
| 173 | - $sql.= " WHERE c.rowid = ".$id; |
|
| 174 | - |
|
| 175 | - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
|
| 176 | - $resql=$this->db->query($sql); |
|
| 177 | - if ($resql) |
|
| 178 | - { |
|
| 179 | - $num_rows = $this->db->num_rows($resql); |
|
| 180 | - |
|
| 181 | - if ($num_rows) |
|
| 182 | - { |
|
| 183 | - $obj = $this->db->fetch_object($resql); |
|
| 184 | - |
|
| 185 | - $this->id = $obj->rowid; |
|
| 186 | - $this->description = $obj->description; |
|
| 187 | - $this->element_type = $obj->element_type; |
|
| 188 | - $this->datec = $this->db->jdate($obj->datec); |
|
| 189 | - $this->tms = $obj->tms; |
|
| 190 | - $this->fk_user_author = $obj->fk_user_author; |
|
| 191 | - $this->fk_element = $obj->fk_element; |
|
| 192 | - $this->entity = $obj->entity; |
|
| 193 | - $this->import_key = $obj->import_key; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - $this->db->free($resql); |
|
| 197 | - |
|
| 198 | - if ($num_rows) return 1; |
|
| 199 | - else return 0; |
|
| 200 | - } |
|
| 201 | - else |
|
| 202 | - { |
|
| 203 | - $this->error="Error ".$this->db->lasterror(); |
|
| 204 | - return -1; |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * Update database |
|
| 211 | - * |
|
| 212 | - * @param User $user User that modify |
|
| 213 | - * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
| 214 | - * @return int <=0 if KO, >0 if OK |
|
| 215 | - */ |
|
| 216 | - function update(User $user, $notrigger=0) |
|
| 217 | - { |
|
| 218 | - global $conf, $langs; |
|
| 219 | - $error=0; |
|
| 220 | - |
|
| 221 | - // Clean parameters |
|
| 222 | - if (isset($this->fk_element)) $this->fk_project=(int) trim($this->fk_element); |
|
| 223 | - if (isset($this->fk_user_author)) $this->fk_user_author=(int) trim($this->fk_user_author); |
|
| 224 | - if (isset($this->description)) $this->description=trim($this->description); |
|
| 225 | - |
|
| 226 | - |
|
| 227 | - // Update request |
|
| 228 | - $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET"; |
|
| 229 | - $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; |
|
| 230 | - $sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').","; |
|
| 231 | - $sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").","; |
|
| 232 | - $sql.= " element_type='".$this->db->escape($this->element_type)."',"; |
|
| 233 | - $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; |
|
| 234 | - $sql.= " entity=".(!empty($this->entity)?$this->entity:'1').","; |
|
| 235 | - $sql.= " import_key=".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
| 236 | - $sql.= " WHERE rowid=".$this->id; |
|
| 237 | - |
|
| 238 | - $this->db->begin(); |
|
| 239 | - |
|
| 240 | - dol_syslog(get_class($this)."::update", LOG_DEBUG); |
|
| 241 | - $resql = $this->db->query($sql); |
|
| 242 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
| 243 | - |
|
| 244 | - if (! $error) |
|
| 245 | - { |
|
| 246 | - if (! $notrigger) |
|
| 247 | - { |
|
| 248 | - // Call trigger |
|
| 249 | - $result=$this->call_trigger('TASK_COMMENT_MODIFY',$user); |
|
| 250 | - if ($result < 0) { $error++; } |
|
| 251 | - // End call triggers |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - // Commit or rollback |
|
| 256 | - if ($error) |
|
| 257 | - { |
|
| 258 | - foreach($this->errors as $errmsg) |
|
| 259 | - { |
|
| 260 | - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
|
| 261 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 262 | - } |
|
| 263 | - $this->db->rollback(); |
|
| 264 | - return -1*$error; |
|
| 265 | - } |
|
| 266 | - else |
|
| 267 | - { |
|
| 268 | - $this->db->commit(); |
|
| 269 | - return 1; |
|
| 270 | - } |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * Delete task from database |
|
| 276 | - * |
|
| 277 | - * @param User $user User that delete |
|
| 278 | - * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
| 279 | - * @return int <0 if KO, >0 if OK |
|
| 280 | - */ |
|
| 281 | - function delete($user, $notrigger=0) |
|
| 282 | - { |
|
| 283 | - global $conf, $langs; |
|
| 284 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
| 285 | - |
|
| 286 | - $error=0; |
|
| 287 | - |
|
| 288 | - $this->db->begin(); |
|
| 289 | - |
|
| 290 | - $sql = "DELETE FROM ".MAIN_DB_PREFIX."comment"; |
|
| 291 | - $sql.= " WHERE rowid=".$this->id; |
|
| 292 | - |
|
| 293 | - $resql = $this->db->query($sql); |
|
| 294 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
| 295 | - |
|
| 296 | - if (! $error) |
|
| 297 | - { |
|
| 298 | - if (! $notrigger) |
|
| 299 | - { |
|
| 300 | - // Call trigger |
|
| 301 | - $result=$this->call_trigger('TASK_COMMENT_DELETE',$user); |
|
| 302 | - if ($result < 0) { $error++; } |
|
| 303 | - // End call triggers |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - // Commit or rollback |
|
| 308 | - if ($error) |
|
| 309 | - { |
|
| 310 | - foreach($this->errors as $errmsg) |
|
| 311 | - { |
|
| 312 | - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
|
| 313 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 314 | - } |
|
| 315 | - $this->db->rollback(); |
|
| 316 | - return -1*$error; |
|
| 317 | - }else{ |
|
| 318 | - $this->db->commit(); |
|
| 319 | - return 1; |
|
| 320 | - } |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * Load comments linked with current task |
|
| 326 | - * |
|
| 327 | - * @param string $element_type Element type |
|
| 328 | - * @param int $fk_element Id of element |
|
| 329 | - * @return array Comment array |
|
| 330 | - */ |
|
| 331 | - public function fetchAllFor($element_type, $fk_element) |
|
| 332 | - { |
|
| 333 | - global $db,$conf; |
|
| 334 | - $this->comments = array(); |
|
| 335 | - if(!empty($element_type) && !empty($fk_element)) { |
|
| 336 | - $sql = "SELECT"; |
|
| 337 | - $sql.= " c.rowid"; |
|
| 338 | - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
| 339 | - $sql.= " WHERE c.fk_element = ".$fk_element; |
|
| 340 | - $sql.= " AND c.element_type = '".$db->escape($element_type)."'"; |
|
| 341 | - $sql.= " AND c.entity = ".$conf->entity; |
|
| 342 | - $sql.= " ORDER BY c.tms DESC"; |
|
| 343 | - |
|
| 344 | - dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); |
|
| 345 | - $resql=$db->query($sql); |
|
| 346 | - if ($resql) |
|
| 347 | - { |
|
| 348 | - $num_rows = $db->num_rows($resql); |
|
| 349 | - if ($num_rows > 0) |
|
| 350 | - { |
|
| 351 | - while($obj = $db->fetch_object($resql)) |
|
| 352 | - { |
|
| 353 | - $comment = new self($db); |
|
| 354 | - $comment->fetch($obj->rowid); |
|
| 355 | - $this->comments[] = $comment; |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - $db->free($resql); |
|
| 359 | - } else { |
|
| 360 | - $this->errors[]="Error ".$this->db->lasterror(); |
|
| 361 | - return -1; |
|
| 362 | - } |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - return count($this->comments); |
|
| 366 | - } |
|
| 53 | + public $fk_user_author; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @var int Entity |
|
| 57 | + */ |
|
| 58 | + public $entity; |
|
| 59 | + |
|
| 60 | + public $import_key; |
|
| 61 | + |
|
| 62 | + public $comments = array(); |
|
| 63 | + |
|
| 64 | + public $oldcopy; |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Constructor |
|
| 69 | + * |
|
| 70 | + * @param DoliDB $db Database handler |
|
| 71 | + */ |
|
| 72 | + function __construct($db) |
|
| 73 | + { |
|
| 74 | + $this->db = $db; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Create into database |
|
| 80 | + * |
|
| 81 | + * @param User $user User that create |
|
| 82 | + * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
| 83 | + * @return int <0 if KO, Id of created object if OK |
|
| 84 | + */ |
|
| 85 | + function create($user, $notrigger=0) |
|
| 86 | + { |
|
| 87 | + global $conf, $langs; |
|
| 88 | + |
|
| 89 | + $error=0; |
|
| 90 | + |
|
| 91 | + // Insert request |
|
| 92 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."comment ("; |
|
| 93 | + $sql.= "description"; |
|
| 94 | + $sql.= ", datec"; |
|
| 95 | + $sql.= ", fk_element"; |
|
| 96 | + $sql.= ", element_type"; |
|
| 97 | + $sql.= ", fk_user_author"; |
|
| 98 | + $sql.= ", entity"; |
|
| 99 | + $sql.= ", import_key"; |
|
| 100 | + $sql.= ") VALUES ("; |
|
| 101 | + $sql.= "'".$this->db->escape($this->description)."'"; |
|
| 102 | + $sql.= ", ".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null'); |
|
| 103 | + $sql.= ", '".(isset($this->fk_element)?$this->fk_element:"null")."'"; |
|
| 104 | + $sql.= ", '".$this->db->escape($this->element_type)."'"; |
|
| 105 | + $sql.= ", '".(isset($this->fk_user_author)?$this->fk_user_author:"null")."'"; |
|
| 106 | + $sql.= ", ".(!empty($this->entity)?$this->entity:'1'); |
|
| 107 | + $sql.= ", ".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
| 108 | + $sql.= ")"; |
|
| 109 | + |
|
| 110 | + //var_dump($this->db); |
|
| 111 | + //echo $sql; |
|
| 112 | + |
|
| 113 | + $this->db->begin(); |
|
| 114 | + |
|
| 115 | + dol_syslog(get_class($this)."::create", LOG_DEBUG); |
|
| 116 | + $resql=$this->db->query($sql); |
|
| 117 | + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
| 118 | + |
|
| 119 | + if (! $error) |
|
| 120 | + { |
|
| 121 | + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment"); |
|
| 122 | + |
|
| 123 | + if (! $notrigger) |
|
| 124 | + { |
|
| 125 | + // Call trigger |
|
| 126 | + $result=$this->call_trigger('TASK_COMMENT_CREATE',$user); |
|
| 127 | + if ($result < 0) { $error++; } |
|
| 128 | + // End call triggers |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + // Commit or rollback |
|
| 133 | + if ($error) |
|
| 134 | + { |
|
| 135 | + foreach($this->errors as $errmsg) |
|
| 136 | + { |
|
| 137 | + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
|
| 138 | + $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 139 | + } |
|
| 140 | + $this->db->rollback(); |
|
| 141 | + return -1*$error; |
|
| 142 | + } |
|
| 143 | + else |
|
| 144 | + { |
|
| 145 | + $this->db->commit(); |
|
| 146 | + return $this->id; |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Load object in memory from database |
|
| 153 | + * |
|
| 154 | + * @param int $id Id object |
|
| 155 | + * @param int $ref ref object |
|
| 156 | + * @return int <0 if KO, 0 if not found, >0 if OK |
|
| 157 | + */ |
|
| 158 | + function fetch($id, $ref='') |
|
| 159 | + { |
|
| 160 | + global $langs; |
|
| 161 | + |
|
| 162 | + $sql = "SELECT"; |
|
| 163 | + $sql.= " c.rowid,"; |
|
| 164 | + $sql.= " c.description,"; |
|
| 165 | + $sql.= " c.datec,"; |
|
| 166 | + $sql.= " c.tms,"; |
|
| 167 | + $sql.= " c.fk_element,"; |
|
| 168 | + $sql.= " c.element_type,"; |
|
| 169 | + $sql.= " c.fk_user_author,"; |
|
| 170 | + $sql.= " c.entity,"; |
|
| 171 | + $sql.= " c.import_key"; |
|
| 172 | + $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
| 173 | + $sql.= " WHERE c.rowid = ".$id; |
|
| 174 | + |
|
| 175 | + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
|
| 176 | + $resql=$this->db->query($sql); |
|
| 177 | + if ($resql) |
|
| 178 | + { |
|
| 179 | + $num_rows = $this->db->num_rows($resql); |
|
| 180 | + |
|
| 181 | + if ($num_rows) |
|
| 182 | + { |
|
| 183 | + $obj = $this->db->fetch_object($resql); |
|
| 184 | + |
|
| 185 | + $this->id = $obj->rowid; |
|
| 186 | + $this->description = $obj->description; |
|
| 187 | + $this->element_type = $obj->element_type; |
|
| 188 | + $this->datec = $this->db->jdate($obj->datec); |
|
| 189 | + $this->tms = $obj->tms; |
|
| 190 | + $this->fk_user_author = $obj->fk_user_author; |
|
| 191 | + $this->fk_element = $obj->fk_element; |
|
| 192 | + $this->entity = $obj->entity; |
|
| 193 | + $this->import_key = $obj->import_key; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + $this->db->free($resql); |
|
| 197 | + |
|
| 198 | + if ($num_rows) return 1; |
|
| 199 | + else return 0; |
|
| 200 | + } |
|
| 201 | + else |
|
| 202 | + { |
|
| 203 | + $this->error="Error ".$this->db->lasterror(); |
|
| 204 | + return -1; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * Update database |
|
| 211 | + * |
|
| 212 | + * @param User $user User that modify |
|
| 213 | + * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
| 214 | + * @return int <=0 if KO, >0 if OK |
|
| 215 | + */ |
|
| 216 | + function update(User $user, $notrigger=0) |
|
| 217 | + { |
|
| 218 | + global $conf, $langs; |
|
| 219 | + $error=0; |
|
| 220 | + |
|
| 221 | + // Clean parameters |
|
| 222 | + if (isset($this->fk_element)) $this->fk_project=(int) trim($this->fk_element); |
|
| 223 | + if (isset($this->fk_user_author)) $this->fk_user_author=(int) trim($this->fk_user_author); |
|
| 224 | + if (isset($this->description)) $this->description=trim($this->description); |
|
| 225 | + |
|
| 226 | + |
|
| 227 | + // Update request |
|
| 228 | + $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET"; |
|
| 229 | + $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; |
|
| 230 | + $sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').","; |
|
| 231 | + $sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").","; |
|
| 232 | + $sql.= " element_type='".$this->db->escape($this->element_type)."',"; |
|
| 233 | + $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; |
|
| 234 | + $sql.= " entity=".(!empty($this->entity)?$this->entity:'1').","; |
|
| 235 | + $sql.= " import_key=".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
| 236 | + $sql.= " WHERE rowid=".$this->id; |
|
| 237 | + |
|
| 238 | + $this->db->begin(); |
|
| 239 | + |
|
| 240 | + dol_syslog(get_class($this)."::update", LOG_DEBUG); |
|
| 241 | + $resql = $this->db->query($sql); |
|
| 242 | + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
| 243 | + |
|
| 244 | + if (! $error) |
|
| 245 | + { |
|
| 246 | + if (! $notrigger) |
|
| 247 | + { |
|
| 248 | + // Call trigger |
|
| 249 | + $result=$this->call_trigger('TASK_COMMENT_MODIFY',$user); |
|
| 250 | + if ($result < 0) { $error++; } |
|
| 251 | + // End call triggers |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + // Commit or rollback |
|
| 256 | + if ($error) |
|
| 257 | + { |
|
| 258 | + foreach($this->errors as $errmsg) |
|
| 259 | + { |
|
| 260 | + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
|
| 261 | + $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 262 | + } |
|
| 263 | + $this->db->rollback(); |
|
| 264 | + return -1*$error; |
|
| 265 | + } |
|
| 266 | + else |
|
| 267 | + { |
|
| 268 | + $this->db->commit(); |
|
| 269 | + return 1; |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * Delete task from database |
|
| 276 | + * |
|
| 277 | + * @param User $user User that delete |
|
| 278 | + * @param int $notrigger 0=launch triggers after, 1=disable triggers |
|
| 279 | + * @return int <0 if KO, >0 if OK |
|
| 280 | + */ |
|
| 281 | + function delete($user, $notrigger=0) |
|
| 282 | + { |
|
| 283 | + global $conf, $langs; |
|
| 284 | + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
| 285 | + |
|
| 286 | + $error=0; |
|
| 287 | + |
|
| 288 | + $this->db->begin(); |
|
| 289 | + |
|
| 290 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."comment"; |
|
| 291 | + $sql.= " WHERE rowid=".$this->id; |
|
| 292 | + |
|
| 293 | + $resql = $this->db->query($sql); |
|
| 294 | + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
| 295 | + |
|
| 296 | + if (! $error) |
|
| 297 | + { |
|
| 298 | + if (! $notrigger) |
|
| 299 | + { |
|
| 300 | + // Call trigger |
|
| 301 | + $result=$this->call_trigger('TASK_COMMENT_DELETE',$user); |
|
| 302 | + if ($result < 0) { $error++; } |
|
| 303 | + // End call triggers |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + // Commit or rollback |
|
| 308 | + if ($error) |
|
| 309 | + { |
|
| 310 | + foreach($this->errors as $errmsg) |
|
| 311 | + { |
|
| 312 | + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
|
| 313 | + $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 314 | + } |
|
| 315 | + $this->db->rollback(); |
|
| 316 | + return -1*$error; |
|
| 317 | + }else{ |
|
| 318 | + $this->db->commit(); |
|
| 319 | + return 1; |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * Load comments linked with current task |
|
| 326 | + * |
|
| 327 | + * @param string $element_type Element type |
|
| 328 | + * @param int $fk_element Id of element |
|
| 329 | + * @return array Comment array |
|
| 330 | + */ |
|
| 331 | + public function fetchAllFor($element_type, $fk_element) |
|
| 332 | + { |
|
| 333 | + global $db,$conf; |
|
| 334 | + $this->comments = array(); |
|
| 335 | + if(!empty($element_type) && !empty($fk_element)) { |
|
| 336 | + $sql = "SELECT"; |
|
| 337 | + $sql.= " c.rowid"; |
|
| 338 | + $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
| 339 | + $sql.= " WHERE c.fk_element = ".$fk_element; |
|
| 340 | + $sql.= " AND c.element_type = '".$db->escape($element_type)."'"; |
|
| 341 | + $sql.= " AND c.entity = ".$conf->entity; |
|
| 342 | + $sql.= " ORDER BY c.tms DESC"; |
|
| 343 | + |
|
| 344 | + dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); |
|
| 345 | + $resql=$db->query($sql); |
|
| 346 | + if ($resql) |
|
| 347 | + { |
|
| 348 | + $num_rows = $db->num_rows($resql); |
|
| 349 | + if ($num_rows > 0) |
|
| 350 | + { |
|
| 351 | + while($obj = $db->fetch_object($resql)) |
|
| 352 | + { |
|
| 353 | + $comment = new self($db); |
|
| 354 | + $comment->fetch($obj->rowid); |
|
| 355 | + $this->comments[] = $comment; |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + $db->free($resql); |
|
| 359 | + } else { |
|
| 360 | + $this->errors[]="Error ".$this->db->lasterror(); |
|
| 361 | + return -1; |
|
| 362 | + } |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + return count($this->comments); |
|
| 366 | + } |
|
| 367 | 367 | } |
@@ -24,17 +24,17 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * @var string ID to identify managed object |
| 26 | 26 | */ |
| 27 | - public $element='comment'; |
|
| 27 | + public $element = 'comment'; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * @var string Name of table without prefix where object is stored |
| 31 | 31 | */ |
| 32 | - public $table_element='comment'; |
|
| 32 | + public $table_element = 'comment'; |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * @var int Field with ID of parent key if this field has a parent |
| 36 | 36 | */ |
| 37 | - public $fk_element =''; |
|
| 37 | + public $fk_element = ''; |
|
| 38 | 38 | |
| 39 | 39 | public $element_type; |
| 40 | 40 | |
@@ -82,30 +82,30 @@ discard block |
||
| 82 | 82 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
| 83 | 83 | * @return int <0 if KO, Id of created object if OK |
| 84 | 84 | */ |
| 85 | - function create($user, $notrigger=0) |
|
| 85 | + function create($user, $notrigger = 0) |
|
| 86 | 86 | { |
| 87 | 87 | global $conf, $langs; |
| 88 | 88 | |
| 89 | - $error=0; |
|
| 89 | + $error = 0; |
|
| 90 | 90 | |
| 91 | 91 | // Insert request |
| 92 | 92 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."comment ("; |
| 93 | - $sql.= "description"; |
|
| 94 | - $sql.= ", datec"; |
|
| 95 | - $sql.= ", fk_element"; |
|
| 96 | - $sql.= ", element_type"; |
|
| 97 | - $sql.= ", fk_user_author"; |
|
| 98 | - $sql.= ", entity"; |
|
| 99 | - $sql.= ", import_key"; |
|
| 100 | - $sql.= ") VALUES ("; |
|
| 101 | - $sql.= "'".$this->db->escape($this->description)."'"; |
|
| 102 | - $sql.= ", ".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null'); |
|
| 103 | - $sql.= ", '".(isset($this->fk_element)?$this->fk_element:"null")."'"; |
|
| 104 | - $sql.= ", '".$this->db->escape($this->element_type)."'"; |
|
| 105 | - $sql.= ", '".(isset($this->fk_user_author)?$this->fk_user_author:"null")."'"; |
|
| 106 | - $sql.= ", ".(!empty($this->entity)?$this->entity:'1'); |
|
| 107 | - $sql.= ", ".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
| 108 | - $sql.= ")"; |
|
| 93 | + $sql .= "description"; |
|
| 94 | + $sql .= ", datec"; |
|
| 95 | + $sql .= ", fk_element"; |
|
| 96 | + $sql .= ", element_type"; |
|
| 97 | + $sql .= ", fk_user_author"; |
|
| 98 | + $sql .= ", entity"; |
|
| 99 | + $sql .= ", import_key"; |
|
| 100 | + $sql .= ") VALUES ("; |
|
| 101 | + $sql .= "'".$this->db->escape($this->description)."'"; |
|
| 102 | + $sql .= ", ".($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null'); |
|
| 103 | + $sql .= ", '".(isset($this->fk_element) ? $this->fk_element : "null")."'"; |
|
| 104 | + $sql .= ", '".$this->db->escape($this->element_type)."'"; |
|
| 105 | + $sql .= ", '".(isset($this->fk_user_author) ? $this->fk_user_author : "null")."'"; |
|
| 106 | + $sql .= ", ".(!empty($this->entity) ? $this->entity : '1'); |
|
| 107 | + $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); |
|
| 108 | + $sql .= ")"; |
|
| 109 | 109 | |
| 110 | 110 | //var_dump($this->db); |
| 111 | 111 | //echo $sql; |
@@ -113,17 +113,17 @@ discard block |
||
| 113 | 113 | $this->db->begin(); |
| 114 | 114 | |
| 115 | 115 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
| 116 | - $resql=$this->db->query($sql); |
|
| 117 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
| 116 | + $resql = $this->db->query($sql); |
|
| 117 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
| 118 | 118 | |
| 119 | - if (! $error) |
|
| 119 | + if (!$error) |
|
| 120 | 120 | { |
| 121 | 121 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment"); |
| 122 | 122 | |
| 123 | - if (! $notrigger) |
|
| 123 | + if (!$notrigger) |
|
| 124 | 124 | { |
| 125 | 125 | // Call trigger |
| 126 | - $result=$this->call_trigger('TASK_COMMENT_CREATE',$user); |
|
| 126 | + $result = $this->call_trigger('TASK_COMMENT_CREATE', $user); |
|
| 127 | 127 | if ($result < 0) { $error++; } |
| 128 | 128 | // End call triggers |
| 129 | 129 | } |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | // Commit or rollback |
| 133 | 133 | if ($error) |
| 134 | 134 | { |
| 135 | - foreach($this->errors as $errmsg) |
|
| 135 | + foreach ($this->errors as $errmsg) |
|
| 136 | 136 | { |
| 137 | 137 | dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
| 138 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 138 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 139 | 139 | } |
| 140 | 140 | $this->db->rollback(); |
| 141 | - return -1*$error; |
|
| 141 | + return -1 * $error; |
|
| 142 | 142 | } |
| 143 | 143 | else |
| 144 | 144 | { |
@@ -155,25 +155,25 @@ discard block |
||
| 155 | 155 | * @param int $ref ref object |
| 156 | 156 | * @return int <0 if KO, 0 if not found, >0 if OK |
| 157 | 157 | */ |
| 158 | - function fetch($id, $ref='') |
|
| 158 | + function fetch($id, $ref = '') |
|
| 159 | 159 | { |
| 160 | 160 | global $langs; |
| 161 | 161 | |
| 162 | 162 | $sql = "SELECT"; |
| 163 | - $sql.= " c.rowid,"; |
|
| 164 | - $sql.= " c.description,"; |
|
| 165 | - $sql.= " c.datec,"; |
|
| 166 | - $sql.= " c.tms,"; |
|
| 167 | - $sql.= " c.fk_element,"; |
|
| 168 | - $sql.= " c.element_type,"; |
|
| 169 | - $sql.= " c.fk_user_author,"; |
|
| 170 | - $sql.= " c.entity,"; |
|
| 171 | - $sql.= " c.import_key"; |
|
| 172 | - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
| 173 | - $sql.= " WHERE c.rowid = ".$id; |
|
| 163 | + $sql .= " c.rowid,"; |
|
| 164 | + $sql .= " c.description,"; |
|
| 165 | + $sql .= " c.datec,"; |
|
| 166 | + $sql .= " c.tms,"; |
|
| 167 | + $sql .= " c.fk_element,"; |
|
| 168 | + $sql .= " c.element_type,"; |
|
| 169 | + $sql .= " c.fk_user_author,"; |
|
| 170 | + $sql .= " c.entity,"; |
|
| 171 | + $sql .= " c.import_key"; |
|
| 172 | + $sql .= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
| 173 | + $sql .= " WHERE c.rowid = ".$id; |
|
| 174 | 174 | |
| 175 | 175 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
| 176 | - $resql=$this->db->query($sql); |
|
| 176 | + $resql = $this->db->query($sql); |
|
| 177 | 177 | if ($resql) |
| 178 | 178 | { |
| 179 | 179 | $num_rows = $this->db->num_rows($resql); |
@@ -182,14 +182,14 @@ discard block |
||
| 182 | 182 | { |
| 183 | 183 | $obj = $this->db->fetch_object($resql); |
| 184 | 184 | |
| 185 | - $this->id = $obj->rowid; |
|
| 186 | - $this->description = $obj->description; |
|
| 187 | - $this->element_type = $obj->element_type; |
|
| 188 | - $this->datec = $this->db->jdate($obj->datec); |
|
| 189 | - $this->tms = $obj->tms; |
|
| 190 | - $this->fk_user_author = $obj->fk_user_author; |
|
| 185 | + $this->id = $obj->rowid; |
|
| 186 | + $this->description = $obj->description; |
|
| 187 | + $this->element_type = $obj->element_type; |
|
| 188 | + $this->datec = $this->db->jdate($obj->datec); |
|
| 189 | + $this->tms = $obj->tms; |
|
| 190 | + $this->fk_user_author = $obj->fk_user_author; |
|
| 191 | 191 | $this->fk_element = $obj->fk_element; |
| 192 | - $this->entity = $obj->entity; |
|
| 192 | + $this->entity = $obj->entity; |
|
| 193 | 193 | $this->import_key = $obj->import_key; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | else |
| 202 | 202 | { |
| 203 | - $this->error="Error ".$this->db->lasterror(); |
|
| 203 | + $this->error = "Error ".$this->db->lasterror(); |
|
| 204 | 204 | return -1; |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -213,40 +213,40 @@ discard block |
||
| 213 | 213 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
| 214 | 214 | * @return int <=0 if KO, >0 if OK |
| 215 | 215 | */ |
| 216 | - function update(User $user, $notrigger=0) |
|
| 216 | + function update(User $user, $notrigger = 0) |
|
| 217 | 217 | { |
| 218 | 218 | global $conf, $langs; |
| 219 | - $error=0; |
|
| 219 | + $error = 0; |
|
| 220 | 220 | |
| 221 | 221 | // Clean parameters |
| 222 | - if (isset($this->fk_element)) $this->fk_project=(int) trim($this->fk_element); |
|
| 223 | - if (isset($this->fk_user_author)) $this->fk_user_author=(int) trim($this->fk_user_author); |
|
| 224 | - if (isset($this->description)) $this->description=trim($this->description); |
|
| 222 | + if (isset($this->fk_element)) $this->fk_project = (int) trim($this->fk_element); |
|
| 223 | + if (isset($this->fk_user_author)) $this->fk_user_author = (int) trim($this->fk_user_author); |
|
| 224 | + if (isset($this->description)) $this->description = trim($this->description); |
|
| 225 | 225 | |
| 226 | 226 | |
| 227 | 227 | // Update request |
| 228 | 228 | $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET"; |
| 229 | - $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; |
|
| 230 | - $sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').","; |
|
| 231 | - $sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").","; |
|
| 232 | - $sql.= " element_type='".$this->db->escape($this->element_type)."',"; |
|
| 233 | - $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; |
|
| 234 | - $sql.= " entity=".(!empty($this->entity)?$this->entity:'1').","; |
|
| 235 | - $sql.= " import_key=".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
| 236 | - $sql.= " WHERE rowid=".$this->id; |
|
| 229 | + $sql .= " description=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; |
|
| 230 | + $sql .= " datec=".($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null').","; |
|
| 231 | + $sql .= " fk_element=".(isset($this->fk_element) ? $this->fk_element : "null").","; |
|
| 232 | + $sql .= " element_type='".$this->db->escape($this->element_type)."',"; |
|
| 233 | + $sql .= " fk_user_author=".(isset($this->fk_user_author) ? $this->fk_user_author : "null").","; |
|
| 234 | + $sql .= " entity=".(!empty($this->entity) ? $this->entity : '1').","; |
|
| 235 | + $sql .= " import_key=".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); |
|
| 236 | + $sql .= " WHERE rowid=".$this->id; |
|
| 237 | 237 | |
| 238 | 238 | $this->db->begin(); |
| 239 | 239 | |
| 240 | 240 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
| 241 | 241 | $resql = $this->db->query($sql); |
| 242 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
| 242 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
| 243 | 243 | |
| 244 | - if (! $error) |
|
| 244 | + if (!$error) |
|
| 245 | 245 | { |
| 246 | - if (! $notrigger) |
|
| 246 | + if (!$notrigger) |
|
| 247 | 247 | { |
| 248 | 248 | // Call trigger |
| 249 | - $result=$this->call_trigger('TASK_COMMENT_MODIFY',$user); |
|
| 249 | + $result = $this->call_trigger('TASK_COMMENT_MODIFY', $user); |
|
| 250 | 250 | if ($result < 0) { $error++; } |
| 251 | 251 | // End call triggers |
| 252 | 252 | } |
@@ -255,13 +255,13 @@ discard block |
||
| 255 | 255 | // Commit or rollback |
| 256 | 256 | if ($error) |
| 257 | 257 | { |
| 258 | - foreach($this->errors as $errmsg) |
|
| 258 | + foreach ($this->errors as $errmsg) |
|
| 259 | 259 | { |
| 260 | 260 | dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
| 261 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 261 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 262 | 262 | } |
| 263 | 263 | $this->db->rollback(); |
| 264 | - return -1*$error; |
|
| 264 | + return -1 * $error; |
|
| 265 | 265 | } |
| 266 | 266 | else |
| 267 | 267 | { |
@@ -278,27 +278,27 @@ discard block |
||
| 278 | 278 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
| 279 | 279 | * @return int <0 if KO, >0 if OK |
| 280 | 280 | */ |
| 281 | - function delete($user, $notrigger=0) |
|
| 281 | + function delete($user, $notrigger = 0) |
|
| 282 | 282 | { |
| 283 | 283 | global $conf, $langs; |
| 284 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
| 284 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 285 | 285 | |
| 286 | - $error=0; |
|
| 286 | + $error = 0; |
|
| 287 | 287 | |
| 288 | 288 | $this->db->begin(); |
| 289 | 289 | |
| 290 | 290 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."comment"; |
| 291 | - $sql.= " WHERE rowid=".$this->id; |
|
| 291 | + $sql .= " WHERE rowid=".$this->id; |
|
| 292 | 292 | |
| 293 | 293 | $resql = $this->db->query($sql); |
| 294 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
| 294 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
| 295 | 295 | |
| 296 | - if (! $error) |
|
| 296 | + if (!$error) |
|
| 297 | 297 | { |
| 298 | - if (! $notrigger) |
|
| 298 | + if (!$notrigger) |
|
| 299 | 299 | { |
| 300 | 300 | // Call trigger |
| 301 | - $result=$this->call_trigger('TASK_COMMENT_DELETE',$user); |
|
| 301 | + $result = $this->call_trigger('TASK_COMMENT_DELETE', $user); |
|
| 302 | 302 | if ($result < 0) { $error++; } |
| 303 | 303 | // End call triggers |
| 304 | 304 | } |
@@ -307,14 +307,14 @@ discard block |
||
| 307 | 307 | // Commit or rollback |
| 308 | 308 | if ($error) |
| 309 | 309 | { |
| 310 | - foreach($this->errors as $errmsg) |
|
| 310 | + foreach ($this->errors as $errmsg) |
|
| 311 | 311 | { |
| 312 | 312 | dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
| 313 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 313 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 314 | 314 | } |
| 315 | 315 | $this->db->rollback(); |
| 316 | - return -1*$error; |
|
| 317 | - }else{ |
|
| 316 | + return -1 * $error; |
|
| 317 | + } else { |
|
| 318 | 318 | $this->db->commit(); |
| 319 | 319 | return 1; |
| 320 | 320 | } |
@@ -330,25 +330,25 @@ discard block |
||
| 330 | 330 | */ |
| 331 | 331 | public function fetchAllFor($element_type, $fk_element) |
| 332 | 332 | { |
| 333 | - global $db,$conf; |
|
| 333 | + global $db, $conf; |
|
| 334 | 334 | $this->comments = array(); |
| 335 | - if(!empty($element_type) && !empty($fk_element)) { |
|
| 335 | + if (!empty($element_type) && !empty($fk_element)) { |
|
| 336 | 336 | $sql = "SELECT"; |
| 337 | - $sql.= " c.rowid"; |
|
| 338 | - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
| 339 | - $sql.= " WHERE c.fk_element = ".$fk_element; |
|
| 340 | - $sql.= " AND c.element_type = '".$db->escape($element_type)."'"; |
|
| 341 | - $sql.= " AND c.entity = ".$conf->entity; |
|
| 342 | - $sql.= " ORDER BY c.tms DESC"; |
|
| 337 | + $sql .= " c.rowid"; |
|
| 338 | + $sql .= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
| 339 | + $sql .= " WHERE c.fk_element = ".$fk_element; |
|
| 340 | + $sql .= " AND c.element_type = '".$db->escape($element_type)."'"; |
|
| 341 | + $sql .= " AND c.entity = ".$conf->entity; |
|
| 342 | + $sql .= " ORDER BY c.tms DESC"; |
|
| 343 | 343 | |
| 344 | 344 | dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); |
| 345 | - $resql=$db->query($sql); |
|
| 345 | + $resql = $db->query($sql); |
|
| 346 | 346 | if ($resql) |
| 347 | 347 | { |
| 348 | 348 | $num_rows = $db->num_rows($resql); |
| 349 | 349 | if ($num_rows > 0) |
| 350 | 350 | { |
| 351 | - while($obj = $db->fetch_object($resql)) |
|
| 351 | + while ($obj = $db->fetch_object($resql)) |
|
| 352 | 352 | { |
| 353 | 353 | $comment = new self($db); |
| 354 | 354 | $comment->fetch($obj->rowid); |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | } |
| 358 | 358 | $db->free($resql); |
| 359 | 359 | } else { |
| 360 | - $this->errors[]="Error ".$this->db->lasterror(); |
|
| 360 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
| 361 | 361 | return -1; |
| 362 | 362 | } |
| 363 | 363 | } |
@@ -139,8 +139,7 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | $this->db->rollback(); |
| 141 | 141 | return -1*$error; |
| 142 | - } |
|
| 143 | - else |
|
| 142 | + } else |
|
| 144 | 143 | { |
| 145 | 144 | $this->db->commit(); |
| 146 | 145 | return $this->id; |
@@ -195,10 +194,12 @@ discard block |
||
| 195 | 194 | |
| 196 | 195 | $this->db->free($resql); |
| 197 | 196 | |
| 198 | - if ($num_rows) return 1; |
|
| 199 | - else return 0; |
|
| 200 | - } |
|
| 201 | - else |
|
| 197 | + if ($num_rows) { |
|
| 198 | + return 1; |
|
| 199 | + } else { |
|
| 200 | + return 0; |
|
| 201 | + } |
|
| 202 | + } else |
|
| 202 | 203 | { |
| 203 | 204 | $this->error="Error ".$this->db->lasterror(); |
| 204 | 205 | return -1; |
@@ -219,9 +220,15 @@ discard block |
||
| 219 | 220 | $error=0; |
| 220 | 221 | |
| 221 | 222 | // Clean parameters |
| 222 | - if (isset($this->fk_element)) $this->fk_project=(int) trim($this->fk_element); |
|
| 223 | - if (isset($this->fk_user_author)) $this->fk_user_author=(int) trim($this->fk_user_author); |
|
| 224 | - if (isset($this->description)) $this->description=trim($this->description); |
|
| 223 | + if (isset($this->fk_element)) { |
|
| 224 | + $this->fk_project=(int) trim($this->fk_element); |
|
| 225 | + } |
|
| 226 | + if (isset($this->fk_user_author)) { |
|
| 227 | + $this->fk_user_author=(int) trim($this->fk_user_author); |
|
| 228 | + } |
|
| 229 | + if (isset($this->description)) { |
|
| 230 | + $this->description=trim($this->description); |
|
| 231 | + } |
|
| 225 | 232 | |
| 226 | 233 | |
| 227 | 234 | // Update request |
@@ -262,8 +269,7 @@ discard block |
||
| 262 | 269 | } |
| 263 | 270 | $this->db->rollback(); |
| 264 | 271 | return -1*$error; |
| 265 | - } |
|
| 266 | - else |
|
| 272 | + } else |
|
| 267 | 273 | { |
| 268 | 274 | $this->db->commit(); |
| 269 | 275 | return 1; |
@@ -314,7 +320,7 @@ discard block |
||
| 314 | 320 | } |
| 315 | 321 | $this->db->rollback(); |
| 316 | 322 | return -1*$error; |
| 317 | - }else{ |
|
| 323 | + } else{ |
|
| 318 | 324 | $this->db->commit(); |
| 319 | 325 | return 1; |
| 320 | 326 | } |
@@ -35,15 +35,15 @@ discard block |
||
| 35 | 35 | public $db; |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * @var string Error code (or message) |
|
| 39 | - */ |
|
| 40 | - public $error=''; |
|
| 38 | + * @var string Error code (or message) |
|
| 39 | + */ |
|
| 40 | + public $error=''; |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * Constructor |
|
| 45 | - * |
|
| 46 | - * @param DoliDB $db Database handler |
|
| 44 | + * Constructor |
|
| 45 | + * |
|
| 46 | + * @param DoliDB $db Database handler |
|
| 47 | 47 | */ |
| 48 | 48 | function __construct($db) |
| 49 | 49 | { |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | '50' => $langs->trans("ActionRunningShort"), |
| 76 | 76 | '100' => $langs->trans("ActionDoneShort") |
| 77 | 77 | ); |
| 78 | - // +ActionUncomplete |
|
| 78 | + // +ActionUncomplete |
|
| 79 | 79 | |
| 80 | 80 | if (! empty($conf->use_javascript_ajax)) |
| 81 | 81 | { |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | if (! empty($conf->use_javascript_ajax) || $onlyselect) |
| 129 | 129 | { |
| 130 | - //var_dump($selected); |
|
| 131 | - if ($selected == 'done') $selected='100'; |
|
| 130 | + //var_dump($selected); |
|
| 131 | + if ($selected == 'done') $selected='100'; |
|
| 132 | 132 | print '<select '.($canedit?'':'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'">'; |
| 133 | 133 | if ($showempty) print '<option value=""'.($selected == ''?' selected':'').'></option>'; |
| 134 | 134 | foreach($listofstatus as $key => $val) |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>'; |
| 137 | 137 | if ($key == '50' && $onlyselect == 2) |
| 138 | 138 | { |
| 139 | - print '<option value="todo"'.($selected == 'todo' ? ' selected' : '').'>'.$langs->trans("ActionUncomplete").' ('.$langs->trans("ActionsToDoShort")."+".$langs->trans("ActionRunningShort").')</option>'; |
|
| 139 | + print '<option value="todo"'.($selected == 'todo' ? ' selected' : '').'>'.$langs->trans("ActionUncomplete").' ('.$langs->trans("ActionsToDoShort")."+".$langs->trans("ActionRunningShort").')</option>'; |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | print '</select>'; |
@@ -144,12 +144,12 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | if (empty($onlyselect)) |
| 146 | 146 | { |
| 147 | - print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled').'>'; |
|
| 148 | - print '<span class="hideonsmartphone hideifna">%</span>'; |
|
| 147 | + print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled').'>'; |
|
| 148 | + print '<span class="hideonsmartphone hideifna">%</span>'; |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | else |
| 152 | - { |
|
| 152 | + { |
|
| 153 | 153 | print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled').'>%'; |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -179,18 +179,18 @@ discard block |
||
| 179 | 179 | $sortorder='DESC,DESC'; |
| 180 | 180 | |
| 181 | 181 | $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0)); |
| 182 | - if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); |
|
| 182 | + if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); |
|
| 183 | 183 | |
| 184 | 184 | $num = count($listofactions); |
| 185 | 185 | if ($num || $forceshowtitle) |
| 186 | 186 | { |
| 187 | - if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); |
|
| 188 | - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); |
|
| 189 | - elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); |
|
| 190 | - elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); |
|
| 191 | - elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); |
|
| 192 | - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); |
|
| 193 | - elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); |
|
| 187 | + if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); |
|
| 188 | + elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); |
|
| 189 | + elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); |
|
| 190 | + elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); |
|
| 191 | + elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); |
|
| 192 | + elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); |
|
| 193 | + elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); |
|
| 194 | 194 | elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); |
| 195 | 195 | elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
| 196 | 196 | elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
@@ -203,111 +203,111 @@ discard block |
||
| 203 | 203 | if ($typeelement == 'project') $projectid = $object->id; |
| 204 | 204 | |
| 205 | 205 | $newcardbutton=''; |
| 206 | - if (! empty($conf->agenda->enabled)) |
|
| 207 | - { |
|
| 208 | - $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(),'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid>0?'&socid='.$object->socid:($socid>0?'&socid='.$socid:'')).($projectid>0?'&projectid='.$projectid:'').'&backtopage='.urlencode($urlbacktopage).'"><span class="valignmiddle">'.$langs->trans("AddEvent").'</span>'; |
|
| 209 | - $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
| 210 | - $newcardbutton.= '</a>'; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - print '<!-- formactions->showactions -->'."\n"; |
|
| 214 | - print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlright); |
|
| 215 | - |
|
| 216 | - $page=0; $param=''; |
|
| 217 | - |
|
| 218 | - $total = 0; |
|
| 219 | - |
|
| 220 | - print '<div class="div-table-responsive-no-min">'; |
|
| 221 | - print '<table class="noborder'.($morecss?' '.$morecss:'').'" width="100%">'; |
|
| 222 | - print '<tr class="liste_titre">'; |
|
| 223 | - print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 224 | - print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 225 | - print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 226 | - print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 227 | - print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); |
|
| 228 | - print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); |
|
| 229 | - print '</tr>'; |
|
| 230 | - print "\n"; |
|
| 231 | - |
|
| 232 | - $userstatic = new User($this->db); |
|
| 233 | - |
|
| 234 | - if (count($listofactions)) |
|
| 235 | - { |
|
| 236 | - $cursorevent = 0; |
|
| 237 | - foreach($listofactions as $action) |
|
| 238 | - { |
|
| 239 | - if ($max && $cursorevent >= $max) break; |
|
| 240 | - |
|
| 241 | - $ref=$action->getNomUrl(1,-1); |
|
| 242 | - $label=$action->getNomUrl(0,38); |
|
| 243 | - |
|
| 244 | - print '<tr class="oddeven">'; |
|
| 245 | - // Ref |
|
| 246 | - print '<td>'.$ref.'</td>'; |
|
| 247 | - // Onwer |
|
| 248 | - print '<td>'; |
|
| 249 | - if (! empty($action->userownerid)) |
|
| 250 | - { |
|
| 251 | - $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched |
|
| 252 | - print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', ''); |
|
| 253 | - } |
|
| 254 | - print '</td>'; |
|
| 255 | - // Type |
|
| 256 | - print '<td>'; |
|
| 257 | - $imgpicto=''; |
|
| 258 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
| 259 | - { |
|
| 260 | - if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto); |
|
| 261 | - else { |
|
| 262 | - if ($action->type_code == 'AC_RDV') $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
| 263 | - elseif ($action->type_code == 'AC_TEL') $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
| 264 | - elseif ($action->type_code == 'AC_FAX') $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
| 265 | - elseif ($action->type_code == 'AC_EMAIL') $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
| 266 | - elseif ($action->type_code == 'AC_INT') $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
| 267 | - elseif (! preg_match('/_AUTO/', $action->type_code)) $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - print $imgpicto; |
|
| 271 | - print $action->type_short ? $action->type_short : $action->type; |
|
| 272 | - print '</td>'; |
|
| 273 | - // Label |
|
| 274 | - print '<td>'.$label.'</td>'; |
|
| 275 | - // Date |
|
| 276 | - print '<td align="center">'.dol_print_date($action->datep, 'dayhour', 'tzuserrel'); |
|
| 277 | - if ($action->datef) |
|
| 278 | - { |
|
| 279 | - $tmpa=dol_getdate($action->datep); |
|
| 280 | - $tmpb=dol_getdate($action->datef); |
|
| 281 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) |
|
| 282 | - { |
|
| 283 | - if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
|
| 284 | - } |
|
| 285 | - else print '-'.dol_print_date($action->datef, 'dayhour', 'tzuserrel'); |
|
| 286 | - } |
|
| 287 | - print '</td>'; |
|
| 288 | - print '<td align="right">'; |
|
| 289 | - if (! empty($action->author->id)) |
|
| 290 | - { |
|
| 291 | - print $action->getLibStatut(3); |
|
| 292 | - } |
|
| 293 | - print '</td>'; |
|
| 294 | - print '</tr>'; |
|
| 295 | - |
|
| 296 | - $cursorevent++; |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - else |
|
| 300 | - { |
|
| 301 | - print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - if ($max && $num > $max) |
|
| 305 | - { |
|
| 306 | - print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("More").'...</td></tr>'; |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - print '</table>'; |
|
| 310 | - print '</div>'; |
|
| 206 | + if (! empty($conf->agenda->enabled)) |
|
| 207 | + { |
|
| 208 | + $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(),'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid>0?'&socid='.$object->socid:($socid>0?'&socid='.$socid:'')).($projectid>0?'&projectid='.$projectid:'').'&backtopage='.urlencode($urlbacktopage).'"><span class="valignmiddle">'.$langs->trans("AddEvent").'</span>'; |
|
| 209 | + $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
| 210 | + $newcardbutton.= '</a>'; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + print '<!-- formactions->showactions -->'."\n"; |
|
| 214 | + print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlright); |
|
| 215 | + |
|
| 216 | + $page=0; $param=''; |
|
| 217 | + |
|
| 218 | + $total = 0; |
|
| 219 | + |
|
| 220 | + print '<div class="div-table-responsive-no-min">'; |
|
| 221 | + print '<table class="noborder'.($morecss?' '.$morecss:'').'" width="100%">'; |
|
| 222 | + print '<tr class="liste_titre">'; |
|
| 223 | + print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 224 | + print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 225 | + print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 226 | + print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 227 | + print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); |
|
| 228 | + print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); |
|
| 229 | + print '</tr>'; |
|
| 230 | + print "\n"; |
|
| 231 | + |
|
| 232 | + $userstatic = new User($this->db); |
|
| 233 | + |
|
| 234 | + if (count($listofactions)) |
|
| 235 | + { |
|
| 236 | + $cursorevent = 0; |
|
| 237 | + foreach($listofactions as $action) |
|
| 238 | + { |
|
| 239 | + if ($max && $cursorevent >= $max) break; |
|
| 240 | + |
|
| 241 | + $ref=$action->getNomUrl(1,-1); |
|
| 242 | + $label=$action->getNomUrl(0,38); |
|
| 243 | + |
|
| 244 | + print '<tr class="oddeven">'; |
|
| 245 | + // Ref |
|
| 246 | + print '<td>'.$ref.'</td>'; |
|
| 247 | + // Onwer |
|
| 248 | + print '<td>'; |
|
| 249 | + if (! empty($action->userownerid)) |
|
| 250 | + { |
|
| 251 | + $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched |
|
| 252 | + print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', ''); |
|
| 253 | + } |
|
| 254 | + print '</td>'; |
|
| 255 | + // Type |
|
| 256 | + print '<td>'; |
|
| 257 | + $imgpicto=''; |
|
| 258 | + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
| 259 | + { |
|
| 260 | + if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto); |
|
| 261 | + else { |
|
| 262 | + if ($action->type_code == 'AC_RDV') $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
| 263 | + elseif ($action->type_code == 'AC_TEL') $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
| 264 | + elseif ($action->type_code == 'AC_FAX') $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
| 265 | + elseif ($action->type_code == 'AC_EMAIL') $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
| 266 | + elseif ($action->type_code == 'AC_INT') $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
| 267 | + elseif (! preg_match('/_AUTO/', $action->type_code)) $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + print $imgpicto; |
|
| 271 | + print $action->type_short ? $action->type_short : $action->type; |
|
| 272 | + print '</td>'; |
|
| 273 | + // Label |
|
| 274 | + print '<td>'.$label.'</td>'; |
|
| 275 | + // Date |
|
| 276 | + print '<td align="center">'.dol_print_date($action->datep, 'dayhour', 'tzuserrel'); |
|
| 277 | + if ($action->datef) |
|
| 278 | + { |
|
| 279 | + $tmpa=dol_getdate($action->datep); |
|
| 280 | + $tmpb=dol_getdate($action->datef); |
|
| 281 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) |
|
| 282 | + { |
|
| 283 | + if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
|
| 284 | + } |
|
| 285 | + else print '-'.dol_print_date($action->datef, 'dayhour', 'tzuserrel'); |
|
| 286 | + } |
|
| 287 | + print '</td>'; |
|
| 288 | + print '<td align="right">'; |
|
| 289 | + if (! empty($action->author->id)) |
|
| 290 | + { |
|
| 291 | + print $action->getLibStatut(3); |
|
| 292 | + } |
|
| 293 | + print '</td>'; |
|
| 294 | + print '</tr>'; |
|
| 295 | + |
|
| 296 | + $cursorevent++; |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + else |
|
| 300 | + { |
|
| 301 | + print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + if ($max && $num > $max) |
|
| 305 | + { |
|
| 306 | + print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("More").'...</td></tr>'; |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + print '</table>'; |
|
| 310 | + print '</div>'; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | return $num; |
@@ -338,27 +338,27 @@ discard block |
||
| 338 | 338 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
| 339 | 339 | $caction=new CActionComm($this->db); |
| 340 | 340 | |
| 341 | - // Suggest a list with manual events or all auto events |
|
| 342 | - $arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot); |
|
| 343 | - array_unshift($arraylist,' '); // Add empty line at start |
|
| 344 | - //asort($arraylist); |
|
| 341 | + // Suggest a list with manual events or all auto events |
|
| 342 | + $arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot); |
|
| 343 | + array_unshift($arraylist,' '); // Add empty line at start |
|
| 344 | + //asort($arraylist); |
|
| 345 | 345 | |
| 346 | - if ($selected == 'manual') $selected='AC_OTH'; |
|
| 347 | - if ($selected == 'auto') $selected='AC_OTH_AUTO'; |
|
| 346 | + if ($selected == 'manual') $selected='AC_OTH'; |
|
| 347 | + if ($selected == 'auto') $selected='AC_OTH_AUTO'; |
|
| 348 | 348 | |
| 349 | - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
| 349 | + if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
| 350 | 350 | |
| 351 | - $out=''; |
|
| 351 | + $out=''; |
|
| 352 | 352 | |
| 353 | - if (! empty($multiselect)) |
|
| 354 | - { |
|
| 355 | - if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); |
|
| 356 | - $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
|
| 357 | - } |
|
| 358 | - else |
|
| 359 | - { |
|
| 360 | - $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
|
| 361 | - } |
|
| 353 | + if (! empty($multiselect)) |
|
| 354 | + { |
|
| 355 | + if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); |
|
| 356 | + $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
|
| 357 | + } |
|
| 358 | + else |
|
| 359 | + { |
|
| 360 | + $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | 363 | if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) |
| 364 | 364 | { |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * @var string Error code (or message) |
| 39 | 39 | */ |
| 40 | - public $error=''; |
|
| 40 | + public $error = ''; |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | * @param string $morecss More css on select field |
| 65 | 65 | * @return void |
| 66 | 66 | */ |
| 67 | - function form_select_status_action($formname, $selected, $canedit=1, $htmlname='complete', $showempty=0, $onlyselect=0, $morecss='maxwidth100') |
|
| 67 | + function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100') |
|
| 68 | 68 | { |
| 69 | 69 | // phpcs:enable |
| 70 | - global $langs,$conf; |
|
| 70 | + global $langs, $conf; |
|
| 71 | 71 | |
| 72 | 72 | $listofstatus = array( |
| 73 | 73 | '-1' => $langs->trans("ActionNotApplicable"), |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | ); |
| 78 | 78 | // +ActionUncomplete |
| 79 | 79 | |
| 80 | - if (! empty($conf->use_javascript_ajax)) |
|
| 80 | + if (!empty($conf->use_javascript_ajax)) |
|
| 81 | 81 | { |
| 82 | 82 | print "\n"; |
| 83 | 83 | print "<script type=\"text/javascript\"> |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | function select_status() { |
| 99 | 99 | var defaultvalue = $('#select' + htmlname).val(); |
| 100 | 100 | var percentage = $('input[name=percentage]'); |
| 101 | - var selected = '".(isset($selected)?$selected:'')."'; |
|
| 101 | + var selected = '".(isset($selected) ? $selected : '')."'; |
|
| 102 | 102 | var value = (selected>0?selected:(defaultvalue>=0?defaultvalue:'')); |
| 103 | 103 | |
| 104 | 104 | percentage.val(value); |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | </script>\n"; |
| 127 | 127 | } |
| 128 | - if (! empty($conf->use_javascript_ajax) || $onlyselect) |
|
| 128 | + if (!empty($conf->use_javascript_ajax) || $onlyselect) |
|
| 129 | 129 | { |
| 130 | 130 | //var_dump($selected); |
| 131 | - if ($selected == 'done') $selected='100'; |
|
| 132 | - print '<select '.($canedit?'':'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'">'; |
|
| 133 | - if ($showempty) print '<option value=""'.($selected == ''?' selected':'').'></option>'; |
|
| 134 | - foreach($listofstatus as $key => $val) |
|
| 131 | + if ($selected == 'done') $selected = '100'; |
|
| 132 | + print '<select '.($canedit ? '' : 'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">'; |
|
| 133 | + if ($showempty) print '<option value=""'.($selected == '' ? ' selected' : '').'></option>'; |
|
| 134 | + foreach ($listofstatus as $key => $val) |
|
| 135 | 135 | { |
| 136 | 136 | print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>'; |
| 137 | 137 | if ($key == '50' && $onlyselect == 2) |
@@ -140,17 +140,17 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | print '</select>'; |
| 143 | - if ($selected == 0 || $selected == 100) $canedit=0; |
|
| 143 | + if ($selected == 0 || $selected == 100) $canedit = 0; |
|
| 144 | 144 | |
| 145 | 145 | if (empty($onlyselect)) |
| 146 | 146 | { |
| 147 | - print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled').'>'; |
|
| 147 | + print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit && ($selected >= 0) ? '' : ' disabled').'>'; |
|
| 148 | 148 | print '<span class="hideonsmartphone hideifna">%</span>'; |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | else |
| 152 | 152 | { |
| 153 | - print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled').'>%'; |
|
| 153 | + print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit ? '' : ' disabled').'>%'; |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
@@ -168,64 +168,64 @@ discard block |
||
| 168 | 168 | * @param string $morehtmlright More html text on right of title line |
| 169 | 169 | * @return int <0 if KO, >=0 if OK |
| 170 | 170 | */ |
| 171 | - function showactions($object, $typeelement, $socid=0, $forceshowtitle=0, $morecss='listactions', $max=0, $moreparambacktopage='', $morehtmlright='') |
|
| 171 | + function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlright = '') |
|
| 172 | 172 | { |
| 173 | - global $langs,$conf,$user; |
|
| 173 | + global $langs, $conf, $user; |
|
| 174 | 174 | global $bc; |
| 175 | 175 | |
| 176 | 176 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
| 177 | 177 | |
| 178 | - $sortfield='a.datep,a.id'; |
|
| 179 | - $sortorder='DESC,DESC'; |
|
| 178 | + $sortfield = 'a.datep,a.id'; |
|
| 179 | + $sortorder = 'DESC,DESC'; |
|
| 180 | 180 | |
| 181 | - $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0)); |
|
| 182 | - if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); |
|
| 181 | + $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0)); |
|
| 182 | + if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions'); |
|
| 183 | 183 | |
| 184 | 184 | $num = count($listofactions); |
| 185 | 185 | if ($num || $forceshowtitle) |
| 186 | 186 | { |
| 187 | - if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); |
|
| 188 | - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); |
|
| 189 | - elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); |
|
| 190 | - elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); |
|
| 191 | - elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); |
|
| 192 | - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); |
|
| 193 | - elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); |
|
| 194 | - elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); |
|
| 195 | - elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
| 196 | - elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
| 197 | - elseif ($typeelement == 'member') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
| 198 | - else $title=$langs->trans("LatestLinkedEvents", $max?$max:''); |
|
| 199 | - |
|
| 200 | - $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); |
|
| 187 | + if ($typeelement == 'invoice') $title = $langs->trans('ActionsOnBill'); |
|
| 188 | + elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill'); |
|
| 189 | + elseif ($typeelement == 'propal') $title = $langs->trans('ActionsOnPropal'); |
|
| 190 | + elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal'); |
|
| 191 | + elseif ($typeelement == 'order') $title = $langs->trans('ActionsOnOrder'); |
|
| 192 | + elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title = $langs->trans('ActionsOnOrder'); |
|
| 193 | + elseif ($typeelement == 'shipping') $title = $langs->trans('ActionsOnShipping'); |
|
| 194 | + elseif ($typeelement == 'fichinter') $title = $langs->trans('ActionsOnFicheInter'); |
|
| 195 | + elseif ($typeelement == 'project') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
| 196 | + elseif ($typeelement == 'task') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
| 197 | + elseif ($typeelement == 'member') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
| 198 | + else $title = $langs->trans("LatestLinkedEvents", $max ? $max : ''); |
|
| 199 | + |
|
| 200 | + $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : ''); |
|
| 201 | 201 | |
| 202 | 202 | $projectid = $object->fk_project; |
| 203 | 203 | if ($typeelement == 'project') $projectid = $object->id; |
| 204 | 204 | |
| 205 | - $newcardbutton=''; |
|
| 206 | - if (! empty($conf->agenda->enabled)) |
|
| 205 | + $newcardbutton = ''; |
|
| 206 | + if (!empty($conf->agenda->enabled)) |
|
| 207 | 207 | { |
| 208 | - $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(),'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid>0?'&socid='.$object->socid:($socid>0?'&socid='.$socid:'')).($projectid>0?'&projectid='.$projectid:'').'&backtopage='.urlencode($urlbacktopage).'"><span class="valignmiddle">'.$langs->trans("AddEvent").'</span>'; |
|
| 209 | - $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
| 210 | - $newcardbutton.= '</a>'; |
|
| 208 | + $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage).'"><span class="valignmiddle">'.$langs->trans("AddEvent").'</span>'; |
|
| 209 | + $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
| 210 | + $newcardbutton .= '</a>'; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | print '<!-- formactions->showactions -->'."\n"; |
| 214 | 214 | print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlright); |
| 215 | 215 | |
| 216 | - $page=0; $param=''; |
|
| 216 | + $page = 0; $param = ''; |
|
| 217 | 217 | |
| 218 | 218 | $total = 0; |
| 219 | 219 | |
| 220 | 220 | print '<div class="div-table-responsive-no-min">'; |
| 221 | - print '<table class="noborder'.($morecss?' '.$morecss:'').'" width="100%">'; |
|
| 221 | + print '<table class="noborder'.($morecss ? ' '.$morecss : '').'" width="100%">'; |
|
| 222 | 222 | print '<tr class="liste_titre">'; |
| 223 | - print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 224 | - print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 225 | - print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 223 | + print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 224 | + print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 225 | + print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
| 226 | 226 | print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
| 227 | - print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); |
|
| 228 | - print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); |
|
| 227 | + print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); |
|
| 228 | + print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); |
|
| 229 | 229 | print '</tr>'; |
| 230 | 230 | print "\n"; |
| 231 | 231 | |
@@ -234,37 +234,37 @@ discard block |
||
| 234 | 234 | if (count($listofactions)) |
| 235 | 235 | { |
| 236 | 236 | $cursorevent = 0; |
| 237 | - foreach($listofactions as $action) |
|
| 237 | + foreach ($listofactions as $action) |
|
| 238 | 238 | { |
| 239 | 239 | if ($max && $cursorevent >= $max) break; |
| 240 | 240 | |
| 241 | - $ref=$action->getNomUrl(1,-1); |
|
| 242 | - $label=$action->getNomUrl(0,38); |
|
| 241 | + $ref = $action->getNomUrl(1, -1); |
|
| 242 | + $label = $action->getNomUrl(0, 38); |
|
| 243 | 243 | |
| 244 | 244 | print '<tr class="oddeven">'; |
| 245 | 245 | // Ref |
| 246 | 246 | print '<td>'.$ref.'</td>'; |
| 247 | 247 | // Onwer |
| 248 | 248 | print '<td>'; |
| 249 | - if (! empty($action->userownerid)) |
|
| 249 | + if (!empty($action->userownerid)) |
|
| 250 | 250 | { |
| 251 | - $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched |
|
| 251 | + $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched |
|
| 252 | 252 | print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', ''); |
| 253 | 253 | } |
| 254 | 254 | print '</td>'; |
| 255 | 255 | // Type |
| 256 | 256 | print '<td>'; |
| 257 | - $imgpicto=''; |
|
| 258 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
| 257 | + $imgpicto = ''; |
|
| 258 | + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
| 259 | 259 | { |
| 260 | - if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto); |
|
| 260 | + if ($action->type_picto) $imgpicto = img_picto('', $action->type_picto); |
|
| 261 | 261 | else { |
| 262 | - if ($action->type_code == 'AC_RDV') $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
| 263 | - elseif ($action->type_code == 'AC_TEL') $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
| 264 | - elseif ($action->type_code == 'AC_FAX') $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
| 265 | - elseif ($action->type_code == 'AC_EMAIL') $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
| 266 | - elseif ($action->type_code == 'AC_INT') $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
| 267 | - elseif (! preg_match('/_AUTO/', $action->type_code)) $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
| 262 | + if ($action->type_code == 'AC_RDV') $imgpicto = img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
| 263 | + elseif ($action->type_code == 'AC_TEL') $imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
| 264 | + elseif ($action->type_code == 'AC_FAX') $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
| 265 | + elseif ($action->type_code == 'AC_EMAIL') $imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
| 266 | + elseif ($action->type_code == 'AC_INT') $imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
| 267 | + elseif (!preg_match('/_AUTO/', $action->type_code)) $imgpicto = img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | print $imgpicto; |
@@ -276,8 +276,8 @@ discard block |
||
| 276 | 276 | print '<td align="center">'.dol_print_date($action->datep, 'dayhour', 'tzuserrel'); |
| 277 | 277 | if ($action->datef) |
| 278 | 278 | { |
| 279 | - $tmpa=dol_getdate($action->datep); |
|
| 280 | - $tmpb=dol_getdate($action->datef); |
|
| 279 | + $tmpa = dol_getdate($action->datep); |
|
| 280 | + $tmpb = dol_getdate($action->datef); |
|
| 281 | 281 | if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) |
| 282 | 282 | { |
| 283 | 283 | if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | print '</td>'; |
| 288 | 288 | print '<td align="right">'; |
| 289 | - if (! empty($action->author->id)) |
|
| 289 | + if (!empty($action->author->id)) |
|
| 290 | 290 | { |
| 291 | 291 | print $action->getLibStatut(3); |
| 292 | 292 | } |
@@ -327,42 +327,42 @@ discard block |
||
| 327 | 327 | * @param int $nooutput 1=No output |
| 328 | 328 | * @return string |
| 329 | 329 | */ |
| 330 | - function select_type_actions($selected='', $htmlname='actioncode', $excludetype='', $onlyautoornot=0, $hideinfohelp=0, $multiselect=0, $nooutput=0) |
|
| 330 | + function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0) |
|
| 331 | 331 | { |
| 332 | 332 | // phpcs:enable |
| 333 | - global $langs,$user,$form,$conf; |
|
| 333 | + global $langs, $user, $form, $conf; |
|
| 334 | 334 | |
| 335 | - if (! is_object($form)) $form=new Form($this->db); |
|
| 335 | + if (!is_object($form)) $form = new Form($this->db); |
|
| 336 | 336 | |
| 337 | 337 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; |
| 338 | 338 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
| 339 | - $caction=new CActionComm($this->db); |
|
| 339 | + $caction = new CActionComm($this->db); |
|
| 340 | 340 | |
| 341 | 341 | // Suggest a list with manual events or all auto events |
| 342 | - $arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot); |
|
| 343 | - array_unshift($arraylist,' '); // Add empty line at start |
|
| 342 | + $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot); |
|
| 343 | + array_unshift($arraylist, ' '); // Add empty line at start |
|
| 344 | 344 | //asort($arraylist); |
| 345 | 345 | |
| 346 | - if ($selected == 'manual') $selected='AC_OTH'; |
|
| 347 | - if ($selected == 'auto') $selected='AC_OTH_AUTO'; |
|
| 346 | + if ($selected == 'manual') $selected = 'AC_OTH'; |
|
| 347 | + if ($selected == 'auto') $selected = 'AC_OTH_AUTO'; |
|
| 348 | 348 | |
| 349 | - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
| 349 | + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
| 350 | 350 | |
| 351 | - $out=''; |
|
| 351 | + $out = ''; |
|
| 352 | 352 | |
| 353 | - if (! empty($multiselect)) |
|
| 353 | + if (!empty($multiselect)) |
|
| 354 | 354 | { |
| 355 | 355 | if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); |
| 356 | - $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
|
| 356 | + $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
|
| 357 | 357 | } |
| 358 | 358 | else |
| 359 | 359 | { |
| 360 | - $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
|
| 360 | + $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) |
| 364 | 364 | { |
| 365 | - $out.=info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''),1); |
|
| 365 | + $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | if ($nooutput) return $out; |
@@ -128,9 +128,13 @@ discard block |
||
| 128 | 128 | if (! empty($conf->use_javascript_ajax) || $onlyselect) |
| 129 | 129 | { |
| 130 | 130 | //var_dump($selected); |
| 131 | - if ($selected == 'done') $selected='100'; |
|
| 131 | + if ($selected == 'done') { |
|
| 132 | + $selected='100'; |
|
| 133 | + } |
|
| 132 | 134 | print '<select '.($canedit?'':'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'">'; |
| 133 | - if ($showempty) print '<option value=""'.($selected == ''?' selected':'').'></option>'; |
|
| 135 | + if ($showempty) { |
|
| 136 | + print '<option value=""'.($selected == ''?' selected':'').'></option>'; |
|
| 137 | + } |
|
| 134 | 138 | foreach($listofstatus as $key => $val) |
| 135 | 139 | { |
| 136 | 140 | print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>'; |
@@ -140,15 +144,16 @@ discard block |
||
| 140 | 144 | } |
| 141 | 145 | } |
| 142 | 146 | print '</select>'; |
| 143 | - if ($selected == 0 || $selected == 100) $canedit=0; |
|
| 147 | + if ($selected == 0 || $selected == 100) { |
|
| 148 | + $canedit=0; |
|
| 149 | + } |
|
| 144 | 150 | |
| 145 | 151 | if (empty($onlyselect)) |
| 146 | 152 | { |
| 147 | 153 | print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled').'>'; |
| 148 | 154 | print '<span class="hideonsmartphone hideifna">%</span>'; |
| 149 | 155 | } |
| 150 | - } |
|
| 151 | - else |
|
| 156 | + } else |
|
| 152 | 157 | { |
| 153 | 158 | print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled').'>%'; |
| 154 | 159 | } |
@@ -179,28 +184,45 @@ discard block |
||
| 179 | 184 | $sortorder='DESC,DESC'; |
| 180 | 185 | |
| 181 | 186 | $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0)); |
| 182 | - if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); |
|
| 187 | + if (! is_array($listofactions)) { |
|
| 188 | + dol_print_error($this->db,'FailedToGetActions'); |
|
| 189 | + } |
|
| 183 | 190 | |
| 184 | 191 | $num = count($listofactions); |
| 185 | 192 | if ($num || $forceshowtitle) |
| 186 | 193 | { |
| 187 | - if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); |
|
| 188 | - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); |
|
| 189 | - elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); |
|
| 190 | - elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); |
|
| 191 | - elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); |
|
| 192 | - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); |
|
| 193 | - elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); |
|
| 194 | - elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); |
|
| 195 | - elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
| 196 | - elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
| 197 | - elseif ($typeelement == 'member') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
| 198 | - else $title=$langs->trans("LatestLinkedEvents", $max?$max:''); |
|
| 194 | + if ($typeelement == 'invoice') { |
|
| 195 | + $title=$langs->trans('ActionsOnBill'); |
|
| 196 | + } elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') { |
|
| 197 | + $title=$langs->trans('ActionsOnBill'); |
|
| 198 | + } elseif ($typeelement == 'propal') { |
|
| 199 | + $title=$langs->trans('ActionsOnPropal'); |
|
| 200 | + } elseif ($typeelement == 'supplier_proposal') { |
|
| 201 | + $title=$langs->trans('ActionsOnSupplierProposal'); |
|
| 202 | + } elseif ($typeelement == 'order') { |
|
| 203 | + $title=$langs->trans('ActionsOnOrder'); |
|
| 204 | + } elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') { |
|
| 205 | + $title=$langs->trans('ActionsOnOrder'); |
|
| 206 | + } elseif ($typeelement == 'shipping') { |
|
| 207 | + $title=$langs->trans('ActionsOnShipping'); |
|
| 208 | + } elseif ($typeelement == 'fichinter') { |
|
| 209 | + $title=$langs->trans('ActionsOnFicheInter'); |
|
| 210 | + } elseif ($typeelement == 'project') { |
|
| 211 | + $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
| 212 | + } elseif ($typeelement == 'task') { |
|
| 213 | + $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
| 214 | + } elseif ($typeelement == 'member') { |
|
| 215 | + $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
| 216 | + } else { |
|
| 217 | + $title=$langs->trans("LatestLinkedEvents", $max?$max:''); |
|
| 218 | + } |
|
| 199 | 219 | |
| 200 | 220 | $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); |
| 201 | 221 | |
| 202 | 222 | $projectid = $object->fk_project; |
| 203 | - if ($typeelement == 'project') $projectid = $object->id; |
|
| 223 | + if ($typeelement == 'project') { |
|
| 224 | + $projectid = $object->id; |
|
| 225 | + } |
|
| 204 | 226 | |
| 205 | 227 | $newcardbutton=''; |
| 206 | 228 | if (! empty($conf->agenda->enabled)) |
@@ -236,7 +258,9 @@ discard block |
||
| 236 | 258 | $cursorevent = 0; |
| 237 | 259 | foreach($listofactions as $action) |
| 238 | 260 | { |
| 239 | - if ($max && $cursorevent >= $max) break; |
|
| 261 | + if ($max && $cursorevent >= $max) { |
|
| 262 | + break; |
|
| 263 | + } |
|
| 240 | 264 | |
| 241 | 265 | $ref=$action->getNomUrl(1,-1); |
| 242 | 266 | $label=$action->getNomUrl(0,38); |
@@ -257,14 +281,22 @@ discard block |
||
| 257 | 281 | $imgpicto=''; |
| 258 | 282 | if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
| 259 | 283 | { |
| 260 | - if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto); |
|
| 261 | - else { |
|
| 262 | - if ($action->type_code == 'AC_RDV') $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
| 263 | - elseif ($action->type_code == 'AC_TEL') $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
| 264 | - elseif ($action->type_code == 'AC_FAX') $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
| 265 | - elseif ($action->type_code == 'AC_EMAIL') $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
| 266 | - elseif ($action->type_code == 'AC_INT') $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
| 267 | - elseif (! preg_match('/_AUTO/', $action->type_code)) $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
| 284 | + if ($action->type_picto) { |
|
| 285 | + $imgpicto=img_picto('', $action->type_picto); |
|
| 286 | + } else { |
|
| 287 | + if ($action->type_code == 'AC_RDV') { |
|
| 288 | + $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
| 289 | + } elseif ($action->type_code == 'AC_TEL') { |
|
| 290 | + $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
| 291 | + } elseif ($action->type_code == 'AC_FAX') { |
|
| 292 | + $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
| 293 | + } elseif ($action->type_code == 'AC_EMAIL') { |
|
| 294 | + $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
| 295 | + } elseif ($action->type_code == 'AC_INT') { |
|
| 296 | + $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
| 297 | + } elseif (! preg_match('/_AUTO/', $action->type_code)) { |
|
| 298 | + $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
| 299 | + } |
|
| 268 | 300 | } |
| 269 | 301 | } |
| 270 | 302 | print $imgpicto; |
@@ -280,9 +312,12 @@ discard block |
||
| 280 | 312 | $tmpb=dol_getdate($action->datef); |
| 281 | 313 | if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) |
| 282 | 314 | { |
| 283 | - if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
|
| 315 | + if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) { |
|
| 316 | + print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
|
| 317 | + } |
|
| 318 | + } else { |
|
| 319 | + print '-'.dol_print_date($action->datef, 'dayhour', 'tzuserrel'); |
|
| 284 | 320 | } |
| 285 | - else print '-'.dol_print_date($action->datef, 'dayhour', 'tzuserrel'); |
|
| 286 | 321 | } |
| 287 | 322 | print '</td>'; |
| 288 | 323 | print '<td align="right">'; |
@@ -295,8 +330,7 @@ discard block |
||
| 295 | 330 | |
| 296 | 331 | $cursorevent++; |
| 297 | 332 | } |
| 298 | - } |
|
| 299 | - else |
|
| 333 | + } else |
|
| 300 | 334 | { |
| 301 | 335 | print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; |
| 302 | 336 | } |
@@ -332,7 +366,9 @@ discard block |
||
| 332 | 366 | // phpcs:enable |
| 333 | 367 | global $langs,$user,$form,$conf; |
| 334 | 368 | |
| 335 | - if (! is_object($form)) $form=new Form($this->db); |
|
| 369 | + if (! is_object($form)) { |
|
| 370 | + $form=new Form($this->db); |
|
| 371 | + } |
|
| 336 | 372 | |
| 337 | 373 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; |
| 338 | 374 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
@@ -343,19 +379,26 @@ discard block |
||
| 343 | 379 | array_unshift($arraylist,' '); // Add empty line at start |
| 344 | 380 | //asort($arraylist); |
| 345 | 381 | |
| 346 | - if ($selected == 'manual') $selected='AC_OTH'; |
|
| 347 | - if ($selected == 'auto') $selected='AC_OTH_AUTO'; |
|
| 382 | + if ($selected == 'manual') { |
|
| 383 | + $selected='AC_OTH'; |
|
| 384 | + } |
|
| 385 | + if ($selected == 'auto') { |
|
| 386 | + $selected='AC_OTH_AUTO'; |
|
| 387 | + } |
|
| 348 | 388 | |
| 349 | - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
| 389 | + if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) { |
|
| 390 | + unset($arraylist['AC_OTH_AUTO']); |
|
| 391 | + } |
|
| 350 | 392 | |
| 351 | 393 | $out=''; |
| 352 | 394 | |
| 353 | 395 | if (! empty($multiselect)) |
| 354 | 396 | { |
| 355 | - if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); |
|
| 397 | + if (!is_array($selected) && !empty($selected)) { |
|
| 398 | + $selected = explode(',', $selected); |
|
| 399 | + } |
|
| 356 | 400 | $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
| 357 | - } |
|
| 358 | - else |
|
| 401 | + } else |
|
| 359 | 402 | { |
| 360 | 403 | $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
| 361 | 404 | } |
@@ -365,8 +408,11 @@ discard block |
||
| 365 | 408 | $out.=info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''),1); |
| 366 | 409 | } |
| 367 | 410 | |
| 368 | - if ($nooutput) return $out; |
|
| 369 | - else print $out; |
|
| 411 | + if ($nooutput) { |
|
| 412 | + return $out; |
|
| 413 | + } else { |
|
| 414 | + print $out; |
|
| 415 | + } |
|
| 370 | 416 | return ''; |
| 371 | 417 | } |
| 372 | 418 | } |
@@ -28,75 +28,75 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class FormCron extends Form |
| 30 | 30 | { |
| 31 | - /** |
|
| 31 | + /** |
|
| 32 | 32 | * @var DoliDB Database handler. |
| 33 | 33 | */ |
| 34 | 34 | public $db; |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var string Error code (or message) |
|
| 38 | - */ |
|
| 39 | - public $error=''; |
|
| 36 | + /** |
|
| 37 | + * @var string Error code (or message) |
|
| 38 | + */ |
|
| 39 | + public $error=''; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Constructor |
|
| 43 | - * |
|
| 44 | - * @param DoliDB $db Database handler |
|
| 45 | - */ |
|
| 46 | - function __construct($db) |
|
| 47 | - { |
|
| 48 | - $this->db = $db; |
|
| 49 | - } |
|
| 41 | + /** |
|
| 42 | + * Constructor |
|
| 43 | + * |
|
| 44 | + * @param DoliDB $db Database handler |
|
| 45 | + */ |
|
| 46 | + function __construct($db) |
|
| 47 | + { |
|
| 48 | + $this->db = $db; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 53 | - /** |
|
| 54 | - * Display On Off selector |
|
| 55 | - * |
|
| 56 | - * @param string $htmlname Html control name |
|
| 57 | - * @param integer $selected selected value |
|
| 58 | - * @param integer $readonly Select is read only or not |
|
| 59 | - * @return string HTML select field |
|
| 60 | - */ |
|
| 61 | - function select_typejob($htmlname,$selected=0,$readonly=0) |
|
| 62 | - { |
|
| 53 | + /** |
|
| 54 | + * Display On Off selector |
|
| 55 | + * |
|
| 56 | + * @param string $htmlname Html control name |
|
| 57 | + * @param integer $selected selected value |
|
| 58 | + * @param integer $readonly Select is read only or not |
|
| 59 | + * @return string HTML select field |
|
| 60 | + */ |
|
| 61 | + function select_typejob($htmlname,$selected=0,$readonly=0) |
|
| 62 | + { |
|
| 63 | 63 | // phpcs:enable |
| 64 | - global $langs; |
|
| 64 | + global $langs; |
|
| 65 | 65 | |
| 66 | - $langs->load('cron@cron'); |
|
| 67 | - if (!empty($readonly)) { |
|
| 68 | - if ($selected=='command') { |
|
| 69 | - $out= $langs->trans('CronType_command'); |
|
| 70 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
| 71 | - $out.= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
| 72 | - $out.='</SELECT>'; |
|
| 73 | - } elseif ($selected=='method') { |
|
| 74 | - $out= $langs->trans('CronType_method'); |
|
| 75 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
| 76 | - $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
| 77 | - $out.='</SELECT>'; |
|
| 78 | - } |
|
| 79 | - }else { |
|
| 66 | + $langs->load('cron@cron'); |
|
| 67 | + if (!empty($readonly)) { |
|
| 68 | + if ($selected=='command') { |
|
| 69 | + $out= $langs->trans('CronType_command'); |
|
| 70 | + $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
| 71 | + $out.= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
| 72 | + $out.='</SELECT>'; |
|
| 73 | + } elseif ($selected=='method') { |
|
| 74 | + $out= $langs->trans('CronType_method'); |
|
| 75 | + $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
| 76 | + $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
| 77 | + $out.='</SELECT>'; |
|
| 78 | + } |
|
| 79 | + }else { |
|
| 80 | 80 | |
| 81 | - $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
| 81 | + $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
| 82 | 82 | |
| 83 | - if ($selected=='command') { |
|
| 84 | - $selected_attr=' selected '; |
|
| 85 | - } else { |
|
| 86 | - $selected_attr=''; |
|
| 87 | - } |
|
| 88 | - $out.= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
| 83 | + if ($selected=='command') { |
|
| 84 | + $selected_attr=' selected '; |
|
| 85 | + } else { |
|
| 86 | + $selected_attr=''; |
|
| 87 | + } |
|
| 88 | + $out.= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
| 89 | 89 | |
| 90 | - if ($selected=='method') { |
|
| 91 | - $selected_attr=' selected '; |
|
| 92 | - } else { |
|
| 93 | - $selected_attr=''; |
|
| 94 | - } |
|
| 95 | - $out.= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
| 90 | + if ($selected=='method') { |
|
| 91 | + $selected_attr=' selected '; |
|
| 92 | + } else { |
|
| 93 | + $selected_attr=''; |
|
| 94 | + } |
|
| 95 | + $out.= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
| 96 | 96 | |
| 97 | - $out.='</SELECT>'; |
|
| 98 | - } |
|
| 97 | + $out.='</SELECT>'; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - return $out; |
|
| 101 | - } |
|
| 100 | + return $out; |
|
| 101 | + } |
|
| 102 | 102 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | /** |
| 37 | 37 | * @var string Error code (or message) |
| 38 | 38 | */ |
| 39 | - public $error=''; |
|
| 39 | + public $error = ''; |
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * Constructor |
@@ -58,43 +58,43 @@ discard block |
||
| 58 | 58 | * @param integer $readonly Select is read only or not |
| 59 | 59 | * @return string HTML select field |
| 60 | 60 | */ |
| 61 | - function select_typejob($htmlname,$selected=0,$readonly=0) |
|
| 61 | + function select_typejob($htmlname, $selected = 0, $readonly = 0) |
|
| 62 | 62 | { |
| 63 | 63 | // phpcs:enable |
| 64 | 64 | global $langs; |
| 65 | 65 | |
| 66 | 66 | $langs->load('cron@cron'); |
| 67 | 67 | if (!empty($readonly)) { |
| 68 | - if ($selected=='command') { |
|
| 69 | - $out= $langs->trans('CronType_command'); |
|
| 70 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
| 71 | - $out.= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
| 72 | - $out.='</SELECT>'; |
|
| 73 | - } elseif ($selected=='method') { |
|
| 74 | - $out= $langs->trans('CronType_method'); |
|
| 75 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
| 76 | - $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
| 77 | - $out.='</SELECT>'; |
|
| 68 | + if ($selected == 'command') { |
|
| 69 | + $out = $langs->trans('CronType_command'); |
|
| 70 | + $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
| 71 | + $out .= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
| 72 | + $out .= '</SELECT>'; |
|
| 73 | + } elseif ($selected == 'method') { |
|
| 74 | + $out = $langs->trans('CronType_method'); |
|
| 75 | + $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
| 76 | + $out .= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
| 77 | + $out .= '</SELECT>'; |
|
| 78 | 78 | } |
| 79 | - }else { |
|
| 79 | + } else { |
|
| 80 | 80 | |
| 81 | - $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
| 81 | + $out = '<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
| 82 | 82 | |
| 83 | - if ($selected=='command') { |
|
| 84 | - $selected_attr=' selected '; |
|
| 83 | + if ($selected == 'command') { |
|
| 84 | + $selected_attr = ' selected '; |
|
| 85 | 85 | } else { |
| 86 | - $selected_attr=''; |
|
| 86 | + $selected_attr = ''; |
|
| 87 | 87 | } |
| 88 | - $out.= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
| 88 | + $out .= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
| 89 | 89 | |
| 90 | - if ($selected=='method') { |
|
| 91 | - $selected_attr=' selected '; |
|
| 90 | + if ($selected == 'method') { |
|
| 91 | + $selected_attr = ' selected '; |
|
| 92 | 92 | } else { |
| 93 | - $selected_attr=''; |
|
| 93 | + $selected_attr = ''; |
|
| 94 | 94 | } |
| 95 | - $out.= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
| 95 | + $out .= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
| 96 | 96 | |
| 97 | - $out.='</SELECT>'; |
|
| 97 | + $out .= '</SELECT>'; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | return $out; |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
| 77 | 77 | $out.='</SELECT>'; |
| 78 | 78 | } |
| 79 | - }else { |
|
| 79 | + } else { |
|
| 80 | 80 | |
| 81 | 81 | $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
| 82 | 82 | |
@@ -27,33 +27,33 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class FormMailing extends Form |
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * @var string[] Error codes (or messages) |
|
| 32 | - */ |
|
| 33 | - public $errors = array(); |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Output a select with destinaries status |
|
| 37 | - * |
|
| 38 | - * @param string $selectedid The selected id |
|
| 39 | - * @param string $htmlname Name of controm |
|
| 40 | - * @param integer $show_empty Show empty option |
|
| 41 | - * @return string HTML select |
|
| 42 | - */ |
|
| 30 | + /** |
|
| 31 | + * @var string[] Error codes (or messages) |
|
| 32 | + */ |
|
| 33 | + public $errors = array(); |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Output a select with destinaries status |
|
| 37 | + * |
|
| 38 | + * @param string $selectedid The selected id |
|
| 39 | + * @param string $htmlname Name of controm |
|
| 40 | + * @param integer $show_empty Show empty option |
|
| 41 | + * @return string HTML select |
|
| 42 | + */ |
|
| 43 | 43 | public function selectDestinariesStatus($selectedid='', $htmlname='dest_status', $show_empty=0) |
| 44 | 44 | { |
| 45 | 45 | |
| 46 | - global $langs; |
|
| 47 | - $langs->load("mails"); |
|
| 46 | + global $langs; |
|
| 47 | + $langs->load("mails"); |
|
| 48 | 48 | |
| 49 | - require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; |
|
| 50 | - $mailing = new Mailing($this->db); |
|
| 49 | + require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; |
|
| 50 | + $mailing = new Mailing($this->db); |
|
| 51 | 51 | |
| 52 | - $options = array(); |
|
| 52 | + $options = array(); |
|
| 53 | 53 | |
| 54 | - if ($show_empty) { |
|
| 55 | - $options[-2] = ''; // Note -1 is used for error |
|
| 56 | - } |
|
| 54 | + if ($show_empty) { |
|
| 55 | + $options[-2] = ''; // Note -1 is used for error |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | $options = $options + $mailing->statut_dest; |
| 59 | 59 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * \ingroup core |
| 21 | 21 | * \brief File of predefined functions for HTML forms for mailing module |
| 22 | 22 | */ |
| 23 | -require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; |
|
| 23 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Class to offer components to list and upload files |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param integer $show_empty Show empty option |
| 41 | 41 | * @return string HTML select |
| 42 | 42 | */ |
| 43 | - public function selectDestinariesStatus($selectedid='', $htmlname='dest_status', $show_empty=0) |
|
| 43 | + public function selectDestinariesStatus($selectedid = '', $htmlname = 'dest_status', $show_empty = 0) |
|
| 44 | 44 | { |
| 45 | 45 | |
| 46 | 46 | global $langs; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $options = array(); |
| 53 | 53 | |
| 54 | 54 | if ($show_empty) { |
| 55 | - $options[-2] = ''; // Note -1 is used for error |
|
| 55 | + $options[-2] = ''; // Note -1 is used for error |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $options = $options + $mailing->statut_dest; |
@@ -70,8 +70,12 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); |
| 72 | 72 | |
| 73 | - if (! $rows) $rows=round($height/20); |
|
| 74 | - if (! $cols) $cols=($width?round($width/6):80); |
|
| 73 | + if (! $rows) { |
|
| 74 | + $rows=round($height/20); |
|
| 75 | + } |
|
| 76 | + if (! $cols) { |
|
| 77 | + $cols=($width?round($width/6):80); |
|
| 78 | + } |
|
| 75 | 79 | $shorttoolbarname=preg_replace('/_encoded$/','',$toolbarname); |
| 76 | 80 | |
| 77 | 81 | // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') |
@@ -81,8 +85,12 @@ discard block |
||
| 81 | 85 | $this->readonly=$readonly; |
| 82 | 86 | |
| 83 | 87 | // Check if extended editor is ok. If not we force textarea |
| 84 | - if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; |
|
| 85 | - if ($okforextendededitor === 'ace') $this->tool='ace'; |
|
| 88 | + if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) { |
|
| 89 | + $this->tool = 'textarea'; |
|
| 90 | + } |
|
| 91 | + if ($okforextendededitor === 'ace') { |
|
| 92 | + $this->tool='ace'; |
|
| 93 | + } |
|
| 86 | 94 | //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile |
| 87 | 95 | |
| 88 | 96 | // Define content and some properties |
@@ -100,7 +108,9 @@ discard block |
||
| 100 | 108 | $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; |
| 101 | 109 | $this->editor->Value = $content; |
| 102 | 110 | $this->editor->Height = $height; |
| 103 | - if (! empty($width)) $this->editor->Width = $width; |
|
| 111 | + if (! empty($width)) { |
|
| 112 | + $this->editor->Width = $width; |
|
| 113 | + } |
|
| 104 | 114 | $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js |
| 105 | 115 | $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) |
| 106 | 116 | $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; |
@@ -163,9 +173,11 @@ discard block |
||
| 163 | 173 | $found=0; |
| 164 | 174 | $out=''; |
| 165 | 175 | |
| 166 | - if ($this->tool == 'fckeditor') // not used anymore |
|
| 176 | + if ($this->tool == 'fckeditor') { |
|
| 177 | + // not used anymore |
|
| 167 | 178 | { |
| 168 | 179 | $found=1; |
| 180 | + } |
|
| 169 | 181 | $this->editor->Create(); |
| 170 | 182 | } |
| 171 | 183 | if (in_array($this->tool,array('textarea','ckeditor'))) |
@@ -179,7 +191,9 @@ discard block |
||
| 179 | 191 | |
| 180 | 192 | if ($this->tool == 'ckeditor' && ! empty($conf->use_javascript_ajax)) |
| 181 | 193 | { |
| 182 | - if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); |
|
| 194 | + if (! defined('REQUIRE_CKEDITOR')) { |
|
| 195 | + define('REQUIRE_CKEDITOR','1'); |
|
| 196 | + } |
|
| 183 | 197 | |
| 184 | 198 | if (! empty($conf->global->FCKEDITOR_SKIN)) { |
| 185 | 199 | $skin = $conf->global->FCKEDITOR_SKIN; |
@@ -343,7 +357,10 @@ discard block |
||
| 343 | 357 | $out.= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; |
| 344 | 358 | } |
| 345 | 359 | |
| 346 | - if ($noprint) return $out; |
|
| 347 | - else print $out; |
|
| 360 | + if ($noprint) { |
|
| 361 | + return $out; |
|
| 362 | + } else { |
|
| 363 | + print $out; |
|
| 364 | + } |
|
| 348 | 365 | } |
| 349 | 366 | } |
@@ -30,19 +30,19 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | var $tool; // Store the selected tool |
| 32 | 32 | |
| 33 | - // If using fckeditor |
|
| 34 | - var $editor; |
|
| 33 | + // If using fckeditor |
|
| 34 | + var $editor; |
|
| 35 | 35 | |
| 36 | - // If not using fckeditor |
|
| 37 | - var $content; |
|
| 38 | - var $htmlname; |
|
| 39 | - var $toolbarname; |
|
| 40 | - var $toolbarstartexpanded; |
|
| 41 | - var $rows; |
|
| 42 | - var $cols; |
|
| 43 | - var $height; |
|
| 44 | - var $width; |
|
| 45 | - var $readonly; |
|
| 36 | + // If not using fckeditor |
|
| 37 | + var $content; |
|
| 38 | + var $htmlname; |
|
| 39 | + var $toolbarname; |
|
| 40 | + var $toolbarstartexpanded; |
|
| 41 | + var $rows; |
|
| 42 | + var $cols; |
|
| 43 | + var $height; |
|
| 44 | + var $width; |
|
| 45 | + var $readonly; |
|
| 46 | 46 | |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -57,22 +57,22 @@ discard block |
||
| 57 | 57 | * 'In' each window has its own toolbar |
| 58 | 58 | * 'Out:name' share toolbar into the div called 'name' |
| 59 | 59 | * @param boolean $toolbarstartexpanded Bar is visible or not at start |
| 60 | - * @param int $uselocalbrowser Enabled to add links to local object with local browser. If false, only external images can be added in content. |
|
| 61 | - * @param boolean|string $okforextendededitor True=Allow usage of extended editor tool if qualified (like ckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace. |
|
| 62 | - * Warning: If you use 'ace', don't forget to also include ace.js in page header. Also, the button "save" must have class="buttonforacesave". |
|
| 60 | + * @param int $uselocalbrowser Enabled to add links to local object with local browser. If false, only external images can be added in content. |
|
| 61 | + * @param boolean|string $okforextendededitor True=Allow usage of extended editor tool if qualified (like ckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace. |
|
| 62 | + * Warning: If you use 'ace', don't forget to also include ace.js in page header. Also, the button "save" must have class="buttonforacesave". |
|
| 63 | 63 | * @param int $rows Size of rows for textarea tool |
| 64 | - * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') |
|
| 65 | - * @param int $readonly 0=Read/Edit, 1=Read only |
|
| 66 | - */ |
|
| 64 | + * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') |
|
| 65 | + * @param int $readonly 0=Read/Edit, 1=Read only |
|
| 66 | + */ |
|
| 67 | 67 | function __construct($htmlname, $content, $width='', $height=200, $toolbarname='Basic', $toolbarlocation='In', $toolbarstartexpanded=false, $uselocalbrowser=true, $okforextendededitor=true, $rows=0, $cols=0, $readonly=0) |
| 68 | 68 | { |
| 69 | - global $conf,$langs; |
|
| 69 | + global $conf,$langs; |
|
| 70 | 70 | |
| 71 | - dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); |
|
| 71 | + dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); |
|
| 72 | 72 | |
| 73 | - if (! $rows) $rows=round($height/20); |
|
| 74 | - if (! $cols) $cols=($width?round($width/6):80); |
|
| 75 | - $shorttoolbarname=preg_replace('/_encoded$/','',$toolbarname); |
|
| 73 | + if (! $rows) $rows=round($height/20); |
|
| 74 | + if (! $cols) $cols=($width?round($width/6):80); |
|
| 75 | + $shorttoolbarname=preg_replace('/_encoded$/','',$toolbarname); |
|
| 76 | 76 | |
| 77 | 77 | // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') |
| 78 | 78 | $defaulteditor='ckeditor'; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | // Check if extended editor is ok. If not we force textarea |
| 84 | 84 | if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; |
| 85 | - if ($okforextendededitor === 'ace') $this->tool='ace'; |
|
| 85 | + if ($okforextendededitor === 'ace') $this->tool='ace'; |
|
| 86 | 86 | //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile |
| 87 | 87 | |
| 88 | 88 | // Define content and some properties |
@@ -91,50 +91,50 @@ discard block |
||
| 91 | 91 | $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
| 92 | 92 | } |
| 93 | 93 | if ($this->tool == 'fckeditor') |
| 94 | - { |
|
| 95 | - require_once DOL_DOCUMENT_ROOT.'/includes/fckeditor/fckeditor.php'; |
|
| 96 | - |
|
| 97 | - $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
|
| 98 | - |
|
| 99 | - $this->editor = new FCKeditor($htmlname); |
|
| 100 | - $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; |
|
| 101 | - $this->editor->Value = $content; |
|
| 102 | - $this->editor->Height = $height; |
|
| 103 | - if (! empty($width)) $this->editor->Width = $width; |
|
| 104 | - $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js |
|
| 105 | - $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) |
|
| 106 | - $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; |
|
| 107 | - $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; |
|
| 108 | - |
|
| 109 | - // Rem: Le forcage de ces 2 parametres ne semble pas fonctionner. |
|
| 110 | - // Dolibarr utilise toujours liens avec modulepart='fckeditor' quelque soit modulepart. |
|
| 111 | - // Ou se trouve donc cette valeur /viewimage.php?modulepart=fckeditor&file=' ? |
|
| 112 | - $modulepart='fckeditor'; |
|
| 113 | - $this->editor->Config['UserFilesPath'] = '/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&file='; |
|
| 114 | - $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/' ; |
|
| 115 | - |
|
| 116 | - $this->editor->Config['LinkBrowser']=($uselocalbrowser?'true':'false'); |
|
| 117 | - $this->editor->Config['ImageBrowser']=($uselocalbrowser?'true':'false'); |
|
| 118 | - |
|
| 119 | - if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js')) |
|
| 120 | - { |
|
| 121 | - $this->editor->Config['CustomConfigurationsPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js'; |
|
| 122 | - $this->editor->Config['SkinPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/'; |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // Define some properties |
|
| 94 | + { |
|
| 95 | + require_once DOL_DOCUMENT_ROOT.'/includes/fckeditor/fckeditor.php'; |
|
| 96 | + |
|
| 97 | + $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
|
| 98 | + |
|
| 99 | + $this->editor = new FCKeditor($htmlname); |
|
| 100 | + $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; |
|
| 101 | + $this->editor->Value = $content; |
|
| 102 | + $this->editor->Height = $height; |
|
| 103 | + if (! empty($width)) $this->editor->Width = $width; |
|
| 104 | + $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js |
|
| 105 | + $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) |
|
| 106 | + $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; |
|
| 107 | + $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; |
|
| 108 | + |
|
| 109 | + // Rem: Le forcage de ces 2 parametres ne semble pas fonctionner. |
|
| 110 | + // Dolibarr utilise toujours liens avec modulepart='fckeditor' quelque soit modulepart. |
|
| 111 | + // Ou se trouve donc cette valeur /viewimage.php?modulepart=fckeditor&file=' ? |
|
| 112 | + $modulepart='fckeditor'; |
|
| 113 | + $this->editor->Config['UserFilesPath'] = '/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&file='; |
|
| 114 | + $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/' ; |
|
| 115 | + |
|
| 116 | + $this->editor->Config['LinkBrowser']=($uselocalbrowser?'true':'false'); |
|
| 117 | + $this->editor->Config['ImageBrowser']=($uselocalbrowser?'true':'false'); |
|
| 118 | + |
|
| 119 | + if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js')) |
|
| 120 | + { |
|
| 121 | + $this->editor->Config['CustomConfigurationsPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js'; |
|
| 122 | + $this->editor->Config['SkinPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/'; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // Define some properties |
|
| 127 | 127 | if (in_array($this->tool,array('textarea','ckeditor','ace'))) |
| 128 | 128 | { |
| 129 | - $this->content = $content; |
|
| 130 | - $this->htmlname = $htmlname; |
|
| 131 | - $this->toolbarname = $shorttoolbarname; |
|
| 132 | - $this->toolbarstartexpanded = $toolbarstartexpanded; |
|
| 129 | + $this->content = $content; |
|
| 130 | + $this->htmlname = $htmlname; |
|
| 131 | + $this->toolbarname = $shorttoolbarname; |
|
| 132 | + $this->toolbarstartexpanded = $toolbarstartexpanded; |
|
| 133 | 133 | $this->rows = max(ROWS_3,$rows); |
| 134 | 134 | $this->cols = (preg_match('/%/',$cols)?$cols:max(40,$cols)); // If $cols is a percent, we keep it, otherwise, we take max |
| 135 | 135 | $this->height = $height; |
| 136 | 136 | $this->width = $width; |
| 137 | - } |
|
| 137 | + } |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -152,20 +152,20 @@ discard block |
||
| 152 | 152 | function Create($noprint=0, $morejs='', $disallowAnyContent=true, $titlecontent='', $option='') |
| 153 | 153 | { |
| 154 | 154 | // phpcs:enable |
| 155 | - global $conf,$langs; |
|
| 155 | + global $conf,$langs; |
|
| 156 | 156 | |
| 157 | - $fullpage=false; |
|
| 158 | - if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) |
|
| 159 | - { |
|
| 160 | - $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all |
|
| 161 | - } |
|
| 157 | + $fullpage=false; |
|
| 158 | + if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) |
|
| 159 | + { |
|
| 160 | + $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - $found=0; |
|
| 164 | - $out=''; |
|
| 163 | + $found=0; |
|
| 164 | + $out=''; |
|
| 165 | 165 | |
| 166 | 166 | if ($this->tool == 'fckeditor') // not used anymore |
| 167 | 167 | { |
| 168 | - $found=1; |
|
| 168 | + $found=1; |
|
| 169 | 169 | $this->editor->Create(); |
| 170 | 170 | } |
| 171 | 171 | if (in_array($this->tool,array('textarea','ckeditor'))) |
@@ -179,12 +179,12 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | if ($this->tool == 'ckeditor' && ! empty($conf->use_javascript_ajax)) |
| 181 | 181 | { |
| 182 | - if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); |
|
| 182 | + if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); |
|
| 183 | 183 | |
| 184 | - if (! empty($conf->global->FCKEDITOR_SKIN)) { |
|
| 185 | - $skin = $conf->global->FCKEDITOR_SKIN; |
|
| 186 | - } else { |
|
| 187 | - // $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa |
|
| 184 | + if (! empty($conf->global->FCKEDITOR_SKIN)) { |
|
| 185 | + $skin = $conf->global->FCKEDITOR_SKIN; |
|
| 186 | + } else { |
|
| 187 | + // $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa |
|
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * Alixar: |
@@ -195,10 +195,10 @@ discard block |
||
| 195 | 195 | $skin = CKEDITOR_SKIN; // In AlixarDispatcher defineConstants() |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - $htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false'; |
|
| 198 | + $htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false'; |
|
| 199 | 199 | |
| 200 | - $out.= '<!-- Output ckeditor $disallowAnyContent='.$disallowAnyContent.' toolbarname='.$this->toolbarname.' -->'."\n"; |
|
| 201 | - $out.= '<script type="text/javascript"> |
|
| 200 | + $out.= '<!-- Output ckeditor $disallowAnyContent='.$disallowAnyContent.' toolbarname='.$this->toolbarname.' -->'."\n"; |
|
| 201 | + $out.= '<script type="text/javascript"> |
|
| 202 | 202 | $(document).ready(function () { |
| 203 | 203 | /* if (CKEDITOR.loadFullCore) CKEDITOR.loadFullCore(); */ |
| 204 | 204 | /* should be editor=CKEDITOR.replace but what if serveral editors ? */ |
@@ -233,8 +233,8 @@ discard block |
||
| 233 | 233 | }); |
| 234 | 234 | } |
| 235 | 235 | }'; |
| 236 | - if ($this->uselocalbrowser) |
|
| 237 | - { |
|
| 236 | + if ($this->uselocalbrowser) |
|
| 237 | + { |
|
| 238 | 238 | $out.= ','."\n"; |
| 239 | 239 | // To use filemanager with old fckeditor (GPL) |
| 240 | 240 | $out.= ' filebrowserBrowseUrl : ckeditorFilebrowserBrowseUrl,'; |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | //$out.= ' filebrowserImageUploadUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/upload.php?Type=Image\','; |
| 244 | 244 | $out.= "\n"; |
| 245 | 245 | // To use filemanager with ckfinder (Non free) and ckfinder directory is inside htdocs/includes |
| 246 | - /* $out.= ' filebrowserBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html\', |
|
| 246 | + /* $out.= ' filebrowserBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html\', |
|
| 247 | 247 | filebrowserImageBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html?Type=Images\', |
| 248 | 248 | filebrowserFlashBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html?Type=Flash\', |
| 249 | 249 | filebrowserUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files\', |
@@ -254,10 +254,10 @@ discard block |
||
| 254 | 254 | filebrowserWindowHeight : \'500\', |
| 255 | 255 | filebrowserImageWindowWidth : \'900\', |
| 256 | 256 | filebrowserImageWindowHeight : \'500\''; |
| 257 | - } |
|
| 258 | - $out.= ' })'.$morejs; |
|
| 259 | - $out.= '});'."\n"; |
|
| 260 | - $out.= '</script>'."\n"; |
|
| 257 | + } |
|
| 258 | + $out.= ' })'.$morejs; |
|
| 259 | + $out.= '});'."\n"; |
|
| 260 | + $out.= '</script>'."\n"; |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
@@ -265,19 +265,19 @@ discard block |
||
| 265 | 265 | // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. |
| 266 | 266 | if (preg_match('/^ace/', $this->tool)) |
| 267 | 267 | { |
| 268 | - $found=1; |
|
| 269 | - $format=$option; |
|
| 268 | + $found=1; |
|
| 269 | + $format=$option; |
|
| 270 | 270 | |
| 271 | 271 | $out.= "\n".'<!-- Output Ace editor -->'."\n"; |
| 272 | 272 | |
| 273 | - if ($titlecontent) |
|
| 274 | - { |
|
| 275 | - $out.= '<div class="aceeditorstatusbar" id="statusBar'.$this->htmlname.'">'.$titlecontent; |
|
| 276 | - $out.= ' - <a id="morelines" href="#" class="right morelines'.$this->htmlname.'">'.dol_escape_htmltag($langs->trans("ShowMoreLines")).'</a> '; |
|
| 277 | - $out.= '</div>'; |
|
| 278 | - $out.= '<script type="text/javascript" language="javascript">'."\n"; |
|
| 279 | - $out.= 'jQuery(document).ready(function() {'."\n"; |
|
| 280 | - $out.= ' var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
| 273 | + if ($titlecontent) |
|
| 274 | + { |
|
| 275 | + $out.= '<div class="aceeditorstatusbar" id="statusBar'.$this->htmlname.'">'.$titlecontent; |
|
| 276 | + $out.= ' - <a id="morelines" href="#" class="right morelines'.$this->htmlname.'">'.dol_escape_htmltag($langs->trans("ShowMoreLines")).'</a> '; |
|
| 277 | + $out.= '</div>'; |
|
| 278 | + $out.= '<script type="text/javascript" language="javascript">'."\n"; |
|
| 279 | + $out.= 'jQuery(document).ready(function() {'."\n"; |
|
| 280 | + $out.= ' var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
| 281 | 281 | var StatusBar = window.ace.require("ace/ext/statusbar").StatusBar; // Init status bar. Need lib ext-statusbar |
| 282 | 282 | var statusBar = new StatusBar(aceEditor, document.getElementById("statusBar'.$this->htmlname.'")); // Init status bar. Need lib ext-statusbar |
| 283 | 283 | var oldNbOfLines = 0 |
@@ -299,21 +299,21 @@ discard block |
||
| 299 | 299 | } |
| 300 | 300 | }); |
| 301 | 301 | })'; |
| 302 | - $out.= '</script>'."\n"; |
|
| 303 | - } |
|
| 302 | + $out.= '</script>'."\n"; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | 305 | $out.= '<pre id="'.$this->htmlname.'aceeditorid" style="'.($this->width?'width: '.$this->width.'px; ':''); |
| 306 | 306 | $out.= ($this->height?' height: '.$this->height.'px; ':''); |
| 307 | 307 | //$out.=" min-height: 100px;"; |
| 308 | 308 | $out.= '">'; |
| 309 | - $out.= htmlspecialchars($this->content); |
|
| 310 | - $out.= '</pre>'; |
|
| 311 | - $out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" style="width:0px; height: 0px; display: none;">'; |
|
| 312 | - $out.= htmlspecialchars($this->content); |
|
| 313 | - $out.= '</textarea>'; |
|
| 309 | + $out.= htmlspecialchars($this->content); |
|
| 310 | + $out.= '</pre>'; |
|
| 311 | + $out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" style="width:0px; height: 0px; display: none;">'; |
|
| 312 | + $out.= htmlspecialchars($this->content); |
|
| 313 | + $out.= '</textarea>'; |
|
| 314 | 314 | |
| 315 | - $out.= '<script type="text/javascript" language="javascript">'."\n"; |
|
| 316 | - $out.= 'var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
| 315 | + $out.= '<script type="text/javascript" language="javascript">'."\n"; |
|
| 316 | + $out.= 'var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
| 317 | 317 | |
| 318 | 318 | aceEditor.session.setMode("ace/mode/'.$format.'"); |
| 319 | 319 | aceEditor.setOptions({ |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | //aceEditor.getSession().setMode("ace/mode/javascript_expression"); |
| 334 | 334 | '."\n"; |
| 335 | 335 | |
| 336 | - $out.= 'jQuery(document).ready(function() { |
|
| 336 | + $out.= 'jQuery(document).ready(function() { |
|
| 337 | 337 | jQuery(".buttonforacesave").click(function() { |
| 338 | 338 | console.log("We click on savefile button for component '.$this->htmlname.'"); |
| 339 | 339 | var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid") |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | else return false;*/ |
| 344 | 344 | }); |
| 345 | 345 | })'; |
| 346 | - $out.= '</script>'."\n"; |
|
| 346 | + $out.= '</script>'."\n"; |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | if (empty($found)) |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | class DolEditor |
| 30 | 30 | { |
| 31 | - var $tool; // Store the selected tool |
|
| 31 | + var $tool; // Store the selected tool |
|
| 32 | 32 | |
| 33 | 33 | // If using fckeditor |
| 34 | 34 | var $editor; |
@@ -64,57 +64,57 @@ discard block |
||
| 64 | 64 | * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') |
| 65 | 65 | * @param int $readonly 0=Read/Edit, 1=Read only |
| 66 | 66 | */ |
| 67 | - function __construct($htmlname, $content, $width='', $height=200, $toolbarname='Basic', $toolbarlocation='In', $toolbarstartexpanded=false, $uselocalbrowser=true, $okforextendededitor=true, $rows=0, $cols=0, $readonly=0) |
|
| 67 | + function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) |
|
| 68 | 68 | { |
| 69 | - global $conf,$langs; |
|
| 69 | + global $conf, $langs; |
|
| 70 | 70 | |
| 71 | 71 | dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); |
| 72 | 72 | |
| 73 | - if (! $rows) $rows=round($height/20); |
|
| 74 | - if (! $cols) $cols=($width?round($width/6):80); |
|
| 75 | - $shorttoolbarname=preg_replace('/_encoded$/','',$toolbarname); |
|
| 73 | + if (!$rows) $rows = round($height / 20); |
|
| 74 | + if (!$cols) $cols = ($width ?round($width / 6) : 80); |
|
| 75 | + $shorttoolbarname = preg_replace('/_encoded$/', '', $toolbarname); |
|
| 76 | 76 | |
| 77 | 77 | // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') |
| 78 | - $defaulteditor='ckeditor'; |
|
| 79 | - $this->tool=empty($conf->global->FCKEDITOR_EDITORNAME)?$defaulteditor:$conf->global->FCKEDITOR_EDITORNAME; |
|
| 80 | - $this->uselocalbrowser=$uselocalbrowser; |
|
| 81 | - $this->readonly=$readonly; |
|
| 78 | + $defaulteditor = 'ckeditor'; |
|
| 79 | + $this->tool = empty($conf->global->FCKEDITOR_EDITORNAME) ? $defaulteditor : $conf->global->FCKEDITOR_EDITORNAME; |
|
| 80 | + $this->uselocalbrowser = $uselocalbrowser; |
|
| 81 | + $this->readonly = $readonly; |
|
| 82 | 82 | |
| 83 | 83 | // Check if extended editor is ok. If not we force textarea |
| 84 | 84 | if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; |
| 85 | - if ($okforextendededitor === 'ace') $this->tool='ace'; |
|
| 85 | + if ($okforextendededitor === 'ace') $this->tool = 'ace'; |
|
| 86 | 86 | //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile |
| 87 | 87 | |
| 88 | 88 | // Define content and some properties |
| 89 | 89 | if ($this->tool == 'ckeditor') |
| 90 | 90 | { |
| 91 | - $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
|
| 91 | + $content = dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
|
| 92 | 92 | } |
| 93 | 93 | if ($this->tool == 'fckeditor') |
| 94 | 94 | { |
| 95 | 95 | require_once DOL_DOCUMENT_ROOT.'/includes/fckeditor/fckeditor.php'; |
| 96 | 96 | |
| 97 | - $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
|
| 97 | + $content = dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. |
|
| 98 | 98 | |
| 99 | 99 | $this->editor = new FCKeditor($htmlname); |
| 100 | - $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; |
|
| 101 | - $this->editor->Value = $content; |
|
| 100 | + $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/'; |
|
| 101 | + $this->editor->Value = $content; |
|
| 102 | 102 | $this->editor->Height = $height; |
| 103 | - if (! empty($width)) $this->editor->Width = $width; |
|
| 104 | - $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js |
|
| 105 | - $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) |
|
| 103 | + if (!empty($width)) $this->editor->Width = $width; |
|
| 104 | + $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js |
|
| 105 | + $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) |
|
| 106 | 106 | $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; |
| 107 | 107 | $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; |
| 108 | 108 | |
| 109 | 109 | // Rem: Le forcage de ces 2 parametres ne semble pas fonctionner. |
| 110 | 110 | // Dolibarr utilise toujours liens avec modulepart='fckeditor' quelque soit modulepart. |
| 111 | 111 | // Ou se trouve donc cette valeur /viewimage.php?modulepart=fckeditor&file=' ? |
| 112 | - $modulepart='fckeditor'; |
|
| 112 | + $modulepart = 'fckeditor'; |
|
| 113 | 113 | $this->editor->Config['UserFilesPath'] = '/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&file='; |
| 114 | - $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/' ; |
|
| 114 | + $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/'; |
|
| 115 | 115 | |
| 116 | - $this->editor->Config['LinkBrowser']=($uselocalbrowser?'true':'false'); |
|
| 117 | - $this->editor->Config['ImageBrowser']=($uselocalbrowser?'true':'false'); |
|
| 116 | + $this->editor->Config['LinkBrowser'] = ($uselocalbrowser ? 'true' : 'false'); |
|
| 117 | + $this->editor->Config['ImageBrowser'] = ($uselocalbrowser ? 'true' : 'false'); |
|
| 118 | 118 | |
| 119 | 119 | if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js')) |
| 120 | 120 | { |
@@ -124,15 +124,15 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // Define some properties |
| 127 | - if (in_array($this->tool,array('textarea','ckeditor','ace'))) |
|
| 127 | + if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) |
|
| 128 | 128 | { |
| 129 | - $this->content = $content; |
|
| 129 | + $this->content = $content; |
|
| 130 | 130 | $this->htmlname = $htmlname; |
| 131 | - $this->toolbarname = $shorttoolbarname; |
|
| 131 | + $this->toolbarname = $shorttoolbarname; |
|
| 132 | 132 | $this->toolbarstartexpanded = $toolbarstartexpanded; |
| 133 | - $this->rows = max(ROWS_3,$rows); |
|
| 134 | - $this->cols = (preg_match('/%/',$cols)?$cols:max(40,$cols)); // If $cols is a percent, we keep it, otherwise, we take max |
|
| 135 | - $this->height = $height; |
|
| 133 | + $this->rows = max(ROWS_3, $rows); |
|
| 134 | + $this->cols = (preg_match('/%/', $cols) ? $cols : max(40, $cols)); // If $cols is a percent, we keep it, otherwise, we take max |
|
| 135 | + $this->height = $height; |
|
| 136 | 136 | $this->width = $width; |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -149,39 +149,39 @@ discard block |
||
| 149 | 149 | * @param string $option For ACE editor, set the source language ('html', 'php', 'javascript', ...) |
| 150 | 150 | * @return void|string |
| 151 | 151 | */ |
| 152 | - function Create($noprint=0, $morejs='', $disallowAnyContent=true, $titlecontent='', $option='') |
|
| 152 | + function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') |
|
| 153 | 153 | { |
| 154 | 154 | // phpcs:enable |
| 155 | - global $conf,$langs; |
|
| 155 | + global $conf, $langs; |
|
| 156 | 156 | |
| 157 | - $fullpage=false; |
|
| 157 | + $fullpage = false; |
|
| 158 | 158 | if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) |
| 159 | 159 | { |
| 160 | - $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all |
|
| 160 | + $disallowAnyContent = empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $found=0; |
|
| 164 | - $out=''; |
|
| 163 | + $found = 0; |
|
| 164 | + $out = ''; |
|
| 165 | 165 | |
| 166 | 166 | if ($this->tool == 'fckeditor') // not used anymore |
| 167 | 167 | { |
| 168 | - $found=1; |
|
| 168 | + $found = 1; |
|
| 169 | 169 | $this->editor->Create(); |
| 170 | 170 | } |
| 171 | - if (in_array($this->tool,array('textarea','ckeditor'))) |
|
| 171 | + if (in_array($this->tool, array('textarea', 'ckeditor'))) |
|
| 172 | 172 | { |
| 173 | - $found=1; |
|
| 173 | + $found = 1; |
|
| 174 | 174 | //$out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" '.($this->readonly?' disabled':'').' rows="'.$this->rows.'"'.(preg_match('/%/',$this->cols)?' style="margin-top: 5px; width: '.$this->cols.'"':' cols="'.$this->cols.'"').' class="flat">'; |
| 175 | 175 | // TODO We do not put the disabled tag because on a read form, it change style with grey. |
| 176 | - $out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'"'.(preg_match('/%/',$this->cols)?' style="margin-top: 5px; width: '.$this->cols.'"':' cols="'.$this->cols.'"').' class="flat">'; |
|
| 177 | - $out.= $this->content; |
|
| 178 | - $out.= '</textarea>'; |
|
| 176 | + $out .= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'"'.(preg_match('/%/', $this->cols) ? ' style="margin-top: 5px; width: '.$this->cols.'"' : ' cols="'.$this->cols.'"').' class="flat">'; |
|
| 177 | + $out .= $this->content; |
|
| 178 | + $out .= '</textarea>'; |
|
| 179 | 179 | |
| 180 | - if ($this->tool == 'ckeditor' && ! empty($conf->use_javascript_ajax)) |
|
| 180 | + if ($this->tool == 'ckeditor' && !empty($conf->use_javascript_ajax)) |
|
| 181 | 181 | { |
| 182 | - if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); |
|
| 182 | + if (!defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR', '1'); |
|
| 183 | 183 | |
| 184 | - if (! empty($conf->global->FCKEDITOR_SKIN)) { |
|
| 184 | + if (!empty($conf->global->FCKEDITOR_SKIN)) { |
|
| 185 | 185 | $skin = $conf->global->FCKEDITOR_SKIN; |
| 186 | 186 | } else { |
| 187 | 187 | // $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa |
@@ -192,13 +192,13 @@ discard block |
||
| 192 | 192 | * When updating ckeditor, the moono-lisa skin disappears |
| 193 | 193 | * and includes kama and moono. |
| 194 | 194 | */ |
| 195 | - $skin = CKEDITOR_SKIN; // In AlixarDispatcher defineConstants() |
|
| 195 | + $skin = CKEDITOR_SKIN; // In AlixarDispatcher defineConstants() |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - $htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false'; |
|
| 198 | + $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; |
|
| 199 | 199 | |
| 200 | - $out.= '<!-- Output ckeditor $disallowAnyContent='.$disallowAnyContent.' toolbarname='.$this->toolbarname.' -->'."\n"; |
|
| 201 | - $out.= '<script type="text/javascript"> |
|
| 200 | + $out .= '<!-- Output ckeditor $disallowAnyContent='.$disallowAnyContent.' toolbarname='.$this->toolbarname.' -->'."\n"; |
|
| 201 | + $out .= '<script type="text/javascript"> |
|
| 202 | 202 | $(document).ready(function () { |
| 203 | 203 | /* if (CKEDITOR.loadFullCore) CKEDITOR.loadFullCore(); */ |
| 204 | 204 | /* should be editor=CKEDITOR.replace but what if serveral editors ? */ |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | { |
| 207 | 207 | /* property:xxx is same than CKEDITOR.config.property = xxx */ |
| 208 | 208 | customConfig : ckeditorConfig, |
| 209 | - readOnly : '.($this->readonly?'true':'false').', |
|
| 209 | + readOnly : '.($this->readonly ? 'true' : 'false').', |
|
| 210 | 210 | htmlEncodeOutput :'.$htmlencode_force.', |
| 211 | - allowedContent :'.($disallowAnyContent?'false':'true').', |
|
| 211 | + allowedContent :'.($disallowAnyContent ? 'false' : 'true').', |
|
| 212 | 212 | extraAllowedContent : \'\', |
| 213 | - fullPage : '.($fullpage?'true':'false').', |
|
| 213 | + fullPage : '.($fullpage ? 'true' : 'false').', |
|
| 214 | 214 | toolbar: \''.$this->toolbarname.'\', |
| 215 | 215 | toolbarStartupExpanded: '.($this->toolbarstartexpanded ? 'true' : 'false').', |
| 216 | 216 | width: '.($this->width ? '\''.$this->width.'\'' : '\'\'').', |
@@ -235,13 +235,13 @@ discard block |
||
| 235 | 235 | }'; |
| 236 | 236 | if ($this->uselocalbrowser) |
| 237 | 237 | { |
| 238 | - $out.= ','."\n"; |
|
| 238 | + $out .= ','."\n"; |
|
| 239 | 239 | // To use filemanager with old fckeditor (GPL) |
| 240 | - $out.= ' filebrowserBrowseUrl : ckeditorFilebrowserBrowseUrl,'; |
|
| 241 | - $out.= ' filebrowserImageBrowseUrl : ckeditorFilebrowserImageBrowseUrl,'; |
|
| 240 | + $out .= ' filebrowserBrowseUrl : ckeditorFilebrowserBrowseUrl,'; |
|
| 241 | + $out .= ' filebrowserImageBrowseUrl : ckeditorFilebrowserImageBrowseUrl,'; |
|
| 242 | 242 | //$out.= ' filebrowserUploadUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/upload.php?Type=File\','; |
| 243 | 243 | //$out.= ' filebrowserImageUploadUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/upload.php?Type=Image\','; |
| 244 | - $out.= "\n"; |
|
| 244 | + $out .= "\n"; |
|
| 245 | 245 | // To use filemanager with ckfinder (Non free) and ckfinder directory is inside htdocs/includes |
| 246 | 246 | /* $out.= ' filebrowserBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html\', |
| 247 | 247 | filebrowserImageBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html?Type=Images\', |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | filebrowserImageUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images\', |
| 251 | 251 | filebrowserFlashUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash\','."\n"; |
| 252 | 252 | */ |
| 253 | - $out.= ' filebrowserWindowWidth : \'900\', |
|
| 253 | + $out .= ' filebrowserWindowWidth : \'900\', |
|
| 254 | 254 | filebrowserWindowHeight : \'500\', |
| 255 | 255 | filebrowserImageWindowWidth : \'900\', |
| 256 | 256 | filebrowserImageWindowHeight : \'500\''; |
| 257 | 257 | } |
| 258 | - $out.= ' })'.$morejs; |
|
| 259 | - $out.= '});'."\n"; |
|
| 260 | - $out.= '</script>'."\n"; |
|
| 258 | + $out .= ' })'.$morejs; |
|
| 259 | + $out .= '});'."\n"; |
|
| 260 | + $out .= '</script>'."\n"; |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
@@ -265,19 +265,19 @@ discard block |
||
| 265 | 265 | // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. |
| 266 | 266 | if (preg_match('/^ace/', $this->tool)) |
| 267 | 267 | { |
| 268 | - $found=1; |
|
| 269 | - $format=$option; |
|
| 268 | + $found = 1; |
|
| 269 | + $format = $option; |
|
| 270 | 270 | |
| 271 | - $out.= "\n".'<!-- Output Ace editor -->'."\n"; |
|
| 271 | + $out .= "\n".'<!-- Output Ace editor -->'."\n"; |
|
| 272 | 272 | |
| 273 | 273 | if ($titlecontent) |
| 274 | 274 | { |
| 275 | - $out.= '<div class="aceeditorstatusbar" id="statusBar'.$this->htmlname.'">'.$titlecontent; |
|
| 276 | - $out.= ' - <a id="morelines" href="#" class="right morelines'.$this->htmlname.'">'.dol_escape_htmltag($langs->trans("ShowMoreLines")).'</a> '; |
|
| 277 | - $out.= '</div>'; |
|
| 278 | - $out.= '<script type="text/javascript" language="javascript">'."\n"; |
|
| 279 | - $out.= 'jQuery(document).ready(function() {'."\n"; |
|
| 280 | - $out.= ' var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
| 275 | + $out .= '<div class="aceeditorstatusbar" id="statusBar'.$this->htmlname.'">'.$titlecontent; |
|
| 276 | + $out .= ' - <a id="morelines" href="#" class="right morelines'.$this->htmlname.'">'.dol_escape_htmltag($langs->trans("ShowMoreLines")).'</a> '; |
|
| 277 | + $out .= '</div>'; |
|
| 278 | + $out .= '<script type="text/javascript" language="javascript">'."\n"; |
|
| 279 | + $out .= 'jQuery(document).ready(function() {'."\n"; |
|
| 280 | + $out .= ' var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
| 281 | 281 | var StatusBar = window.ace.require("ace/ext/statusbar").StatusBar; // Init status bar. Need lib ext-statusbar |
| 282 | 282 | var statusBar = new StatusBar(aceEditor, document.getElementById("statusBar'.$this->htmlname.'")); // Init status bar. Need lib ext-statusbar |
| 283 | 283 | var oldNbOfLines = 0 |
@@ -299,21 +299,21 @@ discard block |
||
| 299 | 299 | } |
| 300 | 300 | }); |
| 301 | 301 | })'; |
| 302 | - $out.= '</script>'."\n"; |
|
| 302 | + $out .= '</script>'."\n"; |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - $out.= '<pre id="'.$this->htmlname.'aceeditorid" style="'.($this->width?'width: '.$this->width.'px; ':''); |
|
| 306 | - $out.= ($this->height?' height: '.$this->height.'px; ':''); |
|
| 305 | + $out .= '<pre id="'.$this->htmlname.'aceeditorid" style="'.($this->width ? 'width: '.$this->width.'px; ' : ''); |
|
| 306 | + $out .= ($this->height ? ' height: '.$this->height.'px; ' : ''); |
|
| 307 | 307 | //$out.=" min-height: 100px;"; |
| 308 | - $out.= '">'; |
|
| 309 | - $out.= htmlspecialchars($this->content); |
|
| 310 | - $out.= '</pre>'; |
|
| 311 | - $out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" style="width:0px; height: 0px; display: none;">'; |
|
| 312 | - $out.= htmlspecialchars($this->content); |
|
| 313 | - $out.= '</textarea>'; |
|
| 308 | + $out .= '">'; |
|
| 309 | + $out .= htmlspecialchars($this->content); |
|
| 310 | + $out .= '</pre>'; |
|
| 311 | + $out .= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" style="width:0px; height: 0px; display: none;">'; |
|
| 312 | + $out .= htmlspecialchars($this->content); |
|
| 313 | + $out .= '</textarea>'; |
|
| 314 | 314 | |
| 315 | - $out.= '<script type="text/javascript" language="javascript">'."\n"; |
|
| 316 | - $out.= 'var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
| 315 | + $out .= '<script type="text/javascript" language="javascript">'."\n"; |
|
| 316 | + $out .= 'var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
|
| 317 | 317 | |
| 318 | 318 | aceEditor.session.setMode("ace/mode/'.$format.'"); |
| 319 | 319 | aceEditor.setOptions({ |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | enableLiveAutocompletion: false, // the editor completes the statement while you are typing. Need lib ext-language_tools.js |
| 322 | 322 | showPrintMargin: false, // hides the vertical limiting strip |
| 323 | 323 | minLines: 10, |
| 324 | - maxLines: '.(empty($this->height)?'34':(round($this->height/10))).', |
|
| 324 | + maxLines: '.(empty($this->height) ? '34' : (round($this->height / 10))).', |
|
| 325 | 325 | fontSize: "110%" // ensures that the editor fits in the environment |
| 326 | 326 | }); |
| 327 | 327 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | //aceEditor.getSession().setMode("ace/mode/javascript_expression"); |
| 334 | 334 | '."\n"; |
| 335 | 335 | |
| 336 | - $out.= 'jQuery(document).ready(function() { |
|
| 336 | + $out .= 'jQuery(document).ready(function() { |
|
| 337 | 337 | jQuery(".buttonforacesave").click(function() { |
| 338 | 338 | console.log("We click on savefile button for component '.$this->htmlname.'"); |
| 339 | 339 | var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid") |
@@ -343,12 +343,12 @@ discard block |
||
| 343 | 343 | else return false;*/ |
| 344 | 344 | }); |
| 345 | 345 | })'; |
| 346 | - $out.= '</script>'."\n"; |
|
| 346 | + $out .= '</script>'."\n"; |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | if (empty($found)) |
| 350 | 350 | { |
| 351 | - $out.= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; |
|
| 351 | + $out .= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | if ($noprint) return $out; |
@@ -31,589 +31,589 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | class FormCompany |
| 33 | 33 | { |
| 34 | - /** |
|
| 34 | + /** |
|
| 35 | 35 | * @var DoliDB Database handler. |
| 36 | 36 | */ |
| 37 | 37 | public $db; |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var string Error code (or message) |
|
| 41 | - */ |
|
| 42 | - public $error=''; |
|
| 39 | + /** |
|
| 40 | + * @var string Error code (or message) |
|
| 41 | + */ |
|
| 42 | + public $error=''; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Constructor |
|
| 46 | - * |
|
| 47 | - * @param DoliDB $db Database handler |
|
| 48 | - */ |
|
| 49 | - function __construct($db) |
|
| 50 | - { |
|
| 51 | - $this->db = $db; |
|
| 52 | - } |
|
| 44 | + /** |
|
| 45 | + * Constructor |
|
| 46 | + * |
|
| 47 | + * @param DoliDB $db Database handler |
|
| 48 | + */ |
|
| 49 | + function __construct($db) |
|
| 50 | + { |
|
| 51 | + $this->db = $db; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 56 | - /** |
|
| 57 | - * Return list of labels (translated) of third parties type |
|
| 58 | - * |
|
| 59 | - * @param int $mode 0=Return id+label, 1=Return code+label |
|
| 60 | - * @param string $filter Add a SQL filter to select |
|
| 61 | - * @return array Array of types |
|
| 62 | - */ |
|
| 63 | - function typent_array($mode=0, $filter='') |
|
| 64 | - { |
|
| 56 | + /** |
|
| 57 | + * Return list of labels (translated) of third parties type |
|
| 58 | + * |
|
| 59 | + * @param int $mode 0=Return id+label, 1=Return code+label |
|
| 60 | + * @param string $filter Add a SQL filter to select |
|
| 61 | + * @return array Array of types |
|
| 62 | + */ |
|
| 63 | + function typent_array($mode=0, $filter='') |
|
| 64 | + { |
|
| 65 | 65 | // phpcs:enable |
| 66 | - global $langs,$mysoc; |
|
| 67 | - |
|
| 68 | - $effs = array(); |
|
| 69 | - |
|
| 70 | - $sql = "SELECT id, code, libelle"; |
|
| 71 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_typent"; |
|
| 72 | - $sql.= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id)?'0':$mysoc->country_id).")"; |
|
| 73 | - if ($filter) $sql.=" ".$filter; |
|
| 74 | - $sql.= " ORDER by position, id"; |
|
| 75 | - dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); |
|
| 76 | - $resql=$this->db->query($sql); |
|
| 77 | - if ($resql) |
|
| 78 | - { |
|
| 79 | - $num = $this->db->num_rows($resql); |
|
| 80 | - $i = 0; |
|
| 81 | - |
|
| 82 | - while ($i < $num) |
|
| 83 | - { |
|
| 84 | - $objp = $this->db->fetch_object($resql); |
|
| 85 | - if (! $mode) $key=$objp->id; |
|
| 86 | - else $key=$objp->code; |
|
| 87 | - if ($langs->trans($objp->code) != $objp->code) $effs[$key] = $langs->trans($objp->code); |
|
| 88 | - else $effs[$key] = $objp->libelle; |
|
| 89 | - if ($effs[$key]=='-') $effs[$key]=''; |
|
| 90 | - $i++; |
|
| 91 | - } |
|
| 92 | - $this->db->free($resql); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - return $effs; |
|
| 96 | - } |
|
| 66 | + global $langs,$mysoc; |
|
| 67 | + |
|
| 68 | + $effs = array(); |
|
| 69 | + |
|
| 70 | + $sql = "SELECT id, code, libelle"; |
|
| 71 | + $sql.= " FROM ".MAIN_DB_PREFIX."c_typent"; |
|
| 72 | + $sql.= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id)?'0':$mysoc->country_id).")"; |
|
| 73 | + if ($filter) $sql.=" ".$filter; |
|
| 74 | + $sql.= " ORDER by position, id"; |
|
| 75 | + dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); |
|
| 76 | + $resql=$this->db->query($sql); |
|
| 77 | + if ($resql) |
|
| 78 | + { |
|
| 79 | + $num = $this->db->num_rows($resql); |
|
| 80 | + $i = 0; |
|
| 81 | + |
|
| 82 | + while ($i < $num) |
|
| 83 | + { |
|
| 84 | + $objp = $this->db->fetch_object($resql); |
|
| 85 | + if (! $mode) $key=$objp->id; |
|
| 86 | + else $key=$objp->code; |
|
| 87 | + if ($langs->trans($objp->code) != $objp->code) $effs[$key] = $langs->trans($objp->code); |
|
| 88 | + else $effs[$key] = $objp->libelle; |
|
| 89 | + if ($effs[$key]=='-') $effs[$key]=''; |
|
| 90 | + $i++; |
|
| 91 | + } |
|
| 92 | + $this->db->free($resql); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + return $effs; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 99 | - /** |
|
| 100 | - * Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre) |
|
| 101 | - * |
|
| 102 | - * @param int $mode 0=renvoi id+libelle, 1=renvoi code+libelle |
|
| 103 | - * @param string $filter Add a SQL filter to select |
|
| 104 | - * @return array Array of types d'effectifs |
|
| 105 | - */ |
|
| 106 | - function effectif_array($mode=0, $filter='') |
|
| 107 | - { |
|
| 99 | + /** |
|
| 100 | + * Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre) |
|
| 101 | + * |
|
| 102 | + * @param int $mode 0=renvoi id+libelle, 1=renvoi code+libelle |
|
| 103 | + * @param string $filter Add a SQL filter to select |
|
| 104 | + * @return array Array of types d'effectifs |
|
| 105 | + */ |
|
| 106 | + function effectif_array($mode=0, $filter='') |
|
| 107 | + { |
|
| 108 | 108 | // phpcs:enable |
| 109 | - $effs = array(); |
|
| 110 | - |
|
| 111 | - $sql = "SELECT id, code, libelle"; |
|
| 112 | - $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; |
|
| 113 | - $sql.= " WHERE active = 1"; |
|
| 114 | - if ($filter) $sql.=" ".$filter; |
|
| 115 | - $sql .= " ORDER BY id ASC"; |
|
| 116 | - dol_syslog(get_class($this).'::effectif_array', LOG_DEBUG); |
|
| 117 | - $resql=$this->db->query($sql); |
|
| 118 | - if ($resql) |
|
| 119 | - { |
|
| 120 | - $num = $this->db->num_rows($resql); |
|
| 121 | - $i = 0; |
|
| 122 | - |
|
| 123 | - while ($i < $num) |
|
| 124 | - { |
|
| 125 | - $objp = $this->db->fetch_object($resql); |
|
| 126 | - if (! $mode) $key=$objp->id; |
|
| 127 | - else $key=$objp->code; |
|
| 128 | - |
|
| 129 | - $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; |
|
| 130 | - $i++; |
|
| 131 | - } |
|
| 132 | - $this->db->free($resql); |
|
| 133 | - } |
|
| 134 | - return $effs; |
|
| 135 | - } |
|
| 109 | + $effs = array(); |
|
| 110 | + |
|
| 111 | + $sql = "SELECT id, code, libelle"; |
|
| 112 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; |
|
| 113 | + $sql.= " WHERE active = 1"; |
|
| 114 | + if ($filter) $sql.=" ".$filter; |
|
| 115 | + $sql .= " ORDER BY id ASC"; |
|
| 116 | + dol_syslog(get_class($this).'::effectif_array', LOG_DEBUG); |
|
| 117 | + $resql=$this->db->query($sql); |
|
| 118 | + if ($resql) |
|
| 119 | + { |
|
| 120 | + $num = $this->db->num_rows($resql); |
|
| 121 | + $i = 0; |
|
| 122 | + |
|
| 123 | + while ($i < $num) |
|
| 124 | + { |
|
| 125 | + $objp = $this->db->fetch_object($resql); |
|
| 126 | + if (! $mode) $key=$objp->id; |
|
| 127 | + else $key=$objp->code; |
|
| 128 | + |
|
| 129 | + $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; |
|
| 130 | + $i++; |
|
| 131 | + } |
|
| 132 | + $this->db->free($resql); |
|
| 133 | + } |
|
| 134 | + return $effs; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 139 | - /** |
|
| 140 | - * Affiche formulaire de selection des modes de reglement |
|
| 141 | - * |
|
| 142 | - * @param int $page Page |
|
| 143 | - * @param int $selected Id or code preselected |
|
| 144 | - * @param string $htmlname Nom du formulaire select |
|
| 145 | - * @param int $empty Add empty value in list |
|
| 146 | - * @return void |
|
| 147 | - */ |
|
| 148 | - function form_prospect_level($page, $selected='', $htmlname='prospect_level_id', $empty=0) |
|
| 149 | - { |
|
| 139 | + /** |
|
| 140 | + * Affiche formulaire de selection des modes de reglement |
|
| 141 | + * |
|
| 142 | + * @param int $page Page |
|
| 143 | + * @param int $selected Id or code preselected |
|
| 144 | + * @param string $htmlname Nom du formulaire select |
|
| 145 | + * @param int $empty Add empty value in list |
|
| 146 | + * @return void |
|
| 147 | + */ |
|
| 148 | + function form_prospect_level($page, $selected='', $htmlname='prospect_level_id', $empty=0) |
|
| 149 | + { |
|
| 150 | 150 | // phpcs:enable |
| 151 | - global $user, $langs; |
|
| 152 | - |
|
| 153 | - print '<form method="post" action="'.$page.'">'; |
|
| 154 | - print '<input type="hidden" name="action" value="setprospectlevel">'; |
|
| 155 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 156 | - |
|
| 157 | - dol_syslog(get_class($this).'::form_prospect_level',LOG_DEBUG); |
|
| 158 | - $sql = "SELECT code, label"; |
|
| 159 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; |
|
| 160 | - $sql.= " WHERE active > 0"; |
|
| 161 | - $sql.= " ORDER BY sortorder"; |
|
| 162 | - $resql = $this->db->query($sql); |
|
| 163 | - if ($resql) |
|
| 164 | - { |
|
| 165 | - $options = array(); |
|
| 166 | - |
|
| 167 | - if ($empty) { |
|
| 168 | - $options[''] = ''; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - while ($obj = $this->db->fetch_object($resql)) { |
|
| 172 | - $level = $langs->trans($obj->code); |
|
| 173 | - |
|
| 174 | - if ($level == $obj->code) { |
|
| 175 | - $level = $langs->trans($obj->label); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - $options[$obj->code] = $level; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - print Form::selectarray($htmlname, $options, $selected); |
|
| 182 | - } |
|
| 183 | - else dol_print_error($this->db); |
|
| 184 | - if (! empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 185 | - print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 186 | - print '</form>'; |
|
| 187 | - } |
|
| 151 | + global $user, $langs; |
|
| 152 | + |
|
| 153 | + print '<form method="post" action="'.$page.'">'; |
|
| 154 | + print '<input type="hidden" name="action" value="setprospectlevel">'; |
|
| 155 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 156 | + |
|
| 157 | + dol_syslog(get_class($this).'::form_prospect_level',LOG_DEBUG); |
|
| 158 | + $sql = "SELECT code, label"; |
|
| 159 | + $sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; |
|
| 160 | + $sql.= " WHERE active > 0"; |
|
| 161 | + $sql.= " ORDER BY sortorder"; |
|
| 162 | + $resql = $this->db->query($sql); |
|
| 163 | + if ($resql) |
|
| 164 | + { |
|
| 165 | + $options = array(); |
|
| 166 | + |
|
| 167 | + if ($empty) { |
|
| 168 | + $options[''] = ''; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + while ($obj = $this->db->fetch_object($resql)) { |
|
| 172 | + $level = $langs->trans($obj->code); |
|
| 173 | + |
|
| 174 | + if ($level == $obj->code) { |
|
| 175 | + $level = $langs->trans($obj->label); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + $options[$obj->code] = $level; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + print Form::selectarray($htmlname, $options, $selected); |
|
| 182 | + } |
|
| 183 | + else dol_print_error($this->db); |
|
| 184 | + if (! empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 185 | + print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
| 186 | + print '</form>'; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | 189 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 190 | - /** |
|
| 191 | - * Retourne la liste deroulante des departements/province/cantons tout pays confondu ou pour un pays donne. |
|
| 192 | - * Dans le cas d'une liste tout pays confondus, l'affichage fait une rupture sur le pays. |
|
| 193 | - * La cle de la liste est le code (il peut y avoir plusieurs entree pour |
|
| 194 | - * un code donnee mais dans ce cas, le champ pays differe). |
|
| 195 | - * Ainsi les liens avec les departements se font sur un departement independemment de son nom. |
|
| 196 | - * |
|
| 197 | - * @param string $selected Code state preselected |
|
| 198 | - * @param int $country_codeid 0=list for all countries, otherwise country code or country rowid to show |
|
| 199 | - * @param string $htmlname Id of department |
|
| 200 | - * @return void |
|
| 201 | - */ |
|
| 202 | - function select_departement($selected='',$country_codeid=0, $htmlname='state_id') |
|
| 203 | - { |
|
| 190 | + /** |
|
| 191 | + * Retourne la liste deroulante des departements/province/cantons tout pays confondu ou pour un pays donne. |
|
| 192 | + * Dans le cas d'une liste tout pays confondus, l'affichage fait une rupture sur le pays. |
|
| 193 | + * La cle de la liste est le code (il peut y avoir plusieurs entree pour |
|
| 194 | + * un code donnee mais dans ce cas, le champ pays differe). |
|
| 195 | + * Ainsi les liens avec les departements se font sur un departement independemment de son nom. |
|
| 196 | + * |
|
| 197 | + * @param string $selected Code state preselected |
|
| 198 | + * @param int $country_codeid 0=list for all countries, otherwise country code or country rowid to show |
|
| 199 | + * @param string $htmlname Id of department |
|
| 200 | + * @return void |
|
| 201 | + */ |
|
| 202 | + function select_departement($selected='',$country_codeid=0, $htmlname='state_id') |
|
| 203 | + { |
|
| 204 | 204 | // phpcs:enable |
| 205 | - print $this->select_state($selected,$country_codeid, $htmlname); |
|
| 206 | - } |
|
| 205 | + print $this->select_state($selected,$country_codeid, $htmlname); |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | 208 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 209 | - /** |
|
| 210 | - * Retourne la liste deroulante des departements/province/cantons tout pays confondu ou pour un pays donne. |
|
| 211 | - * Dans le cas d'une liste tout pays confondus, l'affichage fait une rupture sur le pays. |
|
| 212 | - * La cle de la liste est le code (il peut y avoir plusieurs entree pour |
|
| 213 | - * un code donnee mais dans ce cas, le champ pays differe). |
|
| 214 | - * Ainsi les liens avec les departements se font sur un departement independemment de son nom. |
|
| 215 | - * |
|
| 216 | - * @param string $selected Code state preselected (mus be state id) |
|
| 217 | - * @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show |
|
| 218 | - * @param string $htmlname Id of department. If '', we want only the string with <option> |
|
| 219 | - * @return string String with HTML select |
|
| 220 | - * @see select_country |
|
| 221 | - */ |
|
| 222 | - function select_state($selected='',$country_codeid=0, $htmlname='state_id') |
|
| 223 | - { |
|
| 209 | + /** |
|
| 210 | + * Retourne la liste deroulante des departements/province/cantons tout pays confondu ou pour un pays donne. |
|
| 211 | + * Dans le cas d'une liste tout pays confondus, l'affichage fait une rupture sur le pays. |
|
| 212 | + * La cle de la liste est le code (il peut y avoir plusieurs entree pour |
|
| 213 | + * un code donnee mais dans ce cas, le champ pays differe). |
|
| 214 | + * Ainsi les liens avec les departements se font sur un departement independemment de son nom. |
|
| 215 | + * |
|
| 216 | + * @param string $selected Code state preselected (mus be state id) |
|
| 217 | + * @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show |
|
| 218 | + * @param string $htmlname Id of department. If '', we want only the string with <option> |
|
| 219 | + * @return string String with HTML select |
|
| 220 | + * @see select_country |
|
| 221 | + */ |
|
| 222 | + function select_state($selected='',$country_codeid=0, $htmlname='state_id') |
|
| 223 | + { |
|
| 224 | 224 | // phpcs:enable |
| 225 | - global $conf,$langs,$user; |
|
| 226 | - |
|
| 227 | - dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid,LOG_DEBUG); |
|
| 228 | - |
|
| 229 | - $langs->load("dict"); |
|
| 230 | - |
|
| 231 | - $out=''; |
|
| 232 | - |
|
| 233 | - // Serch departements/cantons/province active d'une region et pays actif |
|
| 234 | - $sql = "SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.nom as region_name FROM"; |
|
| 235 | - $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; |
|
| 236 | - $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; |
|
| 237 | - $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; |
|
| 238 | - if ($country_codeid && is_numeric($country_codeid)) $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; |
|
| 239 | - if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; |
|
| 240 | - $sql .= " ORDER BY c.code, d.code_departement"; |
|
| 241 | - |
|
| 242 | - $result=$this->db->query($sql); |
|
| 243 | - if ($result) |
|
| 244 | - { |
|
| 245 | - if (!empty($htmlname)) $out.= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
| 246 | - if ($country_codeid) $out.= '<option value="0"> </option>'; |
|
| 247 | - $num = $this->db->num_rows($result); |
|
| 248 | - $i = 0; |
|
| 249 | - dol_syslog(get_class($this)."::select_departement num=".$num,LOG_DEBUG); |
|
| 250 | - if ($num) |
|
| 251 | - { |
|
| 252 | - $country=''; |
|
| 253 | - while ($i < $num) |
|
| 254 | - { |
|
| 255 | - $obj = $this->db->fetch_object($result); |
|
| 256 | - if ($obj->code == '0') // Le code peut etre une chaine |
|
| 257 | - { |
|
| 258 | - $out.= '<option value="0"> </option>'; |
|
| 259 | - } |
|
| 260 | - else { |
|
| 261 | - if (! $country || $country != $obj->country) |
|
| 262 | - { |
|
| 263 | - // Affiche la rupture si on est en mode liste multipays |
|
| 264 | - if (! $country_codeid && $obj->country_code) |
|
| 265 | - { |
|
| 266 | - $out.= '<option value="-1" disabled>----- '.$obj->country." -----</option>\n"; |
|
| 267 | - $country=$obj->country; |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - if ((! empty($selected) && $selected == $obj->rowid) |
|
| 272 | - || (empty($selected) && ! empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) |
|
| 273 | - { |
|
| 274 | - $out.= '<option value="'.$obj->rowid.'" selected>'; |
|
| 275 | - } |
|
| 276 | - else |
|
| 277 | - { |
|
| 278 | - $out.= '<option value="'.$obj->rowid.'">'; |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut |
|
| 282 | - if (!empty($conf->global->MAIN_SHOW_STATE_CODE) && |
|
| 283 | - ($conf->global->MAIN_SHOW_STATE_CODE == 1 || $conf->global->MAIN_SHOW_STATE_CODE == 2 || $conf->global->MAIN_SHOW_STATE_CODE === 'all')) { |
|
| 284 | - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
| 285 | - $out.= $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 286 | - } |
|
| 287 | - else { |
|
| 288 | - $out.= $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 289 | - } |
|
| 290 | - } |
|
| 291 | - else { |
|
| 292 | - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
| 293 | - $out.= $obj->region_name . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 294 | - } |
|
| 295 | - else { |
|
| 296 | - $out.= ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - $out.= '</option>'; |
|
| 301 | - } |
|
| 302 | - $i++; |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - if (! empty($htmlname)) $out.= '</select>'; |
|
| 306 | - if (! empty($htmlname) && $user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 307 | - } |
|
| 308 | - else |
|
| 309 | - { |
|
| 310 | - dol_print_error($this->db); |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - // Make select dynamic |
|
| 314 | - if (! empty($htmlname)) |
|
| 315 | - { |
|
| 316 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 317 | - $out .= ajax_combobox($htmlname); |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - return $out; |
|
| 321 | - } |
|
| 225 | + global $conf,$langs,$user; |
|
| 226 | + |
|
| 227 | + dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid,LOG_DEBUG); |
|
| 228 | + |
|
| 229 | + $langs->load("dict"); |
|
| 230 | + |
|
| 231 | + $out=''; |
|
| 232 | + |
|
| 233 | + // Serch departements/cantons/province active d'une region et pays actif |
|
| 234 | + $sql = "SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.nom as region_name FROM"; |
|
| 235 | + $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; |
|
| 236 | + $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; |
|
| 237 | + $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; |
|
| 238 | + if ($country_codeid && is_numeric($country_codeid)) $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; |
|
| 239 | + if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; |
|
| 240 | + $sql .= " ORDER BY c.code, d.code_departement"; |
|
| 241 | + |
|
| 242 | + $result=$this->db->query($sql); |
|
| 243 | + if ($result) |
|
| 244 | + { |
|
| 245 | + if (!empty($htmlname)) $out.= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
| 246 | + if ($country_codeid) $out.= '<option value="0"> </option>'; |
|
| 247 | + $num = $this->db->num_rows($result); |
|
| 248 | + $i = 0; |
|
| 249 | + dol_syslog(get_class($this)."::select_departement num=".$num,LOG_DEBUG); |
|
| 250 | + if ($num) |
|
| 251 | + { |
|
| 252 | + $country=''; |
|
| 253 | + while ($i < $num) |
|
| 254 | + { |
|
| 255 | + $obj = $this->db->fetch_object($result); |
|
| 256 | + if ($obj->code == '0') // Le code peut etre une chaine |
|
| 257 | + { |
|
| 258 | + $out.= '<option value="0"> </option>'; |
|
| 259 | + } |
|
| 260 | + else { |
|
| 261 | + if (! $country || $country != $obj->country) |
|
| 262 | + { |
|
| 263 | + // Affiche la rupture si on est en mode liste multipays |
|
| 264 | + if (! $country_codeid && $obj->country_code) |
|
| 265 | + { |
|
| 266 | + $out.= '<option value="-1" disabled>----- '.$obj->country." -----</option>\n"; |
|
| 267 | + $country=$obj->country; |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + if ((! empty($selected) && $selected == $obj->rowid) |
|
| 272 | + || (empty($selected) && ! empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) |
|
| 273 | + { |
|
| 274 | + $out.= '<option value="'.$obj->rowid.'" selected>'; |
|
| 275 | + } |
|
| 276 | + else |
|
| 277 | + { |
|
| 278 | + $out.= '<option value="'.$obj->rowid.'">'; |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut |
|
| 282 | + if (!empty($conf->global->MAIN_SHOW_STATE_CODE) && |
|
| 283 | + ($conf->global->MAIN_SHOW_STATE_CODE == 1 || $conf->global->MAIN_SHOW_STATE_CODE == 2 || $conf->global->MAIN_SHOW_STATE_CODE === 'all')) { |
|
| 284 | + if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
| 285 | + $out.= $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 286 | + } |
|
| 287 | + else { |
|
| 288 | + $out.= $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 289 | + } |
|
| 290 | + } |
|
| 291 | + else { |
|
| 292 | + if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
| 293 | + $out.= $obj->region_name . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 294 | + } |
|
| 295 | + else { |
|
| 296 | + $out.= ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + $out.= '</option>'; |
|
| 301 | + } |
|
| 302 | + $i++; |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + if (! empty($htmlname)) $out.= '</select>'; |
|
| 306 | + if (! empty($htmlname) && $user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 307 | + } |
|
| 308 | + else |
|
| 309 | + { |
|
| 310 | + dol_print_error($this->db); |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + // Make select dynamic |
|
| 314 | + if (! empty($htmlname)) |
|
| 315 | + { |
|
| 316 | + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 317 | + $out .= ajax_combobox($htmlname); |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + return $out; |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | 323 | |
| 324 | 324 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 325 | - /** |
|
| 326 | - * Retourne la liste deroulante des regions actives dont le pays est actif |
|
| 327 | - * La cle de la liste est le code (il peut y avoir plusieurs entree pour |
|
| 328 | - * un code donnee mais dans ce cas, le champ pays et lang differe). |
|
| 329 | - * Ainsi les liens avec les regions se font sur une region independemment de son name. |
|
| 330 | - * |
|
| 331 | - * @param string $selected Preselected value |
|
| 332 | - * @param string $htmlname Name of HTML select field |
|
| 333 | - * @return void |
|
| 334 | - */ |
|
| 335 | - function select_region($selected='',$htmlname='region_id') |
|
| 336 | - { |
|
| 325 | + /** |
|
| 326 | + * Retourne la liste deroulante des regions actives dont le pays est actif |
|
| 327 | + * La cle de la liste est le code (il peut y avoir plusieurs entree pour |
|
| 328 | + * un code donnee mais dans ce cas, le champ pays et lang differe). |
|
| 329 | + * Ainsi les liens avec les regions se font sur une region independemment de son name. |
|
| 330 | + * |
|
| 331 | + * @param string $selected Preselected value |
|
| 332 | + * @param string $htmlname Name of HTML select field |
|
| 333 | + * @return void |
|
| 334 | + */ |
|
| 335 | + function select_region($selected='',$htmlname='region_id') |
|
| 336 | + { |
|
| 337 | 337 | // phpcs:enable |
| 338 | - global $conf,$langs; |
|
| 339 | - $langs->load("dict"); |
|
| 340 | - |
|
| 341 | - $sql = "SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country"; |
|
| 342 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c"; |
|
| 343 | - $sql.= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1"; |
|
| 344 | - $sql.= " ORDER BY c.code, c.label ASC"; |
|
| 345 | - |
|
| 346 | - dol_syslog(get_class($this)."::select_region", LOG_DEBUG); |
|
| 347 | - $resql=$this->db->query($sql); |
|
| 348 | - if ($resql) |
|
| 349 | - { |
|
| 350 | - print '<select class="flat" name="'.$htmlname.'">'; |
|
| 351 | - $num = $this->db->num_rows($resql); |
|
| 352 | - $i = 0; |
|
| 353 | - if ($num) |
|
| 354 | - { |
|
| 355 | - $country=''; |
|
| 356 | - while ($i < $num) |
|
| 357 | - { |
|
| 358 | - $obj = $this->db->fetch_object($resql); |
|
| 359 | - if ($obj->code == 0) { |
|
| 360 | - print '<option value="0"> </option>'; |
|
| 361 | - } |
|
| 362 | - else { |
|
| 363 | - if ($country == '' || $country != $obj->country) |
|
| 364 | - { |
|
| 365 | - // Show break |
|
| 366 | - $key=$langs->trans("Country".strtoupper($obj->country_code)); |
|
| 367 | - $valuetoshow=($key != "Country".strtoupper($obj->country_code))?$obj->country_code." - ".$key:$obj->country; |
|
| 368 | - print '<option value="-1" disabled>----- '.$valuetoshow." -----</option>\n"; |
|
| 369 | - $country=$obj->country; |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - if ($selected > 0 && $selected == $obj->code) |
|
| 373 | - { |
|
| 374 | - print '<option value="'.$obj->code.'" selected>'.$obj->label.'</option>'; |
|
| 375 | - } |
|
| 376 | - else |
|
| 377 | - { |
|
| 378 | - print '<option value="'.$obj->code.'">'.$obj->label.'</option>'; |
|
| 379 | - } |
|
| 380 | - } |
|
| 381 | - $i++; |
|
| 382 | - } |
|
| 383 | - } |
|
| 384 | - print '</select>'; |
|
| 385 | - } |
|
| 386 | - else |
|
| 387 | - { |
|
| 388 | - dol_print_error($this->db); |
|
| 389 | - } |
|
| 390 | - } |
|
| 338 | + global $conf,$langs; |
|
| 339 | + $langs->load("dict"); |
|
| 340 | + |
|
| 341 | + $sql = "SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country"; |
|
| 342 | + $sql.= " FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c"; |
|
| 343 | + $sql.= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1"; |
|
| 344 | + $sql.= " ORDER BY c.code, c.label ASC"; |
|
| 345 | + |
|
| 346 | + dol_syslog(get_class($this)."::select_region", LOG_DEBUG); |
|
| 347 | + $resql=$this->db->query($sql); |
|
| 348 | + if ($resql) |
|
| 349 | + { |
|
| 350 | + print '<select class="flat" name="'.$htmlname.'">'; |
|
| 351 | + $num = $this->db->num_rows($resql); |
|
| 352 | + $i = 0; |
|
| 353 | + if ($num) |
|
| 354 | + { |
|
| 355 | + $country=''; |
|
| 356 | + while ($i < $num) |
|
| 357 | + { |
|
| 358 | + $obj = $this->db->fetch_object($resql); |
|
| 359 | + if ($obj->code == 0) { |
|
| 360 | + print '<option value="0"> </option>'; |
|
| 361 | + } |
|
| 362 | + else { |
|
| 363 | + if ($country == '' || $country != $obj->country) |
|
| 364 | + { |
|
| 365 | + // Show break |
|
| 366 | + $key=$langs->trans("Country".strtoupper($obj->country_code)); |
|
| 367 | + $valuetoshow=($key != "Country".strtoupper($obj->country_code))?$obj->country_code." - ".$key:$obj->country; |
|
| 368 | + print '<option value="-1" disabled>----- '.$valuetoshow." -----</option>\n"; |
|
| 369 | + $country=$obj->country; |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + if ($selected > 0 && $selected == $obj->code) |
|
| 373 | + { |
|
| 374 | + print '<option value="'.$obj->code.'" selected>'.$obj->label.'</option>'; |
|
| 375 | + } |
|
| 376 | + else |
|
| 377 | + { |
|
| 378 | + print '<option value="'.$obj->code.'">'.$obj->label.'</option>'; |
|
| 379 | + } |
|
| 380 | + } |
|
| 381 | + $i++; |
|
| 382 | + } |
|
| 383 | + } |
|
| 384 | + print '</select>'; |
|
| 385 | + } |
|
| 386 | + else |
|
| 387 | + { |
|
| 388 | + dol_print_error($this->db); |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | 392 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 393 | - /** |
|
| 394 | - * Return combo list with people title |
|
| 395 | - * |
|
| 396 | - * @param string $selected Title preselected |
|
| 397 | - * @param string $htmlname Name of HTML select combo field |
|
| 398 | - * @param string $morecss Add more css on SELECT element |
|
| 399 | - * @return string String with HTML select |
|
| 400 | - */ |
|
| 401 | - function select_civility($selected='',$htmlname='civility_id',$morecss='maxwidth100') |
|
| 402 | - { |
|
| 393 | + /** |
|
| 394 | + * Return combo list with people title |
|
| 395 | + * |
|
| 396 | + * @param string $selected Title preselected |
|
| 397 | + * @param string $htmlname Name of HTML select combo field |
|
| 398 | + * @param string $morecss Add more css on SELECT element |
|
| 399 | + * @return string String with HTML select |
|
| 400 | + */ |
|
| 401 | + function select_civility($selected='',$htmlname='civility_id',$morecss='maxwidth100') |
|
| 402 | + { |
|
| 403 | 403 | // phpcs:enable |
| 404 | - global $conf,$langs,$user; |
|
| 405 | - $langs->load("dict"); |
|
| 406 | - |
|
| 407 | - $out=''; |
|
| 408 | - |
|
| 409 | - $sql = "SELECT rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_civility"; |
|
| 410 | - $sql.= " WHERE active = 1"; |
|
| 411 | - |
|
| 412 | - dol_syslog("Form::select_civility", LOG_DEBUG); |
|
| 413 | - $resql=$this->db->query($sql); |
|
| 414 | - if ($resql) |
|
| 415 | - { |
|
| 416 | - $out.= '<select class="flat'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 417 | - $out.= '<option value=""> </option>'; |
|
| 418 | - $num = $this->db->num_rows($resql); |
|
| 419 | - $i = 0; |
|
| 420 | - if ($num) |
|
| 421 | - { |
|
| 422 | - while ($i < $num) |
|
| 423 | - { |
|
| 424 | - $obj = $this->db->fetch_object($resql); |
|
| 425 | - if ($selected == $obj->code) |
|
| 426 | - { |
|
| 427 | - $out.= '<option value="'.$obj->code.'" selected>'; |
|
| 428 | - } |
|
| 429 | - else |
|
| 430 | - { |
|
| 431 | - $out.= '<option value="'.$obj->code.'">'; |
|
| 432 | - } |
|
| 433 | - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut |
|
| 434 | - $out.= ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->label!='-'?$obj->label:'')); |
|
| 435 | - $out.= '</option>'; |
|
| 436 | - $i++; |
|
| 437 | - } |
|
| 438 | - } |
|
| 439 | - $out.= '</select>'; |
|
| 440 | - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 441 | - } |
|
| 442 | - else |
|
| 443 | - { |
|
| 444 | - dol_print_error($this->db); |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - return $out; |
|
| 448 | - } |
|
| 404 | + global $conf,$langs,$user; |
|
| 405 | + $langs->load("dict"); |
|
| 406 | + |
|
| 407 | + $out=''; |
|
| 408 | + |
|
| 409 | + $sql = "SELECT rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_civility"; |
|
| 410 | + $sql.= " WHERE active = 1"; |
|
| 411 | + |
|
| 412 | + dol_syslog("Form::select_civility", LOG_DEBUG); |
|
| 413 | + $resql=$this->db->query($sql); |
|
| 414 | + if ($resql) |
|
| 415 | + { |
|
| 416 | + $out.= '<select class="flat'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 417 | + $out.= '<option value=""> </option>'; |
|
| 418 | + $num = $this->db->num_rows($resql); |
|
| 419 | + $i = 0; |
|
| 420 | + if ($num) |
|
| 421 | + { |
|
| 422 | + while ($i < $num) |
|
| 423 | + { |
|
| 424 | + $obj = $this->db->fetch_object($resql); |
|
| 425 | + if ($selected == $obj->code) |
|
| 426 | + { |
|
| 427 | + $out.= '<option value="'.$obj->code.'" selected>'; |
|
| 428 | + } |
|
| 429 | + else |
|
| 430 | + { |
|
| 431 | + $out.= '<option value="'.$obj->code.'">'; |
|
| 432 | + } |
|
| 433 | + // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut |
|
| 434 | + $out.= ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->label!='-'?$obj->label:'')); |
|
| 435 | + $out.= '</option>'; |
|
| 436 | + $i++; |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | + $out.= '</select>'; |
|
| 440 | + if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 441 | + } |
|
| 442 | + else |
|
| 443 | + { |
|
| 444 | + dol_print_error($this->db); |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + return $out; |
|
| 448 | + } |
|
| 449 | 449 | |
| 450 | 450 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 451 | - /** |
|
| 452 | - * Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne. |
|
| 453 | - * Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays. |
|
| 454 | - * |
|
| 455 | - * @param string $selected Code forme juridique a pre-selectionne |
|
| 456 | - * @param mixed $country_codeid 0=liste tous pays confondus, sinon code du pays a afficher |
|
| 457 | - * @param string $filter Add a SQL filter on list |
|
| 458 | - * @return void |
|
| 459 | - * @deprecated Use print xxx->select_juridicalstatus instead |
|
| 460 | - * @see select_juridicalstatus() |
|
| 461 | - */ |
|
| 462 | - function select_forme_juridique($selected='', $country_codeid=0, $filter='') |
|
| 463 | - { |
|
| 451 | + /** |
|
| 452 | + * Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne. |
|
| 453 | + * Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays. |
|
| 454 | + * |
|
| 455 | + * @param string $selected Code forme juridique a pre-selectionne |
|
| 456 | + * @param mixed $country_codeid 0=liste tous pays confondus, sinon code du pays a afficher |
|
| 457 | + * @param string $filter Add a SQL filter on list |
|
| 458 | + * @return void |
|
| 459 | + * @deprecated Use print xxx->select_juridicalstatus instead |
|
| 460 | + * @see select_juridicalstatus() |
|
| 461 | + */ |
|
| 462 | + function select_forme_juridique($selected='', $country_codeid=0, $filter='') |
|
| 463 | + { |
|
| 464 | 464 | // phpcs:enable |
| 465 | - print $this->select_juridicalstatus($selected, $country_codeid, $filter); |
|
| 466 | - } |
|
| 465 | + print $this->select_juridicalstatus($selected, $country_codeid, $filter); |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | 468 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 469 | - /** |
|
| 470 | - * Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne. |
|
| 471 | - * Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays |
|
| 472 | - * |
|
| 473 | - * @param string $selected Preselected code of juridical type |
|
| 474 | - * @param int $country_codeid 0=list for all countries, otherwise list only country requested |
|
| 469 | + /** |
|
| 470 | + * Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne. |
|
| 471 | + * Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays |
|
| 472 | + * |
|
| 473 | + * @param string $selected Preselected code of juridical type |
|
| 474 | + * @param int $country_codeid 0=list for all countries, otherwise list only country requested |
|
| 475 | 475 | * @param string $filter Add a SQL filter on list |
| 476 | 476 | * @param string $htmlname HTML name of select |
| 477 | 477 | * @return string String with HTML select |
| 478 | - */ |
|
| 479 | - function select_juridicalstatus($selected='', $country_codeid=0, $filter='', $htmlname='forme_juridique_code') |
|
| 480 | - { |
|
| 478 | + */ |
|
| 479 | + function select_juridicalstatus($selected='', $country_codeid=0, $filter='', $htmlname='forme_juridique_code') |
|
| 480 | + { |
|
| 481 | 481 | // phpcs:enable |
| 482 | - global $conf,$langs,$user; |
|
| 483 | - $langs->load("dict"); |
|
| 484 | - |
|
| 485 | - $out=''; |
|
| 486 | - |
|
| 487 | - // On recherche les formes juridiques actives des pays actifs |
|
| 488 | - $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code"; |
|
| 489 | - $sql .= " FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c"; |
|
| 490 | - $sql .= " WHERE f.fk_pays=c.rowid"; |
|
| 491 | - $sql .= " AND f.active = 1 AND c.active = 1"; |
|
| 492 | - if ($country_codeid) $sql .= " AND c.code = '".$country_codeid."'"; |
|
| 493 | - if ($filter) $sql .= " ".$filter; |
|
| 494 | - $sql .= " ORDER BY c.code"; |
|
| 495 | - |
|
| 496 | - dol_syslog(get_class($this)."::select_juridicalstatus", LOG_DEBUG); |
|
| 497 | - $resql=$this->db->query($sql); |
|
| 498 | - if ($resql) |
|
| 499 | - { |
|
| 500 | - $out.= '<div id="particulier2" class="visible">'; |
|
| 501 | - $out.= '<select class="flat minwidth200" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 502 | - if ($country_codeid) $out.= '<option value="0"> </option>'; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. |
|
| 503 | - |
|
| 504 | - $num = $this->db->num_rows($resql); |
|
| 505 | - if ($num) |
|
| 506 | - { |
|
| 507 | - $i = 0; |
|
| 508 | - $country=''; $arraydata=array(); |
|
| 509 | - while ($i < $num) |
|
| 510 | - { |
|
| 511 | - $obj = $this->db->fetch_object($resql); |
|
| 512 | - |
|
| 513 | - if ($obj->code) // We exclude empty line, we will add it later |
|
| 514 | - { |
|
| 515 | - $labelcountry=(($langs->trans("Country".$obj->country_code)!="Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); |
|
| 516 | - $labeljs=(($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label!='-'?$obj->label:'')); // $obj->label is already in output charset (converted by database driver) |
|
| 517 | - $arraydata[$obj->code]=array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); |
|
| 518 | - } |
|
| 519 | - $i++; |
|
| 520 | - } |
|
| 521 | - |
|
| 522 | - $arraydata=dol_sort_array($arraydata, 'label_sort', 'ASC'); |
|
| 523 | - if (empty($country_codeid)) // Introduce empty value (if $country_codeid not empty, empty value was already added) |
|
| 524 | - { |
|
| 525 | - $arraydata[0]=array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - foreach($arraydata as $key => $val) |
|
| 529 | - { |
|
| 530 | - if (! $country || $country != $val['country']) |
|
| 531 | - { |
|
| 532 | - // Show break when we are in multi country mode |
|
| 533 | - if (empty($country_codeid) && $val['country_code']) |
|
| 534 | - { |
|
| 535 | - $out.= '<option value="0" disabled class="selectoptiondisabledwhite">----- '.$val['country']." -----</option>\n"; |
|
| 536 | - $country=$val['country']; |
|
| 537 | - } |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - if ($selected > 0 && $selected == $val['code']) |
|
| 541 | - { |
|
| 542 | - $out.= '<option value="'.$val['code'].'" selected>'; |
|
| 543 | - } |
|
| 544 | - else |
|
| 545 | - { |
|
| 546 | - $out.= '<option value="'.$val['code'].'">'; |
|
| 547 | - } |
|
| 548 | - // If translation exists, we use it, otherwise we use default label in database |
|
| 549 | - $out.= $val['label']; |
|
| 550 | - $out.= '</option>'; |
|
| 551 | - } |
|
| 552 | - } |
|
| 553 | - $out.= '</select>'; |
|
| 554 | - if ($user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 555 | - |
|
| 556 | - // Make select dynamic |
|
| 557 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 558 | - $out .= ajax_combobox($htmlname); |
|
| 559 | - |
|
| 560 | - $out.= '</div>'; |
|
| 561 | - } |
|
| 562 | - else |
|
| 563 | - { |
|
| 564 | - dol_print_error($this->db); |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - return $out; |
|
| 568 | - } |
|
| 569 | - |
|
| 570 | - |
|
| 571 | - /** |
|
| 572 | - * Output list of third parties. |
|
| 573 | - * |
|
| 574 | - * @param object $object Object we try to find contacts |
|
| 575 | - * @param string $var_id Name of id field |
|
| 576 | - * @param string $selected Pre-selected third party |
|
| 577 | - * @param string $htmlname Name of HTML form |
|
| 578 | - * @param array $limitto Disable answers that are not id in this array list |
|
| 579 | - * @param int $forceid This is to force another object id than object->id |
|
| 482 | + global $conf,$langs,$user; |
|
| 483 | + $langs->load("dict"); |
|
| 484 | + |
|
| 485 | + $out=''; |
|
| 486 | + |
|
| 487 | + // On recherche les formes juridiques actives des pays actifs |
|
| 488 | + $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code"; |
|
| 489 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c"; |
|
| 490 | + $sql .= " WHERE f.fk_pays=c.rowid"; |
|
| 491 | + $sql .= " AND f.active = 1 AND c.active = 1"; |
|
| 492 | + if ($country_codeid) $sql .= " AND c.code = '".$country_codeid."'"; |
|
| 493 | + if ($filter) $sql .= " ".$filter; |
|
| 494 | + $sql .= " ORDER BY c.code"; |
|
| 495 | + |
|
| 496 | + dol_syslog(get_class($this)."::select_juridicalstatus", LOG_DEBUG); |
|
| 497 | + $resql=$this->db->query($sql); |
|
| 498 | + if ($resql) |
|
| 499 | + { |
|
| 500 | + $out.= '<div id="particulier2" class="visible">'; |
|
| 501 | + $out.= '<select class="flat minwidth200" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 502 | + if ($country_codeid) $out.= '<option value="0"> </option>'; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. |
|
| 503 | + |
|
| 504 | + $num = $this->db->num_rows($resql); |
|
| 505 | + if ($num) |
|
| 506 | + { |
|
| 507 | + $i = 0; |
|
| 508 | + $country=''; $arraydata=array(); |
|
| 509 | + while ($i < $num) |
|
| 510 | + { |
|
| 511 | + $obj = $this->db->fetch_object($resql); |
|
| 512 | + |
|
| 513 | + if ($obj->code) // We exclude empty line, we will add it later |
|
| 514 | + { |
|
| 515 | + $labelcountry=(($langs->trans("Country".$obj->country_code)!="Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); |
|
| 516 | + $labeljs=(($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label!='-'?$obj->label:'')); // $obj->label is already in output charset (converted by database driver) |
|
| 517 | + $arraydata[$obj->code]=array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); |
|
| 518 | + } |
|
| 519 | + $i++; |
|
| 520 | + } |
|
| 521 | + |
|
| 522 | + $arraydata=dol_sort_array($arraydata, 'label_sort', 'ASC'); |
|
| 523 | + if (empty($country_codeid)) // Introduce empty value (if $country_codeid not empty, empty value was already added) |
|
| 524 | + { |
|
| 525 | + $arraydata[0]=array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + foreach($arraydata as $key => $val) |
|
| 529 | + { |
|
| 530 | + if (! $country || $country != $val['country']) |
|
| 531 | + { |
|
| 532 | + // Show break when we are in multi country mode |
|
| 533 | + if (empty($country_codeid) && $val['country_code']) |
|
| 534 | + { |
|
| 535 | + $out.= '<option value="0" disabled class="selectoptiondisabledwhite">----- '.$val['country']." -----</option>\n"; |
|
| 536 | + $country=$val['country']; |
|
| 537 | + } |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + if ($selected > 0 && $selected == $val['code']) |
|
| 541 | + { |
|
| 542 | + $out.= '<option value="'.$val['code'].'" selected>'; |
|
| 543 | + } |
|
| 544 | + else |
|
| 545 | + { |
|
| 546 | + $out.= '<option value="'.$val['code'].'">'; |
|
| 547 | + } |
|
| 548 | + // If translation exists, we use it, otherwise we use default label in database |
|
| 549 | + $out.= $val['label']; |
|
| 550 | + $out.= '</option>'; |
|
| 551 | + } |
|
| 552 | + } |
|
| 553 | + $out.= '</select>'; |
|
| 554 | + if ($user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 555 | + |
|
| 556 | + // Make select dynamic |
|
| 557 | + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 558 | + $out .= ajax_combobox($htmlname); |
|
| 559 | + |
|
| 560 | + $out.= '</div>'; |
|
| 561 | + } |
|
| 562 | + else |
|
| 563 | + { |
|
| 564 | + dol_print_error($this->db); |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + return $out; |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + |
|
| 571 | + /** |
|
| 572 | + * Output list of third parties. |
|
| 573 | + * |
|
| 574 | + * @param object $object Object we try to find contacts |
|
| 575 | + * @param string $var_id Name of id field |
|
| 576 | + * @param string $selected Pre-selected third party |
|
| 577 | + * @param string $htmlname Name of HTML form |
|
| 578 | + * @param array $limitto Disable answers that are not id in this array list |
|
| 579 | + * @param int $forceid This is to force another object id than object->id |
|
| 580 | 580 | * @param string $moreparam String with more param to add into url when noajax search is used. |
| 581 | 581 | * @param string $morecss More CSS on select component |
| 582 | - * @return int The selected third party ID |
|
| 583 | - */ |
|
| 584 | - function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0, $moreparam='', $morecss='') |
|
| 585 | - { |
|
| 586 | - global $conf, $langs; |
|
| 587 | - |
|
| 588 | - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) |
|
| 589 | - { |
|
| 590 | - // Use Ajax search |
|
| 591 | - $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2); |
|
| 592 | - |
|
| 593 | - $socid=0; $name=''; |
|
| 594 | - if ($selected > 0) |
|
| 595 | - { |
|
| 596 | - $tmpthirdparty=new Societe($this->db); |
|
| 597 | - $result = $tmpthirdparty->fetch($selected); |
|
| 598 | - if ($result > 0) |
|
| 599 | - { |
|
| 600 | - $socid = $selected; |
|
| 601 | - $name = $tmpthirdparty->name; |
|
| 602 | - } |
|
| 603 | - } |
|
| 604 | - |
|
| 605 | - |
|
| 606 | - $events=array(); |
|
| 607 | - // Add an entry 'method' to say 'yes, we must execute url with param action = method'; |
|
| 608 | - // Add an entry 'url' to say which url to execute |
|
| 609 | - // Add an entry htmlname to say which element we must change once url is called |
|
| 610 | - // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines |
|
| 611 | - // To refresh contacts list on thirdparty list change |
|
| 612 | - $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); |
|
| 613 | - |
|
| 614 | - if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events |
|
| 615 | - { |
|
| 616 | - print '<script type="text/javascript"> |
|
| 582 | + * @return int The selected third party ID |
|
| 583 | + */ |
|
| 584 | + function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0, $moreparam='', $morecss='') |
|
| 585 | + { |
|
| 586 | + global $conf, $langs; |
|
| 587 | + |
|
| 588 | + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) |
|
| 589 | + { |
|
| 590 | + // Use Ajax search |
|
| 591 | + $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2); |
|
| 592 | + |
|
| 593 | + $socid=0; $name=''; |
|
| 594 | + if ($selected > 0) |
|
| 595 | + { |
|
| 596 | + $tmpthirdparty=new Societe($this->db); |
|
| 597 | + $result = $tmpthirdparty->fetch($selected); |
|
| 598 | + if ($result > 0) |
|
| 599 | + { |
|
| 600 | + $socid = $selected; |
|
| 601 | + $name = $tmpthirdparty->name; |
|
| 602 | + } |
|
| 603 | + } |
|
| 604 | + |
|
| 605 | + |
|
| 606 | + $events=array(); |
|
| 607 | + // Add an entry 'method' to say 'yes, we must execute url with param action = method'; |
|
| 608 | + // Add an entry 'url' to say which url to execute |
|
| 609 | + // Add an entry htmlname to say which element we must change once url is called |
|
| 610 | + // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines |
|
| 611 | + // To refresh contacts list on thirdparty list change |
|
| 612 | + $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); |
|
| 613 | + |
|
| 614 | + if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events |
|
| 615 | + { |
|
| 616 | + print '<script type="text/javascript"> |
|
| 617 | 617 | jQuery(document).ready(function() { |
| 618 | 618 | $("#search_'.$htmlname.'").change(function() { |
| 619 | 619 | var obj = '.json_encode($events).'; |
@@ -661,72 +661,72 @@ discard block |
||
| 661 | 661 | }; |
| 662 | 662 | }); |
| 663 | 663 | </script>'; |
| 664 | - } |
|
| 665 | - |
|
| 666 | - print "\n".'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n"; |
|
| 667 | - print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$name.'" />'; |
|
| 668 | - print ajax_autocompleter(($socid?$socid:-1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); |
|
| 669 | - return $socid; |
|
| 670 | - } |
|
| 671 | - else |
|
| 672 | - { |
|
| 673 | - // Search to list thirdparties |
|
| 674 | - $sql = "SELECT s.rowid, s.nom as name FROM"; |
|
| 675 | - $sql.= " ".MAIN_DB_PREFIX."societe as s"; |
|
| 676 | - $sql.= " WHERE s.entity IN (".getEntity('societe').")"; |
|
| 677 | - // For ajax search we limit here. For combo list, we limit later |
|
| 678 | - if (is_array($limitto) && count($limitto)) |
|
| 679 | - { |
|
| 680 | - $sql.= " AND s.rowid IN (".join(',',$limitto).")"; |
|
| 681 | - } |
|
| 682 | - $sql.= " ORDER BY s.nom ASC"; |
|
| 683 | - |
|
| 684 | - $resql = $this->db->query($sql); |
|
| 685 | - if ($resql) |
|
| 686 | - { |
|
| 687 | - print '<select class="flat'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'"'; |
|
| 688 | - if ($conf->use_javascript_ajax) |
|
| 689 | - { |
|
| 690 | - $javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id).$moreparam."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; |
|
| 691 | - print ' onChange="'.$javaScript.'"'; |
|
| 692 | - } |
|
| 693 | - print '>'; |
|
| 694 | - $num = $this->db->num_rows($resql); |
|
| 695 | - $i = 0; |
|
| 696 | - if ($num) |
|
| 697 | - { |
|
| 698 | - while ($i < $num) |
|
| 699 | - { |
|
| 700 | - $obj = $this->db->fetch_object($resql); |
|
| 701 | - if ($i == 0) $firstCompany = $obj->rowid; |
|
| 702 | - $disabled=0; |
|
| 703 | - if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1; |
|
| 704 | - if ($selected > 0 && $selected == $obj->rowid) |
|
| 705 | - { |
|
| 706 | - print '<option value="'.$obj->rowid.'"'; |
|
| 707 | - if ($disabled) print ' disabled'; |
|
| 708 | - print ' selected>'.dol_trunc($obj->name,24).'</option>'; |
|
| 709 | - $firstCompany = $obj->rowid; |
|
| 710 | - } |
|
| 711 | - else |
|
| 712 | - { |
|
| 713 | - print '<option value="'.$obj->rowid.'"'; |
|
| 714 | - if ($disabled) print ' disabled'; |
|
| 715 | - print '>'.dol_trunc($obj->name,24).'</option>'; |
|
| 716 | - } |
|
| 717 | - $i ++; |
|
| 718 | - } |
|
| 719 | - } |
|
| 720 | - print "</select>\n"; |
|
| 721 | - return $firstCompany; |
|
| 722 | - } |
|
| 723 | - else |
|
| 724 | - { |
|
| 725 | - dol_print_error($this->db); |
|
| 726 | - print 'Error sql'; |
|
| 727 | - } |
|
| 728 | - } |
|
| 729 | - } |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + print "\n".'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n"; |
|
| 667 | + print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$name.'" />'; |
|
| 668 | + print ajax_autocompleter(($socid?$socid:-1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); |
|
| 669 | + return $socid; |
|
| 670 | + } |
|
| 671 | + else |
|
| 672 | + { |
|
| 673 | + // Search to list thirdparties |
|
| 674 | + $sql = "SELECT s.rowid, s.nom as name FROM"; |
|
| 675 | + $sql.= " ".MAIN_DB_PREFIX."societe as s"; |
|
| 676 | + $sql.= " WHERE s.entity IN (".getEntity('societe').")"; |
|
| 677 | + // For ajax search we limit here. For combo list, we limit later |
|
| 678 | + if (is_array($limitto) && count($limitto)) |
|
| 679 | + { |
|
| 680 | + $sql.= " AND s.rowid IN (".join(',',$limitto).")"; |
|
| 681 | + } |
|
| 682 | + $sql.= " ORDER BY s.nom ASC"; |
|
| 683 | + |
|
| 684 | + $resql = $this->db->query($sql); |
|
| 685 | + if ($resql) |
|
| 686 | + { |
|
| 687 | + print '<select class="flat'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'"'; |
|
| 688 | + if ($conf->use_javascript_ajax) |
|
| 689 | + { |
|
| 690 | + $javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id).$moreparam."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; |
|
| 691 | + print ' onChange="'.$javaScript.'"'; |
|
| 692 | + } |
|
| 693 | + print '>'; |
|
| 694 | + $num = $this->db->num_rows($resql); |
|
| 695 | + $i = 0; |
|
| 696 | + if ($num) |
|
| 697 | + { |
|
| 698 | + while ($i < $num) |
|
| 699 | + { |
|
| 700 | + $obj = $this->db->fetch_object($resql); |
|
| 701 | + if ($i == 0) $firstCompany = $obj->rowid; |
|
| 702 | + $disabled=0; |
|
| 703 | + if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1; |
|
| 704 | + if ($selected > 0 && $selected == $obj->rowid) |
|
| 705 | + { |
|
| 706 | + print '<option value="'.$obj->rowid.'"'; |
|
| 707 | + if ($disabled) print ' disabled'; |
|
| 708 | + print ' selected>'.dol_trunc($obj->name,24).'</option>'; |
|
| 709 | + $firstCompany = $obj->rowid; |
|
| 710 | + } |
|
| 711 | + else |
|
| 712 | + { |
|
| 713 | + print '<option value="'.$obj->rowid.'"'; |
|
| 714 | + if ($disabled) print ' disabled'; |
|
| 715 | + print '>'.dol_trunc($obj->name,24).'</option>'; |
|
| 716 | + } |
|
| 717 | + $i ++; |
|
| 718 | + } |
|
| 719 | + } |
|
| 720 | + print "</select>\n"; |
|
| 721 | + return $firstCompany; |
|
| 722 | + } |
|
| 723 | + else |
|
| 724 | + { |
|
| 725 | + dol_print_error($this->db); |
|
| 726 | + print 'Error sql'; |
|
| 727 | + } |
|
| 728 | + } |
|
| 729 | + } |
|
| 730 | 730 | |
| 731 | 731 | /** |
| 732 | 732 | * Return a select list with types of contacts |
@@ -740,59 +740,59 @@ discard block |
||
| 740 | 740 | * @param string $morecss Add more css to select component |
| 741 | 741 | * @return void |
| 742 | 742 | */ |
| 743 | - function selectTypeContact($object, $selected, $htmlname = 'type', $source='internal', $sortorder='position', $showempty=0, $morecss='') |
|
| 744 | - { |
|
| 745 | - global $user, $langs; |
|
| 746 | - |
|
| 747 | - if (is_object($object) && method_exists($object, 'liste_type_contact')) |
|
| 748 | - { |
|
| 749 | - $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); |
|
| 750 | - print '<select class="flat valignmiddle'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 751 | - if ($showempty) print '<option value="0"></option>'; |
|
| 752 | - foreach($lesTypes as $key=>$value) |
|
| 753 | - { |
|
| 754 | - print '<option value="'.$key.'"'; |
|
| 755 | - if ($key == $selected) print ' selected'; |
|
| 756 | - print '>'.$value.'</option>'; |
|
| 757 | - } |
|
| 758 | - print "</select>"; |
|
| 759 | - if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 760 | - print "\n"; |
|
| 761 | - } |
|
| 762 | - } |
|
| 743 | + function selectTypeContact($object, $selected, $htmlname = 'type', $source='internal', $sortorder='position', $showempty=0, $morecss='') |
|
| 744 | + { |
|
| 745 | + global $user, $langs; |
|
| 746 | + |
|
| 747 | + if (is_object($object) && method_exists($object, 'liste_type_contact')) |
|
| 748 | + { |
|
| 749 | + $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); |
|
| 750 | + print '<select class="flat valignmiddle'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 751 | + if ($showempty) print '<option value="0"></option>'; |
|
| 752 | + foreach($lesTypes as $key=>$value) |
|
| 753 | + { |
|
| 754 | + print '<option value="'.$key.'"'; |
|
| 755 | + if ($key == $selected) print ' selected'; |
|
| 756 | + print '>'.$value.'</option>'; |
|
| 757 | + } |
|
| 758 | + print "</select>"; |
|
| 759 | + if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 760 | + print "\n"; |
|
| 761 | + } |
|
| 762 | + } |
|
| 763 | 763 | |
| 764 | 764 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 765 | - /** |
|
| 766 | - * Return a select list with zip codes and their town |
|
| 767 | - * |
|
| 768 | - * @param string $selected Preselected value |
|
| 769 | - * @param string $htmlname HTML select name |
|
| 770 | - * @param string $fields Fields |
|
| 771 | - * @param int $fieldsize Field size |
|
| 772 | - * @param int $disableautocomplete 1 To disable ajax autocomplete features (browser autocomplete may still occurs) |
|
| 773 | - * @param string $moreattrib Add more attribute on HTML input field |
|
| 774 | - * @param string $morecss More css |
|
| 775 | - * @return string |
|
| 776 | - */ |
|
| 777 | - function select_ziptown($selected='', $htmlname='zipcode', $fields='', $fieldsize=0, $disableautocomplete=0, $moreattrib='',$morecss='') |
|
| 778 | - { |
|
| 765 | + /** |
|
| 766 | + * Return a select list with zip codes and their town |
|
| 767 | + * |
|
| 768 | + * @param string $selected Preselected value |
|
| 769 | + * @param string $htmlname HTML select name |
|
| 770 | + * @param string $fields Fields |
|
| 771 | + * @param int $fieldsize Field size |
|
| 772 | + * @param int $disableautocomplete 1 To disable ajax autocomplete features (browser autocomplete may still occurs) |
|
| 773 | + * @param string $moreattrib Add more attribute on HTML input field |
|
| 774 | + * @param string $morecss More css |
|
| 775 | + * @return string |
|
| 776 | + */ |
|
| 777 | + function select_ziptown($selected='', $htmlname='zipcode', $fields='', $fieldsize=0, $disableautocomplete=0, $moreattrib='',$morecss='') |
|
| 778 | + { |
|
| 779 | 779 | // phpcs:enable |
| 780 | - global $conf; |
|
| 780 | + global $conf; |
|
| 781 | 781 | |
| 782 | - $out=''; |
|
| 782 | + $out=''; |
|
| 783 | 783 | |
| 784 | - $size=''; |
|
| 785 | - if (!empty($fieldsize)) $size='size="'.$fieldsize.'"'; |
|
| 784 | + $size=''; |
|
| 785 | + if (!empty($fieldsize)) $size='size="'.$fieldsize.'"'; |
|
| 786 | 786 | |
| 787 | - if ($conf->use_javascript_ajax && empty($disableautocomplete)) |
|
| 788 | - { |
|
| 789 | - $out.= ajax_multiautocompleter($htmlname,$fields,DOL_URL_ROOT.'/core/ajax/ziptown.php')."\n"; |
|
| 790 | - $moreattrib.=' autocomplete="off"'; |
|
| 791 | - } |
|
| 792 | - $out.= '<input id="'.$htmlname.'" class="maxwidthonsmartphone'.($morecss?' '.$morecss:'').'" type="text"'.($moreattrib?' '.$moreattrib:'').' name="'.$htmlname.'" '.$size.' value="'.$selected.'">'."\n"; |
|
| 787 | + if ($conf->use_javascript_ajax && empty($disableautocomplete)) |
|
| 788 | + { |
|
| 789 | + $out.= ajax_multiautocompleter($htmlname,$fields,DOL_URL_ROOT.'/core/ajax/ziptown.php')."\n"; |
|
| 790 | + $moreattrib.=' autocomplete="off"'; |
|
| 791 | + } |
|
| 792 | + $out.= '<input id="'.$htmlname.'" class="maxwidthonsmartphone'.($morecss?' '.$morecss:'').'" type="text"'.($moreattrib?' '.$moreattrib:'').' name="'.$htmlname.'" '.$size.' value="'.$selected.'">'."\n"; |
|
| 793 | 793 | |
| 794 | - return $out; |
|
| 795 | - } |
|
| 794 | + return $out; |
|
| 795 | + } |
|
| 796 | 796 | |
| 797 | 797 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 798 | 798 | /** |
@@ -812,30 +812,30 @@ discard block |
||
| 812 | 812 | |
| 813 | 813 | $formlength=0; |
| 814 | 814 | if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) { |
| 815 | - if ($country_code == 'FR') |
|
| 816 | - { |
|
| 817 | - if (isset($idprof)) { |
|
| 818 | - if ($idprof==1) $formlength=9; |
|
| 819 | - else if ($idprof==2) $formlength=14; |
|
| 820 | - else if ($idprof==3) $formlength=5; // 4 chiffres et 1 lettre depuis janvier |
|
| 821 | - else if ($idprof==4) $formlength=32; // No maximum as we need to include a town name in this id |
|
| 822 | - } |
|
| 823 | - } |
|
| 824 | - else if ($country_code == 'ES') |
|
| 825 | - { |
|
| 826 | - if ($idprof==1) $formlength=9; //CIF/NIF/NIE 9 digits |
|
| 827 | - if ($idprof==2) $formlength=12; //NASS 12 digits without / |
|
| 828 | - if ($idprof==3) $formlength=5; //CNAE 5 digits |
|
| 829 | - if ($idprof==4) $formlength=32; //depend of college |
|
| 830 | - } |
|
| 815 | + if ($country_code == 'FR') |
|
| 816 | + { |
|
| 817 | + if (isset($idprof)) { |
|
| 818 | + if ($idprof==1) $formlength=9; |
|
| 819 | + else if ($idprof==2) $formlength=14; |
|
| 820 | + else if ($idprof==3) $formlength=5; // 4 chiffres et 1 lettre depuis janvier |
|
| 821 | + else if ($idprof==4) $formlength=32; // No maximum as we need to include a town name in this id |
|
| 822 | + } |
|
| 823 | + } |
|
| 824 | + else if ($country_code == 'ES') |
|
| 825 | + { |
|
| 826 | + if ($idprof==1) $formlength=9; //CIF/NIF/NIE 9 digits |
|
| 827 | + if ($idprof==2) $formlength=12; //NASS 12 digits without / |
|
| 828 | + if ($idprof==3) $formlength=5; //CNAE 5 digits |
|
| 829 | + if ($idprof==4) $formlength=32; //depend of college |
|
| 830 | + } |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | $selected=$preselected; |
| 834 | 834 | if (! $selected && isset($idprof)) { |
| 835 | - if ($idprof==1 && ! empty($this->idprof1)) $selected=$this->idprof1; |
|
| 836 | - else if ($idprof==2 && ! empty($this->idprof2)) $selected=$this->idprof2; |
|
| 837 | - else if ($idprof==3 && ! empty($this->idprof3)) $selected=$this->idprof3; |
|
| 838 | - else if ($idprof==4 && ! empty($this->idprof4)) $selected=$this->idprof4; |
|
| 835 | + if ($idprof==1 && ! empty($this->idprof1)) $selected=$this->idprof1; |
|
| 836 | + else if ($idprof==2 && ! empty($this->idprof2)) $selected=$this->idprof2; |
|
| 837 | + else if ($idprof==3 && ! empty($this->idprof3)) $selected=$this->idprof3; |
|
| 838 | + else if ($idprof==4 && ! empty($this->idprof4)) $selected=$this->idprof4; |
|
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | $maxlength=$formlength; |
@@ -862,30 +862,30 @@ discard block |
||
| 862 | 862 | |
| 863 | 863 | $num = $this->db->num_rows($tax); |
| 864 | 864 | $i = 0; |
| 865 | - if ($num) |
|
| 866 | - { |
|
| 867 | - $valors=explode(":", $tax); |
|
| 868 | - |
|
| 869 | - if (count($valors) > 1) |
|
| 870 | - { |
|
| 871 | - //montar select |
|
| 872 | - print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 873 | - while ($i <= (count($valors))-1) |
|
| 874 | - { |
|
| 875 | - if ($selected == $valors[$i]) |
|
| 876 | - { |
|
| 877 | - print '<option value="'.$valors[$i].'" selected>'; |
|
| 878 | - } |
|
| 879 | - else |
|
| 880 | - { |
|
| 881 | - print '<option value="'.$valors[$i].'">'; |
|
| 882 | - } |
|
| 883 | - print $valors[$i]; |
|
| 884 | - print '</option>'; |
|
| 885 | - $i++; |
|
| 886 | - } |
|
| 887 | - print'</select>'; |
|
| 888 | - } |
|
| 889 | - } |
|
| 865 | + if ($num) |
|
| 866 | + { |
|
| 867 | + $valors=explode(":", $tax); |
|
| 868 | + |
|
| 869 | + if (count($valors) > 1) |
|
| 870 | + { |
|
| 871 | + //montar select |
|
| 872 | + print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 873 | + while ($i <= (count($valors))-1) |
|
| 874 | + { |
|
| 875 | + if ($selected == $valors[$i]) |
|
| 876 | + { |
|
| 877 | + print '<option value="'.$valors[$i].'" selected>'; |
|
| 878 | + } |
|
| 879 | + else |
|
| 880 | + { |
|
| 881 | + print '<option value="'.$valors[$i].'">'; |
|
| 882 | + } |
|
| 883 | + print $valors[$i]; |
|
| 884 | + print '</option>'; |
|
| 885 | + $i++; |
|
| 886 | + } |
|
| 887 | + print'</select>'; |
|
| 888 | + } |
|
| 889 | + } |
|
| 890 | 890 | } |
| 891 | 891 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * @var string Error code (or message) |
| 41 | 41 | */ |
| 42 | - public $error=''; |
|
| 42 | + public $error = ''; |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * Constructor |
@@ -60,20 +60,20 @@ discard block |
||
| 60 | 60 | * @param string $filter Add a SQL filter to select |
| 61 | 61 | * @return array Array of types |
| 62 | 62 | */ |
| 63 | - function typent_array($mode=0, $filter='') |
|
| 63 | + function typent_array($mode = 0, $filter = '') |
|
| 64 | 64 | { |
| 65 | 65 | // phpcs:enable |
| 66 | - global $langs,$mysoc; |
|
| 66 | + global $langs, $mysoc; |
|
| 67 | 67 | |
| 68 | 68 | $effs = array(); |
| 69 | 69 | |
| 70 | 70 | $sql = "SELECT id, code, libelle"; |
| 71 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_typent"; |
|
| 72 | - $sql.= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id)?'0':$mysoc->country_id).")"; |
|
| 73 | - if ($filter) $sql.=" ".$filter; |
|
| 74 | - $sql.= " ORDER by position, id"; |
|
| 71 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_typent"; |
|
| 72 | + $sql .= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id) ? '0' : $mysoc->country_id).")"; |
|
| 73 | + if ($filter) $sql .= " ".$filter; |
|
| 74 | + $sql .= " ORDER by position, id"; |
|
| 75 | 75 | dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); |
| 76 | - $resql=$this->db->query($sql); |
|
| 76 | + $resql = $this->db->query($sql); |
|
| 77 | 77 | if ($resql) |
| 78 | 78 | { |
| 79 | 79 | $num = $this->db->num_rows($resql); |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | while ($i < $num) |
| 83 | 83 | { |
| 84 | 84 | $objp = $this->db->fetch_object($resql); |
| 85 | - if (! $mode) $key=$objp->id; |
|
| 86 | - else $key=$objp->code; |
|
| 85 | + if (!$mode) $key = $objp->id; |
|
| 86 | + else $key = $objp->code; |
|
| 87 | 87 | if ($langs->trans($objp->code) != $objp->code) $effs[$key] = $langs->trans($objp->code); |
| 88 | 88 | else $effs[$key] = $objp->libelle; |
| 89 | - if ($effs[$key]=='-') $effs[$key]=''; |
|
| 89 | + if ($effs[$key] == '-') $effs[$key] = ''; |
|
| 90 | 90 | $i++; |
| 91 | 91 | } |
| 92 | 92 | $this->db->free($resql); |
@@ -103,18 +103,18 @@ discard block |
||
| 103 | 103 | * @param string $filter Add a SQL filter to select |
| 104 | 104 | * @return array Array of types d'effectifs |
| 105 | 105 | */ |
| 106 | - function effectif_array($mode=0, $filter='') |
|
| 106 | + function effectif_array($mode = 0, $filter = '') |
|
| 107 | 107 | { |
| 108 | 108 | // phpcs:enable |
| 109 | 109 | $effs = array(); |
| 110 | 110 | |
| 111 | 111 | $sql = "SELECT id, code, libelle"; |
| 112 | 112 | $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; |
| 113 | - $sql.= " WHERE active = 1"; |
|
| 114 | - if ($filter) $sql.=" ".$filter; |
|
| 113 | + $sql .= " WHERE active = 1"; |
|
| 114 | + if ($filter) $sql .= " ".$filter; |
|
| 115 | 115 | $sql .= " ORDER BY id ASC"; |
| 116 | 116 | dol_syslog(get_class($this).'::effectif_array', LOG_DEBUG); |
| 117 | - $resql=$this->db->query($sql); |
|
| 117 | + $resql = $this->db->query($sql); |
|
| 118 | 118 | if ($resql) |
| 119 | 119 | { |
| 120 | 120 | $num = $this->db->num_rows($resql); |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | while ($i < $num) |
| 124 | 124 | { |
| 125 | 125 | $objp = $this->db->fetch_object($resql); |
| 126 | - if (! $mode) $key=$objp->id; |
|
| 127 | - else $key=$objp->code; |
|
| 126 | + if (!$mode) $key = $objp->id; |
|
| 127 | + else $key = $objp->code; |
|
| 128 | 128 | |
| 129 | - $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; |
|
| 129 | + $effs[$key] = $objp->libelle != '-' ? $objp->libelle : ''; |
|
| 130 | 130 | $i++; |
| 131 | 131 | } |
| 132 | 132 | $this->db->free($resql); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param int $empty Add empty value in list |
| 146 | 146 | * @return void |
| 147 | 147 | */ |
| 148 | - function form_prospect_level($page, $selected='', $htmlname='prospect_level_id', $empty=0) |
|
| 148 | + function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0) |
|
| 149 | 149 | { |
| 150 | 150 | // phpcs:enable |
| 151 | 151 | global $user, $langs; |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | print '<input type="hidden" name="action" value="setprospectlevel">'; |
| 155 | 155 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 156 | 156 | |
| 157 | - dol_syslog(get_class($this).'::form_prospect_level',LOG_DEBUG); |
|
| 157 | + dol_syslog(get_class($this).'::form_prospect_level', LOG_DEBUG); |
|
| 158 | 158 | $sql = "SELECT code, label"; |
| 159 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; |
|
| 160 | - $sql.= " WHERE active > 0"; |
|
| 161 | - $sql.= " ORDER BY sortorder"; |
|
| 159 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; |
|
| 160 | + $sql .= " WHERE active > 0"; |
|
| 161 | + $sql .= " ORDER BY sortorder"; |
|
| 162 | 162 | $resql = $this->db->query($sql); |
| 163 | 163 | if ($resql) |
| 164 | 164 | { |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | print Form::selectarray($htmlname, $options, $selected); |
| 182 | 182 | } |
| 183 | 183 | else dol_print_error($this->db); |
| 184 | - if (! empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 184 | + if (!empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 185 | 185 | print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
| 186 | 186 | print '</form>'; |
| 187 | 187 | } |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | * @param string $htmlname Id of department |
| 200 | 200 | * @return void |
| 201 | 201 | */ |
| 202 | - function select_departement($selected='',$country_codeid=0, $htmlname='state_id') |
|
| 202 | + function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id') |
|
| 203 | 203 | { |
| 204 | 204 | // phpcs:enable |
| 205 | - print $this->select_state($selected,$country_codeid, $htmlname); |
|
| 205 | + print $this->select_state($selected, $country_codeid, $htmlname); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -219,91 +219,91 @@ discard block |
||
| 219 | 219 | * @return string String with HTML select |
| 220 | 220 | * @see select_country |
| 221 | 221 | */ |
| 222 | - function select_state($selected='',$country_codeid=0, $htmlname='state_id') |
|
| 222 | + function select_state($selected = '', $country_codeid = 0, $htmlname = 'state_id') |
|
| 223 | 223 | { |
| 224 | 224 | // phpcs:enable |
| 225 | - global $conf,$langs,$user; |
|
| 225 | + global $conf, $langs, $user; |
|
| 226 | 226 | |
| 227 | - dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid,LOG_DEBUG); |
|
| 227 | + dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid, LOG_DEBUG); |
|
| 228 | 228 | |
| 229 | 229 | $langs->load("dict"); |
| 230 | 230 | |
| 231 | - $out=''; |
|
| 231 | + $out = ''; |
|
| 232 | 232 | |
| 233 | 233 | // Serch departements/cantons/province active d'une region et pays actif |
| 234 | 234 | $sql = "SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.nom as region_name FROM"; |
| 235 | - $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; |
|
| 235 | + $sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; |
|
| 236 | 236 | $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; |
| 237 | 237 | $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; |
| 238 | 238 | if ($country_codeid && is_numeric($country_codeid)) $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; |
| 239 | - if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; |
|
| 239 | + if ($country_codeid && !is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; |
|
| 240 | 240 | $sql .= " ORDER BY c.code, d.code_departement"; |
| 241 | 241 | |
| 242 | - $result=$this->db->query($sql); |
|
| 242 | + $result = $this->db->query($sql); |
|
| 243 | 243 | if ($result) |
| 244 | 244 | { |
| 245 | - if (!empty($htmlname)) $out.= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
| 246 | - if ($country_codeid) $out.= '<option value="0"> </option>'; |
|
| 245 | + if (!empty($htmlname)) $out .= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
| 246 | + if ($country_codeid) $out .= '<option value="0"> </option>'; |
|
| 247 | 247 | $num = $this->db->num_rows($result); |
| 248 | 248 | $i = 0; |
| 249 | - dol_syslog(get_class($this)."::select_departement num=".$num,LOG_DEBUG); |
|
| 249 | + dol_syslog(get_class($this)."::select_departement num=".$num, LOG_DEBUG); |
|
| 250 | 250 | if ($num) |
| 251 | 251 | { |
| 252 | - $country=''; |
|
| 252 | + $country = ''; |
|
| 253 | 253 | while ($i < $num) |
| 254 | 254 | { |
| 255 | 255 | $obj = $this->db->fetch_object($result); |
| 256 | 256 | if ($obj->code == '0') // Le code peut etre une chaine |
| 257 | 257 | { |
| 258 | - $out.= '<option value="0"> </option>'; |
|
| 258 | + $out .= '<option value="0"> </option>'; |
|
| 259 | 259 | } |
| 260 | 260 | else { |
| 261 | - if (! $country || $country != $obj->country) |
|
| 261 | + if (!$country || $country != $obj->country) |
|
| 262 | 262 | { |
| 263 | 263 | // Affiche la rupture si on est en mode liste multipays |
| 264 | - if (! $country_codeid && $obj->country_code) |
|
| 264 | + if (!$country_codeid && $obj->country_code) |
|
| 265 | 265 | { |
| 266 | - $out.= '<option value="-1" disabled>----- '.$obj->country." -----</option>\n"; |
|
| 267 | - $country=$obj->country; |
|
| 266 | + $out .= '<option value="-1" disabled>----- '.$obj->country." -----</option>\n"; |
|
| 267 | + $country = $obj->country; |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - if ((! empty($selected) && $selected == $obj->rowid) |
|
| 272 | - || (empty($selected) && ! empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) |
|
| 271 | + if ((!empty($selected) && $selected == $obj->rowid) |
|
| 272 | + || (empty($selected) && !empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) |
|
| 273 | 273 | { |
| 274 | - $out.= '<option value="'.$obj->rowid.'" selected>'; |
|
| 274 | + $out .= '<option value="'.$obj->rowid.'" selected>'; |
|
| 275 | 275 | } |
| 276 | 276 | else |
| 277 | 277 | { |
| 278 | - $out.= '<option value="'.$obj->rowid.'">'; |
|
| 278 | + $out .= '<option value="'.$obj->rowid.'">'; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut |
| 282 | 282 | if (!empty($conf->global->MAIN_SHOW_STATE_CODE) && |
| 283 | 283 | ($conf->global->MAIN_SHOW_STATE_CODE == 1 || $conf->global->MAIN_SHOW_STATE_CODE == 2 || $conf->global->MAIN_SHOW_STATE_CODE === 'all')) { |
| 284 | - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
| 285 | - $out.= $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 284 | + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
| 285 | + $out .= $obj->region_name.' - '.$obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); |
|
| 286 | 286 | } |
| 287 | 287 | else { |
| 288 | - $out.= $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 288 | + $out .= $obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); |
|
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | else { |
| 292 | - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
| 293 | - $out.= $obj->region_name . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 292 | + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
| 293 | + $out .= $obj->region_name.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); |
|
| 294 | 294 | } |
| 295 | 295 | else { |
| 296 | - $out.= ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
| 296 | + $out .= ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - $out.= '</option>'; |
|
| 300 | + $out .= '</option>'; |
|
| 301 | 301 | } |
| 302 | 302 | $i++; |
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | - if (! empty($htmlname)) $out.= '</select>'; |
|
| 306 | - if (! empty($htmlname) && $user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 305 | + if (!empty($htmlname)) $out .= '</select>'; |
|
| 306 | + if (!empty($htmlname) && $user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 307 | 307 | } |
| 308 | 308 | else |
| 309 | 309 | { |
@@ -311,9 +311,9 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | // Make select dynamic |
| 314 | - if (! empty($htmlname)) |
|
| 314 | + if (!empty($htmlname)) |
|
| 315 | 315 | { |
| 316 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 316 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
| 317 | 317 | $out .= ajax_combobox($htmlname); |
| 318 | 318 | } |
| 319 | 319 | |
@@ -332,19 +332,19 @@ discard block |
||
| 332 | 332 | * @param string $htmlname Name of HTML select field |
| 333 | 333 | * @return void |
| 334 | 334 | */ |
| 335 | - function select_region($selected='',$htmlname='region_id') |
|
| 335 | + function select_region($selected = '', $htmlname = 'region_id') |
|
| 336 | 336 | { |
| 337 | 337 | // phpcs:enable |
| 338 | - global $conf,$langs; |
|
| 338 | + global $conf, $langs; |
|
| 339 | 339 | $langs->load("dict"); |
| 340 | 340 | |
| 341 | 341 | $sql = "SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country"; |
| 342 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c"; |
|
| 343 | - $sql.= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1"; |
|
| 344 | - $sql.= " ORDER BY c.code, c.label ASC"; |
|
| 342 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c"; |
|
| 343 | + $sql .= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1"; |
|
| 344 | + $sql .= " ORDER BY c.code, c.label ASC"; |
|
| 345 | 345 | |
| 346 | 346 | dol_syslog(get_class($this)."::select_region", LOG_DEBUG); |
| 347 | - $resql=$this->db->query($sql); |
|
| 347 | + $resql = $this->db->query($sql); |
|
| 348 | 348 | if ($resql) |
| 349 | 349 | { |
| 350 | 350 | print '<select class="flat" name="'.$htmlname.'">'; |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | $i = 0; |
| 353 | 353 | if ($num) |
| 354 | 354 | { |
| 355 | - $country=''; |
|
| 355 | + $country = ''; |
|
| 356 | 356 | while ($i < $num) |
| 357 | 357 | { |
| 358 | 358 | $obj = $this->db->fetch_object($resql); |
@@ -363,10 +363,10 @@ discard block |
||
| 363 | 363 | if ($country == '' || $country != $obj->country) |
| 364 | 364 | { |
| 365 | 365 | // Show break |
| 366 | - $key=$langs->trans("Country".strtoupper($obj->country_code)); |
|
| 367 | - $valuetoshow=($key != "Country".strtoupper($obj->country_code))?$obj->country_code." - ".$key:$obj->country; |
|
| 366 | + $key = $langs->trans("Country".strtoupper($obj->country_code)); |
|
| 367 | + $valuetoshow = ($key != "Country".strtoupper($obj->country_code)) ? $obj->country_code." - ".$key : $obj->country; |
|
| 368 | 368 | print '<option value="-1" disabled>----- '.$valuetoshow." -----</option>\n"; |
| 369 | - $country=$obj->country; |
|
| 369 | + $country = $obj->country; |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | if ($selected > 0 && $selected == $obj->code) |
@@ -398,23 +398,23 @@ discard block |
||
| 398 | 398 | * @param string $morecss Add more css on SELECT element |
| 399 | 399 | * @return string String with HTML select |
| 400 | 400 | */ |
| 401 | - function select_civility($selected='',$htmlname='civility_id',$morecss='maxwidth100') |
|
| 401 | + function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth100') |
|
| 402 | 402 | { |
| 403 | 403 | // phpcs:enable |
| 404 | - global $conf,$langs,$user; |
|
| 404 | + global $conf, $langs, $user; |
|
| 405 | 405 | $langs->load("dict"); |
| 406 | 406 | |
| 407 | - $out=''; |
|
| 407 | + $out = ''; |
|
| 408 | 408 | |
| 409 | 409 | $sql = "SELECT rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_civility"; |
| 410 | - $sql.= " WHERE active = 1"; |
|
| 410 | + $sql .= " WHERE active = 1"; |
|
| 411 | 411 | |
| 412 | 412 | dol_syslog("Form::select_civility", LOG_DEBUG); |
| 413 | - $resql=$this->db->query($sql); |
|
| 413 | + $resql = $this->db->query($sql); |
|
| 414 | 414 | if ($resql) |
| 415 | 415 | { |
| 416 | - $out.= '<select class="flat'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 417 | - $out.= '<option value=""> </option>'; |
|
| 416 | + $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 417 | + $out .= '<option value=""> </option>'; |
|
| 418 | 418 | $num = $this->db->num_rows($resql); |
| 419 | 419 | $i = 0; |
| 420 | 420 | if ($num) |
@@ -424,20 +424,20 @@ discard block |
||
| 424 | 424 | $obj = $this->db->fetch_object($resql); |
| 425 | 425 | if ($selected == $obj->code) |
| 426 | 426 | { |
| 427 | - $out.= '<option value="'.$obj->code.'" selected>'; |
|
| 427 | + $out .= '<option value="'.$obj->code.'" selected>'; |
|
| 428 | 428 | } |
| 429 | 429 | else |
| 430 | 430 | { |
| 431 | - $out.= '<option value="'.$obj->code.'">'; |
|
| 431 | + $out .= '<option value="'.$obj->code.'">'; |
|
| 432 | 432 | } |
| 433 | 433 | // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut |
| 434 | - $out.= ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->label!='-'?$obj->label:'')); |
|
| 435 | - $out.= '</option>'; |
|
| 434 | + $out .= ($langs->trans("Civility".$obj->code) != "Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->label != '-' ? $obj->label : '')); |
|
| 435 | + $out .= '</option>'; |
|
| 436 | 436 | $i++; |
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | - $out.= '</select>'; |
|
| 440 | - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 439 | + $out .= '</select>'; |
|
| 440 | + if ($user->admin) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 441 | 441 | } |
| 442 | 442 | else |
| 443 | 443 | { |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | * @deprecated Use print xxx->select_juridicalstatus instead |
| 460 | 460 | * @see select_juridicalstatus() |
| 461 | 461 | */ |
| 462 | - function select_forme_juridique($selected='', $country_codeid=0, $filter='') |
|
| 462 | + function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '') |
|
| 463 | 463 | { |
| 464 | 464 | // phpcs:enable |
| 465 | 465 | print $this->select_juridicalstatus($selected, $country_codeid, $filter); |
@@ -476,13 +476,13 @@ discard block |
||
| 476 | 476 | * @param string $htmlname HTML name of select |
| 477 | 477 | * @return string String with HTML select |
| 478 | 478 | */ |
| 479 | - function select_juridicalstatus($selected='', $country_codeid=0, $filter='', $htmlname='forme_juridique_code') |
|
| 479 | + function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code') |
|
| 480 | 480 | { |
| 481 | 481 | // phpcs:enable |
| 482 | - global $conf,$langs,$user; |
|
| 482 | + global $conf, $langs, $user; |
|
| 483 | 483 | $langs->load("dict"); |
| 484 | 484 | |
| 485 | - $out=''; |
|
| 485 | + $out = ''; |
|
| 486 | 486 | |
| 487 | 487 | // On recherche les formes juridiques actives des pays actifs |
| 488 | 488 | $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code"; |
@@ -494,70 +494,70 @@ discard block |
||
| 494 | 494 | $sql .= " ORDER BY c.code"; |
| 495 | 495 | |
| 496 | 496 | dol_syslog(get_class($this)."::select_juridicalstatus", LOG_DEBUG); |
| 497 | - $resql=$this->db->query($sql); |
|
| 497 | + $resql = $this->db->query($sql); |
|
| 498 | 498 | if ($resql) |
| 499 | 499 | { |
| 500 | - $out.= '<div id="particulier2" class="visible">'; |
|
| 501 | - $out.= '<select class="flat minwidth200" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 502 | - if ($country_codeid) $out.= '<option value="0"> </option>'; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. |
|
| 500 | + $out .= '<div id="particulier2" class="visible">'; |
|
| 501 | + $out .= '<select class="flat minwidth200" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 502 | + if ($country_codeid) $out .= '<option value="0"> </option>'; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. |
|
| 503 | 503 | |
| 504 | 504 | $num = $this->db->num_rows($resql); |
| 505 | 505 | if ($num) |
| 506 | 506 | { |
| 507 | 507 | $i = 0; |
| 508 | - $country=''; $arraydata=array(); |
|
| 508 | + $country = ''; $arraydata = array(); |
|
| 509 | 509 | while ($i < $num) |
| 510 | 510 | { |
| 511 | 511 | $obj = $this->db->fetch_object($resql); |
| 512 | 512 | |
| 513 | 513 | if ($obj->code) // We exclude empty line, we will add it later |
| 514 | 514 | { |
| 515 | - $labelcountry=(($langs->trans("Country".$obj->country_code)!="Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); |
|
| 516 | - $labeljs=(($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label!='-'?$obj->label:'')); // $obj->label is already in output charset (converted by database driver) |
|
| 517 | - $arraydata[$obj->code]=array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); |
|
| 515 | + $labelcountry = (($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); |
|
| 516 | + $labeljs = (($langs->trans("JuridicalStatus".$obj->code) != "JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label != '-' ? $obj->label : '')); // $obj->label is already in output charset (converted by database driver) |
|
| 517 | + $arraydata[$obj->code] = array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); |
|
| 518 | 518 | } |
| 519 | 519 | $i++; |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | - $arraydata=dol_sort_array($arraydata, 'label_sort', 'ASC'); |
|
| 522 | + $arraydata = dol_sort_array($arraydata, 'label_sort', 'ASC'); |
|
| 523 | 523 | if (empty($country_codeid)) // Introduce empty value (if $country_codeid not empty, empty value was already added) |
| 524 | 524 | { |
| 525 | - $arraydata[0]=array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); |
|
| 525 | + $arraydata[0] = array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - foreach($arraydata as $key => $val) |
|
| 528 | + foreach ($arraydata as $key => $val) |
|
| 529 | 529 | { |
| 530 | - if (! $country || $country != $val['country']) |
|
| 530 | + if (!$country || $country != $val['country']) |
|
| 531 | 531 | { |
| 532 | 532 | // Show break when we are in multi country mode |
| 533 | 533 | if (empty($country_codeid) && $val['country_code']) |
| 534 | 534 | { |
| 535 | - $out.= '<option value="0" disabled class="selectoptiondisabledwhite">----- '.$val['country']." -----</option>\n"; |
|
| 536 | - $country=$val['country']; |
|
| 535 | + $out .= '<option value="0" disabled class="selectoptiondisabledwhite">----- '.$val['country']." -----</option>\n"; |
|
| 536 | + $country = $val['country']; |
|
| 537 | 537 | } |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | if ($selected > 0 && $selected == $val['code']) |
| 541 | 541 | { |
| 542 | - $out.= '<option value="'.$val['code'].'" selected>'; |
|
| 542 | + $out .= '<option value="'.$val['code'].'" selected>'; |
|
| 543 | 543 | } |
| 544 | 544 | else |
| 545 | 545 | { |
| 546 | - $out.= '<option value="'.$val['code'].'">'; |
|
| 546 | + $out .= '<option value="'.$val['code'].'">'; |
|
| 547 | 547 | } |
| 548 | 548 | // If translation exists, we use it, otherwise we use default label in database |
| 549 | - $out.= $val['label']; |
|
| 550 | - $out.= '</option>'; |
|
| 549 | + $out .= $val['label']; |
|
| 550 | + $out .= '</option>'; |
|
| 551 | 551 | } |
| 552 | 552 | } |
| 553 | - $out.= '</select>'; |
|
| 554 | - if ($user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 553 | + $out .= '</select>'; |
|
| 554 | + if ($user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 555 | 555 | |
| 556 | 556 | // Make select dynamic |
| 557 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
| 557 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
| 558 | 558 | $out .= ajax_combobox($htmlname); |
| 559 | 559 | |
| 560 | - $out.= '</div>'; |
|
| 560 | + $out .= '</div>'; |
|
| 561 | 561 | } |
| 562 | 562 | else |
| 563 | 563 | { |
@@ -581,19 +581,19 @@ discard block |
||
| 581 | 581 | * @param string $morecss More CSS on select component |
| 582 | 582 | * @return int The selected third party ID |
| 583 | 583 | */ |
| 584 | - function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0, $moreparam='', $morecss='') |
|
| 584 | + function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '') |
|
| 585 | 585 | { |
| 586 | 586 | global $conf, $langs; |
| 587 | 587 | |
| 588 | - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) |
|
| 588 | + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) |
|
| 589 | 589 | { |
| 590 | 590 | // Use Ajax search |
| 591 | - $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2); |
|
| 591 | + $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2); |
|
| 592 | 592 | |
| 593 | - $socid=0; $name=''; |
|
| 593 | + $socid = 0; $name = ''; |
|
| 594 | 594 | if ($selected > 0) |
| 595 | 595 | { |
| 596 | - $tmpthirdparty=new Societe($this->db); |
|
| 596 | + $tmpthirdparty = new Societe($this->db); |
|
| 597 | 597 | $result = $tmpthirdparty->fetch($selected); |
| 598 | 598 | if ($result > 0) |
| 599 | 599 | { |
@@ -603,13 +603,13 @@ discard block |
||
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | |
| 606 | - $events=array(); |
|
| 606 | + $events = array(); |
|
| 607 | 607 | // Add an entry 'method' to say 'yes, we must execute url with param action = method'; |
| 608 | 608 | // Add an entry 'url' to say which url to execute |
| 609 | 609 | // Add an entry htmlname to say which element we must change once url is called |
| 610 | 610 | // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines |
| 611 | 611 | // To refresh contacts list on thirdparty list change |
| 612 | - $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); |
|
| 612 | + $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); |
|
| 613 | 613 | |
| 614 | 614 | if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events |
| 615 | 615 | { |
@@ -665,29 +665,29 @@ discard block |
||
| 665 | 665 | |
| 666 | 666 | print "\n".'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n"; |
| 667 | 667 | print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$name.'" />'; |
| 668 | - print ajax_autocompleter(($socid?$socid:-1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); |
|
| 668 | + print ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); |
|
| 669 | 669 | return $socid; |
| 670 | 670 | } |
| 671 | 671 | else |
| 672 | 672 | { |
| 673 | 673 | // Search to list thirdparties |
| 674 | 674 | $sql = "SELECT s.rowid, s.nom as name FROM"; |
| 675 | - $sql.= " ".MAIN_DB_PREFIX."societe as s"; |
|
| 676 | - $sql.= " WHERE s.entity IN (".getEntity('societe').")"; |
|
| 675 | + $sql .= " ".MAIN_DB_PREFIX."societe as s"; |
|
| 676 | + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; |
|
| 677 | 677 | // For ajax search we limit here. For combo list, we limit later |
| 678 | 678 | if (is_array($limitto) && count($limitto)) |
| 679 | 679 | { |
| 680 | - $sql.= " AND s.rowid IN (".join(',',$limitto).")"; |
|
| 680 | + $sql .= " AND s.rowid IN (".join(',', $limitto).")"; |
|
| 681 | 681 | } |
| 682 | - $sql.= " ORDER BY s.nom ASC"; |
|
| 682 | + $sql .= " ORDER BY s.nom ASC"; |
|
| 683 | 683 | |
| 684 | 684 | $resql = $this->db->query($sql); |
| 685 | 685 | if ($resql) |
| 686 | 686 | { |
| 687 | - print '<select class="flat'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'"'; |
|
| 687 | + print '<select class="flat'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'"'; |
|
| 688 | 688 | if ($conf->use_javascript_ajax) |
| 689 | 689 | { |
| 690 | - $javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id).$moreparam."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; |
|
| 690 | + $javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid > 0 ? $forceid : $object->id).$moreparam."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; |
|
| 691 | 691 | print ' onChange="'.$javaScript.'"'; |
| 692 | 692 | } |
| 693 | 693 | print '>'; |
@@ -699,22 +699,22 @@ discard block |
||
| 699 | 699 | { |
| 700 | 700 | $obj = $this->db->fetch_object($resql); |
| 701 | 701 | if ($i == 0) $firstCompany = $obj->rowid; |
| 702 | - $disabled=0; |
|
| 703 | - if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1; |
|
| 702 | + $disabled = 0; |
|
| 703 | + if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) $disabled = 1; |
|
| 704 | 704 | if ($selected > 0 && $selected == $obj->rowid) |
| 705 | 705 | { |
| 706 | 706 | print '<option value="'.$obj->rowid.'"'; |
| 707 | 707 | if ($disabled) print ' disabled'; |
| 708 | - print ' selected>'.dol_trunc($obj->name,24).'</option>'; |
|
| 708 | + print ' selected>'.dol_trunc($obj->name, 24).'</option>'; |
|
| 709 | 709 | $firstCompany = $obj->rowid; |
| 710 | 710 | } |
| 711 | 711 | else |
| 712 | 712 | { |
| 713 | 713 | print '<option value="'.$obj->rowid.'"'; |
| 714 | 714 | if ($disabled) print ' disabled'; |
| 715 | - print '>'.dol_trunc($obj->name,24).'</option>'; |
|
| 715 | + print '>'.dol_trunc($obj->name, 24).'</option>'; |
|
| 716 | 716 | } |
| 717 | - $i ++; |
|
| 717 | + $i++; |
|
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | 720 | print "</select>\n"; |
@@ -740,23 +740,23 @@ discard block |
||
| 740 | 740 | * @param string $morecss Add more css to select component |
| 741 | 741 | * @return void |
| 742 | 742 | */ |
| 743 | - function selectTypeContact($object, $selected, $htmlname = 'type', $source='internal', $sortorder='position', $showempty=0, $morecss='') |
|
| 743 | + function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '') |
|
| 744 | 744 | { |
| 745 | 745 | global $user, $langs; |
| 746 | 746 | |
| 747 | 747 | if (is_object($object) && method_exists($object, 'liste_type_contact')) |
| 748 | 748 | { |
| 749 | 749 | $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); |
| 750 | - print '<select class="flat valignmiddle'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 750 | + print '<select class="flat valignmiddle'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
| 751 | 751 | if ($showempty) print '<option value="0"></option>'; |
| 752 | - foreach($lesTypes as $key=>$value) |
|
| 752 | + foreach ($lesTypes as $key=>$value) |
|
| 753 | 753 | { |
| 754 | 754 | print '<option value="'.$key.'"'; |
| 755 | 755 | if ($key == $selected) print ' selected'; |
| 756 | 756 | print '>'.$value.'</option>'; |
| 757 | 757 | } |
| 758 | 758 | print "</select>"; |
| 759 | - if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 759 | + if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 760 | 760 | print "\n"; |
| 761 | 761 | } |
| 762 | 762 | } |
@@ -774,22 +774,22 @@ discard block |
||
| 774 | 774 | * @param string $morecss More css |
| 775 | 775 | * @return string |
| 776 | 776 | */ |
| 777 | - function select_ziptown($selected='', $htmlname='zipcode', $fields='', $fieldsize=0, $disableautocomplete=0, $moreattrib='',$morecss='') |
|
| 777 | + function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = '', $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '') |
|
| 778 | 778 | { |
| 779 | 779 | // phpcs:enable |
| 780 | 780 | global $conf; |
| 781 | 781 | |
| 782 | - $out=''; |
|
| 782 | + $out = ''; |
|
| 783 | 783 | |
| 784 | - $size=''; |
|
| 785 | - if (!empty($fieldsize)) $size='size="'.$fieldsize.'"'; |
|
| 784 | + $size = ''; |
|
| 785 | + if (!empty($fieldsize)) $size = 'size="'.$fieldsize.'"'; |
|
| 786 | 786 | |
| 787 | 787 | if ($conf->use_javascript_ajax && empty($disableautocomplete)) |
| 788 | 788 | { |
| 789 | - $out.= ajax_multiautocompleter($htmlname,$fields,DOL_URL_ROOT.'/core/ajax/ziptown.php')."\n"; |
|
| 790 | - $moreattrib.=' autocomplete="off"'; |
|
| 789 | + $out .= ajax_multiautocompleter($htmlname, $fields, DOL_URL_ROOT.'/core/ajax/ziptown.php')."\n"; |
|
| 790 | + $moreattrib .= ' autocomplete="off"'; |
|
| 791 | 791 | } |
| 792 | - $out.= '<input id="'.$htmlname.'" class="maxwidthonsmartphone'.($morecss?' '.$morecss:'').'" type="text"'.($moreattrib?' '.$moreattrib:'').' name="'.$htmlname.'" '.$size.' value="'.$selected.'">'."\n"; |
|
| 792 | + $out .= '<input id="'.$htmlname.'" class="maxwidthonsmartphone'.($morecss ? ' '.$morecss : '').'" type="text"'.($moreattrib ? ' '.$moreattrib : '').' name="'.$htmlname.'" '.$size.' value="'.$selected.'">'."\n"; |
|
| 793 | 793 | |
| 794 | 794 | return $out; |
| 795 | 795 | } |
@@ -805,43 +805,43 @@ discard block |
||
| 805 | 805 | * @param string $morecss More css |
| 806 | 806 | * @return string HTML string with prof id |
| 807 | 807 | */ |
| 808 | - function get_input_id_prof($idprof,$htmlname,$preselected,$country_code,$morecss='maxwidth100onsmartphone quatrevingtpercent') |
|
| 808 | + function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent') |
|
| 809 | 809 | { |
| 810 | 810 | // phpcs:enable |
| 811 | - global $conf,$langs; |
|
| 811 | + global $conf, $langs; |
|
| 812 | 812 | |
| 813 | - $formlength=0; |
|
| 813 | + $formlength = 0; |
|
| 814 | 814 | if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) { |
| 815 | 815 | if ($country_code == 'FR') |
| 816 | 816 | { |
| 817 | 817 | if (isset($idprof)) { |
| 818 | - if ($idprof==1) $formlength=9; |
|
| 819 | - else if ($idprof==2) $formlength=14; |
|
| 820 | - else if ($idprof==3) $formlength=5; // 4 chiffres et 1 lettre depuis janvier |
|
| 821 | - else if ($idprof==4) $formlength=32; // No maximum as we need to include a town name in this id |
|
| 818 | + if ($idprof == 1) $formlength = 9; |
|
| 819 | + else if ($idprof == 2) $formlength = 14; |
|
| 820 | + else if ($idprof == 3) $formlength = 5; // 4 chiffres et 1 lettre depuis janvier |
|
| 821 | + else if ($idprof == 4) $formlength = 32; // No maximum as we need to include a town name in this id |
|
| 822 | 822 | } |
| 823 | 823 | } |
| 824 | 824 | else if ($country_code == 'ES') |
| 825 | 825 | { |
| 826 | - if ($idprof==1) $formlength=9; //CIF/NIF/NIE 9 digits |
|
| 827 | - if ($idprof==2) $formlength=12; //NASS 12 digits without / |
|
| 828 | - if ($idprof==3) $formlength=5; //CNAE 5 digits |
|
| 829 | - if ($idprof==4) $formlength=32; //depend of college |
|
| 826 | + if ($idprof == 1) $formlength = 9; //CIF/NIF/NIE 9 digits |
|
| 827 | + if ($idprof == 2) $formlength = 12; //NASS 12 digits without / |
|
| 828 | + if ($idprof == 3) $formlength = 5; //CNAE 5 digits |
|
| 829 | + if ($idprof == 4) $formlength = 32; //depend of college |
|
| 830 | 830 | } |
| 831 | 831 | } |
| 832 | 832 | |
| 833 | - $selected=$preselected; |
|
| 834 | - if (! $selected && isset($idprof)) { |
|
| 835 | - if ($idprof==1 && ! empty($this->idprof1)) $selected=$this->idprof1; |
|
| 836 | - else if ($idprof==2 && ! empty($this->idprof2)) $selected=$this->idprof2; |
|
| 837 | - else if ($idprof==3 && ! empty($this->idprof3)) $selected=$this->idprof3; |
|
| 838 | - else if ($idprof==4 && ! empty($this->idprof4)) $selected=$this->idprof4; |
|
| 833 | + $selected = $preselected; |
|
| 834 | + if (!$selected && isset($idprof)) { |
|
| 835 | + if ($idprof == 1 && !empty($this->idprof1)) $selected = $this->idprof1; |
|
| 836 | + else if ($idprof == 2 && !empty($this->idprof2)) $selected = $this->idprof2; |
|
| 837 | + else if ($idprof == 3 && !empty($this->idprof3)) $selected = $this->idprof3; |
|
| 838 | + else if ($idprof == 4 && !empty($this->idprof4)) $selected = $this->idprof4; |
|
| 839 | 839 | } |
| 840 | 840 | |
| 841 | - $maxlength=$formlength; |
|
| 842 | - if (empty($formlength)) { $formlength=24; $maxlength=128; } |
|
| 841 | + $maxlength = $formlength; |
|
| 842 | + if (empty($formlength)) { $formlength = 24; $maxlength = 128; } |
|
| 843 | 843 | |
| 844 | - $out = '<input type="text" '.($morecss?'class="'.$morecss.'" ':'').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">'; |
|
| 844 | + $out = '<input type="text" '.($morecss ? 'class="'.$morecss.'" ' : '').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">'; |
|
| 845 | 845 | |
| 846 | 846 | return $out; |
| 847 | 847 | } |
@@ -858,19 +858,19 @@ discard block |
||
| 858 | 858 | function select_localtax($local, $selected, $htmlname) |
| 859 | 859 | { |
| 860 | 860 | // phpcs:enable |
| 861 | - $tax=get_localtax_by_third($local); |
|
| 861 | + $tax = get_localtax_by_third($local); |
|
| 862 | 862 | |
| 863 | 863 | $num = $this->db->num_rows($tax); |
| 864 | 864 | $i = 0; |
| 865 | 865 | if ($num) |
| 866 | 866 | { |
| 867 | - $valors=explode(":", $tax); |
|
| 867 | + $valors = explode(":", $tax); |
|
| 868 | 868 | |
| 869 | 869 | if (count($valors) > 1) |
| 870 | 870 | { |
| 871 | 871 | //montar select |
| 872 | 872 | print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">'; |
| 873 | - while ($i <= (count($valors))-1) |
|
| 873 | + while ($i <= (count($valors)) - 1) |
|
| 874 | 874 | { |
| 875 | 875 | if ($selected == $valors[$i]) |
| 876 | 876 | { |
@@ -70,7 +70,9 @@ discard block |
||
| 70 | 70 | $sql = "SELECT id, code, libelle"; |
| 71 | 71 | $sql.= " FROM ".MAIN_DB_PREFIX."c_typent"; |
| 72 | 72 | $sql.= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id)?'0':$mysoc->country_id).")"; |
| 73 | - if ($filter) $sql.=" ".$filter; |
|
| 73 | + if ($filter) { |
|
| 74 | + $sql.=" ".$filter; |
|
| 75 | + } |
|
| 74 | 76 | $sql.= " ORDER by position, id"; |
| 75 | 77 | dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); |
| 76 | 78 | $resql=$this->db->query($sql); |
@@ -82,11 +84,19 @@ discard block |
||
| 82 | 84 | while ($i < $num) |
| 83 | 85 | { |
| 84 | 86 | $objp = $this->db->fetch_object($resql); |
| 85 | - if (! $mode) $key=$objp->id; |
|
| 86 | - else $key=$objp->code; |
|
| 87 | - if ($langs->trans($objp->code) != $objp->code) $effs[$key] = $langs->trans($objp->code); |
|
| 88 | - else $effs[$key] = $objp->libelle; |
|
| 89 | - if ($effs[$key]=='-') $effs[$key]=''; |
|
| 87 | + if (! $mode) { |
|
| 88 | + $key=$objp->id; |
|
| 89 | + } else { |
|
| 90 | + $key=$objp->code; |
|
| 91 | + } |
|
| 92 | + if ($langs->trans($objp->code) != $objp->code) { |
|
| 93 | + $effs[$key] = $langs->trans($objp->code); |
|
| 94 | + } else { |
|
| 95 | + $effs[$key] = $objp->libelle; |
|
| 96 | + } |
|
| 97 | + if ($effs[$key]=='-') { |
|
| 98 | + $effs[$key]=''; |
|
| 99 | + } |
|
| 90 | 100 | $i++; |
| 91 | 101 | } |
| 92 | 102 | $this->db->free($resql); |
@@ -111,7 +121,9 @@ discard block |
||
| 111 | 121 | $sql = "SELECT id, code, libelle"; |
| 112 | 122 | $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; |
| 113 | 123 | $sql.= " WHERE active = 1"; |
| 114 | - if ($filter) $sql.=" ".$filter; |
|
| 124 | + if ($filter) { |
|
| 125 | + $sql.=" ".$filter; |
|
| 126 | + } |
|
| 115 | 127 | $sql .= " ORDER BY id ASC"; |
| 116 | 128 | dol_syslog(get_class($this).'::effectif_array', LOG_DEBUG); |
| 117 | 129 | $resql=$this->db->query($sql); |
@@ -123,8 +135,11 @@ discard block |
||
| 123 | 135 | while ($i < $num) |
| 124 | 136 | { |
| 125 | 137 | $objp = $this->db->fetch_object($resql); |
| 126 | - if (! $mode) $key=$objp->id; |
|
| 127 | - else $key=$objp->code; |
|
| 138 | + if (! $mode) { |
|
| 139 | + $key=$objp->id; |
|
| 140 | + } else { |
|
| 141 | + $key=$objp->code; |
|
| 142 | + } |
|
| 128 | 143 | |
| 129 | 144 | $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; |
| 130 | 145 | $i++; |
@@ -179,9 +194,12 @@ discard block |
||
| 179 | 194 | } |
| 180 | 195 | |
| 181 | 196 | print Form::selectarray($htmlname, $options, $selected); |
| 197 | + } else { |
|
| 198 | + dol_print_error($this->db); |
|
| 199 | + } |
|
| 200 | + if (! empty($htmlname) && $user->admin) { |
|
| 201 | + print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 182 | 202 | } |
| 183 | - else dol_print_error($this->db); |
|
| 184 | - if (! empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 185 | 203 | print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
| 186 | 204 | print '</form>'; |
| 187 | 205 | } |
@@ -235,15 +253,23 @@ discard block |
||
| 235 | 253 | $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; |
| 236 | 254 | $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; |
| 237 | 255 | $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; |
| 238 | - if ($country_codeid && is_numeric($country_codeid)) $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; |
|
| 239 | - if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; |
|
| 256 | + if ($country_codeid && is_numeric($country_codeid)) { |
|
| 257 | + $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; |
|
| 258 | + } |
|
| 259 | + if ($country_codeid && ! is_numeric($country_codeid)) { |
|
| 260 | + $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; |
|
| 261 | + } |
|
| 240 | 262 | $sql .= " ORDER BY c.code, d.code_departement"; |
| 241 | 263 | |
| 242 | 264 | $result=$this->db->query($sql); |
| 243 | 265 | if ($result) |
| 244 | 266 | { |
| 245 | - if (!empty($htmlname)) $out.= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
| 246 | - if ($country_codeid) $out.= '<option value="0"> </option>'; |
|
| 267 | + if (!empty($htmlname)) { |
|
| 268 | + $out.= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
| 269 | + } |
|
| 270 | + if ($country_codeid) { |
|
| 271 | + $out.= '<option value="0"> </option>'; |
|
| 272 | + } |
|
| 247 | 273 | $num = $this->db->num_rows($result); |
| 248 | 274 | $i = 0; |
| 249 | 275 | dol_syslog(get_class($this)."::select_departement num=".$num,LOG_DEBUG); |
@@ -253,11 +279,12 @@ discard block |
||
| 253 | 279 | while ($i < $num) |
| 254 | 280 | { |
| 255 | 281 | $obj = $this->db->fetch_object($result); |
| 256 | - if ($obj->code == '0') // Le code peut etre une chaine |
|
| 282 | + if ($obj->code == '0') { |
|
| 283 | + // Le code peut etre une chaine |
|
| 257 | 284 | { |
| 258 | 285 | $out.= '<option value="0"> </option>'; |
| 259 | 286 | } |
| 260 | - else { |
|
| 287 | + } else { |
|
| 261 | 288 | if (! $country || $country != $obj->country) |
| 262 | 289 | { |
| 263 | 290 | // Affiche la rupture si on est en mode liste multipays |
@@ -272,8 +299,7 @@ discard block |
||
| 272 | 299 | || (empty($selected) && ! empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) |
| 273 | 300 | { |
| 274 | 301 | $out.= '<option value="'.$obj->rowid.'" selected>'; |
| 275 | - } |
|
| 276 | - else |
|
| 302 | + } else |
|
| 277 | 303 | { |
| 278 | 304 | $out.= '<option value="'.$obj->rowid.'">'; |
| 279 | 305 | } |
@@ -283,16 +309,13 @@ discard block |
||
| 283 | 309 | ($conf->global->MAIN_SHOW_STATE_CODE == 1 || $conf->global->MAIN_SHOW_STATE_CODE == 2 || $conf->global->MAIN_SHOW_STATE_CODE === 'all')) { |
| 284 | 310 | if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
| 285 | 311 | $out.= $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
| 286 | - } |
|
| 287 | - else { |
|
| 312 | + } else { |
|
| 288 | 313 | $out.= $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
| 289 | 314 | } |
| 290 | - } |
|
| 291 | - else { |
|
| 315 | + } else { |
|
| 292 | 316 | if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
| 293 | 317 | $out.= $obj->region_name . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
| 294 | - } |
|
| 295 | - else { |
|
| 318 | + } else { |
|
| 296 | 319 | $out.= ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
| 297 | 320 | } |
| 298 | 321 | } |
@@ -302,10 +325,13 @@ discard block |
||
| 302 | 325 | $i++; |
| 303 | 326 | } |
| 304 | 327 | } |
| 305 | - if (! empty($htmlname)) $out.= '</select>'; |
|
| 306 | - if (! empty($htmlname) && $user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 307 | - } |
|
| 308 | - else |
|
| 328 | + if (! empty($htmlname)) { |
|
| 329 | + $out.= '</select>'; |
|
| 330 | + } |
|
| 331 | + if (! empty($htmlname) && $user->admin) { |
|
| 332 | + $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 333 | + } |
|
| 334 | + } else |
|
| 309 | 335 | { |
| 310 | 336 | dol_print_error($this->db); |
| 311 | 337 | } |
@@ -358,8 +384,7 @@ discard block |
||
| 358 | 384 | $obj = $this->db->fetch_object($resql); |
| 359 | 385 | if ($obj->code == 0) { |
| 360 | 386 | print '<option value="0"> </option>'; |
| 361 | - } |
|
| 362 | - else { |
|
| 387 | + } else { |
|
| 363 | 388 | if ($country == '' || $country != $obj->country) |
| 364 | 389 | { |
| 365 | 390 | // Show break |
@@ -372,8 +397,7 @@ discard block |
||
| 372 | 397 | if ($selected > 0 && $selected == $obj->code) |
| 373 | 398 | { |
| 374 | 399 | print '<option value="'.$obj->code.'" selected>'.$obj->label.'</option>'; |
| 375 | - } |
|
| 376 | - else |
|
| 400 | + } else |
|
| 377 | 401 | { |
| 378 | 402 | print '<option value="'.$obj->code.'">'.$obj->label.'</option>'; |
| 379 | 403 | } |
@@ -382,8 +406,7 @@ discard block |
||
| 382 | 406 | } |
| 383 | 407 | } |
| 384 | 408 | print '</select>'; |
| 385 | - } |
|
| 386 | - else |
|
| 409 | + } else |
|
| 387 | 410 | { |
| 388 | 411 | dol_print_error($this->db); |
| 389 | 412 | } |
@@ -425,8 +448,7 @@ discard block |
||
| 425 | 448 | if ($selected == $obj->code) |
| 426 | 449 | { |
| 427 | 450 | $out.= '<option value="'.$obj->code.'" selected>'; |
| 428 | - } |
|
| 429 | - else |
|
| 451 | + } else |
|
| 430 | 452 | { |
| 431 | 453 | $out.= '<option value="'.$obj->code.'">'; |
| 432 | 454 | } |
@@ -437,9 +459,10 @@ discard block |
||
| 437 | 459 | } |
| 438 | 460 | } |
| 439 | 461 | $out.= '</select>'; |
| 440 | - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 441 | - } |
|
| 442 | - else |
|
| 462 | + if ($user->admin) { |
|
| 463 | + $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 464 | + } |
|
| 465 | + } else |
|
| 443 | 466 | { |
| 444 | 467 | dol_print_error($this->db); |
| 445 | 468 | } |
@@ -489,8 +512,12 @@ discard block |
||
| 489 | 512 | $sql .= " FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c"; |
| 490 | 513 | $sql .= " WHERE f.fk_pays=c.rowid"; |
| 491 | 514 | $sql .= " AND f.active = 1 AND c.active = 1"; |
| 492 | - if ($country_codeid) $sql .= " AND c.code = '".$country_codeid."'"; |
|
| 493 | - if ($filter) $sql .= " ".$filter; |
|
| 515 | + if ($country_codeid) { |
|
| 516 | + $sql .= " AND c.code = '".$country_codeid."'"; |
|
| 517 | + } |
|
| 518 | + if ($filter) { |
|
| 519 | + $sql .= " ".$filter; |
|
| 520 | + } |
|
| 494 | 521 | $sql .= " ORDER BY c.code"; |
| 495 | 522 | |
| 496 | 523 | dol_syslog(get_class($this)."::select_juridicalstatus", LOG_DEBUG); |
@@ -499,7 +526,10 @@ discard block |
||
| 499 | 526 | { |
| 500 | 527 | $out.= '<div id="particulier2" class="visible">'; |
| 501 | 528 | $out.= '<select class="flat minwidth200" name="'.$htmlname.'" id="'.$htmlname.'">'; |
| 502 | - if ($country_codeid) $out.= '<option value="0"> </option>'; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. |
|
| 529 | + if ($country_codeid) { |
|
| 530 | + $out.= '<option value="0"> </option>'; |
|
| 531 | + } |
|
| 532 | + // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. |
|
| 503 | 533 | |
| 504 | 534 | $num = $this->db->num_rows($resql); |
| 505 | 535 | if ($num) |
@@ -510,9 +540,11 @@ discard block |
||
| 510 | 540 | { |
| 511 | 541 | $obj = $this->db->fetch_object($resql); |
| 512 | 542 | |
| 513 | - if ($obj->code) // We exclude empty line, we will add it later |
|
| 543 | + if ($obj->code) { |
|
| 544 | + // We exclude empty line, we will add it later |
|
| 514 | 545 | { |
| 515 | 546 | $labelcountry=(($langs->trans("Country".$obj->country_code)!="Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); |
| 547 | + } |
|
| 516 | 548 | $labeljs=(($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label!='-'?$obj->label:'')); // $obj->label is already in output charset (converted by database driver) |
| 517 | 549 | $arraydata[$obj->code]=array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); |
| 518 | 550 | } |
@@ -520,10 +552,12 @@ discard block |
||
| 520 | 552 | } |
| 521 | 553 | |
| 522 | 554 | $arraydata=dol_sort_array($arraydata, 'label_sort', 'ASC'); |
| 523 | - if (empty($country_codeid)) // Introduce empty value (if $country_codeid not empty, empty value was already added) |
|
| 555 | + if (empty($country_codeid)) { |
|
| 556 | + // Introduce empty value (if $country_codeid not empty, empty value was already added) |
|
| 524 | 557 | { |
| 525 | 558 | $arraydata[0]=array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); |
| 526 | 559 | } |
| 560 | + } |
|
| 527 | 561 | |
| 528 | 562 | foreach($arraydata as $key => $val) |
| 529 | 563 | { |
@@ -540,8 +574,7 @@ discard block |
||
| 540 | 574 | if ($selected > 0 && $selected == $val['code']) |
| 541 | 575 | { |
| 542 | 576 | $out.= '<option value="'.$val['code'].'" selected>'; |
| 543 | - } |
|
| 544 | - else |
|
| 577 | + } else |
|
| 545 | 578 | { |
| 546 | 579 | $out.= '<option value="'.$val['code'].'">'; |
| 547 | 580 | } |
@@ -551,15 +584,16 @@ discard block |
||
| 551 | 584 | } |
| 552 | 585 | } |
| 553 | 586 | $out.= '</select>'; |
| 554 | - if ($user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 587 | + if ($user->admin) { |
|
| 588 | + $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 589 | + } |
|
| 555 | 590 | |
| 556 | 591 | // Make select dynamic |
| 557 | 592 | include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
| 558 | 593 | $out .= ajax_combobox($htmlname); |
| 559 | 594 | |
| 560 | 595 | $out.= '</div>'; |
| 561 | - } |
|
| 562 | - else |
|
| 596 | + } else |
|
| 563 | 597 | { |
| 564 | 598 | dol_print_error($this->db); |
| 565 | 599 | } |
@@ -611,7 +645,8 @@ discard block |
||
| 611 | 645 | // To refresh contacts list on thirdparty list change |
| 612 | 646 | $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); |
| 613 | 647 | |
| 614 | - if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events |
|
| 648 | + if (count($events)) { |
|
| 649 | + // If there is some ajax events to run once selection is done, we add code here to run events |
|
| 615 | 650 | { |
| 616 | 651 | print '<script type="text/javascript"> |
| 617 | 652 | jQuery(document).ready(function() { |
@@ -662,13 +697,13 @@ discard block |
||
| 662 | 697 | }); |
| 663 | 698 | </script>'; |
| 664 | 699 | } |
| 700 | + } |
|
| 665 | 701 | |
| 666 | 702 | print "\n".'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n"; |
| 667 | 703 | print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$name.'" />'; |
| 668 | 704 | print ajax_autocompleter(($socid?$socid:-1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); |
| 669 | 705 | return $socid; |
| 670 | - } |
|
| 671 | - else |
|
| 706 | + } else |
|
| 672 | 707 | { |
| 673 | 708 | // Search to list thirdparties |
| 674 | 709 | $sql = "SELECT s.rowid, s.nom as name FROM"; |
@@ -698,20 +733,27 @@ discard block |
||
| 698 | 733 | while ($i < $num) |
| 699 | 734 | { |
| 700 | 735 | $obj = $this->db->fetch_object($resql); |
| 701 | - if ($i == 0) $firstCompany = $obj->rowid; |
|
| 736 | + if ($i == 0) { |
|
| 737 | + $firstCompany = $obj->rowid; |
|
| 738 | + } |
|
| 702 | 739 | $disabled=0; |
| 703 | - if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1; |
|
| 740 | + if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) { |
|
| 741 | + $disabled=1; |
|
| 742 | + } |
|
| 704 | 743 | if ($selected > 0 && $selected == $obj->rowid) |
| 705 | 744 | { |
| 706 | 745 | print '<option value="'.$obj->rowid.'"'; |
| 707 | - if ($disabled) print ' disabled'; |
|
| 746 | + if ($disabled) { |
|
| 747 | + print ' disabled'; |
|
| 748 | + } |
|
| 708 | 749 | print ' selected>'.dol_trunc($obj->name,24).'</option>'; |
| 709 | 750 | $firstCompany = $obj->rowid; |
| 710 | - } |
|
| 711 | - else |
|
| 751 | + } else |
|
| 712 | 752 | { |
| 713 | 753 | print '<option value="'.$obj->rowid.'"'; |
| 714 | - if ($disabled) print ' disabled'; |
|
| 754 | + if ($disabled) { |
|
| 755 | + print ' disabled'; |
|
| 756 | + } |
|
| 715 | 757 | print '>'.dol_trunc($obj->name,24).'</option>'; |
| 716 | 758 | } |
| 717 | 759 | $i ++; |
@@ -719,8 +761,7 @@ discard block |
||
| 719 | 761 | } |
| 720 | 762 | print "</select>\n"; |
| 721 | 763 | return $firstCompany; |
| 722 | - } |
|
| 723 | - else |
|
| 764 | + } else |
|
| 724 | 765 | { |
| 725 | 766 | dol_print_error($this->db); |
| 726 | 767 | print 'Error sql'; |
@@ -748,15 +789,21 @@ discard block |
||
| 748 | 789 | { |
| 749 | 790 | $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); |
| 750 | 791 | print '<select class="flat valignmiddle'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
| 751 | - if ($showempty) print '<option value="0"></option>'; |
|
| 792 | + if ($showempty) { |
|
| 793 | + print '<option value="0"></option>'; |
|
| 794 | + } |
|
| 752 | 795 | foreach($lesTypes as $key=>$value) |
| 753 | 796 | { |
| 754 | 797 | print '<option value="'.$key.'"'; |
| 755 | - if ($key == $selected) print ' selected'; |
|
| 798 | + if ($key == $selected) { |
|
| 799 | + print ' selected'; |
|
| 800 | + } |
|
| 756 | 801 | print '>'.$value.'</option>'; |
| 757 | 802 | } |
| 758 | 803 | print "</select>"; |
| 759 | - if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 804 | + if ($user->admin) { |
|
| 805 | + print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 806 | + } |
|
| 760 | 807 | print "\n"; |
| 761 | 808 | } |
| 762 | 809 | } |
@@ -782,7 +829,9 @@ discard block |
||
| 782 | 829 | $out=''; |
| 783 | 830 | |
| 784 | 831 | $size=''; |
| 785 | - if (!empty($fieldsize)) $size='size="'.$fieldsize.'"'; |
|
| 832 | + if (!empty($fieldsize)) { |
|
| 833 | + $size='size="'.$fieldsize.'"'; |
|
| 834 | + } |
|
| 786 | 835 | |
| 787 | 836 | if ($conf->use_javascript_ajax && empty($disableautocomplete)) |
| 788 | 837 | { |
@@ -815,27 +864,51 @@ discard block |
||
| 815 | 864 | if ($country_code == 'FR') |
| 816 | 865 | { |
| 817 | 866 | if (isset($idprof)) { |
| 818 | - if ($idprof==1) $formlength=9; |
|
| 819 | - else if ($idprof==2) $formlength=14; |
|
| 820 | - else if ($idprof==3) $formlength=5; // 4 chiffres et 1 lettre depuis janvier |
|
| 821 | - else if ($idprof==4) $formlength=32; // No maximum as we need to include a town name in this id |
|
| 867 | + if ($idprof==1) { |
|
| 868 | + $formlength=9; |
|
| 869 | + } else if ($idprof==2) { |
|
| 870 | + $formlength=14; |
|
| 871 | + } else if ($idprof==3) { |
|
| 872 | + $formlength=5; |
|
| 873 | + } |
|
| 874 | + // 4 chiffres et 1 lettre depuis janvier |
|
| 875 | + else if ($idprof==4) { |
|
| 876 | + $formlength=32; |
|
| 877 | + } |
|
| 878 | + // No maximum as we need to include a town name in this id |
|
| 822 | 879 | } |
| 823 | - } |
|
| 824 | - else if ($country_code == 'ES') |
|
| 880 | + } else if ($country_code == 'ES') |
|
| 825 | 881 | { |
| 826 | - if ($idprof==1) $formlength=9; //CIF/NIF/NIE 9 digits |
|
| 827 | - if ($idprof==2) $formlength=12; //NASS 12 digits without / |
|
| 828 | - if ($idprof==3) $formlength=5; //CNAE 5 digits |
|
| 829 | - if ($idprof==4) $formlength=32; //depend of college |
|
| 882 | + if ($idprof==1) { |
|
| 883 | + $formlength=9; |
|
| 884 | + } |
|
| 885 | + //CIF/NIF/NIE 9 digits |
|
| 886 | + if ($idprof==2) { |
|
| 887 | + $formlength=12; |
|
| 888 | + } |
|
| 889 | + //NASS 12 digits without / |
|
| 890 | + if ($idprof==3) { |
|
| 891 | + $formlength=5; |
|
| 892 | + } |
|
| 893 | + //CNAE 5 digits |
|
| 894 | + if ($idprof==4) { |
|
| 895 | + $formlength=32; |
|
| 896 | + } |
|
| 897 | + //depend of college |
|
| 830 | 898 | } |
| 831 | 899 | } |
| 832 | 900 | |
| 833 | 901 | $selected=$preselected; |
| 834 | 902 | if (! $selected && isset($idprof)) { |
| 835 | - if ($idprof==1 && ! empty($this->idprof1)) $selected=$this->idprof1; |
|
| 836 | - else if ($idprof==2 && ! empty($this->idprof2)) $selected=$this->idprof2; |
|
| 837 | - else if ($idprof==3 && ! empty($this->idprof3)) $selected=$this->idprof3; |
|
| 838 | - else if ($idprof==4 && ! empty($this->idprof4)) $selected=$this->idprof4; |
|
| 903 | + if ($idprof==1 && ! empty($this->idprof1)) { |
|
| 904 | + $selected=$this->idprof1; |
|
| 905 | + } else if ($idprof==2 && ! empty($this->idprof2)) { |
|
| 906 | + $selected=$this->idprof2; |
|
| 907 | + } else if ($idprof==3 && ! empty($this->idprof3)) { |
|
| 908 | + $selected=$this->idprof3; |
|
| 909 | + } else if ($idprof==4 && ! empty($this->idprof4)) { |
|
| 910 | + $selected=$this->idprof4; |
|
| 911 | + } |
|
| 839 | 912 | } |
| 840 | 913 | |
| 841 | 914 | $maxlength=$formlength; |
@@ -875,8 +948,7 @@ discard block |
||
| 875 | 948 | if ($selected == $valors[$i]) |
| 876 | 949 | { |
| 877 | 950 | print '<option value="'.$valors[$i].'" selected>'; |
| 878 | - } |
|
| 879 | - else |
|
| 951 | + } else |
|
| 880 | 952 | { |
| 881 | 953 | print '<option value="'.$valors[$i].'">'; |
| 882 | 954 | } |
@@ -545,8 +545,7 @@ |
||
| 545 | 545 | $ret = $this->InitPrinter($printerid); |
| 546 | 546 | if ($ret>0) { |
| 547 | 547 | setEventMessages($this->error, $this->errors, 'errors'); |
| 548 | - } |
|
| 549 | - else |
|
| 548 | + } else |
|
| 550 | 549 | { |
| 551 | 550 | $nboflines = count($vals); |
| 552 | 551 | for ($line=0; $line < $nboflines; $line++) |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | */ |
| 94 | 94 | |
| 95 | -require_once DOL_DOCUMENT_ROOT .'/includes/mike42/escpos-php/Escpos.php'; |
|
| 95 | +require_once DOL_DOCUMENT_ROOT.'/includes/mike42/escpos-php/Escpos.php'; |
|
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | /** |
| 119 | 119 | * @var string Error code (or message) |
| 120 | 120 | */ |
| 121 | - public $error=''; |
|
| 121 | + public $error = ''; |
|
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * @var string[] Error codes (or messages) |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | function __construct($db) |
| 136 | 136 | { |
| 137 | - $this->db=$db; |
|
| 137 | + $this->db = $db; |
|
| 138 | 138 | $this->tags = array( |
| 139 | 139 | 'dol_align_left', |
| 140 | 140 | 'dol_align_center', |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | $line = 0; |
| 219 | 219 | $obj = array(); |
| 220 | 220 | $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; |
| 221 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; |
|
| 222 | - $sql.= ' WHERE entity = '.$conf->entity; |
|
| 221 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; |
|
| 222 | + $sql .= ' WHERE entity = '.$conf->entity; |
|
| 223 | 223 | $resql = $this->db->query($sql); |
| 224 | 224 | if ($resql) { |
| 225 | 225 | $num = $this->db->num_rows($resql); |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | $line = 0; |
| 287 | 287 | $obj = array(); |
| 288 | 288 | $sql = 'SELECT rowid, name, template'; |
| 289 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; |
|
| 290 | - $sql.= ' WHERE entity = '.$conf->entity; |
|
| 289 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; |
|
| 290 | + $sql .= ' WHERE entity = '.$conf->entity; |
|
| 291 | 291 | $resql = $this->db->query($sql); |
| 292 | 292 | if ($resql) { |
| 293 | 293 | $num = $this->db->num_rows($resql); |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @param string $htmlname select html name |
| 312 | 312 | * @return int 0 if OK; >0 if KO |
| 313 | 313 | */ |
| 314 | - function selectTypePrinter($selected='', $htmlname='printertypeid') |
|
| 314 | + function selectTypePrinter($selected = '', $htmlname = 'printertypeid') |
|
| 315 | 315 | { |
| 316 | 316 | global $langs; |
| 317 | 317 | |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * @param string $htmlname select html name |
| 336 | 336 | * @return int 0 if OK; >0 if KO |
| 337 | 337 | */ |
| 338 | - function selectProfilePrinter($selected='', $htmlname='printerprofileid') |
|
| 338 | + function selectProfilePrinter($selected = '', $htmlname = 'printerprofileid') |
|
| 339 | 339 | { |
| 340 | 340 | global $langs; |
| 341 | 341 | |
@@ -368,10 +368,10 @@ discard block |
||
| 368 | 368 | global $conf; |
| 369 | 369 | $error = 0; |
| 370 | 370 | $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt'; |
| 371 | - $sql.= ' (name, fk_type, fk_profile, parameter, entity)'; |
|
| 372 | - $sql.= ' VALUES ("'.$this->db->escape($name).'", '.$type.', '.$profile.', "'.$this->db->escape($parameter).'", '.$conf->entity.')'; |
|
| 371 | + $sql .= ' (name, fk_type, fk_profile, parameter, entity)'; |
|
| 372 | + $sql .= ' VALUES ("'.$this->db->escape($name).'", '.$type.', '.$profile.', "'.$this->db->escape($parameter).'", '.$conf->entity.')'; |
|
| 373 | 373 | $resql = $this->db->query($sql); |
| 374 | - if (! $resql) { |
|
| 374 | + if (!$resql) { |
|
| 375 | 375 | $error++; |
| 376 | 376 | $this->errors[] = $this->db->lasterror; |
| 377 | 377 | } |
@@ -395,13 +395,13 @@ discard block |
||
| 395 | 395 | global $conf; |
| 396 | 396 | $error = 0; |
| 397 | 397 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt'; |
| 398 | - $sql.= ' SET name="'.$this->db->escape($name).'"'; |
|
| 399 | - $sql.= ', fk_type='.$type; |
|
| 400 | - $sql.= ', fk_profile='.$profile; |
|
| 401 | - $sql.= ', parameter="'.$this->db->escape($parameter).'"'; |
|
| 402 | - $sql.= ' WHERE rowid='.$printerid; |
|
| 398 | + $sql .= ' SET name="'.$this->db->escape($name).'"'; |
|
| 399 | + $sql .= ', fk_type='.$type; |
|
| 400 | + $sql .= ', fk_profile='.$profile; |
|
| 401 | + $sql .= ', parameter="'.$this->db->escape($parameter).'"'; |
|
| 402 | + $sql .= ' WHERE rowid='.$printerid; |
|
| 403 | 403 | $resql = $this->db->query($sql); |
| 404 | - if (! $resql) { |
|
| 404 | + if (!$resql) { |
|
| 405 | 405 | $error++; |
| 406 | 406 | $this->errors[] = $this->db->lasterror; |
| 407 | 407 | } |
@@ -421,9 +421,9 @@ discard block |
||
| 421 | 421 | global $conf; |
| 422 | 422 | $error = 0; |
| 423 | 423 | $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt'; |
| 424 | - $sql.= ' WHERE rowid='.$printerid; |
|
| 424 | + $sql .= ' WHERE rowid='.$printerid; |
|
| 425 | 425 | $resql = $this->db->query($sql); |
| 426 | - if (! $resql) { |
|
| 426 | + if (!$resql) { |
|
| 427 | 427 | $error++; |
| 428 | 428 | $this->errors[] = $this->db->lasterror; |
| 429 | 429 | } |
@@ -445,11 +445,11 @@ discard block |
||
| 445 | 445 | global $conf; |
| 446 | 446 | $error = 0; |
| 447 | 447 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt_template'; |
| 448 | - $sql.= ' SET name="'.$this->db->escape($name).'"'; |
|
| 449 | - $sql.= ', template="'.$this->db->escape($template).'"'; |
|
| 450 | - $sql.= ' WHERE rowid='.$templateid; |
|
| 448 | + $sql .= ' SET name="'.$this->db->escape($name).'"'; |
|
| 449 | + $sql .= ', template="'.$this->db->escape($template).'"'; |
|
| 450 | + $sql .= ' WHERE rowid='.$templateid; |
|
| 451 | 451 | $resql = $this->db->query($sql); |
| 452 | - if (! $resql) { |
|
| 452 | + if (!$resql) { |
|
| 453 | 453 | $error++; |
| 454 | 454 | $this->errors[] = $this->db->lasterror; |
| 455 | 455 | } |
@@ -469,9 +469,9 @@ discard block |
||
| 469 | 469 | // phpcs:enable |
| 470 | 470 | global $conf; |
| 471 | 471 | $error = 0; |
| 472 | - $img = new EscposImage(DOL_BASE_URI . '/theme/common/dolibarr_logo_bw.png'); |
|
| 472 | + $img = new EscposImage(DOL_BASE_URI.'/theme/common/dolibarr_logo_bw.png'); |
|
| 473 | 473 | $ret = $this->InitPrinter($printerid); |
| 474 | - if ($ret>0) { |
|
| 474 | + if ($ret > 0) { |
|
| 475 | 475 | setEventMessages($this->error, $this->errors, 'errors'); |
| 476 | 476 | } else { |
| 477 | 477 | try { |
@@ -543,35 +543,35 @@ discard block |
||
| 543 | 543 | $level = 0; |
| 544 | 544 | $html = '<table border="1" style="width:210px"><pre>'; |
| 545 | 545 | $ret = $this->InitPrinter($printerid); |
| 546 | - if ($ret>0) { |
|
| 546 | + if ($ret > 0) { |
|
| 547 | 547 | setEventMessages($this->error, $this->errors, 'errors'); |
| 548 | 548 | } |
| 549 | 549 | else |
| 550 | 550 | { |
| 551 | 551 | $nboflines = count($vals); |
| 552 | - for ($line=0; $line < $nboflines; $line++) |
|
| 552 | + for ($line = 0; $line < $nboflines; $line++) |
|
| 553 | 553 | { |
| 554 | 554 | switch ($vals[$line]['tag']) { |
| 555 | 555 | case 'DOL_ALIGN_CENTER': |
| 556 | 556 | $this->printer->setJustification(Escpos::JUSTIFY_CENTER); |
| 557 | - $html.='<center>'; |
|
| 557 | + $html .= '<center>'; |
|
| 558 | 558 | $this->printer->text($vals[$line]['value']); |
| 559 | 559 | break; |
| 560 | 560 | case 'DOL_ALIGN_RIGHT': |
| 561 | 561 | $this->printer->setJustification(Escpos::JUSTIFY_RIGHT); |
| 562 | - $html.='<right>'; |
|
| 562 | + $html .= '<right>'; |
|
| 563 | 563 | break; |
| 564 | 564 | case 'DOL_ALIGN_LEFT': |
| 565 | 565 | $this->printer->setJustification(Escpos::JUSTIFY_LEFT); |
| 566 | - $html.='<left>'; |
|
| 566 | + $html .= '<left>'; |
|
| 567 | 567 | break; |
| 568 | 568 | case 'DOL_OPEN_DRAWER': |
| 569 | 569 | $this->printer->pulse(); |
| 570 | - $html.= ' ϟ'.nl2br($vals[$line]['value']); |
|
| 570 | + $html .= ' ϟ'.nl2br($vals[$line]['value']); |
|
| 571 | 571 | break; |
| 572 | 572 | case 'DOL_ACTIVATE_BUZZER': |
| 573 | 573 | //$this->printer->buzzer(); |
| 574 | - $html.= ' ♫'.nl2br($vals[$line]['value']); |
|
| 574 | + $html .= ' ♫'.nl2br($vals[$line]['value']); |
|
| 575 | 575 | break; |
| 576 | 576 | case 'DOL_PRINT_BARCODE': |
| 577 | 577 | // $vals[$line]['value'] -> barcode($content, $type) |
@@ -584,15 +584,15 @@ discard block |
||
| 584 | 584 | case 'DOL_PRINT_QRCODE': |
| 585 | 585 | // $vals[$line]['value'] -> qrCode($content, $ec, $size, $model) |
| 586 | 586 | $this->printer->qrcode($vals[$line]['value']); |
| 587 | - $html.='QRCODE: '.$vals[$line]['value']; |
|
| 587 | + $html .= 'QRCODE: '.$vals[$line]['value']; |
|
| 588 | 588 | break; |
| 589 | 589 | case 'DOL_CUT_PAPER_FULL': |
| 590 | 590 | $this->printer->cut(Escpos::CUT_FULL); |
| 591 | - $html.= ' ✂'.nl2br($vals[$line]['value']); |
|
| 591 | + $html .= ' ✂'.nl2br($vals[$line]['value']); |
|
| 592 | 592 | break; |
| 593 | 593 | case 'DOL_CUT_PAPER_PARTIAL': |
| 594 | 594 | $this->printer->cut(Escpos::CUT_PARTIAL); |
| 595 | - $html.= ' ✂'.nl2br($vals[$line]['value']); |
|
| 595 | + $html .= ' ✂'.nl2br($vals[$line]['value']); |
|
| 596 | 596 | break; |
| 597 | 597 | case 'DOL_USE_FONT_A': |
| 598 | 598 | $this->printer->setFont(Escpos::FONT_A); |
@@ -608,13 +608,13 @@ discard block |
||
| 608 | 608 | break; |
| 609 | 609 | default: |
| 610 | 610 | $this->printer->text($vals[$line]['value']); |
| 611 | - $html.= nl2br($vals[$line]['value']); |
|
| 611 | + $html .= nl2br($vals[$line]['value']); |
|
| 612 | 612 | $this->errors[] = 'UnknowTag: <'.strtolower($vals[$line]['tag']).'>'; |
| 613 | 613 | $error++; |
| 614 | 614 | break; |
| 615 | 615 | } |
| 616 | 616 | } |
| 617 | - $html.= '</pre></table>'; |
|
| 617 | + $html .= '</pre></table>'; |
|
| 618 | 618 | print $html; |
| 619 | 619 | // Close and print |
| 620 | 620 | // uncomment next line to see content sent to printer |
@@ -635,9 +635,9 @@ discard block |
||
| 635 | 635 | global $conf; |
| 636 | 636 | $error = 0; |
| 637 | 637 | $sql = 'SELECT template'; |
| 638 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; |
|
| 639 | - $sql.= ' WHERE rowid='.$templateid; |
|
| 640 | - $sql.= ' AND entity = '.$conf->entity; |
|
| 638 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; |
|
| 639 | + $sql .= ' WHERE rowid='.$templateid; |
|
| 640 | + $sql .= ' AND entity = '.$conf->entity; |
|
| 641 | 641 | $resql = $this->db->query($sql); |
| 642 | 642 | if ($resql) { |
| 643 | 643 | $obj = $this->db->fetch_array($resql); |
@@ -667,11 +667,11 @@ discard block |
||
| 667 | 667 | { |
| 668 | 668 | // phpcs:enable |
| 669 | 669 | global $conf; |
| 670 | - $error=0; |
|
| 670 | + $error = 0; |
|
| 671 | 671 | $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; |
| 672 | - $sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; |
|
| 673 | - $sql.= ' WHERE rowid = '.$printerid; |
|
| 674 | - $sql.= ' AND entity = '.$conf->entity; |
|
| 672 | + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; |
|
| 673 | + $sql .= ' WHERE rowid = '.$printerid; |
|
| 674 | + $sql .= ' AND entity = '.$conf->entity; |
|
| 675 | 675 | $resql = $this->db->query($sql); |
| 676 | 676 | if ($resql) { |
| 677 | 677 | $obj = $this->db->fetch_array($resql); |
@@ -683,12 +683,12 @@ discard block |
||
| 683 | 683 | $error++; |
| 684 | 684 | $this->errors[] = 'PrinterDontExist'; |
| 685 | 685 | } |
| 686 | - if (! $error) { |
|
| 686 | + if (!$error) { |
|
| 687 | 687 | $parameter = $obj['parameter']; |
| 688 | 688 | try { |
| 689 | 689 | switch ($obj['fk_type']) { |
| 690 | 690 | case 1: |
| 691 | - require_once DOL_DOCUMENT_ROOT .'/includes/mike42/escpos-php/src/DummyPrintConnector.php'; |
|
| 691 | + require_once DOL_DOCUMENT_ROOT.'/includes/mike42/escpos-php/src/DummyPrintConnector.php'; |
|
| 692 | 692 | $this->connector = new DummyPrintConnector(); |
| 693 | 693 | break; |
| 694 | 694 | case 2: |