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;
59$hookmanager->initHooks(array(
'cli'));
66print
"***** ".$script_file.
" (".$version.
") pid=".
dol_getmypid().
" - dir=".DOL_DATA_ROOT.
" *****\n";
67dol_syslog($script_file.
" launched with arg ".join(
',', $argv));
70 print
"Usage: $script_file subdirtoscan (test|confirm)\n";
71 print
"Example: $script_file propale test\n";
75print
'--- start'.
"\n";
79if (empty($dir) || empty($subdir)) {
84 print
'Directory '.$dir.
'/'.$subdir.
' not found.'.
"\n";
88print
'Scan directory '.$dir.
'/'.$subdir.
"\n";
90$filearray =
dol_dir_list($dir.
'/'.$subdir,
"directories", 0,
'',
'temp$');
95if ($subdir ==
'propale' || $subdir ==
'proposal') {
96 if (isModEnabled(
'propal')) {
97 require_once DOL_DOCUMENT_ROOT.
"/comm/propal/class/propal.class.php";
98 $tmpobject =
new Propal($db);
100 print
'Error, module not enabled'.
"\n";
102} elseif ($subdir ==
'commande' || $subdir ==
'order') {
103 if (isModEnabled(
'commande')) {
104 require_once DOL_DOCUMENT_ROOT.
"/commande/class/commande.class.php";
107 print
'Error, module not enabled'.
"\n";
109} elseif ($subdir ==
'facture' || $subdir ==
'invoice') {
110 if (isModEnabled(
'facture')) {
111 require_once DOL_DOCUMENT_ROOT.
"/compta/facture/class/facture.class.php";
114 print
'Error, module not enabled'.
"\n";
117 print
'Dir '.$subdir.
' not yet supported'.
"\n";
121 foreach ($filearray as $keyf => $valf) {
122 $ref = basename($valf[
'name']);
123 print
'Process document for dir = '.$subdir.
', ref '.$ref.
"\n";
125 $ret1 = $tmpobject->fetch(0, $ref);
126 $ret2 = $tmpobject->fetch_thirdparty();
131 $outputlangs = $langs;
134 if (!empty($newlang)) {
136 $outputlangs->setDefaultLang($newlang);
145 if (!empty($argv[2]) && $argv[2] ==
'confirm') {
146 $result = $tmpobject->generateDocument($tmpobject->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
152 print
'File for ref '.$tmpobject->ref.
' returned 0 during regeneration with template '.$tmpobject->model_pdf.
"\n";
155 print
'File for ref '.$tmpobject->ref.
' regenerated with template '.$tmpobject->model_pdf.
"\n";
164print $nbok.
" objects processed\n";
165print $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($utf8_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=null, $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.