Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2019-11-13 17:32:11 +00:00
parent 7118dbbd1d
commit 87585c0f2a
12 changed files with 3564 additions and 3564 deletions

File diff suppressed because it is too large Load Diff

View File

@ -78,54 +78,54 @@ if ($action == 'add' && ! empty($permissiontoadd))
}
}
if (! $error)
if (!$error)
{
$result=$object->create($user);
$result = $object->create($user);
if ($result > 0)
{
// Creation OK
$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
header("Location: ".$urltogo);
exit;
}
else
{
// Creation KO
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
$action='create';
$action = 'create';
}
}
else
{
$action='create';
$action = 'create';
}
}
// Action to update record
if ($action == 'update' && ! empty($permissiontoadd))
if ($action == 'update' && !empty($permissiontoadd))
{
foreach ($object->fields as $key => $val)
{
if (! GETPOSTISSET($key)) continue; // The field was not submited to be edited
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
// Set value to update
if (in_array($object->fields[$key]['type'], array('text', 'html'))) {
$value = GETPOST($key, 'none');
} elseif ($object->fields[$key]['type']=='date') {
} elseif ($object->fields[$key]['type'] == 'date') {
$value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'));
} elseif ($object->fields[$key]['type']=='datetime') {
} elseif ($object->fields[$key]['type'] == 'datetime') {
$value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'));
} elseif (in_array($object->fields[$key]['type'], array('price', 'real'))) {
$value = price2num(GETPOST($key));
} else {
$value = GETPOST($key, 'alpha');
}
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field
if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field
if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field
$object->$key=$value;
$object->$key = $value;
if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default']))
{
$error++;
@ -133,28 +133,28 @@ if ($action == 'update' && ! empty($permissiontoadd))
}
}
if (! $error)
if (!$error)
{
$result=$object->update($user);
$result = $object->update($user);
if ($result > 0)
{
$action='view';
$action = 'view';
}
else
{
// Creation KO
setEventMessages($object->error, $object->errors, 'errors');
$action='edit';
$action = 'edit';
}
}
else
{
$action='edit';
$action = 'edit';
}
}
// Action to update one extrafield
if ($action == "update_extras" && ! empty($permissiontoadd))
if ($action == "update_extras" && !empty($permissiontoadd))
{
$object->fetch(GETPOST('id', 'int'));
@ -162,7 +162,7 @@ if ($action == "update_extras" && ! empty($permissiontoadd))
$attributekeylong = 'options_'.$attributekey;
$object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, ' alpha');
$result = $object->insertExtraFields(empty($triggermodname)?'':$triggermodname, $user);
$result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
if ($result > 0)
{
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
@ -176,15 +176,15 @@ if ($action == "update_extras" && ! empty($permissiontoadd))
}
// Action to delete
if ($action == 'confirm_delete' && ! empty($permissiontodelete))
if ($action == 'confirm_delete' && !empty($permissiontodelete))
{
if (! ($object->id > 0))
if (!($object->id > 0))
{
dol_print_error('', 'Error, object must be fetched before being deleted');
exit;
}
$result=$object->delete($user);
$result = $object->delete($user);
if ($result > 0)
{
// Delete OK
@ -194,13 +194,13 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete))
}
else
{
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
}
}
// Remove a line
if ($action == 'confirm_deleteline' && $confirm == 'yes' && ! empty($permissiontoadd))
if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd))
{
$result = $object->deleteline($user, $lineid);
if ($result > 0)
@ -216,7 +216,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && ! empty($permissiont
{
$newlang = $object->thirdparty->default_lang;
}
if (! empty($newlang)) {
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
@ -248,11 +248,11 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd)
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
@ -277,11 +277,11 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd)
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
@ -320,11 +320,11 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd)
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
@ -337,30 +337,30 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd)
}
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd))
if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd))
{
if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers'))
{
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
}
else
{
$objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid.
$objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid.
//$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
// ...
$result=$objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
$result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
if (is_object($result) || $result > 0)
{
$newid = 0;
if (is_object($result)) $newid = $result->id;
else $newid = $result;
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
exit;
}
else
{
setEventMessages($objectutil->error, $objectutil->errors, 'errors');
$action='';
$action = '';
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -35,15 +35,15 @@ $allowinstall = 0;
$allowupgrade = false;
$checksok = 1;
$setuplang=GETPOST("selectlang", 'aZ09', 3)?GETPOST("selectlang", 'aZ09', 3):$langs->getDefaultLang();
$setuplang = GETPOST("selectlang", 'aZ09', 3) ?GETPOST("selectlang", 'aZ09', 3) : $langs->getDefaultLang();
$langs->setDefaultLang($setuplang);
$langs->load("install");
// Now we load forced/pre-set values from install.forced.php file.
$useforcedwizard=false;
$forcedfile="./install.forced.php";
if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php";
$useforcedwizard = false;
$forcedfile = "./install.forced.php";
if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php";
if (@file_exists($forcedfile)) {
$useforcedwizard = true;
include_once $forcedfile;
@ -56,7 +56,7 @@ dolibarr_install_syslog("- check: Dolibarr install/upgrade process started");
* View
*/
pHeader('', ''); // No next step for navigation buttons. Next step is defined by click on links.
pHeader('', ''); // No next step for navigation buttons. Next step is defined by click on links.
//print "<br>\n";
@ -65,28 +65,28 @@ pHeader('', ''); // No next step for navigation buttons. Next step is define
print '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Database"> '.$langs->trans("MiscellaneousChecks").":</h3>\n";
// Check browser
$useragent=$_SERVER['HTTP_USER_AGENT'];
if (! empty($useragent))
$useragent = $_SERVER['HTTP_USER_AGENT'];
if (!empty($useragent))
{
$tmp=getBrowserInfo($_SERVER["HTTP_USER_AGENT"]);
$browserversion=$tmp['browserversion'];
$browsername=$tmp['browsername'];
$tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]);
$browserversion = $tmp['browserversion'];
$browsername = $tmp['browsername'];
if ($browsername == 'ie' && $browserversion < 7) print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("WarningBrowserTooOld")."<br>\n";
}
// Check PHP version
$arrayphpminversionerror = array(5,5,0);
$arrayphpminversionwarning = array(5,5,0);
$arrayphpminversionerror = array(5, 5, 0);
$arrayphpminversionwarning = array(5, 5, 0);
if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) // Minimum to use (error if lower)
{
print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
$checksok=0; // 0=error, 1=warning
$checksok = 0; // 0=error, 1=warning
}
elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) // Minimum supported (warning if lower)
{
print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
$checksok=0; // 0=error, 1=warning
$checksok = 0; // 0=error, 1=warning
}
else
{
@ -97,12 +97,12 @@ print "<br>\n";
// Check PHP support for $_POST
if (! isset($_GET["testget"]) && ! isset($_POST["testpost"]))
if (!isset($_GET["testget"]) && !isset($_POST["testpost"]))
{
print '<img src="../theme/eldy/img/warning.png" alt="Warning"> '.$langs->trans("PHPSupportPOSTGETKo");
print ' (<a href="'.$_SERVER["PHP_SELF"].'?testget=ok">'.$langs->trans("Recheck").'</a>)';
print "<br>\n";
$checksok=0;
$checksok = 0;
}
else
{
@ -111,10 +111,10 @@ else
// Check if sessions enabled
if (! function_exists("session_id"))
if (!function_exists("session_id"))
{
print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportSessions")."<br>\n";
$checksok=0;
$checksok = 0;
}
else
{
@ -123,7 +123,7 @@ else
// Check if GD supported (we need GD for image conversion)
if (! function_exists("imagecreate"))
if (!function_exists("imagecreate"))
{
$langs->load("errors");
print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportGD")."<br>\n";
@ -136,7 +136,7 @@ else
// Check if Curl supported
if (! function_exists("curl_init"))
if (!function_exists("curl_init"))
{
$langs->load("errors");
print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportCurl")."<br>\n";
@ -148,7 +148,7 @@ else
}
// Check if PHP calendar extension is available
if (! function_exists("easter_date"))
if (!function_exists("easter_date"))
{
print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportCalendar")."<br>\n";
}
@ -159,7 +159,7 @@ else
// Check if UTF8 supported
if (! function_exists("utf8_encode"))
if (!function_exists("utf8_encode"))
{
$langs->load("errors");
print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportUTF8")."<br>\n";
@ -174,7 +174,7 @@ else
// Check if intl methods are supported
if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost')
{
if (! function_exists("locale_get_primary_language") || ! function_exists("locale_get_region"))
if (!function_exists("locale_get_primary_language") || !function_exists("locale_get_region"))
{
$langs->load("errors");
print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportIntl")."<br>\n";
@ -188,18 +188,18 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc
// Check memory
$memrequiredorig='64M';
$memrequired=64*1024*1024;
$memmaxorig=@ini_get("memory_limit");
$memmax=@ini_get("memory_limit");
$memrequiredorig = '64M';
$memrequired = 64 * 1024 * 1024;
$memmaxorig = @ini_get("memory_limit");
$memmax = @ini_get("memory_limit");
if ($memmaxorig != '')
{
preg_match('/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg);
if ($reg[2])
{
if (strtoupper($reg[2]) == 'G') $memmax=$reg[1]*1024*1024*1024;
if (strtoupper($reg[2]) == 'M') $memmax=$reg[1]*1024*1024;
if (strtoupper($reg[2]) == 'K') $memmax=$reg[1]*1024;
if (strtoupper($reg[2]) == 'G') $memmax = $reg[1] * 1024 * 1024 * 1024;
if (strtoupper($reg[2]) == 'M') $memmax = $reg[1] * 1024 * 1024;
if (strtoupper($reg[2]) == 'K') $memmax = $reg[1] * 1024;
}
if ($memmax >= $memrequired || $memmax == -1)
{
@ -216,37 +216,37 @@ if ($memmaxorig != '')
clearstatcache();
if (is_readable($conffile) && filesize($conffile) > 8)
{
dolibarr_install_syslog("check: conf file '" . $conffile . "' already defined");
$confexists=1;
dolibarr_install_syslog("check: conf file '".$conffile."' already defined");
$confexists = 1;
include_once $conffile;
$databaseok=1;
$databaseok = 1;
if ($databaseok)
{
// Already installed for all parts (config and database). We can propose upgrade.
$allowupgrade=true;
$allowupgrade = true;
}
else
{
$allowupgrade=false;
$allowupgrade = false;
}
}
else
{
// If not, we create it
dolibarr_install_syslog("check: we try to create conf file '" . $conffile . "'");
$confexists=0;
dolibarr_install_syslog("check: we try to create conf file '".$conffile."'");
$confexists = 0;
// First we try by copying example
if (@copy($conffile.".example", $conffile))
{
// Success
dolibarr_install_syslog("check: successfully copied file " . $conffile . ".example into " . $conffile);
dolibarr_install_syslog("check: successfully copied file ".$conffile.".example into ".$conffile);
}
else
{
// If failed, we try to create an empty file
dolibarr_install_syslog("check: failed to copy file " . $conffile . ".example into " . $conffile . ". We try to create it.", LOG_WARNING);
dolibarr_install_syslog("check: failed to copy file ".$conffile.".example into ".$conffile.". We try to create it.", LOG_WARNING);
$fp = @fopen($conffile, "w");
if ($fp)
@ -255,17 +255,17 @@ else
@fputs($fp, "\n");
fclose($fp);
}
else dolibarr_install_syslog("check: failed to create a new file " . $conffile . " into current dir " . getcwd() . ". Please check permissions.", LOG_ERR);
else dolibarr_install_syslog("check: failed to create a new file ".$conffile." into current dir ".getcwd().". Please check permissions.", LOG_ERR);
}
// First install: no upgrade necessary/required
$allowupgrade=false;
$allowupgrade = false;
}
// File is missing and cannot be created
if (! file_exists($conffile))
if (!file_exists($conffile))
{
print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
print "<br><br>";
@ -281,7 +281,7 @@ else
{
print '<img src="../theme/eldy/img/error.png" alt="Warning"> '.$langs->trans("ConfFileMustBeAFileNotADir", $conffiletoshow);
$allowinstall=0;
$allowinstall = 0;
}
// File exists but cannot be modified
elseif (!is_writable($conffile))
@ -298,7 +298,7 @@ else
print '<img src="../theme/eldy/img/tick.png" alt="Warning"> '.$langs->trans("ConfFileIsNotWritable", $conffiletoshow);
print "<br>\n";
$allowinstall=0;
$allowinstall = 0;
}
// File exists and can be modified
else
@ -315,37 +315,37 @@ else
print '<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans("ConfFileIsWritable", $conffiletoshow);
print "<br>\n";
$allowinstall=1;
$allowinstall = 1;
}
print "<br>\n";
// Requirements met/all ok: display the next step button
if ($checksok)
{
$ok=0;
$ok = 0;
// Try to create db connection
if (file_exists($conffile))
{
include_once $conffile;
if (! empty($dolibarr_main_db_type) && ! empty($dolibarr_main_document_root))
if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root))
{
if (! file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php"))
if (!file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php"))
{
print '<span class="error">A '.$conffiletoshow.' file exists with a dolibarr_main_document_root to '.$dolibarr_main_document_root.' that seems wrong. Try to fix or remove the '.$conffiletoshow.' file.</span><br>'."\n";
dol_syslog("A '" . $conffiletoshow . "' file exists with a dolibarr_main_document_root to " . $dolibarr_main_document_root . " that seems wrong. Try to fix or remove the '" . $conffiletoshow . "' file.", LOG_WARNING);
dol_syslog("A '".$conffiletoshow."' file exists with a dolibarr_main_document_root to ".$dolibarr_main_document_root." that seems wrong. Try to fix or remove the '".$conffiletoshow."' file.", LOG_WARNING);
}
else
{
require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
// If password is encoded, we decode it
if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass))
{
require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
if (preg_match('/crypted:/i', $dolibarr_main_db_pass))
{
$dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially crypted
$dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially crypted
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}
else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
@ -358,10 +358,10 @@ else
$conf->db->name = $dolibarr_main_db_name;
$conf->db->user = $dolibarr_main_db_user;
$conf->db->pass = $dolibarr_main_db_pass;
$db=getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
$db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
if ($db->connected && $db->database_selected)
{
$ok=true;
$ok = true;
}
}
}
@ -370,26 +370,26 @@ else
// If database access is available, we set more variables
if ($ok)
{
if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0;
$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = '';
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
$conf->setValues($db);
// Reset forced setup after the setValues
if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE=constant('SYSLOG_FILE');
if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
$conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
// Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
// Version to install is DOL_VERSION
$dolibarrlastupgradeversionarray=preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL)?$conf->global->MAIN_VERSION_LAST_INSTALL:''));
$dolibarrversiontoinstallarray=versiondolibarrarray();
$dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : ''));
$dolibarrversiontoinstallarray = versiondolibarrarray();
}
// Show title
if (! empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ! empty($conf->global->MAIN_VERSION_LAST_INSTALL))
if (!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || !empty($conf->global->MAIN_VERSION_LAST_INSTALL))
{
print $langs->trans("VersionLastUpgrade").': <b><span class="ok">'.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_INSTALL:$conf->global->MAIN_VERSION_LAST_UPGRADE).'</span></b> - ';
print $langs->trans("VersionLastUpgrade").': <b><span class="ok">'.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE).'</span></b> - ';
print $langs->trans("VersionProgram").': <b><span class="ok">'.DOL_VERSION.'</span></b>';
//print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired"));
print '<br>';
@ -400,7 +400,7 @@ else
//print $langs->trans("InstallEasy")." ";
print '<h3><span class="soustitre">'.$langs->trans("ChooseYourSetupMode").'</span></h3>';
$foundrecommandedchoice=0;
$foundrecommandedchoice = 0;
$available_choices = array();
$notavailable_choices = array();
@ -417,7 +417,7 @@ else
//print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
$choice .= '<div class="center"><div class="ok">'.$langs->trans("InstallChoiceSuggested").'</div></div>';
// <img src="../theme/eldy/img/tick.png" alt="Ok"> ';
$foundrecommandedchoice=1; // To show only once
$foundrecommandedchoice = 1; // To show only once
}
$choice .= '</td>';
@ -441,14 +441,14 @@ else
}
// Show upgrade lines
$allowupgrade=true;
$allowupgrade = true;
if (empty($dolibarr_main_db_host)) // This means install process was not run
{
$allowupgrade=false;
$allowupgrade = false;
}
if (defined("MAIN_NOT_INSTALLED")) $allowupgrade=false;
if (GETPOST('allowupgrade')) $allowupgrade=true;
$migrationscript=array( array('from'=>'3.0.0', 'to'=>'3.1.0'),
if (defined("MAIN_NOT_INSTALLED")) $allowupgrade = false;
if (GETPOST('allowupgrade')) $allowupgrade = true;
$migrationscript = array(array('from'=>'3.0.0', 'to'=>'3.1.0'),
array('from'=>'3.1.0', 'to'=>'3.2.0'),
array('from'=>'3.2.0', 'to'=>'3.3.0'),
array('from'=>'3.3.0', 'to'=>'3.4.0'),
@ -467,26 +467,26 @@ else
array('from'=>'10.0.0', 'to'=>'11.0.0')
);
$count=0;
$count = 0;
foreach ($migrationscript as $migarray)
{
$choice = '';
$count++;
$recommended_choice = false;
$version=DOL_VERSION;
$versionfrom=$migarray['from'];
$versionto=$migarray['to'];
$versionarray=preg_split('/[\.-]/', $version);
$dolibarrversionfromarray=preg_split('/[\.-]/', $versionfrom);
$dolibarrversiontoarray=preg_split('/[\.-]/', $versionto);
$version = DOL_VERSION;
$versionfrom = $migarray['from'];
$versionto = $migarray['to'];
$versionarray = preg_split('/[\.-]/', $version);
$dolibarrversionfromarray = preg_split('/[\.-]/', $versionfrom);
$dolibarrversiontoarray = preg_split('/[\.-]/', $versionto);
// Define string newversionxxx that are used for text to show
$newversionfrom=preg_replace('/(\.[0-9]+)$/i', '.*', $versionfrom);
$newversionto=preg_replace('/(\.[0-9]+)$/i', '.*', $versionto);
$newversionfrombis='';
$newversionfrom = preg_replace('/(\.[0-9]+)$/i', '.*', $versionfrom);
$newversionto = preg_replace('/(\.[0-9]+)$/i', '.*', $versionto);
$newversionfrombis = '';
if (versioncompare($dolibarrversiontoarray, $versionarray) < -2) // From x.y.z -> x.y.z+1
{
$newversionfrombis=' '.$langs->trans("or").' '.$versionto;
$newversionfrombis = ' '.$langs->trans("or").' '.$versionto;
}
if ($ok)
@ -498,7 +498,7 @@ else
(versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray, $versionarray) < -2)
)
{
$foundrecommandedchoice=1; // To show only once
$foundrecommandedchoice = 1; // To show only once
$recommended_choice = true;
}
}
@ -519,7 +519,7 @@ else
$choice .= '<br>';
//print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
$choice .= '<div class="center">';
$choice .= '<div class="ok">'.$langs->trans("InstallChoiceSuggested").'</div>';
$choice .= '<div class="ok">'.$langs->trans("InstallChoiceSuggested").'</div>';
if ($count < count($migarray)) // There are other choices after
{
print $langs->trans("MigrateIsDoneStepByStep", DOL_VERSION);
@ -531,10 +531,10 @@ else
$choice .= '<td class="center">';
if ($allowupgrade)
{
$disabled=false;
$disabled = false;
if ($foundrecommandedchoice == 2)
{
$disabled=true;
$disabled = true;
}
if ($foundrecommandedchoice == 1)
{
@ -546,7 +546,7 @@ else
}
else
{
$choice .= '<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count<count($migrationscript)?'_'.$versionto:'').'&amp;selectlang='.$setuplang.'&amp;versionfrom='.$versionfrom.'&amp;versionto='.$versionto.'">'.$langs->trans("Start").'</a>';
$choice .= '<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ? '_'.$versionto : '').'&amp;selectlang='.$setuplang.'&amp;versionfrom='.$versionfrom.'&amp;versionto='.$versionto.'">'.$langs->trans("Start").'</a>';
}
}
else
@ -566,8 +566,8 @@ else
// If there is no choice at all, we show all of them.
if (empty($available_choices))
{
$available_choices=$notavailable_choices;
$notavailable_choices=array();
$available_choices = $notavailable_choices;
$notavailable_choices = array();
}
// Array of install choices
@ -621,4 +621,4 @@ $(".runupgrade").click(function() {
</script>';
dolibarr_install_syslog("- check: end");
pFooter(1); // Never display next button
pFooter(1); // Never display next button

View File

@ -23,7 +23,7 @@
*/
// Put here all includes required by your class file
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
@ -89,27 +89,27 @@ class MyObject extends CommonObject
/**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
public $fields=array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20),
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1),
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'),
'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'),
public $fields = array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20),
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1),
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'),
'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'),
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'),
'fk_project' =>array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1),
'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60),
'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61),
'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62),
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501),
'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60),
'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61),
'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62),
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501),
//'date_validation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502),
'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid'),
'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid'),
'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
//'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'notnull'=>-1, 'position'=>1010),
'status' =>array('type'=>'smallint', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled')),
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'notnull'=>-1, 'position'=>1010),
'status' =>array('type'=>'smallint', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled')),
);
/**
@ -214,11 +214,11 @@ class MyObject extends CommonObject
$this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0;
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0;
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0;
// Unset fields that are disabled
foreach($this->fields as $key => $val)
foreach ($this->fields as $key => $val)
{
if (isset($val['enabled']) && empty($val['enabled']))
{
@ -274,7 +274,7 @@ class MyObject extends CommonObject
// Load source object
$result = $object->fetchCommon($fromid);
if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines();
if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
// get lines so they will be clone
//foreach($this->lines as $line)
@ -287,18 +287,18 @@ class MyObject extends CommonObject
// Clear fields
$object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref: $this->fields['ref']['default'];
$object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default'];
$object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref : $this->fields['ref']['default'];
$object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
$object->status = self::STATUS_DRAFT;
// ...
// Clear extrafields that are unique
if (is_array($object->array_options) && count($object->array_options) > 0)
{
$extrafields->fetch_name_optionals_label($this->table_element);
foreach($object->array_options as $key => $option)
foreach ($object->array_options as $key => $option)
{
$shortkey = preg_replace('/options_/', '', $key);
if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey]))
if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey]))
{
//var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
unset($object->array_options[$key]);
@ -315,7 +315,7 @@ class MyObject extends CommonObject
$this->errors = $object->errors;
}
if (! $error)
if (!$error)
{
// copy internal contacts
if ($this->copy_linked_contact($object, 'internal') < 0)
@ -324,7 +324,7 @@ class MyObject extends CommonObject
}
}
if (! $error)
if (!$error)
{
// copy external contacts if same company
if (property_exists($this, 'socid') && $this->socid == $object->socid)
@ -356,7 +356,7 @@ class MyObject extends CommonObject
public function fetch($id, $ref = null)
{
$result = $this->fetchCommon($id, $ref);
if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
return $result;
}
@ -367,7 +367,7 @@ class MyObject extends CommonObject
*/
public function fetchLines()
{
$this->lines=array();
$this->lines = array();
$result = $this->fetchLinesCommon();
return $result;
@ -391,40 +391,40 @@ class MyObject extends CommonObject
dol_syslog(__METHOD__, LOG_DEBUG);
$records=array();
$records = array();
$sql = 'SELECT ';
$sql .= $this->getFieldList();
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
else $sql .= ' WHERE 1 = 1';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
if ($key=='t.rowid') {
$sqlwhere[] = $key . '='. $value;
if ($key == 't.rowid') {
$sqlwhere[] = $key.'='.$value;
}
elseif (strpos($key, 'date') !== false) {
$sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';
}
elseif ($key=='customsql') {
elseif ($key == 'customsql') {
$sqlwhere[] = $value;
}
else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
$sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
}
}
}
if (count($sqlwhere) > 0) {
$sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')';
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
}
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield, $sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit, $offset);
$sql .= ' '.$this->db->plimit($limit, $offset);
}
$resql = $this->db->query($sql);
@ -446,8 +446,8 @@ class MyObject extends CommonObject
return $records;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
return -1;
}
@ -587,51 +587,51 @@ class MyObject extends CommonObject
{
global $conf, $langs, $hookmanager;
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
$result = '';
$label = '<u>' . $langs->trans("MyObject") . '</u>';
$label.= '<br>';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
$label = '<u>'.$langs->trans("MyObject").'</u>';
$label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
$url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id;
if ($option != 'nolink')
{
// Add param to save lastsearch_values or not
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
}
$linkclose='';
$linkclose = '';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowMyObject");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
$label = $langs->trans("ShowMyObject");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
}
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
$linkstart .= $linkclose.'>';
$linkend = '</a>';
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= $this->ref;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= $this->ref;
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
global $action,$hookmanager;
global $action, $hookmanager;
$hookmanager->initHooks(array('myobjectdao'));
$parameters=array('id'=>$this->id, 'getnomurl'=>$result);
$reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint;
else $result .= $hookmanager->resPrint;
@ -687,10 +687,10 @@ class MyObject extends CommonObject
public function info($id)
{
$sql = 'SELECT rowid, date_creation as datec, tms as datem,';
$sql.= ' fk_user_creat, fk_user_modif';
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql.= ' WHERE t.rowid = '.$id;
$result=$this->db->query($sql);
$sql .= ' fk_user_creat, fk_user_modif';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
@ -701,7 +701,7 @@ class MyObject extends CommonObject
{
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
$this->user_creation = $cuser;
}
if ($obj->fk_user_valid)
@ -715,7 +715,7 @@ class MyObject extends CommonObject
{
$cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser;
$this->user_cloture = $cluser;
}
$this->date_creation = $this->db->jdate($obj->datec);
@ -749,7 +749,7 @@ class MyObject extends CommonObject
*/
public function getLinesArray()
{
$this->lines=array();
$this->lines = array();
$objectline = new MyObjectLine($this->db);
$result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_myobject = '.$this->id));
@ -780,16 +780,16 @@ class MyObject extends CommonObject
*/
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
{
global $conf,$langs;
global $conf, $langs;
$langs->load("mymodule@mymodule");
if (! dol_strlen($modele)) {
if (!dol_strlen($modele)) {
$modele = 'standard';
if ($this->modelpdf) {
$modele = $this->modelpdf;
} elseif (! empty($conf->global->MYOBJECT_ADDON_PDF)) {
} elseif (!empty($conf->global->MYOBJECT_ADDON_PDF)) {
$modele = $conf->global->MYOBJECT_ADDON_PDF;
}
}
@ -814,7 +814,7 @@ class MyObject extends CommonObject
$error = 0;
$this->output = '';
$this->error='';
$this->error = '';
dol_syslog(__METHOD__, LOG_DEBUG);

View File

@ -35,21 +35,21 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
$langs->loadLangs(array('stock', 'other', 'productbatch'));
// Get parameters
$id = GETPOST('id', 'int');
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$batch = GETPOST('batch', 'alpha');
$productid = GETPOST('productid', 'int');
$ref = GETPOST('ref', 'alpha'); // ref is productid_batch
$ref = GETPOST('ref', 'alpha'); // ref is productid_batch
$search_entity=GETPOST('search_entity', 'int');
$search_fk_product=GETPOST('search_fk_product', 'int');
$search_batch=GETPOST('search_batch', 'alpha');
$search_fk_user_creat=GETPOST('search_fk_user_creat', 'int');
$search_fk_user_modif=GETPOST('search_fk_user_modif', 'int');
$search_import_key=GETPOST('search_import_key', 'int');
$search_entity = GETPOST('search_entity', 'int');
$search_fk_product = GETPOST('search_fk_product', 'int');
$search_batch = GETPOST('search_batch', 'alpha');
$search_fk_user_creat = GETPOST('search_fk_user_creat', 'int');
$search_fk_user_modif = GETPOST('search_fk_user_modif', 'int');
$search_import_key = GETPOST('search_import_key', 'int');
if (empty($action) && empty($id) && empty($ref)) $action='list';
if (empty($action) && empty($id) && empty($ref)) $action = 'list';
// Protection if external user
@ -73,21 +73,21 @@ if ($id || $ref)
{
if ($ref)
{
$tmp=explode('_', $ref);
$productid=$tmp[0];
$batch=$tmp[1];
$tmp = explode('_', $ref);
$productid = $tmp[0];
$batch = $tmp[1];
}
$object->fetch($id, $productid, $batch);
$object->ref = $object->batch; // For document management ( it use $object->ref)
}
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('productlotcard','globalcard'));
$hookmanager->initHooks(array('productlotcard', 'globalcard'));
$permissionnote = $user->rights->stock->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->stock->creer; // Used by the include of actions_dellink.inc.php
$permissiontoadd = $user->rights->stock->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissionnote = $user->rights->stock->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->stock->creer; // Used by the include of actions_dellink.inc.php
$permissiontoadd = $user->rights->stock->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$usercanread = $user->rights->produit->lire;
$usercancreate = $user->rights->produit->creer;
@ -97,8 +97,8 @@ $usercandelete = $user->rights->produit->supprimer;
* Actions
*/
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
@ -112,7 +112,7 @@ if (empty($reshook))
if ($action == 'setsellby' && $user->rights->stock->creer)
{
$newvalue=dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']);
$newvalue = dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']);
$result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
if ($result < 0) dol_print_error($db, $object->error);
}
@ -125,7 +125,7 @@ if (empty($reshook))
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)
if (!$error)
{
// Actions on extra fields
$result = $object->insertExtraFields('PRODUCT_LOT_MODIFY');
@ -145,21 +145,21 @@ if (empty($reshook))
{
if (GETPOST('cancel', 'alpha'))
{
$urltogo=$backtopage?$backtopage:dol_buildpath('/stock/list.php', 1);
$urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1);
header("Location: ".$urltogo);
exit;
}
$error=0;
$error = 0;
/* object_prop_getpost_prop */
$object->entity=GETPOST('entity', 'int');
$object->fk_product=GETPOST('fk_product', 'int');
$object->batch=GETPOST('batch', 'alpha');
$object->fk_user_creat=GETPOST('fk_user_creat', 'int');
$object->fk_user_modif=GETPOST('fk_user_modif', 'int');
$object->import_key=GETPOST('import_key', 'int');
$object->entity = GETPOST('entity', 'int');
$object->fk_product = GETPOST('fk_product', 'int');
$object->batch = GETPOST('batch', 'alpha');
$object->fk_user_creat = GETPOST('fk_user_creat', 'int');
$object->fk_user_modif = GETPOST('fk_user_modif', 'int');
$object->import_key = GETPOST('import_key', 'int');
if (empty($object->ref))
{
@ -167,43 +167,43 @@ if (empty($reshook))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
}
if (! $error)
if (!$error)
{
$result=$object->create($user);
$result = $object->create($user);
if ($result > 0)
{
// Creation OK
$urltogo=$backtopage?$backtopage:dol_buildpath('/stock/list.php', 1);
$urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1);
header("Location: ".$urltogo);
exit;
}
{
// Creation KO
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
$action='create';
$action = 'create';
}
}
else
{
$action='create';
$action = 'create';
}
}
// Cancel
if ($action == 'update' && GETPOST('cancel', 'alpha')) $action='view';
if ($action == 'update' && GETPOST('cancel', 'alpha')) $action = 'view';
// Action to update record
if ($action == 'update' && ! GETPOST('cancel', 'alpha'))
if ($action == 'update' && !GETPOST('cancel', 'alpha'))
{
$error=0;
$error = 0;
$object->entity=GETPOST('entity', 'int');
$object->fk_product=GETPOST('fk_product', 'int');
$object->batch=GETPOST('batch', 'alpha');
$object->fk_user_creat=GETPOST('fk_user_creat', 'int');
$object->fk_user_modif=GETPOST('fk_user_modif', 'int');
$object->import_key=GETPOST('import_key', 'int');
$object->entity = GETPOST('entity', 'int');
$object->fk_product = GETPOST('fk_product', 'int');
$object->batch = GETPOST('batch', 'alpha');
$object->fk_user_creat = GETPOST('fk_user_creat', 'int');
$object->fk_user_modif = GETPOST('fk_user_modif', 'int');
$object->import_key = GETPOST('import_key', 'int');
if (empty($object->ref))
{
@ -211,31 +211,31 @@ if (empty($reshook))
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
}
if (! $error)
if (!$error)
{
$result=$object->update($user);
$result = $object->update($user);
if ($result > 0)
{
$action='view';
$action = 'view';
}
else
{
// Creation KO
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
$action='edit';
$action = 'edit';
}
}
else
{
$action='edit';
$action = 'edit';
}
}
// Action to delete
if ($action == 'confirm_delete')
{
$result=$object->delete($user);
$result = $object->delete($user);
if ($result > 0)
{
// Delete OK
@ -245,7 +245,7 @@ if (empty($reshook))
}
else
{
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
}
}
@ -265,7 +265,7 @@ if (empty($reshook))
llxHeader('', 'ProductLot', '');
$form=new Form($db);
$form = new Form($db);
// Part to create
@ -310,15 +310,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($action == 'delete') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteBatch'), $langs->trans('ConfirmDeleteBatch'), 'confirm_delete', '', 0, 1);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBatch'), $langs->trans('ConfirmDeleteBatch'), 'confirm_delete', '', 0, 1);
print $formconfirm;
}
$linkback = '<a href="' . DOL_URL_ROOT . '/product/stock/productlot_list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$shownav = 1;
if ($user->socid && ! in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0;
if ($user->socid && !in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch');
@ -352,7 +352,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Other attributes
$cols = 2;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
print '</table>';
@ -363,8 +363,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Buttons
print '<div class="tabsAction">'."\n";
$parameters=array();
$reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
@ -403,12 +403,12 @@ if (empty($action))
// Documents
$filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product_batch').dol_sanitizeFileName($object->ref);
$urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed=$usercanread;
$delallowed=$usercancreate;
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = $usercanread;
$delallowed = $usercancreate;
print $formfile->showdocuments('product_batch', dol_sanitizeFileName($object->ref), $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object);
$somethingshown=$formfile->numoffiles;
$somethingshown = $formfile->numoffiles;
print '</div>';
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff