Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into develop

This commit is contained in:
florian HENRY 2017-01-06 14:48:05 +01:00
commit c8c78dc9cf
117 changed files with 2840 additions and 1121 deletions

155
ChangeLog
View File

@ -152,6 +152,52 @@ Dolibarr better:
- The trigger that activate or close a contract line is run on a contract line, not on contract.
***** ChangeLog for 4.0.3 to 4.0.2 *****
FIX: #5853 $conf->global->$calc==0 || $conf->global->$calc==1
FIX: #5958 no discount on supplier command made by replenishment
FIX: #5966 Bug: getNomUrl tooltips show Proposal info even if user has no rights to read them
FIX: #5972 #5734
FIX: #6007
FIX: #6010
FIX: #6029
FIX: #6043 - Payment mode not visible on supplier invoice list
FIX: #6051
FIX: #6062
FIX: #6088
FIX: A draft can be deleted by a user with create permission.
FIX: bad permission to see contract on home page
FIX: bad permission to see contract statistics
FIX: Bcc must not appears to recipient when using SMTPs lib
FIX: Consistent description for add or edit product
FIX: delete contract extrafields on contract deletion
FIX: Deposits and credit notes weren't added in the received and pending columns
FIX: export extrafields must not include separe type
FIX: Export of opportunity status must be code, not id.
FIX: False positive on services not activated
FIX: Filter was wrong or lost during navigation
FIX: HT and TTC price should always be displayed together
FIX: if a supplier price reference is changed after creating an order, we can't clone order.
FIX: in export. Error when using a separate extrafields.
FIX: Introduce hidden option MAIL_PREFIX_FOR_EMAIL_ID to solve pb of tracking email.
FIX: javascript error when using on mobile/smartphone
FIX: javascript xss injection and a translation
FIX: Label of project is in field title not label.
FIX: List of people able to validate an expense report was not complete.
FIX: Missing field
FIX: Module gravatar was not triggered on thirdparty and contact card
FIX: Must use external link into a forged email content.
FIX: Pb in management of date end of projects
FIX: Regression when deleting product
FIX: rendering of output of estimated amount on project overview page.
FIX: Sanitize title of ajax_dialog
FIX: Security to restrict email sending was not efficient
FIX: Setting supplier as client when accept a supplier proposal
FIX: Some statistics not compatible with multicompany module.
FIX: the time spent on project was not visible in its overwiew
FIX: Update intervention lline crash with PgSQL
FIX: wrong test on dict.php
FIX: wrong var name
***** ChangeLog for 4.0.2 compared to 4.0.1 *****
FIX: #5340
FIX: #5779
@ -357,6 +403,115 @@ So if you included it into your module, change your code like this to be compati
if (! $res) include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
***** ChangeLog for 3.9.4 compared to 3.9.3 *****
FIX: #2853
FIX: #3128
FIX: #4447
FIX: #5128 if create method return duplicated code error not use GETPOST in order to get a new code
FIX: #5340
FIX: #5473
FIX: #5474 Country_id of "Don" object is still empty
FIX: #5534
FIX: #5535 bad dependency.
FIX: #5537 AJAX project search does not work properly
FIX: #5540 getFormMail is not registered as addReplace hook
FIX: #5544 Disabled Contact still appear in lists to send emails
FIX: #5549 getNomUrl tooltips show Order info even if user has no rights to read them
FIX: #5568
FIX: #5594
FIX: #5629 PgSQL Interger string stylish error
FIX: #5651
FIX: #5660
FIX: #5853 $conf->global->$calc==0 || $conf->global->$calc==1
FIX: #5907
FIX: #5966 Bug: getNomUrl tooltips show Proposal info even if user has no rights to read them
FIX: #6051
FIX: #6088
FIX: Can correct stock of lot using eatby or sell by date
FIX: Can make a movement on "out of sell" products
FIX: cannot update bank account on invoice if module order not activated
FIX: Can't create withdrawal document
FIX: delete contract extrafields on contract deletion
FIX: Direction of movement lost if an error occurs
FIX: Error when CATEGORIE_RECURSIV_ADD is enabled and new category is daughter of an already linked to object
FIX: export extrafields must not include separe type
FIX: External user must not be able to edit its discounts
FIX: Failed to export contact categories with contact extra fields
FIX: header title in commercial area
FIX: HT and TTC price should always be displayed together
FIX: incoterms
FIX: incoterms do not output into crabe invoice PDF
FIX: in PgSQL no quote "word style" is permitted around column name
FIX: Introduce hidden option MAIL_PREFIX_FOR_EMAIL_ID to solve pb of tracking email.
FIX: margin tab on customer card must filter on current entity invoices
FIX: missing column into SQL on thridparty list
FIX: only show projects of related third if external user
FIX: PgSQL Module Ressource list crash #5637
FIX: php Strict
FIX: Regression when deleting product
FIX: Security to restrict email sending was not efficient
FIX: tag for date rfc in odt substitution
FIX: Update intervention lline crash with PgSQL
FIX: update limit stock on product stock
FIX: vat dictionary should allow enter and edit multiple values for localtaxes, separated by: (ex -19:-15)
FIX: wrong test on dict.php
***** ChangeLog for 3.9.4 compared to 3.9.3 *****
FIX: #2853
FIX: #3128
FIX: #4447
FIX: #5128 if create method return duplicated code error not use GETPOST in order to get a new code
FIX: #5340
FIX: #5473
FIX: #5474 Country_id of "Don" object is still empty
FIX: #5534
FIX: #5535 bad dependency.
FIX: #5537 AJAX project search does not work properly
FIX: #5540 getFormMail is not registered as addReplace hook
FIX: #5544 Disabled Contact still appear in lists to send emails
FIX: #5549 getNomUrl tooltips show Order info even if user has no rights to read them
FIX: #5568
FIX: #5594
FIX: #5629 PgSQL Interger string stylish error
FIX: #5651
FIX: #5660
FIX: #5853 $conf->global->$calc==0 || $conf->global->$calc==1
FIX: #5907
FIX: #5966 Bug: getNomUrl tooltips show Proposal info even if user has no rights to read them
FIX: #6051
FIX: #6088
FIX: Can correct stock of lot using eatby or sell by date
FIX: Can make a movement on "out of sell" products
FIX: cannot update bank account on invoice if module order not activated
FIX: Can't create withdrawal document
FIX: delete contract extrafields on contract deletion
FIX: Direction of movement lost if an error occurs
FIX: Error when CATEGORIE_RECURSIV_ADD is enabled and new category is daughter of an already linked to object
FIX: export extrafields must not include separe type
FIX: External user must not be able to edit its discounts
FIX: Failed to export contact categories with contact extra fields
FIX: header title in commercial area
FIX: HT and TTC price should always be displayed together
FIX: incoterms
FIX: incoterms do not output into crabe invoice PDF
FIX: in PgSQL no quote "word style" is permitted around column name
FIX: Introduce hidden option MAIL_PREFIX_FOR_EMAIL_ID to solve pb of tracking email.
FIX: margin tab on customer card must filter on current entity invoices
FIX: missing column into SQL on thridparty list
FIX: only show projects of related third if external user
FIX: PgSQL Module Ressource list crash #5637
FIX: php Strict
FIX: Regression when deleting product
FIX: Security to restrict email sending was not efficient
FIX: tag for date rfc in odt substitution
FIX: Update intervention lline crash with PgSQL
FIX: update limit stock on product stock
FIX: vat dictionary should allow enter and edit multiple values for localtaxes, separated by: (ex -19:-15)
FIX: wrong test on dict.php
***** ChangeLog for 3.9.3 compared to 3.9.2 *****
FIX: #4383 $userid not defined
FIX: #4448 $filebonprev is not used, $this->filename now

22
build/generate_filelist_xml.php Normal file → Executable file
View File

@ -65,6 +65,8 @@ fputs($fp, '<checksum_list version="'.$release.'">'."\n");
fputs($fp, '<dolibarr_htdocs_dir>'."\n");
$checksumconcat=array();
$dir_iterator1 = new RecursiveDirectoryIterator(dirname(__FILE__).'/../htdocs/');
$iterator1 = new RecursiveIteratorIterator($dir_iterator1);
// need to ignore document custom etc
@ -81,12 +83,22 @@ foreach ($files as $file) {
$needtoclose=1;
}
if (filetype($file)=="file") {
fputs($fp, '<md5file name="'.basename($file).'">'.md5_file($file).'</md5file>'."\n");
$md5=md5_file($file);
$checksumconcat[]=$md5;
fputs($fp, '<md5file name="'.basename($file).'">'.$md5.'</md5file>'."\n");
}
}
fputs($fp, '</dir>'."\n");
fputs($fp, '</dolibarr_htdocs_dir>'."\n");
asort($checksumconcat); // Sort list of checksum
//var_dump($checksumconcat);
fputs($fp, '<dolibarr_htdocs_dir_checksum>'."\n");
fputs($fp, md5(join(',',$checksumconcat))."\n");
fputs($fp, '</dolibarr_htdocs_dir_checksum>'."\n");
$checksumconcat=array();
fputs($fp, '<dolibarr_script_dir version="'.$release.'">'."\n");
@ -106,12 +118,18 @@ foreach ($files as $file) {
$needtoclose=1;
}
if (filetype($file)=="file") {
fputs($fp, '<md5file name="'.basename($file).'">'.md5_file($file).'</md5file>'."\n");
$md5=md5_file($file);
$checksumconcat[]=$md5;
fputs($fp, '<md5file name="'.basename($file).'">'.$md5.'</md5file>'."\n");
}
}
fputs($fp, '</dir>'."\n");
fputs($fp, '</dolibarr_script_dir>'."\n");
asort($checksumconcat); // Sort list of checksum
fputs($fp, '<dolibarr_script_dir_checksum>'."\n");
fputs($fp, md5(join(',',$checksumconcat))."\n");
fputs($fp, '</dolibarr_script_dir_checksum>'."\n");
fputs($fp, '</checksum_list>'."\n");
fclose($fp);

View File

@ -303,7 +303,7 @@ foreach($property as $key => $prop)
$varprop.="\$this->db->escape(\$this->".$prop['field'].")";
$varprop.=".\"'\")";
}
elseif ($prop['field']=='fk_user_mod' || $prop['field']=='fk_user_author')
elseif ($prop['field']=='fk_user_mod' || $prop['field']=='fk_user_m' || $prop['field']=='fk_user_author')
{
$varprop.="'.\$user->id";
}
@ -367,7 +367,7 @@ foreach($property as $key => $prop)
$varprop.=')."\'" : \'null\')';
}
elseif ($prop['field']=='fk_user_mod') {
elseif ($prop['field']=='fk_user_mod' || $prop['field']=='fk_user_m') {
$varprop.="'.\$user->id";
}
else

View File

@ -188,11 +188,13 @@ class Skeleton_Class extends CommonObject
// Retrieve all extrafields for invoice
// fetch optionals attributes and labels
/*
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
*/
// $this->fetch_lines();
$this->db->free($resql);
@ -251,23 +253,19 @@ class Skeleton_Class extends CommonObject
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
$sql .= ' ' . $this->db->plimit($limit, $offset);
}
$this->lines = array();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) {
$line = new Skeleton_ClassLine();
$line = new self($this->db);
$line->id = $obj->rowid;
$line->prop1 = $obj->field1;
$line->prop2 = $obj->field2;
$this->lines[$line->id] = $line;
//...
}
$this->db->free($resql);

View File

@ -357,7 +357,7 @@ class AccountancyExport
$Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_compte, 20), 20);
$Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+';
$Tab['montant'] = str_pad(abs($data->montant) * 100, 12, '0', STR_PAD_LEFT); // TODO manage negative amount
$Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
$Tab['contrepartie'] = str_repeat(' ', 8);
if (! empty($data->date_echeance))
$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE);

View File

@ -83,6 +83,8 @@ class FormVentilation extends Form
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
$out = '';
$options = array();
if ($usecache && ! empty($this->options_cache[$usecache]))
{
@ -109,7 +111,7 @@ class FormVentilation extends Form
return -1;
}
$out = ajax_combobox($htmlname, $event);
$out .= ajax_combobox($htmlname, $event);
$selected = 0;
while ($obj = $this->db->fetch_object($resql))

View File

@ -91,10 +91,10 @@ if ($action == 'add' && $user->rights->adherent->configurer)
$object = new AdherentType($db);
$object->libelle = trim($label);
$object->subscription = trim($subscription);
$object->subscription = (int) trim($subscription);
$object->note = trim($comment);
$object->mail_valid = trim($mail_valid);
$object->vote = trim($vote);
$object->mail_valid = (boolean) trim($mail_valid);
$object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
@ -129,10 +129,10 @@ if ($action == 'update' && $user->rights->adherent->configurer)
$object = new AdherentType($db);
$object->id = $rowid;
$object->libelle = trim($label);
$object->subscription = trim($subscription);
$object->subscription = (int) trim($subscription);
$object->note = trim($comment);
$object->mail_valid = trim($mail_valid);
$object->vote = trim($vote);
$object->mail_valid = (boolean) trim($mail_valid);
$object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);

View File

@ -1274,6 +1274,7 @@ if ($id)
// Title line with search boxes
print '<tr class="liste_titre">';
$filterfound=0;
foreach ($fieldlist as $field => $value)
{
$showfield=1; // By defaut
@ -1284,21 +1285,25 @@ if ($id)
{
if ($value == 'country')
{
print '<td>';
print '<td class="liste_titre">';
print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
print '</td>';
$filterfound++;
}
else
{
print '<td></td>';
print '<td class="liste_titre"></td>';
}
}
}
if ($id == 4) print '<td></td>';
print '<td></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre" colspan="2" align="right">';
$searchpitco=$form->showFilterAndCheckAddButtons(0);
print $searchpitco;
if ($filterfound)
{
$searchpitco=$form->showFilterAndCheckAddButtons(0);
print $searchpitco;
}
print '</td>';
print '</tr>';
@ -1314,19 +1319,17 @@ if ($id)
print '<tr '.$bc[$var].' id="rowid-'.$obj->rowid.'">';
if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
{
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
$tmpaction='edit';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
// Show fields
if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit');
print '<td colspan="3" align="center">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';

View File

@ -619,6 +619,12 @@ else
print '</div>';
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail')
{
$text = $langs->trans("WarningPHPMail");
print info_admin($text);
}
// Run the test to connect
if ($action == 'testconnect')
{

View File

@ -75,9 +75,9 @@ $file_list = array('missing' => array(), 'updated' => array());
// File to analyze
//$xmlfile = DOL_DOCUMENT_ROOT.'/install/filelist-'.DOL_VERSION.'.xml';
$xmlshortfile = '/install/filelist-'.DOL_VERSION.'.xml';
$xmlshortfile = GETPOST('xmlshortfile')?GETPOST('xmlshortfile'):'/install/filelist-'.DOL_VERSION.'.xml';
$xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile;
$xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml';
$xmlremote = GETPOST('xmlremote')?GETPOST('xmlremote'):'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml';
// Test if remote test is ok
@ -87,21 +87,27 @@ if (preg_match('/beta|alpha/i', DOL_VERSION)) $enableremotecheck=False;
print '<form name="check" action="'.$_SERVER["PHP_SELF"].'">';
print $langs->trans("MakeIntegrityAnalysisFrom").':<br>';
print '<!-- for a local check target=local&xmlshortfile=... -->'."\n";
if (dol_is_file($xmlfile))
{
print '<input type="radio" name="target" value="local"'.((! GETPOST('target') || GETPOST('target') == 'local') ? 'checked="checked"':'').'"> '.$langs->trans("LocalSignature").' = '.$xmlshortfile.'<br>';
}
else
{
print '<input type="radio" name="target" value="local"> '.$langs->trans("LocalSignature").' = '.$xmlshortfile.' <span class="warning">('.$langs->trans("AvailableOnlyOnPackagedVersions").')</span><br>';
print '<input type="radio" name="target" value="local"> '.$langs->trans("LocalSignature").' = '.$xmlshortfile;
if (! GETPOST('xmlshortfile')) print ' <span class="warning">('.$langs->trans("AvailableOnlyOnPackagedVersions").')</span>';
print '<br>';
}
print '<!-- for a remote target=remote&xmlremote=... -->'."\n";
if ($enableremotecheck)
{
print '<input type="radio" name="target" value="remote"'.(GETPOST('target') == 'remote' ? 'checked="checked"':'').'> '.$langs->trans("RemoteSignature").' = '.$xmlremote.'<br>';
}
else
{
print '<input type="radio" name="target" value="remote" disabled="disabled"> '.$langs->trans("RemoteSignature").' = '.$xmlremote.' <span class="warning">('.$langs->trans("FeatureAvailableOnlyOnStable").')</span><br>';
print '<input type="radio" name="target" value="remote" disabled="disabled"> '.$langs->trans("RemoteSignature").' = '.$xmlremote;
if (! GETPOST('xmlremote')) print ' <span class="warning">('.$langs->trans("FeatureAvailableOnlyOnStable").')</span>';
print '<br>';
}
print '<br><div class="center"><input type="submit" name="check" class="button" value="'.$langs->trans("Check").'"></div>';
print '</form>';
@ -128,7 +134,8 @@ if (GETPOST('target') == 'remote')
if (! $xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404')
{
$xmlfile = $xmlarray['content'];
$xml = simplexml_load_file($xmlfile);
//print "eee".$xmlfile."eee";
$xml = simplexml_load_string($xmlfile);
}
else
{
@ -141,11 +148,14 @@ if (GETPOST('target') == 'remote')
if ($xml)
{
$checksumconcat = array();
// Scan htdocs
if (is_object($xml->dolibarr_htdocs_dir[0]))
{
$file_list = array();
$ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0]); // Fill array $file_list
$file_list = array();
$ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list
print '<table class="noborder">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("FilesMissing") . '</td>';
@ -181,10 +191,10 @@ if ($xml)
print '<td align="right">' . $langs->trans("DateModification") . '</td>';
print '</tr>'."\n";
$var = true;
$tmpfilelist = dol_sort_array($file_list['updated'], 'filename');
if (is_array($tmpfilelist) && count($tmpfilelist))
$tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename');
if (is_array($tmpfilelist2) && count($tmpfilelist2))
{
foreach ($tmpfilelist as $file)
foreach ($tmpfilelist2 as $file)
{
$var = !$var;
print '<tr ' . $bc[$var] . '>';
@ -201,12 +211,44 @@ if ($xml)
print '<tr ' . $bc[false] . '><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
print '</table>';
if (empty($tmpfilelist) && empty($tmpfilelist2))
{
setEventMessage($langs->trans("FileIntegrityIsStrictlyConformedWithReference"));
}
else
{
setEventMessage($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), 'warnings');
}
}
else
{
print 'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile;
$error++;
}
// Scan scripts
/*
if (is_object($xml->dolibarr_script_dir[0]))
{
$file_list = array();
$ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', ???, $checksumconcat); // Fill array $file_list
}*/
asort($checksumconcat); // Sort list of checksum
//var_dump($checksumconcat);
$checksumget = md5(join(',',$checksumconcat));
$checksumtoget = $xml->dolibarr_htdocs_dir_checksum;
if ($checksumtoget)
{
print '<br>';
print '<strong>'.$langs->trans("GlobalChecksum").'</strong><br>';
print $langs->trans("ExpectedChecksum").' = '.$checksumtoget.'<br>';
print $langs->trans("CurrentChecksum").' = '.$checksumget;
}
}
@ -223,12 +265,14 @@ exit($error);
* Function to get list of updated or modified files.
* $file_list is used as global variable
*
* @param array $file_list Array for response
* @param SimpleXMLElement $dir SimpleXMLElement of files to test
* @param string $path Path of file
* @return array Array of filenames
* @param array $file_list Array for response
* @param SimpleXMLElement $dir SimpleXMLElement of files to test
* @param string $path Path of files relative to $pathref. We start with ''. Used by recursive calls.
* @param string $pathref Path ref (DOL_DOCUMENT_ROOT)
* @param array $checksumconcat Array of checksum
* @return array Array of filenames
*/
function getFilesUpdated(&$file_list, SimpleXMLElement $dir, $path = '')
function getFilesUpdated(&$file_list, SimpleXMLElement $dir, $path = '', $pathref = '', &$checksumconcat = array())
{
$exclude = 'install';
@ -236,20 +280,21 @@ function getFilesUpdated(&$file_list, SimpleXMLElement $dir, $path = '')
{
$filename = $path.$file['name'];
if (preg_match('#'.$exclude.'#', $filename)) continue;
//if (preg_match('#'.$exclude.'#', $filename)) continue;
if (!file_exists(DOL_DOCUMENT_ROOT.'/'.$filename))
if (!file_exists($pathref.'/'.$filename))
{
$file_list['missing'][] = array('filename'=>$filename, 'expectedmd5'=>(string) $file);
}
else
{
$md5_local = md5_file(DOL_DOCUMENT_ROOT.'/'.$filename);
$md5_local = md5_file($pathref.'/'.$filename);
if ($md5_local != (string) $file) $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>(string) $file, 'md5'=>(string) $md5_local);
}
$checksumconcat[] = $md5_local;
}
}
foreach ($dir->dir as $subdir) getFilesUpdated($file_list, $subdir, $path.$subdir['name'].'/');
foreach ($dir->dir as $subdir) getFilesUpdated($file_list, $subdir, $path.$subdir['name'].'/', $pathref, $checksumconcat);
return $file_list;
}

View File

@ -105,7 +105,7 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update'))
}
if (! $error)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."overwrite_trans(lang, transkey, transvalue) VALUE ('".$db->escape($langcode)."','".$db->escape($transkey)."','".$db->escape($transvalue)."')";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."overwrite_trans(lang, transkey, transvalue) VALUES ('".$db->escape($langcode)."','".$db->escape($transkey)."','".$db->escape($transvalue)."')";
$result = $db->query($sql);
if ($result > 0)
{

View File

@ -37,7 +37,7 @@ class Facturation
* int $prix => Prix HT du produit en cours
* int $tva => 'rowid' du taux de tva dans llx_c_tva
*/
var $id;
public $id;
protected $ref;
protected $qte;
protected $stock;

View File

@ -278,7 +278,7 @@ if ($action == 'add')
if (GETPOST("doneby") > 0) $object->userdoneid = GETPOST("doneby","int");
}
$object->note = trim($_POST["note"]);
$object->note = trim(GETPOST("note"));
if (isset($_POST["contactid"])) $object->contact = $contact;
@ -290,11 +290,6 @@ if ($action == 'add')
$object->societe = $object->thirdparty; // For backward compatibility
}
// Special for module webcal and phenix
// TODO external modules
if (! empty($conf->webcalendar->enabled) && GETPOST('add_webcal') == 'on') $object->use_webcal=1;
if (! empty($conf->phenix->enabled) && GETPOST('add_phenix') == 'on') $object->use_phenix=1;
// Check parameters
if (empty($object->userownerid) && empty($_SESSION['assignedtouser']))
{

View File

@ -656,7 +656,7 @@ foreach ($typeofevents as $typeofevent)
if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1;
if ($today) $style='cal_today_peruser';
show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
show_day_events_pertype($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
$i++;
}
@ -756,7 +756,7 @@ $db->close();
* @param bool $var true or false for alternat style on tr/td
* @return void
*/
function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false, $colorsbytype=array(), $var=false)
function show_day_events_pertype($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false, $colorsbytype=array(), $var=false)
{
global $db;
global $user, $conf, $langs, $hookmanager, $action;

View File

@ -756,8 +756,9 @@ else
$sendingmode=$conf->global->MAIN_MAIL_SENDMODE;
if (empty($sendingmode)) $sendingmode='mail'; // If not defined, we use php mail function
// MAILING_NO_USING_PHPMAIL may be defined or not
// MAILING_LIMIT_SENDBYWEB is always defined to something != 0, MAILING_LIMIT_SENDBYCLI may be defined ot not.
// MAILING_NO_USING_PHPMAIL may be defined or not.
// MAILING_LIMIT_SENDBYWEB is always defined to something != 0 (-1=forbidden).
// MAILING_LIMIT_SENDBYCLI may be defined ot not (-1=forbidden, 0=no limit).
if (! empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail')
{
// EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent.
@ -797,7 +798,7 @@ else
}
$text.=$langs->trans('ConfirmSendingEmailing').'<br>';
$text.=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('SendMailing'),$text,'sendallconfirmed',$formquestion,'',1,270);
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('SendMailing'),$text,'sendallconfirmed',$formquestion,'',1,300);
}
}
@ -844,23 +845,28 @@ else
print $langs->trans("TotalNbOfDistinctRecipients");
print '</td><td colspan="3">';
$nbemail = ($object->nbemail?$object->nbemail:img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>');
if ($object->statut != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && is_numeric($nbemail) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
if ($object->statut != 3 && is_numeric($nbemail))
{
if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
{
$text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
print $form->textwithpicto($nbemail,$text,1,'warning');
}
else
{
$text=$langs->trans('NotEnoughPermissions');
print $form->textwithpicto($nbemail,$text,1,'warning');
}
}
else
{
print $nbemail;
$text='';
if (! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
{
if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
{
$text.=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
}
else
{
$text.=$langs->trans('NotEnoughPermissions');
}
}
if ($text)
{
print $form->textwithpicto($nbemail,$text,1,'warning');
}
else
{
print $nbemail;
}
}
print '</td></tr>';

View File

@ -2025,7 +2025,7 @@ if ($action == 'create')
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
if($object->statut == 0) {
if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code != $conf->currency) {
print '<div class="inline-block"> &nbsp; &nbsp; &nbsp; &nbsp; ';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>';
print '</div>';

View File

@ -132,9 +132,9 @@ if ($id > 0 || ! empty($ref))
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
$cssclass="titlefield";
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print '</div>';
print '</div>';
dol_fiche_end();

View File

@ -2219,7 +2219,7 @@ if ($action == 'create' && $user->rights->commande->creer)
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
if($object->statut == 0) {
if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code != $conf->currency) {
print '<div class="inline-block"> &nbsp; &nbsp; &nbsp; &nbsp; ';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>';
print '</div>';

View File

@ -1061,7 +1061,8 @@ if ($resql)
$text_info='';
$text_warning='';
$nbprod=0;
// Ref
if (! empty($arrayfields['c.ref']['checked']))
{
print '<td class="nowrap">';
@ -1186,12 +1187,12 @@ if ($resql)
print '</td>';
}
// Warning late icon
// Warning late icon and note
print '<td class="nobordernopadding nowrap">';
if ($generic_commande->hasDelay()) {
print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning");
}
if(!empty($obj->note_private))
if (!empty($obj->note_private) || !empty($obj->note_public))
{
print ' <span class="note">';
print '<a href="'.DOL_URL_ROOT.'/commande/note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'</a>';

View File

@ -1345,8 +1345,16 @@ if (empty($reshook))
setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
$error ++;
}
if (! GETPOST('prod_entry_mode'))
{
if (GETPOST('type') < 0 && ! GETPOST('search_idprod'))
{
setEventMessages($langs->trans('ErrorChooseBetweenFreeAntryOrPredefinedProduct'), null, 'errors');
$error ++;
}
}
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
$error ++;
}
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '') && $price_ht_devise == '') // Unit price can be 0 but not ''
@ -3257,7 +3265,7 @@ else if ($id > 0 || ! empty($ref))
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
if($object->statut == 0) {
if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code != $conf->currency) {
print '<div class="inline-block"> &nbsp; &nbsp; &nbsp; &nbsp; ';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>';
print '</div>';
@ -3723,7 +3731,7 @@ else if ($id > 0 || ! empty($ref))
else
print $langs->trans('ExcessReceived');
print ' :</td>';
print '<td align="right"'.($resteapayeraffiche?' class="amountremaintopay"':$cssforamountpaymentcomplete).'>' . price($resteapayeraffiche) . '</td>';
print '<td align="right"'.($resteapayeraffiche?' class="amountremaintopay"':(' class="'.$cssforamountpaymentcomplete.'"')).'>' . price($resteapayeraffiche) . '</td>';
print '<td class="nowrap">&nbsp;</td></tr>';
}
else // Credit note

View File

@ -867,18 +867,20 @@ if ($resql)
$facturestatic->type=$obj->type;
$facturestatic->statut=$obj->fk_statut;
$facturestatic->date_lim_reglement=$db->jdate($obj->datelimite);
$facturestatic->type=$obj->type;
$facturestatic->note_public=$obj->note_public;
$facturestatic->note_private=$obj->note_private;
$paiement = $facturestatic->getSommePaiement();
$totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
$totaldeposits = $facturestatic->getSumDepositsUsed();
$totalpay = $paiement + $totalcreditnotes + $totaldeposits;
$remaintopay = $obj->total_ttc - $totalpay;
print '<tr '.$bc[$var].'>';
if (! empty($arrayfields['f.facnumber']['checked']))
{
print '<td class="nowrap">';
$paiement = $facturestatic->getSommePaiement();
$remaintopay = $obj->total_ttc - $paiement;
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding nowrap">';
@ -1028,10 +1030,10 @@ if ($resql)
if (! empty($arrayfields['dynamount_payed']['checked']))
{
print '<td align="right">'.(! empty($paiement)?price($paiement,0,$langs):'&nbsp;').'</td>'; // TODO Use a denormalized field
print '<td align="right">'.(! empty($totalpay)?price($totalpay,0,$langs):'&nbsp;').'</td>'; // TODO Use a denormalized field
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalamfield']=$totalarray['nbfield'];
$totalarray['totalam'] += $paiement;
$totalarray['totalam'] += $totalpay;
}
if (! empty($arrayfields['rtp']['checked']))

View File

@ -39,10 +39,6 @@ class Cpaiement
*/
public $table_element = 'c_paiement';
/**
* @var CpaiementLine[] Lines
*/
public $lines = array();
/**
*/
@ -227,84 +223,6 @@ class Cpaiement
}
}
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
* @param string $filtermode filter mode (AND or OR)
*
* @return int <0 if KO, >0 if OK
*/
public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
$sql .= ' t.id,';
$sql .= " t.code,";
$sql .= " t.libelle,";
$sql .= " t.type,";
$sql .= " t.active,";
$sql .= " t.accountancy_code,";
$sql .= " t.module";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
}
if (count($sqlwhere) > 0) {
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
}
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$this->lines = array();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) {
$line = new CpaiementLine();
$line->id = $obj->id;
$line->code = $obj->code;
$line->libelle = $obj->libelle;
$line->type = $obj->type;
$line->active = $obj->active;
$line->accountancy_code = $obj->accountancy_code;
$line->module = $obj->module;
$this->lines[$line->id] = $line;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Update object into database
*

View File

@ -30,14 +30,14 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
$langs->load("companies");
if (! empty($conf->facture->enabled)) $langs->load("bills");
// Security check
$socid = GETPOST("socid",'int');
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
$id = GETPOST('id')?GETPOST('id','int'):GETPOST('socid','int');
// Security check
if ($user->societe_id) $id=$user->societe_id;
$result = restrictedArea($user, 'societe', $id, '&societe');
$object = new Societe($db);
if ($id > 0) $object->fetch($id);
/*
@ -47,20 +47,21 @@ if ($user->societe_id > 0)
$form = new Form($db);
$userstatic=new User($db);
llxHeader();
$title=$langs->trans("ThirdParty").' - '.$langs->trans("Summary");
if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Symmary");
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
if ($socid > 0)
llxHeader('',$title,$help_url);
if ($id > 0)
{
$societe = new Societe($db);
$societe->fetch($socid);
/*
* Affichage onglets
*/
$head = societe_prepare_head($societe);
$head = societe_prepare_head($object);
dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company');
dol_banner_tab($societe, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 1);
dol_fiche_end();
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
@ -86,7 +87,7 @@ if ($socid > 0)
$sql.= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
$sql.= " u.login, u.rowid as userid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id;
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id;
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.fk_user_valid = u.rowid";
$sql.= " ORDER BY f.datef ASC";

View File

@ -646,7 +646,7 @@ print '<tr class="liste_titre"><td class="liste_titre">&nbsp;</td>';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
print '<td align="center" colspan="2" class="borderrightlight">';
print '<td align="center" colspan="2" class="liste_titre borderrightlight">';
print '<a href="clientfourn.php?year='.$annee.'">';
print $annee;
if ($conf->global->SOCIETE_FISCAL_MONTH_START > 1) print '-'.($annee+1);
@ -656,8 +656,8 @@ print '</tr>';
print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Month").'</td>';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
print '<td align="center">'.$langs->trans("Outcome").'</td>';
print '<td align="center" class="borderrightlight">'.$langs->trans("Income").'</td>';
print '<td class="liste_titre" align="center">'.$langs->trans("Outcome").'</td>';
print '<td class="liste_titre" align="center" class="borderrightlight">'.$langs->trans("Income").'</td>';
}
print '</tr>';
@ -678,7 +678,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
if($mois>12) {$annee_decalage=$annee+1;}
$case = strftime("%Y-%m",dol_mktime(12,0,0,$mois_modulo,1,$annee_decalage));
print '<td align="right">&nbsp;';
print '<td class="liste_titre" align="right">&nbsp;';
if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0)
{
print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">'.price(price2num($decaiss_ttc[$case],'MT')).'</a>';
@ -687,7 +687,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
}
print "</td>";
print '<td align="right" class="borderrightlight">&nbsp;';
print '<td align="right" class="liste_titre borderrightlight">&nbsp;';
//if (isset($encaiss_ttc[$case]) && $encaiss_ttc[$case] != 0)
if (isset($encaiss_ttc[$case]))
{
@ -704,7 +704,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
// Total
$var=!$var;
$nbcols=0;
print '<tr class="liste_total"><td>'.$langs->trans("TotalTTC").'</td>';
print '<tr class="liste_total impair"><td>'.$langs->trans("TotalTTC").'</td>';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
$nbcols+=2;
@ -714,7 +714,7 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
print "</tr>\n";
// Empty line
print '<tr><td>&nbsp;</td>';
print '<tr class="impair"><td>&nbsp;</td>';
print '<td colspan="'.$nbcols.'">&nbsp;</td>';
print "</tr>\n";

View File

@ -556,34 +556,42 @@ if ($id > 0)
print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td align="right">'.$langs->trans("Amount").'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$var=True;
while ($i < $num)
$var=true;
if ($num > 0)
{
while ($i < $num)
{
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr ".$bc[$var]."><td>";
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
$labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
print '<td align="right">'.price($objp->amount)."</td>\n";
print "</tr>";
$totalpaye += $objp->amount;
$i++;
}
}
else
{
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr ".$bc[$var]."><td>";
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
$labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
print '<td align="right">'.price($objp->amount)."</td><td>&nbsp;".$langs->trans("Currency".$conf->currency)."</td>\n";
print "</tr>";
$totalpaye += $objp->amount;
$i++;
print '<tr '.$bc[$var].'><td colspan="'.$nbcols.'" class="opacitymedium">'.$langs->trans("None").'</td><td></td><td></td><td></td></tr>';
}
if ($object->paye == 0)
{
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\">".price($totalpaye)."</td><td>&nbsp;".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\">".price($object->amount)."</td><td>&nbsp;".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\">".price($totalpaye)."</td></tr>\n";
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\">".price($object->amount)."</td></tr>\n";
$resteapayer = $object->amount - $totalpaye;
$cssforamountpaymentcomplete = 'amountpaymentcomplete';
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
print "<td align=\"right\">".price($resteapayer)."</td><td>&nbsp;".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
print '<td align="right"'.($resteapayer?' class="amountremaintopay"':(' class="'.$cssforamountpaymentcomplete.'"')).'>'.price($resteapayer)."</td></tr>\n";
}
print "</table>";
$db->free($resql);

View File

@ -43,11 +43,6 @@ class Cchargesociales
*/
public $table_element = 'c_chargesociales';
/**
* @var CchargesocialesLine[] Lines
*/
public $lines = array();
/**
*/
@ -237,83 +232,6 @@ class Cchargesociales
}
}
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
* @param string $filtermode filter mode (AND or OR)
*
* @return int <0 if KO, >0 if OK
*/
public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
$sql .= " t.id,";
$sql .= " t.libelle,";
$sql .= " t.deductible,";
$sql .= " t.active,";
$sql .= " t.code,";
$sql .= " t.fk_pays,";
$sql .= " t.module,";
$sql .= " t.accountancy_code";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
}
if (count($sqlwhere) > 0) {
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
}
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$this->lines = array();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) {
$line = new CchargesocialesLine();
$line->id = $obj->id;
$line->libelle = $obj->libelle;
$line->deductible = $obj->deductible;
$line->active = $obj->active;
$line->code = $obj->code;
$line->fk_pays = $obj->fk_pays;
$line->module = $obj->module;
$line->accountancy_code = $obj->accountancy_code;
$this->lines[$line->id] = $line;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Update object into database
*

View File

@ -510,7 +510,7 @@ class ChargeSociales extends CommonObject
function info($id)
{
$sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,";
$sql.= " fk_user_author, fk_user_modif, fk_user_valid";
$sql.= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid";
$sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as e";
$sql.= " WHERE e.rowid = ".$id;
@ -543,7 +543,7 @@ class ChargeSociales extends CommonObject
}
$this->date_creation = $this->db->jdate($obj->datec);
if (! empty($obj->fk_user_modif)) $this->date_modification = $this->db->jdate($obj->datem);
$this->date_modification = $this->db->jdate($obj->datem);
$this->date_validation = $this->db->jdate($obj->datev);
$this->import_key = $obj->import_key;
}

View File

@ -456,10 +456,10 @@ print '<td class="liste_titre" align="left">';
print $form->select_country($search_country, 'search_country');
//print '<input class="flat" size="6" type="text" name="search_country" value="'.$search_country.'">';
print '</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '</tr>';
$var=true;

View File

@ -197,13 +197,13 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
}
print '</tr>';
print '<tr class="liste_titre"><td>'.$langs->trans("Month").'</td>';
print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Month").'</td>';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
if ($modecompta == 'CREANCES-DETTES') print '<td align="right">'.$langs->trans("AmountHT").'</td>';
print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
print '<td align="right" class="borderrightlight">'.$langs->trans("Delta").'</td>';
if ($annee != $year_end) print '<td width="15">&nbsp;</td>';
if ($modecompta == 'CREANCES-DETTES') print '<td class="liste_titre" align="right">'.$langs->trans("AmountHT").'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans("AmountTTC").'</td>';
print '<td class="liste_titre" align="right" class="borderrightlight">'.$langs->trans("Delta").'</td>';
if ($annee != $year_end) print '<td class="liste_titre" width="15">&nbsp;</td>';
}
print '</tr>';

View File

@ -250,11 +250,16 @@ $dolibarr_main_restrict_os_commands='mysqldump, mysql, pg_dump, pgrestore';
$dolibarr_nocsrfcheck='0';
// dolibarr_mailing_limit_sendbyweb
// Can set a limit for mailing send by web. Can be used for a restricted mode.
// Default value: 0 (use database value if exist)
// Examples:
// $dolibarr_mailing_limit_sendbyweb='0';
// Can set a limit for mailing send by web. This overwrite database value. Can be used to restrict on OS level.
// Default value: '25'
// Examples: '-1' (sending by web is forbidden)
// $dolibarr_mailing_limit_sendbyweb='25';
// dolibarr_mailing_limit_sendbycli
// Can set a limit for mailing send by cli. This overwrite database value. Can be used to restrict on OS level.
// Default value: '0' (no hard limit, use soft database value if exists)
// Examples: '-1' (sending by cli is forbidden)
// $dolibarr_mailing_limit_sendbycli='0';
//##################
@ -273,18 +278,6 @@ $dolibarr_nocsrfcheck='0';
// Examples:
// $dolibarr_main_limit_users='0';
// dolibarr_mailing_limit_sendbyweb
// Can set a limit for mailing send by web. This overwrite database value. Can be used to restrict on OS level.
// Default value: '0' (no overwrite, use database value if exists)
// Examples: '-1' (sending by web is forbidden)
// $dolibarr_mailing_limit_sendbyweb='0';
// dolibarr_mailing_limit_sendbycli
// Can set a limit for mailing send by cli. This overwrite database value. Can be used to restrict on OS level.
// Default value: '0' (no overwrite, use database value if exists)
// Examples: '-1' (sending by cli is forbidden)
// $dolibarr_mailing_limit_sendbycli='0';
// dolibarr_strict_mode
// Set this to 1 to enable the PHP strict mode. For dev environment only.
// Default value: 0 (use database value if exist)

View File

@ -18,10 +18,12 @@
* or see http://www.gnu.org/
*/
// Variable $upload_dir must be defined when entering here
// Variable $upload_dirold may also exists.
//var_dump($upload_dir);
//var_dump($upload_dirold);
// Submit file/link
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
@ -165,7 +167,11 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave'))
setEventMessages($langs->trans("FileRenamed"), null);
}
else setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
else
{
$langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
}
}
}
}

View File

@ -488,28 +488,35 @@ class CMailFile
// Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL
if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL=10;
$tmparray = explode(',', $this->addr_to);
if (count($tmparray) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)
$tmparray1 = explode(',', $this->addr_to);
if (count($tmparray1) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL)
{
$this->error = 'Too much recipients in to:';
dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING);
return false;
}
$tmparray = explode(',', $this->addr_cc);
if (count($tmparray) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)
$tmparray2 = explode(',', $this->addr_cc);
if (count($tmparray2) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL)
{
$this->error = 'Too much recipients in cc:';
dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING);
return false;
}
$tmparray = explode(',', $this->addr_bcc);
if (count($tmparray) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)
$tmparray3 = explode(',', $this->addr_bcc);
if (count($tmparray3) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL)
{
$this->error = 'Too much recipients in bcc:';
dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING);
return false;
}
if ((count($tmparray1)+count($tmparray2)+count($tmparray3)) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)
{
$this->error = 'Too much recipients in to:, cc:, bcc:';
dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING);
return false;
}
// Action according to choosed sending method
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail')
{
@ -538,25 +545,28 @@ class CMailFile
}
else
{
$bounce = ''; // By default
$additionnalparam = ''; // By default
if (! empty($conf->global->MAIN_MAIL_ALLOW_SENDMAIL_F))
{
// le "Return-Path" (retour des messages bounced) dans les header ne fonctionne pas avec tous les MTA
// Le forcage de la valeur grace à l'option -f de sendmail est donc possible si la constante MAIN_MAIL_ALLOW_SENDMAIL_F est definie.
// La variable definie pose des pb avec certains sendmail securisee (option -f refusee car dangereuse)
$bounce .= ($bounce?' ':'').(! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '-f' . $this->getValidAddress($conf->global->MAIN_MAIL_ERRORS_TO,2) : ($this->addr_from != '' ? '-f' . $this->getValidAddress($this->addr_from,2) : '') );
// Having this variable defined may create problems with some sendmail (option -f refused)
// Having this variable not defined may create problems with some other sendmail (option -f required)
$additionnalparam .= ($additionnalparam?' ':'').(! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '-f' . $this->getValidAddress($conf->global->MAIN_MAIL_ERRORS_TO,2) : ($this->addr_from != '' ? '-f' . $this->getValidAddress($this->addr_from,2) : '') );
}
if (! empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_BA)) // To force usage of -ba option. This option tells sendmail to read From: or Sender: to setup sender
{
$bounce .= ($bounce?' ':'').'-ba';
$additionnalparam .= ($additionnalparam?' ':'').'-ba';
}
dol_syslog("CMailFile::sendfile: mail start HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port').", additionnal_parameters=".$bounce, LOG_DEBUG);
if (! empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_ADDPARAM)) $additionnalparam .= ($additionnalparam?' ':'').'-U '.$additionnalparam; // Use -U to add additionnal params
dol_syslog("CMailFile::sendfile: mail start HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port').", additionnal_parameters=".$additionnalparam, LOG_DEBUG);
$this->message=stripslashes($this->message);
if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail();
if (! empty($bounce)) $res = mail($dest,$this->encodetorfc2822($this->subject),$this->message,$this->headers, $bounce);
if (! empty($additionnalparam)) $res = mail($dest, $this->encodetorfc2822($this->subject), $this->message, $this->headers, $additionnalparam);
else $res = mail($dest, $this->encodetorfc2822($this->subject), $this->message, $this->headers);
if (! $res)

View File

@ -1929,7 +1929,10 @@ abstract class CommonObject
*/
function updateRangOfLine($rowid,$rang)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET rang = '.$rang;
$fieldposition = 'rang';
if ($this->table_element_line == 'ecm_files') $fieldposition = 'position';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang;
$sql.= ' WHERE rowid = '.$rowid;
dol_syslog(get_class($this)."::updateRangOfLine", LOG_DEBUG);

View File

@ -282,6 +282,7 @@ class Conf
// Define default dir_output and dir_temp for directories of modules
foreach($this->modules as $module)
{
//var_dump($module);
// For multicompany sharings
$this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
$this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp");

View File

@ -331,16 +331,40 @@ class ExtraFields
$table=$elementtype.'_extrafields';
$error=0;
if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
{
$result=$this->db->DDLDropField(MAIN_DB_PREFIX.$table,$attrname); // This also drop the unique key
$result=$this->delete_label($attrname,$elementtype);
if ($result < 0)
{
$this->error=$this->db->lasterror();
$this->error=$this->db->lasterror();
$error++;
}
$result=$this->delete_label($attrname,$elementtype);
if (! $error)
{
$sql = "SELECT COUNT(rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields";
$sql.= " WHERE elementtype = '".$elementtype."'";
$sql.= " AND name = '".$attrname."'";
//$sql.= " AND entity IN (0,".$conf->entity.")"; Do not test on entity here. We want to see if there is still on field remaning in other entities before deleting field in table
$resql = $this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
if ($obj->nb <= 0)
{
$result=$this->db->DDLDropField(MAIN_DB_PREFIX.$table,$attrname); // This also drop the unique key
if ($result < 0)
{
$this->error=$this->db->lasterror();
$error++;
}
}
}
}
return $result;
}
else

View File

@ -856,38 +856,62 @@ class FormFile
/**
* Show list of documents in a directory
* Show list of documents in $filearray (may be they are all in same directory but may not)
*
* @param array $filearray Array of files loaded by dol_dir_list('files') function before calling this
* @param Object $object Object on which document is linked to
* @param string $modulepart Value for modulepart used by download or viewimage wrapper
* @param array $filearray Array of files loaded by dol_dir_list('files') function before calling this.
* @param Object $object Object on which document is linked to.
* @param string $modulepart Value for modulepart used by download or viewimage wrapper.
* @param string $param Parameters on sort links (param must start with &, example &aaa=bbb&ccc=ddd)
* @param int $forcedownload Force to open dialog box "Save As" when clicking on file
* @param string $relativepath Relative path of docs (autodefined if not provided)
* @param int $forcedownload Force to open dialog box "Save As" when clicking on file.
* @param string $relativepath Relative path of docs (autodefined if not provided), relative to module dir, not to MAIN_DATA_ROOT.
* @param int $permonobject Permission on object (so permission to delete or crop document)
* @param int $useinecm Change output for use in ecm module
* @param string $textifempty Text to show if filearray is empty ('NoFileFound' if not defined)
* @param int $maxlength Maximum length of file name shown
* @param int $maxlength Maximum length of file name shown.
* @param string $title Title before list
* @param string $url Full url to use for click links ('' = autodetect)
* @param int $showrelpart 0=Show only filename (default), 1=Show first level 1 dir
* @param int $permtoeditline Permission to edit document line (-1 is deprecated)
* @param int $permtoeditline Permission to edit document line (You must provide a value, -1 is deprecated and must not be used any more)
* @param string $upload_dir Full path directory so we can know dir relative to MAIN_DATA_ROOT. Fill this if you want to complete file data with database indexes.
* @param string $sortfield Sort field ('name', 'size', 'position', ...)
* @param string $sortorder Sort order ('ASC' or 'DESC')
* @param int $disablemove 1=Disable move button, 0=Position move is possible.
* @return int <0 if KO, nb of files shown if OK
*/
function list_of_documents($filearray,$object,$modulepart,$param='',$forcedownload=0,$relativepath='',$permonobject=1,$useinecm=0,$textifempty='',$maxlength=0,$title='',$url='', $showrelpart=0, $permtoeditline=-1)
function list_of_documents($filearray,$object,$modulepart,$param='',$forcedownload=0,$relativepath='',$permonobject=1,$useinecm=0,$textifempty='',$maxlength=0,$title='',$url='', $showrelpart=0, $permtoeditline=-1,$upload_dir='',$sortfield='',$sortorder='ASC', $disablemove=1)
{
global $user, $conf, $langs, $hookmanager;
global $bc;
global $bc,$bcdd;
global $sortfield, $sortorder, $maxheightmini;
$hookmanager->initHooks(array('formfile'));
// Define relative path used to store the file
if (empty($relativepath))
{
$relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/';
if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id,2,0,0,$object,'invoice_supplier').$relativepath; // TODO Call using a defined value for $relativepath
if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.';
}
// For backward compatiblity, we detect file is stored into an old path
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $file['level1name'] == 'photos')
{
$relativepath=preg_replace('/^.*\/produit\//','',$file['path']).'/';
}
// Defined relative dir to DOL_DATA_ROOT
$relativedir = '';
if ($upload_dir)
{
$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir);
$relativedir = preg_replace('/^[\\/]/','',$relativedir);
}
$hookmanager->initHooks(array('formfile'));
$parameters=array(
'filearray' => $filearray,
'modulepart'=> $modulepart,
'param' => $param,
'forcedownload' => $forcedownload,
'relativepath' => $relativepath,
'relativepath' => $relativepath, // relative filename to module dir
'relativedir' => $relativedir, // relative dirname to DOL_DATA_ROOT
'permtodelete' => $permonobject,
'useinecm' => $useinecm,
'textifempty' => $textifempty,
@ -932,45 +956,119 @@ class FormFile
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="modulepart" value="'.$modulepart.'">';
}
print '<table width="100%" class="'.($useinecm?'liste noborderbottom':'liste').'">'."\n";
print '<table width="100%" id="tablelines" class="'.($useinecm?'liste noborderbottom':'liste').'">'."\n";
print '<tr class="liste_titre">';
print '<tr class="liste_titre nodrag nodrop">';
print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Size"),$url,"size","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Date"),$url,"date","",$param,'align="center"',$sortfield,$sortorder);
if (empty($useinecm)) print_liste_field_titre('',$url,"","",$param,'align="center"');
print_liste_field_titre('');
if (! $disablemove) print_liste_field_titre('');
print "</tr>\n";
// Get list of files stored into database for same relative directory
if ($relativedir)
{
$filearrayindatabase = dol_dir_list_in_database($relativedir, '', null, 'name', SORT_ASC);
//var_dump($filearray);
//var_dump($filearrayindatabase);
// Complete filearray with properties found into $filearrayindatabase
foreach($filearray as $key => $val)
{
$found=0;
// Search if it exists into $filearrayindatabase
foreach($filearrayindatabase as $key2 => $val2)
{
if ($filearrayindatabase[$key2]['name'] == $filearray[$key]['name'])
{
$filearray[$key]['position_name']=($filearrayindatabase[$key2]['position']?$filearrayindatabase[$key2]['position']:'0').'_'.$filearrayindatabase[$key2]['name'];
$filearray[$key]['position']=$filearrayindatabase[$key2]['position'];
$filearray[$key]['cover']=$filearrayindatabase[$key2]['cover'];
$filearray[$key]['acl']=$filearrayindatabase[$key2]['acl'];
$filearray[$key]['rowid']=$filearrayindatabase[$key2]['rowid'];
$filearray[$key]['label']=$filearrayindatabase[$key2]['label'];
$found=1;
break;
}
}
if (! $found) // This happen in transition towerd version 6, or if files were added manually into os dir.
{
$filearray[$key]['position']='999999'; // File not indexed are at end. So if we add a file, it will not replace an existing position
$filearray[$key]['cover']=0;
$filearray[$key]['acl']='';
$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filearray[$key]['fullname']);
if (! preg_match('/(\/temp\/|\/thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file
{
dol_syslog("list_of_documents We found a file called '".$filearray[$key]['name']."' not indexed into database. We add it");
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($this->db);
// Add entry into database
$filename = basename($rel_filename);
$rel_dir = dirname($rel_filename);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($filearray[$key]['fullname'])); // $destfile is a full path to file
$ecmfile->fullpath_orig = $filearray[$key]['fullname'];
$ecmfile->gen_or_uploaded = 'unknown';
$ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content
$result = $ecmfile->create($user);
if ($result < 0)
{
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
else
{
$filearray[$key]['rowid']=$result;
}
}
else
{
$filearray[$key]['rowid']=0; // Should not happened
}
}
}
/*var_dump($filearray);
var_dump($sortfield);
var_dump($sortorder);*/
if ($sortfield && $sortorder)
{
$filearray=dol_sort_array($filearray, $sortfield, $sortorder);
}
//var_dump($filearray);
}
$nboffiles=count($filearray);
if ($nboffiles > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
$var=true;
$var=true; $i=0; $nboflines = 0; $lastrowid=0;
foreach($filearray as $key => $file) // filearray must be only files here
{
if ($file['name'] != '.'
&& $file['name'] != '..'
&& ! preg_match('/\.meta$/i',$file['name']))
{
// Define relative path used to store the file
if (empty($relativepath))
{
$relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/';
if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id,2,0,0,$object,'invoice_supplier').$relativepath; // TODO Call using a defined value for $relativepath
if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.';
}
// For backward compatiblity, we detect file is stored into an old path
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $file['level1name'] == 'photos')
{
$relativepath=preg_replace('/^.*\/produit\//','',$file['path']).'/';
}
$var=!$var;
$editline=0;
if ($filearray[$key]['rowid'] > 0) $lastrowid = $filearray[$key]['rowid'];
print '<!-- Line list_of_documents '.$key.' -->'."\n";
print '<tr '.$bc[$var].'>';
$editline=0;
$nboflines++;
print '<!-- Line list_of_documents '.$key.' relativepath = '.$relativepath.' -->'."\n";
// Do we have entry into database ?
print '<!-- In database: position='.$filearray[$key]['position'].' -->'."\n";
print '<tr id="row-'.($filearray[$key]['rowid']>0?$filearray[$key]['rowid']:'-AFTER'.$lastrowid.'POS'.($i+1)).'" '.$bcdd[$var].'>';
print '<td class="tdoverflow">';
//print "XX".$file['name']; //$file['name'] must be utf8
@ -1074,6 +1172,24 @@ class FormFile
print '<a href="'.(($useinecm && $useajax)?'#':$url.'?action=delete&urlfile='.urlencode($filepath).$param).'" class="deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>';
}
print "</td>";
if (empty($disablemove))
{
if ($nboffiles > 1 && empty($conf->browser->phone)) {
print '<td align="center" class="linecolmove tdlineupdown">';
if ($i > 0) {
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=up&amp;rowid='.$line->id.'">'.img_up('default',0,'imgupforline').'</a>';
}
if ($i < $nboffiles-1) {
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=down&amp;rowid='.$line->id.'">'.img_down('default',0,'imgdownforline').'</a>';
}
print '</td>';
}
else {
print '<td align="center"'.((empty($conf->browser->phone) && empty($disablemove)) ?' class="linecolmove tdlineupdown"':' class="linecolmove"').'>';
print '</td>';
}
}
}
else
{
@ -1081,18 +1197,32 @@ class FormFile
print '<input type="submit" class="button" name="renamefilesave" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</td>';
if (empty($disablemove)) print '<td class="right"></td>';
}
print "</tr>\n";
$i++;
}
}
if ($nboffiles == 0)
{
print '<tr '.$bc[false].'><td colspan="'.(empty($useinecm)?'5':'5').'" class="opacitymedium">';
$colspan=(empty($useinecm)?'5':'5');
if (empty($disablemove)) $colspan++;
print '<tr '.$bc[false].'><td colspan="'.$colspan.'" class="opacitymedium">';
if (empty($textifempty)) print $langs->trans("NoFileFound");
else print $textifempty;
print '</td></tr>';
}
print "</table>";
if (! $editline && $nboflines > 1) {
if (! empty($conf->use_javascript_ajax) && $permtoeditline) {
$table_element_line = 'ecm_files';
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
}
}
if (GETPOST('action') == 'editfile' && $permtoeditline)
{
print '</form>';

View File

@ -239,7 +239,7 @@ function show_array_actions_to_do($max=5)
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("LastActionsToDo",$max).'</td>';
print '<td colspan="2" align="right"><a href="'.DOL_URL_ROOT.'/comm/action/listactions.php?status=todo">'.$langs->trans("FullList").'</a>';
print '<td colspan="2" align="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/comm/action/listactions.php?status=todo">'.$langs->trans("FullList").'</a>';
print '</tr>';
$var = true;
@ -336,7 +336,7 @@ function show_array_last_actions_done($max=5)
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("LastDoneTasks",$max).'</td>';
print '<td colspan="2" align="right"><a href="'.DOL_URL_ROOT.'/comm/action/listactions.php?status=done">'.$langs->trans("FullList").'</a>';
print '<td colspan="2" align="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/comm/action/listactions.php?status=done">'.$langs->trans("FullList").'</a>';
print '</tr>';
$var = true;
$i = 0;

View File

@ -965,7 +965,7 @@ function show_actions_todo($conf,$langs,$db,$filterobj,$objcon='',$noprint=0,$ac
* @return mixed Return html part or void if noprint is 1
* TODO change function to be able to list event linked to an object.
*/
function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC')
function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep,a.id', $sortorder='DESC')
{
global $bc,$user,$conf;
global $form;
@ -993,16 +993,26 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
$sql.= " u.login, u.rowid as user_id";
if (get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname";
if (get_class($filterobj) == 'Adherent') $sql.= ", m.lastname, m.firstname";
if (get_class($filterobj) == 'CommandeFournisseur') $sql.= ", o.ref";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id";
if (get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
if (get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m";
if (get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o";
$sql.= " WHERE u.rowid = a.fk_user_author";
$sql.= " AND a.entity IN (".getEntity('agenda', 1).")";
if (get_class($filterobj) == 'Societe' && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id;
if (get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id;
if (get_class($filterobj) == 'Adherent') $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
if (get_class($filterobj) == 'Adherent' && $filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id;
if (get_class($filterobj) == 'Adherent')
{
$sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id;
}
if (get_class($filterobj) == 'CommandeFournisseur')
{
$sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id;
}
if (is_object($objcon) && $objcon->id) $sql.= " AND a.fk_contact = ".$objcon->id;
// Condition on actioncode
if (! empty($actioncode))
@ -1133,6 +1143,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
@ -1142,9 +1153,10 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
$userstatic=new User($db);
$contactstatic = new Contact($db);
// TODO uniformize
// TODO mutualize/uniformize
$propalstatic=new Propal($db);
$orderstatic=new Commande($db);
$supplierorderstatic=new CommandeFournisseur($db);
$facturestatic=new Facture($db);
$out.='<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
@ -1171,7 +1183,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
}
$out.=getTitleFieldOfList($langs->trans("Ref"), 0, $_SERVER["PHP_SELF"], 'a.id', '', $param, '', $sortfield, $sortorder);
$out.='<td class="maxwidth100onsmartphone">'.$langs->trans("Label").'</td>';
$out.=getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep, a.id', '', $param, '', $sortfield, $sortorder);
$out.=getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, '', $sortfield, $sortorder);
$out.='<td>'.$langs->trans("Type").'</td>';
$out.='<td></td>';
$out.='<td></td>';
@ -1286,7 +1298,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
//$out.='<td>'.dol_trunc($histo[$key]['note'], 40).'</td>';
// Objet lie
// TODO uniformize
// TODO mutualize/uniformize
$out.='<td>';
//var_dump($histo[$key]['elementtype']);
if (isset($histo[$key]['elementtype']))

View File

@ -41,7 +41,7 @@ function dol_basename($pathfile)
* Scan a directory and return a list of files/directories.
* Content for string is UTF8 and dir separator is "/".
*
* @param string $path Starting path from which to search
* @param string $path Starting path from which to search. This is a full path.
* @param string $types Can be "directories", "files", or "all"
* @param int $recursive Determines whether subdirectories are searched
* @param string $filter Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function
@ -50,7 +50,8 @@ function dol_basename($pathfile)
* @param string $sortorder Sort order (SORT_ASC, SORT_DESC)
* @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only
* @param int $nohook Disable all hooks
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file')
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...)
* @see dol_dir_list_indatabase
*/
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=false)
{
@ -87,7 +88,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
}
// $reshook may contain returns stacked by other modules
// $reshook is always empty with an array for can not lose returns stacked with other modules
// $reshook is always empty with an array to not lose returns stacked with other modules
// $hookmanager->resArray may contain array stacked by other modules
if (! $nohook && ! empty($hookmanager->resArray)) // forced to use $hookmanager->resArray even if $hookmanager->resArray['nodes'] is empty
{
@ -205,6 +206,84 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
}
/**
* Scan a directory and return a list of files/directories.
* Content for string is UTF8 and dir separator is "/".
*
* @param string $path Starting path from which to search. Example: 'produit/MYPROD'
* @param string $filter Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function
* @param array|null $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview\.png)$','^\.'))
* @param string $sortcriteria Sort criteria ("","fullname","name","date","size")
* @param string $sortorder Sort order (SORT_ASC, SORT_DESC)
* @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like description
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','type'=>'dir|file',...)
* @see dol_dir_list
*/
function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
{
global $conf, $db;
$sql=" SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m, acl, position";
if ($mode) $sql.=", description";
$sql.=" FROM ".MAIN_DB_PREFIX."ecm_files";
$sql.=" WHERE filepath = '".$db->escape($path)."'";
$sql.=" AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
$file_list=array();
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
if ($obj)
{
preg_match('/([^\/]+)\/[^\/]+$/',DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename,$reg);
$level1name=(isset($reg[1])?$reg[1]:'');
$file_list[] = array(
"rowid" => $obj->rowid,
"label" => $obj->label, // md5
"name" => $obj->filename,
"path" => DOL_DATA_ROOT.'/'.$obj->filepath,
"level1name" => $level1name,
"fullname" => DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename,
"fullpath_orig" => $obj->fullpath_orig,
"date_c" => $db->jdate($obj->date_c),
"date_m" => $db->jdate($obj->date_m),
"type" => 'file',
"keywords" => $obj->keywords,
"cover" => $obj->cover,
"position" => (int) $obj->position,
"acl" => $obj->acl
);
}
$i++;
}
// Obtain a list of columns
if (! empty($sortcriteria))
{
$myarray=array();
foreach ($file_list as $key => $row)
{
$myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:'');
}
// Sort the data
if ($sortorder) array_multisort($myarray, $sortorder, $file_list);
}
return $file_list;
}
else
{
dol_print_error($db);
return array();
}
}
/**
* Fast compare of 2 files identified by their properties ->name, ->date and ->size
*
@ -497,11 +576,19 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists)
*/
function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
{
global $conf;
global $user, $db, $conf;
$result=false;
dol_syslog("files.lib.php::dol_move srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwritifexists=".$overwriteifexists);
$srcexists=dol_is_file($srcfile);
$destexists=dol_is_file($destfile);
if (! $srcexists)
{
dol_syslog("files.lib.php::dol_move srcfile does not exists. we ignore the move request.");
return false;
}
if ($overwriteifexists || ! $destexists)
{
$newpathofsrcfile=dol_osencode($srcfile);
@ -512,13 +599,68 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
{
if ($destexists)
{
dol_syslog("files.lib.php::dol_move failed. We try to delete first and move after.", LOG_WARNING);
dol_syslog("files.lib.php::dol_move Failed. We try to delete target first and move after.", LOG_WARNING);
// We force delete and try again. Rename function sometimes fails to replace dest file with some windows NTFS partitions.
dol_delete_file($destfile);
$result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
}
else dol_syslog("files.lib.php::dol_move failed", LOG_WARNING);
else dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING);
}
// Move ok
if ($result)
{
// Rename entry into ecm database
$rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $srcfile);
$rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $destfile);
if (! preg_match('/(\/temp\/|\/thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file
{
$rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore);
$rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter);
//var_dump($rel_filetorenamebefore.' - '.$rel_filetorenameafter);
dol_syslog("Try to rename also entries in database for full relative path before = ".$rel_filetorenamebefore." after = ".$rel_filetorenameafter, LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db);
$result = $ecmfile->fetch(0, '', $rel_filetorenamebefore);
if ($result > 0) // If found
{
$filename = basename($rel_filetorenameafter);
$rel_dir = dirname($rel_filetorenameafter);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$result = $ecmfile->update($user);
}
elseif ($result == 0) // If not found
{
$filename = basename($rel_filetorenameafter);
$rel_dir = dirname($rel_filetorenameafter);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($destfile)); // $destfile is a full path to file
$ecmfile->fullpath_orig = $srcfile;
$ecmfile->gen_or_uploaded = 'unknown';
$ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content
$result = $ecmfile->create($user);
if ($result < 0)
{
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
}
elseif ($result < 0)
{
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
}
}
if (empty($newmask)) $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK;
$newmaskdec=octdec($newmask);
// Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too)
@ -743,10 +885,33 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
{
if ($nophperrors) $ok=@unlink($filename);
else $ok=unlink($filename);
if ($ok) dol_syslog("Removed file ".$filename, LOG_DEBUG);
if ($ok)
{
dol_syslog("Removed file ".$filename, LOG_DEBUG);
// Delete entry into ecm database
$rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filename);
if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete)) // If not a tmp file
{
$rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete);
dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db);
$result = $ecmfile->fetch(0, '', $rel_filetodelete);
if ($result >= 0)
{
$result = $ecmfile->delete($user);
}
if ($result < 0)
{
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
}
}
else dol_syslog("Failed to remove file ".$filename, LOG_WARNING);
// TODO Failure to remove can be because file was already removed or because of permission
// If error because of not exists, we must can return true but we should return false if this is a permission problem
// If error because of not exists, we must should return true and we should return false if this is a permission problem
}
}
else dol_syslog("No files to delete found", LOG_WARNING);
@ -995,12 +1160,12 @@ function dol_init_file_process($pathtoscan='', $trackid='')
* All information used are in db, conf, langs, user and _FILES.
* Note: This function can be used only into a HTML page context.
*
* @param string $upload_dir Directory where to store uploaded file (note: also find in first part of dest_file)
* @param string $upload_dir Directory where to store uploaded file (note: used to forge $destpath = $upload_dir + filename)
* @param int $allowoverwrite 1=Allow overwrite existing file
* @param int $donotupdatesession 1=Do no edit _SESSION variable
* @param string $varfiles _FILES var name
* @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
* @param string $link Link to add
* @param string $link Link to add (to add a link instead of a file)
* @param string $trackid Track id (used to prefix name of session vars to avoid conflict)
* @return void
*/
@ -1026,49 +1191,82 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
for ($i = 0; $i < $nbfile; $i++)
{
// Define $destpath (path to file including filename) and $destfile (only filename)
$destpath=$upload_dir . "/" . $TFile['name'][$i];
// Define $destfull (path to file including filename) and $destfile (only filename)
$destfull=$upload_dir . "/" . $TFile['name'][$i];
$destfile=$TFile['name'][$i];
$savingdocmask = dol_sanitizeFileName($savingdocmask);
if ($savingdocmask)
{
$destpath=$upload_dir . "/" . preg_replace('/__file__/',$TFile['name'][$i],$savingdocmask);
$destfull=$upload_dir . "/" . preg_replace('/__file__/',$TFile['name'][$i],$savingdocmask);
$destfile=preg_replace('/__file__/',$TFile['name'][$i],$savingdocmask);
}
// lowercase extension
$info = pathinfo($destpath);
$destpath = $info['dirname'].'/'.$info['filename'].'.'.strtolower($info['extension']);
$info = pathinfo($destfull);
$destfull = $info['dirname'].'/'.$info['filename'].'.'.strtolower($info['extension']);
$info = pathinfo($destfile);
$destfile = $info['filename'].'.'.strtolower($info['extension']);
$resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destpath, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles);
if (is_numeric($resupload) && $resupload > 0)
$resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles);
if (is_numeric($resupload) && $resupload > 0) // $resupload can be 'ErrorFileAlreadyExists'
{
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini;
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
// Generate thumbs.
if (image_format_supported($destfull) == 1)
{
// Create thumbs
// We can't use $object->addThumbs here because there is no $object known
// Used on logon for example
$imgThumbSmall = vignette($destfull, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs");
// Create mini thumbs for image (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($destfull, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs");
}
// Update session
if (empty($donotupdatesession))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->trackid = $trackid;
$formmail->add_attached_files($destpath, $destfile, $TFile['type'][$i]);
$formmail->add_attached_files($destfull, $destfile, $TFile['type'][$i]);
}
if (image_format_supported($destpath) == 1)
// Update table of files
if ($donotupdatesession)
{
// Create thumbs
// We can't use $object->addThumbs here because there is no $object known
// Used on logon for example
$imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs");
// Create mini thumbs for image (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs");
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir);
if (! preg_match('/[\\/]temp[\\/]/', $rel_dir)) // If not a tmp dir
{
$filename = basename($destfile);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db);
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($destfull));
$ecmfile->fullpath_orig = $TFile['name'][$i];
$ecmfile->gen_or_uploaded = 'uploaded';
$ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content
$result = $ecmfile->create($user);
if ($result < 0)
{
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
}
}
setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs');
}
else
@ -1145,7 +1343,7 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=
{
$pathtodelete=$listofpaths[$keytodelete];
$filetodelete=$listofnames[$keytodelete];
if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete,1);
if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete,1); // The delete of ecm database is inside the function dol_delete_file
else $result=0;
if ($result >= 0)
{
@ -1337,11 +1535,11 @@ function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta
* Security check when accessing to a document (used by document.php, viewimage.php and webservices)
*
* @param string $modulepart Module of document ('module', 'module_user_temp', 'module_user' or 'module_temp')
* @param string $original_file Relative path with filename
* @param string $original_file Relative path with filename, relative to modulepart.
* @param string $entity Restrict onto entity
* @param User $fuser User object (forced)
* @param string $refname Ref of object to check permission for external users (autodetect if not provided)
* @return mixed Array with access information : accessallowed & sqlprotectagainstexternals & original_file (as full path name)
* @return mixed Array with access information : 'accessallowed' & 'sqlprotectagainstexternals' & 'original_file' (as a full path name)
*/
function dol_check_secure_access_document($modulepart,$original_file,$entity,$fuser='',$refname='')
{
@ -1635,7 +1833,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
$accessallowed=1;
}
$original_file=$conf->projet->dir_output.'/'.$original_file;
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project', 1).")";
}
else if ($modulepart == 'project_task')
{
@ -1644,7 +1842,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
$accessallowed=1;
}
$original_file=$conf->projet->dir_output.'/'.$original_file;
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project', 1).")";
}
// Wrapping for interventions
else if ($modulepart == 'fichinter')
@ -1759,6 +1957,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
$accessallowed=1;
}
$original_file=$conf->contrat->dir_output.'/'.$original_file;
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."contrat WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('contract', 1).")";
}
// Wrapping pour les dons

View File

@ -101,7 +101,8 @@ function facturefourn_prepare_head($object)
*/
function ordersupplier_prepare_head($object)
{
global $db, $langs, $conf;
global $db, $langs, $conf, $user;
$h = 0;
$head = array();
@ -159,7 +160,12 @@ function ordersupplier_prepare_head($object)
$h++;
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/info.php?id='.$object->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][1].= $langs->trans("Events");
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
{
$head[$h][1].= '/';
$head[$h][1].= $langs->trans("Agenda");
}
$head[$h][2] = 'info';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order', 'remove');

View File

@ -37,8 +37,10 @@ $quality = 80;
*/
function image_format_supported($file)
{
$regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm'; // See also into product.class.php
// Case filename is not a format image
if (! preg_match('/(\.gif|\.jpg|\.jpeg|\.png|\.bmp)$/i',$file,$reg)) return -1;
if (! preg_match('/('.$regeximgext.')$/i',$file,$reg)) return -1;
// Case filename is a format image but not supported by this PHP
$imgfonction='';
@ -47,6 +49,8 @@ function image_format_supported($file)
if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg';
if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg';
if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp';
if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm';
if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm';
if ($imgfonction)
{
if (! function_exists($imgfonction))

View File

@ -110,12 +110,9 @@ function report_header($nom,$variante,$period,$periodlink,$description,$builddat
if ($exportlink) print '</td><td>'.$langs->trans("Export").'</td><td>'.$exportlink;
print '</td></tr>';
print '<tr>';
print '<td colspan="4" align="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></td>';
print '</tr>';
print '</table>';
print '<br><div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></div>';
print '</form>';
dol_fiche_end();

View File

@ -110,8 +110,8 @@ class pdf_einstein extends ModelePDFCommandes
{
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
$this->posxqty=130;
$this->posxunit=147;
}
else
{
@ -129,6 +129,7 @@ class pdf_einstein extends ModelePDFCommandes
$this->posxtva-=20;
$this->posxup-=20;
$this->posxqty-=20;
$this->posxunit-=20;
$this->posxdiscount-=20;
$this->postotalht-=20;
}

View File

@ -119,8 +119,8 @@ class pdf_crabe extends ModelePDFFactures
{
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
$this->posxqty=130;
$this->posxunit=147;
}
else
{
@ -135,12 +135,14 @@ class pdf_crabe extends ModelePDFFactures
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{
$this->posxpicture-=20;
$this->posxtva-=20;
$this->posxup-=20;
$this->posxqty-=20;
$this->posxdiscount-=20;
$this->postotalht-=20;
$this->posxpicture-=20;
$this->posxtva-=20;
$this->posxup-=20;
$this->posxqty-=20;
$this->posxunit-=20;
$this->posxdiscount-=20;
$this->posxprogress-=20;
$this->postotalht-=20;
}
$this->tva=array();
@ -297,7 +299,7 @@ class pdf_crabe extends ModelePDFFactures
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) // retreive space not used by discount
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
@ -527,9 +529,9 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell($this->posxprogress-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
}
// Situation progress
if ($this->situationinvoice)
{
// Situation progress
$progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxprogress, $curY);
$pdf->MultiCell($this->postotalht-$this->posxprogress, 3, $progress, 0, 'R');

View File

@ -50,8 +50,8 @@ class modAccounting extends DolibarrModules
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Advanced accounting management";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'experimental';
// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
$this->version = 'dolibarr';
$this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
$this->special = 0;

View File

@ -62,7 +62,7 @@ class modMultiCurrency extends DolibarrModules
$this->description = "Module to enter elements with a foreign currency";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
$this->version = 'experimental';
$this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)

View File

@ -108,8 +108,8 @@ class pdf_azur extends ModelePDFPropales
{
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
$this->posxqty=130;
$this->posxunit=147;
}
else
{
@ -127,6 +127,7 @@ class pdf_azur extends ModelePDFPropales
$this->posxtva-=20;
$this->posxup-=20;
$this->posxqty-=20;
$this->posxunit-=20;
$this->posxdiscount-=20;
$this->postotalht-=20;
}

View File

@ -102,8 +102,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
if($conf->global->PRODUCT_USE_UNITS) {
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
$this->posxqty=130;
$this->posxunit=147;
}
//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
@ -113,6 +113,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$this->posxtva-=20;
$this->posxup-=20;
$this->posxqty-=20;
$this->posxunit-=20;
$this->posxdiscount-=20;
$this->postotalht-=20;
}

View File

@ -111,8 +111,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
{
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
$this->posxqty=130;
$this->posxunit=147;
} else {
$this->posxtva=112;
$this->posxup=126;
@ -127,6 +127,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$this->posxtva-=20;
$this->posxup-=20;
$this->posxqty-=20;
$this->posxunit-=20;
$this->posxdiscount-=20;
$this->postotalht-=20;
}

View File

@ -115,6 +115,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$this->posxtva-=20;
$this->posxup-=20;
$this->posxqty-=20;
$this->posxunit-=20;
$this->posxdiscount-=20;
$this->postotalht-=20;
}

View File

@ -134,11 +134,50 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
{
$fullpath=$dir."/".$original_file;
$result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']);
if ($result == $fullpath)
{
$object->addThumbs($fullpath);
// Update/create database for file $fullpath
$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath);
$rel_filename = preg_replace('/^[\\/]/','',$rel_filename);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db);
$result = $ecmfile->fetch(0, '', $rel_filename);
if ($result > 0) // If found
{
$filename = basename($rel_filename);
$rel_dir = dirname($rel_filename);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->label = md5_file(dol_osencode($fullpath));
$result = $ecmfile->update($user);
}
elseif ($result == 0) // If not found
{
$filename = basename($rel_filename);
$rel_dir = dirname($rel_filename);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
$ecmfile->fullpath_orig = $fullpath;
$ecmfile->gen_or_uploaded = 'unknown';
$ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content
$result = $ecmfile->create($user);
if ($result < 0)
{
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
$result = $ecmfile->create($user);
}
if ($backtourl)
{
header("Location: ".$backtourl);
@ -168,6 +207,45 @@ if ($action == 'confirm_crop')
{
$object->addThumbs($fullpath);
// Update/create database for file $fullpath
$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath);
$rel_filename = preg_replace('/^[\\/]/','',$rel_filename);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db);
$result = $ecmfile->fetch(0, '', $rel_filename);
if ($result > 0) // If found
{
$filename = basename($rel_filename);
$rel_dir = dirname($rel_filename);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->label = md5_file(dol_osencode($fullpath));
$result = $ecmfile->update($user);
}
elseif ($result == 0) // If not found
{
$filename = basename($rel_filename);
$rel_dir = dirname($rel_filename);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
$ecmfile->fullpath_orig = $fullpath;
$ecmfile->gen_or_uploaded = 'unknown';
$ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content
$result = $ecmfile->create($user);
if ($result < 0)
{
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
$result = $ecmfile->create($user);
}
if ($backtourl)
{
header("Location: ".$backtourl);
@ -218,10 +296,11 @@ print '<legend>'.$langs->trans("Resize").'</legend>';
print $langs->trans("ResizeDesc").'<br>';
print $langs->trans("NewLength").': <input class="flat" name="sizex" size="10" type="text" > px &nbsp; '.$langs->trans("or").' &nbsp; ';
print $langs->trans("NewHeight").': <input class="flat" name="sizey" size="10" type="text" > px &nbsp; <br>';
print '<input type="hidden" name="file" value="'.dol_escape_htmltag(GETPOST('file')).'" />';
print '<input type="hidden" name="action" value="confirm_resize" />';
print '<input type="hidden" name="product" value="'.$id.'" />';
print '<input type="hidden" name="modulepart" value="'.$modulepart.'" />';
print '<input type="hidden" name="modulepart" value="'.dol_escape_htmltag($modulepart).'" />';
print '<input type="hidden" name="id" value="'.$id.'" />';
print '<br>';
print '<input class="button" id="submitresize" name="sendit" value="'.dol_escape_htmltag($langs->trans("Resize")).'" type="submit" />';

View File

@ -17,18 +17,19 @@
*
* Javascript code to activate drag and drop on lines
* You can use this if you want to be abale to drag and drop rows of a table.
* You must add id="tablelines" on table level tag and have count($object->lines) or count($taskarray) > 0
* You must add id="tablelines" on table level tag and have ($nboflines or count($object->lines) or count($taskarray) > 0)
*/
?>
<!-- BEGIN PHP TEMPLATE AJAXROW.TPL.PHP -->
<!-- BEGIN PHP TEMPLATE AJAXROW.TPL.PHP - Script to enable drag and drop on tables -->
<?php
$id=$object->id;
$fk_element=$object->fk_element;
$table_element_line=$object->table_element_line;
$nboflines=(isset($object->lines)?count($object->lines):(isset($tasksarray)?count($tasksarray):0));
$table_element_line=(empty($table_element_line)?$object->table_element_line:$table_element_line);
$nboflines=(isset($object->lines)?count($object->lines):(isset($tasksarray)?count($tasksarray):(empty($nboflines)?0:$nboflines)));
$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
$filepath=(empty($filepath)?'':$filepath);
if (GETPOST('action') != 'editline' && $nboflines > 1) { ?>
<script type="text/javascript">
@ -43,16 +44,19 @@ $(document).ready(function(){
$("#<?php echo $tagidfortablednd; ?>").tableDnD({
onDrop: function(table, row) {
var reloadpage = "<?php echo $forcereloadpage; ?>";
console.log($("#<?php echo $tagidfortablednd; ?>").tableDnDSerialize());
var roworder = cleanSerialize($("#<?php echo $tagidfortablednd; ?>").tableDnDSerialize());
var table_element_line = "<?php echo $table_element_line; ?>";
var fk_element = "<?php echo $fk_element; ?>";
var element_id = "<?php echo $id; ?>";
var filepath = "<?php echo urlencode($filepath); ?>";
$.post("<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php",
{
roworder: roworder,
table_element_line: table_element_line,
fk_element: fk_element,
element_id: element_id
element_id: element_id,
filepath: filepath
},
function() {
if (reloadpage == 1) {

View File

@ -72,6 +72,9 @@ $formfile->form_attach_new_file(
$savingdocmask
);
$disablemove=1;
if ($modulepart == 'produit') $disablemove=0;
// List of document
$formfile->list_of_documents(
$filearray,
@ -79,7 +82,7 @@ $formfile->list_of_documents(
$modulepart,
$param,
0,
$relativepathwithnofile, // relative path with no file. For example "moduledir/0/1"
$relativepathwithnofile, // relative path with no file. For example "0/1"
$permission,
0,
'',
@ -87,7 +90,11 @@ $formfile->list_of_documents(
'',
'',
0,
$permtoedit
$permtoedit,
$upload_dir,
$sortfield,
$sortorder,
$disablemove
);
print "<br>";

View File

@ -109,7 +109,7 @@ if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart');
$check_access = dol_check_secure_access_document($modulepart,$original_file,$entity,$refname);
$accessallowed = $check_access['accessallowed'];
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
$original_file = $check_access['original_file'];
$original_file = $check_access['original_file']; // original_file is now a full path name
// Basic protection (against external users only)
if ($user->societe_id > 0)

View File

@ -126,7 +126,7 @@ if ($object->id)
if ($user->rights->don->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
// $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';

View File

@ -80,7 +80,7 @@ if (! empty($conf->projet->enabled))
if ($user->rights->don->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
// $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';

View File

@ -97,7 +97,7 @@ if ($id > 0 || ! empty($ref))
if ($user->rights->don->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
// $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';

View File

@ -23,8 +23,7 @@
*/
/**
* \class EcmDirectory
* \brief Class to manage ECM directories
* Class to manage ECM directories
*/
class EcmDirectory // extends CommonObject
{

View File

@ -0,0 +1,782 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) ---Put here your own copyright and developer email---
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file ecm/ecmfiles.class.php
* \ingroup ecm
* \brief Class to manage ECM Files (Create/Read/Update/Delete)
*/
// Put here all includes required by your class file
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';
/**
* Class to manage ECM files
*/
class EcmFiles //extends CommonObject
{
/**
* @var string Id to identify managed objects
*/
public $element = 'ecmfiles';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'ecm_files';
/**
*/
public $label;
public $entity;
public $filename;
public $filepath;
public $fullpath_orig;
public $description;
public $keywords;
public $cover;
public $position;
public $gen_or_uploaded; // can be 'generated', 'uploaded', 'unknown'
public $extraparams;
public $date_c = '';
public $date_m = '';
public $fk_user_c;
public $fk_user_m;
public $acl;
/**
*/
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
public function __construct(DoliDB $db)
{
$this->db = $db;
}
/**
* Create object into database
*
* @param User $user User that creates
* @param bool $notrigger false=launch triggers after, true=disable triggers
*
* @return int <0 if KO, Id of created object if OK
*/
public function create(User $user, $notrigger = false)
{
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0;
// Clean parameters
if (isset($this->label)) {
$this->label = trim($this->label);
}
if (isset($this->entity)) {
$this->entity = trim($this->entity);
}
if (isset($this->filename)) {
$this->filename = trim($this->filename);
}
if (isset($this->filepath)) {
$this->filepath = trim($this->filepath);
}
if (isset($this->fullpath_orig)) {
$this->fullpath_orig = trim($this->fullpath_orig);
}
if (isset($this->description)) {
$this->description = trim($this->description);
}
if (isset($this->keywords)) {
$this->keywords = trim($this->keywords);
}
if (isset($this->cover)) {
$this->cover = trim($this->cover);
}
if (isset($this->gen_or_uploaded)) {
$this->gen_or_uploaded = trim($this->gen_or_uploaded);
}
if (isset($this->extraparams)) {
$this->extraparams = trim($this->extraparams);
}
if (isset($this->fk_user_c)) {
$this->fk_user_c = trim($this->fk_user_c);
}
if (isset($this->fk_user_m)) {
$this->fk_user_m = trim($this->fk_user_m);
}
if (isset($this->acl)) {
$this->acl = trim($this->acl);
}
if (empty($this->date_c)) $this->date_c = dol_now();
$maxposition=0;
if (empty($this->position)) // Get max used
{
$sql = "SELECT MAX(position) as maxposition FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql.= " WHERE filepath ='".$this->filepath."'";
$resql = $this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
$maxposition = (int) $obj->maxposition;
}
else dol_print_error($this->db);
}
$maxposition=$maxposition+1;
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
$sql.= 'label,';
$sql.= 'entity,';
$sql.= 'filename,';
$sql.= 'filepath,';
$sql.= 'fullpath_orig,';
$sql.= 'description,';
$sql.= 'keywords,';
$sql.= 'cover,';
$sql.= 'position,';
$sql.= 'gen_or_uploaded,';
$sql.= 'extraparams,';
$sql.= 'date_c,';
$sql.= 'date_m,';
$sql.= 'fk_user_c,';
$sql.= 'fk_user_m,';
$sql.= 'acl';
$sql .= ') VALUES (';
$sql .= ' '.(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").',';
$sql .= ' '.(! isset($this->entity)?$conf->entity:$this->entity).',';
$sql .= ' '.(! isset($this->filename)?'NULL':"'".$this->db->escape($this->filename)."'").',';
$sql .= ' '.(! isset($this->filepath)?'NULL':"'".$this->db->escape($this->filepath)."'").',';
$sql .= ' '.(! isset($this->fullpath_orig)?'NULL':"'".$this->db->escape($this->fullpath_orig)."'").',';
$sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").',';
$sql .= ' '.(! isset($this->keywords)?'NULL':"'".$this->db->escape($this->keywords)."'").',';
$sql .= ' '.(! isset($this->cover)?'NULL':"'".$this->db->escape($this->cover)."'").',';
$sql .= ' '.$maxposition.',';
$sql .= ' '.(! isset($this->gen_or_uploaded)?'NULL':"'".$this->db->escape($this->gen_or_uploaded)."'").',';
$sql .= ' '.(! isset($this->extraparams)?'NULL':"'".$this->db->escape($this->extraparams)."'").',';
$sql .= ' '."'".$this->db->idate($this->date_c)."'".',';
$sql .= ' '.(! isset($this->date_m) || dol_strlen($this->date_m)==0?'NULL':"'".$this->db->idate($this->date_m)."'").',';
$sql .= ' '.(! isset($this->fk_user_c)?$user->id:$this->fk_user_c).',';
$sql .= ' '.(! isset($this->fk_user_m)?'NULL':$this->fk_user_m).',';
$sql .= ' '.(! isset($this->acl)?'NULL':"'".$this->db->escape($this->acl)."'");
$sql .= ')';
$this->db->begin();
$resql = $this->db->query($sql);
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
}
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
$this->position = $maxposition;
if (!$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action to call a trigger.
//// Call triggers
//$result=$this->call_trigger('MYOBJECT_CREATE',$user);
//if ($result < 0) $error++;
//// End call triggers
}
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return $this->id;
}
}
/**
* Load object in memory from the database
*
* @param int $id Id object
* @param string $ref Not used yet. Will contains a hash id from filename+filepath
* @param string $fullpath Full path of file (relative path to document directory)
* @return int <0 if KO, 0 if not found, >0 if OK
*/
public function fetch($id, $ref = null, $fullpath = '')
{
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= " t.ref,";
$sql .= " t.label,";
$sql .= " t.entity,";
$sql .= " t.filename,";
$sql .= " t.filepath,";
$sql .= " t.fullpath_orig,";
$sql .= " t.description,";
$sql .= " t.keywords,";
$sql .= " t.cover,";
$sql .= " t.position,";
$sql .= " t.gen_or_uploaded,";
$sql .= " t.extraparams,";
$sql .= " t.date_c,";
$sql .= " t.date_m,";
$sql .= " t.fk_user_c,";
$sql .= " t.fk_user_m,";
$sql .= " t.acl";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
$sql.= ' WHERE 1 = 1';
/* Fetching this table depends on filepath+filename, it must not depends on entity
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity("ecmfiles", 1) . ")";
}*/
if ($fullpath) {
$sql .= " AND t.filepath = '" . $this->db->escape(dirname($fullpath)) . "' AND t.filename = '".$this->db->escape(basename($fullpath))."'";
}
elseif (null !== $ref) {
$sql .= " AND t.ref = '".$this->db->escape($ref)."'";
} else {
$sql .= ' AND t.rowid = ' . $id;
}
$resql = $this->db->query($sql);
if ($resql) {
$numrows = $this->db->num_rows($resql);
if ($numrows) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->ref = $obj->ref;
$this->label = $obj->label;
$this->entity = $obj->entity;
$this->filename = $obj->filename;
$this->filepath = $obj->filepath;
$this->fullpath_orig = $obj->fullpath_orig;
$this->description = $obj->description;
$this->keywords = $obj->keywords;
$this->cover = $obj->cover;
$this->position = $obj->position;
$this->gen_or_uploaded = $obj->gen_or_uploaded;
$this->extraparams = $obj->extraparams;
$this->date_c = $this->db->jdate($obj->date_c);
$this->date_m = $this->db->jdate($obj->date_m);
$this->fk_user_c = $obj->fk_user_c;
$this->fk_user_m = $obj->fk_user_m;
$this->acl = $obj->acl;
}
// Retrieve all extrafields for invoice
// fetch optionals attributes and labels
/*
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
*/
// $this->fetch_lines();
$this->db->free($resql);
if ($numrows) {
return 1;
} else {
return 0;
}
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
* @param string $filtermode filter mode (AND or OR)
*
* @return int <0 if KO, >0 if OK
*/
public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= " t.label,";
$sql .= " t.entity,";
$sql .= " t.filename,";
$sql .= " t.filepath,";
$sql .= " t.fullpath_orig,";
$sql .= " t.description,";
$sql .= " t.keywords,";
$sql .= " t.cover,";
$sql .= " t.position,";
$sql .= " t.gen_or_uploaded,";
$sql .= " t.extraparams,";
$sql .= " t.date_c,";
$sql .= " t.date_m,";
$sql .= " t.fk_user_c,";
$sql .= " t.fk_user_m,";
$sql .= " t.acl";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
}
$sql.= ' WHERE 1 = 1';
/* Fetching this table depends on filepath+filename, it must not depends on entity
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND entity IN (" . getEntity("ecmfiles", 1) . ")";
}*/
if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere);
}
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit, $offset);
}
$this->lines = array();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) {
$line = new EcmfilesLine();
$line->id = $obj->rowid;
$line->label = $obj->label;
$line->entity = $obj->entity;
$line->filename = $obj->filename;
$line->filepath = $obj->filepath;
$line->fullpath_orig = $obj->fullpath_orig;
$line->description = $obj->description;
$line->keywords = $obj->keywords;
$line->cover = $obj->cover;
$line->position = $obj->position;
$line->gen_or_uploaded = $obj->gen_or_uploaded;
$line->extraparams = $obj->extraparams;
$line->date_c = $this->db->jdate($obj->date_c);
$line->date_m = $this->db->jdate($obj->date_m);
$line->fk_user_c = $obj->fk_user_c;
$line->fk_user_m = $obj->fk_user_m;
$line->acl = $obj->acl;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Update object into database
*
* @param User $user User that modifies
* @param bool $notrigger false=launch triggers after, true=disable triggers
*
* @return int <0 if KO, >0 if OK
*/
public function update(User $user, $notrigger = false)
{
$error = 0;
dol_syslog(__METHOD__, LOG_DEBUG);
// Clean parameters
if (isset($this->label)) {
$this->label = trim($this->label);
}
if (isset($this->entity)) {
$this->entity = trim($this->entity);
}
if (isset($this->filename)) {
$this->filename = trim($this->filename);
}
if (isset($this->filepath)) {
$this->filepath = trim($this->filepath);
}
if (isset($this->fullpath_orig)) {
$this->fullpath_orig = trim($this->fullpath_orig);
}
if (isset($this->description)) {
$this->description = trim($this->description);
}
if (isset($this->keywords)) {
$this->keywords = trim($this->keywords);
}
if (isset($this->cover)) {
$this->cover = trim($this->cover);
}
if (isset($this->gen_or_uploaded)) {
$this->gen_or_uploaded = trim($this->gen_or_uploaded);
}
if (isset($this->extraparams)) {
$this->extraparams = trim($this->extraparams);
}
if (isset($this->fk_user_c)) {
$this->fk_user_c = trim($this->fk_user_c);
}
if (isset($this->fk_user_m)) {
$this->fk_user_m = trim($this->fk_user_m);
}
if (isset($this->acl)) {
$this->acl = trim($this->acl);
}
// Check parameters
// Put here code to add a control on parameters values
// Update request
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
$sql .= ' label = '.(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").',';
$sql .= ' entity = '.(isset($this->entity)?$this->entity:$conf->entity).',';
$sql .= ' filename = '.(isset($this->filename)?"'".$this->db->escape($this->filename)."'":"null").',';
$sql .= ' filepath = '.(isset($this->filepath)?"'".$this->db->escape($this->filepath)."'":"null").',';
$sql .= ' fullpath_orig = '.(isset($this->fullpath_orig)?"'".$this->db->escape($this->fullpath_orig)."'":"null").',';
$sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").',';
$sql .= ' keywords = '.(isset($this->keywords)?"'".$this->db->escape($this->keywords)."'":"null").',';
$sql .= ' cover = '.(isset($this->cover)?"'".$this->db->escape($this->cover)."'":"null").',';
$sql .= ' position = '.(isset($this->position)?$this->db->escape($this->position):"0").',';
$sql .= ' gen_or_uploaded = '.(isset($this->gen_or_uploaded)?"'".$this->db->escape($this->gen_or_uploaded)."'":"null").',';
$sql .= ' extraparams = '.(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").',';
$sql .= ' date_c = '.(! isset($this->date_c) || dol_strlen($this->date_c) != 0 ? "'".$this->db->idate($this->date_c)."'" : 'null').',';
//$sql .= ' date_m = '.(! isset($this->date_m) || dol_strlen($this->date_m) != 0 ? "'".$this->db->idate($this->date_m)."'" : 'null').','; // Field automatically updated
$sql .= ' fk_user_c = '.(isset($this->fk_user_c)?$this->fk_user_c:"null").',';
$sql .= ' fk_user_m = '.($this->fk_user_m > 0?$this->fk_user_m:$user->id).',';
$sql .= ' acl = '.(isset($this->acl)?"'".$this->db->escape($this->acl)."'":"null");
$sql .= ' WHERE rowid=' . $this->id;
$this->db->begin();
$resql = $this->db->query($sql);
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
}
if (!$error && !$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers
//$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
//// End call triggers
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* Delete object in database
*
* @param User $user User that deletes
* @param bool $notrigger false=launch triggers after, true=disable triggers
*
* @return int <0 if KO, >0 if OK
*/
public function delete(User $user, $notrigger = false)
{
dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0;
$this->db->begin();
if (!$error) {
if (!$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers
//$result=$this->call_trigger('MYOBJECT_DELETE',$user);
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
//// End call triggers
}
}
// If you need to delete child tables to, you can insert them here
if (!$error) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
$sql .= ' WHERE rowid=' . $this->id;
$resql = $this->db->query($sql);
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
}
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* Load an object from its id and create a new one in database
*
* @param int $fromid Id of object to clone
*
* @return int New id of clone
*/
public function createFromClone($fromid)
{
dol_syslog(__METHOD__, LOG_DEBUG);
global $user;
$error = 0;
$object = new Ecmfiles($this->db);
$this->db->begin();
// Load source object
$object->fetch($fromid);
// Reset object
$object->id = 0;
// Clear fields
// ...
// Create clone
$result = $object->create($user);
// Other options
if ($result < 0) {
$error ++;
$this->errors = $object->errors;
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
}
// End
if (!$error) {
$this->db->commit();
return $object->id;
} else {
$this->db->rollback();
return - 1;
}
}
/**
* Return a link to the object card (with optionaly the picto)
*
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param string $option On what the link point to
* @param int $notooltip 1=Disable tooltip
* @param int $maxlen Max length of visible user name
* @param string $morecss Add more css on link
* @return string String with URL
*/
function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
{
global $db, $conf, $langs;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$result = '';
$companylink = '';
$label = '<u>' . $langs->trans("MyModule") . '</u>';
$label.= '<br>';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
$url = DOL_URL_ROOT.'/ecm/'.$this->table_name.'_card.php?id='.$this->id;
$linkclose='';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowProject");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
}
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
if ($withpicto)
{
$result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
if ($withpicto != 2) $result.=' ';
}
$result.= $linkstart . $this->ref . $linkend;
return $result;
}
/**
* Retourne le libelle du status d'un user (actif, inactif)
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label of status
*/
function getLibStatut($mode=0)
{
return $this->LibStatut($this->status,$mode);
}
/**
* Return the status
*
* @param int $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto
* @return string Label of status
*/
static function LibStatut($status,$mode=0)
{
global $langs;
if ($mode == 0)
{
$prefix='';
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
}
if ($mode == 1)
{
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
}
if ($mode == 2)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
if ($mode == 3)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
}
if ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
if ($mode == 5)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
}
if ($mode == 6)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
}
}
/**
* Initialise object with example values
* Id must be 0 if object instance is a specimen
*
* @return void
*/
public function initAsSpecimen()
{
global $conf,$user;
$this->id = 0;
$this->label = '0a1b2c3e4f59999999';
$this->entity = '1';
$this->filename = 'myspecimenfilefile.pdf';
$this->filepath = '/aaa/bbb';
$this->fullpath_orig = 'c:/file on my disk.pdf';
$this->description = 'This is a long description of file';
$this->keywords = 'key1,key2';
$this->cover = '1';
$this->position = '5';
$this->gen_or_uploaded = 'uploaded';
$this->extraparams = '';
$this->date_c = (dol_now() - 3600 * 24 * 10);
$this->date_m = '';
$this->fk_user_c = $user->id;
$this->fk_user_m = '';
$this->acl = '';
}
}

View File

@ -1207,15 +1207,14 @@ class ExpenseReport extends CommonObject
$expld_car = (empty($conf->global->NDF_EXPLODE_CHAR))?"-":$conf->global->NDF_EXPLODE_CHAR;
$num_car = (empty($conf->global->NDF_NUM_CAR_REF))?"5":$conf->global->NDF_NUM_CAR_REF;
$sql = 'SELECT de.ref_number_int';
$sql = 'SELECT MAX(de.ref_number_int) as max';
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' de';
$sql.= ' ORDER BY de.ref_number_int DESC';
$result = $this->db->query($sql);
if($this->db->num_rows($result) > 0):
$objp = $this->db->fetch_object($result);
$this->ref = $objp->ref_number_int;
$this->ref = $objp->max;
$this->ref++;
while(strlen($this->ref) < $num_car):
$this->ref = "0".$this->ref;

View File

@ -183,7 +183,7 @@ $min_year = 5;
$sql = "SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,";
$sql.= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve,";
$sql.= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve, d.note_private, d.note_public,";
$sql.= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.statut, u.photo";
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
@ -524,17 +524,40 @@ if ($resql)
$expensereportstatic->date_modif=$db->jdate($obj->date_modif);
$expensereportstatic->date_valid=$db->jdate($obj->date_valid);
$expensereportstatic->date_approve=$db->jdate($obj->date_approve);
$expensereportstatic->note_private=$obj->note_private;
$expensereportstatic->note_public=$obj->note_public;
$var=!$var;
print "<tr ".$bc[$var].">";
// Ref
if (! empty($arrayfields['d.ref']['checked'])) {
print '<td>';
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding nowrap">';
print $expensereportstatic->getNomUrl(1);
print '</td>';
// Warning late icon and note
print '<td class="nobordernopadding nowrap">';
if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) print img_warning($langs->trans("Late"));
if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) print img_warning($langs->trans("Late"));
if (!empty($obj->note_private) || !empty($obj->note_public))
{
print ' <span class="note">';
print '<a href="'.DOL_URL_ROOT.'/commande/note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'</a>';
print '</span>';
}
print '</td>';
print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->expensereport->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($expensereportstatic->element, $filename, $filedir);
print '</td>';
print '</tr></table>';
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// User
if (! empty($arrayfields['user']['checked'])) {
print '<td align="left">';
$usertmp->id=$obj->id_user;
@ -547,18 +570,22 @@ if ($resql)
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Start date
if (! empty($arrayfields['d.date_debut']['checked'])) {
print '<td align="center">'.($obj->date_debut > 0 ? dol_print_date($obj->date_debut, 'day') : '').'</td>';
if (! $i) $totalarray['nbfield']++;
}
// End date
if (! empty($arrayfields['d.date_fin']['checked'])) {
print '<td align="center">'.($obj->date_fin > 0 ? dol_print_date($obj->date_fin, 'day') : '').'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Date validation
if (! empty($arrayfields['d.date_valid']['checked'])) {
print '<td align="center">'.($obj->date_valid > 0 ? dol_print_date($obj->date_valid, 'day') : '').'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Date approval
if (! empty($arrayfields['d.date_approve']['checked'])) {
print '<td align="center">'.($obj->date_approve > 0 ? dol_print_date($obj->date_approve, 'day') : '').'</td>';
if (! $i) $totalarray['nbfield']++;

View File

@ -407,10 +407,11 @@ if ($result)
print $warnornote;
print '</td>';
}
// Other picto tool
print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->fichinter->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$filedir=$conf->ficheinter->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
print '</td></tr></table>';

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
@ -31,7 +31,7 @@
*/
if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr');
if (! defined('DOL_VERSION')) define('DOL_VERSION','5.0.0-beta');
if (! defined('DOL_VERSION')) define('DOL_VERSION','6.0.0-alpha');
if (! defined('EURO')) define('EURO',chr(128));

View File

@ -128,6 +128,12 @@ class CommandeFournisseur extends CommonOrder
public $multicurrency_total_tva;
public $multicurrency_total_ttc;
/**
* Draft status
*/
const STATUS_DRAFT = 0;
/**
* Constructor

View File

@ -596,7 +596,7 @@ class CommandeFournisseurDispatch extends CommonObject
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
$sql .= ' ' . $this->db->plimit($limit, $offset);
}
$this->lines = array();

View File

@ -1900,7 +1900,7 @@ elseif (! empty($object->id))
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
if($object->statut == 0) {
if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code != $conf->currency) {
print '<div class="inline-block"> &nbsp; &nbsp; &nbsp; &nbsp; ';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>';
print '</div>';

View File

@ -184,7 +184,7 @@ if ($id > 0 || ! empty($ref))
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
dol_fiche_end();

View File

@ -625,9 +625,9 @@ if ($id > 0 || ! empty($ref)) {
// Message if nothing to dispatch
if (! $nbproduct) {
if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED))
print $langs->trans("NoPredefinedProductToDispatch"); // No predefined line at all
print '<div class="opacitymedium">'.$langs->trans("NoPredefinedProductToDispatch").'</div>'; // No predefined line at all
else
print $langs->trans("NoMorePredefinedProductToDispatch"); // No predefined line that remain to be dispatched.
print '<div class="opacitymedium">'.$langs->trans("NoMorePredefinedProductToDispatch").'</div>'; // No predefined line that remain to be dispatched.
}
print '</form>';

View File

@ -27,6 +27,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
$langs->load("orders");
$langs->load("suppliers");
@ -35,11 +36,44 @@ $langs->load('stocks');
$id=GETPOST('id','int');
$ref=GETPOST('ref','alpha');
$action = GETPOST('action','alpha');
if (GETPOST('actioncode','array'))
{
$actioncode=GETPOST('actioncode','array',3);
if (! count($actioncode)) $actioncode='0';
}
else
{
$actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE));
}
$search_agenda_label=GETPOST('search_agenda_label');
// Security check
$socid='';
if (! empty($user->societe_id)) $socid=$user->societe_id;
$result = restrictedArea($user, 'fournisseur', $id, '', 'commande');
$socid=0;
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'fournisseur',$id,'', 'commande');
if (!$user->rights->fournisseur->commande->lire) accessforbidden();
/*
* Actions
*/
$parameters=array('id'=>$id);
$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');
// Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{
$actioncode='';
$search_agenda_label='';
}
/*
@ -47,89 +81,143 @@ $result = restrictedArea($user, 'fournisseur', $id, '', 'commande');
*/
$form = new Form($db);
$now=dol_now();
$object = new CommandeFournisseur($db);
if ($id > 0 || ! empty($ref))
{
$soc = new Societe($db);
$object = new CommandeFournisseur($db);
$result=$object->fetch($id,$ref);
if ($result >= 0)
{
$object->info($object->id);
$soc->fetch($object->socid);
$help_url='EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
llxHeader('',$langs->trans("Order"),$help_url);
$head = ordersupplier_prepare_head($object);
$title=$langs->trans("SupplierOrder");
dol_fiche_head($head, 'info', $title, 0, 'order');
/*
* Commande
*/
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td>';
print '<td colspan="2">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
print '</td>';
print '</tr>';
// Fournisseur
print '<tr><td>'.$langs->trans("Supplier")."</td>";
print '<td colspan="2">'.$soc->getNomUrl(1,'supplier').'</td>';
print '</tr>';
// Statut
print '<tr>';
print '<td>'.$langs->trans("Status").'</td>';
print '<td colspan="2">';
print $object->getLibStatut(4);
print "</td></tr>";
// Date
if ($object->methode_commande_id > 0)
{
print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">';
if ($object->date_commande)
{
print dol_print_date($object->date_commande,"dayhourtext")."\n";
}
print "</td></tr>";
if ($object->methode_commande)
{
print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$object->getInputMethod().'</td></tr>';
}
}
print "</table>\n";
print "<br>";
print '<table width="100%"><tr><td>';
dol_print_object_info($object, 1);
print '</td></tr></table>';
print '</div>';
}
else
{
/* Order not found */
print "OrderNotFound";
}
$object->fetch($id, $ref);
$object->fetch_thirdparty();
$object->info($object->id);
}
$title=$langs->trans("SupplierOrder").' - '.$object->ref.' '.$object->name;
if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref.' '.$object->name.' - '.$langs->trans("Info");
$help_url='EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
llxHeader('',$title,$help_url);
$now=dol_now();
$head = ordersupplier_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("SupplierOrder"), 0, 'order');
// Supplier order card
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Ref supplier
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->fournisseur->commande->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
dol_print_object_info($object, 1);
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
// Actions buttons
$out='';
$permok=$user->rights->agenda->myactions->create;
if ($permok)
{
$out.='&originid='.$object->id.'&origin=order_supplier';
}
print '<div class="tabsAction">';
if (! empty($conf->agenda->enabled))
{
if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create))
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddAction").'</a>';
}
else
{
print '<a class="butActionRefused" href="#">'.$langs->trans("AddAction").'</a>';
}
}
print '</div>';
if (!empty($object->id))
{
$param='&id='.$object->id;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
print load_fiche_titre($langs->trans("ActionsOnOrder"),'','');
// List of actions on element
/*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions=new FormActions($db);
$somethingshown=$formactions->showactions($object,'project',0);*/
// List of todo actions
//show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode);
// List of done actions
//show_actions_done($conf,$langs,$db,$object,null,0,$actioncode);
// List of all actions
$filters=array();
$filters['search_agenda_label']=$search_agenda_label;
show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters);
}
llxFooter();
$db->close();

View File

@ -134,32 +134,66 @@ if ($id > 0 || ! empty($ref))
{
$object->fetch_thirdparty();
$alreadypaid=$object->getSommePaiement();
$head = facturefourn_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans('SupplierInvoice'), 0, 'bill');
/*
* Facture synthese pour rappel
*/
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
// Ref supplier
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->facture->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
$object->totalpaye = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Reference du facture
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print "</td></tr>";
// Ref supplier
print '<tr><td class="nowrap">'.$langs->trans("RefSupplier").'</td><td colspan="3">'.$object->ref_supplier.'</td>';
print "</tr>\n";
// Third party
print "<tr><td>".$langs->trans("Supplier")."</td>";
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1,'supplier').'</td></tr>';
// Type
print '<tr><td>'.$langs->trans('Type').'</td><td colspan="4">';
print '<tr><td class="titlefield">'.$langs->trans('Type').'</td><td colspan="4">';
print $object->getLibType();
if ($object->type == FactureFournisseur::TYPE_REPLACEMENT)
{
@ -198,33 +232,29 @@ if ($id > 0 || ! empty($ref))
print '</td></tr>';
// Label
print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,0).'</td><td colspan="3">';
print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,0).'</td><td>';
print $form->editfieldval("Label",'label',$object->label,$object,0);
print '</td></tr>';
// Status
$alreadypaid=$object->getSommePaiement();
print '<tr><td>'.$langs->trans('Status').'</td><td colspan="3">'.$object->getLibStatut(4,$alreadypaid).'</td></tr>';
// Amount
print '<tr><td>'.$langs->trans('AmountHT').'</td><td colspan="3">'.price($object->total_ht,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td colspan="3">'.price($object->total_tva,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountHT').'</td><td>'.price($object->total_ht,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($object->total_tva,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
// Amount Local Taxes
//TODO: Place into a function to control showing by country or study better option
if ($societe->localtax1_assuj=="1") //Localtax1
{
print '<tr><td>'.$langs->transcountry("AmountLT1",$societe->country_code).'</td>';
print '<td colspan="3">'.price($object->total_localtax1,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '<td>'.price($object->total_localtax1,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '</tr>';
}
if ($societe->localtax2_assuj=="1") //Localtax2
{
print '<tr><td>'.$langs->transcountry("AmountLT2",$societe->country_code).'</td>';
print '<td colspan="3">'.price($object->total_localtax2,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '<td>'.price($object->total_localtax2,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '</tr>';
}
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td colspan="3">'.price($object->total_ttc,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($object->total_ttc,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print "</table>";

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -89,6 +90,58 @@ if ($object->id > 0)
{
$head = facturefourn_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('SupplierInvoice'), 0, 'bill');
$totalpaye = $object->getSommePaiement();
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
// Ref supplier
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->facture->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
@ -109,23 +162,8 @@ if ($object->id > 0)
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td class="titlefield nowrap">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
print '</td>';
print "</tr>\n";
// Ref supplier
print '<tr><td class="nowrap">'.$langs->trans("RefSupplier").'</td><td colspan="3">'.$object->ref_supplier.'</td>';
print "</tr>\n";
// Thirdparty
print '<tr><td>'.$langs->trans('Supplier').'</td><td colspan="3">'.$object->thirdparty->getNomUrl(1,'supplier').'</td></tr>';
// Type
print '<tr><td>'.$langs->trans('Type').'</td><td colspan="4">';
print '<tr><td class="titlefield">'.$langs->trans('Type').'</td><td>';
print $object->getLibType();
if ($object->type == FactureFournisseur::TYPE_REPLACEMENT)
{
@ -166,42 +204,38 @@ if ($object->id > 0)
print '</td></tr>';
// Label
print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,0).'</td><td colspan="3">';
print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,0).'</td><td>';
print $form->editfieldval("Label",'label',$object->label,$object,0);
print '</td>';
// Status
$alreadypaid=$object->getSommePaiement();
print '<tr><td>'.$langs->trans('Status').'</td><td colspan="3">'.$object->getLibStatut(4,$alreadypaid).'</td></tr>';
// Amount
print '<tr><td>'.$langs->trans('AmountHT').'</td><td colspan="3">'.price($object->total_ht,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td colspan="3">'.price($object->total_tva,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountHT').'</td><td>'.price($object->total_ht,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($object->total_tva,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
// Amount Local Taxes
//TODO: Place into a function to control showing by country or study better option
if ($societe->localtax1_assuj=="1") //Localtax1
{
print '<tr><td>'.$langs->transcountry("AmountLT1",$societe->country_code).'</td>';
print '<td colspan="3">'.price($object->total_localtax1,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '<td>'.price($object->total_localtax1,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '</tr>';
}
if ($societe->localtax2_assuj=="1") //Localtax2
{
print '<tr><td>'.$langs->transcountry("AmountLT2",$societe->country_code).'</td>';
print '<td colspan="3">'.price($object->total_localtax2,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '<td>'.price($object->total_localtax2,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '</tr>';
}
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td colspan="3">'.price($object->total_ttc,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($object->total_ttc,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '</table><br>';
print '<table class="border" width="100%">';
// Nb of files
print '<tr><td class="titlefield nowrap">'.$langs->trans('NbOfAttachedFiles').'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td class="titlefield nowrap">'.$langs->trans('NbOfAttachedFiles').'</td><td>'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans('TotalSizeOfAttachedFiles').'</td><td colspan="3">'.$totalsize.' '.$langs->trans('bytes').'</td></tr>';
print '<tr><td>'.$langs->trans('TotalSizeOfAttachedFiles').'</td><td>'.$totalsize.' '.$langs->trans('bytes').'</td></tr>';
print '</table>';
print '</div>';

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -26,17 +27,19 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->load('bills');
$id = GETPOST("facid",'int');
$id = GETPOST("facid",'int')?GETPOST("facid",'int'):GETPOST("id",'int');
$ref = GETPOST("ref",'alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
$object = new FactureFournisseur($db);
/*
@ -47,16 +50,69 @@ $title = $langs->trans('SupplierInvoice') . " - " . $langs->trans('Info');
$helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores";
llxHeader('', $title, $helpurl);
$object = new FactureFournisseur($db);
$object->fetch($id);
$object->info($id);
$soc = new Societe($db);
$soc->fetch($object->socid);
$object->fetch($id, $ref);
$object->fetch_thirdparty();
$object->info($object->id);
$alreadypaid=$object->getSommePaiement();
$head = facturefourn_prepare_head($object);
$titre=$langs->trans('SupplierInvoice');
dol_fiche_head($head, 'info', $langs->trans('SupplierInvoice'), 0, 'bill');
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
// Ref supplier
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1);
// Thirdparty
// $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->facture->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
$object->totalpaye = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';

View File

@ -75,6 +75,8 @@ if ($object->id > 0)
{
$object->fetch_thirdparty();
$alreadypaid=$object->getSommePaiement();
$head = facturefourn_prepare_head($object);
$titre=$langs->trans('SupplierInvoice');
dol_fiche_head($head, 'note', $titre, 0, 'bill');
@ -82,23 +84,59 @@ if ($object->id > 0)
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Supplier invoice card
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td class="titlefield nowrap">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '</td>';
print "</tr>\n";
$morehtmlref='<div class="refidno">';
// Ref supplier
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->fournisseur->commande->creer)
{
if ($action != 'classify')
// $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
// Ref supplier
print '<tr><td class="nowrap">'.$langs->trans("RefSupplier").'</td><td colspan="3">'.$object->ref_supplier.'</td>';
print "</tr>\n";
$object->totalpaye = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
// Company
print '<tr><td>'.$langs->trans('Supplier').'</td><td colspan="3">'.$object->thirdparty->getNomUrl(1,'supplier').'</td></tr>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
// Type
print '<tr><td>'.$langs->trans('Type').'</td><td colspan="4">';
print '<tr><td class="titlefield">'.$langs->trans('Type').'</td><td>';
print $object->getLibType();
if ($object->type == FactureFournisseur::TYPE_REPLACEMENT)
{
@ -137,38 +175,35 @@ if ($object->id > 0)
print '</td></tr>';
// Label
print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,0).'</td><td colspan="3">';
print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,0).'</td><td>';
print $form->editfieldval("Label",'label',$object->label,$object,0);
print '</td></tr>';
// Status
$alreadypaid=$object->getSommePaiement();
print '<tr><td>'.$langs->trans('Status').'</td><td colspan="3">'.$object->getLibStatut(4,$alreadypaid).'</td></tr>';
// Amount
print '<tr><td>'.$langs->trans('AmountHT').'</td><td colspan="3">'.price($object->total_ht,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td colspan="3">'.price($object->total_tva,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountHT').'</td><td>'.price($object->total_ht,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($object->total_tva,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
// Amount Local Taxes
//TODO: Place into a function to control showing by country or study better option
if ($societe->localtax1_assuj=="1") //Localtax1
{
print '<tr><td>'.$langs->transcountry("AmountLT1",$societe->country_code).'</td>';
print '<td colspan="3">'.price($object->total_localtax1,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '<td>'.price($object->total_localtax1,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '</tr>';
}
if ($societe->localtax2_assuj=="1") //Localtax2
{
print '<tr><td>'.$langs->transcountry("AmountLT2",$societe->country_code).'</td>';
print '<td colspan="3">'.price($object->total_localtax2,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '<td>'.price($object->total_localtax2,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '</tr>';
}
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td colspan="3">'.price($object->total_ttc,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($object->total_ttc,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
print "</table>";
print '<br>';
$cssclass="titlefield";
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
dol_fiche_end();

View File

@ -34,20 +34,20 @@ class Establishment extends CommonObject
public $fk_element = 'fk_establishment';
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
var $id;
var $rowid;
public $id;
public $rowid;
var $name;
var $address;
var $zip;
var $town;
var $status; // 0=open, 1=closed
var $entity;
public $name;
public $address;
public $zip;
public $town;
public $status; // 0=open, 1=closed
public $entity;
var $country_id;
public $country_id;
var $statuts=array();
var $statuts_short=array();
public $statuts=array();
public $statuts_short=array();
/**
* Constructor

View File

@ -411,7 +411,8 @@ else
array('from'=>'3.7.0', 'to'=>'3.8.0'),
array('from'=>'3.8.0', 'to'=>'3.9.0'),
array('from'=>'3.9.0', 'to'=>'4.0.0'),
array('from'=>'4.0.0', 'to'=>'5.0.0')
array('from'=>'4.0.0', 'to'=>'5.0.0'),
array('from'=>'5.0.0', 'to'=>'6.0.0')
);
$count=0;

View File

@ -77,6 +77,9 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_CLASSIFY_UNBILLED','Intervention set unbilled','Executed when a intervention is set to unbilled (when option FICHINTER_CLASSIFY_BILLED is set)','ficheinter',19);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_REOPEN','Intervention opened','Executed when a intervention is re-opened','ficheinter',19);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_SENTBYMAIL','Intervention sent by mail','Executed when a intervention is sent by mail','ficheinter',19);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',30);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',30);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',30);
-- actions not enabled by default (no constant created for that) when we enable module agenda
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_CREATE','Project creation','Executed when a project is created','project',140);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_MODIFY','Project modified','Executed when a project is modified','project',141);

View File

@ -43,6 +43,6 @@ insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 7, 'TE_RE
insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 8, 'TE_PRIVATE', 'Particulier', NULL, 1);
insert into llx_c_typent (id,code,libelle,fk_country,active) values (100, 'TE_OTHER', 'Autres', NULL, 1);
-- Argentina (country 23)
insert into llx_c_typent (id,code,libelle,fk_country,active) values (231, 'TE_A_RI', 'Responsable Inscripto', 23, 0);
insert into llx_c_typent (id,code,libelle,fk_country,active) values (232, 'TE_B_RNI', 'Responsable No Inscripto', 23, 0);
insert into llx_c_typent (id,code,libelle,fk_country,active) values (233, 'TE_C_FE', 'Consumidor Final/Exento', 23, 0);
insert into llx_c_typent (id,code,libelle,fk_country,active) values (231, 'TE_A_RI', 'Responsable Inscripto (typo A)', 23, 0);
insert into llx_c_typent (id,code,libelle,fk_country,active) values (232, 'TE_B_RNI', 'Responsable No Inscripto (typo B)', 23, 0);
insert into llx_c_typent (id,code,libelle,fk_country,active) values (233, 'TE_C_FE', 'Consumidor Final/Exento (typo C)', 23, 0);

View File

@ -230,6 +230,7 @@ ALTER TABLE llx_expensereport ADD INDEX idx_expensereport_fk_user_valid (fk_user
ALTER TABLE llx_expensereport ADD INDEX idx_expensereport_fk_user_approve (fk_user_approve);
ALTER TABLE llx_expensereport ADD INDEX idx_expensereport_fk_refuse (fk_user_approve);
DELETE FROM llx_actioncomm_resources WHERE fk_actioncomm not in (select id from llx_actioncomm);
-- Sequence to removed duplicated values of llx_links. Use serveral times if you still have duplicate.
drop table tmp_links_double;

View File

@ -0,0 +1,45 @@
--
-- Be carefull to requests order.
-- This file must be loaded by calling /install/index.php page
-- when current version is 5.0.0 or higher.
--
-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new;
-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);
-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname;
-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60);
-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name;
-- To drop an index: -- VMYSQL4.0 DROP INDEX nomindex on llx_table
-- To drop an index: -- VPGSQL8.0 DROP INDEX nomindex
-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y
-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y
-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT;
-- To make pk to be auto increment (postgres): -- VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE
-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL;
-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL;
-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL;
-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL;
-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL;
-- Note: fields with type BLOB/TEXT can't have default value.
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
ALTER TABLE llx_ecm_files ADD COLUMN ref varchar(128) AFTER rowid;
ALTER TABLE llx_ecm_files CHANGE COLUMN fullpath filepath varchar(255);
ALTER TABLE llx_ecm_files CHANGE COLUMN filepath filepath varchar(255);
ALTER TABLE llx_ecm_files ADD COLUMN position integer;
ALTER TABLE llx_ecm_files ADD COLUMN keyword varchar(750);
ALTER TABLE llx_ecm_files CHANGE COLUMN keyword keyword varchar(750);
ALTER TABLE llx_ecm_files ADD COLUMN gen_or_uploaded varchar(12);
ALTER TABLE llx_ecm_files DROP INDEX uk_ecm_files;
ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (filepath, filename, entity);
ALTER TABLE llx_ecm_files ADD INDEX idx_ecm_files_label (label);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',30);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',30);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',30);

View File

@ -143,6 +143,10 @@ delete from llx_element_element where sourcetype='facture' and fk_source not in
delete from llx_element_element where sourcetype='commande' and fk_source not in (select rowid from llx_commande);
-- Fix: delete orphelin actioncomm_resources
DELETE FROM llx_actioncomm_resources WHERE fk_actioncomm not in (select id from llx_actioncomm);
UPDATE llx_product SET canvas = NULL where canvas = 'default@product';
UPDATE llx_product SET canvas = NULL where canvas = 'service@product';

View File

@ -21,7 +21,7 @@ create table llx_c_typent
(
id integer PRIMARY KEY,
code varchar(12) NOT NULL,
libelle varchar(30),
libelle varchar(48),
fk_country integer NULL, -- Defined only to have specific list for countries that can't use generic list (like argentina that need type A or B)
active tinyint DEFAULT 1 NOT NULL,
module varchar(32) NULL,

View File

@ -1,5 +1,5 @@
-- ============================================================================
-- Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
@ -17,5 +17,9 @@
-- ============================================================================
ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (label, entity);
ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (filepath, filename);
ALTER TABLE llx_ecm_files ADD INDEX idx_ecm_files_label (label);
--ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); Disabled, mysql limits size of index

View File

@ -19,14 +19,16 @@
CREATE TABLE llx_ecm_files
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
label varchar(64) NOT NULL,
ref varchar(128), -- Not used yet. Will contains a hash id from filename+filepath
label varchar(64) NOT NULL, -- label contains a md5
entity integer DEFAULT 1 NOT NULL, -- multi company id
filepath varchar(255) NOT NULL, -- relative to dolibarr document dir. Example module/def
filename varchar(255) NOT NULL, -- file name only without any directory
fullpath varchar(750) NOT NULL, -- relative to dolibarr document dir. example abc/def/myfile
fullpath_orig varchar(750), -- full path of original filename, when file is uploaded from a local computer
description text,
keywords text, -- list of keywords, separated with comma
keywords varchar(750), -- list of keywords, separated with comma. Must be limited to most important keywords.
cover text, -- is this file a file to use for a cover
position integer, -- position of file among others
gen_or_uploaded varchar(12), -- 'generated' or 'uploaded'
extraparams varchar(255), -- for stocking other parameters with json format
date_c datetime,

View File

@ -28,6 +28,5 @@ CREATE TABLE llx_website_page
content mediumtext, -- text is not enough in size
status integer,
date_creation datetime,
date_modification datetime,
tms timestamp
) ENGINE=innodb;

View File

@ -541,16 +541,20 @@ if (! $error && $db->connected && $action == "set")
{
if ($db->connected)
{
$resultbis = 1;
// Create user
$tmpdolibarr_main_db_host = $dolibarr_main_db_host;
$result=$db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
// Create user bis
if ($databasefortest == 'mysql')
{
if (! in_array($conf->db->host, array('127.0.0.1', 'localhost', 'localhost.local'))) $tmpdolibarr_main_db_host='%';
if (! in_array($dolibarr_main_db_host, array('127.0.0.1', '::1', 'localhost', 'localhost.local')))
{
$resultbis=$db->DDLCreateUser('%', $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
}
}
$result=$db->DDLCreateUser($tmpdolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
if ($result > 0)
if ($result > 0 && $resultbis > 0)
{
print '<tr><td>';

View File

@ -10,6 +10,9 @@ VersionUnknown=Unknown
VersionRecommanded=Recommended
FileCheck=Files integrity checker
FileCheckDesc=This tool allows you to check the integrity of files of your application, comparing each files with the official ones. You can use this tool to detect if some files were modified by a hacker for example.
FileIntegrityIsStrictlyConformedWithReference=Files integrity is strictly conformed with the reference.
FileIntegritySomeFilesWereRemovedOrModified=Files integrity check has failed. Some files were modified of removed.
GlobalChecksum=Global checksum
MakeIntegrityAnalysisFrom=Make integrity analysis of application files from
LocalSignature=Embedded local signature (less reliable)
RemoteSignature=Remote distant signature (more reliable)
@ -411,6 +414,7 @@ ModuleCompanyCodePanicum=Return an empty accountancy code.
ModuleCompanyCodeDigitaria=Accountancy code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code.
Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to create and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce a third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1=validation, 2=first approval and 3=second approval if amount is enough).<br>Set this to empty if one approval (2 steps) is enough, set it to a very low value (0.1) if a second approval (3 steps) is always required.
UseDoubleApproval=Use a 3 steps approval when amount (without tax) is higher than...
WarningPHPMail=WARNING: Some email providers (like Yahoo) does not allow you to send an email from another server than the Yahoo server if the email address used as a sender is your Yahoo email (like myemail@yahoo.com, myemail@yahoo.fr, ...). Your current setup use the server of the application to send email, so some recipients (the one compatible with the restrictive DMARC protocol), will ask Yahoo if they can accept your email and Yahoo will respond "no" because the server is not a server owned by Yahoo, so few of your sent Emails may not be accepted.<br>If your Email provider (like Yahoo) has this restriction, you must change Email setup to choose the other method "SMTP server" and enter the SMTP server and credentials provided by your Email provider (ask your EMail provider to get SMTP credentials for your account).
# Modules
Module0Name=Users & groups

View File

@ -170,11 +170,11 @@ ErrorWarehouseRequiredIntoShipmentLine=Warehouse is required on the line to ship
ErrorFileMustHaveFormat=File must have format %s
ErrorSupplierCountryIsNotDefined=Country for this supplier is not defined. Correct this first.
ErrorsThirdpartyMerge=Failed to merge the two records. Request canceled.
ErrorStockIsNotEnoughToAddProductOnOrder=Stock is not enougth for product %s to add it into a new order.
ErrorStockIsNotEnoughToAddProductOnInvoice=Stock is not enougth for product %s to add it into a new invoice.
ErrorStockIsNotEnoughToAddProductOnShipment=Stock is not enougth for product %s to add it into a new shipment.
ErrorStockIsNotEnoughToAddProductOnProposal=Stock is not enougth for product %s to add it into a new proposal.
ErrorFailedToLoadLoginFileForMode=Failed to get the login file for mode '%s'.
ErrorStockIsNotEnoughToAddProductOnOrder=Stock is not enough for product %s to add it into a new order.
ErrorStockIsNotEnoughToAddProductOnInvoice=Stock is not enough for product %s to add it into a new invoice.
ErrorStockIsNotEnoughToAddProductOnShipment=Stock is not enough for product %s to add it into a new shipment.
ErrorStockIsNotEnoughToAddProductOnProposal=Stock is not enough for product %s to add it into a new proposal.
ErrorFailedToLoadLoginFileForMode=Failed to get the login key for mode '%s'.
ErrorModuleNotFound=File of module was not found.
ErrorFieldAccountNotDefinedForBankLine=Value for Accounting account not defined for source bank line %s
ErrorBankStatementNameMustFollowRegex=Error, bank statement name must follow the following syntax rule %s

View File

@ -35,7 +35,7 @@ MailingStatusSentPartialy=Sent partialy
MailingStatusSentCompletely=Sent completely
MailingStatusError=Error
MailingStatusNotSent=Not sent
MailSuccessfulySent=Email successfully sent (from %s to %s)
MailSuccessfulySent=Email successfully accepted for delivery (from %s to %s)
MailingSuccessfullyValidated=EMailing successfully validated
MailUnsubcribe=Unsubscribe
MailingStatusNotContact=Don't contact anymore

View File

@ -753,6 +753,7 @@ RemoveString=Remove string '%s'
SomeTranslationAreUncomplete=Some languages may be partially translated or may contains errors. If you detect some, you can fix language files registering to <a href="https://transifex.com/projects/p/dolibarr/" target="_blank">http://transifex.com/projects/p/dolibarr/</a>.
DirectDownloadLink=Direct download link
Download=Download
ActualizeCurrency=Update currency rate
# Week day
Monday=Monday
Tuesday=Tuesday

View File

@ -58,6 +58,7 @@ TaskDateEnd=Task end date
TaskDescription=Task description
NewTask=New task
AddTask=Create task
AddTimeSpent=Create time spent
Activity=Activity
Activities=Tasks/activities
MyActivities=My tasks/activities

View File

@ -27,7 +27,7 @@ DeleteAMailing=Delete an emailing
PreviewMailing=Preview emailing
CreateMailing=Create emailing
TestMailing=Test email
ValidMailing=Valid emailing
ValidMailing=Validate emailing
MailingStatusDraft=Draft
MailingStatusValidated=Validated
MailingStatusSent=Sent

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@zendsi.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -70,6 +70,8 @@ dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0,
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';

View File

@ -168,7 +168,7 @@ if ($result)
$num = $db->num_rows($result);
print '<br>';
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',0,0,'');
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,$num,'');
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";

View File

@ -205,7 +205,7 @@ if ($result)
$num = $db->num_rows($result);
print '<br>';
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',0,0,'');
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,$num,'');
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";

View File

@ -201,7 +201,7 @@ if ($result)
$num = $db->num_rows($result);
print '<br>';
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&amp;id=".$id,$sortfield,$sortorder,'',0,0,'');
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&amp;id=".$id,$sortfield,$sortorder,'',$num,$num,'');
$moreforfilter='';
@ -301,16 +301,10 @@ if ($result)
// affichage totaux marges
$var=!$var;
$totalMargin = $cumul_vente - $cumul_achat;
/*if ($totalMargin < 0)
{
$marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):'';
$markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):'';
}
else
{*/
$marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):'';
$markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):'';
//}
$marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):'';
$markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):'';
print '<tr class="liste_total">';
if ($id > 0)
print '<td colspan=2>';

View File

@ -54,7 +54,7 @@ class Product extends CommonObject
*/
protected $table_ref_field = 'ref';
var $regeximgext='\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff';
var $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm'; // See also into images.lib.php
/*
* @deprecated
@ -3691,15 +3691,16 @@ class Product extends CommonObject
}
/**
* Affiche la premiere photo du produit
* Return if at least one photo is available
*
* @param string $sdir Repertoire a scanner
* @return boolean true si photo dispo, false sinon
* @param string $sdir Directory to scan
* @return boolean True if at least one photo is available, False if not
*/
function is_photo_available($sdir)
{
include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php';
global $conf;
$dir = $sdir;
@ -3717,7 +3718,7 @@ class Product extends CommonObject
while (($file = readdir($handle)) !== false)
{
if (! utf8_check($file)) $file=utf8_encode($file); // To be sure data is stored in UTF8 in memory
if (dol_is_file($dir.$file)) return true;
if (dol_is_file($dir.$file) && image_format_supported($file) > 0) return true;
}
}
}
@ -3729,7 +3730,7 @@ class Product extends CommonObject
* Show photos of a product (nbmax maximum), into several columns
* TODO Move this into html.formproduct.class.php
*
* @param string $sdir Directory to scan
* @param string $sdir Directory to scan (full absolute path)
* @param int $size 0=original size, 1='small' use thumbnail if possible
* @param int $nbmax Nombre maximum de photos (0=pas de max)
* @param int $nbbyrow Number of image per line or -1 to use div. Used only if size=1.
@ -3747,140 +3748,186 @@ class Product extends CommonObject
include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php';
$sortfield='position_name';
$sortorder='asc';
$dir = $sdir . '/';
$pdir = '/';
$dir .= get_exdir(0,0,0,0,$this,'product').$this->ref.'/';
$pdir .= get_exdir(0,0,0,0,$this,'product').$this->ref.'/';
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
$dir .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/";
$pdir .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/";
}
else
{
$dir .= get_exdir(0,0,0,0,$this,'product').$this->ref.'/';
$pdir .= get_exdir(0,0,0,0,$this,'product').$this->ref.'/';
$dirold .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/";
$pdirold .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/";
}
// Defined relative dir to DOL_DATA_ROOT
$relativedir = '';
if ($dir)
{
$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir);
$relativedir = preg_replace('/^[\\/]/','',$relativedir);
$relativedir = preg_replace('/[\\/]$/','',$relativedir);
}
$dirthumb = $dir.'thumbs/';
$pdirthumb = $pdir.'thumbs/';
$return ='<!-- Photo -->'."\n";
$nbphoto=0;
$dir_osencoded=dol_osencode($dir);
if (file_exists($dir_osencoded))
$filearray=dol_dir_list($dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs
{
$handle=opendir($dir_osencoded);
if (is_resource($handle))
$filearrayold=dol_dir_list($dirold,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$filearray=array_merge($filearray, $filearrayold);
}
$filearrayindatabase = dol_dir_list_in_database($relativedir, '', null, 'name', SORT_ASC);
//var_dump($filearray);
//var_dump($filearrayindatabase);
// Complete filearray with properties found into $filearrayindatabase
foreach($filearray as $key => $val)
{
$found=0;
// Search if it exists into $filearrayindatabase
foreach($filearrayindatabase as $key2 => $val2)
{
while (($file = readdir($handle)) !== false)
{
$photo='';
if ($filearrayindatabase[$key2]['name'] == $filearray[$key]['name'])
{
$filearray[$key]['position_name']=($filearrayindatabase[$key2]['position']?$filearrayindatabase[$key2]['position']:'0').'_'.$filearrayindatabase[$key2]['name'];
$filearray[$key]['position']=$filearrayindatabase[$key2]['position'];
$filearray[$key]['cover']=$filearrayindatabase[$key2]['cover'];
$filearray[$key]['acl']=$filearrayindatabase[$key2]['acl'];
$filearray[$key]['rowid']=$filearrayindatabase[$key2]['rowid'];
$filearray[$key]['label']=$filearrayindatabase[$key2]['label'];
$found=1;
break;
}
}
}
if (count($filearray))
{
if ($sortfield && $sortorder)
{
$filearray=dol_sort_array($filearray, $sortfield, $sortorder);
}
foreach($filearray as $key => $val)
{
$photo='';
$file = $val['name'];
//if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory
if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory
//if (dol_is_file($dir.$file) && image_format_supported($file) >= 0)
if (image_format_supported($file) >= 0)
{
$nbphoto++;
$photo = $file;
$viewfilename = $file;
if (dol_is_file($dir.$file) && preg_match('/('.$this->regeximgext.')$/i', $dir.$file))
{
$nbphoto++;
$photo = $file;
$viewfilename = $file;
if ($size == 1 || $size == 'small') { // Format vignette
if ($size == 1 || $size == 'small') { // Format vignette
// Find name of thumb file
$photo_vignette=basename(getImageFileNameForSize($dir.$file, '_small'));
if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette='';
// Get filesize of original file
$imgarray=dol_getImageSize($dir.$photo);
// Find name of thumb file
$photo_vignette=basename(getImageFileNameForSize($dir.$file, '_small'));
if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette='';
// Get filesize of original file
$imgarray=dol_getImageSize($dir.$photo);
if ($nbbyrow > 0)
{
if ($nbphoto == 1) $return.= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
if ($nbbyrow > 0)
{
if ($nbphoto == 1) $return.= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
if ($nbphoto % $nbbyrow == 1) $return.= '<tr align=center valign=middle border=1>';
$return.= '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
}
else if ($nbbyrow < 0) $return .= '<div class="inline-block">';
if ($nbphoto % $nbbyrow == 1) $return.= '<tr align=center valign=middle border=1>';
$return.= '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
}
else if ($nbbyrow < 0) $return .= '<div class="inline-block">';
$return.= "\n";
$relativefile=preg_replace('/^\//', '', $pdir.$photo);
if (empty($nolink))
{
$urladvanced=getAdvancedPreviewUrl('product', $relativefile);
if ($urladvanced) $return.='<a href="'.$urladvanced.'">';
else $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">';
}
$return.= "\n";
$relativefile=preg_replace('/^\//', '', $pdir.$photo);
if (empty($nolink))
{
$urladvanced=getAdvancedPreviewUrl('product', $relativefile);
if ($urladvanced) $return.='<a href="'.$urladvanced.'">';
else $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">';
}
// Show image (width height=$maxHeight)
// Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine
$alt=$langs->transnoentitiesnoconv('File').': '.$relativefile;
$alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height'];
if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight)
{
$return.= '<!-- Show thumb -->';
$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">';
}
else {
$return.= '<!-- Show original file -->';
$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">';
}
// Show image (width height=$maxHeight)
// Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine
$alt=$langs->transnoentitiesnoconv('File').': '.$relativefile;
$alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height'];
if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight)
{
$return.= '<!-- Show thumb -->';
$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">';
}
else {
$return.= '<!-- Show original file -->';
$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">';
}
if (empty($nolink)) $return.= '</a>';
$return.="\n";
if (empty($nolink)) $return.= '</a>';
$return.="\n";
if ($showfilename) $return.= '<br>'.$viewfilename;
if ($showaction)
{
$return.= '<br>';
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
if ($photo_vignette && (image_format_supported($photo) > 0) && ($this->imgWidth > $maxWidth || $this->imgHeight > $maxHeight))
{
$return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=addthumb&amp;file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').'&nbsp;&nbsp;</a>';
}
if ($user->rights->produit->creer || $user->rights->service->creer)
{
// Link to resize
$return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&amp;file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'</a> &nbsp; ';
if ($showfilename) $return.= '<br>'.$viewfilename;
if ($showaction)
{
$return.= '<br>';
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
if ($photo_vignette && preg_match('/('.$this->regeximgext.')$/i', $photo) && ($this->imgWidth > $maxWidth || $this->imgHeight > $maxHeight))
{
$return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=addthumb&amp;file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').'&nbsp;&nbsp;</a>';
}
if ($user->rights->produit->creer || $user->rights->service->creer)
{
// Link to resize
$return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&amp;file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'</a> &nbsp; ';
// Link to delete
$return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=delete&amp;file='.urlencode($pdir.$viewfilename).'">';
$return.= img_delete().'</a>';
}
}
$return.= "\n";
// Link to delete
$return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=delete&amp;file='.urlencode($pdir.$viewfilename).'">';
$return.= img_delete().'</a>';
}
}
$return.= "\n";
if ($nbbyrow > 0)
{
$return.= '</td>';
if (($nbphoto % $nbbyrow) == 0) $return.= '</tr>';
}
else if ($nbbyrow < 0) $return.='</div>';
}
if ($nbbyrow > 0)
{
$return.= '</td>';
if (($nbphoto % $nbbyrow) == 0) $return.= '</tr>';
}
else if ($nbbyrow < 0) $return.='</div>';
}
if (empty($size)) { // Format origine
$return.= '<img class="photo photowithmargin" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">';
if (empty($size)) { // Format origine
$return.= '<img class="photo photowithmargin" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">';
if ($showfilename) $return.= '<br>'.$viewfilename;
if ($showaction)
{
if ($user->rights->produit->creer || $user->rights->service->creer)
{
// Link to resize
$return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&amp;file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'</a> &nbsp; ';
if ($showfilename) $return.= '<br>'.$viewfilename;
if ($showaction)
{
if ($user->rights->produit->creer || $user->rights->service->creer)
{
// Link to resize
$return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&amp;file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'</a> &nbsp; ';
// Link to delete
$return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=delete&amp;file='.urlencode($pdir.$viewfilename).'">';
$return.= img_delete().'</a>';
}
}
}
// Link to delete
$return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=delete&amp;file='.urlencode($pdir.$viewfilename).'">';
$return.= img_delete().'</a>';
}
}
}
// On continue ou on arrete de boucler ?
if ($nbmax && $nbphoto >= $nbmax) break;
}
}
// On continue ou on arrete de boucler ?
if ($nbmax && $nbphoto >= $nbmax) break;
}
}
if ($size==1 || $size=='small')
@ -3897,8 +3944,6 @@ class Product extends CommonObject
if ($nbphoto) $return.= '</table>';
}
}
closedir($handle);
}
$this->nbphoto = $nbphoto;
@ -3916,8 +3961,9 @@ class Product extends CommonObject
*/
function liste_photos($dir,$nbmax=0)
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
$nbphoto=0;
$tabobj=array();
@ -3928,7 +3974,7 @@ class Product extends CommonObject
while (($file = readdir($handle)) !== false)
{
if (! utf8_check($file)) $file=utf8_encode($file); // readdir returns ISO
if (dol_is_file($dir.$file) && preg_match('/('.$this->regeximgext.')$/i', $dir.$file))
if (dol_is_file($dir.$file) && image_format_supported($file) >= 0)
{
$nbphoto++;
@ -3969,8 +4015,9 @@ class Product extends CommonObject
*/
function delete_photo($file)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
$dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
$dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette
$filename = preg_replace('/'.preg_quote($dir,'/').'/i','',$file); // Nom du fichier

View File

@ -29,14 +29,14 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Service extends CommonObject
{
var $libelle;
var $price;
var $tms;
var $debut;
var $fin;
public $libelle;
public $price;
public $tms;
public $debut;
public $fin;
var $debut_epoch;
var $fin_epoch;
public $debut_epoch;
public $fin_epoch;
/**
* Constructor

View File

@ -62,7 +62,7 @@ $offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
if (! $sortfield) $sortfield="position_name";
$object = new Product($db);
@ -192,7 +192,7 @@ if ($object->id)
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);

View File

@ -256,92 +256,6 @@ class Productlot extends CommonObject
}
}
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
* @param string $filtermode filter mode (AND or OR)
*
* @return int <0 if KO, >0 if OK
*/
public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= " t.entity,";
$sql .= " t.fk_product,";
$sql .= " t.batch,";
$sql .= " t.eatby,";
$sql .= " t.sellby,";
$sql .= " t.datec,";
$sql .= " t.tms,";
$sql .= " t.fk_user_creat,";
$sql .= " t.fk_user_modif,";
$sql .= " t.import_key";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
}
if (count($sqlwhere) > 0) {
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
}
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$this->lines = array();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql))
{
$line = new ProductlotLine();
$line->id = $obj->rowid;
$line->entity = $obj->entity;
$line->fk_product = $obj->fk_product;
$line->batch = $obj->batch;
$line->eatby = $this->db->jdate($obj->eatby);
$line->sellby = $this->db->jdate($obj->sellby);
$line->datec = $this->db->jdate($obj->datec);
$line->tms = $this->db->jdate($obj->tms);
$line->fk_user_creat = $obj->fk_user_creat;
$line->fk_user_modif = $obj->fk_user_modif;
$line->import_key = $obj->import_key;
$this->lines[$line->id] = $line;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Update object into database
*
@ -595,32 +509,3 @@ class Productlot extends CommonObject
}
/**
* Class ProductlotLine
*/
class ProductlotLine
{
/**
* @var int ID
*/
public $id;
/**
* @var mixed Sample line property 1
*/
public $entity;
public $fk_product;
public $batch;
public $eatby = '';
public $sellby = '';
public $datec = '';
public $tms = '';
public $fk_user_creat;
public $fk_user_modif;
public $import_key;
/**
* @var mixed Sample line property 2
*/
}

View File

@ -273,7 +273,7 @@ class ProductStockEntrepot extends CommonObject
// "elseif" used instead of "if" because getting list with specified fk_product and specified fk_entrepot would be the same as doing a fetch
if (!empty($sortfield)) $sql .= $this->db->order($sortfield,$sortorder);
if (!empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
if (!empty($limit)) $sql .= ' ' . $this->db->plimit($limit, $offset);
$lines = array();

Some files were not shown because too many files have changed in this diff Show More