# Zones marquees MODIF dans : accountancy/class/accountancyexport.class (05.12.2023 19.10).php # Fichier actif correspondant : accountancy/class/accountancyexport.class.php ... 843 | $Tab['quantity1'] = str_repeat(' ', 10); 844 | $Tab['num_piece2'] = str_pad(self::trunc($data->piece_num, 8), 8); 845 | $Tab['devis'] = str_pad($conf->currency, 3); 846 | $Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3); 847 | $Tab['filler3'] = str_repeat(' ', 3); 848 | 849 | // MODIF JOSE $Tab['num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10); 850 | $ref_document = array(); 851 | $ref_document = explode(' - ',$data->label_operation); // Quick to get the reference document 852 | // END MODIF JOSE 853 | 854 | // Keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!! 855 | // as we use utf8, we must remove accent to have only one ascii char instead of utf8 2 chars for specials that report wrong line size that will exceed import format spec 856 | // TODO: we should filter more than only accent to avoid wrong line size 857 | // TODO: remove invoice number doc_ref in libelle, 858 | // TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software 859 | //$Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . ' ' . dol_string_unaccent($data->label_operation), 30), 30); 860 | // MODIF JOSE $Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 30), 30); 861 | if (!empty($data->multicurrency_amount)){ 862 | $Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($ref_document[0]), 15)." ".$data->multicurrency_code.price2num($data->multicurrency_amount), 30); 863 | } else { 864 | $Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($ref_document[0]), 15)." ".$data->doc_ref, 30); 865 | } 866 | $Tab['codetva'] = str_repeat(' ', 2); 867 | 868 | // We need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part 869 | // $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10); 870 | // MODIF JOSE $Tab['num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10); 871 | $Tab['num_piece3'] = str_pad(substr(self::trunc(trim($ref_document[1]," -"), 20), -10),10) ; // trim to clean Space and Minus(from TC orders) and length as to be 10. 872 | $Tab['reserved'] = str_repeat(' ', 10); // position 159 873 | $Tab['currency_amount'] = str_repeat(' ', 13); // position 169 874 | // get document file 875 | $attachmentFileName = ''; 876 | // error_log("TEST 0 ".print_r($Tab,1),1,"josett225@gmail.com"); 877 | // dol_syslog("Message Erreur".print_r($Tab,1),LOG_DEBUG); 878 | // dol_syslog(get_class($this)."::create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type, LOG_DEBUG); ... 892 | $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output; 893 | } 894 | $arrayofinclusion = array(); 895 | $arrayofinclusion[] = '^'.preg_quote($objectFileName, '/').'\.pdf$'; 896 | $arrayofinclusion[] = '^'.preg_quote($ref_document[1], '/').'\.pdf$'; // find ref_supplier.pdf 897 | $arrayofinclusion[] = $ref_document[1]; // find ref_supplier in filename 898 | // MODIF JOSE $fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 1, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, true); 899 | // error_log("TEST 1".print_r($arrayofinclusion,1),1,"jose.martinez@pichinov.com"); 900 | 901 | if ($data->doc_type == 'supplier_invoice') { 902 | $directoryFound = dol_dir_list($objectDirPath.'/', 'files', 1,implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, true); // Get Supplier Directory 903 | $fileFoundList = dol_dir_list($directoryFound[0]['path'], 'files', 1,'', '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, true); //get supplier files 904 | 905 | } else { // customer or expense 906 | $fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 1, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, true); 907 | } 908 | // error_log("TEST 2".print_r($fileFoundList,1),1,"jose.martinez@pichinov.com"); 909 | 910 | // END MODIF JOSE 911 | if (!empty($fileFoundList)) { 912 | $attachmentFileNameTrunc = str_pad(self::trunc($data->piece_num, 8), 8, '0', STR_PAD_LEFT); 913 | // error_log("TEST 3".print_r($attachmentFileNameTrunc,1),1,"jose.martinez@pichinov.com"); 914 | foreach ($fileFoundList as $fileFound) { 915 | // MODIF JOSE if (strstr($fileFound['name'], $objectFileName)) { 916 | if (strstr(substr($fileFound['name'],0,-4), $ref_document[1])) { // Quick and Dirt to remove '.pdf' for testing purpose 917 | // MODIF JOSE $fileFoundPath = $objectDirPath.'/'.$objectFileName.'/'.$fileFound['name']; 918 | $fileFoundPath = $fileFound['fullname']; // Information already build in array 919 | if (file_exists($fileFoundPath)) { 920 | $archiveFileList[$attachmentFileKey] = array( 921 | 'path' => $fileFoundPath, 922 | 'name' => $attachmentFileNameTrunc.'.pdf', 923 | ); 924 | break; 925 | }