26if (!defined(
'NOSESSION')) {
27 define(
'NOSESSION',
'1');
30$sapi_type = php_sapi_name();
31$script_file = basename(__FILE__);
35if (substr($sapi_type, 0, 3) ==
'cgi') {
36 echo
"Error: You are using PHP for CGI. To execute ".$script_file.
" from command line, you must use PHP for CLI mode.\n";
41define(
'EVEN_IF_ONLY_LOGIN_ALLOWED', 1);
44require_once $path.
"../../htdocs/master.inc.php";
45require_once DOL_DOCUMENT_ROOT.
"/product/class/product.class.php";
46require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
47require_once DOL_DOCUMENT_ROOT.
"/core/lib/images.lib.php";
55$version = DOL_VERSION;
59print
"***** ".$script_file.
" (".$version.
") pid=".
dol_getmypid().
" - dir=".DOL_DATA_ROOT.
" *****\n";
60dol_syslog($script_file.
" launched with arg ".join(
',', $argv));
63 print
"Usage: $script_file subdirtoscan (test|confirm)\n";
64 print
"Example: $script_file propale test\n";
68print
'--- start'.
"\n";
72if (empty($dir) || empty($subdir)) {
77 print
'Directory '.$dir.
'/'.$subdir.
' not found.'.
"\n";
81print
'Scan directory '.$dir.
'/'.$subdir.
"\n";
83$filearray =
dol_dir_list($dir.
'/'.$subdir,
"directories", 0,
'',
'temp$');
88if ($subdir ==
'propale' || $subdir ==
'proposal') {
89 if (isModEnabled(
'propal')) {
90 require_once DOL_DOCUMENT_ROOT.
"/comm/propal/class/propal.class.php";
91 $tmpobject =
new Propal($db);
93 print
'Error, module not enabled'.
"\n";
95} elseif ($subdir ==
'commande' || $subdir ==
'order') {
96 if (isModEnabled(
'commande')) {
97 require_once DOL_DOCUMENT_ROOT.
"/commande/class/commande.class.php";
100 print
'Error, module not enabled'.
"\n";
102} elseif ($subdir ==
'facture' || $subdir ==
'invoice') {
103 if (isModEnabled(
'facture')) {
104 require_once DOL_DOCUMENT_ROOT.
"/compta/facture/class/facture.class.php";
107 print
'Error, module not enabled'.
"\n";
110 print
'Dir '.$subdir.
' not yet supported'.
"\n";
114 foreach ($filearray as $keyf => $valf) {
115 $ref = basename($valf[
'name']);
116 print
'Process document for dir = '.$subdir.
', ref '.$ref.
"\n";
118 $ret1 = $tmpobject->fetch(0, $ref);
119 $ret2 = $tmpobject->fetch_thirdparty();
124 $outputlangs = $langs;
127 if (!empty($newlang)) {
129 $outputlangs->setDefaultLang($newlang);
138 if (!empty($argv[2]) && $argv[2] ==
'confirm') {
139 $result = $tmpobject->generateDocument($tmpobject->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
145 print
'File for ref '.$tmpobject->ref.
' returned 0 during regeneration with template '.$tmpobject->model_pdf.
"\n";
148 print
'File for ref '.$tmpobject->ref.
' regenerated with template '.$tmpobject->model_pdf.
"\n";
157print $nbok.
" objects processed\n";
158print $nbko.
" objects with errors\n";
Class to manage customers orders.
Class to manage invoices.
Class to manage proposals.
Class to manage translations.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_is_dir($folder)
Test if filename is a directory.
dol_getmypid()
Return getmypid() or random PID when function is disabled Some web hosts disable this php function fo...
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.