Fix: global converting lines delimiter

This commit is contained in:
Regis Houssin 2012-07-02 19:30:37 +02:00
parent d593878c78
commit 6f1651309e
116 changed files with 3580 additions and 3580 deletions

View File

@ -39,8 +39,8 @@ $langs->load("users");
$langs->load("mails"); $langs->load("mails");
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$rowid=GETPOST('rowid','int'); $rowid=GETPOST('rowid','int');
$typeid=GETPOST('typeid','int'); $typeid=GETPOST('typeid','int');
// Security check // Security check

View File

@ -1008,7 +1008,7 @@ class Adherent extends CommonObject
if ($rowid) $sql.= " AND d.rowid=".$rowid; if ($rowid) $sql.= " AND d.rowid=".$rowid;
elseif ($ref || $fk_soc) { elseif ($ref || $fk_soc) {
$sql.= " AND d.entity IN (".getEntity().")"; $sql.= " AND d.entity IN (".getEntity().")";
if ($ref) $sql.= " AND d.rowid='".$ref."'"; if ($ref) $sql.= " AND d.rowid='".$ref."'";
elseif ($fk_soc) $sql.= " AND d.fk_soc='".$fk_soc."'"; elseif ($fk_soc) $sql.= " AND d.fk_soc='".$fk_soc."'";
} }

View File

@ -35,7 +35,7 @@ require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
$langs->load("members"); $langs->load("members");
$langs->load("companies"); $langs->load("companies");
$langs->load('other'); $langs->load('other');
$id=GETPOST('id','int'); $id=GETPOST('id','int');
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');

View File

@ -42,12 +42,12 @@ $langs->load("members");
$langs->load("users"); $langs->load("users");
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$backtopage=GETPOST('backtopage','alpha'); $backtopage=GETPOST('backtopage','alpha');
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$rowid=GETPOST('rowid','int'); $rowid=GETPOST('rowid','int');
$typeid=GETPOST('typeid','int'); $typeid=GETPOST('typeid','int');
$userid=GETPOST('userid','int'); $userid=GETPOST('userid','int');
$socid=GETPOST('socid','int'); $socid=GETPOST('socid','int');
// Security check // Security check

View File

@ -27,14 +27,14 @@ require_once(DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php');
require_once(DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'); require_once(DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php');
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
$langs->load("companies"); $langs->load("companies");
$langs->load("members"); $langs->load("members");
$langs->load("bills"); $langs->load("bills");
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$id=GETPOST('id','int'); $id=GETPOST('id','int');
// Security check // Security check
$result=restrictedArea($user,'adherent',$id); $result=restrictedArea($user,'adherent',$id);
$object = new Adherent($db); $object = new Adherent($db);

View File

@ -49,7 +49,7 @@ $pagenext = $page + 1;
if (! $sortorder) { $sortorder="DESC"; } if (! $sortorder) { $sortorder="DESC"; }
if (! $sortfield) { $sortfield="d.nom"; } if (! $sortfield) { $sortfield="d.nom"; }
// Security check // Security check
$result=restrictedArea($user,'adherent',$rowid,'adherent_type'); $result=restrictedArea($user,'adherent',$rowid,'adherent_type');
if (GETPOST('button_removefilter')) if (GETPOST('button_removefilter'))

View File

@ -913,8 +913,8 @@ if ($id)
else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') { else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') {
$showfield=0; $showfield=0;
} }
else if ($fieldlist[$field]=='unicode') { else if ($fieldlist[$field]=='unicode') {
$valuetoshow = getCurrencySymbol($obj->code); $valuetoshow = getCurrencySymbol($obj->code);
} }
if ($showfield) print '<td>'.$valuetoshow.'</td>'; if ($showfield) print '<td>'.$valuetoshow.'</td>';
} }

View File

@ -77,7 +77,7 @@ if ($action == 'specimen')
if ($action == 'setdoc') if ($action == 'setdoc')
{ {
$value = GETPOST('value','alpha'); $value = GETPOST('value','alpha');
$label = GETPOST('label','alpha'); $label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha'); $scandir = GETPOST('scandir','alpha');
$db->begin(); $db->begin();
@ -111,8 +111,8 @@ if ($action == 'setdoc')
if ($action == 'set') if ($action == 'set')
{ {
$value = GETPOST('value','alpha'); $value = GETPOST('value','alpha');
$label = GETPOST('label','alpha'); $label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha'); $scandir = GETPOST('scandir','alpha');
$type='donation'; $type='donation';

View File

@ -38,9 +38,9 @@ $langs->load("interventions");
if (! $user->admin) accessforbidden(); if (! $user->admin) accessforbidden();
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$value = GETPOST('value','alpha'); $value = GETPOST('value','alpha');
$label = GETPOST('label','alpha'); $label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha'); $scandir = GETPOST('scandir','alpha');
$type='ficheinter'; $type='ficheinter';
@ -334,8 +334,8 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
$var=true; $var=true;
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$dir = dol_buildpath($reldir."core/modules/fichinter/doc/"); $dir = dol_buildpath($reldir."core/modules/fichinter/doc/");
if (is_dir($dir)) if (is_dir($dir))

View File

@ -163,7 +163,7 @@ if ($action == 'specimenfacture') // For invoices
if ($action == 'set') if ($action == 'set')
{ {
$label = GETPOST('label','alpha'); $label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha'); $scandir = GETPOST('scandir','alpha');
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
@ -195,7 +195,7 @@ if ($action == 'del')
if ($action == 'setdoc') if ($action == 'setdoc')
{ {
$label = GETPOST('label','alpha'); $label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha'); $scandir = GETPOST('scandir','alpha');
$db->begin(); $db->begin();

View File

@ -209,12 +209,12 @@ if ($action == 'edit') // Edit
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
// Hide unauthorized button // Hide unauthorized button
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ButtonHideUnauthorized").'</td><td>'; print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ButtonHideUnauthorized").'</td><td>';
print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED',isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)?$conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED:0,1); print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED',isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)?$conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED:0,1);
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
// Hide helpcenter link on login page // Hide helpcenter link on login page
@ -367,10 +367,10 @@ else // Show
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
// Hide unauthorized button // Hide unauthorized button
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ButtonHideUnauthorized").'</td><td colspan="2">'; print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ButtonHideUnauthorized").'</td><td colspan="2">';
print yn($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED,1); print yn($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED,1);
print '</td></tr>'; print '</td></tr>';
// Link to help center // Link to help center

View File

@ -34,8 +34,8 @@ if (! $user->admin) accessforbidden();
$dirstandard = array(); $dirstandard = array();
$dirsmartphone = array(); $dirsmartphone = array();
$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']); $dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
foreach($dirmenus as $dirmenu) foreach($dirmenus as $dirmenu)
{ {
$dirstandard[]=$dirmenu.'standard'; $dirstandard[]=$dirmenu.'standard';
$dirsmartphone[]=$dirmenu.'smartphone'; $dirsmartphone[]=$dirmenu.'smartphone';

View File

@ -212,9 +212,9 @@ if ($action == 'edit') // Edit
if ($conf->global->MAIN_FEATURES_LEVEL > 1) if ($conf->global->MAIN_FEATURES_LEVEL > 1)
{ {
//Desc //Desc
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>';
print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC:0,1); print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC:0,1);
print '</td></tr>'; print '</td></tr>';
//Ref //Ref
@ -223,10 +223,10 @@ if ($action == 'edit') // Edit
print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_REF',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF:0,1); print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_REF',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF:0,1);
print '</td></tr>'; print '</td></tr>';
//Details //Details
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>';
print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0,1); print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0,1);
print '</td></tr>'; print '</td></tr>';
} }
@ -371,25 +371,25 @@ else // Show
print yn($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT,1); print yn($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT,1);
print '</td></tr>'; print '</td></tr>';
if ($conf->global->MAIN_FEATURES_LEVEL > 1) if ($conf->global->MAIN_FEATURES_LEVEL > 1)
{ {
//Desc //Desc
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>';
print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC,1); print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC,1);
print '</td></tr>'; print '</td></tr>';
//Ref //Ref
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("HideRefOnPDF").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("HideRefOnPDF").'</td><td>';
print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF,1); print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF,1);
print '</td></tr>'; print '</td></tr>';
//Details //Details
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>';
print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS,1); print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS,1);
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; print '</table>';

View File

@ -39,7 +39,7 @@ if (! $user->admin) accessforbidden();
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$value = GETPOST('value','alpha'); $value = GETPOST('value','alpha');
$label = GETPOST('label','alpha'); $label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha'); $scandir = GETPOST('scandir','alpha');
$type='propal'; $type='propal';
@ -207,7 +207,7 @@ else if ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0)
{ {
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }

View File

@ -165,7 +165,7 @@ $daylight=(is_numeric($c) && is_numeric($b))?round($c-$b):'unknown';
$val=($a>=0?'+':'').$a; $val=($a>=0?'+':'').$a;
$val.=' ('.($a==='unknown'?'unknown':($a>=0?'+':'').($a*3600)).')'; $val.=' ('.($a==='unknown'?'unknown':($a>=0?'+':'').($a*3600)).')';
$val.=' &nbsp; &nbsp; &nbsp; '.getServerTimeZoneString(); $val.=' &nbsp; &nbsp; &nbsp; '.getServerTimeZoneString();
$val.=' &nbsp; &nbsp; &nbsp; '.$langs->trans("DaylingSavingTime").': '.($daylight==='unknown'?'unknown':yn($daylight)); $val.=' &nbsp; &nbsp; &nbsp; '.$langs->trans("DaylingSavingTime").': '.($daylight==='unknown'?'unknown':yn($daylight));
print $form->textwithtooltip($val,$txt,2,1,img_info('')); print $form->textwithtooltip($val,$txt,2,1,img_info(''));
print '</td></tr>'."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php print '</td></tr>'."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php
$var=!$var; $var=!$var;

View File

@ -79,7 +79,7 @@ if (GETPOST('action','alpha')=='install')
$result=dol_uncompress($newfile,$documentrootalt); $result=dol_uncompress($newfile,$documentrootalt);
if (! empty($result['error'])) if (! empty($result['error']))
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">'.$langs->trans($result['error'],$original_file).'</div>'; $mesg = '<div class="error">'.$langs->trans($result['error'],$original_file).'</div>';
} }
@ -95,8 +95,8 @@ if (GETPOST('action','alpha')=='install')
* View * View
*/ */
$dirins=DOL_DOCUMENT_ROOT_ALT; $dirins=DOL_DOCUMENT_ROOT_ALT;
$dirins_ok=(is_dir($dirins)); $dirins_ok=(is_dir($dirins));
$wikihelp='EN:Installation_-_Upgrade|FR:Installation_-_Mise_à_jour|ES:Instalación_-_Actualización'; $wikihelp='EN:Installation_-_Upgrade|FR:Installation_-_Mise_à_jour|ES:Instalación_-_Actualización';
llxHeader('',$langs->trans("Upgrade"),$wikihelp); llxHeader('',$langs->trans("Upgrade"),$wikihelp);
@ -150,14 +150,14 @@ if (! empty($conf->global->MAIN_ONLINE_INSTALL_MODULE))
print '</form>'; print '</form>';
} }
else else
{ {
$message=info_admin($langs->trans("NotExistsDirect").$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); $message=info_admin($langs->trans("NotExistsDirect").$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
print $message; print $message;
} }
} }
else else
{ {
print '<b>'.$langs->trans("StepNb",4).'</b>: '; print '<b>'.$langs->trans("StepNb",4).'</b>: ';
print $langs->trans("SetupIsReadyForUse").'<br>'; print $langs->trans("SetupIsReadyForUse").'<br>';
} }
print '</form>'; print '</form>';

View File

@ -51,11 +51,11 @@ if ($id == "")
$result = restrictedArea($user, 'categorie', $id, '&category'); $result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db); $object = new Categorie($db);
if ($id > 0) if ($id > 0)
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
$upload_dir = $conf->categorie->multidir_output[$object->entity]; $upload_dir = $conf->categorie->multidir_output[$object->entity];
} }
@ -89,207 +89,207 @@ $form = new Form($db);
if ($object->id) if ($object->id)
{ {
$title=$langs->trans("ProductsCategoryShort"); $title=$langs->trans("ProductsCategoryShort");
if ($type == 0) $title=$langs->trans("ProductsCategoryShort"); if ($type == 0) $title=$langs->trans("ProductsCategoryShort");
elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort"); elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort");
elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort"); elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort");
elseif ($type == 3) $title=$langs->trans("MembersCategoryShort"); elseif ($type == 3) $title=$langs->trans("MembersCategoryShort");
$head = categories_prepare_head($object,$type); $head = categories_prepare_head($object,$type);
dol_fiche_head($head, 'photos', $title, 0, 'category'); dol_fiche_head($head, 'photos', $title, 0, 'category');
/* /*
* Confirmation de la suppression de photo * Confirmation de la suppression de photo
*/ */
if ($action == 'delete') if ($action == 'delete')
{ {
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1); $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
print($mesg); print($mesg);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Path of category // Path of category
print '<tr><td width="20%" class="notopnoleft">'; print '<tr><td width="20%" class="notopnoleft">';
$ways = $object->print_all_ways(); $ways = $object->print_all_ways();
print $langs->trans("Ref").'</td><td>'; print $langs->trans("Ref").'</td><td>';
print '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> '; print '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
foreach ($ways as $way) foreach ($ways as $way)
{ {
print $way."<br>\n"; print $way."<br>\n";
} }
print '</td></tr>'; print '</td></tr>';
// Description // Description
print '<tr><td width="20%" class="notopnoleft">'; print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("Description").'</td><td>'; print $langs->trans("Description").'</td><td>';
print nl2br($object->description); print nl2br($object->description);
print '</td></tr>'; print '</td></tr>';
// Visibility // Visibility
/* if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) /* if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
{ {
if ($object->socid) if ($object->socid)
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($object->socid); $soc->fetch($object->socid);
print '<tr><td width="20%" class="notopnoleft">'; print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("AssignedToTheCustomer").'</td><td>'; print $langs->trans("AssignedToTheCustomer").'</td><td>';
print $soc->getNomUrl(1); print $soc->getNomUrl(1);
print '</td></tr>'; print '</td></tr>';
$catsMeres = $object->get_meres (); $catsMeres = $object->get_meres ();
if ($catsMeres < 0) if ($catsMeres < 0)
{ {
dol_print_error(); dol_print_error();
} }
else if (count($catsMeres) > 0) else if (count($catsMeres) > 0)
{ {
print '<tr><td width="20%" class="notopnoleft">'; print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("CategoryContents").'</td><td>'; print $langs->trans("CategoryContents").'</td><td>';
print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible")); print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
print '</td></tr>'; print '</td></tr>';
} }
} }
else else
{ {
print '<tr><td width="20%" class="notopnoleft">'; print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("CategoryContents").'</td><td>'; print $langs->trans("CategoryContents").'</td><td>';
print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible")); print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
print '</td></tr>'; print '</td></tr>';
} }
} }
else else
{ {
print '<tr><td width="20%" class="notopnoleft">'; print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("CategoryContents").'</td><td>'; print $langs->trans("CategoryContents").'</td><td>';
print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible")); print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
print '</td></tr>'; print '</td></tr>';
} }
*/ */
print "</table>\n"; print "</table>\n";
print "</div>\n"; print "</div>\n";
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* Barre d'action */ /* Barre d'action */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n"; print "\n<div class=\"tabsAction\">\n";
if ($action != 'ajout_photo' && $user->rights->categorie->creer) if ($action != 'ajout_photo' && $user->rights->categorie->creer)
{ {
if (! empty($conf->global->MAIN_UPLOAD_DOC)) if (! empty($conf->global->MAIN_UPLOAD_DOC))
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=ajout_photo&amp;id='.$object->id.'&amp;type='.$type.'">'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=ajout_photo&amp;id='.$object->id.'&amp;type='.$type.'">';
print $langs->trans("AddPhoto").'</a>'; print $langs->trans("AddPhoto").'</a>';
} }
else else
{ {
print '<a class="butActionRefused" href="#">'; print '<a class="butActionRefused" href="#">';
print $langs->trans("AddPhoto").'</a>'; print $langs->trans("AddPhoto").'</a>';
} }
} }
print "\n</div>\n"; print "\n</div>\n";
/* /*
* Ajouter une photo * Ajouter une photo
*/ */
if ($action == 'ajout_photo' && $user->rights->categorie->creer && ! empty($conf->global->MAIN_UPLOAD_DOC)) if ($action == 'ajout_photo' && $user->rights->categorie->creer && ! empty($conf->global->MAIN_UPLOAD_DOC))
{ {
// Affiche formulaire upload // Affiche formulaire upload
$formfile=new FormFile($db); $formfile=new FormFile($db);
$formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;type='.$type,$langs->trans("AddPhoto"),1); $formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;type='.$type,$langs->trans("AddPhoto"),1);
} }
// Affiche photos // Affiche photos
if ($action != 'ajout_photo') if ($action != 'ajout_photo')
{ {
$nbphoto=0; $nbphoto=0;
$nbbyrow=5; $nbbyrow=5;
$maxWidth = 160; $maxWidth = 160;
$maxHeight = 120; $maxHeight = 120;
$pdir = get_exdir($object->id,2) . $object->id ."/photos/"; $pdir = get_exdir($object->id,2) . $object->id ."/photos/";
$dir = $upload_dir.'/'.$pdir; $dir = $upload_dir.'/'.$pdir;
print '<br>'; print '<br>';
print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
foreach ($object->liste_photos($dir) as $key => $obj) foreach ($object->liste_photos($dir) as $key => $obj)
{ {
$nbphoto++; $nbphoto++;
if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>'; if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>';
if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">'; if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">'; print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">';
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
if ($obj['photo_vignette']) if ($obj['photo_vignette'])
{ {
$filename='thumbs/'.$obj['photo_vignette']; $filename='thumbs/'.$obj['photo_vignette'];
} }
else else
{ {
$filename=$obj['photo']; $filename=$obj['photo'];
} }
// Nom affiche // Nom affiche
$viewfilename=$obj['photo']; $viewfilename=$obj['photo'];
// Taille de l'image // Taille de l'image
$object->get_image_size($dir.$filename); $object->get_image_size($dir.$filename);
$imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth; $imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth;
$imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight; $imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight;
print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$filename).'">'; print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$filename).'">';
print '</a>'; print '</a>';
print '<br>'.$viewfilename; print '<br>'.$viewfilename;
print '<br>'; print '<br>';
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight)) if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight))
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->entity.'&amp;action=addthumb&amp;type='.$type.'&amp;file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').'&nbsp;&nbsp;</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->entity.'&amp;action=addthumb&amp;type='.$type.'&amp;file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').'&nbsp;&nbsp;</a>';
} }
if ($user->rights->categorie->creer) if ($user->rights->categorie->creer)
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->entity.'&amp;action=delete&amp;type='.$type.'&amp;file='.urlencode($pdir.$viewfilename).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->entity.'&amp;action=delete&amp;type='.$type.'&amp;file='.urlencode($pdir.$viewfilename).'">';
print img_delete().'</a>'; print img_delete().'</a>';
} }
if ($nbbyrow) print '</td>'; if ($nbbyrow) print '</td>';
if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>'; if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>';
} }
// Ferme tableau // Ferme tableau
while ($nbphoto % $nbbyrow) while ($nbphoto % $nbbyrow)
{ {
print '<td width="'.ceil(100/$nbbyrow).'%">&nbsp;</td>'; print '<td width="'.ceil(100/$nbbyrow).'%">&nbsp;</td>';
$nbphoto++; $nbphoto++;
} }
if ($nbphoto < 1) if ($nbphoto < 1)
{ {
print '<tr align=center valign=middle border=1><td class="photo">'; print '<tr align=center valign=middle border=1><td class="photo">';
print "<br>".$langs->trans("NoPhotoYet")."<br><br>"; print "<br>".$langs->trans("NoPhotoYet")."<br><br>";
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; print '</table>';
} }
} }
else else

View File

@ -51,11 +51,11 @@ $object = new Address($db);
* Actions * Actions
*/ */
// Cancel // Cancel
if (GETPOST("cancel") && ! empty($backtopage)) if (GETPOST("cancel") && ! empty($backtopage))
{ {
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} }
if ($action == 'add' || $action == 'update') if ($action == 'add' || $action == 'update')
@ -80,7 +80,7 @@ if ($action == 'add' || $action == 'update')
{ {
if (! empty($backtopage)) if (! empty($backtopage))
{ {
Header("Location: ".$backtopage); Header("Location: ".$backtopage);
exit; exit;
} }
else if ($origin == 'commande') else if ($origin == 'commande')
@ -93,10 +93,10 @@ if ($action == 'add' || $action == 'update')
Header("Location: ../comm/propal/contact.php?action=editdelivery_adress&socid=".$socid."&id=".$originid); Header("Location: ../comm/propal/contact.php?action=editdelivery_adress&socid=".$socid."&id=".$originid);
exit; exit;
} }
elseif ($origin == 'shipment') elseif ($origin == 'shipment')
{ {
Header("Location: ../expedition/fiche.php?id=".$originid); Header("Location: ../expedition/fiche.php?id=".$originid);
exit; exit;
} }
else else
{ {
@ -118,10 +118,10 @@ if ($action == 'add' || $action == 'update')
if ($result >= 0) if ($result >= 0)
{ {
if (! empty($backtopage)) if (! empty($backtopage))
{ {
Header("Location: ".$backtopage); Header("Location: ".$backtopage);
exit; exit;
} }
else if ($origin == 'commande') else if ($origin == 'commande')
{ {
@ -286,10 +286,10 @@ if ($action == 'create')
print '<br><center>'; print '<br><center>';
print '<input type="submit" class="button" value="'.$langs->trans('Add').'">'; print '<input type="submit" class="button" value="'.$langs->trans('Add').'">';
if (! empty($backtopage)) if (! empty($backtopage))
{ {
print ' &nbsp; &nbsp; '; print ' &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
} }
print '</center>'."\n"; print '</center>'."\n";
@ -384,10 +384,10 @@ elseif ($action == 'edit')
print '</table><br>'; print '</table><br>';
print '<center>'; print '<center>';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; '; print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</center>'; print '</center>';
print '</form>'; print '</form>';

View File

@ -92,7 +92,7 @@ $result = restrictedArea($user, $module, $objectid, $dbtable);
$object = new Propal($db); $object = new Propal($db);
// Load object // Load object
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$ret=$object->fetch($id, $ref); $ret=$object->fetch($id, $ref);
} }
@ -159,29 +159,29 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->prop
// Remove line // Remove line
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propale->creer) else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propale->creer)
{ {
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$result = $object->deleteline($lineid); $result = $object->deleteline($lineid);
// reorder lines // reorder lines
if ($result) $object->line_order(true); if ($result) $object->line_order(true);
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang=''; $newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang)) if (! empty($newlang))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$ret=$object->fetch($id); // Reload to get new records $ret=$object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
} }
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }
@ -253,18 +253,18 @@ else if ($action == 'set_ref_client' && $user->rights->propale->creer)
$object->set_ref_client($user, $_POST['ref_client']); $object->set_ref_client($user, $_POST['ref_client']);
} }
else if ($action == 'setnote_public' && $user->rights->propale->creer) else if ($action == 'setnote_public' && $user->rights->propale->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
else if ($action == 'setnote' && $user->rights->propale->creer) else if ($action == 'setnote' && $user->rights->propale->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
// Create proposal // Create proposal
@ -957,21 +957,21 @@ else if ($action == 'builddoc' && $user->rights->propale->creer)
} }
} }
// Remove file in doc form // Remove file in doc form
else if ($action == 'remove_file') else if ($action == 'remove_file')
{ {
if ($object->fetch($id)) if ($object->fetch($id))
{ {
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$langs->load("other"); $langs->load("other");
$upload_dir = $conf->propal->dir_output; $upload_dir = $conf->propal->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object); dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>'; $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
} }
} }
// Set project // Set project
@ -1071,63 +1071,63 @@ else if ($action == 'down' && $user->rights->propale->creer)
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
if ($action == 'addcontact' && $user->rights->propale->creer) if ($action == 'addcontact' && $user->rights->propale->creer)
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
} }
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
else else
{ {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
} }
else else
{ {
$mesg = '<div class="error">'.$object->error.'</div>'; $mesg = '<div class="error">'.$object->error.'</div>';
} }
} }
} }
// Bascule du statut d'un contact // Bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->propale->creer) else if ($action == 'swapstatut' && $user->rights->propale->creer)
{ {
if ($object->fetch($id) > 0) if ($object->fetch($id) > 0)
{ {
$result=$object->swapContactStatus(GETPOST('ligne')); $result=$object->swapContactStatus(GETPOST('ligne'));
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
// Efface un contact // Efface un contact
else if ($action == 'deletecontact' && $user->rights->propale->creer) else if ($action == 'deletecontact' && $user->rights->propale->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->delete_contact($lineid); $result = $object->delete_contact($lineid);
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
@ -1564,19 +1564,19 @@ print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" cols
print '</table><br>'; print '</table><br>';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db); $formcompany= new FormCompany($db);
$blocname = 'contacts'; $blocname = 'contacts';
$title = $langs->trans('ContactsAddresses'); $title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
} }
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$blocname = 'notes'; $blocname = 'notes';
$title = $langs->trans('Notes'); $title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
} }

View File

@ -969,7 +969,7 @@ class Propal extends CommonObject
$sql.= ", p.fk_cond_reglement"; $sql.= ", p.fk_cond_reglement";
$sql.= ", p.fk_mode_reglement"; $sql.= ", p.fk_mode_reglement";
$sql.= ", c.label as statut_label"; $sql.= ", c.label as statut_label";
$sql.= ", ca.code as availability_code, ca.label as availability"; $sql.= ", ca.code as availability_code, ca.label as availability";
$sql.= ", dr.code as demand_reason_code, dr.label as demand_reason"; $sql.= ", dr.code as demand_reason_code, dr.label as demand_reason";
$sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc";
$sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement";

View File

@ -39,11 +39,11 @@ $confirm = GETPOST('confirm','alpha');
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref = GETPOST('ref','alpha'); $ref = GETPOST('ref','alpha');
$mesg=''; $mesg='';
if (isset($_SESSION['DolMessage'])) if (isset($_SESSION['DolMessage']))
{ {
$mesg=$_SESSION['DolMessage']; $mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']); unset($_SESSION['DolMessage']);
} }
// Security check // Security check
@ -67,9 +67,9 @@ if (! $sortfield) $sortfield="name";
$object = new Propal($db); $object = new Propal($db);
$object->fetch($id,$ref); $object->fetch($id,$ref);
if ($object->id > 0) if ($object->id > 0)
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
} }
/* /*
@ -148,70 +148,70 @@ $form = new Form($db);
if ($object->id > 0) if ($object->id > 0)
{ {
$upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref);
$head = propal_prepare_head($object); $head = propal_prepare_head($object);
dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal'); dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal');
// Construit liste des fichiers // Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0; $totalsize=0;
foreach($filearray as $key => $file) foreach($filearray as $key => $file)
{ {
$totalsize+=$file['size']; $totalsize+=$file['size'];
} }
print '<table class="border"width="100%">'; print '<table class="border"width="100%">';
$linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder".'">'.$langs->trans("BackToList").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder".'">'.$langs->trans("BackToList").'</a>';
// Ref // Ref
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'; print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
print $form->showrefnav($object,'ref',$linkback,1,'ref','ref',''); print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print '</td></tr>'; print '</td></tr>';
// Ref client // Ref client
print '<tr><td>'; print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>'; print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
print $langs->trans('RefCustomer').'</td><td align="left">'; print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>'; print '</td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
print $object->ref_client; print $object->ref_client;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Customer // Customer
print "<tr><td>".$langs->trans("Company")."</td>"; print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>'; print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.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 colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
dol_htmloutput_mesg($mesg,$mesgs); dol_htmloutput_mesg($mesg,$mesgs);
/* /*
* Confirmation suppression fichier * Confirmation suppression fichier
*/ */
if ($action == 'delete') if ($action == 'delete')
{ {
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
// Affiche formulaire upload // Affiche formulaire upload
$formfile=new FormFile($db); $formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id,'',0,0,$user->rights->propale->creer,50,$object); $formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id,'',0,0,$user->rights->propale->creer,50,$object);
// List of document // List of document
$param='&id='.$object->id; $param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'propal',$param); $formfile->list_of_documents($filearray,$object,'propal',$param);
} }
else else

View File

@ -184,14 +184,14 @@ if ($conf->propal->enabled)
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
$propalstatic->id=$obj->rowid; $propalstatic->id=$obj->rowid;
$propalstatic->ref=$obj->ref; $propalstatic->ref=$obj->ref;
print '<td nowrap="nowrap">'.$propalstatic->getNomUrl(1).'</td>'; print '<td nowrap="nowrap">'.$propalstatic->getNomUrl(1).'</td>';
$companystatic->id=$obj->socid; $companystatic->id=$obj->socid;
$companystatic->name=$obj->socname; $companystatic->name=$obj->socname;
$companystatic->client=$obj->client; $companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas; $companystatic->canvas=$obj->canvas;
print '<td>'.$companystatic->getNomUrl(1,'customer',24).'</td>'; print '<td>'.$companystatic->getNomUrl(1,'customer',24).'</td>';
print '</tr>'; print '</tr>';
@ -265,10 +265,10 @@ if ($resql)
print '</td>'; print '</td>';
$companystatic->id=$obj->socid; $companystatic->id=$obj->socid;
$companystatic->name=$obj->socname; $companystatic->name=$obj->socname;
$companystatic->client=$obj->client; $companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas; $companystatic->canvas=$obj->canvas;
print '<td>'.$companystatic->getNomUrl(1,'customer').'</td>'; print '<td>'.$companystatic->getNomUrl(1,'customer').'</td>';
print '<td>'.dol_print_date($db->jdate($obj->datec),'day').'</td>'; print '<td>'.dol_print_date($db->jdate($obj->datec),'day').'</td>';
@ -340,10 +340,10 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
print "</td>"; print "</td>";
$companystatic->id=$obj->socid; $companystatic->id=$obj->socid;
$companystatic->name=$obj->socname; $companystatic->name=$obj->socname;
$companystatic->client=$obj->client; $companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas; $companystatic->canvas=$obj->canvas;
print '<td align="left">'.$companystatic->getNomUrl(1,'customer',44).'</td>'."\n"; print '<td align="left">'.$companystatic->getNomUrl(1,'customer',44).'</td>'."\n";
print '<td align="right">'; print '<td align="right">';

View File

@ -86,7 +86,7 @@ $result = restrictedArea($user, $module, $objectid, $dbtable);
$object = new Propal($db); $object = new Propal($db);
// Load object // Load object
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$ret=$object->fetch($id, $ref); $ret=$object->fetch($id, $ref);
} }
@ -172,9 +172,9 @@ if ($search_ref)
{ {
$sql.= " AND p.ref LIKE '%".$db->escape(trim($search_ref))."%'"; $sql.= " AND p.ref LIKE '%".$db->escape(trim($search_ref))."%'";
} }
if ($search_refcustomer) if ($search_refcustomer)
{ {
$sql.= " AND p.ref_client LIKE '%".$db->escape(trim($search_refcustomer))."%'"; $sql.= " AND p.ref_client LIKE '%".$db->escape(trim($search_refcustomer))."%'";
} }
if ($search_societe) if ($search_societe)
{ {
@ -284,8 +284,8 @@ if ($result)
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" size="16" name="search_societe" value="'.$search_societe.'">'; print '<input class="flat" type="text" size="16" name="search_societe" value="'.$search_societe.'">';
print '</td>'; print '</td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<input class="flat" size="10" type="text" name="search_refcustomer" value="'.$search_refcustomer.'">'; print '<input class="flat" size="10" type="text" name="search_refcustomer" value="'.$search_refcustomer.'">';
print '</td>'; print '</td>';
print '<td class="liste_titre" colspan="1" align="center">'; print '<td class="liste_titre" colspan="1" align="center">';
print $langs->trans('Month').': <input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">'; print $langs->trans('Month').': <input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
@ -352,8 +352,8 @@ if ($result)
print '</td>'; print '</td>';
// Customer ref // Customer ref
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
print $objp->ref_client; print $objp->ref_client;
print '</td>'; print '</td>';
// Date propale // Date propale

View File

@ -47,18 +47,18 @@ $object = new Propal($db);
/* Actions */ /* Actions */
/******************************************************************************/ /******************************************************************************/
if ($action == 'setnote_public' && $user->rights->propale->creer) if ($action == 'setnote_public' && $user->rights->propale->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
else if ($action == 'setnote' && $user->rights->propale->creer) else if ($action == 'setnote' && $user->rights->propale->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }

View File

@ -921,13 +921,13 @@ class Commande extends CommonObject
$this->note_public = $object->note_public; $this->note_public = $object->note_public;
$this->origin = $object->element; $this->origin = $object->element;
$this->origin_id = $object->id; $this->origin_id = $object->id;
// Possibility to add external linked objects with hooks // Possibility to add external linked objects with hooks
$this->linked_objects[$this->origin] = $this->origin_id; $this->linked_objects[$this->origin] = $this->origin_id;
if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
{ {
$this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
} }
$ret = $this->create($user); $ret = $this->create($user);
@ -937,7 +937,7 @@ class Commande extends CommonObject
// Actions hooked (by external module) // Actions hooked (by external module)
if (! is_object($hookmanager)) if (! is_object($hookmanager))
{ {
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db); $hookmanager=new HookManager($this->db);
} }
$hookmanager->initHooks(array('orderdao')); $hookmanager->initHooks(array('orderdao'));

View File

@ -163,7 +163,7 @@ if ($resql)
$lienfin='</a>'; $lienfin='</a>';
$name=$obj->nom; $name=$obj->nom;
$result.=($lien.img_object($langs->trans("ShowCompany").': '.$name,'company').$lienfin); $result.=($lien.img_object($langs->trans("ShowCompany").': '.$name,'company').$lienfin);
$result.=$lien.(dol_trunc($name,$maxlen)).$lienfin; $result.=$lien.(dol_trunc($name,$maxlen)).$lienfin;
print $result; print $result;
print '</td>'; print '</td>';

View File

@ -40,11 +40,11 @@ $confirm = GETPOST('confirm');
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref = GETPOST('ref'); $ref = GETPOST('ref');
$mesg=''; $mesg='';
if (isset($_SESSION['DolMessage'])) if (isset($_SESSION['DolMessage']))
{ {
$mesg=$_SESSION['DolMessage']; $mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']); unset($_SESSION['DolMessage']);
} }
// Security check // Security check
@ -130,7 +130,7 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes')
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object); dol_delete_file($file,0,0,0,$object);
$_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }
} }

View File

@ -58,7 +58,7 @@ $confirm = GETPOST('confirm');
$lineid = GETPOST('lineid'); $lineid = GETPOST('lineid');
$mesg = GETPOST('mesg'); $mesg = GETPOST('mesg');
//PDF //PDF
$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
@ -69,10 +69,10 @@ $result=restrictedArea($user,'commande',$id,'');
$object = new Commande($db); $object = new Commande($db);
// Load object // Load object
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$ret=$object->fetch($id, $ref); $ret=$object->fetch($id, $ref);
} }
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
@ -512,18 +512,18 @@ else if ($action == 'setremiseabsolue' && $user->rights->commande->creer)
$result = $object->set_remise_absolue($user, $_POST['remise_absolue']); $result = $object->set_remise_absolue($user, $_POST['remise_absolue']);
} }
else if ($action == 'setnote_public' && $user->rights->commande->creer) else if ($action == 'setnote_public' && $user->rights->commande->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
else if ($action == 'setnote' && $user->rights->commande->creer) else if ($action == 'setnote' && $user->rights->commande->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
/* /*
@ -1227,64 +1227,64 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
} }
} }
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
if ($action == 'addcontact' && $user->rights->commande->creer) if ($action == 'addcontact' && $user->rights->commande->creer)
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
} }
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
else else
{ {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
} }
else else
{ {
$mesg = '<div class="error">'.$object->error.'</div>'; $mesg = '<div class="error">'.$object->error.'</div>';
} }
} }
} }
// bascule du statut d'un contact // bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->commande->creer) else if ($action == 'swapstatut' && $user->rights->commande->creer)
{ {
if ($object->fetch($id)) if ($object->fetch($id))
{ {
$result=$object->swapContactStatus(GETPOST('ligne')); $result=$object->swapContactStatus(GETPOST('ligne'));
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
// Efface un contact // Efface un contact
else if ($action == 'deletecontact' && $user->rights->commande->creer) else if ($action == 'deletecontact' && $user->rights->commande->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->delete_contact($lineid); $result = $object->delete_contact($lineid);
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
else { else {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
@ -2052,24 +2052,24 @@ else
print '<td colspan="2">'.$object->getLibStatut(4).'</td>'; print '<td colspan="2">'.$object->getLibStatut(4).'</td>';
print '</tr>'; print '</tr>';
print '</table><br>'; print '</table><br>';
print "\n"; print "\n";
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db); $formcompany= new FormCompany($db);
$blocname = 'contacts'; $blocname = 'contacts';
$title = $langs->trans('ContactsAddresses'); $title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
} }
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$blocname = 'notes'; $blocname = 'notes';
$title = $langs->trans('Notes'); $title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
} }
/* /*

View File

@ -44,7 +44,7 @@ $sref_client=GETPOST('sref_client');
$sall=GETPOST('sall'); $sall=GETPOST('sall');
$socid=GETPOST('socid','int'); $socid=GETPOST('socid','int');
if (! $user->rights->facture->creer) if (! $user->rights->facture->creer)
accessforbidden(); accessforbidden();
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
@ -52,9 +52,9 @@ $sortorder = GETPOST("sortorder",'alpha');
if (! $sortfield) $sortfield='c.rowid'; if (! $sortfield) $sortfield='c.rowid';
if (! $sortorder) $sortorder='DESC'; if (! $sortorder) $sortorder='DESC';
$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); // Date for local PHP server $date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); // Date for local PHP server
$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); $date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
$date_starty=dol_mktime(0,0,0,$_REQUEST["date_start_delymonth"],$_REQUEST["date_start_delyday"],$_REQUEST["date_start_delyyear"]); // Date for local PHP server $date_starty=dol_mktime(0,0,0,$_REQUEST["date_start_delymonth"],$_REQUEST["date_start_delyday"],$_REQUEST["date_start_delyyear"]); // Date for local PHP server
$date_endy=dol_mktime(23,59,59,$_REQUEST["date_end_delymonth"],$_REQUEST["date_end_delyday"],$_REQUEST["date_end_delyyear"]); $date_endy=dol_mktime(23,59,59,$_REQUEST["date_end_delymonth"],$_REQUEST["date_end_delyday"],$_REQUEST["date_end_delyyear"]);
$selected=GETPOST('orders_to_invoice'); $selected=GETPOST('orders_to_invoice');
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
@ -78,399 +78,399 @@ $formfile = new FormFile($db);
$companystatic = new Societe($db); $companystatic = new Societe($db);
$htmlother = new FormOther($db); $htmlother = new FormOther($db);
/* /*
* Actions * Actions
*/ */
if (($action == 'create' || $action == 'add') && ! $mesg ) if (($action == 'create' || $action == 'add') && ! $mesg )
{ {
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'); require_once(DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php');
require_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'); require_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php');
require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php');
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php');
$langs->load('bills'); $langs->load('bills');
$langs->load('products'); $langs->load('products');
$langs->load('main'); $langs->load('main');
if (isset($_GET['orders_to_invoice'])) if (isset($_GET['orders_to_invoice']))
{ {
$orders_id = $_GET['orders_to_invoice']; $orders_id = $_GET['orders_to_invoice'];
$n = count($orders_id); $n = count($orders_id);
$i = 0; $i = 0;
$originid=$orders_id[0];
$_GET['originid']=$orders_id[0];
}
if (isset($_POST['orders_to_invoice']))
{
$orders_id = $_POST['orders_to_invoice'];
$nn = count($orders_id);
$ii = 0;
$originid=$orders_id[0];
$_POST['originid']=$orders_id[0];
}
if (GETPOST('mesg','int',1) && isset($_SESSION['message'])) $mesg=$_SESSION['message'];
$sall=isset($_GET['sall'])?trim($_GET['sall']):trim($_POST['sall']);
$projectid=isset($_GET['projectid'])?$_GET['projectid']:0;
$id =(GETPOST('id')?GETPOST("id"):GETPOST("facid")); // For backward compatibility
$ref =GETPOST('ref');
$socid =GETPOST('socid');
$action =GETPOST('action');
$confirm =GETPOST('confirm');
$lineid =GETPOST('lineid');
$userid =GETPOST('userid');
$search_ref =GETPOST('sf_ref')?GETPOST('sf_ref'):GETPOST('search_ref');
// Security check $originid=$orders_id[0];
$fieldid = isset($_GET["ref"])?'facnumber':'rowid'; $_GET['originid']=$orders_id[0];
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'facture', $id,'','','fk_soc',$fieldid); }
if (isset($_POST['orders_to_invoice']))
$usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; {
$orders_id = $_POST['orders_to_invoice'];
$nn = count($orders_id);
$ii = 0;
$originid=$orders_id[0];
$_POST['originid']=$orders_id[0];
}
if (GETPOST('mesg','int',1) && isset($_SESSION['message'])) $mesg=$_SESSION['message'];
$sall=isset($_GET['sall'])?trim($_GET['sall']):trim($_POST['sall']);
$projectid=isset($_GET['projectid'])?$_GET['projectid']:0;
$id =(GETPOST('id')?GETPOST("id"):GETPOST("facid")); // For backward compatibility
$ref =GETPOST('ref');
$socid =GETPOST('socid');
$action =GETPOST('action');
$confirm =GETPOST('confirm');
$lineid =GETPOST('lineid');
$userid =GETPOST('userid');
$search_ref =GETPOST('sf_ref')?GETPOST('sf_ref'):GETPOST('search_ref');
// Security check
$fieldid = isset($_GET["ref"])?'facnumber':'rowid';
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'facture', $id,'','','fk_soc',$fieldid);
$usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE;
$object=new Facture($db); $object=new Facture($db);
// Insert new invoice in database // Insert new invoice in database
if ($action == 'add' && $user->rights->facture->creer) if ($action == 'add' && $user->rights->facture->creer)
{ {
$object->socid=GETPOST('socid'); $object->socid=GETPOST('socid');
$db->begin(); $db->begin();
$error=0; $error=0;
// Standard or deposit or proforma invoice // Standard or deposit or proforma invoice
if ($_POST['type'] == 0 ) if ($_POST['type'] == 0 )
{ {
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
if (empty($datefacture)) if (empty($datefacture))
{ {
$datefacture = dol_mktime(12, 0, 0, date("m"), date("d"), date("Y")); $datefacture = dol_mktime(12, 0, 0, date("m"), date("d"), date("Y"));
} }
if (! $error) if (! $error)
{ {
// Si facture standard // Si facture standard
$object->socid = $_POST['socid']; $object->socid = $_POST['socid'];
$object->type = $_POST['type']; $object->type = $_POST['type'];
$object->number = $_POST['facnumber']; $object->number = $_POST['facnumber'];
$object->date = $datefacture; $object->date = $datefacture;
$object->note_public = trim($_POST['note_public']); $object->note_public = trim($_POST['note_public']);
$object->note = trim($_POST['note']); $object->note = trim($_POST['note']);
$object->ref_client = $_POST['ref_client']; $object->ref_client = $_POST['ref_client'];
$object->ref_int = $_POST['ref_int']; $object->ref_int = $_POST['ref_int'];
$object->modelpdf = $_POST['model']; $object->modelpdf = $_POST['model'];
$object->fk_project = $_POST['projectid']; $object->fk_project = $_POST['projectid'];
$object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']); $object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']);
$object->mode_reglement_id = $_POST['mode_reglement_id']; $object->mode_reglement_id = $_POST['mode_reglement_id'];
$object->amount = $_POST['amount']; $object->amount = $_POST['amount'];
$object->remise_absolue = $_POST['remise_absolue']; $object->remise_absolue = $_POST['remise_absolue'];
$object->remise_percent = $_POST['remise_percent']; $object->remise_percent = $_POST['remise_percent'];
if ($_POST['origin'] && $_POST['originid']) if ($_POST['origin'] && $_POST['originid'])
{ {
$object->origin = $_POST['origin']; $object->origin = $_POST['origin'];
$object->origin_id = $orders_id[$ii]; $object->origin_id = $orders_id[$ii];
$object->linked_objects = $orders_id; $object->linked_objects = $orders_id;
$id = $object->create($user); $id = $object->create($user);
if ($id>0) if ($id>0)
{ {
foreach($orders_id as $origin => $origin_id) foreach($orders_id as $origin => $origin_id)
{ {
$origin_id = (! empty($origin_id) ? $origin_id : $object->origin_id); $origin_id = (! empty($origin_id) ? $origin_id : $object->origin_id);
$db->begin(); $db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
$sql.= "fk_source"; $sql.= "fk_source";
$sql.= ", sourcetype"; $sql.= ", sourcetype";
$sql.= ", fk_target"; $sql.= ", fk_target";
$sql.= ", targettype"; $sql.= ", targettype";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= $origin_id; $sql.= $origin_id;
$sql.= ", '".$object->origin."'"; $sql.= ", '".$object->origin."'";
$sql.= ", ".$id; $sql.= ", ".$id;
$sql.= ", '".$object->element."'"; $sql.= ", '".$object->element."'";
$sql.= ")"; $sql.= ")";
if ($db->query($sql)) if ($db->query($sql))
{ {
$db->commit(); $db->commit();
}
else
{
$db->rollback();
} }
} else
{
while ($ii < $nn) $db->rollback();
{ }
dol_include_once('/commande/class/commande.class.php'); }
$srcobject = new Commande($db);
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); while ($ii < $nn)
$result=$srcobject->fetch($orders_id[$ii]); {
if ($result > 0) dol_include_once('/commande/class/commande.class.php');
$srcobject = new Commande($db);
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
$result=$srcobject->fetch($orders_id[$ii]);
if ($result > 0)
{ {
$srcobject->classer_facturee(); $srcobject->classer_facturee();
$srcobject->setStatut(3); $srcobject->setStatut(3);
$lines = $srcobject->lines; $lines = $srcobject->lines;
if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
$fk_parent_line=0; $fk_parent_line=0;
$num=count($lines); $num=count($lines);
for ($i=0;$i<$num;$i++) for ($i=0;$i<$num;$i++)
{ {
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
if ($lines[$i]->subprice < 0) if ($lines[$i]->subprice < 0)
{ {
// Negative line, we create a discount line // Negative line, we create a discount line
$discount = new DiscountAbsolute($db); $discount = new DiscountAbsolute($db);
$discount->fk_soc=$object->socid; $discount->fk_soc=$object->socid;
$discount->amount_ht=abs($lines[$i]->total_ht); $discount->amount_ht=abs($lines[$i]->total_ht);
$discount->amount_tva=abs($lines[$i]->total_tva); $discount->amount_tva=abs($lines[$i]->total_tva);
$discount->amount_ttc=abs($lines[$i]->total_ttc); $discount->amount_ttc=abs($lines[$i]->total_ttc);
$discount->tva_tx=$lines[$i]->tva_tx; $discount->tva_tx=$lines[$i]->tva_tx;
$discount->fk_user=$user->id; $discount->fk_user=$user->id;
$discount->description=$desc; $discount->description=$desc;
$discountid=$discount->create($user); $discountid=$discount->create($user);
if ($discountid > 0) if ($discountid > 0)
{ {
$result=$object->insert_discount($discountid); $result=$object->insert_discount($discountid);
//$result=$discount->link_to_invoice($lineid,$id); //$result=$discount->link_to_invoice($lineid,$id);
} }
else else
{ {
$mesg=$discount->error; $mesg=$discount->error;
$error++; $error++;
break; break;
} }
} }
else else
{ {
// Positive line // Positive line
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
// Date start // Date start
$date_start=false; $date_start=false;
if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
//Date end //Date end
$date_end=false; $date_end=false;
if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
// Reset fk_parent_line for no child products and special product // Reset fk_parent_line for no child products and special product
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
{ {
$fk_parent_line = 0; $fk_parent_line = 0;
} }
$result = $object->addline( $result = $object->addline(
$id, $id,
$desc, $desc,
$lines[$i]->subprice, $lines[$i]->subprice,
$lines[$i]->qty, $lines[$i]->qty,
$lines[$i]->tva_tx, $lines[$i]->tva_tx,
$lines[$i]->localtax1_tx, $lines[$i]->localtax1_tx,
$lines[$i]->localtax2_tx, $lines[$i]->localtax2_tx,
$lines[$i]->fk_product, $lines[$i]->fk_product,
$lines[$i]->remise_percent, $lines[$i]->remise_percent,
$date_start, $date_start,
$date_end, $date_end,
0, 0,
$lines[$i]->info_bits, $lines[$i]->info_bits,
$lines[$i]->fk_remise_except, $lines[$i]->fk_remise_except,
'HT', 'HT',
0, 0,
$product_type, $product_type,
$lines[$i]->rang, $lines[$i]->rang,
$lines[$i]->special_code, $lines[$i]->special_code,
$object->origin, $object->origin,
$lines[$i]->rowid, $lines[$i]->rowid,
$fk_parent_line $fk_parent_line
); );
if ($result > 0) if ($result > 0)
{ {
$lineid=$result; $lineid=$result;
} }
else else
{ {
$lineid=0; $lineid=0;
$error++; $error++;
break; break;
} }
// Defined the new fk_parent_line // Defined the new fk_parent_line
if ($result > 0 && $lines[$i]->product_type == 9) if ($result > 0 && $lines[$i]->product_type == 9)
{ {
$fk_parent_line = $result; $fk_parent_line = $result;
} }
} }
} }
}
else
{
$mesg=$srcobject->error;
$error++;
} }
$ii++; else
{
$mesg=$srcobject->error;
$error++;
}
$ii++;
} }
} }
else else
{ {
$mesg=$object->error; $mesg=$object->error;
$error++; $error++;
} }
} }
} }
} }
// End of object creation, we show it // End of object creation, we show it
if ($id > 0 && ! $error) if ($id > 0 && ! $error)
{ {
$db->commit(); $db->commit();
Header('Location: '.DOL_URL_ROOT.'/compta/facture.php?facid='.$id); Header('Location: '.DOL_URL_ROOT.'/compta/facture.php?facid='.$id);
exit; exit;
} }
else else
{ {
$db->rollback(); $db->rollback();
$action='create'; $action='create';
$_GET["origin"]=$_POST["origin"]; $_GET["origin"]=$_POST["origin"];
$_GET["originid"]=$_POST["originid"]; $_GET["originid"]=$_POST["originid"];
if (! $mesg) $mesg='<div class="error">'.$object->error.'</div>'; if (! $mesg) $mesg='<div class="error">'.$object->error.'</div>';
} }
} }
/* /*
* View * View
*/ */
$html = new Form($db); $html = new Form($db);
$htmlother = new FormOther($db); $htmlother = new FormOther($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$now=dol_now(); $now=dol_now();
// Mode creation // Mode creation
if ($action == 'create') if ($action == 'create')
{ {
$facturestatic=new Facture($db); $facturestatic=new Facture($db);
llxHeader(); llxHeader();
print_fiche_titre($langs->trans('NewBill')); print_fiche_titre($langs->trans('NewBill'));
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
$soc = new Societe($db); $soc = new Societe($db);
if ($socid) $res=$soc->fetch($socid); if ($socid) $res=$soc->fetch($socid);
if ($res) if ($res)
{ {
$cond_reglement_id = $soc->cond_reglement_id; $cond_reglement_id = $soc->cond_reglement_id;
$mode_reglement_id = $soc->mode_reglement_id; $mode_reglement_id = $soc->mode_reglement_id;
$remise_percent = $soc->remise_percent; $remise_percent = $soc->remise_percent;
} }
$remise_absolue = 0; $remise_absolue = 0;
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
$absolute_discount=$soc->getAvailableDiscounts(); $absolute_discount=$soc->getAvailableDiscounts();
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n"; print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n";
print '<input name="facnumber" type="hidden" value="provisoire">'; print '<input name="facnumber" type="hidden" value="provisoire">';
print '<input name="ref_client" type="hidden" value="'.$ref_client.'">'; print '<input name="ref_client" type="hidden" value="'.$ref_client.'">';
print '<input name="ref_int" type="hidden" value="'.$ref_int.'">'; print '<input name="ref_int" type="hidden" value="'.$ref_int.'">';
print '<input type="hidden" name="origin" value="'.GETPOST('origin').'">'; print '<input type="hidden" name="origin" value="'.GETPOST('origin').'">';
print '<input type="hidden" name="originid" value="'.GETPOST('originid').'">'; print '<input type="hidden" name="originid" value="'.GETPOST('originid').'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>';
// Tiers // Tiers
print '<tr><td class="fieldrequired">'.$langs->trans('Customer').'</td><td colspan="2">'; print '<tr><td class="fieldrequired">'.$langs->trans('Customer').'</td><td colspan="2">';
print $soc->getNomUrl(1); print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="'.$soc->id.'">'; print '<input type="hidden" name="socid" value="'.$soc->id.'">';
print '</td>'; print '</td>';
print '</tr>'."\n"; print '</tr>'."\n";
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('Type').'</td><td colspan="2">'; print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('Type').'</td><td colspan="2">';
print '<table class="nobordernopadding">'."\n"; print '<table class="nobordernopadding">'."\n";
// Standard invoice // Standard invoice
print '<tr height="18"><td width="16px" valign="middle">'; print '<tr height="18"><td width="16px" valign="middle">';
print '<input type="radio" name="type" value="0"'.(GETPOST('type')==0?' checked="true"':'').'>'; print '<input type="radio" name="type" value="0"'.(GETPOST('type')==0?' checked="true"':'').'>';
print '</td><td valign="middle">'; print '</td><td valign="middle">';
$desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1); $desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1);
print $desc; print $desc;
print '</td></tr>'."\n"; print '</td></tr>'."\n";
print '</table>'; print '</table>';
// Date invoice // Date invoice
print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td colspan="2">'; print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td colspan="2">';
$html->select_date(0,'','','','',"add",1,1); $html->select_date(0,'','','','',"add",1,1);
print '</td></tr>'; print '</td></tr>';
// Payment term // Payment term
print '<tr><td nowrap>'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">'; print '<tr><td nowrap>'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">';
$html->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id'); $html->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id');
print '</td></tr>'; print '</td></tr>';
// Payment mode // Payment mode
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">';
$html->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id'); $html->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id');
print '</td></tr>'; print '</td></tr>';
// Project // Project
if ($conf->projet->enabled) if ($conf->projet->enabled)
{ {
$langs->load('projects'); $langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
select_projects($soc->id, $projectid, 'projectid'); select_projects($soc->id, $projectid, 'projectid');
print '</td></tr>'; print '</td></tr>';
} }
// Modele PDF // Modele PDF
print '<tr><td>'.$langs->trans('Model').'</td>'; print '<tr><td>'.$langs->trans('Model').'</td>';
print '<td>'; print '<td>';
include_once(DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'); include_once(DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php');
$liste=ModelePDFFactures::liste_modeles($db); $liste=ModelePDFFactures::liste_modeles($db);
print $html->selectarray('model',$liste,$conf->global->FACTURE_ADDON_PDF); print $html->selectarray('model',$liste,$conf->global->FACTURE_ADDON_PDF);
print "</td></tr>"; print "</td></tr>";
// Public note // Public note
print '<tr>'; print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>'; print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>';
print '<td valign="top" colspan="2">'; print '<td valign="top" colspan="2">';
print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">'; print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">';
dol_include_once('/commande/class/commande.class.php'); dol_include_once('/commande/class/commande.class.php');
$srcobject = new Commande($db); $srcobject = new Commande($db);
$commandes = $langs->trans("Orders").": "; $commandes = $langs->trans("Orders").": ";
foreach ($selected as $sel) foreach ($selected as $sel)
{ {
$result=$srcobject->fetch($sel); $result=$srcobject->fetch($sel);
if ($result > 0) if ($result > 0)
{ {
$commandes.= $srcobject->ref." "; $commandes.= $srcobject->ref." ";
} }
} }
print $commandes; print $commandes;
print '</textarea></td></tr>'; print '</textarea></td></tr>';
// Private note // Private note
if (! $user->societe_id) if (! $user->societe_id)
{ {
print '<tr>'; print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>'; print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
print '<td valign="top" colspan="2">'; print '<td valign="top" colspan="2">';
print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">'; print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">';
print '</textarea></td></tr>'; print '</textarea></td></tr>';
} }
print '</table>'; print '</table>';
print '</td></tr>'; print '</td></tr>';
} }
while ($i < $n) while ($i < $n)
{ {
print '<input type="hidden" name="orders_to_invoice[]" value="'.$orders_id[$i].'">'; print '<input type="hidden" name="orders_to_invoice[]" value="'.$orders_id[$i].'">';
$i++; $i++;
} }
print "</table>\n"; print "</table>\n";
// Button "Create Draft" // Button "Create Draft"
print '<br><center><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></center>'; print '<br><center><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></center>';
print "</form>\n"; print "</form>\n";
} }
@ -513,7 +513,7 @@ else
//Date filter //Date filter
if ($date_start && $date_end) $sql.= " AND c.date_commande >= '".$db->idate($date_start)."' AND c.date_commande <= '".$db->idate($date_end)."'"; if ($date_start && $date_end) $sql.= " AND c.date_commande >= '".$db->idate($date_start)."' AND c.date_commande <= '".$db->idate($date_end)."'";
if ($date_starty && $date_endy) $sql.= " AND c.date_livraison >= '".$db->idate($date_starty)."' AND c.date_livraison <= '".$db->idate($date_endy)."'"; if ($date_starty && $date_endy) $sql.= " AND c.date_livraison >= '".$db->idate($date_starty)."' AND c.date_livraison <= '".$db->idate($date_endy)."'";
if (!empty($sref_client)) if (!empty($sref_client))
{ {
@ -538,14 +538,14 @@ else
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
print_fiche_titre($title); print_fiche_titre($title);
$i = 0; $i = 0;
$period=$html->select_date($date_start,'date_start',0,0,1,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,1,'',1,0,1); $period=$html->select_date($date_start,'date_start',0,0,1,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,1,'',1,0,1);
$periodely=$html->select_date($date_starty,'date_start_dely',0,0,1,'',1,0,1).' - '.$html->select_date($date_endy,'date_end_dely',0,0,1,'',1,0,1); $periodely=$html->select_date($date_starty,'date_start_dely',0,0,1,'',1,0,1).' - '.$html->select_date($date_endy,'date_end_dely',0,0,1,'',1,0,1);
// Company // Company
print '<h3>'; print '<h3>';
$companystatic->id=$socid; $companystatic->id=$socid;
$companystatic->nom=$soc->nom; $companystatic->nom=$soc->nom;
print $companystatic->getNomUrl(1,'customer'); print $companystatic->getNomUrl(1,'customer');
print '</h3>'; print '</h3>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -584,8 +584,8 @@ else
print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
//ALL/NONE //ALL/NONE
print '<td class="liste_titre" align="center">'; print '<td class="liste_titre" align="center">';
if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a>'; if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a>';
print '</td>'; print '</td>';
print '</td></tr>'; print '</td></tr>';
@ -625,13 +625,13 @@ else
print '<td>'.$objp->ref_client.'</td>'; print '<td>'.$objp->ref_client.'</td>';
// Order date // Order date
print '<td align="center" nowrap>'; print '<td align="center" nowrap>';
print dol_print_date($db->jdate($objp->date_commande),'day'); print dol_print_date($db->jdate($objp->date_commande),'day');
print '</td>'; print '</td>';
//Delivery date //Delivery date
print '<td align="center" nowrap>'; print '<td align="center" nowrap>';
print dol_print_date($db->jdate($objp->date_livraison),'day'); print dol_print_date($db->jdate($objp->date_livraison),'day');
print '</td>'; print '</td>';
// Statut // Statut
@ -650,15 +650,15 @@ else
} }
print '</table>'; print '</table>';
/* /*
* Boutons actions * Boutons actions
*/ */
print '<div align="right">'; print '<div align="right">';
print '<input type="hidden" name="socid" value="'.$socid.'">'; print '<input type="hidden" name="socid" value="'.$socid.'">';
print '<input type="hidden" name="action" value="create">'; print '<input type="hidden" name="action" value="create">';
print '<input type="hidden" name="origin" value="commande"><br>'; print '<input type="hidden" name="origin" value="commande"><br>';
print '<a class="butAction" href="index.php">'.$langs->trans("GoBack").'</a>'; print '<a class="butAction" href="index.php">'.$langs->trans("GoBack").'</a>';
print '<input type="submit" class="butAction" value='.$langs->trans("GenerateBill").'>'; print '<input type="submit" class="butAction" value='.$langs->trans("GenerateBill").'>';
print '</form>'; print '</form>';
$db->free($resql); $db->free($resql);
} }

View File

@ -499,8 +499,8 @@ else if ($id)
print "</table><br>"; print "</table><br>";
// Notes // Notes
$blocname = 'notes'; $blocname = 'notes';
$title = $langs->trans('Notes'); $title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
print '</div>'; print '</div>';

View File

@ -69,7 +69,7 @@ $search_societe=GETPOST('search_societe','alpha');
$search_montant_ht=GETPOST('search_montant_ht','alpha'); $search_montant_ht=GETPOST('search_montant_ht','alpha');
$search_montant_ttc=GETPOST('search_montant_ttc','alpha'); $search_montant_ttc=GETPOST('search_montant_ttc','alpha');
//PDF //PDF
$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
@ -86,10 +86,10 @@ $usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE;
$object=new Facture($db); $object=new Facture($db);
// Load object // Load object
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$ret=$object->fetch($id, $ref); $ret=$object->fetch($id, $ref);
} }
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
@ -1524,21 +1524,21 @@ else if ($action == 'builddoc') // En get ou en post
} }
} }
// Remove file in doc form // Remove file in doc form
else if ($action == 'remove_file') else if ($action == 'remove_file')
{ {
if ($object->fetch($id)) if ($object->fetch($id))
{ {
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$langs->load("other"); $langs->load("other");
$upload_dir = $conf->facture->dir_output; $upload_dir = $conf->facture->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object); dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>'; $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
} }
} }
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))

View File

@ -256,30 +256,30 @@ class Facture extends CommonObject
$error++; $error++;
} }
// TODO mutualiser // TODO mutualiser
if ($origin == 'commande') if ($origin == 'commande')
{ {
// On recupere les differents contact interne et externe // On recupere les differents contact interne et externe
$order = new Commande($this->db); $order = new Commande($this->db);
$order->id = $origin_id; $order->id = $origin_id;
// On recupere le commercial suivi propale // On recupere le commercial suivi propale
$this->userid = $order->getIdcontact('internal', 'SALESREPFOLL'); $this->userid = $order->getIdcontact('internal', 'SALESREPFOLL');
if ($this->userid) if ($this->userid)
{ {
//On passe le commercial suivi commande en commercial suivi paiement //On passe le commercial suivi commande en commercial suivi paiement
$this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal'); $this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
} }
// On recupere le contact client facturation commande // On recupere le contact client facturation commande
$this->contactid = $order->getIdcontact('external', 'BILLING'); $this->contactid = $order->getIdcontact('external', 'BILLING');
if ($this->contactid) if ($this->contactid)
{ {
//On passe le contact client facturation commande en contact client facturation //On passe le contact client facturation commande en contact client facturation
$this->add_contact($this->contactid[0], 'BILLING', 'external'); $this->add_contact($this->contactid[0], 'BILLING', 'external');
} }
} }
} }
} }
@ -674,11 +674,11 @@ class Facture extends CommonObject
$this->origin = $object->element; $this->origin = $object->element;
$this->origin_id = $object->id; $this->origin_id = $object->id;
// Possibility to add external linked objects with hooks // Possibility to add external linked objects with hooks
$this->linked_objects[$this->origin] = $this->origin_id; $this->linked_objects[$this->origin] = $this->origin_id;
if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
{ {
$this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
} }
$ret = $this->create($user); $ret = $this->create($user);
@ -1240,32 +1240,32 @@ class Facture extends CommonObject
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
// On efface le repertoire de pdf provisoire // On efface le repertoire de pdf provisoire
$ref = dol_sanitizeFileName($this->ref); $ref = dol_sanitizeFileName($this->ref);
if ($conf->facture->dir_output) if ($conf->facture->dir_output)
{ {
$dir = $conf->facture->dir_output . "/" . $ref; $dir = $conf->facture->dir_output . "/" . $ref;
$file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf"; $file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf";
if (file_exists($file)) // We must delete all files before deleting directory if (file_exists($file)) // We must delete all files before deleting directory
{ {
$ret=dol_delete_preview($this); $ret=dol_delete_preview($this);
if (! dol_delete_file($file,0,0,0,$this)) // For triggers if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{ {
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file); $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
$this->db->rollback(); $this->db->rollback();
return 0; return 0;
} }
} }
if (file_exists($dir)) if (file_exists($dir))
{ {
if (! dol_delete_dir_recursive($dir)) // For remove dir and meta if (! dol_delete_dir_recursive($dir)) // For remove dir and meta
{ {
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
$this->db->rollback(); $this->db->rollback();
return 0; return 0;
} }
} }
} }
$this->db->commit(); $this->db->commit();

View File

@ -43,11 +43,11 @@ $confirm = GETPOST('confirm');
$id = GETPOST('facid','int'); $id = GETPOST('facid','int');
$ref = GETPOST('ref'); $ref = GETPOST('ref');
$mesg=''; $mesg='';
if (isset($_SESSION['DolMessage'])) if (isset($_SESSION['DolMessage']))
{ {
$mesg=$_SESSION['DolMessage']; $mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']); unset($_SESSION['DolMessage']);
} }
// Security check // Security check

View File

@ -31,9 +31,9 @@ require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php');
$langs->load("companies"); $langs->load("companies");
$langs->load("bills"); $langs->load("bills");
$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility $id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
$ref=GETPOST('ref','alpha'); $ref=GETPOST('ref','alpha');
$socid=GETPOST('socid','int'); $socid=GETPOST('socid','int');
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
// Security check // Security check

View File

@ -791,35 +791,35 @@ class Contrat extends CommonObject
} }
} }
if (! $error) if (! $error)
{ {
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('CONTRACT_DELETE',$this,$user,$langs,$conf); $result=$interface->run_triggers('CONTRACT_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { if ($result < 0) {
$error++; $this->errors=$interface->errors; $error++; $this->errors=$interface->errors;
} }
// Fin appel triggers // Fin appel triggers
} }
if (! $error) if (! $error)
{ {
// We remove directory // We remove directory
$ref = dol_sanitizeFileName($this->ref); $ref = dol_sanitizeFileName($this->ref);
if ($conf->contrat->dir_output) if ($conf->contrat->dir_output)
{ {
$dir = $conf->contrat->dir_output . "/" . $ref; $dir = $conf->contrat->dir_output . "/" . $ref;
if (file_exists($dir)) if (file_exists($dir))
{ {
$res=@dol_delete_dir_recursive($dir); $res=@dol_delete_dir_recursive($dir);
if (! $res) if (! $res)
{ {
$this->error='ErrorFailToDeleteDir'; $this->error='ErrorFailToDeleteDir';
$error++; $error++;
} }
} }
} }
} }
if (! $error) if (! $error)

View File

@ -168,9 +168,9 @@ if ($id > 0 || ! empty($ref))
print '</div>'; print '</div>';
print '<br>'; print '<br>';
// Contacts lines // Contacts lines
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
} }

View File

@ -36,16 +36,16 @@ $langs->load("other");
$langs->load("products"); $langs->load("products");
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha'); $confirm = GETPOST('confirm','alpha');
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref = GETPOST('ref','alpha'); $ref = GETPOST('ref','alpha');
$mesg=''; $mesg='';
if (isset($_SESSION['DolMessage'])) if (isset($_SESSION['DolMessage']))
{ {
$mesg=$_SESSION['DolMessage']; $mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']); unset($_SESSION['DolMessage']);
} }
// Security check // Security check
@ -120,19 +120,19 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
} }
} }
// Delete // Delete
if ($action == 'confirm_deletefile' && $confirm == 'yes') if ($action == 'confirm_deletefile' && $confirm == 'yes')
{ {
if ($object->id) if ($object->id)
{ {
$langs->load("other"); $langs->load("other");
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object); $ret=dol_delete_file($file,0,0,0,$object);
$_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} }
} }
@ -178,13 +178,13 @@ if ($object->id)
dol_htmloutput_mesg($mesg,$mesgs); dol_htmloutput_mesg($mesg,$mesgs);
/* /*
* Confirmation suppression fichier * Confirmation suppression fichier
*/ */
if ($action == 'delete') if ($action == 'delete')
{ {
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }

View File

@ -428,113 +428,113 @@ else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contr
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer) else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer)
{ {
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$result=$object->delete($user); $result=$object->delete($user);
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: index.php"); Header("Location: index.php");
return; return;
} }
else else
{ {
$mesg='<div class="error">'.$object->error.'</div>'; $mesg='<div class="error">'.$object->error.'</div>';
} }
} }
else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer)
{ {
if ($_POST['newcid'] > 0) if ($_POST['newcid'] > 0)
{ {
$contractline = new ContratLigne($db); $contractline = new ContratLigne($db);
$result=$contractline->fetch($_GET["lineid"]); $result=$contractline->fetch($_GET["lineid"]);
$contractline->fk_contrat = $_POST["newcid"]; $contractline->fk_contrat = $_POST["newcid"];
$result=$contractline->update($user,1); $result=$contractline->update($user,1);
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
return; return;
} }
else else
{ {
$mesg='<div class="error">'.$object->error.'</div>'; $mesg='<div class="error">'.$object->error.'</div>';
} }
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("RefNewContract")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("RefNewContract")).'</div>';
} }
} }
else if ($action == 'setnote_public' && $user->rights->contrat->creer) else if ($action == 'setnote_public' && $user->rights->contrat->creer)
{ {
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->contrat->creer)
{
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
} }
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) else if ($action == 'setnote' && $user->rights->contrat->creer)
{ {
if ($action == 'addcontact' && $user->rights->contrat->creer) $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
{ if ($result < 0) dol_print_error($db,$object->error);
$result = $object->fetch($id); }
if ($result > 0 && $id > 0) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
if ($action == 'addcontact' && $user->rights->contrat->creer)
{
$result = $object->fetch($id);
if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
} }
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
else else
{ {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
} }
else else
{ {
$mesg = '<div class="error">'.$object->error.'</div>'; $mesg = '<div class="error">'.$object->error.'</div>';
} }
} }
} }
// bascule du statut d'un contact // bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->contrat->creer) else if ($action == 'swapstatut' && $user->rights->contrat->creer)
{ {
if ($object->fetch($id)) if ($object->fetch($id))
{ {
$result=$object->swapContactStatus(GETPOST('ligne')); $result=$object->swapContactStatus(GETPOST('ligne'));
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
// Efface un contact // Efface un contact
else if ($action == 'deletecontact' && $user->rights->contrat->creer) else if ($action == 'deletecontact' && $user->rights->contrat->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->delete_contact($_GET["lineid"]); $result = $object->delete_contact($_GET["lineid"]);
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
else { else {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
@ -783,21 +783,21 @@ else
echo '<br>'; echo '<br>';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db); $formcompany= new FormCompany($db);
$blocname = 'contacts'; $blocname = 'contacts';
$title = $langs->trans('ContactsAddresses'); $title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
} }
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$blocname = 'notes'; $blocname = 'notes';
$title = $langs->trans('Notes'); $title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
} }

View File

@ -30,9 +30,9 @@ require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
$langs->load("companies"); $langs->load("companies");
$langs->load("contracts"); $langs->load("contracts");
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$socid=GETPOST('socid','int'); $socid=GETPOST('socid','int');
$id=GETPOST('id','int'); $id=GETPOST('id','int');
$ref=GETPOST('ref','alpha'); $ref=GETPOST('ref','alpha');

View File

@ -57,7 +57,7 @@ header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size'); header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
switch ($_SERVER['REQUEST_METHOD']) { switch ($_SERVER['REQUEST_METHOD']) {
case 'OPTIONS': case 'OPTIONS':
break; break;
case 'HEAD': case 'HEAD':
case 'GET': case 'GET':

View File

@ -90,7 +90,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
$module = $subelement = $ext_element; $module = $subelement = $ext_element;
if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
{ {
$module = $regs[1]; $module = $regs[1];
$subelement = $regs[2]; $subelement = $regs[2];
} }

View File

@ -30,9 +30,9 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
require('../../main.inc.php'); require('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
$field = GETPOST('field','alpha',2); $field = GETPOST('field','alpha',2);
$element = GETPOST('element','alpha',2); $element = GETPOST('element','alpha',2);
$table_element = GETPOST('table_element','alpha',2); $table_element = GETPOST('table_element','alpha',2);
$fk_element = GETPOST('fk_element','alpha',2); $fk_element = GETPOST('fk_element','alpha',2);
/* /*
@ -132,11 +132,11 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
} }
else else
{ {
$module = $subelement = $ext_element; $module = $subelement = $ext_element;
if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
{ {
$module = $regs[1]; $module = $regs[1];
$subelement = $regs[2]; $subelement = $regs[2];
} }
dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php'); dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php');

View File

@ -49,12 +49,12 @@ if (! empty($id) && ! empty($action) && ! empty($htmlname))
$soc->fetch($id); $soc->fetch($id);
$return=array(); $return=array();
$return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true); $return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true);
$return['num'] = $form->num; $return['num'] = $form->num;
$return['error'] = $form->error; $return['error'] = $form->error;
echo json_encode($return); echo json_encode($return);
} }

View File

@ -206,28 +206,28 @@ class Conf
//var_dump($this->modules); //var_dump($this->modules);
//var_dump($this->modules_parts); //var_dump($this->modules_parts);
// Object $mc // Object $mc
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
{ {
global $mc; global $mc;
$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php'); $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
if ($ret) $mc = new ActionsMulticompany($db); if ($ret) $mc = new ActionsMulticompany($db);
} }
// Second or others levels object // Second or others levels object
$this->propal->cloture = (object) array(); $this->propal->cloture = (object) array();
$this->propal->facturation = (object) array(); $this->propal->facturation = (object) array();
$this->commande->client = (object) array(); $this->commande->client = (object) array();
$this->commande->fournisseur = (object) array(); $this->commande->fournisseur = (object) array();
$this->facture->client = (object) array(); $this->facture->client = (object) array();
$this->facture->fournisseur = (object) array(); $this->facture->fournisseur = (object) array();
$this->fournisseur->commande = (object) array(); $this->fournisseur->commande = (object) array();
$this->fournisseur->facture = (object) array(); $this->fournisseur->facture = (object) array();
$this->contrat->services = (object) array(); $this->contrat->services = (object) array();
$this->contrat->services->inactifs = (object) array(); $this->contrat->services->inactifs = (object) array();
$this->contrat->services->expires = (object) array(); $this->contrat->services->expires = (object) array();
$this->adherent->cotisation = (object) array(); $this->adherent->cotisation = (object) array();
$this->bank->rappro = (object) array(); $this->bank->rappro = (object) array();
$this->bank->cheque = (object) array(); $this->bank->cheque = (object) array();
// Clean some variables // Clean some variables
@ -261,7 +261,7 @@ class Conf
// Define default dir_output and dir_temp for directories of modules // Define default dir_output and dir_temp for directories of modules
foreach($this->modules as $module) foreach($this->modules as $module)
{ {
$this->$module->multidir_output = array($this->entity => $rootfordata."/".$module); $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
$this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp"); $this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp");
// For backward compatibility // For backward compatibility
$this->$module->dir_output = $rootfordata."/".$module; $this->$module->dir_output = $rootfordata."/".$module;
@ -277,14 +277,14 @@ class Conf
$this->admin->dir_temp=$rootfordata.'/admin/temp'; $this->admin->dir_temp=$rootfordata.'/admin/temp';
// For user storage // For user storage
$this->user->multidir_output = array($this->entity => $rootfordata."/users"); $this->user->multidir_output = array($this->entity => $rootfordata."/users");
$this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp"); $this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp");
// For backward compatibility // For backward compatibility
$this->user->dir_output=$rootforuser."/users"; $this->user->dir_output=$rootforuser."/users";
$this->user->dir_temp=$rootforuser."/users/temp"; $this->user->dir_temp=$rootforuser."/users/temp";
// For propal storage // For propal storage
$this->propal->dir_output=$rootforuser."/propale"; $this->propal->dir_output=$rootforuser."/propale";
$this->propal->dir_temp=$rootforuser."/propale/temp"; $this->propal->dir_temp=$rootforuser."/propale/temp";
// Exception: Some dir are not the name of module. So we keep exception here // Exception: Some dir are not the name of module. So we keep exception here
@ -307,9 +307,9 @@ class Conf
$this->service->multidir_output=array($this->entity => $rootfordata."/produit"); $this->service->multidir_output=array($this->entity => $rootfordata."/produit");
$this->service->multidir_temp =array($this->entity => $rootfordata."/produit/temp"); $this->service->multidir_temp =array($this->entity => $rootfordata."/produit/temp");
// For backward compatibility // For backward compatibility
$this->product->dir_output=$rootfordata."/produit"; $this->product->dir_output=$rootfordata."/produit";
$this->product->dir_temp =$rootfordata."/produit/temp"; $this->product->dir_temp =$rootfordata."/produit/temp";
$this->service->dir_output=$rootfordata."/produit"; $this->service->dir_output=$rootfordata."/produit";
$this->service->dir_temp =$rootfordata."/produit/temp"; $this->service->dir_temp =$rootfordata."/produit/temp";
// Module contrat // Module contrat
@ -429,10 +429,10 @@ class Conf
if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_backoffice.php'; if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_backoffice.php';
elseif ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_backoffice.php'; elseif ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_backoffice.php';
// Object $mc // Object $mc
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
{ {
if (is_object($mc)) $mc->setValues($this); if (is_object($mc)) $mc->setValues($this);
} }
} }
} }

View File

@ -65,9 +65,9 @@ class FileUpload
$pathname = 'compta/facture'; $pathname = 'compta/facture';
$dir_output=$conf->$element->dir_output; $dir_output=$conf->$element->dir_output;
} }
elseif ($element == 'project') { elseif ($element == 'project') {
$element = $pathname = 'projet'; $element = $pathname = 'projet';
$dir_output=$conf->$element->dir_output; $dir_output=$conf->$element->dir_output;
} }
elseif ($element == 'fichinter') { elseif ($element == 'fichinter') {
$element='ficheinter'; $element='ficheinter';
@ -108,11 +108,11 @@ class FileUpload
'accept_file_types' => '/.+$/i', 'accept_file_types' => '/.+$/i',
// The maximum number of files for the upload directory: // The maximum number of files for the upload directory:
'max_number_of_files' => null, 'max_number_of_files' => null,
// Image resolution restrictions: // Image resolution restrictions:
'max_width' => null, 'max_width' => null,
'max_height' => null, 'max_height' => null,
'min_width' => 1, 'min_width' => 1,
'min_height' => 1, 'min_height' => 1,
// Set the following option to false to enable resumable uploads: // Set the following option to false to enable resumable uploads:
'discard_aborted_uploads' => true, 'discard_aborted_uploads' => true,
'image_versions' => array( 'image_versions' => array(
@ -131,7 +131,7 @@ class FileUpload
'thumbnail' => array( 'thumbnail' => array(
'upload_dir' => $dir_output . '/' . $object->ref . '/thumbs/', 'upload_dir' => $dir_output . '/' . $object->ref . '/thumbs/',
'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$object->ref.'/thumbs/', 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$object->ref.'/thumbs/',
'max_width' => 80, 'max_width' => 80,
'max_height' => 80 'max_height' => 80
) )
) )
@ -148,14 +148,14 @@ class FileUpload
*/ */
protected function getFullUrl() protected function getFullUrl()
{ {
$https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'; $https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
return return
($https ? 'https://' : 'http://'). ($https ? 'https://' : 'http://').
(!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : ''). (!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : '').
(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME']. (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].
($https && $_SERVER['SERVER_PORT'] === 443 || ($https && $_SERVER['SERVER_PORT'] === 443 ||
$_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))). $_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))).
substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/')); substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
} }
/** /**
@ -165,13 +165,13 @@ class FileUpload
* @return void * @return void
*/ */
protected function setFileDeleteUrl($file) protected function setFileDeleteUrl($file)
{ {
$file->delete_url = $this->options['script_url'] $file->delete_url = $this->options['script_url']
.'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element; .'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element;
$file->delete_type = $this->options['delete_type']; $file->delete_type = $this->options['delete_type'];
if ($file->delete_type !== 'DELETE') { if ($file->delete_type !== 'DELETE') {
$file->delete_url .= '&_method=DELETE'; $file->delete_url .= '&_method=DELETE';
} }
} }
/** /**
@ -260,9 +260,9 @@ class FileUpload
$file->error = $error; $file->error = $error;
return false; return false;
} }
if (!$file->name) { if (!$file->name) {
$file->error = 'missingFileName'; $file->error = 'missingFileName';
return false; return false;
} }
if (!preg_match($this->options['accept_file_types'], $file->name)) { if (!preg_match($this->options['accept_file_types'], $file->name)) {
$file->error = 'acceptFileTypes'; $file->error = 'acceptFileTypes';
@ -314,10 +314,10 @@ class FileUpload
* @return string ??? * @return string ???
*/ */
protected function upcountNameCallback($matches) protected function upcountNameCallback($matches)
{ {
$index = isset($matches[1]) ? intval($matches[1]) + 1 : 1; $index = isset($matches[1]) ? intval($matches[1]) + 1 : 1;
$ext = isset($matches[2]) ? $matches[2] : ''; $ext = isset($matches[2]) ? $matches[2] : '';
return ' ('.$index.')'.$ext; return ' ('.$index.')'.$ext;
} }
/** /**
@ -327,8 +327,8 @@ class FileUpload
* @return string ??? * @return string ???
*/ */
protected function upcountName($name) protected function upcountName($name)
{ {
return preg_replace_callback('/(?:(?: \(([\d]+)\))?(\.[^.]+))?$/', array($this, 'upcountNameCallback'), $name, 1); return preg_replace_callback('/(?:(?: \(([\d]+)\))?(\.[^.]+))?$/', array($this, 'upcountNameCallback'), $name, 1);
} }
/** /**
@ -340,24 +340,24 @@ class FileUpload
* @return void * @return void
*/ */
protected function trimFileName($name, $type, $index) protected function trimFileName($name, $type, $index)
{ {
// Remove path information and dots around the filename, to prevent uploading // Remove path information and dots around the filename, to prevent uploading
// into different directories or replacing hidden system files. // into different directories or replacing hidden system files.
// Also remove control characters and spaces (\x00..\x20) around the filename: // Also remove control characters and spaces (\x00..\x20) around the filename:
$file_name = trim(basename(stripslashes($name)), ".\x00..\x20"); $file_name = trim(basename(stripslashes($name)), ".\x00..\x20");
// Add missing file extension for known image types: // Add missing file extension for known image types:
if (strpos($file_name, '.') === false && if (strpos($file_name, '.') === false &&
preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) { preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) {
$file_name .= '.'.$matches[1]; $file_name .= '.'.$matches[1];
} }
if ($this->options['discard_aborted_uploads']) if ($this->options['discard_aborted_uploads'])
{ {
while(is_file($this->options['upload_dir'].$file_name)) while(is_file($this->options['upload_dir'].$file_name))
{ {
$file_name = $this->upcountName($file_name); $file_name = $this->upcountName($file_name);
} }
} }
return $file_name; return $file_name;
} }
/** /**
@ -367,33 +367,33 @@ class FileUpload
* @return int Success or not * @return int Success or not
*/ */
protected function orientImage($file_path) protected function orientImage($file_path)
{ {
$exif = @exif_read_data($file_path); $exif = @exif_read_data($file_path);
if ($exif === false) { if ($exif === false) {
return false; return false;
} }
$orientation = intval(@$exif['Orientation']); $orientation = intval(@$exif['Orientation']);
if (!in_array($orientation, array(3, 6, 8))) { if (!in_array($orientation, array(3, 6, 8))) {
return false; return false;
} }
$image = @imagecreatefromjpeg($file_path); $image = @imagecreatefromjpeg($file_path);
switch ($orientation) { switch ($orientation) {
case 3: case 3:
$image = @imagerotate($image, 180, 0); $image = @imagerotate($image, 180, 0);
break; break;
case 6: case 6:
$image = @imagerotate($image, 270, 0); $image = @imagerotate($image, 270, 0);
break; break;
case 8: case 8:
$image = @imagerotate($image, 90, 0); $image = @imagerotate($image, 90, 0);
break; break;
default: default:
return false; return false;
} }
$success = imagejpeg($image, $file_path); $success = imagejpeg($image, $file_path);
// Free up memory (imagedestroy does not delete files): // Free up memory (imagedestroy does not delete files):
@imagedestroy($image); @imagedestroy($image);
return $success; return $success;
} }
/** /**
@ -416,40 +416,40 @@ class FileUpload
$file->type = $type; $file->type = $type;
if ($this->validate($uploaded_file, $file, $error, $index) && dol_mkdir($this->options['upload_dir']) >= 0) if ($this->validate($uploaded_file, $file, $error, $index) && dol_mkdir($this->options['upload_dir']) >= 0)
{ {
$file_path = $this->options['upload_dir'].$file->name; $file_path = $this->options['upload_dir'].$file->name;
$append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path); $append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path);
clearstatcache(); clearstatcache();
if ($uploaded_file && is_uploaded_file($uploaded_file)) { if ($uploaded_file && is_uploaded_file($uploaded_file)) {
// multipart/formdata uploads (POST method uploads) // multipart/formdata uploads (POST method uploads)
if ($append_file) if ($append_file)
{ {
file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND); file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND);
} else { } else {
dol_move_uploaded_file($uploaded_file, $file_path, 1); dol_move_uploaded_file($uploaded_file, $file_path, 1);
} }
} }
else else
{ {
// Non-multipart uploads (PUT method support) // Non-multipart uploads (PUT method support)
file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0);
} }
$file_size = filesize($file_path); $file_size = filesize($file_path);
if ($file_size === $file->size) if ($file_size === $file->size)
{ {
$file->url = $this->options['upload_url'].rawurlencode($file->name); $file->url = $this->options['upload_url'].rawurlencode($file->name);
foreach($this->options['image_versions'] as $version => $options) foreach($this->options['image_versions'] as $version => $options)
{ {
if ($this->createScaledImage($file->name, $options)) if ($this->createScaledImage($file->name, $options))
{ {
$tmp=explode('.',$file->name); $tmp=explode('.',$file->name);
$file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]); $file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]);
} }
} }
} }
else if ($this->options['discard_aborted_uploads']) else if ($this->options['discard_aborted_uploads'])
{ {
unlink($file_path); unlink($file_path);
$file->error = 'abort'; $file->error = 'abort';
} }
$file->size = $file_size; $file->size = $file_size;
$this->setFileDeleteUrl($file); $this->setFileDeleteUrl($file);
@ -486,15 +486,15 @@ class FileUpload
public function post() public function post()
{ {
if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE')
{ {
return $this->delete(); return $this->delete();
} }
$upload = isset($_FILES[$this->options['param_name']]) ? $upload = isset($_FILES[$this->options['param_name']]) ?
$_FILES[$this->options['param_name']] : null; $_FILES[$this->options['param_name']] : null;
$info = array(); $info = array();
if ($upload && is_array($upload['tmp_name'])) if ($upload && is_array($upload['tmp_name']))
{ {
// param_name is an array identifier like "files[]", // param_name is an array identifier like "files[]",
// $_FILES is a multi-dimensional array: // $_FILES is a multi-dimensional array:
foreach ($upload['tmp_name'] as $index => $value) { foreach ($upload['tmp_name'] as $index => $value) {
$info[] = $this->handleFileUpload( $info[] = $this->handleFileUpload(
@ -507,7 +507,7 @@ class FileUpload
); );
} }
} elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) { } elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) {
// param_name is a single object identifier like "file", // param_name is a single object identifier like "file",
// $_FILES is a one-dimensional array: // $_FILES is a one-dimensional array:
$info[] = $this->handleFileUpload( $info[] = $this->handleFileUpload(
isset($upload['tmp_name']) ? $upload['tmp_name'] : null, isset($upload['tmp_name']) ? $upload['tmp_name'] : null,
@ -519,11 +519,11 @@ class FileUpload
} }
header('Vary: Accept'); header('Vary: Accept');
$json = json_encode($info); $json = json_encode($info);
$redirect = isset($_REQUEST['redirect']) ? $redirect = isset($_REQUEST['redirect']) ?
stripslashes($_REQUEST['redirect']) : null; stripslashes($_REQUEST['redirect']) : null;
if ($redirect) { if ($redirect) {
header('Location: '.sprintf($redirect, rawurlencode($json))); header('Location: '.sprintf($redirect, rawurlencode($json)));
return; return;
} }
if (isset($_SERVER['HTTP_ACCEPT']) && if (isset($_SERVER['HTTP_ACCEPT']) &&
(strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) { (strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) {

View File

@ -285,12 +285,12 @@ class Form
if (! empty($tmp[2])) $savemethod=$tmp[2]; if (! empty($tmp[2])) $savemethod=$tmp[2];
if (! empty($tmp[3])) $button_only=true; if (! empty($tmp[3])) $button_only=true;
} }
else if (preg_match('/^textarea/',$inputType)) else if (preg_match('/^textarea/',$inputType))
{ {
$tmp=explode(':',$inputType); $tmp=explode(':',$inputType);
$inputType=$tmp[0]; $inputType=$tmp[0];
if (! empty($tmp[1])) $rows=$tmp[1]; if (! empty($tmp[1])) $rows=$tmp[1];
if (! empty($tmp[2])) $cols=$tmp[2]; if (! empty($tmp[2])) $cols=$tmp[2];
} }
else if (preg_match('/^ckeditor/',$inputType)) else if (preg_match('/^ckeditor/',$inputType))
{ {
@ -790,20 +790,20 @@ class Form
} }
} }
/** /**
* Return list of all contacts (for a third party or all) * Return list of all contacts (for a third party or all)
* *
* @param int $socid Id ot third party or 0 for all * @param int $socid Id ot third party or 0 for all
* @param string $selected Id contact pre-selectionne * @param string $selected Id contact pre-selectionne
* @param string $htmlname Name of HTML field ('none' for a not editable field) * @param string $htmlname Name of HTML field ('none' for a not editable field)
* @param int $showempty 0=no empty value, 1=add an empty value * @param int $showempty 0=no empty value, 1=add an empty value
* @param string $exclude List of contacts id to exclude * @param string $exclude List of contacts id to exclude
* @param string $limitto Disable answers that are not id in this array list * @param string $limitto Disable answers that are not id in this array list
* @param string $showfunction Add function into label * @param string $showfunction Add function into label
* @param string $moreclass Add more class to class style * @param string $moreclass Add more class to class style
* @return int <0 if KO, Nb of contact in list if OK * @return int <0 if KO, Nb of contact in list if OK
*/ */
function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='') function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='')
{ {
print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass); print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass);
return $this->num; return $this->num;
@ -2725,50 +2725,50 @@ class Form
print $this->selectcurrency($selected,$htmlname); print $this->selectcurrency($selected,$htmlname);
} }
/** /**
* Load into the cache all currencies * Load into the cache all currencies
* *
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO * @return int Nb of loaded lines, 0 if already loaded, <0 if KO
*/ */
function load_cache_currencies() function load_cache_currencies()
{ {
global $langs; global $langs;
$langs->load("dict"); $langs->load("dict");
if (count($this->cache_currencies)) return 0; // Cache deja charge if (count($this->cache_currencies)) return 0; // Cache deja charge
$sql = "SELECT code_iso, label, unicode"; $sql = "SELECT code_iso, label, unicode";
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies"; $sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
$sql.= " WHERE active = 1"; $sql.= " WHERE active = 1";
$sql.= " ORDER BY code_iso ASC"; $sql.= " ORDER BY code_iso ASC";
dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG); dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:'')); $this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:''));
$this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true); $this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true);
$label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label']; $label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
$i++; $i++;
} }
array_multisort($label, SORT_ASC, $this->cache_currencies); array_multisort($label, SORT_ASC, $this->cache_currencies);
return $num; return $num;
} }
else else
{ {
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
} }
} }
/** /**
@ -2833,33 +2833,33 @@ class Form
print $this->load_tva($htmlname, $selectedrate, $societe_vendeuse, $societe_acheteuse, $idprod, $info_bits, $type); print $this->load_tva($htmlname, $selectedrate, $societe_vendeuse, $societe_acheteuse, $idprod, $info_bits, $type);
} }
/** /**
* Load into the cache vat rates of a country * Load into the cache vat rates of a country
* *
* @param string $country_code Country code * @param string $country_code Country code
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO * @return int Nb of loaded lines, 0 if already loaded, <0 if KO
*/ */
function load_cache_vatrates($country_code) function load_cache_vatrates($country_code)
{ {
global $langs; global $langs;
$num = count($this->cache_vatrates); $num = count($this->cache_vatrates);
if ($num > 0) return $num; // Cache deja charge if ($num > 0) return $num; // Cache deja charge
$sql = "SELECT DISTINCT t.taux, t.recuperableonly"; $sql = "SELECT DISTINCT t.taux, t.recuperableonly";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
$sql.= " WHERE t.fk_pays = p.rowid"; $sql.= " WHERE t.fk_pays = p.rowid";
$sql.= " AND t.active = 1"; $sql.= " AND t.active = 1";
$sql.= " AND p.code IN (".$country_code.")"; $sql.= " AND p.code IN (".$country_code.")";
$sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC"; $sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) if ($num)
{ {
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->cache_vatrates[$i]['txtva'] = $obj->taux; $this->cache_vatrates[$i]['txtva'] = $obj->taux;
@ -2879,7 +2879,7 @@ class Form
{ {
$this->error = '<font class="error">'.$this->db->error().'</font>'; $this->error = '<font class="error">'.$this->db->error().'</font>';
return -2; return -2;
} }
} }
/** /**
@ -2975,32 +2975,32 @@ class Form
if ($num > 0) if ($num > 0)
{ {
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '') // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
{ {
$defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod); $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod);
$defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod); $defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod);
} }
// Si taux par defaut n'a pu etre determine, on prend dernier de la liste. // Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
// Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
{ {
$defaulttx = $this->cache_vatrates[$num-1]['txtva']; $defaulttx = $this->cache_vatrates[$num-1]['txtva'];
} }
if (! $options_only) $return.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">'; if (! $options_only) $return.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
foreach ($this->cache_vatrates as $rate) foreach ($this->cache_vatrates as $rate)
{ {
$return.= '<option value="'.$rate['txtva']; $return.= '<option value="'.$rate['txtva'];
$return.= $rate['nprtva'] ? '*': ''; $return.= $rate['nprtva'] ? '*': '';
$return.= '"'; $return.= '"';
if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr) if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr)
{ {
$return.= ' selected="selected"'; $return.= ' selected="selected"';
} }
$return.= '>'.vatrate($rate['libtva']); $return.= '>'.vatrate($rate['libtva']);
$return.= $rate['nprtva'] ? ' *': ''; $return.= $rate['nprtva'] ? ' *': '';
$return.= '</option>'; $return.= '</option>';
@ -3391,79 +3391,79 @@ class Form
return $out; return $out;
} }
/** /**
* Show a multiselect form from an array. * Show a multiselect form from an array.
* *
* @param string $htmlname Name of select * @param string $htmlname Name of select
* @param array $array Array with key+value * @param array $array Array with key+value
* @param array $selected Preselected keys * @param array $selected Preselected keys
* @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value" * @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value"
* @param int $value_as_key 1 to use value as key * @param int $value_as_key 1 to use value as key
* @param string $option Valeur de l'option en fonction du type choisi * @param string $option Valeur de l'option en fonction du type choisi
* @param int $translate Translate and encode value * @param int $translate Translate and encode value
* @return string HTML multiselect string * @return string HTML multiselect string
*/ */
function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $option='', $translate=0) function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $option='', $translate=0)
{ {
global $conf, $langs; global $conf, $langs;
$out = '<select id="'.$htmlname.'" class="multiselect" multiple="multiple" name="'.$htmlname.'[]"'.$option.'>'."\n"; $out = '<select id="'.$htmlname.'" class="multiselect" multiple="multiple" name="'.$htmlname.'[]"'.$option.'>'."\n";
if (is_array($array) && ! empty($array)) if (is_array($array) && ! empty($array))
{ {
if ($value_as_key) $array=array_combine($array, $array); if ($value_as_key) $array=array_combine($array, $array);
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && is_array($selected) && ! empty($selected)) if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && is_array($selected) && ! empty($selected))
{ {
foreach ($selected as $selected_value) foreach ($selected as $selected_value)
{ {
foreach($array as $key => $value) foreach($array as $key => $value)
{ {
if ($selected_value == $key) if ($selected_value == $key)
{ {
$value=$array[$selected_value]; $value=$array[$selected_value];
$out.= '<option value="'.$key.'" selected="selected">'; $out.= '<option value="'.$key.'" selected="selected">';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value); $newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval); $newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval); $out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n"; $out.= '</option>'."\n";
unset($array[$key]); unset($array[$key]);
} }
} }
} }
if (! empty($array)) if (! empty($array))
{ {
foreach ($array as $key => $value) foreach ($array as $key => $value)
{ {
$out.= '<option value="'.$key.'">'; $out.= '<option value="'.$key.'">';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value); $newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval); $newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval); $out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n"; $out.= '</option>'."\n";
} }
} }
} }
else else
{ {
foreach ($array as $key => $value) foreach ($array as $key => $value)
{ {
$out.= '<option value="'.$key.'"'; $out.= '<option value="'.$key.'"';
if (is_array($selected) && ! empty($selected) && in_array($key, $selected)) if (is_array($selected) && ! empty($selected) && in_array($key, $selected))
{ {
$out.= ' selected="selected"'; $out.= ' selected="selected"';
} }
$out.= '>'; $out.= '>';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value); $newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval); $newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval); $out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n"; $out.= '</option>'."\n";
} }
} }
} }
$out.= '</select>'."\n"; $out.= '</select>'."\n";
return $out; return $out;
} }

View File

@ -813,7 +813,7 @@ class FormFile
// Max file size // Max file size
$max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize); $max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize);
// Include main // Include main
include(DOL_DOCUMENT_ROOT.'/core/tpl/ajax/fileupload_main.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/ajax/fileupload_main.tpl.php');
// Include template // Include template

View File

@ -170,9 +170,9 @@ class SMTPs
*/ */
var $_smtpsRelatedBoundary = null; var $_smtpsRelatedBoundary = null;
/** /**
* Alternative Boundary * Alternative Boundary
*/ */
var $_smtpsAlternativeBoundary = null; var $_smtpsAlternativeBoundary = null;
/** /**
@ -1223,8 +1223,8 @@ class SMTPs
if (key_exists('image', $this->_msgContent)) if (key_exists('image', $this->_msgContent))
{ {
$content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
$content .= "\r\n"; $content .= "\r\n";
$content .= "--" . $this->_getBoundary('alternative') . "\r\n"; $content .= "--" . $this->_getBoundary('alternative') . "\r\n";
} }
@ -1268,21 +1268,21 @@ class SMTPs
. $_data['data'] . "\r\n"; . $_data['data'] . "\r\n";
} }
// always end related and end alternative after inline images // always end related and end alternative after inline images
$content.= "--" . $this->_getBoundary('related') . "--" . "\r\n"; $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n";
$content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n"; $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n";
$content.= "\r\n"; $content.= "\r\n";
} }
else else
{ {
if (key_exists('image', $this->_msgContent)) if (key_exists('image', $this->_msgContent))
{ {
$content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
$content.= "\r\n" . strip_tags($_content['data']) . "\r\n"; // Add plain text message $content.= "\r\n" . strip_tags($_content['data']) . "\r\n"; // Add plain text message
$content.= "--" . $this->_getBoundary('alternative') . "\r\n"; $content.= "--" . $this->_getBoundary('alternative') . "\r\n";
$content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n"; $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n";
$content.= "\r\n"; $content.= "\r\n";
$content.= "--" . $this->_getBoundary('related') . "\r\n"; $content.= "--" . $this->_getBoundary('related') . "\r\n";
} }
$content .= 'Content-Type: ' . $_content['mimeType'] . '; ' $content .= 'Content-Type: ' . $_content['mimeType'] . '; '
@ -1490,7 +1490,7 @@ class SMTPs
function _setBoundary() function _setBoundary()
{ {
$this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary"; $this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary";
$this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2")); $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"));
$this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3")); $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"));
} }

View File

@ -1,88 +1,88 @@
/* /*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net * FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2010 Frederico Caldeira Knabben * Copyright (C) 2003-2010 Frederico Caldeira Knabben
* *
* == BEGIN LICENSE == * == BEGIN LICENSE ==
* *
* Licensed under the terms of any of the following licenses at your * Licensed under the terms of any of the following licenses at your
* choice: * choice:
* *
* - GNU General Public License Version 2 or later (the "GPL") * - GNU General Public License Version 2 or later (the "GPL")
* http://www.gnu.org/licenses/gpl.html * http://www.gnu.org/licenses/gpl.html
* *
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL") * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* http://www.gnu.org/licenses/lgpl.html * http://www.gnu.org/licenses/lgpl.html
* *
* - Mozilla Public License Version 1.1 or later (the "MPL") * - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html * http://www.mozilla.org/MPL/MPL-1.1.html
* *
* == END LICENSE == * == END LICENSE ==
* *
* Common objects and functions shared by all pages that compose the * Common objects and functions shared by all pages that compose the
* File Browser dialog window. * File Browser dialog window.
*/ */
// Automatically detect the correct document.domain (#1919). // Automatically detect the correct document.domain (#1919).
(function() (function()
{ {
var d = document.domain ; var d = document.domain ;
while ( true ) while ( true )
{ {
// Test if we can access a parent property. // Test if we can access a parent property.
try try
{ {
var test = window.top.opener.document.domain ; var test = window.top.opener.document.domain ;
break ; break ;
} }
catch( e ) catch( e )
{} {}
// Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
d = d.replace( /.*?(?:\.|$)/, '' ) ; d = d.replace( /.*?(?:\.|$)/, '' ) ;
if ( d.length == 0 ) if ( d.length == 0 )
break ; // It was not able to detect the domain. break ; // It was not able to detect the domain.
try try
{ {
document.domain = d ; document.domain = d ;
} }
catch (e) catch (e)
{ {
break ; break ;
} }
} }
})() ; })() ;
function AddSelectOption( selectElement, optionText, optionValue ) function AddSelectOption( selectElement, optionText, optionValue )
{ {
var oOption = document.createElement("OPTION") ; var oOption = document.createElement("OPTION") ;
oOption.text = optionText ; oOption.text = optionText ;
oOption.value = optionValue ; oOption.value = optionValue ;
selectElement.options.add(oOption) ; selectElement.options.add(oOption) ;
return oOption ; return oOption ;
} }
var oConnector = window.parent.oConnector ; var oConnector = window.parent.oConnector ;
var oIcons = window.parent.oIcons ; var oIcons = window.parent.oIcons ;
function StringBuilder( value ) function StringBuilder( value )
{ {
this._Strings = new Array( value || '' ) ; this._Strings = new Array( value || '' ) ;
} }
StringBuilder.prototype.Append = function( value ) StringBuilder.prototype.Append = function( value )
{ {
if ( value ) if ( value )
this._Strings.push( value ) ; this._Strings.push( value ) ;
} }
StringBuilder.prototype.ToString = function() StringBuilder.prototype.ToString = function()
{ {
return this._Strings.join( '' ) ; return this._Strings.join( '' ) ;
} }

View File

@ -1,147 +1,147 @@
/* /*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net * FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2010 Frederico Caldeira Knabben * Copyright (C) 2003-2010 Frederico Caldeira Knabben
* *
* == BEGIN LICENSE == * == BEGIN LICENSE ==
* *
* Licensed under the terms of any of the following licenses at your * Licensed under the terms of any of the following licenses at your
* choice: * choice:
* *
* - GNU General Public License Version 2 or later (the "GPL") * - GNU General Public License Version 2 or later (the "GPL")
* http://www.gnu.org/licenses/gpl.html * http://www.gnu.org/licenses/gpl.html
* *
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL") * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* http://www.gnu.org/licenses/lgpl.html * http://www.gnu.org/licenses/lgpl.html
* *
* - Mozilla Public License Version 1.1 or later (the "MPL") * - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html * http://www.mozilla.org/MPL/MPL-1.1.html
* *
* == END LICENSE == * == END LICENSE ==
* *
* Defines the FCKXml object that is used for XML data calls * Defines the FCKXml object that is used for XML data calls
* and XML processing. * and XML processing.
* *
* This script is shared by almost all pages that compose the * This script is shared by almost all pages that compose the
* File Browser frameset. * File Browser frameset.
*/ */
var FCKXml = function() var FCKXml = function()
{} {}
FCKXml.prototype.GetHttpRequest = function() FCKXml.prototype.GetHttpRequest = function()
{ {
// Gecko / IE7 // Gecko / IE7
try { return new XMLHttpRequest(); } try { return new XMLHttpRequest(); }
catch(e) {} catch(e) {}
// IE6 // IE6
try { return new ActiveXObject( 'Msxml2.XMLHTTP' ) ; } try { return new ActiveXObject( 'Msxml2.XMLHTTP' ) ; }
catch(e) {} catch(e) {}
// IE5 // IE5
try { return new ActiveXObject( 'Microsoft.XMLHTTP' ) ; } try { return new ActiveXObject( 'Microsoft.XMLHTTP' ) ; }
catch(e) {} catch(e) {}
return null ; return null ;
} }
FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer ) FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer )
{ {
var oFCKXml = this ; var oFCKXml = this ;
var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ; var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
var oXmlHttp = this.GetHttpRequest() ; var oXmlHttp = this.GetHttpRequest() ;
oXmlHttp.open( "GET", urlToCall, bAsync ) ; oXmlHttp.open( "GET", urlToCall, bAsync ) ;
if ( bAsync ) if ( bAsync )
{ {
oXmlHttp.onreadystatechange = function() oXmlHttp.onreadystatechange = function()
{ {
if ( oXmlHttp.readyState == 4 ) if ( oXmlHttp.readyState == 4 )
{ {
var oXml ; var oXml ;
try try
{ {
// this is the same test for an FF2 bug as in fckxml_gecko.js // this is the same test for an FF2 bug as in fckxml_gecko.js
// but we've moved the responseXML assignment into the try{} // but we've moved the responseXML assignment into the try{}
// so we don't even have to check the return status codes. // so we don't even have to check the return status codes.
var test = oXmlHttp.responseXML.firstChild ; var test = oXmlHttp.responseXML.firstChild ;
oXml = oXmlHttp.responseXML ; oXml = oXmlHttp.responseXML ;
} }
catch ( e ) catch ( e )
{ {
try try
{ {
oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ; oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ;
} }
catch ( e ) {} catch ( e ) {}
} }
if ( !oXml || !oXml.firstChild || oXml.firstChild.nodeName == 'parsererror' ) if ( !oXml || !oXml.firstChild || oXml.firstChild.nodeName == 'parsererror' )
{ {
alert( 'The server didn\'t send back a proper XML response. Please contact your system administrator.\n\n' + alert( 'The server didn\'t send back a proper XML response. Please contact your system administrator.\n\n' +
'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')\n\n' + 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')\n\n' +
'Requested URL:\n' + urlToCall + '\n\n' + 'Requested URL:\n' + urlToCall + '\n\n' +
'Response text:\n' + oXmlHttp.responseText ) ; 'Response text:\n' + oXmlHttp.responseText ) ;
return ; return ;
} }
oFCKXml.DOMDocument = oXml ; oFCKXml.DOMDocument = oXml ;
asyncFunctionPointer( oFCKXml ) ; asyncFunctionPointer( oFCKXml ) ;
} }
} }
} }
oXmlHttp.send( null ) ; oXmlHttp.send( null ) ;
if ( ! bAsync ) if ( ! bAsync )
{ {
if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 ) if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
this.DOMDocument = oXmlHttp.responseXML ; this.DOMDocument = oXmlHttp.responseXML ;
else else
{ {
alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ; alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
} }
} }
} }
FCKXml.prototype.SelectNodes = function( xpath ) FCKXml.prototype.SelectNodes = function( xpath )
{ {
if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE
return this.DOMDocument.selectNodes( xpath ) ; return this.DOMDocument.selectNodes( xpath ) ;
else // Gecko else // Gecko
{ {
var aNodeArray = new Array(); var aNodeArray = new Array();
var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ; this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
if ( xPathResult ) if ( xPathResult )
{ {
var oNode = xPathResult.iterateNext() ; var oNode = xPathResult.iterateNext() ;
while( oNode ) while( oNode )
{ {
aNodeArray[aNodeArray.length] = oNode ; aNodeArray[aNodeArray.length] = oNode ;
oNode = xPathResult.iterateNext(); oNode = xPathResult.iterateNext();
} }
} }
return aNodeArray ; return aNodeArray ;
} }
} }
FCKXml.prototype.SelectSingleNode = function( xpath ) FCKXml.prototype.SelectSingleNode = function( xpath )
{ {
if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE
return this.DOMDocument.selectSingleNode( xpath ) ; return this.DOMDocument.selectSingleNode( xpath ) ;
else // Gecko else // Gecko
{ {
var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null); this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);
if ( xPathResult && xPathResult.singleNodeValue ) if ( xPathResult && xPathResult.singleNodeValue )
return xPathResult.singleNodeValue ; return xPathResult.singleNodeValue ;
else else
return null ; return null ;
} }
} }

View File

@ -725,11 +725,11 @@ function activateModule($value,$withdeps=1)
$num = count($objMod->depends); $num = count($objMod->depends);
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++)
{ {
foreach ($modulesdir as $dir) foreach ($modulesdir as $dir)
{ {
if (file_exists($dir.$objMod->depends[$i].".class.php")) if (file_exists($dir.$objMod->depends[$i].".class.php"))
{ {
activateModule($objMod->depends[$i]); activateModule($objMod->depends[$i]);
} }
} }
} }
@ -741,11 +741,11 @@ function activateModule($value,$withdeps=1)
$num = count($objMod->conflictwith); $num = count($objMod->conflictwith);
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++)
{ {
foreach ($modulesdir as $dir) foreach ($modulesdir as $dir)
{ {
if (file_exists($dir.$objMod->conflictwith[$i].".class.php")) if (file_exists($dir.$objMod->conflictwith[$i].".class.php"))
{ {
unActivateModule($objMod->conflictwith[$i],0); unActivateModule($objMod->conflictwith[$i],0);
} }
} }
} }
@ -1128,16 +1128,16 @@ function form_constantes($tableau)
print '</table>'; print '</table>';
} }
/** /**
* Add document model used by doc generator * Add document model used by doc generator
* *
* @param string $name Model name * @param string $name Model name
* @param string $type Model type * @param string $type Model type
* @param string $label Model label * @param string $label Model label
* @param string $description Model description * @param string $description Model description
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function addDocumentModel($name, $type, $label='', $description='') function addDocumentModel($name, $type, $label='', $description='')
{ {
global $db, $conf; global $db, $conf;
@ -1150,51 +1150,51 @@ function addDocumentModel($name, $type, $label='', $description='')
$sql.= ")"; $sql.= ")";
dol_syslog("admin.lib::addDocumentModel sql=".$sql); dol_syslog("admin.lib::addDocumentModel sql=".$sql);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$db->commit(); $db->commit();
return 1; return 1;
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
$db->rollback(); $db->rollback();
return -1; return -1;
} }
} }
/** /**
* Delete document model used by doc generator * Delete document model used by doc generator
* *
* @param string $name Model name * @param string $name Model name
* @param string $type Model type * @param string $type Model type
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function delDocumentModel($name, $type) function delDocumentModel($name, $type)
{ {
global $db, $conf; global $db, $conf;
$db->begin(); $db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE nom = '".$db->escape($name)."'"; $sql.= " WHERE nom = '".$db->escape($name)."'";
$sql.= " AND type = '".$type."'"; $sql.= " AND type = '".$type."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
dol_syslog("admin.lib::delDocumentModel sql=".$sql); dol_syslog("admin.lib::delDocumentModel sql=".$sql);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$db->commit(); $db->commit();
return 1; return 1;
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
$db->rollback(); $db->rollback();
return -1; return -1;
} }
} }
?> ?>

View File

@ -595,99 +595,99 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
return $i; return $i;
} }
/** /**
* Show html area for list of addresses * Show html area for list of addresses
* *
* @param Conf $conf Object conf * @param Conf $conf Object conf
* @param Translate $langs Object langs * @param Translate $langs Object langs
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param Object $object Third party object * @param Object $object Third party object
* @param string $backtopage Url to go once address is created * @param string $backtopage Url to go once address is created
* @return void * @return void
*/ */
function show_addresses($conf,$langs,$db,$object,$backtopage='') function show_addresses($conf,$langs,$db,$object,$backtopage='')
{ {
global $user; global $user;
global $bc; global $bc;
require_once(DOL_DOCUMENT_ROOT."/societe/class/address.class.php"); require_once(DOL_DOCUMENT_ROOT."/societe/class/address.class.php");
$addressstatic = new Address($db); $addressstatic = new Address($db);
$num = $addressstatic->fetch_lines($object->id); $num = $addressstatic->fetch_lines($object->id);
$buttoncreate=''; $buttoncreate='';
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {
$buttoncreate='<a class="addnewrecord" href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage).'">'.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').'</a>'."\n"; $buttoncreate='<a class="addnewrecord" href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage).'">'.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').'</a>'."\n";
} }
print "\n"; print "\n";
print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,''); print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,'');
print "\n".'<table class="noborder" width="100%">'."\n"; print "\n".'<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>'; print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("CompanyName").'</td>'; print '<td>'.$langs->trans("CompanyName").'</td>';
print '<td>'.$langs->trans("Town").'</td>'; print '<td>'.$langs->trans("Town").'</td>';
print '<td>'.$langs->trans("Country").'</td>'; print '<td>'.$langs->trans("Country").'</td>';
print '<td>'.$langs->trans("Tel").'</td>'; print '<td>'.$langs->trans("Tel").'</td>';
print '<td>'.$langs->trans("Fax").'</td>'; print '<td>'.$langs->trans("Fax").'</td>';
print "<td>&nbsp;</td>"; print "<td>&nbsp;</td>";
print "</tr>"; print "</tr>";
if ($num > 0) if ($num > 0)
{ {
$var=true; $var=true;
foreach ($addressstatic->lines as $address) foreach ($addressstatic->lines as $address)
{ {
$var = !$var; $var = !$var;
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
print '<td>'; print '<td>';
$addressstatic->id = $address->id; $addressstatic->id = $address->id;
$addressstatic->label = $address->label; $addressstatic->label = $address->label;
print $addressstatic->getNomUrl(1); print $addressstatic->getNomUrl(1);
print '</td>'; print '</td>';
print '<td>'.$address->name.'</td>'; print '<td>'.$address->name.'</td>';
print '<td>'.$address->town.'</td>'; print '<td>'.$address->town.'</td>';
$img=picto_from_langcode($address->country_code); $img=picto_from_langcode($address->country_code);
print '<td>'.($img?$img.' ':'').$address->country.'</td>'; print '<td>'.($img?$img.' ':'').$address->country.'</td>';
// Lien click to dial // Lien click to dial
print '<td>'; print '<td>';
print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL'); print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX'); print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX');
print '</td>'; print '</td>';
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {
print '<td align="right">'; print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/comm/address.php?action=edit&amp;id='.$address->id.'&amp;socid='.$object->id.'&amp;backtopage='.urlencode($backtopage).'">'; print '<a href="'.DOL_URL_ROOT.'/comm/address.php?action=edit&amp;id='.$address->id.'&amp;socid='.$object->id.'&amp;backtopage='.urlencode($backtopage).'">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
} }
print "</tr>\n"; print "</tr>\n";
} }
} }
else else
{ {
//print "<tr ".$bc[$var].">"; //print "<tr ".$bc[$var].">";
//print '<td>'.$langs->trans("NoAddressYetDefined").'</td>'; //print '<td>'.$langs->trans("NoAddressYetDefined").'</td>';
//print "</tr>\n"; //print "</tr>\n";
} }
print "\n</table>\n"; print "\n</table>\n";
print "<br>\n"; print "<br>\n";
return $num; return $num;
} }
/** /**

View File

@ -39,11 +39,11 @@ function contract_prepare_head($object)
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans("ContactsAddresses"); $head[$h][1] = $langs->trans("ContactsAddresses");
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $h++;
} }
@ -53,11 +53,11 @@ function contract_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'contract'); complete_head_from_modules($conf,$langs,$object,$head,$h,'contract');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Note"); $head[$h][1] = $langs->trans("Note");
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }

View File

@ -43,11 +43,11 @@ function fichinter_prepare_head($object)
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('InterventionContact'); $head[$h][1] = $langs->trans('InterventionContact');
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $h++;
} }
@ -65,11 +65,11 @@ function fichinter_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention'); complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes'); $head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }

View File

@ -507,9 +507,9 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
*/ */
function dol_unescapefile($filename) function dol_unescapefile($filename)
{ {
// Remove path information and dots around the filename, to prevent uploading // Remove path information and dots around the filename, to prevent uploading
// into different directories or replacing hidden system files. // into different directories or replacing hidden system files.
// Also remove control characters and spaces (\x00..\x20) around the filename: // Also remove control characters and spaces (\x00..\x20) around the filename:
return trim(basename($filename), ".\x00..\x20"); return trim(basename($filename), ".\x00..\x20");
} }
@ -628,15 +628,15 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
{ {
if (is_object($object)) if (is_object($object))
{ {
$object->src_file=$dest_file; $object->src_file=$dest_file;
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db); $interface=new Interfaces($db);
$result=$interface->run_triggers('FILE_UPLOAD',$object,$user,$langs,$conf); $result=$interface->run_triggers('FILE_UPLOAD',$object,$user,$langs,$conf);
if ($result < 0) { if ($result < 0) {
$error++; $errors=$interface->errors; $error++; $errors=$interface->errors;
} }
// Fin appel triggers // Fin appel triggers
} }
else else

View File

@ -41,11 +41,11 @@ function facturefourn_prepare_head($object)
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses'); $head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $h++;
} }
@ -55,11 +55,11 @@ function facturefourn_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice'); complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
$head[$h][1] = $langs->trans('Notes'); $head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }
@ -107,11 +107,11 @@ function ordersupplier_prepare_head($object)
$h++; $h++;
} }
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses'); $head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $h++;
} }
@ -121,11 +121,11 @@ function ordersupplier_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order'); complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Notes"); $head[$h][1] = $langs->trans("Notes");
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }

View File

@ -4007,36 +4007,36 @@ function colorArrayToHex($arraycolor,$colorifnotfound='888888')
if (! is_array($arraycolor)) return $colorifnotfound; if (! is_array($arraycolor)) return $colorifnotfound;
return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]); return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]);
} }
/** /**
* Convert a currency code into its symbol * Convert a currency code into its symbol
* *
* @param string $currency_code Currency code * @param string $currency_code Currency code
* @return string Currency symbol encoded into UTF8 * @return string Currency symbol encoded into UTF8
*/ */
function getCurrencySymbol($currency_code) function getCurrencySymbol($currency_code)
{ {
global $db, $form; global $db, $form;
$currency_sign = ''; $currency_sign = '';
if (! is_object($form)) $form = new Form($db); if (! is_object($form)) $form = new Form($db);
$form->load_cache_currencies(); $form->load_cache_currencies();
if (function_exists("mb_convert_encoding") && is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode'])) if (function_exists("mb_convert_encoding") && is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode']))
{ {
foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode) foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
{ {
$currency_sign .= mb_convert_encoding("&#{$unicode};", "UTF-8", 'HTML-ENTITIES'); $currency_sign .= mb_convert_encoding("&#{$unicode};", "UTF-8", 'HTML-ENTITIES');
} }
} }
else else
{ {
$currency_sign = $currency_code; $currency_sign = $currency_code;
} }
return $currency_sign; return $currency_sign;
} }
if (! function_exists('getmypid')) if (! function_exists('getmypid'))

View File

@ -185,7 +185,7 @@ function dol_print_object_info($object)
$deltadateforclient=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); $deltadateforclient=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
//$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); //$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
$deltadateforuser=round($deltadateforclient-$deltadateforserver); $deltadateforuser=round($deltadateforclient-$deltadateforserver);
//print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser; //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser;
// Import key // Import key
if (isset($object->import_key)) if (isset($object->import_key))

View File

@ -40,11 +40,11 @@ function facture_prepare_head($object)
$head[$h][2] = 'compta'; $head[$h][2] = 'compta';
$h++; $h++;
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses'); $head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $h++;
} }
@ -71,11 +71,11 @@ function facture_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice'); complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id;
$head[$h][1] = $langs->trans('Notes'); $head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }

View File

@ -25,60 +25,60 @@
if (! function_exists('json_encode')) if (! function_exists('json_encode'))
{ {
/** /**
* Implement json_encode for PHP that does not support it * Implement json_encode for PHP that does not support it
* *
* @param mixed $elements PHP Object to json encode * @param mixed $elements PHP Object to json encode
* @return string Json encoded string * @return string Json encoded string
*/ */
function json_encode($elements) function json_encode($elements)
{ {
return dol_json_encode($elements); return dol_json_encode($elements);
} }
} }
/** /**
* Implement json_encode for PHP that does not support it * Implement json_encode for PHP that does not support it
* *
* @param mixed $elements PHP Object to json encode * @param mixed $elements PHP Object to json encode
* @return string Json encoded string * @return string Json encoded string
*/ */
function dol_json_encode($elements) function dol_json_encode($elements)
{ {
$num = count($elements); $num = count($elements);
// determine type // determine type
if (is_numeric(key($elements))) if (is_numeric(key($elements)))
{ {
// indexed (list) // indexed (list)
$output = '['; $output = '[';
for ($i = 0, $last = ($num - 1); isset($elements[$i]); ++$i) for ($i = 0, $last = ($num - 1); isset($elements[$i]); ++$i)
{ {
if (is_array($elements[$i])) $output.= json_encode($elements[$i]); if (is_array($elements[$i])) $output.= json_encode($elements[$i]);
else $output .= _val($elements[$i]); else $output .= _val($elements[$i]);
if($i !== $last) $output.= ','; if($i !== $last) $output.= ',';
} }
$output.= ']'; $output.= ']';
} }
else else
{ {
// associative (object) // associative (object)
$output = '{'; $output = '{';
$last = $num - 1; $last = $num - 1;
$i = 0; $i = 0;
foreach($elements as $key => $value) foreach($elements as $key => $value)
{ {
$output .= '"'.$key.'":'; $output .= '"'.$key.'":';
if (is_array($value)) $output.= json_encode($value); if (is_array($value)) $output.= json_encode($value);
else $output .= _val($value); else $output .= _val($value);
if ($i !== $last) $output.= ','; if ($i !== $last) $output.= ',';
++$i; ++$i;
} }
$output.= '}'; $output.= '}';
} }
// return // return
return $output; return $output;
} }
/** /**
@ -189,70 +189,70 @@ function _val($val)
if (! function_exists('json_decode')) if (! function_exists('json_decode'))
{ {
/** /**
* Implement json_decode for PHP that does not support it * Implement json_decode for PHP that does not support it
* *
* @param string $json Json encoded to PHP Object or Array * @param string $json Json encoded to PHP Object or Array
* @param bool $assoc False return an object, true return an array * @param bool $assoc False return an object, true return an array
* @return mixed Object or Array * @return mixed Object or Array
*/ */
function json_decode($json, $assoc=false) function json_decode($json, $assoc=false)
{ {
return dol_json_decode($json, $assoc); return dol_json_decode($json, $assoc);
} }
} }
/** /**
* Implement json_decode for PHP that does not support it * Implement json_decode for PHP that does not support it
* *
* @param string $json Json encoded to PHP Object or Array * @param string $json Json encoded to PHP Object or Array
* @param bool $assoc False return an object, true return an array. Try to always use it with true ! * @param bool $assoc False return an object, true return an array. Try to always use it with true !
* @return mixed Object or Array * @return mixed Object or Array
*/ */
function dol_json_decode($json, $assoc=false) function dol_json_decode($json, $assoc=false)
{ {
$comment = false; $comment = false;
$out=''; $out='';
$strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length
for ($i=0; $i<$strLength; $i++) for ($i=0; $i<$strLength; $i++)
{ {
if (! $comment) if (! $comment)
{ {
if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array('; if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array(';
else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')'; else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')';
else if ($json[$i] == ':') $out.= ' => '; else if ($json[$i] == ':') $out.= ' => ';
else $out.=$json[$i]; else $out.=$json[$i];
} }
else $out.= $json[$i]; else $out.= $json[$i];
if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment; if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment;
} }
$out=_unval($out); $out=_unval($out);
// Return an array // Return an array
if ($out != '') eval('$array = '.$out.';'); if ($out != '') eval('$array = '.$out.';');
else $array=array(); else $array=array();
// Return an object // Return an object
if (! $assoc) if (! $assoc)
{ {
if (! empty($array)) if (! empty($array))
{ {
$object = false; $object = false;
foreach ($array as $key => $value) foreach ($array as $key => $value)
{ {
$object->{$key} = $value; $object->{$key} = $value;
} }
return $object; return $object;
} }
return false; return false;
} }
return $array; return $array;
} }
/** /**

View File

@ -68,11 +68,11 @@ function commande_prepare_head($object)
$h++; $h++;
} }
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses'); $head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $h++;
} }
@ -91,11 +91,11 @@ function commande_prepare_head($object)
$head[$h][2] = 'documents'; $head[$h][2] = 'documents';
$h++; $h++;
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes'); $head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }

View File

@ -714,7 +714,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
} }
} }
/** /**
* Show linked objects for PDF generation * Show linked objects for PDF generation
* *
* @param PDF &$pdf Object PDF * @param PDF &$pdf Object PDF
@ -728,8 +728,8 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
* @param string $default_font_size Font size * @param string $default_font_size Font size
* @param HookManager $hookmanager Hook manager object * @param HookManager $hookmanager Hook manager object
* @return void * @return void
*/ */
function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size,$hookmanager=false) function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size,$hookmanager=false)
{ {
$linkedobjects = pdf_getLinkedObjects($object,$outputlangs,$hookmanager); $linkedobjects = pdf_getLinkedObjects($object,$outputlangs,$hookmanager);
if (! empty($linkedobjects)) if (! empty($linkedobjects))
@ -743,14 +743,14 @@ function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$al
if (! empty($linkedobject["date_title"]) && ! empty($linkedobject["date_value"])) if (! empty($linkedobject["date_title"]) && ! empty($linkedobject["date_value"]))
{ {
$posy+=3; $posy+=3;
$pdf->SetXY($posx,$posy); $pdf->SetXY($posx,$posy);
$pdf->MultiCell($w, $h, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', $align); $pdf->MultiCell($w, $h, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', $align);
} }
} }
} }
return $pdf->getY(); return $pdf->getY();
} }
/** /**
@ -1354,26 +1354,26 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false)
*/ */
function pdf_getCurrencySymbol(&$pdf, $currency_code) function pdf_getCurrencySymbol(&$pdf, $currency_code)
{ {
global $db, $form; global $db, $form;
$currency_sign = ''; $currency_sign = '';
if (! is_object($form)) $form = new Form($db); if (! is_object($form)) $form = new Form($db);
$form->load_cache_currencies(); $form->load_cache_currencies();
if (is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode'])) if (is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode']))
{ {
foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode) foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
{ {
$currency_sign.= $pdf->unichr($unicode); $currency_sign.= $pdf->unichr($unicode);
} }
} }
else else
{ {
$currency_sign = $currency_code; $currency_sign = $currency_code;
} }
return $currency_sign; return $currency_sign;
} }
@ -1417,25 +1417,25 @@ function pdf_getLinkedObjects($object,$outputlangs,$hookmanager=false)
$linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date,'day','',$outputlangs); $linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date,'day','',$outputlangs);
} }
} }
else if ($objecttype == 'contrat') else if ($objecttype == 'contrat')
{ {
$outputlangs->load('contracts'); $outputlangs->load('contracts');
$num=count($objects); $num=count($objects);
for ($i=0;$i<$num;$i++) for ($i=0;$i<$num;$i++)
{ {
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract"); $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract");
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref);
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract"); $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract");
$linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date_contrat,'day','',$outputlangs); $linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date_contrat,'day','',$outputlangs);
} }
} }
} }
// For add external linked objects // For add external linked objects
if (is_object($hookmanager)) if (is_object($hookmanager))
{ {
$parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs); $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs);
$action=''; $action='';
$hookmanager->executeHooks('pdf_getLinkedObjects',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $hookmanager->executeHooks('pdf_getLinkedObjects',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray; if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray;
} }

View File

@ -155,9 +155,9 @@ function product_admin_prepare_head($object=null)
if ($conf->global->MAIN_FEATURES_LEVEL > 1) if ($conf->global->MAIN_FEATURES_LEVEL > 1)
{ {
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_tools.php'; $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_tools.php';
$head[$h][1] = $langs->trans("Tools"); $head[$h][1] = $langs->trans("Tools");
$head[$h][2] = 'tools'; $head[$h][2] = 'tools';
$h++; $h++;
} }

View File

@ -65,9 +65,9 @@ function propal_prepare_head($object)
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses'); $head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $h++;
} }

View File

@ -379,9 +379,9 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature
} }
else else
{ {
$sql = "SELECT dbt.".$dbt_select; $sql = "SELECT dbt.".$dbt_select;
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid; $sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
} }
} }

View File

@ -72,14 +72,14 @@ function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmod
$mode=trim($mode); $mode=trim($mode);
$authfile='functions_'.$mode.'.php'; $authfile='functions_'.$mode.'.php';
$fullauthfile=''; $fullauthfile='';
$dirlogin=array_merge(array("/core/login"),(array) $conf->modules_parts['login']); $dirlogin=array_merge(array("/core/login"),(array) $conf->modules_parts['login']);
foreach($dirlogin as $reldir) foreach($dirlogin as $reldir)
{ {
$dir=dol_buildpath($reldir,0); $dir=dol_buildpath($reldir,0);
$newdir=dol_osencode($dir); $newdir=dol_osencode($dir);
// Check if file found (do not use dol_is_file to avoid loading files.lib.php) // Check if file found (do not use dol_is_file to avoid loading files.lib.php)
if (is_file($newdir.'/'.$authfile)) $fullauthfile=$newdir.'/'.$authfile; if (is_file($newdir.'/'.$authfile)) $fullauthfile=$newdir.'/'.$authfile;
} }
@ -130,12 +130,12 @@ function dol_loginfunction($langs,$conf,$mysoc)
global $dolibarr_main_demo,$db; global $dolibarr_main_demo,$db;
global $smartphone,$hookmanager; global $smartphone,$hookmanager;
// Instantiate hooks of thirdparty module only if not already define // Instantiate hooks of thirdparty module only if not already define
if (! is_object($hookmanager)) if (! is_object($hookmanager))
{ {
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($db); $hookmanager=new HookManager($db);
} }
$hookmanager->initHooks(array('mainloginpage')); $hookmanager->initHooks(array('mainloginpage'));
$langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang')); $langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang'));
@ -205,8 +205,8 @@ function dol_loginfunction($langs,$conf,$mysoc)
} }
// Execute hook getLoginPageOptions // Execute hook getLoginPageOptions
// Should be an array with differents options in $hookmanager->resArray // Should be an array with differents options in $hookmanager->resArray
$parameters=array('entity' => $_POST['entity']); $parameters=array('entity' => $_POST['entity']);
$hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks
// Login // Login

View File

@ -47,13 +47,13 @@ function shipping_prepare_head($object)
if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire) if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)
{ {
// delivery link // delivery link
$object->fetchObjectLinked($object->id,$object->element); $object->fetchObjectLinked($object->id,$object->element);
if (! empty($object->linkedObjectsIds['delivery'][0])) if (! empty($object->linkedObjectsIds['delivery'][0]))
{ {
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linkedObjectsIds['delivery'][0]; $head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linkedObjectsIds['delivery'][0];
$head[$h][1] = $langs->trans("DeliveryCard"); $head[$h][1] = $langs->trans("DeliveryCard");
$head[$h][2] = 'delivery'; $head[$h][2] = 'delivery';
$h++; $h++;
} }
} }

View File

@ -219,53 +219,53 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
foreach($dirthemes as $dir) foreach($dirthemes as $dir)
{ {
$dirtheme=dol_buildpath($dir,0); $dirtheme=dol_buildpath($dir,0);
$urltheme=dol_buildpath($dir,1); $urltheme=dol_buildpath($dir,1);
if (is_dir($dirtheme)) if (is_dir($dirtheme))
{ {
$handle=opendir($dirtheme); $handle=opendir($dirtheme);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($subdir = readdir($handle))!==false) while (($subdir = readdir($handle))!==false)
{ {
if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.' if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir)) && substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir))
{ {
// Disable not stable themes // Disable not stable themes
//if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/bureau2crea/i',$subdir)) continue; //if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/bureau2crea/i',$subdir)) continue;
if ($i % $thumbsbyrow == 0) if ($i % $thumbsbyrow == 0)
{ {
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
} }
print '<td align="center">'; print '<td align="center">';
$file=$dirtheme."/".$subdir."/thumb.png"; $file=$dirtheme."/".$subdir."/thumb.png";
$url=$urltheme."/".$subdir."/thumb.png"; $url=$urltheme."/".$subdir."/thumb.png";
if (! file_exists($file)) $url=$urltheme."/common/nophoto.jpg"; if (! file_exists($file)) $url=$urltheme."/common/nophoto.jpg";
print '<table><tr><td>'; print '<table><tr><td>';
print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST("optioncss")?'&optioncss='.GETPOST("optioncss",'alpha',1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">'; print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST("optioncss")?'&optioncss='.GETPOST("optioncss",'alpha',1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive"); if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive");
else $title=$langs->trans("ShowPreview"); else $title=$langs->trans("ShowPreview");
print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'">'; print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'">';
print '</a>'; print '</a>';
print '</td></tr><tr><td align="center">'; print '</td></tr><tr><td align="center">';
if ($subdir == $selected_theme) if ($subdir == $selected_theme)
{ {
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>'; print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
} }
else else
{ {
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir; print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
} }
print '</td></tr></table></td>'; print '</td></tr></table></td>';
$i++; $i++;
if ($i % $thumbsbyrow == 0) print '</tr>'; if ($i % $thumbsbyrow == 0) print '</tr>';
} }
} }
} }
} }
} }

View File

@ -1370,7 +1370,7 @@ abstract class DolibarrModules
{ {
foreach($this->module_parts as $key => $value) foreach($this->module_parts as $key => $value)
{ {
// If entity is defined // If entity is defined
if (is_array($value) && isset($value['entity'])) $entity = $value['entity']; if (is_array($value) && isset($value['entity'])) $entity = $value['entity'];
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

View File

@ -300,7 +300,7 @@ class pdf_edison extends ModelePDFCommandes
// Actions on extra fields (by external module or standard code) // Actions on extra fields (by external module or standard code)
if (! is_object($hookmanager)) if (! is_object($hookmanager))
{ {
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db); $hookmanager=new HookManager($this->db);
} }
$hookmanager->initHooks(array('pdfgeneration')); $hookmanager->initHooks(array('pdfgeneration'));
@ -651,7 +651,7 @@ class pdf_edison extends ModelePDFCommandes
$posy+=1; $posy+=1;
// Show list of linked objects // Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'L', $default_font_size, $hookmanager); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'L', $default_font_size, $hookmanager);
} }

View File

@ -929,8 +929,8 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
$posy+=2; $posy+=2;
// Show list of linked objects // Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);

View File

@ -154,37 +154,37 @@ class MailingTargets // This can't be abstract as it is used for some method
{ {
if (! empty($cibles[$i]['email'])) // avoid empty email address if (! empty($cibles[$i]['email'])) // avoid empty email address
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " (fk_mailing,"; $sql .= " (fk_mailing,";
$sql .= " fk_contact,"; $sql .= " fk_contact,";
$sql .= " nom, prenom, email, other, source_url, source_id,"; $sql .= " nom, prenom, email, other, source_url, source_id,";
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= " tag,"; if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= " tag,";
$sql.= " source_type)"; $sql.= " source_type)";
$sql .= " VALUES (".$mailing_id.","; $sql .= " VALUES (".$mailing_id.",";
$sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .","; $sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .",";
$sql .= "'".$this->db->escape($cibles[$i]['name'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['name'])."',";
$sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',";
$sql .= "'".$this->db->escape($cibles[$i]['email'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['email'])."',";
$sql .= "'".$this->db->escape($cibles[$i]['other'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['other'])."',";
$sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',";
$sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',";
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',"; if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',";
$sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')"; $sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')";
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
{ {
$j++; $j++;
} }
else else
{ {
if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
// Si erreur autre que doublon // Si erreur autre que doublon
dol_syslog($this->db->error()); dol_syslog($this->db->error());
$this->error=$this->db->error(); $this->error=$this->db->error();
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
} }
} }

View File

@ -74,8 +74,8 @@ class modMailing extends DolibarrModules
// Permissions // Permissions
$this->rights = array(); $this->rights = array();
$this->rights_class = 'mailing'; $this->rights_class = 'mailing';
$r=0; $r=0;
$r++; $r++;
$this->rights[$r][0] = 221; // id de la permission $this->rights[$r][0] = 221; // id de la permission
$this->rights[$r][1] = 'Consulter les mailings'; // libelle de la permission $this->rights[$r][1] = 'Consulter les mailings'; // libelle de la permission
@ -104,28 +104,28 @@ class modMailing extends DolibarrModules
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'supprimer'; $this->rights[$r][4] = 'supprimer';
$r++; $r++;
$this->rights[$r][0] = 237; $this->rights[$r][0] = 237;
$this->rights[$r][1] = 'View recipients and info'; $this->rights[$r][1] = 'View recipients and info';
$this->rights[$r][2] = 'r'; $this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'recipient'; $this->rights[$r][5] = 'recipient';
$r++; $r++;
$this->rights[$r][0] = 238; $this->rights[$r][0] = 238;
$this->rights[$r][1] = 'Manually send mailings'; $this->rights[$r][1] = 'Manually send mailings';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'send'; $this->rights[$r][5] = 'send';
$r++; $r++;
$this->rights[$r][0] = 239; $this->rights[$r][0] = 239;
$this->rights[$r][1] = 'Delete mailings after validation and/or sent'; $this->rights[$r][1] = 'Delete mailings after validation and/or sent';
$this->rights[$r][2] = 'd'; $this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'delete'; $this->rights[$r][5] = 'delete';
} }

View File

@ -982,9 +982,9 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
} }
$posy+=2; $posy+=2;
// Show list of linked objects // Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);
if ($showaddress) if ($showaddress)

View File

@ -417,13 +417,13 @@ function thirdparty_doc_create($db, &$object, $message, $modele, $outputlangs)
{ {
$outputlangs->charset_output=$sav_charset_output; $outputlangs->charset_output=$sav_charset_output;
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db); $interface=new Interfaces($db);
$result=$interface->run_triggers('COMPANY_BUILDDOC',$object,$user,$langs,$conf); $result=$interface->run_triggers('COMPANY_BUILDDOC',$object,$user,$langs,$conf);
if ($result < 0) { if ($result < 0) {
$error++; $this->errors=$interface->errors; $error++; $this->errors=$interface->errors;
} }
// Fin appel triggers // Fin appel triggers
return 1; return 1;

View File

@ -42,7 +42,7 @@ require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
$langs->load("products"); $langs->load("products");
$langs->load("other"); $langs->load("other");
$id=GETPOST('id','int'); $id=GETPOST('id','int');
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$modulepart=GETPOST('modulepart','alpha')?GETPOST('modulepart','alpha'):'produit|service'; $modulepart=GETPOST('modulepart','alpha')?GETPOST('modulepart','alpha'):'produit|service';
$original_file = isset($_REQUEST["file"])?urldecode($_REQUEST["file"]):''; $original_file = isset($_REQUEST["file"])?urldecode($_REQUEST["file"]):'';
@ -65,12 +65,12 @@ if (! $accessallowed)
} }
$object = new Product($db); $object = new Product($db);
if ($id > 0) if ($id > 0)
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) dol_print_error($db,'Failed to load object'); if ($result <= 0) dol_print_error($db,'Failed to load object');
$dir=$conf->product->multidir_output[$object->entity]; // By default $dir=$conf->product->multidir_output[$object->entity]; // By default
if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity]; if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity];
if ($object->type == 1) $dir=$conf->service->multidir_output[$object->entity]; if ($object->type == 1) $dir=$conf->service->multidir_output[$object->entity];
} }

View File

@ -16,17 +16,17 @@
* *
*/ */
$module = $object->element; $module = $object->element;
$permission=(isset($permission)?$permission:$user->rights->$module->creer); // If already defined by caller page $permission=(isset($permission)?$permission:$user->rights->$module->creer); // If already defined by caller page
// Special cases // Special cases
if ($module == 'propal') { $permission=$user->rights->propale->creer; } if ($module == 'propal') { $permission=$user->rights->propale->creer; }
elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; } elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; }
elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; } elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; } elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; }
$companystatic=new Societe($db); $companystatic=new Societe($db);
$contactstatic=new Contact($db); $contactstatic=new Contact($db);
$userstatic=new User($db); $userstatic=new User($db);
?> ?>
@ -73,8 +73,8 @@ $userstatic=new User($db);
<?php if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) { ?> <?php if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) { ?>
<td> <td>
<?php <?php
$events=array(); $events=array();
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
print $form->select_company($object->socid,'socid','',1,0,0,$events); print $form->select_company($object->socid,'socid','',1,0,0,$events);
?> ?>
</td> </td>
@ -113,12 +113,12 @@ $userstatic=new User($db);
<?php $var=true; ?> <?php $var=true; ?>
<?php <?php
foreach(array('internal','external') as $source) { foreach(array('internal','external') as $source) {
$tab = $object->liste_contact(-1,$source); $tab = $object->liste_contact(-1,$source);
$num=count($tab); $num=count($tab);
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {
$var = !$var; $var = !$var;
?> ?>
@ -129,36 +129,36 @@ $userstatic=new User($db);
</td> </td>
<td align="left"> <td align="left">
<?php <?php
if ($tab[$i]['socid'] > 0) if ($tab[$i]['socid'] > 0)
{ {
$companystatic->fetch($tab[$i]['socid']); $companystatic->fetch($tab[$i]['socid']);
echo $companystatic->getNomUrl(1); echo $companystatic->getNomUrl(1);
} }
if ($tab[$i]['socid'] < 0) if ($tab[$i]['socid'] < 0)
{ {
echo $conf->global->MAIN_INFO_SOCIETE_NOM; echo $conf->global->MAIN_INFO_SOCIETE_NOM;
} }
if (! $tab[$i]['socid']) if (! $tab[$i]['socid'])
{ {
echo '&nbsp;'; echo '&nbsp;';
} }
?> ?>
</td> </td>
<td> <td>
<?php <?php
if ($tab[$i]['source']=='internal') if ($tab[$i]['source']=='internal')
{ {
$userstatic->id=$tab[$i]['id']; $userstatic->id=$tab[$i]['id'];
$userstatic->lastname=$tab[$i]['lastname']; $userstatic->lastname=$tab[$i]['lastname'];
$userstatic->firstname=$tab[$i]['firstname']; $userstatic->firstname=$tab[$i]['firstname'];
echo $userstatic->getNomUrl(1); echo $userstatic->getNomUrl(1);
} }
if ($tab[$i]['source']=='external') if ($tab[$i]['source']=='external')
{ {
$contactstatic->id=$tab[$i]['id']; $contactstatic->id=$tab[$i]['id'];
$contactstatic->lastname=$tab[$i]['lastname']; $contactstatic->lastname=$tab[$i]['lastname'];
$contactstatic->firstname=$tab[$i]['firstname']; $contactstatic->firstname=$tab[$i]['firstname'];
echo $contactstatic->getNomUrl(1); echo $contactstatic->getNomUrl(1);
} }
?> ?>
</td> </td>

View File

@ -35,7 +35,7 @@ print '<!-- Includes for JQuery (Ajax library) -->'."\n";
if (constant('JS_JQUERY_UI')) print '<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.'css/'.$jquerytheme.'/jquery-ui.min.css" />'."\n"; // JQuery if (constant('JS_JQUERY_UI')) print '<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.'css/'.$jquerytheme.'/jquery-ui.min.css" />'."\n"; // JQuery
else print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui-latest.custom.css" />'."\n"; // JQuery else print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui-latest.custom.css" />'."\n"; // JQuery
// JQuery. Must be before other includes // JQuery. Must be before other includes
$ext='.js'; $ext='.js';
if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x01)) $ext='.jgz'; if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x01)) $ext='.jgz';
print '<!-- Includes JS for JQuery -->'."\n"; print '<!-- Includes JS for JQuery -->'."\n";
if (constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js"></script>'."\n"; if (constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js"></script>'."\n";

View File

@ -111,37 +111,37 @@ class InterfacePaypalWorkflow
} }
else else
{ {
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
$soc = new Societe($this->db); $soc = new Societe($this->db);
// Parse element/subelement (ex: project_task) // Parse element/subelement (ex: project_task)
$element = $path = $filename = $object->source; $element = $path = $filename = $object->source;
if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs)) if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs))
{ {
$element = $path = $regs[1]; $element = $path = $regs[1];
$filename = $regs[2]; $filename = $regs[2];
} }
// For compatibility // For compatibility
if ($element == 'order') { if ($element == 'order') {
$path = $filename = 'commande'; $path = $filename = 'commande';
} }
if ($element == 'invoice') { if ($element == 'invoice') {
$path = 'compta/facture'; $filename = 'facture'; $path = 'compta/facture'; $filename = 'facture';
} }
dol_include_once('/'.$path.'/class/'.$filename.'.class.php'); dol_include_once('/'.$path.'/class/'.$filename.'.class.php');
$classname = ucfirst($filename); $classname = ucfirst($filename);
$obj = new $classname($this->db); $obj = new $classname($this->db);
$ret = $obj->fetch('',$object->ref); $ret = $obj->fetch('',$object->ref);
if ($ret < 0) return -1; if ($ret < 0) return -1;
// Add payer id // Add payer id
$soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid); $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
// Add transaction id // Add transaction id
$obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]); $obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]);
} }

View File

@ -73,11 +73,11 @@ class Expedition extends CommonObject
var $date_creation; var $date_creation;
var $date_valid; var $date_valid;
// For Invoicing // For Invoicing
var $total_ht; // Total net of tax var $total_ht; // Total net of tax
var $total_ttc; // Total with tax var $total_ttc; // Total with tax
var $total_tva; // Total VAT var $total_tva; // Total VAT
var $total_localtax1; // Total Local tax 1 var $total_localtax1; // Total Local tax 1
var $total_localtax2; // Total Local tax 2 var $total_localtax2; // Total Local tax 2
@ -871,10 +871,10 @@ class Expedition extends CommonObject
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
$this->total_ht = 0; $this->total_ht = 0;
$this->total_tva = 0; $this->total_tva = 0;
$this->total_ttc = 0; $this->total_ttc = 0;
$this->total_localtax1 = 0; $this->total_localtax1 = 0;
$this->total_localtax2 = 0; $this->total_localtax2 = 0;
while ($i < $num) while ($i < $num)
@ -915,11 +915,11 @@ class Expedition extends CommonObject
$line->subprice = $obj->subprice; $line->subprice = $obj->subprice;
$line->remise_percent = $obj->remise_percent; $line->remise_percent = $obj->remise_percent;
$tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $info_bits); $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $info_bits);
$this->total_ht+= $tabprice[0]; $this->total_ht+= $tabprice[0];
$this->total_tva+= $tabprice[1]; $this->total_tva+= $tabprice[1];
$this->total_ttc+= $tabprice[2]; $this->total_ttc+= $tabprice[2];
$this->total_localtax1+= $tabprice[9]; $this->total_localtax1+= $tabprice[9];
$this->total_localtax2+= $tabprice[10]; $this->total_localtax2+= $tabprice[10];
$this->lines[$i] = $line; $this->lines[$i] = $line;
@ -1212,28 +1212,28 @@ class Expedition extends CommonObject
} }
} }
/** /**
* Classify the shipping as invoiced * Classify the shipping as invoiced
* *
* @return int <0 if ko, >0 if ok * @return int <0 if ko, >0 if ok
*/ */
function set_billed() function set_billed()
{ {
global $conf; global $conf;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2';
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
//TODO: Option to set order billed if 100% of order is shipped //TODO: Option to set order billed if 100% of order is shipped
return 1; return 1;
} }
else else
{ {
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
} }
} }
} }
@ -1257,11 +1257,11 @@ class ExpeditionLigne
var $ref; var $ref;
// Invoicing // Invoicing
var $remise_percent; var $remise_percent;
var $total_ht; // Total net of tax var $total_ht; // Total net of tax
var $total_ttc; // Total with tax var $total_ttc; // Total with tax
var $total_tva; // Total VAT var $total_tva; // Total VAT
var $total_localtax1; // Total Local tax 1 var $total_localtax1; // Total Local tax 1
var $total_localtax2; // Total Local tax 2 var $total_localtax2; // Total Local tax 2

View File

@ -119,11 +119,11 @@ else if ($action == 'deleteline' && $user->rights->expedition->creer)
} }
} }
else if ($action == 'setaddress' && $user->rights->expedition->creer) else if ($action == 'setaddress' && $user->rights->expedition->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->setDeliveryAddress($_POST['fk_address']); $result=$object->setDeliveryAddress($_POST['fk_address']);
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
@ -210,27 +210,27 @@ if ($id > 0 || ! empty($ref))
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Delivery address // Delivery address
if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
{ {
print '<tr><td>'; print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryAddress'); print $langs->trans('DeliveryAddress');
print '</td>'; print '</td>';
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>'; if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'editdelivery_address') if ($action == 'editdelivery_address')
{ {
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','shipping',$object->id); $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','shipping',$object->id);
} }
else else
{ {
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','shipping',$object->id); $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','shipping',$object->id);
} }
print '</td></tr>'; print '</td></tr>';
} }
print "</table>"; print "</table>";

View File

@ -60,7 +60,7 @@ $result=restrictedArea($user,$origin,$origin_id);
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha'); $confirm = GETPOST('confirm','alpha');
//PDF //PDF
$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
@ -509,10 +509,10 @@ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile'
} }
} }
else if ($action == 'classifybilled') else if ($action == 'classifybilled')
{ {
$object->fetch($id); $object->fetch($id);
$object->set_billed(); $object->set_billed();
} }
@ -1340,9 +1340,9 @@ else
$somethingshown=$formfile->show_documents('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); $somethingshown=$formfile->show_documents('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
/* /*
* Linked object block * Linked object block
*/ */
$somethingshown=$object->showLinkedObjectBlock(); $somethingshown=$object->showLinkedObjectBlock();
if ($genallowed && ! $somethingshown) $somethingshown=1; if ($genallowed && ! $somethingshown) $somethingshown=1;

View File

@ -156,13 +156,13 @@ class Fichinter extends CommonObject
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
{ {
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('FICHEINTER_CREATE',$this,$user,$langs,$conf); $result=$interface->run_triggers('FICHEINTER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { if ($result < 0) {
$error++; $this->errors=$interface->errors; $error++; $this->errors=$interface->errors;
} }
// Fin appel triggers // Fin appel triggers
$this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter"); $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter");
@ -202,13 +202,13 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('FICHEINTER_MODIFY',$this,$user,$langs,$conf); $result=$interface->run_triggers('FICHEINTER_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { if ($result < 0) {
$error++; $this->errors=$interface->errors; $error++; $this->errors=$interface->errors;
} }
// Fin appel triggers // Fin appel triggers
$this->db->commit(); $this->db->commit();
@ -665,13 +665,13 @@ class Fichinter extends CommonObject
} }
} }
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('FICHEINTER_DELETE',$this,$user,$langs,$conf); $result=$interface->run_triggers('FICHEINTER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { if ($result < 0) {
$error++; $this->errors=$interface->errors; $error++; $this->errors=$interface->errors;
} }
// Fin appel triggers // Fin appel triggers
$this->db->commit(); $this->db->commit();

View File

@ -43,11 +43,11 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha'); $confirm = GETPOST('confirm','alpha');
$mesg=''; $mesg='';
if (isset($_SESSION['DolMessage'])) if (isset($_SESSION['DolMessage']))
{ {
$mesg=$_SESSION['DolMessage']; $mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']); unset($_SESSION['DolMessage']);
} }
// Security check // Security check
@ -118,20 +118,20 @@ if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC))
} }
} }
// Delete // Delete
else if ($action == 'confirm_deletefile' && $confirm == 'yes') else if ($action == 'confirm_deletefile' && $confirm == 'yes')
{ {
if ($object->id > 0) if ($object->id > 0)
{ {
$langs->load("other"); $langs->load("other");
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object); dol_delete_file($file,0,0,0,$object);
$_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }
} }
@ -178,15 +178,15 @@ if ($object->id)
print '</div>'; print '</div>';
dol_htmloutput_mesg($mesg,$mesgs); dol_htmloutput_mesg($mesg,$mesgs);
/* /*
* Confirmation suppression fichier * Confirmation suppression fichier
*/ */
if ($action == 'delete') if ($action == 'delete')
{ {
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
// Affiche formulaire upload // Affiche formulaire upload

View File

@ -50,7 +50,7 @@ $action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha'); $confirm = GETPOST('confirm','alpha');
$mesg = GETPOST('msg','alpha'); $mesg = GETPOST('msg','alpha');
//PDF //PDF
$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
@ -200,21 +200,21 @@ else if ($action == 'builddoc' && $user->rights->ficheinter->creer) // En get ou
} }
} }
// Remove file in doc form // Remove file in doc form
else if ($action == 'remove_file') else if ($action == 'remove_file')
{ {
if ($object->fetch($id)) if ($object->fetch($id))
{ {
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$langs->load("other"); $langs->load("other");
$upload_dir = $conf->ficheinter->dir_output; $upload_dir = $conf->ficheinter->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object); dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>'; $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
} }
} }
// Set into a project // Set into a project
@ -228,7 +228,7 @@ else if ($action == 'classin' && $user->rights->ficheinter->creer)
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer) else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer)
{ {
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$object->delete($user); $object->delete($user);
Header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter'); Header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter');
@ -382,30 +382,30 @@ else if ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST(
*/ */
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->ficheinter->creer) else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->ficheinter->creer)
{ {
$objectline = new FichinterLigne($db); $objectline = new FichinterLigne($db);
if ($objectline->fetch(GETPOST('line_id','int')) <= 0) if ($objectline->fetch(GETPOST('line_id','int')) <= 0)
{ {
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
$result=$objectline->deleteline(); $result=$objectline->deleteline();
if ($object->fetch($objectline->fk_fichinter) <= 0) if ($object->fetch($objectline->fk_fichinter) <= 0)
{ {
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang=''; $newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang)) if (! empty($newlang))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
fichinter_create($db, $object, $object->modelpdf, $outputlangs); fichinter_create($db, $object, $object->modelpdf, $outputlangs);
} }
@ -644,64 +644,64 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
$action='presend'; $action='presend';
} }
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
if ($action == 'addcontact' && $user->rights->ficheinter->creer) if ($action == 'addcontact' && $user->rights->ficheinter->creer)
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int')); $contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int'));
$result = $object->add_contact($contactid, GETPOST('type','int'), GETPOST('source','alpha')); $result = $object->add_contact($contactid, GETPOST('type','int'), GETPOST('source','alpha'));
} }
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
else else
{ {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
} }
else else
{ {
$mesg = '<div class="error">'.$object->error.'</div>'; $mesg = '<div class="error">'.$object->error.'</div>';
} }
} }
} }
// bascule du statut d'un contact // bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->ficheinter->creer) else if ($action == 'swapstatut' && $user->rights->ficheinter->creer)
{ {
if ($object->fetch($id)) if ($object->fetch($id))
{ {
$result=$object->swapContactStatus(GETPOST('ligne','int')); $result=$object->swapContactStatus(GETPOST('ligne','int'));
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
// Efface un contact // Efface un contact
else if ($action == 'deletecontact' && $user->rights->ficheinter->creer) else if ($action == 'deletecontact' && $user->rights->ficheinter->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->delete_contact(GETPOST('lineid','int')); $result = $object->delete_contact(GETPOST('lineid','int'));
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
else { else {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
@ -941,15 +941,15 @@ else if ($id > 0 || ! empty($ref))
print "</table><br>"; print "</table><br>";
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db); $formcompany= new FormCompany($db);
$blocname = 'contacts'; $blocname = 'contacts';
$title = $langs->trans('ContactsAddresses'); $title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
} }
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))

View File

@ -1298,44 +1298,44 @@ class CommandeFournisseur extends Commande
$error++; $error++;
} }
if (! $error) if (! $error)
{ {
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('ORDER_SUPPLIER_DELETE',$this,$user,$langs,$conf); $result=$interface->run_triggers('ORDER_SUPPLIER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { if ($result < 0) {
$error++; $this->errors=$interface->errors; $error++; $this->errors=$interface->errors;
} }
// Fin appel triggers // Fin appel triggers
} }
if (! $error) if (! $error)
{ {
// We remove directory // We remove directory
$ref = dol_sanitizeFileName($this->ref); $ref = dol_sanitizeFileName($this->ref);
if ($conf->fournisseur->commande->dir_output) if ($conf->fournisseur->commande->dir_output)
{ {
$dir = $conf->fournisseur->commande->dir_output . "/" . $ref ; $dir = $conf->fournisseur->commande->dir_output . "/" . $ref ;
$file = $dir . "/" . $ref . ".pdf"; $file = $dir . "/" . $ref . ".pdf";
if (file_exists($file)) if (file_exists($file))
{ {
if (! dol_delete_file($file,0,0,0,$this)) // For triggers if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{ {
$this->error='ErrorFailToDeleteFile'; $this->error='ErrorFailToDeleteFile';
$error++; $error++;
} }
} }
if (file_exists($dir)) if (file_exists($dir))
{ {
$res=@dol_delete_dir_recursive($dir); $res=@dol_delete_dir_recursive($dir);
if (! $res) if (! $res)
{ {
$this->error='ErrorFailToDeleteDir'; $this->error='ErrorFailToDeleteDir';
$error++; $error++;
} }
} }
} }
} }
if (! $error) if (! $error)

View File

@ -41,16 +41,16 @@ $langs->load('deliveries');
$langs->load('products'); $langs->load('products');
$langs->load('stocks'); $langs->load('stocks');
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha'); $confirm = GETPOST('confirm','alpha');
$mesg=''; $mesg='';
if (isset($_SESSION['DolMessage'])) if (isset($_SESSION['DolMessage']))
{ {
$mesg=$_SESSION['DolMessage']; $mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']); unset($_SESSION['DolMessage']);
} }
// Security check // Security check
@ -121,18 +121,18 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
} }
} }
else if ($action == 'confirm_deletefile' && $confirm == 'yes') else if ($action == 'confirm_deletefile' && $confirm == 'yes')
{ {
if ($object->id > 0) if ($object->id > 0)
{ {
$langs->load("other"); $langs->load("other");
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object); dol_delete_file($file,0,0,0,$object);
$_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }
} }
@ -211,15 +211,15 @@ if ($object->id > 0)
print "</div>\n"; print "</div>\n";
dol_htmloutput_mesg($mesg,$mesgs); dol_htmloutput_mesg($mesg,$mesgs);
/* /*
* Confirmation suppression fichier * Confirmation suppression fichier
*/ */
if ($action == 'delete') if ($action == 'delete')
{ {
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
// Affiche formulaire upload // Affiche formulaire upload

View File

@ -55,7 +55,7 @@ $comclientid = GETPOST('comid','int');
$socid = GETPOST('socid','int'); $socid = GETPOST('socid','int');
$projectid = GETPOST('projectid','int'); $projectid = GETPOST('projectid','int');
//PDF //PDF
$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));

View File

@ -46,7 +46,7 @@ $id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int'));
$action = GETPOST("action"); $action = GETPOST("action");
$confirm = GETPOST("confirm"); $confirm = GETPOST("confirm");
//PDF //PDF
$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
@ -189,17 +189,17 @@ elseif ($action == 'setdate_lim_reglement' && $user->rights->fournisseur->factur
$result=$object->update($user); $result=$object->update($user);
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
elseif ($action == 'setnote_public' && $user->rights->fournisseur->facture->creer) elseif ($action == 'setnote_public' && $user->rights->fournisseur->facture->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
elseif ($action == 'setnote' && $user->rights->fournisseur->facture->creer) elseif ($action == 'setnote' && $user->rights->fournisseur->facture->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
// Delete payment // Delete payment
@ -437,7 +437,7 @@ elseif ($action == 'update_line')
} }
$localtax1tx= get_localtax($_POST['tauxtva'], 1, $object->thirdparty); $localtax1tx= get_localtax($_POST['tauxtva'], 1, $object->thirdparty);
$localtax2tx= get_localtax($_POST['tauxtva'], 2, $object->thirdparty); $localtax2tx= get_localtax($_POST['tauxtva'], 2, $object->thirdparty);
$result=$object->updateline($_GET['lineid'], $label, $pu, $_POST['tauxtva'], $localtax1tx, $localtax2tx, $_POST['qty'], $_POST['idprod'], $price_base_type, 0, $type); $result=$object->updateline($_GET['lineid'], $label, $pu, $_POST['tauxtva'], $localtax1tx, $localtax2tx, $_POST['qty'], $_POST['idprod'], $price_base_type, 0, $type);
@ -834,64 +834,64 @@ elseif ($action == 'remove_file')
} }
} }
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
if ($action == 'addcontact' && $user->rights->fournisseur->facture->creer) if ($action == 'addcontact' && $user->rights->fournisseur->facture->creer)
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
} }
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
else else
{ {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
} }
else else
{ {
$mesg = '<div class="error">'.$object->error.'</div>'; $mesg = '<div class="error">'.$object->error.'</div>';
} }
} }
} }
// bascule du statut d'un contact // bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->fournisseur->facture->creer) else if ($action == 'swapstatut' && $user->rights->fournisseur->facture->creer)
{ {
if ($object->fetch($id)) if ($object->fetch($id))
{ {
$result=$object->swapContactStatus(GETPOST('ligne')); $result=$object->swapContactStatus(GETPOST('ligne'));
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
// Efface un contact // Efface un contact
else if ($action == 'deletecontact' && $user->rights->fournisseur->facture->creer) else if ($action == 'deletecontact' && $user->rights->fournisseur->facture->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->delete_contact($_GET["lineid"]); $result = $object->delete_contact($_GET["lineid"]);
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
else { else {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
@ -1504,23 +1504,23 @@ else
print '</table><br>'; print '</table><br>';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
$formcompany= new FormCompany($db); $formcompany= new FormCompany($db);
$blocname = 'contacts'; $blocname = 'contacts';
$title = $langs->trans('ContactsAddresses'); $title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
} }
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$colwidth=20; $colwidth=20;
$blocname = 'notes'; $blocname = 'notes';
$title = $langs->trans('Notes'); $title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
} }

View File

@ -72,9 +72,9 @@ $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$search_ref = GETPOST('search_ref','alpha'); $search_ref = GETPOST('search_ref','alpha');
$search_ref_supplier = GETPOST('search_ref_supplier','alpha'); $search_ref_supplier = GETPOST('search_ref_supplier','alpha');
$search_societe = GETPOST('search_societe','alpha'); $search_societe = GETPOST('search_societe','alpha');
$search_montant_ht = GETPOST('search_montant_ht','int'); $search_montant_ht = GETPOST('search_montant_ht','int');
$search_montant_ttc = GETPOST('search_montant_ttc','int'); $search_montant_ttc = GETPOST('search_montant_ttc','int');
@ -164,9 +164,9 @@ if ($user->rights->fournisseur->facture->lire)
if ($socid) $param.="&socid=".$socid; if ($socid) $param.="&socid=".$socid;
if ($search_ref) $param.='&amp;search_ref='.urlencode($search_ref); if ($search_ref) $param.='&amp;search_ref='.urlencode($search_ref);
if ($search_ref_supplier) $param.='&amp;search_ref_supplier='.urlencode($search_ref_supplier); if ($search_ref_supplier) $param.='&amp;search_ref_supplier='.urlencode($search_ref_supplier);
if ($search_societe) $param.='&amp;search_societe='.urlencode($search_societe); if ($search_societe) $param.='&amp;search_societe='.urlencode($search_societe);
if ($search_montant_ht) $param.='&amp;search_montant_ht='.urlencode($search_montant_ht); if ($search_montant_ht) $param.='&amp;search_montant_ht='.urlencode($search_montant_ht);
if ($search_montant_ttc) $param.='&amp;search_montant_ttc='.urlencode($search_montant_ttc); if ($search_montant_ttc) $param.='&amp;search_montant_ttc='.urlencode($search_montant_ttc);
$param.=($option?"&option=".$option:""); $param.=($option?"&option=".$option:"");

View File

@ -404,10 +404,10 @@ if ($object->fetch($id))
show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?id='.$object->id); show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?id='.$object->id);
} }
// Addresses list // Addresses list
if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB)) if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB))
{ {
$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
} }
if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB))

View File

@ -237,7 +237,7 @@ if (! $error && $db->connected)
{ {
if (! empty($_POST["db_create_database"])) // If we create database, we force default value if (! empty($_POST["db_create_database"])) // If we create database, we force default value
{ {
$defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); $defaultCharacterSet=getStaticMember(get_class($db),'forcecharset');
$defaultCollationConnection=getStaticMember(get_class($db),'forcecollate'); $defaultCollationConnection=getStaticMember(get_class($db),'forcecollate');
} }
else // If already created, we take current value else // If already created, we take current value

View File

@ -81,11 +81,11 @@ if (! defined('DONOTLOADCONF') && file_exists($conffile))
{ {
if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // For backward compatibility if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // For backward compatibility
// Clean parameters // Clean parameters
$dolibarr_main_data_root =isset($dolibarr_main_data_root)?trim($dolibarr_main_data_root):''; $dolibarr_main_data_root =isset($dolibarr_main_data_root)?trim($dolibarr_main_data_root):'';
$dolibarr_main_url_root =isset($dolibarr_main_url_root)?trim($dolibarr_main_url_root):''; $dolibarr_main_url_root =isset($dolibarr_main_url_root)?trim($dolibarr_main_url_root):'';
$dolibarr_main_url_root_alt =isset($dolibarr_main_url_root_alt)?trim($dolibarr_main_url_root_alt):''; $dolibarr_main_url_root_alt =isset($dolibarr_main_url_root_alt)?trim($dolibarr_main_url_root_alt):'';
$dolibarr_main_document_root =isset($dolibarr_main_document_root)?trim($dolibarr_main_document_root):''; $dolibarr_main_document_root =isset($dolibarr_main_document_root)?trim($dolibarr_main_document_root):'';
$dolibarr_main_document_root_alt=isset($dolibarr_main_document_root_alt)?trim($dolibarr_main_document_root_alt):''; $dolibarr_main_document_root_alt=isset($dolibarr_main_document_root_alt)?trim($dolibarr_main_document_root_alt):'';
// Remove last / or \ on directories or url value // Remove last / or \ on directories or url value

View File

@ -27,20 +27,20 @@
* @param int $id Element id * @param int $id Element id
* @param string $table Table of Element * @param string $table Table of Element
*/ */
function checkElementExist($id, $table) function checkElementExist($id, $table)
{ {
global $db; global $db;
$sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . $table; $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . $table;
$sql.= ' WHERE rowid = '.$id; $sql.= ' WHERE rowid = '.$id;
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num > 0) return true; if ($num > 0) return true;
else return false; else return false;
} }
else return true; // for security else return true; // for security
} }
/** /**
@ -50,11 +50,11 @@ function checkElementExist($id, $table)
* @param string $targettype Target element type * @param string $targettype Target element type
* @return string * @return string
*/ */
function checkLinkedElements($sourcetype, $targettype) function checkLinkedElements($sourcetype, $targettype)
{ {
global $db, $langs; global $db, $langs;
$elements=array(); $elements=array();
$deleted=0; $deleted=0;
$sourcetable=$sourcetype; $sourcetable=$sourcetype;
@ -62,51 +62,51 @@ function checkLinkedElements($sourcetype, $targettype)
if ($sourcetype == 'shipping') $sourcetable = 'expedition'; if ($sourcetype == 'shipping') $sourcetable = 'expedition';
else if ($targettype == 'shipping') $targettable = 'expedition'; else if ($targettype == 'shipping') $targettable = 'expedition';
if ($sourcetype == 'delivery') $sourcetable = 'livraison'; if ($sourcetype == 'delivery') $sourcetable = 'livraison';
else if ($targettype == 'delivery') $targettable = 'livraison'; else if ($targettype == 'delivery') $targettable = 'livraison';
if ($sourcetype == 'order_supplier') $sourcetable = 'commande_fournisseur'; if ($sourcetype == 'order_supplier') $sourcetable = 'commande_fournisseur';
else if ($targettype == 'order_supplier') $targettable = 'commande_fournisseur'; else if ($targettype == 'order_supplier') $targettable = 'commande_fournisseur';
if ($sourcetype == 'invoice_supplier') $sourcetable = 'facture_fourn'; if ($sourcetype == 'invoice_supplier') $sourcetable = 'facture_fourn';
else if ($targettype == 'invoice_supplier') $targettable = 'facture_fourn'; else if ($targettype == 'invoice_supplier') $targettable = 'facture_fourn';
$out = $langs->trans('SourceType').': '.$sourcetype.' => '.$langs->trans('TargetType').': '.$targettype.' '; $out = $langs->trans('SourceType').': '.$sourcetype.' => '.$langs->trans('TargetType').': '.$targettype.' ';
$sql = 'SELECT * FROM '.MAIN_DB_PREFIX .'element_element'; $sql = 'SELECT * FROM '.MAIN_DB_PREFIX .'element_element';
$sql.= ' WHERE sourcetype="'.$sourcetype.'" AND targettype="'.$targettype.'"'; $sql.= ' WHERE sourcetype="'.$sourcetype.'" AND targettype="'.$targettype.'"';
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num) if ($num)
{
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$elements[$obj->rowid]=array($sourcetype => $obj->fk_source, $targettype => $obj->fk_target);
$i++;
}
}
}
if (! empty($elements))
{
foreach($elements as $key => $element)
{ {
if (! checkElementExist($element[$sourcetype], $sourcetable) || ! checkElementExist($element[$targettype], $targettable)) $i = 0;
{ while ($i < $num)
$sql = 'DELETE FROM '.MAIN_DB_PREFIX .'element_element'; {
$sql.= ' WHERE rowid = '.$key; $obj = $db->fetch_object($resql);
$resql=$db->query($sql); $elements[$obj->rowid]=array($sourcetype => $obj->fk_source, $targettype => $obj->fk_target);
$deleted++; $i++;
} }
} }
} }
if ($deleted) $out.= '('.$langs->trans('LinkedElementsInvalidDeleted', $deleted).')<br>'; if (! empty($elements))
else $out.= '('.$langs->trans('NothingToDelete').')<br>'; {
foreach($elements as $key => $element)
return $out; {
if (! checkElementExist($element[$sourcetype], $sourcetable) || ! checkElementExist($element[$targettype], $targettable))
{
$sql = 'DELETE FROM '.MAIN_DB_PREFIX .'element_element';
$sql.= ' WHERE rowid = '.$key;
$resql=$db->query($sql);
$deleted++;
}
}
}
if ($deleted) $out.= '('.$langs->trans('LinkedElementsInvalidDeleted', $deleted).')<br>';
else $out.= '('.$langs->trans('NothingToDelete').')<br>';
return $out;
} }
?> ?>

View File

@ -893,8 +893,8 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
//print 'themepath='.$themepath.' themeparam='.$themeparam;exit; //print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
print '<link rel="stylesheet" type="text/css" title="default" href="'.$themepath.$themeparam.'">'."\n"; print '<link rel="stylesheet" type="text/css" title="default" href="'.$themepath.$themeparam.'">'."\n";
// CSS forced by modules (relative url starting with /) // CSS forced by modules (relative url starting with /)
$dircss=(array) $conf->modules_parts['css']; $dircss=(array) $conf->modules_parts['css'];
foreach($dircss as $key => $cssfile) foreach($dircss as $key => $cssfile)
{ {
// cssfile is a relative path // cssfile is a relative path
print '<link rel="stylesheet" type="text/css" title="default" href="'.dol_buildpath($cssfile,1); print '<link rel="stylesheet" type="text/css" title="default" href="'.dol_buildpath($cssfile,1);
@ -991,7 +991,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-fp.js"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-fp.js"></script>'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-ui.js"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-ui.js"></script>'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-jui.js"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-jui.js"></script>'."\n";
print '<!-- The XDomainRequest Transport is included for cross-domain file deletion for IE8+ -->'."\n"; print '<!-- The XDomainRequest Transport is included for cross-domain file deletion for IE8+ -->'."\n";
'<!--[if gte IE 8]><script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/cors/jquery.xdr-transport.js"></script><![endif]-->'."\n"; '<!--[if gte IE 8]><script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/cors/jquery.xdr-transport.js"></script><![endif]-->'."\n";
} }
// jQuery DataTables // jQuery DataTables
@ -1002,10 +1002,10 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/ColVis/js/ColVis.min'.$ext.'"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/ColVis/js/ColVis.min'.$ext.'"></script>'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/TableTools/js/TableTools.min'.$ext.'"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/TableTools/js/TableTools.min'.$ext.'"></script>'."\n";
} }
// jQuery Multiselect // jQuery Multiselect
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)) if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT))
{ {
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/multiselect/js/ui.multiselect.js"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/multiselect/js/ui.multiselect.js"></script>'."\n";
} }
// CKEditor // CKEditor
if (! empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor')) if (! empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor'))
@ -1030,11 +1030,11 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/datepicker.js.php?lang='.$langs->defaultlang.'"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/datepicker.js.php?lang='.$langs->defaultlang.'"></script>'."\n";
// JS forced by modules (relative url starting with /) // JS forced by modules (relative url starting with /)
$dirjs=(array) $conf->modules_parts['js']; $dirjs=(array) $conf->modules_parts['js'];
foreach($dirjs as $key => $jsfile) foreach($dirjs as $key => $jsfile)
{ {
// jsfile is a relative path // jsfile is a relative path
print '<script type="text/javascript" src="'.dol_buildpath($jsfile,1).'"></script><!-- Added by module '.$key. '-->'."\n"; print '<script type="text/javascript" src="'.dol_buildpath($jsfile,1).'"></script><!-- Added by module '.$key. '-->'."\n";
} }
// JS forced by page in top_htmlhead (relative url starting with /) // JS forced by page in top_htmlhead (relative url starting with /)
if (is_array($arrayofjs)) if (is_array($arrayofjs))

View File

@ -763,28 +763,28 @@ function deformatNVP($nvpstr)
return $nvpArray; return $nvpArray;
} }
/** /**
* Get API errors * Get API errors
* *
* @return array Array of errors * @return array Array of errors
*/ */
function getApiError() function getApiError()
{ {
$errors=array(); $errors=array();
$resArray=$_SESSION['reshash']; $resArray=$_SESSION['reshash'];
if(isset($_SESSION['curl_error_no'])) if(isset($_SESSION['curl_error_no']))
{ {
$errors[] = $_SESSION['curl_error_no'].'-'.$_SESSION['curl_error_msg']; $errors[] = $_SESSION['curl_error_no'].'-'.$_SESSION['curl_error_msg'];
} }
foreach($resArray as $key => $value) foreach($resArray as $key => $value)
{ {
$errors[] = $key.'-'.$value; $errors[] = $key.'-'.$value;
} }
return $errors; return $errors;
} }
?> ?>

View File

@ -511,32 +511,32 @@ class Product extends CommonObject
if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref)) if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref))
{ {
// We remove directory // We remove directory
if ($conf->product->dir_output) if ($conf->product->dir_output)
{ {
$olddir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); $olddir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref);
$newdir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->ref); $newdir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->ref);
if (file_exists($olddir)) if (file_exists($olddir))
{ {
$res=@dol_move($olddir, $newdir); $res=@dol_move($olddir, $newdir);
if (! $res) if (! $res)
{ {
$this->error='ErrorFailToMoveDir'; $this->error='ErrorFailToMoveDir';
$error++; $error++;
} }
} }
} }
} }
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->db->rollback(); $this->db->rollback();
return -$error; return -$error;
} }
} }
else else
@ -621,31 +621,31 @@ class Product extends CommonObject
if (! $error) if (! $error)
{ {
// We remove directory // We remove directory
$ref = dol_sanitizeFileName($this->ref); $ref = dol_sanitizeFileName($this->ref);
if ($conf->product->dir_output) if ($conf->product->dir_output)
{ {
$dir = $conf->product->dir_output . "/" . $ref; $dir = $conf->product->dir_output . "/" . $ref;
if (file_exists($dir)) if (file_exists($dir))
{ {
$res=@dol_delete_dir_recursive($dir); $res=@dol_delete_dir_recursive($dir);
if (! $res) if (! $res)
{ {
$this->error='ErrorFailToDeleteDir'; $this->error='ErrorFailToDeleteDir';
$error++; $error++;
} }
} }
} }
} }
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->db->rollback(); $this->db->rollback();
return -$error; return -$error;
} }
} }

View File

@ -209,23 +209,23 @@ class Project extends CommonObject
// End call triggers // End call triggers
} }
if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref)) if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref))
{ {
// We remove directory // We remove directory
if ($conf->projet->dir_output) if ($conf->projet->dir_output)
{ {
$olddir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); $olddir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref);
$newdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->ref); $newdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->ref);
if (file_exists($olddir)) if (file_exists($olddir))
{ {
$res=@dol_move($olddir, $newdir); $res=@dol_move($olddir, $newdir);
if (! $res) if (! $res)
{ {
$this->error='ErrorFailToMoveDir'; $this->error='ErrorFailToMoveDir';
$error++; $error++;
} }
} }
} }
} }
$result = 1; $result = 1;

View File

@ -33,17 +33,17 @@ $langs->load('projects');
$langs->load('other'); $langs->load('other');
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha'); $confirm = GETPOST('confirm','alpha');
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref = GETPOST('ref','alpha'); $ref = GETPOST('ref','alpha');
$mine = (GETPOST('mode','alpha') == 'mine' ? 1 : 0); $mine = (GETPOST('mode','alpha') == 'mine' ? 1 : 0);
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$mesg=''; $mesg='';
if (isset($_SESSION['DolMessage'])) if (isset($_SESSION['DolMessage']))
{ {
$mesg=$_SESSION['DolMessage']; $mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']); unset($_SESSION['DolMessage']);
} }
// Security check // Security check
@ -52,7 +52,7 @@ if ($user->societe_id > 0) $socid=$user->societe_id;
$result=restrictedArea($user,'projet',$id,''); $result=restrictedArea($user,'projet',$id,'');
$object = new Project($db); $object = new Project($db);
$object->fetch($id,$ref); $object->fetch($id,$ref);
if ($object->id > 0) if ($object->id > 0)
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();

View File

@ -49,11 +49,11 @@ $socid=0;
if ($user->societe_id > 0) $socid=$user->societe_id; if ($user->societe_id > 0) $socid=$user->societe_id;
$result = restrictedArea($user, 'projet', $id); $result = restrictedArea($user, 'projet', $id);
$object = new Project($db); $object = new Project($db);
$object->fetch($id,$ref); $object->fetch($id,$ref);
if ($object->id > 0) if ($object->id > 0)
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
} }

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