@@ -41,181 +41,181 @@ discard block |
||
| 41 | 41 | * Constructor |
| 42 | 42 | * |
| 43 | 43 | * @param DoliDB $db Database handler |
| 44 | - */ |
|
| 44 | + */ |
|
| 45 | 45 | public function __construct($db) { |
| 46 | 46 | $this->db = $db; |
| 47 | 47 | return 1; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Define array with couple subtitution key => subtitution value |
|
| 53 | - * |
|
| 54 | - * @param User $user User |
|
| 55 | - * @param Translate $outputlangs Language object for output |
|
| 56 | - * @return array Array of substitution key->code |
|
| 57 | - */ |
|
| 58 | - function get_substitutionarray_user($user,$outputlangs) |
|
| 59 | - { |
|
| 60 | - global $conf; |
|
| 61 | - |
|
| 62 | - $logotouse=$conf->user->dir_output.'/'.get_exdir($user->id, 2, 0, 1, $user, 'user').'/'.$user->photo; |
|
| 63 | - |
|
| 64 | - return array( |
|
| 65 | - 'myuser_lastname'=>$user->lastname, |
|
| 66 | - 'myuser_firstname'=>$user->firstname, |
|
| 67 | - 'myuser_fullname'=>$user->getFullName($outputlangs,1), |
|
| 68 | - 'myuser_login'=>$user->login, |
|
| 69 | - 'myuser_phone'=>$user->office_phone, |
|
| 70 | - 'myuser_address'=>$user->address, |
|
| 71 | - 'myuser_zip'=>$user->zip, |
|
| 72 | - 'myuser_town'=>$user->town, |
|
| 73 | - 'myuser_country'=>$user->country, |
|
| 74 | - 'myuser_country_code'=>$user->country_code, |
|
| 75 | - 'myuser_state'=>$user->state, |
|
| 76 | - 'myuser_state_code'=>$user->state_code, |
|
| 77 | - 'myuser_fax'=>$user->office_fax, |
|
| 78 | - 'myuser_mobile'=>$user->user_mobile, |
|
| 79 | - 'myuser_email'=>$user->email, |
|
| 80 | - 'myuser_logo'=>$logotouse, |
|
| 81 | - 'myuser_job'=>$user->job, |
|
| 82 | - 'myuser_web'=>'' // url not exist in $user object |
|
| 83 | - ); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Define array with couple subtitution key => subtitution value |
|
| 89 | - * |
|
| 90 | - * @param Societe $mysoc Object thirdparty |
|
| 91 | - * @param Translate $outputlangs Language object for output |
|
| 92 | - * @return array Array of substitution key->code |
|
| 93 | - */ |
|
| 94 | - function get_substitutionarray_mysoc($mysoc,$outputlangs) |
|
| 95 | - { |
|
| 96 | - global $conf; |
|
| 97 | - |
|
| 98 | - if (empty($mysoc->forme_juridique) && ! empty($mysoc->forme_juridique_code)) |
|
| 99 | - { |
|
| 100 | - $mysoc->forme_juridique=getFormeJuridiqueLabel($mysoc->forme_juridique_code); |
|
| 101 | - } |
|
| 102 | - if (empty($mysoc->country) && ! empty($mysoc->country_code)) |
|
| 103 | - { |
|
| 104 | - $mysoc->country=$outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code); |
|
| 105 | - } |
|
| 106 | - if (empty($mysoc->state) && ! empty($mysoc->state_code)) |
|
| 107 | - { |
|
| 108 | - $mysoc->state=getState($mysoc->state_code,0); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - $logotouse=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
| 112 | - |
|
| 113 | - return array( |
|
| 114 | - 'mycompany_logo'=>$logotouse, |
|
| 115 | - 'mycompany_name'=>$mysoc->name, |
|
| 116 | - 'mycompany_email'=>$mysoc->email, |
|
| 117 | - 'mycompany_phone'=>$mysoc->phone, |
|
| 118 | - 'mycompany_fax'=>$mysoc->fax, |
|
| 119 | - 'mycompany_address'=>$mysoc->address, |
|
| 120 | - 'mycompany_zip'=>$mysoc->zip, |
|
| 121 | - 'mycompany_town'=>$mysoc->town, |
|
| 122 | - 'mycompany_country'=>$mysoc->country, |
|
| 123 | - 'mycompany_country_code'=>$mysoc->country_code, |
|
| 124 | - 'mycompany_state'=>$mysoc->state, |
|
| 125 | - 'mycompany_state_code'=>$mysoc->state_code, |
|
| 126 | - 'mycompany_web'=>$mysoc->url, |
|
| 127 | - 'mycompany_juridicalstatus'=>$mysoc->forme_juridique, |
|
| 128 | - 'mycompany_managers'=>$mysoc->managers, |
|
| 129 | - 'mycompany_capital'=>$mysoc->capital, |
|
| 130 | - 'mycompany_barcode'=>$mysoc->barcode, |
|
| 131 | - 'mycompany_idprof1'=>$mysoc->idprof1, |
|
| 132 | - 'mycompany_idprof2'=>$mysoc->idprof2, |
|
| 133 | - 'mycompany_idprof3'=>$mysoc->idprof3, |
|
| 134 | - 'mycompany_idprof4'=>$mysoc->idprof4, |
|
| 135 | - 'mycompany_idprof5'=>$mysoc->idprof5, |
|
| 136 | - 'mycompany_idprof6'=>$mysoc->idprof6, |
|
| 137 | - 'mycompany_vatnumber'=>$mysoc->tva_intra, |
|
| 51 | + /** |
|
| 52 | + * Define array with couple subtitution key => subtitution value |
|
| 53 | + * |
|
| 54 | + * @param User $user User |
|
| 55 | + * @param Translate $outputlangs Language object for output |
|
| 56 | + * @return array Array of substitution key->code |
|
| 57 | + */ |
|
| 58 | + function get_substitutionarray_user($user,$outputlangs) |
|
| 59 | + { |
|
| 60 | + global $conf; |
|
| 61 | + |
|
| 62 | + $logotouse=$conf->user->dir_output.'/'.get_exdir($user->id, 2, 0, 1, $user, 'user').'/'.$user->photo; |
|
| 63 | + |
|
| 64 | + return array( |
|
| 65 | + 'myuser_lastname'=>$user->lastname, |
|
| 66 | + 'myuser_firstname'=>$user->firstname, |
|
| 67 | + 'myuser_fullname'=>$user->getFullName($outputlangs,1), |
|
| 68 | + 'myuser_login'=>$user->login, |
|
| 69 | + 'myuser_phone'=>$user->office_phone, |
|
| 70 | + 'myuser_address'=>$user->address, |
|
| 71 | + 'myuser_zip'=>$user->zip, |
|
| 72 | + 'myuser_town'=>$user->town, |
|
| 73 | + 'myuser_country'=>$user->country, |
|
| 74 | + 'myuser_country_code'=>$user->country_code, |
|
| 75 | + 'myuser_state'=>$user->state, |
|
| 76 | + 'myuser_state_code'=>$user->state_code, |
|
| 77 | + 'myuser_fax'=>$user->office_fax, |
|
| 78 | + 'myuser_mobile'=>$user->user_mobile, |
|
| 79 | + 'myuser_email'=>$user->email, |
|
| 80 | + 'myuser_logo'=>$logotouse, |
|
| 81 | + 'myuser_job'=>$user->job, |
|
| 82 | + 'myuser_web'=>'' // url not exist in $user object |
|
| 83 | + ); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Define array with couple subtitution key => subtitution value |
|
| 89 | + * |
|
| 90 | + * @param Societe $mysoc Object thirdparty |
|
| 91 | + * @param Translate $outputlangs Language object for output |
|
| 92 | + * @return array Array of substitution key->code |
|
| 93 | + */ |
|
| 94 | + function get_substitutionarray_mysoc($mysoc,$outputlangs) |
|
| 95 | + { |
|
| 96 | + global $conf; |
|
| 97 | + |
|
| 98 | + if (empty($mysoc->forme_juridique) && ! empty($mysoc->forme_juridique_code)) |
|
| 99 | + { |
|
| 100 | + $mysoc->forme_juridique=getFormeJuridiqueLabel($mysoc->forme_juridique_code); |
|
| 101 | + } |
|
| 102 | + if (empty($mysoc->country) && ! empty($mysoc->country_code)) |
|
| 103 | + { |
|
| 104 | + $mysoc->country=$outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code); |
|
| 105 | + } |
|
| 106 | + if (empty($mysoc->state) && ! empty($mysoc->state_code)) |
|
| 107 | + { |
|
| 108 | + $mysoc->state=getState($mysoc->state_code,0); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + $logotouse=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
| 112 | + |
|
| 113 | + return array( |
|
| 114 | + 'mycompany_logo'=>$logotouse, |
|
| 115 | + 'mycompany_name'=>$mysoc->name, |
|
| 116 | + 'mycompany_email'=>$mysoc->email, |
|
| 117 | + 'mycompany_phone'=>$mysoc->phone, |
|
| 118 | + 'mycompany_fax'=>$mysoc->fax, |
|
| 119 | + 'mycompany_address'=>$mysoc->address, |
|
| 120 | + 'mycompany_zip'=>$mysoc->zip, |
|
| 121 | + 'mycompany_town'=>$mysoc->town, |
|
| 122 | + 'mycompany_country'=>$mysoc->country, |
|
| 123 | + 'mycompany_country_code'=>$mysoc->country_code, |
|
| 124 | + 'mycompany_state'=>$mysoc->state, |
|
| 125 | + 'mycompany_state_code'=>$mysoc->state_code, |
|
| 126 | + 'mycompany_web'=>$mysoc->url, |
|
| 127 | + 'mycompany_juridicalstatus'=>$mysoc->forme_juridique, |
|
| 128 | + 'mycompany_managers'=>$mysoc->managers, |
|
| 129 | + 'mycompany_capital'=>$mysoc->capital, |
|
| 130 | + 'mycompany_barcode'=>$mysoc->barcode, |
|
| 131 | + 'mycompany_idprof1'=>$mysoc->idprof1, |
|
| 132 | + 'mycompany_idprof2'=>$mysoc->idprof2, |
|
| 133 | + 'mycompany_idprof3'=>$mysoc->idprof3, |
|
| 134 | + 'mycompany_idprof4'=>$mysoc->idprof4, |
|
| 135 | + 'mycompany_idprof5'=>$mysoc->idprof5, |
|
| 136 | + 'mycompany_idprof6'=>$mysoc->idprof6, |
|
| 137 | + 'mycompany_vatnumber'=>$mysoc->tva_intra, |
|
| 138 | 138 | 'mycompany_object'=>$mysoc->object, |
| 139 | - 'mycompany_note_private'=>$mysoc->note_private, |
|
| 140 | - //'mycompany_note_public'=>$mysoc->note_public, // Only private not exists for "mysoc" but both for thirdparties |
|
| 141 | - ); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Define array with couple subtitution key => subtitution value |
|
| 147 | - * |
|
| 148 | - * @param Object $object Object |
|
| 149 | - * @param Translate $outputlangs Language object for output |
|
| 150 | - * @return array Array of substitution key->code |
|
| 151 | - */ |
|
| 152 | - function get_substitutionarray_thirdparty($object,$outputlangs) |
|
| 153 | - { |
|
| 154 | - global $conf; |
|
| 155 | - |
|
| 156 | - if (empty($object->country) && ! empty($object->country_code)) |
|
| 157 | - { |
|
| 158 | - $object->country=$outputlangs->transnoentitiesnoconv("Country".$object->country_code); |
|
| 159 | - } |
|
| 160 | - if (empty($object->state) && ! empty($object->state_code)) |
|
| 161 | - { |
|
| 162 | - $object->state=getState($object->state_code,0); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - $array_thirdparty = array( |
|
| 166 | - 'company_name'=>$object->name, |
|
| 167 | - 'company_name_alias' => $object->name_alias, |
|
| 168 | - 'company_email'=>$object->email, |
|
| 169 | - 'company_phone'=>$object->phone, |
|
| 170 | - 'company_fax'=>$object->fax, |
|
| 171 | - 'company_address'=>$object->address, |
|
| 172 | - 'company_zip'=>$object->zip, |
|
| 173 | - 'company_town'=>$object->town, |
|
| 174 | - 'company_country'=>$object->country, |
|
| 175 | - 'company_country_code'=>$object->country_code, |
|
| 176 | - 'company_state'=>$object->state, |
|
| 177 | - 'company_state_code'=>$object->state_code, |
|
| 178 | - 'company_web'=>$object->url, |
|
| 179 | - 'company_barcode'=>$object->barcode, |
|
| 180 | - 'company_vatnumber'=>$object->tva_intra, |
|
| 181 | - 'company_customercode'=>$object->code_client, |
|
| 182 | - 'company_suppliercode'=>$object->code_fournisseur, |
|
| 183 | - 'company_customeraccountancycode'=>$object->code_compta, |
|
| 184 | - 'company_supplieraccountancycode'=>$object->code_compta_fournisseur, |
|
| 185 | - 'company_juridicalstatus'=>$object->forme_juridique, |
|
| 186 | - 'company_outstanding_limit'=>$object->outstanding_limit, |
|
| 187 | - 'company_capital'=>$object->capital, |
|
| 188 | - 'company_idprof1'=>$object->idprof1, |
|
| 189 | - 'company_idprof2'=>$object->idprof2, |
|
| 190 | - 'company_idprof3'=>$object->idprof3, |
|
| 191 | - 'company_idprof4'=>$object->idprof4, |
|
| 192 | - 'company_idprof5'=>$object->idprof5, |
|
| 193 | - 'company_idprof6'=>$object->idprof6, |
|
| 194 | - 'company_note_public'=>$object->note_public, |
|
| 195 | - 'company_note_private'=>$object->note_private, |
|
| 196 | - 'company_default_bank_iban'=>$object->bank_account->iban, |
|
| 197 | - 'company_default_bank_bic'=>$object->bank_account->bic |
|
| 198 | - ); |
|
| 199 | - |
|
| 200 | - // Retrieve extrafields |
|
| 201 | - if(is_array($object->array_options) && count($object->array_options)) |
|
| 202 | - { |
|
| 203 | - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
| 204 | - $extrafields = new ExtraFields($this->db); |
|
| 205 | - $extralabels = $extrafields->fetch_name_optionals_label('societe',true); |
|
| 206 | - $object->fetch_optionals(); |
|
| 207 | - |
|
| 208 | - foreach($extrafields->attribute_label as $key=>$label) |
|
| 209 | - { |
|
| 210 | - if($extrafields->attribute_type[$key] == 'price') |
|
| 211 | - { |
|
| 212 | - $object->array_options['options_'.$key] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
|
| 213 | - } |
|
| 214 | - else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 215 | - { |
|
| 216 | - $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
|
| 217 | - } |
|
| 218 | - $array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key])); |
|
| 139 | + 'mycompany_note_private'=>$mysoc->note_private, |
|
| 140 | + //'mycompany_note_public'=>$mysoc->note_public, // Only private not exists for "mysoc" but both for thirdparties |
|
| 141 | + ); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Define array with couple subtitution key => subtitution value |
|
| 147 | + * |
|
| 148 | + * @param Object $object Object |
|
| 149 | + * @param Translate $outputlangs Language object for output |
|
| 150 | + * @return array Array of substitution key->code |
|
| 151 | + */ |
|
| 152 | + function get_substitutionarray_thirdparty($object,$outputlangs) |
|
| 153 | + { |
|
| 154 | + global $conf; |
|
| 155 | + |
|
| 156 | + if (empty($object->country) && ! empty($object->country_code)) |
|
| 157 | + { |
|
| 158 | + $object->country=$outputlangs->transnoentitiesnoconv("Country".$object->country_code); |
|
| 159 | + } |
|
| 160 | + if (empty($object->state) && ! empty($object->state_code)) |
|
| 161 | + { |
|
| 162 | + $object->state=getState($object->state_code,0); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + $array_thirdparty = array( |
|
| 166 | + 'company_name'=>$object->name, |
|
| 167 | + 'company_name_alias' => $object->name_alias, |
|
| 168 | + 'company_email'=>$object->email, |
|
| 169 | + 'company_phone'=>$object->phone, |
|
| 170 | + 'company_fax'=>$object->fax, |
|
| 171 | + 'company_address'=>$object->address, |
|
| 172 | + 'company_zip'=>$object->zip, |
|
| 173 | + 'company_town'=>$object->town, |
|
| 174 | + 'company_country'=>$object->country, |
|
| 175 | + 'company_country_code'=>$object->country_code, |
|
| 176 | + 'company_state'=>$object->state, |
|
| 177 | + 'company_state_code'=>$object->state_code, |
|
| 178 | + 'company_web'=>$object->url, |
|
| 179 | + 'company_barcode'=>$object->barcode, |
|
| 180 | + 'company_vatnumber'=>$object->tva_intra, |
|
| 181 | + 'company_customercode'=>$object->code_client, |
|
| 182 | + 'company_suppliercode'=>$object->code_fournisseur, |
|
| 183 | + 'company_customeraccountancycode'=>$object->code_compta, |
|
| 184 | + 'company_supplieraccountancycode'=>$object->code_compta_fournisseur, |
|
| 185 | + 'company_juridicalstatus'=>$object->forme_juridique, |
|
| 186 | + 'company_outstanding_limit'=>$object->outstanding_limit, |
|
| 187 | + 'company_capital'=>$object->capital, |
|
| 188 | + 'company_idprof1'=>$object->idprof1, |
|
| 189 | + 'company_idprof2'=>$object->idprof2, |
|
| 190 | + 'company_idprof3'=>$object->idprof3, |
|
| 191 | + 'company_idprof4'=>$object->idprof4, |
|
| 192 | + 'company_idprof5'=>$object->idprof5, |
|
| 193 | + 'company_idprof6'=>$object->idprof6, |
|
| 194 | + 'company_note_public'=>$object->note_public, |
|
| 195 | + 'company_note_private'=>$object->note_private, |
|
| 196 | + 'company_default_bank_iban'=>$object->bank_account->iban, |
|
| 197 | + 'company_default_bank_bic'=>$object->bank_account->bic |
|
| 198 | + ); |
|
| 199 | + |
|
| 200 | + // Retrieve extrafields |
|
| 201 | + if(is_array($object->array_options) && count($object->array_options)) |
|
| 202 | + { |
|
| 203 | + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
| 204 | + $extrafields = new ExtraFields($this->db); |
|
| 205 | + $extralabels = $extrafields->fetch_name_optionals_label('societe',true); |
|
| 206 | + $object->fetch_optionals(); |
|
| 207 | + |
|
| 208 | + foreach($extrafields->attribute_label as $key=>$label) |
|
| 209 | + { |
|
| 210 | + if($extrafields->attribute_type[$key] == 'price') |
|
| 211 | + { |
|
| 212 | + $object->array_options['options_'.$key] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
|
| 213 | + } |
|
| 214 | + else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 215 | + { |
|
| 216 | + $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
|
| 217 | + } |
|
| 218 | + $array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key])); |
|
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | return $array_thirdparty; |
@@ -242,32 +242,32 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | $array_contact = array ( |
| 245 | - $array_key . '_fullname' => $object->getFullName($outputlangs, 1), |
|
| 246 | - $array_key . '_lastname' => $object->lastname, |
|
| 247 | - $array_key . '_firstname' => $object->firstname, |
|
| 248 | - $array_key . '_address' => $object->address, |
|
| 249 | - $array_key . '_zip' => $object->zip, |
|
| 250 | - $array_key . '_town' => $object->town, |
|
| 251 | - $array_key . '_state_id' => $object->state_id, |
|
| 252 | - $array_key . '_state_code' => $object->state_code, |
|
| 253 | - $array_key . '_state' => $object->state, |
|
| 254 | - $array_key . '_country_id' => $object->country_id, |
|
| 255 | - $array_key . '_country_code' => $object->country_code, |
|
| 256 | - $array_key . '_country' => $object->country, |
|
| 257 | - $array_key . '_poste' => $object->poste, |
|
| 258 | - $array_key . '_socid' => $object->socid, |
|
| 259 | - $array_key . '_statut' => $object->statut, |
|
| 260 | - $array_key . '_code' => $object->code, |
|
| 261 | - $array_key . '_email' => $object->email, |
|
| 262 | - $array_key . '_jabberid' => $object->jabberid, |
|
| 263 | - $array_key . '_phone_pro' => $object->phone_pro, |
|
| 264 | - $array_key . '_phone_perso' => $object->phone_perso, |
|
| 265 | - $array_key . '_phone_mobile' => $object->phone_mobile, |
|
| 266 | - $array_key . '_fax' => $object->fax, |
|
| 267 | - $array_key . '_birthday' => $object->birthday, |
|
| 268 | - $array_key . '_default_lang' => $object->default_lang, |
|
| 269 | - $array_key . '_note_public' => $object->note_public, |
|
| 270 | - $array_key . '_note_private' => $object->note_private |
|
| 245 | + $array_key . '_fullname' => $object->getFullName($outputlangs, 1), |
|
| 246 | + $array_key . '_lastname' => $object->lastname, |
|
| 247 | + $array_key . '_firstname' => $object->firstname, |
|
| 248 | + $array_key . '_address' => $object->address, |
|
| 249 | + $array_key . '_zip' => $object->zip, |
|
| 250 | + $array_key . '_town' => $object->town, |
|
| 251 | + $array_key . '_state_id' => $object->state_id, |
|
| 252 | + $array_key . '_state_code' => $object->state_code, |
|
| 253 | + $array_key . '_state' => $object->state, |
|
| 254 | + $array_key . '_country_id' => $object->country_id, |
|
| 255 | + $array_key . '_country_code' => $object->country_code, |
|
| 256 | + $array_key . '_country' => $object->country, |
|
| 257 | + $array_key . '_poste' => $object->poste, |
|
| 258 | + $array_key . '_socid' => $object->socid, |
|
| 259 | + $array_key . '_statut' => $object->statut, |
|
| 260 | + $array_key . '_code' => $object->code, |
|
| 261 | + $array_key . '_email' => $object->email, |
|
| 262 | + $array_key . '_jabberid' => $object->jabberid, |
|
| 263 | + $array_key . '_phone_pro' => $object->phone_pro, |
|
| 264 | + $array_key . '_phone_perso' => $object->phone_perso, |
|
| 265 | + $array_key . '_phone_mobile' => $object->phone_mobile, |
|
| 266 | + $array_key . '_fax' => $object->fax, |
|
| 267 | + $array_key . '_birthday' => $object->birthday, |
|
| 268 | + $array_key . '_default_lang' => $object->default_lang, |
|
| 269 | + $array_key . '_note_public' => $object->note_public, |
|
| 270 | + $array_key . '_note_private' => $object->note_private |
|
| 271 | 271 | ); |
| 272 | 272 | |
| 273 | 273 | // Retrieve extrafields |
@@ -292,40 +292,40 @@ discard block |
||
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | |
| 295 | - /** |
|
| 296 | - * Define array with couple subtitution key => subtitution value |
|
| 297 | - * |
|
| 298 | - * @param Translate $outputlangs Language object for output |
|
| 299 | - * @return array Array of substitution key->code |
|
| 300 | - */ |
|
| 301 | - function get_substitutionarray_other($outputlangs) |
|
| 302 | - { |
|
| 303 | - global $conf; |
|
| 304 | - |
|
| 305 | - $now=dol_now('gmt'); // gmt |
|
| 306 | - $array_other = array( |
|
| 307 | - // Date in default language |
|
| 308 | - 'current_date'=>dol_print_date($now,'day','tzuser'), |
|
| 309 | - 'current_datehour'=>dol_print_date($now,'dayhour','tzuser'), |
|
| 295 | + /** |
|
| 296 | + * Define array with couple subtitution key => subtitution value |
|
| 297 | + * |
|
| 298 | + * @param Translate $outputlangs Language object for output |
|
| 299 | + * @return array Array of substitution key->code |
|
| 300 | + */ |
|
| 301 | + function get_substitutionarray_other($outputlangs) |
|
| 302 | + { |
|
| 303 | + global $conf; |
|
| 304 | + |
|
| 305 | + $now=dol_now('gmt'); // gmt |
|
| 306 | + $array_other = array( |
|
| 307 | + // Date in default language |
|
| 308 | + 'current_date'=>dol_print_date($now,'day','tzuser'), |
|
| 309 | + 'current_datehour'=>dol_print_date($now,'dayhour','tzuser'), |
|
| 310 | 310 | 'current_server_date'=>dol_print_date($now,'day','tzserver'), |
| 311 | 311 | 'current_server_datehour'=>dol_print_date($now,'dayhour','tzserver'), |
| 312 | - // Date in requested output language |
|
| 313 | - 'current_date_locale'=>dol_print_date($now,'day','tzuser',$outputlangs), |
|
| 312 | + // Date in requested output language |
|
| 313 | + 'current_date_locale'=>dol_print_date($now,'day','tzuser',$outputlangs), |
|
| 314 | 314 | 'current_datehour_locale'=>dol_print_date($now,'dayhour','tzuser',$outputlangs), |
| 315 | 315 | 'current_server_date_locale'=>dol_print_date($now,'day','tzserver',$outputlangs), |
| 316 | 316 | 'current_server_datehour_locale'=>dol_print_date($now,'dayhour','tzserver',$outputlangs), |
| 317 | - ); |
|
| 317 | + ); |
|
| 318 | 318 | |
| 319 | 319 | |
| 320 | - foreach($conf->global as $key => $val) |
|
| 321 | - { |
|
| 322 | - if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; |
|
| 323 | - else $newval = $val; |
|
| 324 | - $array_other['__['.$key.']__'] = $newval; |
|
| 325 | - } |
|
| 320 | + foreach($conf->global as $key => $val) |
|
| 321 | + { |
|
| 322 | + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; |
|
| 323 | + else $newval = $val; |
|
| 324 | + $array_other['__['.$key.']__'] = $newval; |
|
| 325 | + } |
|
| 326 | 326 | |
| 327 | - return $array_other; |
|
| 328 | - } |
|
| 327 | + return $array_other; |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | 330 | |
| 331 | 331 | /** |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | * |
| 334 | 334 | * @param Object $object Main object to use as data source |
| 335 | 335 | * @param Translate $outputlangs Lang object to use for output |
| 336 | - * @param string $array_key Name of the key for return array |
|
| 336 | + * @param string $array_key Name of the key for return array |
|
| 337 | 337 | * @return array Array of substitution |
| 338 | 338 | */ |
| 339 | 339 | function get_substitutionarray_object($object,$outputlangs,$array_key='object') |
@@ -363,11 +363,11 @@ discard block |
||
| 363 | 363 | $array_key.'_ref_supplier'=>(! empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), |
| 364 | 364 | $array_key.'_source_invoice_ref'=>$invoice_source->ref, |
| 365 | 365 | // Dates |
| 366 | - $array_key.'_hour'=>dol_print_date($date,'hour'), |
|
| 366 | + $array_key.'_hour'=>dol_print_date($date,'hour'), |
|
| 367 | 367 | $array_key.'_date'=>dol_print_date($date,'day'), |
| 368 | 368 | $array_key.'_date_rfc'=>dol_print_date($date,'dayrfc'), |
| 369 | 369 | $array_key.'_date_limit'=>(! empty($object->date_lim_reglement)?dol_print_date($object->date_lim_reglement,'day'):''), |
| 370 | - $array_key.'_date_end'=>(! empty($object->fin_validite)?dol_print_date($object->fin_validite,'day'):''), |
|
| 370 | + $array_key.'_date_end'=>(! empty($object->fin_validite)?dol_print_date($object->fin_validite,'day'):''), |
|
| 371 | 371 | $array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), |
| 372 | 372 | $array_key.'_date_modification'=>(! empty($object->date_modification)?dol_print_date($object->date_modification,'day'):''), |
| 373 | 373 | $array_key.'_date_validation'=>(! empty($object->date_validation)?dol_print_date($object->date_validation,'dayhour'):''), |
@@ -393,8 +393,8 @@ discard block |
||
| 393 | 393 | |
| 394 | 394 | $array_key.'_multicurrency_code' => price2num($object->multicurrency_code), |
| 395 | 395 | $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), |
| 396 | - $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), |
|
| 397 | - $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), |
|
| 396 | + $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), |
|
| 397 | + $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), |
|
| 398 | 398 | $array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc), |
| 399 | 399 | $array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs), |
| 400 | 400 | $array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs), |
@@ -448,11 +448,11 @@ discard block |
||
| 448 | 448 | { |
| 449 | 449 | foreach ($object->lines as $line) |
| 450 | 450 | { |
| 451 | - // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility |
|
| 451 | + // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility |
|
| 452 | 452 | if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; |
| 453 | 453 | $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
| 454 | 454 | $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); |
| 455 | - // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) |
|
| 455 | + // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) |
|
| 456 | 456 | $vatformated=vatrate($line->tva_tx); |
| 457 | 457 | if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; |
| 458 | 458 | $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; |
@@ -502,30 +502,30 @@ discard block |
||
| 502 | 502 | 'line_price_ht_locale'=>price($line->total_ht, 0, $outputlangs), |
| 503 | 503 | 'line_price_ttc_locale'=>price($line->total_ttc, 0, $outputlangs), |
| 504 | 504 | 'line_price_vat_locale'=>price($line->total_tva, 0, $outputlangs), |
| 505 | - // Dates |
|
| 505 | + // Dates |
|
| 506 | 506 | 'line_date_start'=>dol_print_date($line->date_start, 'day', 'tzuser'), |
| 507 | 507 | 'line_date_start_locale'=>dol_print_date($line->date_start, 'day', 'tzuser', $outputlangs), |
| 508 | - 'line_date_start_rfc'=>dol_print_date($line->date_start, 'dayrfc', 'tzuser'), |
|
| 509 | - 'line_date_end'=>dol_print_date($line->date_end, 'day', 'tzuser'), |
|
| 510 | - 'line_date_end_locale'=>dol_print_date($line->date_end, 'day', 'tzuser', $outputlangs), |
|
| 511 | - 'line_date_end_rfc'=>dol_print_date($line->date_end, 'dayrfc', 'tzuser'), |
|
| 512 | - |
|
| 513 | - 'line_multicurrency_code' => price2num($line->multicurrency_code), |
|
| 514 | - 'line_multicurrency_subprice' => price2num($line->multicurrency_subprice), |
|
| 515 | - 'line_multicurrency_total_ht' => price2num($line->multicurrency_total_ht), |
|
| 516 | - 'line_multicurrency_total_tva' => price2num($line->multicurrency_total_tva), |
|
| 517 | - 'line_multicurrency_total_ttc' => price2num($line->multicurrency_total_ttc), |
|
| 518 | - 'line_multicurrency_subprice_locale' => price($line->multicurrency_subprice, 0, $outputlangs), |
|
| 519 | - 'line_multicurrency_total_ht_locale' => price($line->multicurrency_total_ht, 0, $outputlangs), |
|
| 520 | - 'line_multicurrency_total_tva_locale' => price($line->multicurrency_total_tva, 0, $outputlangs), |
|
| 521 | - 'line_multicurrency_total_ttc_locale' => price($line->multicurrency_total_ttc, 0, $outputlangs), |
|
| 508 | + 'line_date_start_rfc'=>dol_print_date($line->date_start, 'dayrfc', 'tzuser'), |
|
| 509 | + 'line_date_end'=>dol_print_date($line->date_end, 'day', 'tzuser'), |
|
| 510 | + 'line_date_end_locale'=>dol_print_date($line->date_end, 'day', 'tzuser', $outputlangs), |
|
| 511 | + 'line_date_end_rfc'=>dol_print_date($line->date_end, 'dayrfc', 'tzuser'), |
|
| 512 | + |
|
| 513 | + 'line_multicurrency_code' => price2num($line->multicurrency_code), |
|
| 514 | + 'line_multicurrency_subprice' => price2num($line->multicurrency_subprice), |
|
| 515 | + 'line_multicurrency_total_ht' => price2num($line->multicurrency_total_ht), |
|
| 516 | + 'line_multicurrency_total_tva' => price2num($line->multicurrency_total_tva), |
|
| 517 | + 'line_multicurrency_total_ttc' => price2num($line->multicurrency_total_ttc), |
|
| 518 | + 'line_multicurrency_subprice_locale' => price($line->multicurrency_subprice, 0, $outputlangs), |
|
| 519 | + 'line_multicurrency_total_ht_locale' => price($line->multicurrency_total_ht, 0, $outputlangs), |
|
| 520 | + 'line_multicurrency_total_tva_locale' => price($line->multicurrency_total_tva, 0, $outputlangs), |
|
| 521 | + 'line_multicurrency_total_ttc_locale' => price($line->multicurrency_total_ttc, 0, $outputlangs), |
|
| 522 | 522 | ); |
| 523 | 523 | |
| 524 | - // Units |
|
| 524 | + // Units |
|
| 525 | 525 | if ($conf->global->PRODUCT_USE_UNITS) |
| 526 | 526 | { |
| 527 | - $resarray['line_unit']=$outputlangs->trans($line->getLabelOfUnit('long')); |
|
| 528 | - $resarray['line_unit_short']=$outputlangs->trans($line->getLabelOfUnit('short')); |
|
| 527 | + $resarray['line_unit']=$outputlangs->trans($line->getLabelOfUnit('long')); |
|
| 528 | + $resarray['line_unit_short']=$outputlangs->trans($line->getLabelOfUnit('short')); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | // Retrieve extrafields |
@@ -550,54 +550,54 @@ discard block |
||
| 550 | 550 | return $resarray; |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | - /** |
|
| 554 | - * Define array with couple substitution key => substitution value |
|
| 555 | - * |
|
| 556 | - * @param Expedition $object Main object to use as data source |
|
| 557 | - * @param Translate $outputlangs Lang object to use for output |
|
| 558 | - * @param array_key $array_key Name of the key for return array |
|
| 559 | - * @return array Array of substitution |
|
| 560 | - */ |
|
| 561 | - function get_substitutionarray_shipment($object,$outputlangs,$array_key='object') |
|
| 562 | - { |
|
| 563 | - global $conf; |
|
| 553 | + /** |
|
| 554 | + * Define array with couple substitution key => substitution value |
|
| 555 | + * |
|
| 556 | + * @param Expedition $object Main object to use as data source |
|
| 557 | + * @param Translate $outputlangs Lang object to use for output |
|
| 558 | + * @param array_key $array_key Name of the key for return array |
|
| 559 | + * @return array Array of substitution |
|
| 560 | + */ |
|
| 561 | + function get_substitutionarray_shipment($object,$outputlangs,$array_key='object') |
|
| 562 | + { |
|
| 563 | + global $conf; |
|
| 564 | 564 | dol_include_once('/core/lib/product.lib.php'); |
| 565 | 565 | $object->list_delivery_methods($object->shipping_method_id); |
| 566 | 566 | $calculatedVolume=($object->trueWidth * $object->trueHeight * $object->trueDepth); |
| 567 | 567 | |
| 568 | - $array_shipment=array( |
|
| 569 | - $array_key.'_id'=>$object->id, |
|
| 570 | - $array_key.'_ref'=>$object->ref, |
|
| 571 | - $array_key.'_ref_ext'=>$object->ref_ext, |
|
| 572 | - $array_key.'_ref_customer'=>$object->ref_customer, |
|
| 573 | - $array_key.'_date_delivery'=>dol_print_date($object->date_delivery,'day'), |
|
| 574 | - $array_key.'_hour_delivery'=>dol_print_date($object->date_delivery,'hour'), |
|
| 575 | - $array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), |
|
| 576 | - $array_key.'_total_ht'=>price($object->total_ht), |
|
| 577 | - $array_key.'_total_vat'=>price($object->total_tva), |
|
| 578 | - $array_key.'_total_ttc'=>price($object->total_ttc), |
|
| 579 | - $array_key.'_total_discount_ht' => price($object->getTotalDiscount()), |
|
| 580 | - $array_key.'_note_private'=>$object->note_private, |
|
| 581 | - $array_key.'_note'=>$object->note_public, |
|
| 582 | - $array_key.'_tracking_number'=>$object->tracking_number, |
|
| 583 | - $array_key.'_tracking_url'=>$object->tracking_url, |
|
| 584 | - $array_key.'_shipping_method'=>$object->listmeths[0]['libelle'], |
|
| 585 | - $array_key.'_weight'=>$object->trueWeight.' '.measuring_units_string($object->weight_units, 'weight'), |
|
| 586 | - $array_key.'_width'=>$object->trueWidth.' '.measuring_units_string($object->width_units, 'size'), |
|
| 587 | - $array_key.'_height'=>$object->trueHeight.' '.measuring_units_string($object->height_units, 'size'), |
|
| 588 | - $array_key.'_depth'=>$object->trueDepth.' '.measuring_units_string($object->depth_units, 'size'), |
|
| 589 | - $array_key.'_size'=>$calculatedVolume.' '.measuring_units_string(0, 'volume'), |
|
| 590 | - ); |
|
| 591 | - |
|
| 592 | - // Add vat by rates |
|
| 593 | - foreach ($object->lines as $line) |
|
| 594 | - { |
|
| 595 | - if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
| 596 | - $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
|
| 597 | - } |
|
| 568 | + $array_shipment=array( |
|
| 569 | + $array_key.'_id'=>$object->id, |
|
| 570 | + $array_key.'_ref'=>$object->ref, |
|
| 571 | + $array_key.'_ref_ext'=>$object->ref_ext, |
|
| 572 | + $array_key.'_ref_customer'=>$object->ref_customer, |
|
| 573 | + $array_key.'_date_delivery'=>dol_print_date($object->date_delivery,'day'), |
|
| 574 | + $array_key.'_hour_delivery'=>dol_print_date($object->date_delivery,'hour'), |
|
| 575 | + $array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), |
|
| 576 | + $array_key.'_total_ht'=>price($object->total_ht), |
|
| 577 | + $array_key.'_total_vat'=>price($object->total_tva), |
|
| 578 | + $array_key.'_total_ttc'=>price($object->total_ttc), |
|
| 579 | + $array_key.'_total_discount_ht' => price($object->getTotalDiscount()), |
|
| 580 | + $array_key.'_note_private'=>$object->note_private, |
|
| 581 | + $array_key.'_note'=>$object->note_public, |
|
| 582 | + $array_key.'_tracking_number'=>$object->tracking_number, |
|
| 583 | + $array_key.'_tracking_url'=>$object->tracking_url, |
|
| 584 | + $array_key.'_shipping_method'=>$object->listmeths[0]['libelle'], |
|
| 585 | + $array_key.'_weight'=>$object->trueWeight.' '.measuring_units_string($object->weight_units, 'weight'), |
|
| 586 | + $array_key.'_width'=>$object->trueWidth.' '.measuring_units_string($object->width_units, 'size'), |
|
| 587 | + $array_key.'_height'=>$object->trueHeight.' '.measuring_units_string($object->height_units, 'size'), |
|
| 588 | + $array_key.'_depth'=>$object->trueDepth.' '.measuring_units_string($object->depth_units, 'size'), |
|
| 589 | + $array_key.'_size'=>$calculatedVolume.' '.measuring_units_string(0, 'volume'), |
|
| 590 | + ); |
|
| 591 | + |
|
| 592 | + // Add vat by rates |
|
| 593 | + foreach ($object->lines as $line) |
|
| 594 | + { |
|
| 595 | + if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
| 596 | + $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
|
| 597 | + } |
|
| 598 | 598 | |
| 599 | - // Retrieve extrafields |
|
| 600 | - /*if(is_array($object->array_options) && count($object->array_options)) |
|
| 599 | + // Retrieve extrafields |
|
| 600 | + /*if(is_array($object->array_options) && count($object->array_options)) |
|
| 601 | 601 | { |
| 602 | 602 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
| 603 | 603 | $extrafields = new ExtraFields($this->db); |
@@ -606,80 +606,80 @@ discard block |
||
| 606 | 606 | |
| 607 | 607 | $array_shipment = $this->fill_substitutionarray_with_extrafields($object,$array_shipment,$extrafields,$array_key,$outputlangs); |
| 608 | 608 | }*/ |
| 609 | - return $array_shipment; |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - |
|
| 613 | - /** |
|
| 614 | - * Define array with couple substitution key => substitution value |
|
| 615 | - * |
|
| 616 | - * @param array $line Array of lines |
|
| 617 | - * @param Translate $outputlangs Lang object to use for output |
|
| 618 | - * @return array Substitution array |
|
| 619 | - */ |
|
| 620 | - function get_substitutionarray_shipment_lines($line,$outputlangs) |
|
| 621 | - { |
|
| 622 | - global $conf; |
|
| 609 | + return $array_shipment; |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + |
|
| 613 | + /** |
|
| 614 | + * Define array with couple substitution key => substitution value |
|
| 615 | + * |
|
| 616 | + * @param array $line Array of lines |
|
| 617 | + * @param Translate $outputlangs Lang object to use for output |
|
| 618 | + * @return array Substitution array |
|
| 619 | + */ |
|
| 620 | + function get_substitutionarray_shipment_lines($line,$outputlangs) |
|
| 621 | + { |
|
| 622 | + global $conf; |
|
| 623 | 623 | dol_include_once('/core/lib/product.lib.php'); |
| 624 | 624 | |
| 625 | - return array( |
|
| 626 | - 'line_fulldesc'=>doc_getlinedesc($line,$outputlangs), |
|
| 627 | - 'line_product_ref'=>$line->product_ref, |
|
| 628 | - 'line_product_label'=>$line->product_label, |
|
| 629 | - 'line_desc'=>$line->desc, |
|
| 630 | - 'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits), |
|
| 631 | - 'line_up'=>price($line->subprice), |
|
| 632 | - 'line_qty'=>$line->qty, |
|
| 633 | - 'line_qty_shipped'=>$line->qty_shipped, |
|
| 634 | - 'line_qty_asked'=>$line->qty_asked, |
|
| 635 | - 'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), |
|
| 636 | - 'line_price_ht'=>price($line->total_ht), |
|
| 637 | - 'line_price_ttc'=>price($line->total_ttc), |
|
| 638 | - 'line_price_vat'=>price($line->total_tva), |
|
| 639 | - 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuring_units_string($line->weight_units, 'weight'), |
|
| 640 | - 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuring_units_string($line->length_units, 'size'), |
|
| 641 | - 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'), |
|
| 642 | - 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'), |
|
| 643 | - ); |
|
| 644 | - } |
|
| 645 | - |
|
| 646 | - |
|
| 647 | - /** |
|
| 648 | - * Define array with couple subtitution key => subtitution value |
|
| 649 | - * |
|
| 650 | - * @param Object $object Dolibarr Object |
|
| 651 | - * @param Translate $outputlangs Language object for output |
|
| 652 | - * @param boolean $recursive Want to fetch child array or child object |
|
| 653 | - * @return array Array of substitution key->code |
|
| 654 | - */ |
|
| 655 | - function get_substitutionarray_each_var_object(&$object,$outputlangs,$recursive=true) { |
|
| 656 | - $array_other = array(); |
|
| 657 | - if(!empty($object)) { |
|
| 658 | - foreach($object as $key => $value) { |
|
| 659 | - if(!empty($value)) { |
|
| 660 | - if(!is_array($value) && !is_object($value)) { |
|
| 661 | - $array_other['object_'.$key] = $value; |
|
| 662 | - } |
|
| 663 | - if(is_array($value) && $recursive){ |
|
| 664 | - $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value,$outputlangs,false); |
|
| 665 | - } |
|
| 666 | - } |
|
| 667 | - } |
|
| 668 | - } |
|
| 669 | - return $array_other; |
|
| 670 | - } |
|
| 671 | - |
|
| 672 | - |
|
| 673 | - /** |
|
| 674 | - * Fill array with couple extrafield key => extrafield value |
|
| 675 | - * |
|
| 676 | - * @param Object $object Object with extrafields (must have $object->array_options filled) |
|
| 677 | - * @param array $array_to_fill Substitution array |
|
| 678 | - * @param Extrafields $extrafields Extrafields object |
|
| 679 | - * @param string $array_key Prefix for name of the keys into returned array |
|
| 680 | - * @param Translate $outputlangs Lang object to use for output |
|
| 681 | - * @return array Substitution array |
|
| 682 | - */ |
|
| 625 | + return array( |
|
| 626 | + 'line_fulldesc'=>doc_getlinedesc($line,$outputlangs), |
|
| 627 | + 'line_product_ref'=>$line->product_ref, |
|
| 628 | + 'line_product_label'=>$line->product_label, |
|
| 629 | + 'line_desc'=>$line->desc, |
|
| 630 | + 'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits), |
|
| 631 | + 'line_up'=>price($line->subprice), |
|
| 632 | + 'line_qty'=>$line->qty, |
|
| 633 | + 'line_qty_shipped'=>$line->qty_shipped, |
|
| 634 | + 'line_qty_asked'=>$line->qty_asked, |
|
| 635 | + 'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), |
|
| 636 | + 'line_price_ht'=>price($line->total_ht), |
|
| 637 | + 'line_price_ttc'=>price($line->total_ttc), |
|
| 638 | + 'line_price_vat'=>price($line->total_tva), |
|
| 639 | + 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuring_units_string($line->weight_units, 'weight'), |
|
| 640 | + 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuring_units_string($line->length_units, 'size'), |
|
| 641 | + 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'), |
|
| 642 | + 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'), |
|
| 643 | + ); |
|
| 644 | + } |
|
| 645 | + |
|
| 646 | + |
|
| 647 | + /** |
|
| 648 | + * Define array with couple subtitution key => subtitution value |
|
| 649 | + * |
|
| 650 | + * @param Object $object Dolibarr Object |
|
| 651 | + * @param Translate $outputlangs Language object for output |
|
| 652 | + * @param boolean $recursive Want to fetch child array or child object |
|
| 653 | + * @return array Array of substitution key->code |
|
| 654 | + */ |
|
| 655 | + function get_substitutionarray_each_var_object(&$object,$outputlangs,$recursive=true) { |
|
| 656 | + $array_other = array(); |
|
| 657 | + if(!empty($object)) { |
|
| 658 | + foreach($object as $key => $value) { |
|
| 659 | + if(!empty($value)) { |
|
| 660 | + if(!is_array($value) && !is_object($value)) { |
|
| 661 | + $array_other['object_'.$key] = $value; |
|
| 662 | + } |
|
| 663 | + if(is_array($value) && $recursive){ |
|
| 664 | + $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value,$outputlangs,false); |
|
| 665 | + } |
|
| 666 | + } |
|
| 667 | + } |
|
| 668 | + } |
|
| 669 | + return $array_other; |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + |
|
| 673 | + /** |
|
| 674 | + * Fill array with couple extrafield key => extrafield value |
|
| 675 | + * |
|
| 676 | + * @param Object $object Object with extrafields (must have $object->array_options filled) |
|
| 677 | + * @param array $array_to_fill Substitution array |
|
| 678 | + * @param Extrafields $extrafields Extrafields object |
|
| 679 | + * @param string $array_key Prefix for name of the keys into returned array |
|
| 680 | + * @param Translate $outputlangs Lang object to use for output |
|
| 681 | + * @return array Substitution array |
|
| 682 | + */ |
|
| 683 | 683 | function fill_substitutionarray_with_extrafields($object,$array_to_fill,$extrafields,$array_key,$outputlangs) |
| 684 | 684 | { |
| 685 | 685 | global $conf; |
@@ -743,12 +743,12 @@ discard block |
||
| 743 | 743 | * @param int $hidebottom Hide bottom |
| 744 | 744 | * @return void |
| 745 | 745 | */ |
| 746 | - function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
|
| 747 | - { |
|
| 748 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
| 749 | - $pdf->line($x+$l, $y, $x+$l, $y+$h); |
|
| 750 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 751 | - $pdf->line($x, $y+$h, $x, $y); |
|
| 752 | - } |
|
| 746 | + function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
|
| 747 | + { |
|
| 748 | + if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
| 749 | + $pdf->line($x+$l, $y, $x+$l, $y+$h); |
|
| 750 | + if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 751 | + $pdf->line($x, $y+$h, $x, $y); |
|
| 752 | + } |
|
| 753 | 753 | } |
| 754 | 754 | |
@@ -210,8 +210,7 @@ discard block |
||
| 210 | 210 | if($extrafields->attribute_type[$key] == 'price') |
| 211 | 211 | { |
| 212 | 212 | $object->array_options['options_'.$key] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
| 213 | - } |
|
| 214 | - else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 213 | + } else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 215 | 214 | { |
| 216 | 215 | $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
| 217 | 216 | } |
@@ -281,8 +280,7 @@ discard block |
||
| 281 | 280 | if ($extrafields->attribute_type[$key] == 'price') |
| 282 | 281 | { |
| 283 | 282 | $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); |
| 284 | - } |
|
| 285 | - elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 283 | + } elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 286 | 284 | { |
| 287 | 285 | $object->array_options['options_' . $key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_' . $key]]; |
| 288 | 286 | } |
@@ -319,8 +317,11 @@ discard block |
||
| 319 | 317 | |
| 320 | 318 | foreach($conf->global as $key => $val) |
| 321 | 319 | { |
| 322 | - if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; |
|
| 323 | - else $newval = $val; |
|
| 320 | + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) { |
|
| 321 | + $newval = '*****forbidden*****'; |
|
| 322 | + } else { |
|
| 323 | + $newval = $val; |
|
| 324 | + } |
|
| 324 | 325 | $array_other['__['.$key.']__'] = $newval; |
| 325 | 326 | } |
| 326 | 327 | |
@@ -449,12 +450,16 @@ discard block |
||
| 449 | 450 | foreach ($object->lines as $line) |
| 450 | 451 | { |
| 451 | 452 | // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility |
| 452 | - if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
| 453 | + if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) { |
|
| 454 | + $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
| 455 | + } |
|
| 453 | 456 | $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
| 454 | 457 | $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); |
| 455 | 458 | // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) |
| 456 | 459 | $vatformated=vatrate($line->tva_tx); |
| 457 | - if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; |
|
| 460 | + if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) { |
|
| 461 | + $resarray[$array_key.'_total_vat_'.$vatformated]=0; |
|
| 462 | + } |
|
| 458 | 463 | $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; |
| 459 | 464 | $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); |
| 460 | 465 | } |
@@ -543,8 +548,9 @@ discard block |
||
| 543 | 548 | { |
| 544 | 549 | $tmpproduct = new Product($this->db); |
| 545 | 550 | $result = $tmpproduct->fetch($line->fk_product); |
| 546 | - foreach($tmpproduct->array_options as $key=>$label) |
|
| 547 | - $resarray["line_".$key] = $label; |
|
| 551 | + foreach($tmpproduct->array_options as $key=>$label) { |
|
| 552 | + $resarray["line_".$key] = $label; |
|
| 553 | + } |
|
| 548 | 554 | } |
| 549 | 555 | |
| 550 | 556 | return $resarray; |
@@ -592,7 +598,9 @@ discard block |
||
| 592 | 598 | // Add vat by rates |
| 593 | 599 | foreach ($object->lines as $line) |
| 594 | 600 | { |
| 595 | - if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
| 601 | + if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) { |
|
| 602 | + $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
| 603 | + } |
|
| 596 | 604 | $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
| 597 | 605 | } |
| 598 | 606 | |
@@ -691,12 +699,10 @@ discard block |
||
| 691 | 699 | $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
| 692 | 700 | //Add value to store price with currency |
| 693 | 701 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); |
| 694 | - } |
|
| 695 | - else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 702 | + } else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
| 696 | 703 | { |
| 697 | 704 | $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
| 698 | - } |
|
| 699 | - else if($extrafields->attribute_type[$key] == 'date') |
|
| 705 | + } else if($extrafields->attribute_type[$key] == 'date') |
|
| 700 | 706 | { |
| 701 | 707 | if (strlen($object->array_options['options_'.$key])>0) |
| 702 | 708 | { |
@@ -704,8 +710,7 @@ discard block |
||
| 704 | 710 | $object->array_options['options_'.$key] = dol_print_date($date,'day'); // using company output language |
| 705 | 711 | $object->array_options['options_'.$key.'_locale'] = dol_print_date($date,'day','tzserver',$outputlangs); // using output language format |
| 706 | 712 | $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date,'dayrfc'); // international format |
| 707 | - } |
|
| 708 | - else |
|
| 713 | + } else |
|
| 709 | 714 | { |
| 710 | 715 | $object->array_options['options_'.$key] = ''; |
| 711 | 716 | $object->array_options['options_'.$key.'_locale'] = ''; |
@@ -713,8 +718,7 @@ discard block |
||
| 713 | 718 | } |
| 714 | 719 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
| 715 | 720 | $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
| 716 | - } |
|
| 717 | - else if($extrafields->attribute_type[$key] == 'datetime') |
|
| 721 | + } else if($extrafields->attribute_type[$key] == 'datetime') |
|
| 718 | 722 | { |
| 719 | 723 | $datetime = $object->array_options['options_'.$key]; |
| 720 | 724 | $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour'):''); // using company output language |
@@ -745,9 +749,13 @@ discard block |
||
| 745 | 749 | */ |
| 746 | 750 | function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
| 747 | 751 | { |
| 748 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
| 752 | + if (empty($hidetop) || $hidetop==-1) { |
|
| 753 | + $pdf->line($x, $y, $x+$l, $y); |
|
| 754 | + } |
|
| 749 | 755 | $pdf->line($x+$l, $y, $x+$l, $y+$h); |
| 750 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 756 | + if (empty($hidebottom)) { |
|
| 757 | + $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 758 | + } |
|
| 751 | 759 | $pdf->line($x, $y+$h, $x, $y); |
| 752 | 760 | } |
| 753 | 761 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
| 159 | 159 | foreach($listoffiles as $file) |
| 160 | 160 | { |
| 161 | - $texte.=$file['name'].'<br>'; |
|
| 161 | + $texte.=$file['name'].'<br>'; |
|
| 162 | 162 | } |
| 163 | 163 | $texte.='<div id="div_'.get_class($this).'">'; |
| 164 | 164 | } |
@@ -258,8 +258,8 @@ discard block |
||
| 258 | 258 | $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
| 259 | 259 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 260 | 260 | { |
| 261 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
| 262 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 261 | + $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
| 262 | + if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 263 | 263 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 264 | 264 | } |
| 265 | 265 | else |
@@ -291,10 +291,10 @@ discard block |
||
| 291 | 291 | // On peut utiliser le nom de la societe du contact |
| 292 | 292 | if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
| 293 | 293 | else { |
| 294 | - $socobject = $object->thirdparty; |
|
| 295 | - // if we have a BILLING contact and we dont use it as recipient we store the contact object for later use |
|
| 296 | - $contactobject = $object->contact; |
|
| 297 | - } |
|
| 294 | + $socobject = $object->thirdparty; |
|
| 295 | + // if we have a BILLING contact and we dont use it as recipient we store the contact object for later use |
|
| 296 | + $contactobject = $object->contact; |
|
| 297 | + } |
|
| 298 | 298 | } |
| 299 | 299 | else |
| 300 | 300 | { |
@@ -84,7 +84,10 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | // Recupere emetteur |
| 86 | 86 | $this->emetteur=$mysoc; |
| 87 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini |
|
| 87 | + if (! $this->emetteur->country_code) { |
|
| 88 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 89 | + } |
|
| 90 | + // Par defaut, si n'etait pas defini |
|
| 88 | 91 | } |
| 89 | 92 | |
| 90 | 93 | |
@@ -122,11 +125,14 @@ discard block |
||
| 122 | 125 | if (! $tmpdir) { |
| 123 | 126 | unset($listofdir[$key]); continue; |
| 124 | 127 | } |
| 125 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 126 | - else |
|
| 128 | + if (! is_dir($tmpdir)) { |
|
| 129 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 130 | + } else |
|
| 127 | 131 | { |
| 128 | 132 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 129 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 133 | + if (count($tmpfiles)) { |
|
| 134 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 135 | + } |
|
| 130 | 136 | } |
| 131 | 137 | } |
| 132 | 138 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -206,7 +212,9 @@ discard block |
||
| 206 | 212 | $hookmanager->initHooks(array('odtgeneration')); |
| 207 | 213 | global $action; |
| 208 | 214 | |
| 209 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 215 | + if (! is_object($outputlangs)) { |
|
| 216 | + $outputlangs=$langs; |
|
| 217 | + } |
|
| 210 | 218 | $sav_charset_output=$outputlangs->charset_output; |
| 211 | 219 | $outputlangs->charset_output='UTF-8'; |
| 212 | 220 | |
@@ -232,7 +240,9 @@ discard block |
||
| 232 | 240 | |
| 233 | 241 | $dir = $conf->facture->dir_output; |
| 234 | 242 | $objectref = dol_sanitizeFileName($object->ref); |
| 235 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 243 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 244 | + $dir.= "/" . $objectref; |
|
| 245 | + } |
|
| 236 | 246 | $file = $dir . "/" . $objectref . ".odt"; |
| 237 | 247 | |
| 238 | 248 | if (! file_exists($dir)) |
@@ -259,10 +269,11 @@ discard block |
||
| 259 | 269 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 260 | 270 | { |
| 261 | 271 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 262 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 272 | + if ($format == '1') { |
|
| 273 | + $format='%Y%m%d%H%M%S'; |
|
| 274 | + } |
|
| 263 | 275 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 264 | - } |
|
| 265 | - else |
|
| 276 | + } else |
|
| 266 | 277 | { |
| 267 | 278 | $filename=$newfiletmp.'.'.$newfileformat; |
| 268 | 279 | } |
@@ -289,14 +300,14 @@ discard block |
||
| 289 | 300 | if (! empty($usecontact)) |
| 290 | 301 | { |
| 291 | 302 | // On peut utiliser le nom de la societe du contact |
| 292 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 293 | - else { |
|
| 303 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 304 | + $socobject = $object->contact; |
|
| 305 | + } else { |
|
| 294 | 306 | $socobject = $object->thirdparty; |
| 295 | 307 | // if we have a BILLING contact and we dont use it as recipient we store the contact object for later use |
| 296 | 308 | $contactobject = $object->contact; |
| 297 | 309 | } |
| 298 | - } |
|
| 299 | - else |
|
| 310 | + } else |
|
| 300 | 311 | { |
| 301 | 312 | $socobject=$object->thirdparty; |
| 302 | 313 | } |
@@ -340,8 +351,7 @@ discard block |
||
| 340 | 351 | 'DELIMITER_RIGHT' => '}' |
| 341 | 352 | ) |
| 342 | 353 | ); |
| 343 | - } |
|
| 344 | - catch(Exception $e) |
|
| 354 | + } catch(Exception $e) |
|
| 345 | 355 | { |
| 346 | 356 | $this->error=$e->getMessage(); |
| 347 | 357 | return -1; |
@@ -356,8 +366,7 @@ discard block |
||
| 356 | 366 | // Make substitutions into odt of freetext |
| 357 | 367 | try { |
| 358 | 368 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 359 | - } |
|
| 360 | - catch(OdfException $e) |
|
| 369 | + } catch(OdfException $e) |
|
| 361 | 370 | { |
| 362 | 371 | } |
| 363 | 372 | |
@@ -372,7 +381,9 @@ discard block |
||
| 372 | 381 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 373 | 382 | // retrieve contact information for use in invoice as contact_xxx tags |
| 374 | 383 | $array_thirdparty_contact = array(); |
| 375 | - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 384 | + if ($usecontact) { |
|
| 385 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 386 | + } |
|
| 376 | 387 | |
| 377 | 388 | $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other,$array_thirdparty_contact); |
| 378 | 389 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -385,18 +396,19 @@ discard block |
||
| 385 | 396 | foreach($tmparray as $key=>$value) |
| 386 | 397 | { |
| 387 | 398 | try { |
| 388 | - if (preg_match('/logo$/',$key)) // Image |
|
| 399 | + if (preg_match('/logo$/',$key)) { |
|
| 400 | + // Image |
|
| 389 | 401 | { |
| 390 | 402 | //var_dump($value);exit; |
| 391 | 403 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 392 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 393 | - } |
|
| 394 | - else // Text |
|
| 404 | + } else { |
|
| 405 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 406 | + } |
|
| 407 | + } else // Text |
|
| 395 | 408 | { |
| 396 | 409 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 397 | 410 | } |
| 398 | - } |
|
| 399 | - catch(OdfException $e) |
|
| 411 | + } catch(OdfException $e) |
|
| 400 | 412 | { |
| 401 | 413 | } |
| 402 | 414 | } |
@@ -406,8 +418,7 @@ discard block |
||
| 406 | 418 | $foundtagforlines = 1; |
| 407 | 419 | try { |
| 408 | 420 | $listlines = $odfHandler->setSegment('lines'); |
| 409 | - } |
|
| 410 | - catch(OdfException $e) |
|
| 421 | + } catch(OdfException $e) |
|
| 411 | 422 | { |
| 412 | 423 | // We may arrive here if tags for lines not present into template |
| 413 | 424 | $foundtagforlines = 0; |
@@ -427,11 +438,9 @@ discard block |
||
| 427 | 438 | try |
| 428 | 439 | { |
| 429 | 440 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 430 | - } |
|
| 431 | - catch(OdfException $e) |
|
| 441 | + } catch(OdfException $e) |
|
| 432 | 442 | { |
| 433 | - } |
|
| 434 | - catch(SegmentException $e) |
|
| 443 | + } catch(SegmentException $e) |
|
| 435 | 444 | { |
| 436 | 445 | } |
| 437 | 446 | } |
@@ -439,8 +448,7 @@ discard block |
||
| 439 | 448 | } |
| 440 | 449 | $odfHandler->mergeSegment($listlines); |
| 441 | 450 | } |
| 442 | - } |
|
| 443 | - catch(OdfException $e) |
|
| 451 | + } catch(OdfException $e) |
|
| 444 | 452 | { |
| 445 | 453 | $this->error=$e->getMessage(); |
| 446 | 454 | dol_syslog($this->error, LOG_WARNING); |
@@ -453,8 +461,7 @@ discard block |
||
| 453 | 461 | { |
| 454 | 462 | try { |
| 455 | 463 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 456 | - } |
|
| 457 | - catch(OdfException $e) |
|
| 464 | + } catch(OdfException $e) |
|
| 458 | 465 | { |
| 459 | 466 | } |
| 460 | 467 | } |
@@ -467,15 +474,14 @@ discard block |
||
| 467 | 474 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 468 | 475 | try { |
| 469 | 476 | $odfHandler->exportAsAttachedPDF($file); |
| 470 | - }catch (Exception $e){ |
|
| 477 | + } catch (Exception $e){ |
|
| 471 | 478 | $this->error=$e->getMessage(); |
| 472 | 479 | return -1; |
| 473 | 480 | } |
| 474 | - } |
|
| 475 | - else { |
|
| 481 | + } else { |
|
| 476 | 482 | try { |
| 477 | 483 | $odfHandler->saveToDisk($file); |
| 478 | - }catch (Exception $e){ |
|
| 484 | + } catch (Exception $e){ |
|
| 479 | 485 | $this->error=$e->getMessage(); |
| 480 | 486 | return -1; |
| 481 | 487 | } |
@@ -483,16 +489,16 @@ discard block |
||
| 483 | 489 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
| 484 | 490 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 485 | 491 | |
| 486 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 487 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 492 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 493 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 494 | + } |
|
| 488 | 495 | |
| 489 | 496 | $odfHandler=null; // Destroy object |
| 490 | 497 | |
| 491 | 498 | $this->result = array('fullpath'=>$file); |
| 492 | 499 | |
| 493 | 500 | return 1; // Success |
| 494 | - } |
|
| 495 | - else |
|
| 501 | + } else |
|
| 496 | 502 | { |
| 497 | 503 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 498 | 504 | return -1; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param Project $object Main object to use as data source |
| 110 | 110 | * @param Translate $outputlangs Lang object to use for output |
| 111 | - * @param string $array_key Name of the key for return array |
|
| 111 | + * @param string $array_key Name of the key for return array |
|
| 112 | 112 | * @return array Array of substitution |
| 113 | 113 | */ |
| 114 | 114 | function get_substitutionarray_object($object,$outputlangs,$array_key='object') |
@@ -116,18 +116,18 @@ discard block |
||
| 116 | 116 | global $conf; |
| 117 | 117 | |
| 118 | 118 | $resarray=array( |
| 119 | - $array_key.'_id'=>$object->id, |
|
| 120 | - $array_key.'_ref'=>$object->ref, |
|
| 121 | - $array_key.'_title'=>$object->title, |
|
| 122 | - $array_key.'_description'=>$object->description, |
|
| 123 | - $array_key.'_date_creation'=>dol_print_date($object->date_c,'day'), |
|
| 124 | - $array_key.'_date_modification'=>dol_print_date($object->date_m,'day'), |
|
| 125 | - $array_key.'_date_start'=>dol_print_date($object->date_start,'day'), |
|
| 126 | - $array_key.'_date_end'=>dol_print_date($object->date_end,'day'), |
|
| 127 | - $array_key.'_note_private'=>$object->note_private, |
|
| 128 | - $array_key.'_note_public'=>$object->note_public, |
|
| 129 | - $array_key.'_public'=>$object->public, |
|
| 130 | - $array_key.'_statut'=>$object->getLibStatut() |
|
| 119 | + $array_key.'_id'=>$object->id, |
|
| 120 | + $array_key.'_ref'=>$object->ref, |
|
| 121 | + $array_key.'_title'=>$object->title, |
|
| 122 | + $array_key.'_description'=>$object->description, |
|
| 123 | + $array_key.'_date_creation'=>dol_print_date($object->date_c,'day'), |
|
| 124 | + $array_key.'_date_modification'=>dol_print_date($object->date_m,'day'), |
|
| 125 | + $array_key.'_date_start'=>dol_print_date($object->date_start,'day'), |
|
| 126 | + $array_key.'_date_end'=>dol_print_date($object->date_end,'day'), |
|
| 127 | + $array_key.'_note_private'=>$object->note_private, |
|
| 128 | + $array_key.'_note_public'=>$object->note_public, |
|
| 129 | + $array_key.'_public'=>$object->public, |
|
| 130 | + $array_key.'_statut'=>$object->getLibStatut() |
|
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | 133 | // Retrieve extrafields |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
| 405 | 405 | foreach($listoffiles as $file) |
| 406 | 406 | { |
| 407 | - $texte.=$file['name'].'<br>'; |
|
| 407 | + $texte.=$file['name'].'<br>'; |
|
| 408 | 408 | } |
| 409 | 409 | $texte.='<div id="div_'.get_class($this).'">'; |
| 410 | 410 | } |
@@ -500,8 +500,8 @@ discard block |
||
| 500 | 500 | $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
| 501 | 501 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 502 | 502 | { |
| 503 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
| 504 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 503 | + $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
| 504 | + if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 505 | 505 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 506 | 506 | } |
| 507 | 507 | else |
@@ -528,8 +528,8 @@ discard block |
||
| 528 | 528 | // Recipient name |
| 529 | 529 | if (! empty($usecontact)) |
| 530 | 530 | { |
| 531 | - // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use |
|
| 532 | - $contactobject = $object->contact; |
|
| 531 | + // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use |
|
| 532 | + $contactobject = $object->contact; |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | $socobject=$object->thirdparty; |
@@ -36,16 +36,36 @@ discard block |
||
| 36 | 36 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 37 | 37 | require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; |
| 38 | 38 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
| 39 | -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 40 | -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 41 | -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
|
| 42 | -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 43 | -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
| 44 | -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
|
| 45 | -if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
| 46 | -if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; |
|
| 47 | -if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; |
|
| 48 | -if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
| 39 | +if (! empty($conf->propal->enabled)) { |
|
| 40 | + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
| 41 | +} |
|
| 42 | +if (! empty($conf->facture->enabled)) { |
|
| 43 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 44 | +} |
|
| 45 | +if (! empty($conf->facture->enabled)) { |
|
| 46 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
|
| 47 | +} |
|
| 48 | +if (! empty($conf->commande->enabled)) { |
|
| 49 | + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
| 50 | +} |
|
| 51 | +if (! empty($conf->fournisseur->enabled)) { |
|
| 52 | + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
| 53 | +} |
|
| 54 | +if (! empty($conf->fournisseur->enabled)) { |
|
| 55 | + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
|
| 56 | +} |
|
| 57 | +if (! empty($conf->contrat->enabled)) { |
|
| 58 | + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
| 59 | +} |
|
| 60 | +if (! empty($conf->ficheinter->enabled)) { |
|
| 61 | + require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; |
|
| 62 | +} |
|
| 63 | +if (! empty($conf->deplacement->enabled)) { |
|
| 64 | + require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; |
|
| 65 | +} |
|
| 66 | +if (! empty($conf->agenda->enabled)) { |
|
| 67 | + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
| 68 | +} |
|
| 49 | 69 | |
| 50 | 70 | |
| 51 | 71 | /** |
@@ -99,7 +119,10 @@ discard block |
||
| 99 | 119 | |
| 100 | 120 | // Recupere emetteur |
| 101 | 121 | $this->emetteur=$mysoc; |
| 102 | - if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini |
|
| 122 | + if (! $this->emetteur->pays_code) { |
|
| 123 | + $this->emetteur->pays_code=substr($langs->defaultlang,-2); |
|
| 124 | + } |
|
| 125 | + // Par defaut, si n'etait pas defini |
|
| 103 | 126 | } |
| 104 | 127 | |
| 105 | 128 | |
@@ -367,11 +390,14 @@ discard block |
||
| 367 | 390 | if (! $tmpdir) { |
| 368 | 391 | unset($listofdir[$key]); continue; |
| 369 | 392 | } |
| 370 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 371 | - else |
|
| 393 | + if (! is_dir($tmpdir)) { |
|
| 394 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 395 | + } else |
|
| 372 | 396 | { |
| 373 | 397 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 374 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 398 | + if (count($tmpfiles)) { |
|
| 399 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 400 | + } |
|
| 375 | 401 | } |
| 376 | 402 | } |
| 377 | 403 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -449,7 +475,9 @@ discard block |
||
| 449 | 475 | $hookmanager->initHooks(array('odtgeneration')); |
| 450 | 476 | global $action; |
| 451 | 477 | |
| 452 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 478 | + if (! is_object($outputlangs)) { |
|
| 479 | + $outputlangs=$langs; |
|
| 480 | + } |
|
| 453 | 481 | $sav_charset_output=$outputlangs->charset_output; |
| 454 | 482 | $outputlangs->charset_output='UTF-8'; |
| 455 | 483 | |
@@ -475,7 +503,9 @@ discard block |
||
| 475 | 503 | |
| 476 | 504 | $dir = $conf->projet->dir_output; |
| 477 | 505 | $objectref = dol_sanitizeFileName($object->ref); |
| 478 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 506 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 507 | + $dir.= "/" . $objectref; |
|
| 508 | + } |
|
| 479 | 509 | $file = $dir . "/" . $objectref . ".odt"; |
| 480 | 510 | |
| 481 | 511 | if (! file_exists($dir)) |
@@ -501,10 +531,11 @@ discard block |
||
| 501 | 531 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 502 | 532 | { |
| 503 | 533 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 504 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 534 | + if ($format == '1') { |
|
| 535 | + $format='%Y%m%d%H%M%S'; |
|
| 536 | + } |
|
| 505 | 537 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 506 | - } |
|
| 507 | - else |
|
| 538 | + } else |
|
| 508 | 539 | { |
| 509 | 540 | $filename=$newfiletmp.'.'.$newfileformat; |
| 510 | 541 | } |
@@ -556,8 +587,7 @@ discard block |
||
| 556 | 587 | 'DELIMITER_RIGHT' => '}' |
| 557 | 588 | ) |
| 558 | 589 | ); |
| 559 | - } |
|
| 560 | - catch(Exception $e) |
|
| 590 | + } catch(Exception $e) |
|
| 561 | 591 | { |
| 562 | 592 | $this->error=$e->getMessage(); |
| 563 | 593 | return -1; |
@@ -579,7 +609,9 @@ discard block |
||
| 579 | 609 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 580 | 610 | // retrieve contact information for use in project as contact_xxx tags |
| 581 | 611 | $array_project_contact = array(); |
| 582 | - if ($usecontact) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 612 | + if ($usecontact) { |
|
| 613 | + $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 614 | + } |
|
| 583 | 615 | |
| 584 | 616 | $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact); |
| 585 | 617 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -591,17 +623,18 @@ discard block |
||
| 591 | 623 | foreach($tmparray as $key=>$value) |
| 592 | 624 | { |
| 593 | 625 | try { |
| 594 | - if (preg_match('/logo$/',$key)) // Image |
|
| 626 | + if (preg_match('/logo$/',$key)) { |
|
| 627 | + // Image |
|
| 595 | 628 | { |
| 596 | 629 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 597 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 598 | - } |
|
| 599 | - else // Text |
|
| 630 | + } else { |
|
| 631 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 632 | + } |
|
| 633 | + } else // Text |
|
| 600 | 634 | { |
| 601 | 635 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 602 | 636 | } |
| 603 | - } |
|
| 604 | - catch(OdfException $e) |
|
| 637 | + } catch(OdfException $e) |
|
| 605 | 638 | { |
| 606 | 639 | } |
| 607 | 640 | } |
@@ -615,7 +648,9 @@ discard block |
||
| 615 | 648 | |
| 616 | 649 | // Security check |
| 617 | 650 | $socid=0; |
| 618 | - if (!empty($object->fk_soc)) $socid = $object->fk_soc; |
|
| 651 | + if (!empty($object->fk_soc)) { |
|
| 652 | + $socid = $object->fk_soc; |
|
| 653 | + } |
|
| 619 | 654 | |
| 620 | 655 | $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0); |
| 621 | 656 | |
@@ -629,11 +664,9 @@ discard block |
||
| 629 | 664 | try |
| 630 | 665 | { |
| 631 | 666 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 632 | - } |
|
| 633 | - catch(OdfException $e) |
|
| 667 | + } catch(OdfException $e) |
|
| 634 | 668 | { |
| 635 | - } |
|
| 636 | - catch(SegmentException $e) |
|
| 669 | + } catch(SegmentException $e) |
|
| 637 | 670 | { |
| 638 | 671 | } |
| 639 | 672 | } |
@@ -678,11 +711,9 @@ discard block |
||
| 678 | 711 | try |
| 679 | 712 | { |
| 680 | 713 | $listlinestaskres->setVars($key, $val, true, 'UTF-8'); |
| 681 | - } |
|
| 682 | - catch(OdfException $e) |
|
| 714 | + } catch(OdfException $e) |
|
| 683 | 715 | { |
| 684 | - } |
|
| 685 | - catch(SegmentException $e) |
|
| 716 | + } catch(SegmentException $e) |
|
| 686 | 717 | { |
| 687 | 718 | } |
| 688 | 719 | } |
@@ -724,11 +755,9 @@ discard block |
||
| 724 | 755 | try |
| 725 | 756 | { |
| 726 | 757 | $listlinestasktime->setVars($key, $val, true, 'UTF-8'); |
| 727 | - } |
|
| 728 | - catch(OdfException $e) |
|
| 758 | + } catch(OdfException $e) |
|
| 729 | 759 | { |
| 730 | - } |
|
| 731 | - catch(SegmentException $e) |
|
| 760 | + } catch(SegmentException $e) |
|
| 732 | 761 | { |
| 733 | 762 | } |
| 734 | 763 | } |
@@ -755,11 +784,9 @@ discard block |
||
| 755 | 784 | try |
| 756 | 785 | { |
| 757 | 786 | $listtasksfiles->setVars($key, $val, true, 'UTF-8'); |
| 758 | - } |
|
| 759 | - catch(OdfException $e) |
|
| 787 | + } catch(OdfException $e) |
|
| 760 | 788 | { |
| 761 | - } |
|
| 762 | - catch(SegmentException $e) |
|
| 789 | + } catch(SegmentException $e) |
|
| 763 | 790 | { |
| 764 | 791 | } |
| 765 | 792 | } |
@@ -768,8 +795,7 @@ discard block |
||
| 768 | 795 | $listlines->merge(); |
| 769 | 796 | } |
| 770 | 797 | $odfHandler->mergeSegment($listlines); |
| 771 | - } |
|
| 772 | - catch(OdfException $e) |
|
| 798 | + } catch(OdfException $e) |
|
| 773 | 799 | { |
| 774 | 800 | $ExceptionTrace=$e->getTrace(); |
| 775 | 801 | // no segment defined on ODT is not an error |
@@ -799,19 +825,16 @@ discard block |
||
| 799 | 825 | try |
| 800 | 826 | { |
| 801 | 827 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 802 | - } |
|
| 803 | - catch(OdfException $e) |
|
| 828 | + } catch(OdfException $e) |
|
| 804 | 829 | { |
| 805 | - } |
|
| 806 | - catch(SegmentException $e) |
|
| 830 | + } catch(SegmentException $e) |
|
| 807 | 831 | { |
| 808 | 832 | } |
| 809 | 833 | } |
| 810 | 834 | $listlines->merge(); |
| 811 | 835 | } |
| 812 | 836 | $odfHandler->mergeSegment($listlines); |
| 813 | - } |
|
| 814 | - catch(OdfException $e) |
|
| 837 | + } catch(OdfException $e) |
|
| 815 | 838 | { |
| 816 | 839 | $this->error=$e->getMessage(); |
| 817 | 840 | dol_syslog($this->error, LOG_WARNING); |
@@ -856,19 +879,16 @@ discard block |
||
| 856 | 879 | try |
| 857 | 880 | { |
| 858 | 881 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 859 | - } |
|
| 860 | - catch(OdfException $e) |
|
| 882 | + } catch(OdfException $e) |
|
| 861 | 883 | { |
| 862 | - } |
|
| 863 | - catch(SegmentException $e) |
|
| 884 | + } catch(SegmentException $e) |
|
| 864 | 885 | { |
| 865 | 886 | } |
| 866 | 887 | } |
| 867 | 888 | $listlines->merge(); |
| 868 | 889 | } |
| 869 | 890 | $odfHandler->mergeSegment($listlines); |
| 870 | - } |
|
| 871 | - catch(OdfException $e) |
|
| 891 | + } catch(OdfException $e) |
|
| 872 | 892 | { |
| 873 | 893 | $this->error=$e->getMessage(); |
| 874 | 894 | dol_syslog($this->error, LOG_WARNING); |
@@ -968,8 +988,12 @@ discard block |
||
| 968 | 988 | |
| 969 | 989 | //Date object |
| 970 | 990 | $dateref=$element->date; |
| 971 | - if (empty($dateref)) $dateref=$element->datep; |
|
| 972 | - if (empty($dateref)) $dateref=$element->date_contrat; |
|
| 991 | + if (empty($dateref)) { |
|
| 992 | + $dateref=$element->datep; |
|
| 993 | + } |
|
| 994 | + if (empty($dateref)) { |
|
| 995 | + $dateref=$element->date_contrat; |
|
| 996 | + } |
|
| 973 | 997 | $ref_array['date']=$dateref; |
| 974 | 998 | |
| 975 | 999 | //Soc object |
@@ -984,11 +1008,11 @@ discard block |
||
| 984 | 1008 | if (!empty($element->total_ht)) { |
| 985 | 1009 | $ref_array['amountht']=$element->total_ht; |
| 986 | 1010 | $ref_array['amountttc']=$element->total_ttc; |
| 987 | - }else { |
|
| 1011 | + } else { |
|
| 988 | 1012 | $ref_array['amountht']=0; |
| 989 | 1013 | $ref_array['amountttc']=0; |
| 990 | 1014 | } |
| 991 | - }else { |
|
| 1015 | + } else { |
|
| 992 | 1016 | $ref_array['amountht']=''; |
| 993 | 1017 | $ref_array['amountttc']=''; |
| 994 | 1018 | } |
@@ -1002,11 +1026,9 @@ discard block |
||
| 1002 | 1026 | try |
| 1003 | 1027 | { |
| 1004 | 1028 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 1005 | - } |
|
| 1006 | - catch(OdfException $e) |
|
| 1029 | + } catch(OdfException $e) |
|
| 1007 | 1030 | { |
| 1008 | - } |
|
| 1009 | - catch(SegmentException $e) |
|
| 1031 | + } catch(SegmentException $e) |
|
| 1010 | 1032 | { |
| 1011 | 1033 | } |
| 1012 | 1034 | } |
@@ -1017,8 +1039,7 @@ discard block |
||
| 1017 | 1039 | } |
| 1018 | 1040 | $odfHandler->mergeSegment($listlines); |
| 1019 | 1041 | } |
| 1020 | - } |
|
| 1021 | - catch(OdfException $e) |
|
| 1042 | + } catch(OdfException $e) |
|
| 1022 | 1043 | { |
| 1023 | 1044 | $this->error=$e->getMessage(); |
| 1024 | 1045 | dol_syslog($this->error, LOG_WARNING); |
@@ -1031,8 +1052,7 @@ discard block |
||
| 1031 | 1052 | { |
| 1032 | 1053 | try { |
| 1033 | 1054 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 1034 | - } |
|
| 1035 | - catch(OdfException $e) |
|
| 1055 | + } catch(OdfException $e) |
|
| 1036 | 1056 | { |
| 1037 | 1057 | } |
| 1038 | 1058 | } |
@@ -1046,15 +1066,14 @@ discard block |
||
| 1046 | 1066 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 1047 | 1067 | try { |
| 1048 | 1068 | $odfHandler->exportAsAttachedPDF($file); |
| 1049 | - }catch (Exception $e){ |
|
| 1069 | + } catch (Exception $e){ |
|
| 1050 | 1070 | $this->error=$e->getMessage(); |
| 1051 | 1071 | return -1; |
| 1052 | 1072 | } |
| 1053 | - } |
|
| 1054 | - else { |
|
| 1073 | + } else { |
|
| 1055 | 1074 | try { |
| 1056 | 1075 | $odfHandler->saveToDisk($file); |
| 1057 | - }catch (Exception $e){ |
|
| 1076 | + } catch (Exception $e){ |
|
| 1058 | 1077 | $this->error=$e->getMessage(); |
| 1059 | 1078 | return -1; |
| 1060 | 1079 | } |
@@ -1062,16 +1081,16 @@ discard block |
||
| 1062 | 1081 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
| 1063 | 1082 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 1064 | 1083 | |
| 1065 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 1066 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1084 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 1085 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1086 | + } |
|
| 1067 | 1087 | |
| 1068 | 1088 | $odfHandler=null; // Destroy object |
| 1069 | 1089 | |
| 1070 | 1090 | $this->result = array('fullpath'=>$file); |
| 1071 | 1091 | |
| 1072 | 1092 | return 1; // Success |
| 1073 | - } |
|
| 1074 | - else |
|
| 1093 | + } else |
|
| 1075 | 1094 | { |
| 1076 | 1095 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 1077 | 1096 | return -1; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $texte.= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">'; |
| 153 | 153 | $texte.= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">'; |
| 154 | 154 | $texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">'; |
| 155 | - $texte.= '</div>'; |
|
| 155 | + $texte.= '</div>'; |
|
| 156 | 156 | |
| 157 | 157 | $texte.= '</td>'; |
| 158 | 158 | |
@@ -249,8 +249,8 @@ discard block |
||
| 249 | 249 | $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
| 250 | 250 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 251 | 251 | { |
| 252 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
| 253 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 252 | + $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
| 253 | + if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 254 | 254 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 255 | 255 | } |
| 256 | 256 | else |
@@ -281,10 +281,10 @@ discard block |
||
| 281 | 281 | // On peut utiliser le nom de la societe du contact |
| 282 | 282 | if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
| 283 | 283 | else { |
| 284 | - $socobject = $object->thirdparty; |
|
| 285 | - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
|
| 286 | - $contactobject = $object->contact; |
|
| 287 | - } |
|
| 284 | + $socobject = $object->thirdparty; |
|
| 285 | + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
|
| 286 | + $contactobject = $object->contact; |
|
| 287 | + } |
|
| 288 | 288 | } |
| 289 | 289 | else |
| 290 | 290 | { |
@@ -83,7 +83,10 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | // Recupere emetteur |
| 85 | 85 | $this->emetteur=$mysoc; |
| 86 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 86 | + if (! $this->emetteur->country_code) { |
|
| 87 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 88 | + } |
|
| 89 | + // By default if not defined |
|
| 87 | 90 | } |
| 88 | 91 | |
| 89 | 92 | |
@@ -121,11 +124,14 @@ discard block |
||
| 121 | 124 | if (! $tmpdir) { |
| 122 | 125 | unset($listofdir[$key]); continue; |
| 123 | 126 | } |
| 124 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 125 | - else |
|
| 127 | + if (! is_dir($tmpdir)) { |
|
| 128 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 129 | + } else |
|
| 126 | 130 | { |
| 127 | 131 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 128 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 132 | + if (count($tmpfiles)) { |
|
| 133 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 134 | + } |
|
| 129 | 135 | } |
| 130 | 136 | } |
| 131 | 137 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -197,7 +203,9 @@ discard block |
||
| 197 | 203 | $hookmanager->initHooks(array('odtgeneration')); |
| 198 | 204 | global $action; |
| 199 | 205 | |
| 200 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 206 | + if (! is_object($outputlangs)) { |
|
| 207 | + $outputlangs=$langs; |
|
| 208 | + } |
|
| 201 | 209 | $sav_charset_output=$outputlangs->charset_output; |
| 202 | 210 | $outputlangs->charset_output='UTF-8'; |
| 203 | 211 | |
@@ -223,7 +231,9 @@ discard block |
||
| 223 | 231 | |
| 224 | 232 | $dir = $conf->contrat->dir_output; |
| 225 | 233 | $objectref = dol_sanitizeFileName($object->ref); |
| 226 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 234 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 235 | + $dir.= "/" . $objectref; |
|
| 236 | + } |
|
| 227 | 237 | $file = $dir . "/" . $objectref . ".odt"; |
| 228 | 238 | |
| 229 | 239 | if (! file_exists($dir)) |
@@ -250,10 +260,11 @@ discard block |
||
| 250 | 260 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 251 | 261 | { |
| 252 | 262 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 253 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 263 | + if ($format == '1') { |
|
| 264 | + $format='%Y%m%d%H%M%S'; |
|
| 265 | + } |
|
| 254 | 266 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 255 | - } |
|
| 256 | - else |
|
| 267 | + } else |
|
| 257 | 268 | { |
| 258 | 269 | $filename=$newfiletmp.'.'.$newfileformat; |
| 259 | 270 | } |
@@ -279,14 +290,14 @@ discard block |
||
| 279 | 290 | if (! empty($usecontact)) |
| 280 | 291 | { |
| 281 | 292 | // On peut utiliser le nom de la societe du contact |
| 282 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 283 | - else { |
|
| 293 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 294 | + $socobject = $object->contact; |
|
| 295 | + } else { |
|
| 284 | 296 | $socobject = $object->thirdparty; |
| 285 | 297 | // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
| 286 | 298 | $contactobject = $object->contact; |
| 287 | 299 | } |
| 288 | - } |
|
| 289 | - else |
|
| 300 | + } else |
|
| 290 | 301 | { |
| 291 | 302 | $socobject=$object->thirdparty; |
| 292 | 303 | } |
@@ -304,7 +315,9 @@ discard block |
||
| 304 | 315 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 305 | 316 | // retrieve contact information for use in contract as contact_xxx tags |
| 306 | 317 | $array_thirdparty_contact = array(); |
| 307 | - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 318 | + if ($usecontact) { |
|
| 319 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 320 | + } |
|
| 308 | 321 | |
| 309 | 322 | $substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
| 310 | 323 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
@@ -336,8 +349,7 @@ discard block |
||
| 336 | 349 | 'DELIMITER_RIGHT' => '}' |
| 337 | 350 | ) |
| 338 | 351 | ); |
| 339 | - } |
|
| 340 | - catch(Exception $e) |
|
| 352 | + } catch(Exception $e) |
|
| 341 | 353 | { |
| 342 | 354 | $this->error=$e->getMessage(); |
| 343 | 355 | return -1; |
@@ -352,25 +364,25 @@ discard block |
||
| 352 | 364 | // Make substitutions into odt of freetext |
| 353 | 365 | try { |
| 354 | 366 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 355 | - } |
|
| 356 | - catch(OdfException $e) |
|
| 367 | + } catch(OdfException $e) |
|
| 357 | 368 | { |
| 358 | 369 | } |
| 359 | 370 | |
| 360 | 371 | foreach($tmparray as $key=>$value) |
| 361 | 372 | { |
| 362 | 373 | try { |
| 363 | - if (preg_match('/logo$/',$key)) // Image |
|
| 374 | + if (preg_match('/logo$/',$key)) { |
|
| 375 | + // Image |
|
| 364 | 376 | { |
| 365 | 377 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 366 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 367 | - } |
|
| 368 | - else // Text |
|
| 378 | + } else { |
|
| 379 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 380 | + } |
|
| 381 | + } else // Text |
|
| 369 | 382 | { |
| 370 | 383 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 371 | 384 | } |
| 372 | - } |
|
| 373 | - catch(OdfException $e) |
|
| 385 | + } catch(OdfException $e) |
|
| 374 | 386 | { |
| 375 | 387 | } |
| 376 | 388 | } |
@@ -381,8 +393,7 @@ discard block |
||
| 381 | 393 | $foundtagforlines = 1; |
| 382 | 394 | try { |
| 383 | 395 | $listlines = $odfHandler->setSegment('lines'); |
| 384 | - } |
|
| 385 | - catch(OdfException $e) |
|
| 396 | + } catch(OdfException $e) |
|
| 386 | 397 | { |
| 387 | 398 | // We may arrive here if tags for lines not present into template |
| 388 | 399 | $foundtagforlines = 0; |
@@ -402,11 +413,9 @@ discard block |
||
| 402 | 413 | try |
| 403 | 414 | { |
| 404 | 415 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 405 | - } |
|
| 406 | - catch(OdfException $e) |
|
| 416 | + } catch(OdfException $e) |
|
| 407 | 417 | { |
| 408 | - } |
|
| 409 | - catch(SegmentException $e) |
|
| 418 | + } catch(SegmentException $e) |
|
| 410 | 419 | { |
| 411 | 420 | } |
| 412 | 421 | } |
@@ -414,8 +423,7 @@ discard block |
||
| 414 | 423 | } |
| 415 | 424 | $odfHandler->mergeSegment($listlines); |
| 416 | 425 | } |
| 417 | - } |
|
| 418 | - catch(OdfException $e) |
|
| 426 | + } catch(OdfException $e) |
|
| 419 | 427 | { |
| 420 | 428 | $this->error=$e->getMessage(); |
| 421 | 429 | dol_syslog($this->error, LOG_WARNING); |
@@ -428,8 +436,7 @@ discard block |
||
| 428 | 436 | { |
| 429 | 437 | try { |
| 430 | 438 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 431 | - } |
|
| 432 | - catch(OdfException $e) |
|
| 439 | + } catch(OdfException $e) |
|
| 433 | 440 | { |
| 434 | 441 | } |
| 435 | 442 | } |
@@ -442,15 +449,14 @@ discard block |
||
| 442 | 449 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 443 | 450 | try { |
| 444 | 451 | $odfHandler->exportAsAttachedPDF($file); |
| 445 | - }catch (Exception $e){ |
|
| 452 | + } catch (Exception $e){ |
|
| 446 | 453 | $this->error=$e->getMessage(); |
| 447 | 454 | return -1; |
| 448 | 455 | } |
| 449 | - } |
|
| 450 | - else { |
|
| 456 | + } else { |
|
| 451 | 457 | try { |
| 452 | 458 | $odfHandler->saveToDisk($file); |
| 453 | - }catch (Exception $e){ |
|
| 459 | + } catch (Exception $e){ |
|
| 454 | 460 | $this->error=$e->getMessage(); |
| 455 | 461 | return -1; |
| 456 | 462 | } |
@@ -458,16 +464,16 @@ discard block |
||
| 458 | 464 | |
| 459 | 465 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 460 | 466 | |
| 461 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 462 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 467 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 468 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 469 | + } |
|
| 463 | 470 | |
| 464 | 471 | $odfHandler=null; // Destroy object |
| 465 | 472 | |
| 466 | 473 | $this->result = array('fullpath'=>$file); |
| 467 | 474 | |
| 468 | 475 | return 1; // Success |
| 469 | - } |
|
| 470 | - else |
|
| 476 | + } else |
|
| 471 | 477 | { |
| 472 | 478 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 473 | 479 | return -1; |
@@ -83,7 +83,10 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | // Recupere emetteur |
| 85 | 85 | $this->emetteur=$mysoc; |
| 86 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 86 | + if (! $this->emetteur->country_code) { |
|
| 87 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 88 | + } |
|
| 89 | + // By default if not defined |
|
| 87 | 90 | } |
| 88 | 91 | |
| 89 | 92 | |
@@ -127,11 +130,14 @@ discard block |
||
| 127 | 130 | if (! $tmpdir) { |
| 128 | 131 | unset($listofdir[$key]); continue; |
| 129 | 132 | } |
| 130 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 131 | - else |
|
| 133 | + if (! is_dir($tmpdir)) { |
|
| 134 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 135 | + } else |
|
| 132 | 136 | { |
| 133 | 137 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 134 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 138 | + if (count($tmpfiles)) { |
|
| 139 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 140 | + } |
|
| 135 | 141 | } |
| 136 | 142 | } |
| 137 | 143 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -237,7 +243,9 @@ discard block |
||
| 237 | 243 | $hookmanager->initHooks(array('odtgeneration')); |
| 238 | 244 | global $action; |
| 239 | 245 | |
| 240 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 246 | + if (! is_object($outputlangs)) { |
|
| 247 | + $outputlangs=$langs; |
|
| 248 | + } |
|
| 241 | 249 | $sav_charset_output=$outputlangs->charset_output; |
| 242 | 250 | $outputlangs->charset_output='UTF-8'; |
| 243 | 251 | |
@@ -263,7 +271,9 @@ discard block |
||
| 263 | 271 | |
| 264 | 272 | $dir = $conf->supplier_proposal->dir_output; |
| 265 | 273 | $objectref = dol_sanitizeFileName($object->ref); |
| 266 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 274 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 275 | + $dir.= "/" . $objectref; |
|
| 276 | + } |
|
| 267 | 277 | $file = $dir . "/" . $objectref . ".odt"; |
| 268 | 278 | |
| 269 | 279 | if (! file_exists($dir)) |
@@ -290,10 +300,11 @@ discard block |
||
| 290 | 300 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 291 | 301 | { |
| 292 | 302 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 293 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 303 | + if ($format == '1') { |
|
| 304 | + $format='%Y%m%d%H%M%S'; |
|
| 305 | + } |
|
| 294 | 306 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 295 | - } |
|
| 296 | - else |
|
| 307 | + } else |
|
| 297 | 308 | { |
| 298 | 309 | $filename=$newfiletmp.'.'.$newfileformat; |
| 299 | 310 | } |
@@ -319,10 +330,12 @@ discard block |
||
| 319 | 330 | if (! empty($usecontact)) |
| 320 | 331 | { |
| 321 | 332 | // On peut utiliser le nom de la societe du contact |
| 322 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 323 | - else $socobject = $object->thirdparty; |
|
| 324 | - } |
|
| 325 | - else |
|
| 333 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 334 | + $socobject = $object->contact; |
|
| 335 | + } else { |
|
| 336 | + $socobject = $object->thirdparty; |
|
| 337 | + } |
|
| 338 | + } else |
|
| 326 | 339 | { |
| 327 | 340 | $socobject=$object->thirdparty; |
| 328 | 341 | } |
@@ -360,8 +373,7 @@ discard block |
||
| 360 | 373 | 'DELIMITER_RIGHT' => '}' |
| 361 | 374 | ) |
| 362 | 375 | ); |
| 363 | - } |
|
| 364 | - catch(Exception $e) |
|
| 376 | + } catch(Exception $e) |
|
| 365 | 377 | { |
| 366 | 378 | $this->error=$e->getMessage(); |
| 367 | 379 | return -1; |
@@ -376,8 +388,7 @@ discard block |
||
| 376 | 388 | // Make substitutions into odt of freetext |
| 377 | 389 | try { |
| 378 | 390 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 379 | - } |
|
| 380 | - catch(OdfException $e) |
|
| 391 | + } catch(OdfException $e) |
|
| 381 | 392 | { |
| 382 | 393 | } |
| 383 | 394 | |
@@ -399,17 +410,18 @@ discard block |
||
| 399 | 410 | foreach($tmparray as $key=>$value) |
| 400 | 411 | { |
| 401 | 412 | try { |
| 402 | - if (preg_match('/logo$/',$key)) // Image |
|
| 413 | + if (preg_match('/logo$/',$key)) { |
|
| 414 | + // Image |
|
| 403 | 415 | { |
| 404 | 416 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 405 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 406 | - } |
|
| 407 | - else // Text |
|
| 417 | + } else { |
|
| 418 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 419 | + } |
|
| 420 | + } else // Text |
|
| 408 | 421 | { |
| 409 | 422 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 410 | 423 | } |
| 411 | - } |
|
| 412 | - catch(OdfException $e) |
|
| 424 | + } catch(OdfException $e) |
|
| 413 | 425 | { |
| 414 | 426 | } |
| 415 | 427 | } |
@@ -419,8 +431,7 @@ discard block |
||
| 419 | 431 | $foundtagforlines = 1; |
| 420 | 432 | try { |
| 421 | 433 | $listlines = $odfHandler->setSegment('lines'); |
| 422 | - } |
|
| 423 | - catch(OdfException $e) |
|
| 434 | + } catch(OdfException $e) |
|
| 424 | 435 | { |
| 425 | 436 | // We may arrive here if tags for lines not present into template |
| 426 | 437 | $foundtagforlines = 0; |
@@ -440,11 +451,9 @@ discard block |
||
| 440 | 451 | try |
| 441 | 452 | { |
| 442 | 453 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 443 | - } |
|
| 444 | - catch(OdfException $e) |
|
| 454 | + } catch(OdfException $e) |
|
| 445 | 455 | { |
| 446 | - } |
|
| 447 | - catch(SegmentException $e) |
|
| 456 | + } catch(SegmentException $e) |
|
| 448 | 457 | { |
| 449 | 458 | } |
| 450 | 459 | } |
@@ -452,8 +461,7 @@ discard block |
||
| 452 | 461 | } |
| 453 | 462 | $odfHandler->mergeSegment($listlines); |
| 454 | 463 | } |
| 455 | - } |
|
| 456 | - catch(OdfException $e) |
|
| 464 | + } catch(OdfException $e) |
|
| 457 | 465 | { |
| 458 | 466 | $this->error=$e->getMessage(); |
| 459 | 467 | dol_syslog($this->error, LOG_WARNING); |
@@ -466,8 +474,7 @@ discard block |
||
| 466 | 474 | { |
| 467 | 475 | try { |
| 468 | 476 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 469 | - } |
|
| 470 | - catch(OdfException $e) |
|
| 477 | + } catch(OdfException $e) |
|
| 471 | 478 | { |
| 472 | 479 | } |
| 473 | 480 | } |
@@ -480,15 +487,14 @@ discard block |
||
| 480 | 487 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 481 | 488 | try { |
| 482 | 489 | $odfHandler->exportAsAttachedPDF($file); |
| 483 | - }catch (Exception $e){ |
|
| 490 | + } catch (Exception $e){ |
|
| 484 | 491 | $this->error=$e->getMessage(); |
| 485 | 492 | return -1; |
| 486 | 493 | } |
| 487 | - } |
|
| 488 | - else { |
|
| 494 | + } else { |
|
| 489 | 495 | try { |
| 490 | 496 | $odfHandler->saveToDisk($file); |
| 491 | - }catch (Exception $e){ |
|
| 497 | + } catch (Exception $e){ |
|
| 492 | 498 | $this->error=$e->getMessage(); |
| 493 | 499 | return -1; |
| 494 | 500 | } |
@@ -496,16 +502,16 @@ discard block |
||
| 496 | 502 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
| 497 | 503 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 498 | 504 | |
| 499 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 500 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 505 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 506 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 507 | + } |
|
| 501 | 508 | |
| 502 | 509 | $odfHandler=null; // Destroy object |
| 503 | 510 | |
| 504 | 511 | $this->result = array('fullpath'=>$file); |
| 505 | 512 | |
| 506 | 513 | return 1; // Success |
| 507 | - } |
|
| 508 | - else |
|
| 514 | + } else |
|
| 509 | 515 | { |
| 510 | 516 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 511 | 517 | return -1; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
| 160 | 160 | foreach($listoffiles as $file) |
| 161 | 161 | { |
| 162 | - $texte.=$file['name'].'<br>'; |
|
| 162 | + $texte.=$file['name'].'<br>'; |
|
| 163 | 163 | } |
| 164 | 164 | $texte.='<div id="div_'.get_class($this).'">'; |
| 165 | 165 | } |
@@ -258,8 +258,8 @@ discard block |
||
| 258 | 258 | $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
| 259 | 259 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 260 | 260 | { |
| 261 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
| 262 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 261 | + $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
| 262 | + if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 263 | 263 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 264 | 264 | } |
| 265 | 265 | else |
@@ -290,10 +290,10 @@ discard block |
||
| 290 | 290 | // On peut utiliser le nom de la societe du contact |
| 291 | 291 | if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
| 292 | 292 | else { |
| 293 | - $socobject = $object->thirdparty; |
|
| 294 | - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
|
| 295 | - $contactobject = $object->contact; |
|
| 296 | - } |
|
| 293 | + $socobject = $object->thirdparty; |
|
| 294 | + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
|
| 295 | + $contactobject = $object->contact; |
|
| 296 | + } |
|
| 297 | 297 | } |
| 298 | 298 | else |
| 299 | 299 | { |
@@ -84,7 +84,10 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | // Recupere emetteur |
| 86 | 86 | $this->emetteur=$mysoc; |
| 87 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 87 | + if (! $this->emetteur->country_code) { |
|
| 88 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 89 | + } |
|
| 90 | + // By default if not defined |
|
| 88 | 91 | } |
| 89 | 92 | |
| 90 | 93 | |
@@ -122,11 +125,14 @@ discard block |
||
| 122 | 125 | if (! $tmpdir) { |
| 123 | 126 | unset($listofdir[$key]); continue; |
| 124 | 127 | } |
| 125 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 126 | - else |
|
| 128 | + if (! is_dir($tmpdir)) { |
|
| 129 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 130 | + } else |
|
| 127 | 131 | { |
| 128 | 132 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 129 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 133 | + if (count($tmpfiles)) { |
|
| 134 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 135 | + } |
|
| 130 | 136 | } |
| 131 | 137 | } |
| 132 | 138 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -207,7 +213,9 @@ discard block |
||
| 207 | 213 | $hookmanager->initHooks(array('odtgeneration')); |
| 208 | 214 | global $action; |
| 209 | 215 | |
| 210 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 216 | + if (! is_object($outputlangs)) { |
|
| 217 | + $outputlangs=$langs; |
|
| 218 | + } |
|
| 211 | 219 | $sav_charset_output=$outputlangs->charset_output; |
| 212 | 220 | $outputlangs->charset_output='UTF-8'; |
| 213 | 221 | |
@@ -233,7 +241,9 @@ discard block |
||
| 233 | 241 | |
| 234 | 242 | $dir = $conf->commande->dir_output; |
| 235 | 243 | $objectref = dol_sanitizeFileName($object->ref); |
| 236 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 244 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 245 | + $dir.= "/" . $objectref; |
|
| 246 | + } |
|
| 237 | 247 | $file = $dir . "/" . $objectref . ".odt"; |
| 238 | 248 | |
| 239 | 249 | if (! file_exists($dir)) |
@@ -259,10 +269,11 @@ discard block |
||
| 259 | 269 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 260 | 270 | { |
| 261 | 271 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 262 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 272 | + if ($format == '1') { |
|
| 273 | + $format='%Y%m%d%H%M%S'; |
|
| 274 | + } |
|
| 263 | 275 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 264 | - } |
|
| 265 | - else |
|
| 276 | + } else |
|
| 266 | 277 | { |
| 267 | 278 | $filename=$newfiletmp.'.'.$newfileformat; |
| 268 | 279 | } |
@@ -288,14 +299,14 @@ discard block |
||
| 288 | 299 | if (! empty($usecontact)) |
| 289 | 300 | { |
| 290 | 301 | // On peut utiliser le nom de la societe du contact |
| 291 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 292 | - else { |
|
| 302 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 303 | + $socobject = $object->contact; |
|
| 304 | + } else { |
|
| 293 | 305 | $socobject = $object->thirdparty; |
| 294 | 306 | // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
| 295 | 307 | $contactobject = $object->contact; |
| 296 | 308 | } |
| 297 | - } |
|
| 298 | - else |
|
| 309 | + } else |
|
| 299 | 310 | { |
| 300 | 311 | $socobject=$object->thirdparty; |
| 301 | 312 | } |
@@ -333,8 +344,7 @@ discard block |
||
| 333 | 344 | 'DELIMITER_RIGHT' => '}' |
| 334 | 345 | ) |
| 335 | 346 | ); |
| 336 | - } |
|
| 337 | - catch(Exception $e) |
|
| 347 | + } catch(Exception $e) |
|
| 338 | 348 | { |
| 339 | 349 | $this->error=$e->getMessage(); |
| 340 | 350 | return -1; |
@@ -349,8 +359,7 @@ discard block |
||
| 349 | 359 | // Make substitutions into odt of freetext |
| 350 | 360 | try { |
| 351 | 361 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 352 | - } |
|
| 353 | - catch(OdfException $e) |
|
| 362 | + } catch(OdfException $e) |
|
| 354 | 363 | { |
| 355 | 364 | } |
| 356 | 365 | |
@@ -364,7 +373,9 @@ discard block |
||
| 364 | 373 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 365 | 374 | // retrieve contact information for use in order as contact_xxx tags |
| 366 | 375 | $array_thirdparty_contact = array(); |
| 367 | - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 376 | + if ($usecontact) { |
|
| 377 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 378 | + } |
|
| 368 | 379 | |
| 369 | 380 | $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
| 370 | 381 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -376,17 +387,18 @@ discard block |
||
| 376 | 387 | foreach($tmparray as $key=>$value) |
| 377 | 388 | { |
| 378 | 389 | try { |
| 379 | - if (preg_match('/logo$/',$key)) // Image |
|
| 390 | + if (preg_match('/logo$/',$key)) { |
|
| 391 | + // Image |
|
| 380 | 392 | { |
| 381 | 393 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 382 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 383 | - } |
|
| 384 | - else // Text |
|
| 394 | + } else { |
|
| 395 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 396 | + } |
|
| 397 | + } else // Text |
|
| 385 | 398 | { |
| 386 | 399 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 387 | 400 | } |
| 388 | - } |
|
| 389 | - catch(OdfException $e) |
|
| 401 | + } catch(OdfException $e) |
|
| 390 | 402 | { |
| 391 | 403 | } |
| 392 | 404 | } |
@@ -396,8 +408,7 @@ discard block |
||
| 396 | 408 | $foundtagforlines = 1; |
| 397 | 409 | try { |
| 398 | 410 | $listlines = $odfHandler->setSegment('lines'); |
| 399 | - } |
|
| 400 | - catch(OdfException $e) |
|
| 411 | + } catch(OdfException $e) |
|
| 401 | 412 | { |
| 402 | 413 | // We may arrive here if tags for lines not present into template |
| 403 | 414 | $foundtagforlines = 0; |
@@ -417,11 +428,9 @@ discard block |
||
| 417 | 428 | try |
| 418 | 429 | { |
| 419 | 430 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 420 | - } |
|
| 421 | - catch(OdfException $e) |
|
| 431 | + } catch(OdfException $e) |
|
| 422 | 432 | { |
| 423 | - } |
|
| 424 | - catch(SegmentException $e) |
|
| 433 | + } catch(SegmentException $e) |
|
| 425 | 434 | { |
| 426 | 435 | } |
| 427 | 436 | } |
@@ -429,8 +438,7 @@ discard block |
||
| 429 | 438 | } |
| 430 | 439 | $odfHandler->mergeSegment($listlines); |
| 431 | 440 | } |
| 432 | - } |
|
| 433 | - catch(OdfException $e) |
|
| 441 | + } catch(OdfException $e) |
|
| 434 | 442 | { |
| 435 | 443 | $this->error=$e->getMessage(); |
| 436 | 444 | dol_syslog($this->error, LOG_WARNING); |
@@ -443,8 +451,7 @@ discard block |
||
| 443 | 451 | { |
| 444 | 452 | try { |
| 445 | 453 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 446 | - } |
|
| 447 | - catch(OdfException $e) |
|
| 454 | + } catch(OdfException $e) |
|
| 448 | 455 | { |
| 449 | 456 | } |
| 450 | 457 | } |
@@ -458,15 +465,14 @@ discard block |
||
| 458 | 465 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 459 | 466 | try { |
| 460 | 467 | $odfHandler->exportAsAttachedPDF($file); |
| 461 | - }catch (Exception $e){ |
|
| 468 | + } catch (Exception $e){ |
|
| 462 | 469 | $this->error=$e->getMessage(); |
| 463 | 470 | return -1; |
| 464 | 471 | } |
| 465 | - } |
|
| 466 | - else { |
|
| 472 | + } else { |
|
| 467 | 473 | try { |
| 468 | 474 | $odfHandler->saveToDisk($file); |
| 469 | - }catch (Exception $e){ |
|
| 475 | + } catch (Exception $e){ |
|
| 470 | 476 | $this->error=$e->getMessage(); |
| 471 | 477 | return -1; |
| 472 | 478 | } |
@@ -475,16 +481,16 @@ discard block |
||
| 475 | 481 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
| 476 | 482 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 477 | 483 | |
| 478 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 479 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 484 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 485 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 486 | + } |
|
| 480 | 487 | |
| 481 | 488 | $odfHandler=null; // Destroy object |
| 482 | 489 | |
| 483 | 490 | $this->result = array('fullpath'=>$file); |
| 484 | 491 | |
| 485 | 492 | return 1; // Success |
| 486 | - } |
|
| 487 | - else |
|
| 493 | + } else |
|
| 488 | 494 | { |
| 489 | 495 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 490 | 496 | return -1; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
| 165 | 165 | foreach($listoffiles as $file) |
| 166 | 166 | { |
| 167 | - $texte.=$file['name'].'<br>'; |
|
| 167 | + $texte.=$file['name'].'<br>'; |
|
| 168 | 168 | } |
| 169 | 169 | $texte.='<div id="div_'.get_class($this).'">'; |
| 170 | 170 | |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
| 290 | 290 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 291 | 291 | { |
| 292 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
| 293 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 292 | + $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
| 293 | + if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 294 | 294 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 295 | 295 | } |
| 296 | 296 | else |
@@ -321,10 +321,10 @@ discard block |
||
| 321 | 321 | // On peut utiliser le nom de la societe du contact |
| 322 | 322 | if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
| 323 | 323 | else { |
| 324 | - $socobject = $object->thirdparty; |
|
| 325 | - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
|
| 326 | - $contactobject = $object->contact; |
|
| 327 | - } |
|
| 324 | + $socobject = $object->thirdparty; |
|
| 325 | + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
|
| 326 | + $contactobject = $object->contact; |
|
| 327 | + } |
|
| 328 | 328 | } |
| 329 | 329 | else |
| 330 | 330 | { |
@@ -83,7 +83,10 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | // Recupere emetteur |
| 85 | 85 | $this->emetteur=$mysoc; |
| 86 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 86 | + if (! $this->emetteur->country_code) { |
|
| 87 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 88 | + } |
|
| 89 | + // By default if not defined |
|
| 87 | 90 | } |
| 88 | 91 | |
| 89 | 92 | |
@@ -127,11 +130,14 @@ discard block |
||
| 127 | 130 | if (! $tmpdir) { |
| 128 | 131 | unset($listofdir[$key]); continue; |
| 129 | 132 | } |
| 130 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 131 | - else |
|
| 133 | + if (! is_dir($tmpdir)) { |
|
| 134 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 135 | + } else |
|
| 132 | 136 | { |
| 133 | 137 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 134 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 138 | + if (count($tmpfiles)) { |
|
| 139 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 140 | + } |
|
| 135 | 141 | } |
| 136 | 142 | } |
| 137 | 143 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -237,7 +243,9 @@ discard block |
||
| 237 | 243 | $hookmanager->initHooks(array('odtgeneration')); |
| 238 | 244 | global $action; |
| 239 | 245 | |
| 240 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 246 | + if (! is_object($outputlangs)) { |
|
| 247 | + $outputlangs=$langs; |
|
| 248 | + } |
|
| 241 | 249 | $sav_charset_output=$outputlangs->charset_output; |
| 242 | 250 | $outputlangs->charset_output='UTF-8'; |
| 243 | 251 | |
@@ -263,7 +271,9 @@ discard block |
||
| 263 | 271 | |
| 264 | 272 | $dir = $conf->propal->dir_output; |
| 265 | 273 | $objectref = dol_sanitizeFileName($object->ref); |
| 266 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 274 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 275 | + $dir.= "/" . $objectref; |
|
| 276 | + } |
|
| 267 | 277 | $file = $dir . "/" . $objectref . ".odt"; |
| 268 | 278 | |
| 269 | 279 | if (! file_exists($dir)) |
@@ -290,10 +300,11 @@ discard block |
||
| 290 | 300 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 291 | 301 | { |
| 292 | 302 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 293 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 303 | + if ($format == '1') { |
|
| 304 | + $format='%Y%m%d%H%M%S'; |
|
| 305 | + } |
|
| 294 | 306 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 295 | - } |
|
| 296 | - else |
|
| 307 | + } else |
|
| 297 | 308 | { |
| 298 | 309 | $filename=$newfiletmp.'.'.$newfileformat; |
| 299 | 310 | } |
@@ -319,14 +330,14 @@ discard block |
||
| 319 | 330 | if (! empty($usecontact)) |
| 320 | 331 | { |
| 321 | 332 | // On peut utiliser le nom de la societe du contact |
| 322 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 323 | - else { |
|
| 333 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 334 | + $socobject = $object->contact; |
|
| 335 | + } else { |
|
| 324 | 336 | $socobject = $object->thirdparty; |
| 325 | 337 | // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
| 326 | 338 | $contactobject = $object->contact; |
| 327 | 339 | } |
| 328 | - } |
|
| 329 | - else |
|
| 340 | + } else |
|
| 330 | 341 | { |
| 331 | 342 | $socobject=$object->thirdparty; |
| 332 | 343 | } |
@@ -363,8 +374,7 @@ discard block |
||
| 363 | 374 | 'DELIMITER_RIGHT' => '}' |
| 364 | 375 | ) |
| 365 | 376 | ); |
| 366 | - } |
|
| 367 | - catch(Exception $e) |
|
| 377 | + } catch(Exception $e) |
|
| 368 | 378 | { |
| 369 | 379 | $this->error=$e->getMessage(); |
| 370 | 380 | return -1; |
@@ -380,8 +390,7 @@ discard block |
||
| 380 | 390 | // Make substitutions into odt of freetext |
| 381 | 391 | try { |
| 382 | 392 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 383 | - } |
|
| 384 | - catch(OdfException $e) |
|
| 393 | + } catch(OdfException $e) |
|
| 385 | 394 | { |
| 386 | 395 | } |
| 387 | 396 | |
@@ -395,7 +404,9 @@ discard block |
||
| 395 | 404 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 396 | 405 | // retrieve contact information for use in proposal as contact_xxx tags |
| 397 | 406 | $array_thirdparty_contact = array(); |
| 398 | - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 407 | + if ($usecontact) { |
|
| 408 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 409 | + } |
|
| 399 | 410 | |
| 400 | 411 | $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
| 401 | 412 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -407,17 +418,18 @@ discard block |
||
| 407 | 418 | foreach($tmparray as $key=>$value) |
| 408 | 419 | { |
| 409 | 420 | try { |
| 410 | - if (preg_match('/logo$/',$key)) // Image |
|
| 421 | + if (preg_match('/logo$/',$key)) { |
|
| 422 | + // Image |
|
| 411 | 423 | { |
| 412 | 424 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 413 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 414 | - } |
|
| 415 | - else // Text |
|
| 425 | + } else { |
|
| 426 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 427 | + } |
|
| 428 | + } else // Text |
|
| 416 | 429 | { |
| 417 | 430 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 418 | 431 | } |
| 419 | - } |
|
| 420 | - catch(OdfException $e) |
|
| 432 | + } catch(OdfException $e) |
|
| 421 | 433 | { |
| 422 | 434 | } |
| 423 | 435 | } |
@@ -427,8 +439,7 @@ discard block |
||
| 427 | 439 | $foundtagforlines = 1; |
| 428 | 440 | try { |
| 429 | 441 | $listlines = $odfHandler->setSegment('lines'); |
| 430 | - } |
|
| 431 | - catch(OdfException $e) |
|
| 442 | + } catch(OdfException $e) |
|
| 432 | 443 | { |
| 433 | 444 | // We may arrive here if tags for lines not present into template |
| 434 | 445 | $foundtagforlines = 0; |
@@ -448,11 +459,9 @@ discard block |
||
| 448 | 459 | try |
| 449 | 460 | { |
| 450 | 461 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 451 | - } |
|
| 452 | - catch(OdfException $e) |
|
| 462 | + } catch(OdfException $e) |
|
| 453 | 463 | { |
| 454 | - } |
|
| 455 | - catch(SegmentException $e) |
|
| 464 | + } catch(SegmentException $e) |
|
| 456 | 465 | { |
| 457 | 466 | } |
| 458 | 467 | } |
@@ -460,8 +469,7 @@ discard block |
||
| 460 | 469 | } |
| 461 | 470 | $odfHandler->mergeSegment($listlines); |
| 462 | 471 | } |
| 463 | - } |
|
| 464 | - catch(OdfException $e) |
|
| 472 | + } catch(OdfException $e) |
|
| 465 | 473 | { |
| 466 | 474 | $this->error=$e->getMessage(); |
| 467 | 475 | dol_syslog($this->error, LOG_WARNING); |
@@ -474,8 +482,7 @@ discard block |
||
| 474 | 482 | { |
| 475 | 483 | try { |
| 476 | 484 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 477 | - } |
|
| 478 | - catch(OdfException $e) |
|
| 485 | + } catch(OdfException $e) |
|
| 479 | 486 | { |
| 480 | 487 | } |
| 481 | 488 | } |
@@ -488,15 +495,14 @@ discard block |
||
| 488 | 495 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 489 | 496 | try { |
| 490 | 497 | $odfHandler->exportAsAttachedPDF($file); |
| 491 | - }catch (Exception $e){ |
|
| 498 | + } catch (Exception $e){ |
|
| 492 | 499 | $this->error=$e->getMessage(); |
| 493 | 500 | return -1; |
| 494 | 501 | } |
| 495 | - } |
|
| 496 | - else { |
|
| 502 | + } else { |
|
| 497 | 503 | try { |
| 498 | 504 | $odfHandler->saveToDisk($file); |
| 499 | - }catch (Exception $e){ |
|
| 505 | + } catch (Exception $e){ |
|
| 500 | 506 | $this->error=$e->getMessage(); |
| 501 | 507 | return -1; |
| 502 | 508 | } |
@@ -504,16 +510,16 @@ discard block |
||
| 504 | 510 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
| 505 | 511 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 506 | 512 | |
| 507 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 508 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 513 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 514 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 515 | + } |
|
| 509 | 516 | |
| 510 | 517 | $odfHandler=null; // Destroy object |
| 511 | 518 | |
| 512 | 519 | $this->result = array('fullpath'=>$file); |
| 513 | 520 | |
| 514 | 521 | return 1; // Success |
| 515 | - } |
|
| 516 | - else |
|
| 522 | + } else |
|
| 517 | 523 | { |
| 518 | 524 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 519 | 525 | return -1; |
@@ -275,8 +275,8 @@ discard block |
||
| 275 | 275 | $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
| 276 | 276 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 277 | 277 | { |
| 278 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
| 279 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 278 | + $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
| 279 | + if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 280 | 280 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 281 | 281 | } |
| 282 | 282 | else |
@@ -307,10 +307,10 @@ discard block |
||
| 307 | 307 | // On peut utiliser le nom de la societe du contact |
| 308 | 308 | if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
| 309 | 309 | else { |
| 310 | - $socobject = $object->thirdparty; |
|
| 311 | - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
|
| 312 | - $contactobject = $object->contact; |
|
| 313 | - } |
|
| 310 | + $socobject = $object->thirdparty; |
|
| 311 | + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
|
| 312 | + $contactobject = $object->contact; |
|
| 313 | + } |
|
| 314 | 314 | } |
| 315 | 315 | else |
| 316 | 316 | { |
@@ -82,7 +82,10 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | // Recupere emetteur |
| 84 | 84 | $this->emetteur=$mysoc; |
| 85 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 85 | + if (! $this->emetteur->country_code) { |
|
| 86 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 87 | + } |
|
| 88 | + // By default if not defined |
|
| 86 | 89 | } |
| 87 | 90 | |
| 88 | 91 | |
@@ -126,11 +129,14 @@ discard block |
||
| 126 | 129 | if (! $tmpdir) { |
| 127 | 130 | unset($listofdir[$key]); continue; |
| 128 | 131 | } |
| 129 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 130 | - else |
|
| 132 | + if (! is_dir($tmpdir)) { |
|
| 133 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 134 | + } else |
|
| 131 | 135 | { |
| 132 | 136 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 133 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 137 | + if (count($tmpfiles)) { |
|
| 138 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 139 | + } |
|
| 134 | 140 | } |
| 135 | 141 | } |
| 136 | 142 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -221,7 +227,9 @@ discard block |
||
| 221 | 227 | $hookmanager->initHooks(array('odtgeneration')); |
| 222 | 228 | global $action; |
| 223 | 229 | |
| 224 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 230 | + if (! is_object($outputlangs)) { |
|
| 231 | + $outputlangs=$langs; |
|
| 232 | + } |
|
| 225 | 233 | $sav_charset_output=$outputlangs->charset_output; |
| 226 | 234 | $outputlangs->charset_output='UTF-8'; |
| 227 | 235 | |
@@ -249,7 +257,9 @@ discard block |
||
| 249 | 257 | |
| 250 | 258 | $dir = $conf->produit->dir_output; |
| 251 | 259 | $objectref = dol_sanitizeFileName($object->ref); |
| 252 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 260 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 261 | + $dir.= "/" . $objectref; |
|
| 262 | + } |
|
| 253 | 263 | $file = $dir . "/" . $objectref . ".odt"; |
| 254 | 264 | |
| 255 | 265 | if (! file_exists($dir)) |
@@ -276,10 +286,11 @@ discard block |
||
| 276 | 286 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 277 | 287 | { |
| 278 | 288 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 279 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 289 | + if ($format == '1') { |
|
| 290 | + $format='%Y%m%d%H%M%S'; |
|
| 291 | + } |
|
| 280 | 292 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 281 | - } |
|
| 282 | - else |
|
| 293 | + } else |
|
| 283 | 294 | { |
| 284 | 295 | $filename=$newfiletmp.'.'.$newfileformat; |
| 285 | 296 | } |
@@ -305,14 +316,14 @@ discard block |
||
| 305 | 316 | if (! empty($usecontact)) |
| 306 | 317 | { |
| 307 | 318 | // On peut utiliser le nom de la societe du contact |
| 308 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 309 | - else { |
|
| 319 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 320 | + $socobject = $object->contact; |
|
| 321 | + } else { |
|
| 310 | 322 | $socobject = $object->thirdparty; |
| 311 | 323 | // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
| 312 | 324 | $contactobject = $object->contact; |
| 313 | 325 | } |
| 314 | - } |
|
| 315 | - else |
|
| 326 | + } else |
|
| 316 | 327 | { |
| 317 | 328 | $socobject=$object->thirdparty; |
| 318 | 329 | } |
@@ -349,8 +360,7 @@ discard block |
||
| 349 | 360 | 'DELIMITER_RIGHT' => '}' |
| 350 | 361 | ) |
| 351 | 362 | ); |
| 352 | - } |
|
| 353 | - catch(Exception $e) |
|
| 363 | + } catch(Exception $e) |
|
| 354 | 364 | { |
| 355 | 365 | $this->error=$e->getMessage(); |
| 356 | 366 | return -1; |
@@ -366,8 +376,7 @@ discard block |
||
| 366 | 376 | // Make substitutions into odt of freetext |
| 367 | 377 | try { |
| 368 | 378 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 369 | - } |
|
| 370 | - catch(OdfException $e) |
|
| 379 | + } catch(OdfException $e) |
|
| 371 | 380 | { |
| 372 | 381 | } |
| 373 | 382 | |
@@ -381,7 +390,9 @@ discard block |
||
| 381 | 390 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 382 | 391 | // retrieve contact information for use in product as contact_xxx tags |
| 383 | 392 | $array_thirdparty_contact = array(); |
| 384 | - if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 393 | + if ($usecontact) { |
|
| 394 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 395 | + } |
|
| 385 | 396 | |
| 386 | 397 | $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact); |
| 387 | 398 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -393,17 +404,18 @@ discard block |
||
| 393 | 404 | foreach($tmparray as $key=>$value) |
| 394 | 405 | { |
| 395 | 406 | try { |
| 396 | - if (preg_match('/logo$/',$key)) // Image |
|
| 407 | + if (preg_match('/logo$/',$key)) { |
|
| 408 | + // Image |
|
| 397 | 409 | { |
| 398 | 410 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 399 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 400 | - } |
|
| 401 | - else // Text |
|
| 411 | + } else { |
|
| 412 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 413 | + } |
|
| 414 | + } else // Text |
|
| 402 | 415 | { |
| 403 | 416 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 404 | 417 | } |
| 405 | - } |
|
| 406 | - catch(OdfException $e) |
|
| 418 | + } catch(OdfException $e) |
|
| 407 | 419 | { |
| 408 | 420 | } |
| 409 | 421 | } |
@@ -424,11 +436,9 @@ discard block |
||
| 424 | 436 | try |
| 425 | 437 | { |
| 426 | 438 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 427 | - } |
|
| 428 | - catch(OdfException $e) |
|
| 439 | + } catch(OdfException $e) |
|
| 429 | 440 | { |
| 430 | - } |
|
| 431 | - catch(SegmentException $e) |
|
| 441 | + } catch(SegmentException $e) |
|
| 432 | 442 | { |
| 433 | 443 | } |
| 434 | 444 | } |
@@ -436,8 +446,7 @@ discard block |
||
| 436 | 446 | } |
| 437 | 447 | } |
| 438 | 448 | $odfHandler->mergeSegment($listlines); |
| 439 | - } |
|
| 440 | - catch(OdfException $e) |
|
| 449 | + } catch(OdfException $e) |
|
| 441 | 450 | { |
| 442 | 451 | $this->error=$e->getMessage(); |
| 443 | 452 | dol_syslog($this->error, LOG_WARNING); |
@@ -450,8 +459,7 @@ discard block |
||
| 450 | 459 | { |
| 451 | 460 | try { |
| 452 | 461 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 453 | - } |
|
| 454 | - catch(OdfException $e) |
|
| 462 | + } catch(OdfException $e) |
|
| 455 | 463 | { |
| 456 | 464 | } |
| 457 | 465 | } |
@@ -464,15 +472,14 @@ discard block |
||
| 464 | 472 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 465 | 473 | try { |
| 466 | 474 | $odfHandler->exportAsAttachedPDF($file); |
| 467 | - }catch (Exception $e){ |
|
| 475 | + } catch (Exception $e){ |
|
| 468 | 476 | $this->error=$e->getMessage(); |
| 469 | 477 | return -1; |
| 470 | 478 | } |
| 471 | - } |
|
| 472 | - else { |
|
| 479 | + } else { |
|
| 473 | 480 | try { |
| 474 | 481 | $odfHandler->saveToDisk($file); |
| 475 | - }catch (Exception $e){ |
|
| 482 | + } catch (Exception $e){ |
|
| 476 | 483 | $this->error=$e->getMessage(); |
| 477 | 484 | return -1; |
| 478 | 485 | } |
@@ -480,16 +487,16 @@ discard block |
||
| 480 | 487 | |
| 481 | 488 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 482 | 489 | |
| 483 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 484 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 490 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 491 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 492 | + } |
|
| 485 | 493 | |
| 486 | 494 | $odfHandler=null; // Destroy object |
| 487 | 495 | |
| 488 | 496 | $this->result = array('fullpath'=>$file); |
| 489 | 497 | |
| 490 | 498 | return 1; // Success |
| 491 | - } |
|
| 492 | - else |
|
| 499 | + } else |
|
| 493 | 500 | { |
| 494 | 501 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 495 | 502 | return -1; |
@@ -83,7 +83,10 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | // Recupere emetteur |
| 85 | 85 | $this->emetteur=$mysoc; |
| 86 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
| 86 | + if (! $this->emetteur->country_code) { |
|
| 87 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
| 88 | + } |
|
| 89 | + // By default if not defined |
|
| 87 | 90 | } |
| 88 | 91 | |
| 89 | 92 | |
@@ -127,11 +130,14 @@ discard block |
||
| 127 | 130 | if (! $tmpdir) { |
| 128 | 131 | unset($listofdir[$key]); continue; |
| 129 | 132 | } |
| 130 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 131 | - else |
|
| 133 | + if (! is_dir($tmpdir)) { |
|
| 134 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
| 135 | + } else |
|
| 132 | 136 | { |
| 133 | 137 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
| 134 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 138 | + if (count($tmpfiles)) { |
|
| 139 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 140 | + } |
|
| 135 | 141 | } |
| 136 | 142 | } |
| 137 | 143 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -222,7 +228,9 @@ discard block |
||
| 222 | 228 | $hookmanager->initHooks(array('odtgeneration')); |
| 223 | 229 | global $action; |
| 224 | 230 | |
| 225 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
| 231 | + if (! is_object($outputlangs)) { |
|
| 232 | + $outputlangs=$langs; |
|
| 233 | + } |
|
| 226 | 234 | $sav_charset_output=$outputlangs->charset_output; |
| 227 | 235 | $outputlangs->charset_output='UTF-8'; |
| 228 | 236 | |
@@ -248,7 +256,9 @@ discard block |
||
| 248 | 256 | |
| 249 | 257 | $dir = $conf->usergroup->dir_output; |
| 250 | 258 | $objectref = dol_sanitizeFileName($object->ref); |
| 251 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
| 259 | + if (! preg_match('/specimen/i',$objectref)) { |
|
| 260 | + $dir.= "/" . $objectref; |
|
| 261 | + } |
|
| 252 | 262 | $file = $dir . "/" . $objectref . ".odt"; |
| 253 | 263 | |
| 254 | 264 | if (! file_exists($dir)) |
@@ -275,10 +285,11 @@ discard block |
||
| 275 | 285 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
| 276 | 286 | { |
| 277 | 287 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
| 278 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
| 288 | + if ($format == '1') { |
|
| 289 | + $format='%Y%m%d%H%M%S'; |
|
| 290 | + } |
|
| 279 | 291 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
| 280 | - } |
|
| 281 | - else |
|
| 292 | + } else |
|
| 282 | 293 | { |
| 283 | 294 | $filename=$newfiletmp.'.'.$newfileformat; |
| 284 | 295 | } |
@@ -304,14 +315,14 @@ discard block |
||
| 304 | 315 | if (! empty($usecontact)) |
| 305 | 316 | { |
| 306 | 317 | // On peut utiliser le nom de la societe du contact |
| 307 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
| 308 | - else { |
|
| 318 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
| 319 | + $socobject = $object->contact; |
|
| 320 | + } else { |
|
| 309 | 321 | $socobject = $object->thirdparty; |
| 310 | 322 | // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
| 311 | 323 | $contactobject = $object->contact; |
| 312 | 324 | } |
| 313 | - } |
|
| 314 | - else |
|
| 325 | + } else |
|
| 315 | 326 | { |
| 316 | 327 | $socobject=$object->thirdparty; |
| 317 | 328 | } |
@@ -348,8 +359,7 @@ discard block |
||
| 348 | 359 | 'DELIMITER_RIGHT' => '}' |
| 349 | 360 | ) |
| 350 | 361 | ); |
| 351 | - } |
|
| 352 | - catch(Exception $e) |
|
| 362 | + } catch(Exception $e) |
|
| 353 | 363 | { |
| 354 | 364 | $this->error=$e->getMessage(); |
| 355 | 365 | return -1; |
@@ -364,8 +374,7 @@ discard block |
||
| 364 | 374 | // Make substitutions into odt of freetext |
| 365 | 375 | try { |
| 366 | 376 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
| 367 | - } |
|
| 368 | - catch(OdfException $e) |
|
| 377 | + } catch(OdfException $e) |
|
| 369 | 378 | { |
| 370 | 379 | } |
| 371 | 380 | |
@@ -378,8 +387,9 @@ discard block |
||
| 378 | 387 | $array_other=$this->get_substitutionarray_other($outputlangs); |
| 379 | 388 | // retrieve contact information for use in user as contact_xxx tags |
| 380 | 389 | $array_thirdparty_contact = array(); |
| 381 | - if ($usecontact) |
|
| 382 | - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 390 | + if ($usecontact) { |
|
| 391 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
| 392 | + } |
|
| 383 | 393 | |
| 384 | 394 | $tmparray = array_merge($array_global,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
| 385 | 395 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -391,17 +401,18 @@ discard block |
||
| 391 | 401 | { |
| 392 | 402 | try |
| 393 | 403 | { |
| 394 | - if (preg_match('/logo$/',$key)) // Image |
|
| 404 | + if (preg_match('/logo$/',$key)) { |
|
| 405 | + // Image |
|
| 395 | 406 | { |
| 396 | 407 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
| 397 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 398 | - } |
|
| 399 | - else // Text |
|
| 408 | + } else { |
|
| 409 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
| 410 | + } |
|
| 411 | + } else // Text |
|
| 400 | 412 | { |
| 401 | 413 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 402 | 414 | } |
| 403 | - } |
|
| 404 | - catch(OdfException $e) |
|
| 415 | + } catch(OdfException $e) |
|
| 405 | 416 | { |
| 406 | 417 | } |
| 407 | 418 | } |
@@ -411,8 +422,7 @@ discard block |
||
| 411 | 422 | $foundtagforlines = 1; |
| 412 | 423 | try { |
| 413 | 424 | $listlines = $odfHandler->setSegment('lines'); |
| 414 | - } |
|
| 415 | - catch(OdfException $e) |
|
| 425 | + } catch(OdfException $e) |
|
| 416 | 426 | { |
| 417 | 427 | // We may arrive here if tags for lines not present into template |
| 418 | 428 | $foundtagforlines = 0; |
@@ -436,11 +446,9 @@ discard block |
||
| 436 | 446 | if(!is_array($val)) { |
| 437 | 447 | $listlines->setVars($key, $val, true, 'UTF-8'); |
| 438 | 448 | } |
| 439 | - } |
|
| 440 | - catch(OdfException $e) |
|
| 449 | + } catch(OdfException $e) |
|
| 441 | 450 | { |
| 442 | - } |
|
| 443 | - catch(SegmentException $e) |
|
| 451 | + } catch(SegmentException $e) |
|
| 444 | 452 | { |
| 445 | 453 | } |
| 446 | 454 | } |
@@ -448,8 +456,7 @@ discard block |
||
| 448 | 456 | } |
| 449 | 457 | $odfHandler->mergeSegment($listlines); |
| 450 | 458 | } |
| 451 | - } |
|
| 452 | - catch(OdfException $e) |
|
| 459 | + } catch(OdfException $e) |
|
| 453 | 460 | { |
| 454 | 461 | $this->error=$e->getMessage(); |
| 455 | 462 | dol_syslog($this->error, LOG_WARNING); |
@@ -462,8 +469,7 @@ discard block |
||
| 462 | 469 | { |
| 463 | 470 | try { |
| 464 | 471 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
| 465 | - } |
|
| 466 | - catch(OdfException $e) |
|
| 472 | + } catch(OdfException $e) |
|
| 467 | 473 | { |
| 468 | 474 | } |
| 469 | 475 | } |
@@ -476,15 +482,14 @@ discard block |
||
| 476 | 482 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
| 477 | 483 | try { |
| 478 | 484 | $odfHandler->exportAsAttachedPDF($file); |
| 479 | - }catch (Exception $e){ |
|
| 485 | + } catch (Exception $e){ |
|
| 480 | 486 | $this->error=$e->getMessage(); |
| 481 | 487 | return -1; |
| 482 | 488 | } |
| 483 | - } |
|
| 484 | - else { |
|
| 489 | + } else { |
|
| 485 | 490 | try { |
| 486 | 491 | $odfHandler->saveToDisk($file); |
| 487 | - }catch (Exception $e){ |
|
| 492 | + } catch (Exception $e){ |
|
| 488 | 493 | $this->error=$e->getMessage(); |
| 489 | 494 | return -1; |
| 490 | 495 | } |
@@ -492,16 +497,16 @@ discard block |
||
| 492 | 497 | |
| 493 | 498 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 494 | 499 | |
| 495 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 496 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 500 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 501 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 502 | + } |
|
| 497 | 503 | |
| 498 | 504 | $odfHandler=null; // Destroy object |
| 499 | 505 | |
| 500 | 506 | $this->result = array('fullpath'=>$file); |
| 501 | 507 | |
| 502 | 508 | return 1; // Success |
| 503 | - } |
|
| 504 | - else |
|
| 509 | + } else |
|
| 505 | 510 | { |
| 506 | 511 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
| 507 | 512 | return -1; |