+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/comm/propal/document.php
+ * \ingroup propale
+ * \brief Page de gestion des documents attaches a une proposition commerciale
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
+
+$langs->load('compta');
+$langs->load('other');
+
+$action = GETPOST('action','alpha');
+$confirm = GETPOST('confirm','alpha');
+$id = GETPOST('id','int');
+$ref = GETPOST('ref','alpha');
+
+$mesg='';
+if (isset($_SESSION['DolMessage']))
+{
+ $mesg=$_SESSION['DolMessage'];
+ unset($_SESSION['DolMessage']);
+}
+
+// Security check
+if ($user->societe_id)
+{
+ $action='';
+ $socid = $user->societe_id;
+}
+$result = restrictedArea($user, 'propale', $id, 'propal');
+
+// Get parameters
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+$page = GETPOST("page",'int');
+if ($page == -1) { $page = 0; }
+$offset = $conf->liste_limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (! $sortorder) $sortorder="ASC";
+if (! $sortfield) $sortfield="name";
+
+$object = new Propal($db);
+$object->fetch($id,$ref);
+if ($object->id > 0)
+{
+ $object->fetch_thirdparty();
+}
+
+/*
+ * Actions
+ */
+
+// Envoi fichier
+if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
+{
+ if ($object->id > 0)
+ {
+ $object->fetch_thirdparty();
+
+ $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
+
+ if (dol_mkdir($upload_dir) >= 0)
+ {
+ $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']),0,0,$_FILES['userfile']['error']);
+ if (is_numeric($resupload) && $resupload > 0)
+ {
+ if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1)
+ {
+ // Create small thumbs for image (Ratio is near 16/9)
+ // Used on logon for example
+ $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
+ // Create mini thumbs for image (Ratio is near 16/9)
+ // Used on menu or for setup page for example
+ $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs");
+ }
+ $mesg = ''.$langs->trans("FileTransferComplete").'
';
+ }
+ else
+ {
+ $langs->load("errors");
+ if ($resupload < 0) // Unknown error
+ {
+ $mesg = ''.$langs->trans("ErrorFileNotUploaded").'
';
+ }
+ else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
+ {
+ $mesg = ''.$langs->trans("ErrorFileIsInfectedWithAVirus").'
';
+ }
+ else // Known error
+ {
+ $mesg = ''.$langs->trans($resupload).'
';
+ }
+ }
+ }
+ }
+}
+
+// Delete
+if ($action == 'confirm_deletefile' && $confirm == 'yes')
+{
+ if ($object->id > 0)
+ {
+ $langs->load("other");
+
+ $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
+ $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);
+ $_SESSION['DolMessage'] = ''.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
';
+ Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
+ exit;
+ }
+}
+
+
+/*
+ * View
+ */
+
+llxHeader();
+
+$form = new Form($db);
+
+if ($object->id > 0)
+{
+ $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref);
+
+ $head = propal_prepare_head($object);
+ dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal');
+
+
+ // Construit liste des fichiers
+ $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+ $totalsize=0;
+ foreach($filearray as $key => $file)
+ {
+ $totalsize+=$file['size'];
+ }
+
+
+ print '';
+
+ $linkback=''.$langs->trans("BackToList").' ';
+
+ // Ref
+ print ''.$langs->trans('Ref').' ';
+ print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
+ print ' ';
+
+ // Ref client
+ print '';
+ print '';
+ print $langs->trans('RefCustomer').' ';
+ print ' ';
+ print '
';
+ print ' ';
+ print $object->ref_client;
+ print ' ';
+ print ' ';
+
+ // Customer
+ print "".$langs->trans("Company")." ";
+ print ''.$object->thirdparty->getNomUrl(1).' ';
+
+ print ''.$langs->trans("NbOfAttachedFiles").' '.count($filearray).' ';
+ print ''.$langs->trans("TotalSizeOfAttachedFiles").' '.$totalsize.' '.$langs->trans("bytes").' ';
+
+ print '
';
+
+ print '';
+
+ dol_htmloutput_mesg($mesg,$mesgs);
+
+ /*
+ * Confirmation suppression fichier
+ */
+ 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);
+ if ($ret == 'html') print ' ';
+ }
+
+ // Affiche formulaire upload
+ $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);
+
+
+ // List of document
+ $param='&id='.$object->id;
+ $formfile->list_of_documents($filearray,$object,'propal',$param);
+}
+else
+{
+ print $langs->trans("UnkownError");
+}
+
+$db->close();
+
+llxFooter();
+?>
diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php
index ea518da991a..6063c21a8d0 100644
--- a/htdocs/comm/propal/index.php
+++ b/htdocs/comm/propal/index.php
@@ -184,14 +184,14 @@ if ($conf->propal->enabled)
$obj = $db->fetch_object($resql);
print "";
- $propalstatic->id=$obj->rowid;
- $propalstatic->ref=$obj->ref;
+ $propalstatic->id=$obj->rowid;
+ $propalstatic->ref=$obj->ref;
print ''.$propalstatic->getNomUrl(1).' ';
- $companystatic->id=$obj->socid;
- $companystatic->name=$obj->socname;
- $companystatic->client=$obj->client;
- $companystatic->canvas=$obj->canvas;
+ $companystatic->id=$obj->socid;
+ $companystatic->name=$obj->socname;
+ $companystatic->client=$obj->client;
+ $companystatic->canvas=$obj->canvas;
print ''.$companystatic->getNomUrl(1,'customer',24).' ';
print ' ';
@@ -265,10 +265,10 @@ if ($resql)
print '';
- $companystatic->id=$obj->socid;
- $companystatic->name=$obj->socname;
- $companystatic->client=$obj->client;
- $companystatic->canvas=$obj->canvas;
+ $companystatic->id=$obj->socid;
+ $companystatic->name=$obj->socname;
+ $companystatic->client=$obj->client;
+ $companystatic->canvas=$obj->canvas;
print ''.$companystatic->getNomUrl(1,'customer').' ';
print ''.dol_print_date($db->jdate($obj->datec),'day').' ';
@@ -340,10 +340,10 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
print "";
- $companystatic->id=$obj->socid;
- $companystatic->name=$obj->socname;
- $companystatic->client=$obj->client;
- $companystatic->canvas=$obj->canvas;
+ $companystatic->id=$obj->socid;
+ $companystatic->name=$obj->socname;
+ $companystatic->client=$obj->client;
+ $companystatic->canvas=$obj->canvas;
print ''.$companystatic->getNomUrl(1,'customer',44).' '."\n";
print '';
diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php
index fde8d2411d3..47507e5b920 100644
--- a/htdocs/comm/propal/note.php
+++ b/htdocs/comm/propal/note.php
@@ -47,18 +47,18 @@ $object = new Propal($db);
/* Actions */
/******************************************************************************/
-if ($action == 'setnote_public' && $user->rights->propale->creer)
-{
- $object->fetch($id);
- $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
- if ($result < 0) dol_print_error($db,$object->error);
-}
-
-else if ($action == 'setnote' && $user->rights->propale->creer)
-{
- $object->fetch($id);
- $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
- if ($result < 0) dol_print_error($db,$object->error);
+if ($action == 'setnote_public' && $user->rights->propale->creer)
+{
+ $object->fetch($id);
+ $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
+ if ($result < 0) dol_print_error($db,$object->error);
+}
+
+else if ($action == 'setnote' && $user->rights->propale->creer)
+{
+ $object->fetch($id);
+ $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
+ if ($result < 0) dol_print_error($db,$object->error);
}
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 7376e797c3c..25fa62ba302 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -923,13 +923,13 @@ class Commande extends CommonObject
$this->note_public = $object->note_public;
$this->origin = $object->element;
- $this->origin_id = $object->id;
-
- // Possibility to add external linked objects with hooks
- $this->linked_objects[$this->origin] = $this->origin_id;
- 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->origin_id = $object->id;
+
+ // Possibility to add external linked objects with hooks
+ $this->linked_objects[$this->origin] = $this->origin_id;
+ if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
+ {
+ $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
}
$ret = $this->create($user);
@@ -939,7 +939,7 @@ class Commande extends CommonObject
// Actions hooked (by external module)
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->initHooks(array('orderdao'));
@@ -2069,16 +2069,16 @@ class Commande extends CommonObject
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
if ($this->db->query($sql) )
{
- if (! empty($conf->propal->enabled) && ! empty($conf->global->PROPALE_CLASSIFIED_INVOICED_WITH_ORDER))
- {
+ if (! empty($conf->propal->enabled) && ! empty($conf->global->PROPALE_CLASSIFIED_INVOICED_WITH_ORDER))
+ {
$this->fetchObjectLinked('','propal',$this->id,$this->element);
- if (! empty($this->linkedObjects))
- {
- foreach($this->linkedObjects['propal'] as $element)
- {
- $ret=$element->classer_facturee();
- }
- }
+ if (! empty($this->linkedObjects))
+ {
+ foreach($this->linkedObjects['propal'] as $element)
+ {
+ $ret=$element->classer_facturee();
+ }
+ }
}
return 1;
}
diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php
index 9e4cfd2923b..c6ebdf1ade9 100644
--- a/htdocs/commande/contact.php
+++ b/htdocs/commande/contact.php
@@ -106,10 +106,10 @@ else if ($action == 'deletecontact' && $user->rights->commande->creer)
}
}
-else if ($action == 'setaddress' && $user->rights->commande->creer)
-{
- $object->fetch($id);
- $object->setDeliveryAddress($_POST['fk_address']);
+else if ($action == 'setaddress' && $user->rights->commande->creer)
+{
+ $object->fetch($id);
+ $object->setDeliveryAddress($_POST['fk_address']);
}
/*
@@ -173,27 +173,27 @@ if ($id > 0 || ! empty($ref))
print " ".$langs->trans("Company")." ";
print ''.$object->client->getNomUrl(1).' ';
- // Delivery address
- if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
- {
- print '';
- print '';
- print ' ';
-
- if ($action == 'editdelivery_address')
- {
- $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','commande',$object->id);
- }
- else
- {
- $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','commande',$object->id);
- }
- print ' ';
+ // Delivery address
+ if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
+ {
+ print '';
+ print '';
+ print ' ';
+
+ if ($action == 'editdelivery_address')
+ {
+ $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','commande',$object->id);
+ }
+ else
+ {
+ $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','commande',$object->id);
+ }
+ print ' ';
}
print "";
diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php
index 84c2896e0e3..e158495b0c2 100644
--- a/htdocs/commande/document.php
+++ b/htdocs/commande/document.php
@@ -40,11 +40,11 @@ $confirm = GETPOST('confirm');
$id = GETPOST('id','int');
$ref = GETPOST('ref');
-$mesg='';
-if (isset($_SESSION['DolMessage']))
-{
- $mesg=$_SESSION['DolMessage'];
- unset($_SESSION['DolMessage']);
+$mesg='';
+if (isset($_SESSION['DolMessage']))
+{
+ $mesg=$_SESSION['DolMessage'];
+ unset($_SESSION['DolMessage']);
}
// 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).
dol_delete_file($file,0,0,0,$object);
$_SESSION['DolMessage'] = ''.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
';
- Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
+ Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 57b1f6fcc27..c76d12423fa 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -81,10 +81,10 @@ $usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE;
$object=new Facture($db);
-// Load object
-if ($id > 0 || ! empty($ref))
-{
- $ret=$object->fetch($id, $ref);
+// Load object
+if ($id > 0 || ! empty($ref))
+{
+ $ret=$object->fetch($id, $ref);
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
@@ -166,37 +166,37 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fact
// Delete line
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer)
{
- $object->fetch($id);
- $object->fetch_thirdparty();
-
- $result = $object->deleteline($_GET['lineid'], $user);
- if ($result > 0)
- {
- // Define output language
- $outputlangs = $langs;
- $newlang='';
- 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 (! empty($newlang))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($newlang);
- }
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
- {
- $ret=$object->fetch($id); // Reload to get new records
- $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
- }
- if ($result >= 0)
- {
- Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
- exit;
- }
- }
- else
- {
- $mesg=''.$object->error.'
';
- $action='';
+ $object->fetch($id);
+ $object->fetch_thirdparty();
+
+ $result = $object->deleteline($_GET['lineid'], $user);
+ if ($result > 0)
+ {
+ // Define output language
+ $outputlangs = $langs;
+ $newlang='';
+ 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 (! empty($newlang))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
+ {
+ $ret=$object->fetch($id); // Reload to get new records
+ $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
+ }
+ if ($result >= 0)
+ {
+ Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
+ exit;
+ }
+ }
+ else
+ {
+ $mesg=''.$object->error.'
';
+ $action='';
}
}
@@ -317,18 +317,18 @@ else if ($action == 'set_ref_client' && $user->rights->facture->creer)
$object->set_ref_client($_POST['ref_client']);
}
-else if ($action == 'setnote_public' && $user->rights->facture->creer)
-{
- $object->fetch($id);
- $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
- if ($result < 0) dol_print_error($db,$object->error);
-}
-
-else if ($action == 'setnote' && $user->rights->facture->creer)
-{
- $object->fetch($id);
- $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
- if ($result < 0) dol_print_error($db,$object->error);
+else if ($action == 'setnote_public' && $user->rights->facture->creer)
+{
+ $object->fetch($id);
+ $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
+ if ($result < 0) dol_print_error($db,$object->error);
+}
+
+else if ($action == 'setnote' && $user->rights->facture->creer)
+{
+ $object->fetch($id);
+ $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
+ if ($result < 0) dol_print_error($db,$object->error);
}
// Classify to validated
@@ -1513,81 +1513,81 @@ else if ($action == 'builddoc') // En get ou en post
}
}
-// Remove file in doc form
-else if ($action == 'remove_file')
-{
- if ($object->fetch($id))
- {
- require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
-
- $object->fetch_thirdparty();
-
- $langs->load("other");
- $upload_dir = $conf->facture->dir_output;
- $file = $upload_dir . '/' . GETPOST('file');
- dol_delete_file($file,0,0,0,$object);
- $mesg = ''.$langs->trans("FileWasRemoved",GETPOST('file')).'
';
- }
+// Remove file in doc form
+else if ($action == 'remove_file')
+{
+ if ($object->fetch($id))
+ {
+ require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
+
+ $object->fetch_thirdparty();
+
+ $langs->load("other");
+ $upload_dir = $conf->facture->dir_output;
+ $file = $upload_dir . '/' . GETPOST('file');
+ dol_delete_file($file,0,0,0,$object);
+ $mesg = ''.$langs->trans("FileWasRemoved",GETPOST('file')).'
';
+ }
}
-if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
+if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
- if ($action == 'addcontact' && $user->rights->facture->creer)
- {
- $result = $object->fetch($id);
-
- if ($result > 0 && $id > 0)
+ if ($action == 'addcontact' && $user->rights->facture->creer)
+ {
+ $result = $object->fetch($id);
+
+ if ($result > 0 && $id > 0)
{
- $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
- $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
- }
-
- if ($result >= 0)
- {
- Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
- exit;
- }
- else
- {
- if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
- {
- $langs->load("errors");
- $mesg = ''.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
';
- }
- else
- {
- $mesg = ''.$object->error.'
';
- }
- }
- }
-
- // bascule du statut d'un contact
- else if ($action == 'swapstatut' && $user->rights->facture->creer)
- {
- if ($object->fetch($id))
- {
- $result=$object->swapContactStatus(GETPOST('ligne'));
- }
- else
- {
- dol_print_error($db);
- }
- }
-
- // Efface un contact
- else if ($action == 'deletecontact' && $user->rights->facture->creer)
- {
- $object->fetch($id);
- $result = $object->delete_contact($lineid);
-
- if ($result >= 0)
- {
- Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
- exit;
- }
- else {
- dol_print_error($db);
- }
+ $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
+ $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
+ }
+
+ if ($result >= 0)
+ {
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ exit;
+ }
+ else
+ {
+ if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
+ {
+ $langs->load("errors");
+ $mesg = ''.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
';
+ }
+ else
+ {
+ $mesg = ''.$object->error.'
';
+ }
+ }
+ }
+
+ // bascule du statut d'un contact
+ else if ($action == 'swapstatut' && $user->rights->facture->creer)
+ {
+ if ($object->fetch($id))
+ {
+ $result=$object->swapContactStatus(GETPOST('ligne'));
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+ }
+
+ // Efface un contact
+ else if ($action == 'deletecontact' && $user->rights->facture->creer)
+ {
+ $object->fetch($id);
+ $result = $object->delete_contact($lineid);
+
+ if ($result >= 0)
+ {
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ exit;
+ }
+ else {
+ dol_print_error($db);
+ }
}
}
@@ -2825,22 +2825,22 @@ else
print ' ';
- 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.'/core/class/html.formcompany.class.php');
- $formcompany= new FormCompany($db);
-
- $blocname = 'contacts';
- $title = $langs->trans('ContactsAddresses');
- include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
- }
-
- if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
- {
- $blocname = 'notes';
- $title = $langs->trans('Notes');
- include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
+ require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
+ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
+ $formcompany= new FormCompany($db);
+
+ $blocname = 'contacts';
+ $title = $langs->trans('ContactsAddresses');
+ include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
+ }
+
+ if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
+ {
+ $blocname = 'notes';
+ $title = $langs->trans('Notes');
+ include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
/*
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 72698d39326..30040fe6cb4 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -256,30 +256,30 @@ class Facture extends CommonObject
$error++;
}
- // TODO mutualiser
- if ($origin == 'commande')
- {
- // On recupere les differents contact interne et externe
+ // TODO mutualiser
+ if ($origin == 'commande')
+ {
+ // On recupere les differents contact interne et externe
$order = new Commande($this->db);
- $order->id = $origin_id;
-
- // On recupere le commercial suivi propale
+ $order->id = $origin_id;
+
+ // On recupere le commercial suivi propale
$this->userid = $order->getIdcontact('internal', 'SALESREPFOLL');
-
- if ($this->userid)
- {
- //On passe le commercial suivi commande en commercial suivi paiement
- $this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
- }
-
- // On recupere le contact client facturation commande
- $this->contactid = $order->getIdcontact('external', 'BILLING');
-
- if ($this->contactid)
- {
- //On passe le contact client facturation commande en contact client facturation
- $this->add_contact($this->contactid[0], 'BILLING', 'external');
- }
+
+ if ($this->userid)
+ {
+ //On passe le commercial suivi commande en commercial suivi paiement
+ $this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
+ }
+
+ // On recupere le contact client facturation commande
+ $this->contactid = $order->getIdcontact('external', 'BILLING');
+
+ if ($this->contactid)
+ {
+ //On passe le contact client facturation commande en contact client facturation
+ $this->add_contact($this->contactid[0], 'BILLING', 'external');
+ }
}
}
}
@@ -674,11 +674,11 @@ class Facture extends CommonObject
$this->origin = $object->element;
$this->origin_id = $object->id;
- // Possibility to add external linked objects with hooks
- $this->linked_objects[$this->origin] = $this->origin_id;
- if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
- {
- $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
+ // Possibility to add external linked objects with hooks
+ $this->linked_objects[$this->origin] = $this->origin_id;
+ if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
+ {
+ $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
}
$ret = $this->create($user);
@@ -1237,32 +1237,32 @@ class Facture extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
- // On efface le repertoire de pdf provisoire
- $ref = dol_sanitizeFileName($this->ref);
- if ($conf->facture->dir_output)
- {
- $dir = $conf->facture->dir_output . "/" . $ref;
- $file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf";
- if (file_exists($file)) // We must delete all files before deleting directory
- {
+ // On efface le repertoire de pdf provisoire
+ $ref = dol_sanitizeFileName($this->ref);
+ if ($conf->facture->dir_output)
+ {
+ $dir = $conf->facture->dir_output . "/" . $ref;
+ $file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf";
+ if (file_exists($file)) // We must delete all files before deleting directory
+ {
$ret=dol_delete_preview($this);
-
- if (! dol_delete_file($file,0,0,0,$this)) // For triggers
- {
- $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
- $this->db->rollback();
- return 0;
- }
- }
- if (file_exists($dir))
- {
- if (! dol_delete_dir_recursive($dir)) // For remove dir and meta
- {
- $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
- $this->db->rollback();
- return 0;
- }
- }
+
+ if (! dol_delete_file($file,0,0,0,$this)) // For triggers
+ {
+ $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
+ $this->db->rollback();
+ return 0;
+ }
+ }
+ if (file_exists($dir))
+ {
+ if (! dol_delete_dir_recursive($dir)) // For remove dir and meta
+ {
+ $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
+ $this->db->rollback();
+ return 0;
+ }
+ }
}
$this->db->commit();
diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php
index d840db56dce..3598a747e79 100644
--- a/htdocs/compta/facture/contact.php
+++ b/htdocs/compta/facture/contact.php
@@ -35,7 +35,7 @@ $langs->load("companies");
$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
$ref = GETPOST('ref');
-$socid=GETPOST('socid','int');
+$socid=GETPOST('socid','int');
$action=GETPOST('action','alpha');
// Security check
@@ -166,9 +166,9 @@ if ($id > 0 || ! empty($ref))
print '';
- print ' ';
-
- // Contacts lines
+ print ' ';
+
+ // Contacts lines
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
}
else
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index b191b2f3fe6..9176fc5b61d 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -43,11 +43,11 @@ $confirm = GETPOST('confirm');
$id = GETPOST('facid','int');
$ref = GETPOST('ref');
-$mesg='';
-if (isset($_SESSION['DolMessage']))
-{
- $mesg=$_SESSION['DolMessage'];
- unset($_SESSION['DolMessage']);
+$mesg='';
+if (isset($_SESSION['DolMessage']))
+{
+ $mesg=$_SESSION['DolMessage'];
+ unset($_SESSION['DolMessage']);
}
// Security check
diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php
index 80d6bf6ca53..fc56584c564 100644
--- a/htdocs/compta/facture/note.php
+++ b/htdocs/compta/facture/note.php
@@ -31,9 +31,9 @@ require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php');
$langs->load("companies");
$langs->load("bills");
-$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
-$ref=GETPOST('ref','alpha');
-$socid=GETPOST('socid','int');
+$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
+$ref=GETPOST('ref','alpha');
+$socid=GETPOST('socid','int');
$action=GETPOST('action','alpha');
// Security check
diff --git a/htdocs/core/ajax/fileupload.php b/htdocs/core/ajax/fileupload.php
index a3a525d0d3c..30c52242f74 100644
--- a/htdocs/core/ajax/fileupload.php
+++ b/htdocs/core/ajax/fileupload.php
@@ -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');
switch ($_SERVER['REQUEST_METHOD']) {
- case 'OPTIONS':
+ case 'OPTIONS':
break;
case 'HEAD':
case 'GET':
diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php
index 55d9adb70f3..45781e46379 100644
--- a/htdocs/core/ajax/loadinplace.php
+++ b/htdocs/core/ajax/loadinplace.php
@@ -90,7 +90,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
$module = $subelement = $ext_element;
if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
{
- $module = $regs[1];
+ $module = $regs[1];
$subelement = $regs[2];
}
diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php
index 50541facffa..04cb8955a8a 100644
--- a/htdocs/core/ajax/saveinplace.php
+++ b/htdocs/core/ajax/saveinplace.php
@@ -30,9 +30,9 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
require('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
-$field = GETPOST('field','alpha',2);
-$element = GETPOST('element','alpha',2);
-$table_element = GETPOST('table_element','alpha',2);
+$field = GETPOST('field','alpha',2);
+$element = GETPOST('element','alpha',2);
+$table_element = GETPOST('table_element','alpha',2);
$fk_element = GETPOST('fk_element','alpha',2);
/*
@@ -132,11 +132,11 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
}
else
{
- $module = $subelement = $ext_element;
- if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
- {
- $module = $regs[1];
- $subelement = $regs[2];
+ $module = $subelement = $ext_element;
+ if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
+ {
+ $module = $regs[1];
+ $subelement = $regs[2];
}
dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php');
diff --git a/htdocs/core/ajax/vatrates.php b/htdocs/core/ajax/vatrates.php
index c4ecc36ae9b..985cfb9b71b 100644
--- a/htdocs/core/ajax/vatrates.php
+++ b/htdocs/core/ajax/vatrates.php
@@ -49,12 +49,12 @@ if (! empty($id) && ! empty($action) && ! empty($htmlname))
$soc->fetch($id);
- $return=array();
-
- $return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true);
- $return['num'] = $form->num;
- $return['error'] = $form->error;
-
+ $return=array();
+
+ $return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true);
+ $return['num'] = $form->num;
+ $return['error'] = $form->error;
+
echo json_encode($return);
}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 2fce0a684b8..67dfd974885 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -865,93 +865,93 @@ abstract class CommonObject
}
}
- /**
- * Change the payments methods
- *
- * @param int $id Id of new payment method
- * @return int >0 if OK, <0 if KO
- */
- function setPaymentMethods($id)
- {
- dol_syslog(get_class($this).'::setPaymentMethods('.$id.')');
- if ($this->statut >= 0 || $this->element == 'societe')
- {
- // TODO uniformize field name
- $fieldname = 'fk_mode_reglement';
- if ($this->element == 'societe') $fieldname = 'mode_reglement';
-
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql .= ' SET '.$fieldname.' = '.$id;
- $sql .= ' WHERE rowid='.$this->id;
-
- if ($this->db->query($sql))
- {
+ /**
+ * Change the payments methods
+ *
+ * @param int $id Id of new payment method
+ * @return int >0 if OK, <0 if KO
+ */
+ function setPaymentMethods($id)
+ {
+ dol_syslog(get_class($this).'::setPaymentMethods('.$id.')');
+ if ($this->statut >= 0 || $this->element == 'societe')
+ {
+ // TODO uniformize field name
+ $fieldname = 'fk_mode_reglement';
+ if ($this->element == 'societe') $fieldname = 'mode_reglement';
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql .= ' SET '.$fieldname.' = '.$id;
+ $sql .= ' WHERE rowid='.$this->id;
+
+ if ($this->db->query($sql))
+ {
$this->mode_reglement_id = $id;
- $this->mode_reglement = $id; // for compatibility
- return 1;
- }
- else
- {
- dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error());
- $this->error=$this->db->error();
- return -1;
- }
- }
- else
- {
- dol_syslog(get_class($this).'::setPaymentMethods, status of the object is incompatible');
- $this->error='Status of the object is incompatible '.$this->statut;
- return -2;
- }
+ $this->mode_reglement = $id; // for compatibility
+ return 1;
+ }
+ else
+ {
+ dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error());
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
+ else
+ {
+ dol_syslog(get_class($this).'::setPaymentMethods, status of the object is incompatible');
+ $this->error='Status of the object is incompatible '.$this->statut;
+ return -2;
+ }
}
- /**
- * Change the payments terms
- *
- * @param int $id Id of new payment terms
- * @return int >0 if OK, <0 if KO
- */
- function setPaymentTerms($id)
- {
- dol_syslog(get_class($this).'::setPaymentTerms('.$id.')');
- if ($this->statut >= 0 || $this->element == 'societe')
+ /**
+ * Change the payments terms
+ *
+ * @param int $id Id of new payment terms
+ * @return int >0 if OK, <0 if KO
+ */
+ function setPaymentTerms($id)
+ {
+ dol_syslog(get_class($this).'::setPaymentTerms('.$id.')');
+ if ($this->statut >= 0 || $this->element == 'societe')
{
// TODO uniformize field name
$fieldname = 'fk_cond_reglement';
if ($this->element == 'societe') $fieldname = 'cond_reglement';
-
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql .= ' SET '.$fieldname.' = '.$id;
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql .= ' SET '.$fieldname.' = '.$id;
$sql .= ' WHERE rowid='.$this->id;
-
- if ($this->db->query($sql))
- {
+
+ if ($this->db->query($sql))
+ {
$this->cond_reglement_id = $id;
- $this->cond_reglement = $id; // for compatibility
- return 1;
- }
- else
- {
- dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error());
- $this->error=$this->db->error();
- return -1;
- }
- }
- else
- {
- dol_syslog(get_class($this).'::setPaymentTerms, status of the object is incompatible');
- $this->error='Status of the object is incompatible '.$this->statut;
- return -2;
- }
+ $this->cond_reglement = $id; // for compatibility
+ return 1;
+ }
+ else
+ {
+ dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error());
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
+ else
+ {
+ dol_syslog(get_class($this).'::setPaymentTerms, status of the object is incompatible');
+ $this->error='Status of the object is incompatible '.$this->statut;
+ return -2;
+ }
}
- /**
- * Define delivery address
- *
- * @param int $id Address id
- * @return int <0 si ko, >0 si ok
- */
- function setDeliveryAddress($id)
+ /**
+ * Define delivery address
+ *
+ * @param int $id Address id
+ * @return int <0 si ko, >0 si ok
+ */
+ function setDeliveryAddress($id)
{
$fieldname = 'fk_adresse_livraison';
if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address';
@@ -962,14 +962,14 @@ abstract class CommonObject
if ($this->db->query($sql))
{
$this->fk_delivery_address = $id;
- return 1;
+ return 1;
}
else
{
$this->error=$this->db->error();
dol_syslog(get_class($this).'::setDeliveryAddress Erreur '.$sql.' - '.$this->error);
return -1;
- }
+ }
}
/**
@@ -1854,18 +1854,18 @@ abstract class CommonObject
$sql.= " WHERE rowid=".$elementId;
dol_syslog(get_class($this)."::setStatut sql=".$sql, LOG_DEBUG);
- if ($this->db->query($sql))
- {
+ if ($this->db->query($sql))
+ {
$this->db->commit();
- $this->statut = $status;
- return 1;
- }
- else
- {
+ $this->statut = $status;
+ return 1;
+ }
+ else
+ {
$this->error=$this->db->lasterror();
- dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR);
- $this->db->rollback();
- return -1;
+ dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR);
+ $this->db->rollback();
+ return -1;
}
}
@@ -2148,35 +2148,35 @@ abstract class CommonObject
return $nb;
}
- /**
+ /**
* Set extra parameters
*
- * @return void
- */
- function setExtraParameters()
+ * @return void
+ */
+ function setExtraParameters()
{
$this->db->begin();
$extraparams = (! empty($this->extraparams) ? json_encode($this->extraparams) : null);
-
+
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET extraparams = ".(! empty($extraparams) ? "'".$this->db->escape($extraparams)."'" : "null");
$sql.= " WHERE rowid = ".$this->id;
- dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (! $resql)
- {
- $this->error=$this->db->lasterror();
- dol_syslog(get_class($this)."::setExtraParameters ".$this->error, LOG_ERR);
- $this->db->rollback();
- return -1;
- }
- else
- {
- $this->db->commit();
- return 1;
- }
+ dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql)
+ {
+ $this->error=$this->db->lasterror();
+ dol_syslog(get_class($this)."::setExtraParameters ".$this->error, LOG_ERR);
+ $this->db->rollback();
+ return -1;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
}
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index 48f966a9fbf..88536a9f4d4 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -213,28 +213,28 @@ class Conf
//var_dump($this->modules);
//var_dump($this->modules_parts);
- // Object $mc
- if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
- {
- global $mc;
- $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
- if ($ret) $mc = new ActionsMulticompany($db);
+ // Object $mc
+ if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
+ {
+ global $mc;
+ $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
+ if ($ret) $mc = new ActionsMulticompany($db);
}
// Second or others levels object
- $this->propal->cloture = (object) array();
+ $this->propal->cloture = (object) array();
$this->propal->facturation = (object) array();
- $this->commande->client = (object) array();
+ $this->commande->client = (object) array();
$this->commande->fournisseur = (object) array();
- $this->facture->client = (object) array();
+ $this->facture->client = (object) array();
$this->facture->fournisseur = (object) array();
- $this->fournisseur->commande = (object) array();
+ $this->fournisseur->commande = (object) array();
$this->fournisseur->facture = (object) array();
- $this->contrat->services = (object) array();
- $this->contrat->services->inactifs = (object) array();
+ $this->contrat->services = (object) array();
+ $this->contrat->services->inactifs = (object) array();
$this->contrat->services->expires = (object) array();
$this->adherent->cotisation = (object) array();
- $this->bank->rappro = (object) array();
+ $this->bank->rappro = (object) array();
$this->bank->cheque = (object) array();
// Clean some variables
@@ -268,7 +268,7 @@ class Conf
// Define default dir_output and dir_temp for directories of modules
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");
// For backward compatibility
$this->$module->dir_output = $rootfordata."/".$module;
@@ -284,14 +284,14 @@ class Conf
$this->admin->dir_temp=$rootfordata.'/admin/temp';
// 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");
// For backward compatibility
$this->user->dir_output=$rootforuser."/users";
$this->user->dir_temp=$rootforuser."/users/temp";
- // For propal storage
- $this->propal->dir_output=$rootforuser."/propale";
+ // For propal storage
+ $this->propal->dir_output=$rootforuser."/propale";
$this->propal->dir_temp=$rootforuser."/propale/temp";
// Exception: Some dir are not the name of module. So we keep exception here
@@ -314,9 +314,9 @@ class Conf
$this->service->multidir_output=array($this->entity => $rootfordata."/produit");
$this->service->multidir_temp =array($this->entity => $rootfordata."/produit/temp");
// For backward compatibility
- $this->product->dir_output=$rootfordata."/produit";
- $this->product->dir_temp =$rootfordata."/produit/temp";
- $this->service->dir_output=$rootfordata."/produit";
+ $this->product->dir_output=$rootfordata."/produit";
+ $this->product->dir_temp =$rootfordata."/produit/temp";
+ $this->service->dir_output=$rootfordata."/produit";
$this->service->dir_temp =$rootfordata."/produit/temp";
// Module contrat
@@ -436,10 +436,10 @@ class Conf
if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_backoffice.php';
elseif ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_backoffice.php';
- // Object $mc
- if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
+ // Object $mc
+ if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
{
- if (is_object($mc)) $mc->setValues($this);
+ if (is_object($mc)) $mc->setValues($this);
}
}
}
diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php
index af1a24efb26..41fafdb0584 100644
--- a/htdocs/core/class/fileupload.class.php
+++ b/htdocs/core/class/fileupload.class.php
@@ -66,9 +66,9 @@ class FileUpload
$pathname = 'compta/facture';
$dir_output=$conf->$element->dir_output;
}
- elseif ($element == 'project') {
+ elseif ($element == 'project') {
$element = $pathname = 'projet';
- $dir_output=$conf->$element->dir_output;
+ $dir_output=$conf->$element->dir_output;
}
elseif ($element == 'fichinter') {
$element='ficheinter';
@@ -109,11 +109,11 @@ class FileUpload
'accept_file_types' => '/.+$/i',
// The maximum number of files for the upload directory:
'max_number_of_files' => null,
- // Image resolution restrictions:
- 'max_width' => null,
- 'max_height' => null,
- 'min_width' => 1,
- 'min_height' => 1,
+ // Image resolution restrictions:
+ 'max_width' => null,
+ 'max_height' => null,
+ 'min_width' => 1,
+ 'min_height' => 1,
// Set the following option to false to enable resumable uploads:
'discard_aborted_uploads' => true,
'image_versions' => array(
@@ -132,7 +132,7 @@ class FileUpload
'thumbnail' => array(
'upload_dir' => $dir_output . '/' . $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
)
)
@@ -146,14 +146,14 @@ class FileUpload
*
*/
protected function getFullUrl() {
- $https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
- return
- ($https ? 'https://' : 'http://').
- (!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : '').
- (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].
- ($https && $_SERVER['SERVER_PORT'] === 443 ||
- $_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))).
- substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
+ $https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
+ return
+ ($https ? 'https://' : 'http://').
+ (!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : '').
+ (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].
+ ($https && $_SERVER['SERVER_PORT'] === 443 ||
+ $_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))).
+ substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
}
/**
@@ -161,13 +161,13 @@ class FileUpload
*
* @param unknown_type $file
*/
- protected function set_file_delete_url($file) {
- $file->delete_url = $this->_options['script_url']
- .'?file='.rawurlencode($file->name).'&fk_element='.$this->_fk_element.'&element='.$this->_element;
- $file->delete_type = $this->_options['delete_type'];
- if ($file->delete_type !== 'DELETE') {
- $file->delete_url .= '&_method=DELETE';
- }
+ protected function set_file_delete_url($file) {
+ $file->delete_url = $this->_options['script_url']
+ .'?file='.rawurlencode($file->name).'&fk_element='.$this->_fk_element.'&element='.$this->_element;
+ $file->delete_type = $this->_options['delete_type'];
+ if ($file->delete_type !== 'DELETE') {
+ $file->delete_url .= '&_method=DELETE';
+ }
}
/**
@@ -256,9 +256,9 @@ class FileUpload
$file->error = $error;
return false;
}
- if (!$file->name) {
- $file->error = 'missingFileName';
- return false;
+ if (!$file->name) {
+ $file->error = 'missingFileName';
+ return false;
}
if (!preg_match($this->_options['accept_file_types'], $file->name)) {
$file->error = 'acceptFileTypes';
@@ -308,10 +308,10 @@ class FileUpload
*
* @param unknown_type $matches
*/
- protected function upcount_name_callback($matches) {
- $index = isset($matches[1]) ? intval($matches[1]) + 1 : 1;
- $ext = isset($matches[2]) ? $matches[2] : '';
- return ' ('.$index.')'.$ext;
+ protected function upcount_name_callback($matches) {
+ $index = isset($matches[1]) ? intval($matches[1]) + 1 : 1;
+ $ext = isset($matches[2]) ? $matches[2] : '';
+ return ' ('.$index.')'.$ext;
}
/**
@@ -319,13 +319,13 @@ class FileUpload
*
* @param unknown_type $name
*/
- protected function upcount_name($name) {
- return preg_replace_callback(
- '/(?:(?: \(([\d]+)\))?(\.[^.]+))?$/',
- array($this, 'upcount_name_callback'),
- $name,
- 1
- );
+ protected function upcount_name($name) {
+ return preg_replace_callback(
+ '/(?:(?: \(([\d]+)\))?(\.[^.]+))?$/',
+ array($this, 'upcount_name_callback'),
+ $name,
+ 1
+ );
}
/**
@@ -335,22 +335,22 @@ class FileUpload
* @param unknown_type $type
* @param unknown_type $index
*/
- protected function trim_file_name($name, $type, $index) {
- // Remove path information and dots around the filename, to prevent uploading
- // into different directories or replacing hidden system files.
- // Also remove control characters and spaces (\x00..\x20) around the filename:
- $file_name = trim(basename(stripslashes($name)), ".\x00..\x20");
- // Add missing file extension for known image types:
- if (strpos($file_name, '.') === false &&
- preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) {
- $file_name .= '.'.$matches[1];
- }
- if ($this->_options['discard_aborted_uploads']) {
- while(is_file($this->_options['upload_dir'].$file_name)) {
- $file_name = $this->upcount_name($file_name);
- }
- }
- return $file_name;
+ protected function trim_file_name($name, $type, $index) {
+ // Remove path information and dots around the filename, to prevent uploading
+ // into different directories or replacing hidden system files.
+ // Also remove control characters and spaces (\x00..\x20) around the filename:
+ $file_name = trim(basename(stripslashes($name)), ".\x00..\x20");
+ // Add missing file extension for known image types:
+ if (strpos($file_name, '.') === false &&
+ preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) {
+ $file_name .= '.'.$matches[1];
+ }
+ if ($this->_options['discard_aborted_uploads']) {
+ while(is_file($this->_options['upload_dir'].$file_name)) {
+ $file_name = $this->upcount_name($file_name);
+ }
+ }
+ return $file_name;
}
/**
@@ -359,8 +359,8 @@ class FileUpload
* @param unknown_type $file
* @param unknown_type $index
*/
- protected function handle_form_data($file, $index) {
- // Handle form data, e.g. $_REQUEST['description'][$index]
+ protected function handle_form_data($file, $index) {
+ // Handle form data, e.g. $_REQUEST['description'][$index]
}
/**
@@ -368,33 +368,33 @@ class FileUpload
*
* @param unknown_type $file_path
*/
- protected function orient_image($file_path) {
- $exif = @exif_read_data($file_path);
- if ($exif === false) {
- return false;
- }
- $orientation = intval(@$exif['Orientation']);
- if (!in_array($orientation, array(3, 6, 8))) {
- return false;
- }
- $image = @imagecreatefromjpeg($file_path);
- switch ($orientation) {
- case 3:
- $image = @imagerotate($image, 180, 0);
- break;
- case 6:
- $image = @imagerotate($image, 270, 0);
- break;
- case 8:
- $image = @imagerotate($image, 90, 0);
- break;
- default:
- return false;
- }
- $success = imagejpeg($image, $file_path);
- // Free up memory (imagedestroy does not delete files):
- @imagedestroy($image);
- return $success;
+ protected function orient_image($file_path) {
+ $exif = @exif_read_data($file_path);
+ if ($exif === false) {
+ return false;
+ }
+ $orientation = intval(@$exif['Orientation']);
+ if (!in_array($orientation, array(3, 6, 8))) {
+ return false;
+ }
+ $image = @imagecreatefromjpeg($file_path);
+ switch ($orientation) {
+ case 3:
+ $image = @imagerotate($image, 180, 0);
+ break;
+ case 6:
+ $image = @imagerotate($image, 270, 0);
+ break;
+ case 8:
+ $image = @imagerotate($image, 90, 0);
+ break;
+ default:
+ return false;
+ }
+ $success = imagejpeg($image, $file_path);
+ // Free up memory (imagedestroy does not delete files):
+ @imagedestroy($image);
+ return $success;
}
/**
@@ -417,42 +417,42 @@ class FileUpload
$file->type = $type;
if ($this->validate($uploaded_file, $file, $error, $index) && dol_mkdir($this->_options['upload_dir']) >= 0) {
$this->handle_form_data($file, $index);
- $file_path = $this->_options['upload_dir'].$file->name;
- $append_file = !$this->_options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path);
+ $file_path = $this->_options['upload_dir'].$file->name;
+ $append_file = !$this->_options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path);
clearstatcache();
- if ($uploaded_file && is_uploaded_file($uploaded_file)) {
- // multipart/formdata uploads (POST method uploads)
- if ($append_file) {
- file_put_contents(
- $file_path,
- fopen($uploaded_file, 'r'),
- FILE_APPEND
- );
- } else {
- dol_move_uploaded_file($uploaded_file, $file_path, 1);
- }
- } else {
- // Non-multipart uploads (PUT method support)
- file_put_contents(
- $file_path,
- fopen('php://input', 'r'),
- $append_file ? FILE_APPEND : 0
- );
- }
+ if ($uploaded_file && is_uploaded_file($uploaded_file)) {
+ // multipart/formdata uploads (POST method uploads)
+ if ($append_file) {
+ file_put_contents(
+ $file_path,
+ fopen($uploaded_file, 'r'),
+ FILE_APPEND
+ );
+ } else {
+ dol_move_uploaded_file($uploaded_file, $file_path, 1);
+ }
+ } else {
+ // Non-multipart uploads (PUT method support)
+ file_put_contents(
+ $file_path,
+ fopen('php://input', 'r'),
+ $append_file ? FILE_APPEND : 0
+ );
+ }
$file_size = filesize($file_path);
- if ($file_size === $file->size) {
- $file->url = $this->_options['upload_url'].rawurlencode($file->name);
- foreach($this->_options['image_versions'] as $version => $options)
- {
- if ($this->create_scaled_image($file->name, $options))
- {
- $tmp=explode('.',$file->name);
- $file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]);
- }
- }
- } else if ($this->_options['discard_aborted_uploads']) {
- unlink($file_path);
- $file->error = 'abort';
+ if ($file_size === $file->size) {
+ $file->url = $this->_options['upload_url'].rawurlencode($file->name);
+ foreach($this->_options['image_versions'] as $version => $options)
+ {
+ if ($this->create_scaled_image($file->name, $options))
+ {
+ $tmp=explode('.',$file->name);
+ $file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]);
+ }
+ }
+ } else if ($this->_options['discard_aborted_uploads']) {
+ unlink($file_path);
+ $file->error = 'abort';
}
$file->size = $file_size;
$this->set_file_delete_url($file);
@@ -485,14 +485,14 @@ class FileUpload
*/
public function post()
{
- if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
- return $this->delete();
+ if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
+ return $this->delete();
}
$upload = isset($_FILES[$this->_options['param_name']]) ?
$_FILES[$this->_options['param_name']] : null;
$info = array();
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:
foreach ($upload['tmp_name'] as $index => $value) {
$info[] = $this->handle_file_upload(
@@ -505,7 +505,7 @@ class FileUpload
);
}
} 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:
$info[] = $this->handle_file_upload(
isset($upload['tmp_name']) ? $upload['tmp_name'] : null,
@@ -523,11 +523,11 @@ class FileUpload
}
header('Vary: Accept');
$json = json_encode($info);
- $redirect = isset($_REQUEST['redirect']) ?
- stripslashes($_REQUEST['redirect']) : null;
- if ($redirect) {
- header('Location: '.sprintf($redirect, rawurlencode($json)));
- return;
+ $redirect = isset($_REQUEST['redirect']) ?
+ stripslashes($_REQUEST['redirect']) : null;
+ if ($redirect) {
+ header('Location: '.sprintf($redirect, rawurlencode($json)));
+ return;
}
if (isset($_SERVER['HTTP_ACCEPT']) &&
(strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) {
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 99fbe2c5bb2..4ce0b9cc054 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -285,12 +285,12 @@ class Form
if (! empty($tmp[2])) $savemethod=$tmp[2];
if (! empty($tmp[3])) $button_only=true;
}
- else if (preg_match('/^textarea/',$inputType))
- {
- $tmp=explode(':',$inputType);
+ else if (preg_match('/^textarea/',$inputType))
+ {
+ $tmp=explode(':',$inputType);
$inputType=$tmp[0];
- if (! empty($tmp[1])) $rows=$tmp[1];
- if (! empty($tmp[2])) $cols=$tmp[2];
+ if (! empty($tmp[1])) $rows=$tmp[1];
+ if (! empty($tmp[2])) $cols=$tmp[2];
}
else if (preg_match('/^ckeditor/',$inputType))
{
@@ -669,6 +669,7 @@ class Form
$sql.= " FROM ".MAIN_DB_PREFIX ."societe as s";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
+ if (! empty($user->societe_id)) $sql.= " AND s.rowid = ".$user->societe_id;
if ($filter) $sql.= " AND ".$filter;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " ORDER BY nom ASC";
@@ -790,20 +791,20 @@ class Form
}
}
- /**
- * Return list of all contacts (for a third party or all)
- *
- * @param int $socid Id ot third party or 0 for all
- * @param string $selected Id contact pre-selectionne
- * @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 string $exclude List of contacts id to exclude
- * @param string $limitto Disable answers that are not id in this array list
- * @param string $showfunction Add function into label
- * @param string $moreclass Add more class to class style
- * @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='')
+ /**
+ * Return list of all contacts (for a third party or all)
+ *
+ * @param int $socid Id ot third party or 0 for all
+ * @param string $selected Id contact pre-selectionne
+ * @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 string $exclude List of contacts id to exclude
+ * @param string $limitto Disable answers that are not id in this array list
+ * @param string $showfunction Add function into label
+ * @param string $moreclass Add more class to class style
+ * @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='')
{
print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass);
return $this->num;
@@ -978,6 +979,7 @@ class Form
{
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
}
+ if (! empty($user->societe_id)) $sql.= " AND u.fk_societe = ".$user->societe_id;
if (is_array($exclude) && $excludeUsers) $sql.= " AND u.rowid NOT IN ('".$excludeUsers."')";
if (is_array($include) && $includeUsers) $sql.= " AND u.rowid IN ('".$includeUsers."')";
$sql.= " ORDER BY u.name ASC";
@@ -2774,50 +2776,50 @@ class Form
print $this->selectcurrency($selected,$htmlname);
}
- /**
- * Load into the cache all currencies
- *
- * @return int Nb of loaded lines, 0 if already loaded, <0 if KO
- */
- function load_cache_currencies()
- {
+ /**
+ * Load into the cache all currencies
+ *
+ * @return int Nb of loaded lines, 0 if already loaded, <0 if KO
+ */
+ function load_cache_currencies()
+ {
global $langs;
- $langs->load("dict");
-
- if (count($this->cache_currencies)) return 0; // Cache deja charge
-
+ $langs->load("dict");
+
+ if (count($this->cache_currencies)) return 0; // Cache deja charge
+
$sql = "SELECT code_iso, label, unicode";
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
$sql.= " WHERE active = 1";
$sql.= " ORDER BY code_iso ASC";
-
- dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
-
- // 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:''));
+
+ dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ // 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]['unicode'] = (array) json_decode($obj->unicode, true);
$label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
- $i++;
+ $i++;
}
array_multisort($label, SORT_ASC, $this->cache_currencies);
-
- return $num;
- }
- else
- {
- dol_print_error($this->db);
- return -1;
- }
+
+ return $num;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ return -1;
+ }
}
/**
@@ -2882,32 +2884,32 @@ class Form
print $this->load_tva($htmlname, $selectedrate, $societe_vendeuse, $societe_acheteuse, $idprod, $info_bits, $type);
}
- /**
+ /**
* Load into the cache vat rates of a country
*
- * @param string $country_code Country code
- * @return int Nb of loaded lines, 0 if already loaded, <0 if KO
+ * @param string $country_code Country code
+ * @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;
-
+
if (count($this->cache_vatrates)) return 0; // Cache deja charge
- $sql = "SELECT DISTINCT t.taux, t.recuperableonly";
- $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
- $sql.= " WHERE t.fk_pays = p.rowid";
- $sql.= " AND t.active = 1";
- $sql.= " AND p.code IN (".$country_code.")";
- $sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC";
-
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- if ($num)
- {
- for ($i = 0; $i < $num; $i++)
+ $sql = "SELECT DISTINCT t.taux, t.recuperableonly";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
+ $sql.= " WHERE t.fk_pays = p.rowid";
+ $sql.= " AND t.active = 1";
+ $sql.= " AND p.code IN (".$country_code.")";
+ $sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC";
+
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ if ($num)
+ {
+ for ($i = 0; $i < $num; $i++)
{
$obj = $this->db->fetch_object($resql);
$this->cache_vatrates[$i]['txtva'] = $obj->taux;
@@ -2927,7 +2929,7 @@ class Form
{
$this->error = ''.$this->db->error().' ';
return -2;
- }
+ }
}
/**
@@ -3023,32 +3025,32 @@ class Form
if ($num > 0)
{
- // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
- if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
- {
- $defaulttx=get_default_tva($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.
- // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
- if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
- {
- $defaulttx = $this->cache_vatrates[$num-1]['txtva'];
+ // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
+ if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
+ {
+ $defaulttx=get_default_tva($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.
+ // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
+ if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
+ {
+ $defaulttx = $this->cache_vatrates[$num-1]['txtva'];
}
if (! $options_only) $return.= '';
foreach ($this->cache_vatrates as $rate)
{
- $return.= ''.vatrate($rate['libtva']);
+ }
+ $return.= '>'.vatrate($rate['libtva']);
$return.= $rate['nprtva'] ? ' *': '';
$return.= ' ';
@@ -3439,79 +3441,79 @@ class Form
return $out;
}
- /**
- * Show a multiselect form from an array.
- *
+ /**
+ * Show a multiselect form from an array.
+ *
* @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 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 string $option Valeur de l'option en fonction du type choisi
- * @param int $translate Translate and encode value
- * @return string HTML multiselect string
- */
- function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $option='', $translate=0)
- {
+ * @param int $translate Translate and encode value
+ * @return string HTML multiselect string
+ */
+ function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $option='', $translate=0)
+ {
global $conf, $langs;
-
- $out = ''."\n";
- if (is_array($array) && ! empty($array))
+
+ $out = ''."\n";
+ if (is_array($array) && ! empty($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($array as $key => $value)
{
- if ($selected_value == $key)
- {
- $value=$array[$selected_value];
- $out.= '';
- $newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
- $newval = ($key_in_label ? $key.' - '.$newval : $newval);
- $out.= dol_htmlentitiesbr($newval);
- $out.= ' '."\n";
- unset($array[$key]);
+ if ($selected_value == $key)
+ {
+ $value=$array[$selected_value];
+ $out.= '';
+ $newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
+ $newval = ($key_in_label ? $key.' - '.$newval : $newval);
+ $out.= dol_htmlentitiesbr($newval);
+ $out.= ' '."\n";
+ unset($array[$key]);
}
}
}
if (! empty($array))
{
- foreach ($array as $key => $value)
+ foreach ($array as $key => $value)
{
- $out.= '';
- $newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
- $newval = ($key_in_label ? $key.' - '.$newval : $newval);
- $out.= dol_htmlentitiesbr($newval);
- $out.= ' '."\n";
+ $out.= '';
+ $newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
+ $newval = ($key_in_label ? $key.' - '.$newval : $newval);
+ $out.= dol_htmlentitiesbr($newval);
+ $out.= ' '."\n";
}
}
}
else
{
- foreach ($array as $key => $value)
- {
- $out.= '';
-
- $newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
- $newval = ($key_in_label ? $key.' - '.$newval : $newval);
- $out.= dol_htmlentitiesbr($newval);
- $out.= ' '."\n";
+ foreach ($array as $key => $value)
+ {
+ $out.= '';
+
+ $newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
+ $newval = ($key_in_label ? $key.' - '.$newval : $newval);
+ $out.= dol_htmlentitiesbr($newval);
+ $out.= ' '."\n";
}
- }
- }
- $out.= ' '."\n";
-
- return $out;
+ }
+ }
+ $out.= ' '."\n";
+
+ return $out;
}
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 4a4a96adcea..f8c3f0a7ecf 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -805,7 +805,7 @@ class FormFile
// Max file size
$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 template
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index 83b41a8a0c3..c37c9d3926a 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -450,17 +450,17 @@ class FormOther
}
}
- /**
- * Output a HTML code to select a color
- *
- * @param string $set_color Pre-selected color
- * @param string $prefix Name of HTML field
- * @param string $form_name Name of form
- * @param int $showcolorbox 1=Show color code and color box, 0=Show only color code
- * @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813')
- * @return void
- */
- function select_color($set_color='', $prefix='f_color', $form_name='objForm', $showcolorbox=1, $arrayofcolors='')
+ /**
+ * Output a HTML code to select a color
+ *
+ * @param string $set_color Pre-selected color
+ * @param string $prefix Name of HTML field
+ * @param string $form_name Name of form
+ * @param int $showcolorbox 1=Show color code and color box, 0=Show only color code
+ * @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813')
+ * @return void
+ */
+ function select_color($set_color='', $prefix='f_color', $form_name='objForm', $showcolorbox=1, $arrayofcolors='')
{
print $this->selectColor($set_color, $prefix, $form_name, $showcolorbox, $arrayofcolors);
}
diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php
index 4b09433eecc..185178d0525 100644
--- a/htdocs/core/lib/admin.lib.php
+++ b/htdocs/core/lib/admin.lib.php
@@ -725,11 +725,11 @@ function activateModule($value,$withdeps=1)
$num = count($objMod->depends);
for ($i = 0; $i < $num; $i++)
{
- foreach ($modulesdir as $dir)
+ foreach ($modulesdir as $dir)
{
- if (file_exists($dir.$objMod->depends[$i].".class.php"))
- {
- activateModule($objMod->depends[$i]);
+ if (file_exists($dir.$objMod->depends[$i].".class.php"))
+ {
+ activateModule($objMod->depends[$i]);
}
}
}
@@ -741,11 +741,11 @@ function activateModule($value,$withdeps=1)
$num = count($objMod->conflictwith);
for ($i = 0; $i < $num; $i++)
{
- foreach ($modulesdir as $dir)
+ foreach ($modulesdir as $dir)
{
- if (file_exists($dir.$objMod->conflictwith[$i].".class.php"))
- {
- unActivateModule($objMod->conflictwith[$i],0);
+ if (file_exists($dir.$objMod->conflictwith[$i].".class.php"))
+ {
+ unActivateModule($objMod->conflictwith[$i],0);
}
}
}
@@ -1126,16 +1126,16 @@ function form_constantes($tableau)
print '';
}
-/**
- * Add document model used by doc generator
- *
+/**
+ * Add document model used by doc generator
+ *
* @param string $name Model name
- * @param string $type Model type
- * @param string $label Model label
- * @param string $description Model description
- * @return int <0 if KO, >0 if OK
- */
-function addDocumentModel($name, $type, $label='', $description='')
+ * @param string $type Model type
+ * @param string $label Model label
+ * @param string $description Model description
+ * @return int <0 if KO, >0 if OK
+ */
+function addDocumentModel($name, $type, $label='', $description='')
{
global $db, $conf;
@@ -1148,51 +1148,51 @@ function addDocumentModel($name, $type, $label='', $description='')
$sql.= ")";
dol_syslog("admin.lib::addDocumentModel sql=".$sql);
- $resql=$db->query($sql);
- if ($resql)
- {
+ $resql=$db->query($sql);
+ if ($resql)
+ {
$db->commit();
- return 1;
- }
- else
- {
+ return 1;
+ }
+ else
+ {
dol_print_error($db);
- $db->rollback();
- return -1;
- }
+ $db->rollback();
+ return -1;
+ }
}
-/**
- * Delete document model used by doc generator
- *
- * @param string $name Model name
- * @param string $type Model type
- * @return int <0 if KO, >0 if OK
- */
-function delDocumentModel($name, $type)
-{
+/**
+ * Delete document model used by doc generator
+ *
+ * @param string $name Model name
+ * @param string $type Model type
+ * @return int <0 if KO, >0 if OK
+ */
+function delDocumentModel($name, $type)
+{
global $db, $conf;
$db->begin();
-
+
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE nom = '".$db->escape($name)."'";
$sql.= " AND type = '".$type."'";
- $sql.= " AND entity = ".$conf->entity;
-
- dol_syslog("admin.lib::delDocumentModel sql=".$sql);
- $resql=$db->query($sql);
- if ($resql)
- {
+ $sql.= " AND entity = ".$conf->entity;
+
+ dol_syslog("admin.lib::delDocumentModel sql=".$sql);
+ $resql=$db->query($sql);
+ if ($resql)
+ {
$db->commit();
- return 1;
- }
- else
- {
+ return 1;
+ }
+ else
+ {
dol_print_error($db);
- $db->rollback();
- return -1;
- }
+ $db->rollback();
+ return -1;
+ }
}
?>
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 09fc90fe7c5..f8bf5d4530b 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -595,99 +595,99 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
return $i;
}
-/**
- * Show html area for list of addresses
- *
- * @param Conf $conf Object conf
- * @param Translate $langs Object langs
- * @param DoliDB $db Database handler
- * @param Object $object Third party object
- * @param string $backtopage Url to go once address is created
- * @return void
- */
-function show_addresses($conf,$langs,$db,$object,$backtopage='')
-{
- global $user;
+/**
+ * Show html area for list of addresses
+ *
+ * @param Conf $conf Object conf
+ * @param Translate $langs Object langs
+ * @param DoliDB $db Database handler
+ * @param Object $object Third party object
+ * @param string $backtopage Url to go once address is created
+ * @return void
+ */
+function show_addresses($conf,$langs,$db,$object,$backtopage='')
+{
+ global $user;
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);
- $num = $addressstatic->fetch_lines($object->id);
-
- $buttoncreate='';
- if ($user->rights->societe->creer)
- {
- $buttoncreate=''.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').' '."\n";
- }
-
- print "\n";
- print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,'');
-
- print "\n".''."\n";
-
- print ''.$langs->trans("Label").' ';
+ $num = $addressstatic->fetch_lines($object->id);
+
+ $buttoncreate='';
+ if ($user->rights->societe->creer)
+ {
+ $buttoncreate=''.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').' '."\n";
+ }
+
+ print "\n";
+ print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,'');
+
+ print "\n".''."\n";
+
+ print ''.$langs->trans("Label").' ';
print ''.$langs->trans("CompanyName").' ';
print ''.$langs->trans("Town").' ';
print ''.$langs->trans("Country").' ';
- print ''.$langs->trans("Tel").' ';
- print ''.$langs->trans("Fax").' ';
- print " ";
- print " ";
-
- if ($num > 0)
- {
- $var=true;
-
- foreach ($addressstatic->lines as $address)
- {
- $var = !$var;
-
- print "";
-
+ print ''.$langs->trans("Tel").' ';
+ print ''.$langs->trans("Fax").' ';
+ print " ";
+ print " ";
+
+ if ($num > 0)
+ {
+ $var=true;
+
+ foreach ($addressstatic->lines as $address)
+ {
+ $var = !$var;
+
+ print "";
+
print '';
$addressstatic->id = $address->id;
- $addressstatic->label = $address->label;
- print $addressstatic->getNomUrl(1);
- print ' ';
-
+ $addressstatic->label = $address->label;
+ print $addressstatic->getNomUrl(1);
+ print '';
+
print ''.$address->name.' ';
print ''.$address->town.' ';
$img=picto_from_langcode($address->country_code);
- print ''.($img?$img.' ':'').$address->country.' ';
-
- // Lien click to dial
- print '';
- print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL');
- print ' ';
- print '';
- print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX');
- print ' ';
-
- if ($user->rights->societe->creer)
- {
- print '';
- print '';
- print img_edit();
- print ' ';
- }
-
- print " \n";
- }
- }
- else
- {
- //print "";
- //print ''.$langs->trans("NoAddressYetDefined").' ';
- //print " \n";
- }
- print "\n
\n";
-
- print " \n";
-
- return $num;
+ print ''.($img?$img.' ':'').$address->country.' ';
+
+ // Lien click to dial
+ print '';
+ print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL');
+ print ' ';
+ print '';
+ print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX');
+ print ' ';
+
+ if ($user->rights->societe->creer)
+ {
+ print '';
+ print '';
+ print img_edit();
+ print ' ';
+ }
+
+ print " \n";
+ }
+ }
+ else
+ {
+ //print "";
+ //print ''.$langs->trans("NoAddressYetDefined").' ';
+ //print " \n";
+ }
+ print "\n
\n";
+
+ print " \n";
+
+ return $num;
}
/**
diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php
index 586abb9e719..90a15cf958e 100644
--- a/htdocs/core/lib/contract.lib.php
+++ b/htdocs/core/lib/contract.lib.php
@@ -39,11 +39,11 @@ function contract_prepare_head($object)
$head[$h][2] = 'card';
$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][1] = $langs->trans("ContactsAddresses");
- $head[$h][2] = 'contact';
+ $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id;
+ $head[$h][1] = $langs->trans("ContactsAddresses");
+ $head[$h][2] = 'contact';
$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
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][1] = $langs->trans("Note");
- $head[$h][2] = 'note';
+ $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id;
+ $head[$h][1] = $langs->trans("Note");
+ $head[$h][2] = 'note';
$h++;
}
diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php
index e31b708f09b..08732c271af 100644
--- a/htdocs/core/lib/fichinter.lib.php
+++ b/htdocs/core/lib/fichinter.lib.php
@@ -43,11 +43,11 @@ function fichinter_prepare_head($object)
$head[$h][2] = 'card';
$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][1] = $langs->trans('InterventionContact');
- $head[$h][2] = 'contact';
+ $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
+ $head[$h][1] = $langs->trans('InterventionContact');
+ $head[$h][2] = 'contact';
$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
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][1] = $langs->trans('Notes');
- $head[$h][2] = 'note';
+ $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
+ $head[$h][1] = $langs->trans('Notes');
+ $head[$h][2] = 'note';
$h++;
}
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index 97bf52a96d1..904d5dfef54 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -614,15 +614,15 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
{
if (is_object($object))
{
- $object->src_file=$dest_file;
-
- // Appel des triggers
- include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
- $interface=new Interfaces($db);
- $result=$interface->run_triggers('FILE_UPLOAD',$object,$user,$langs,$conf);
- if ($result < 0) {
- $error++; $errors=$interface->errors;
- }
+ $object->src_file=$dest_file;
+
+ // Appel des triggers
+ include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+ $interface=new Interfaces($db);
+ $result=$interface->run_triggers('FILE_UPLOAD',$object,$user,$langs,$conf);
+ if ($result < 0) {
+ $error++; $errors=$interface->errors;
+ }
// Fin appel triggers
}
else
diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php
index 1cd38ce0c9b..96adf043259 100644
--- a/htdocs/core/lib/fourn.lib.php
+++ b/htdocs/core/lib/fourn.lib.php
@@ -41,11 +41,11 @@ function facturefourn_prepare_head($object)
$head[$h][2] = 'card';
$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][1] = $langs->trans('ContactsAddresses');
- $head[$h][2] = 'contact';
+ $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id;
+ $head[$h][1] = $langs->trans('ContactsAddresses');
+ $head[$h][2] = 'contact';
$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
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][1] = $langs->trans('Notes');
- $head[$h][2] = 'note';
+ $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
+ $head[$h][1] = $langs->trans('Notes');
+ $head[$h][2] = 'note';
$h++;
}
@@ -107,11 +107,11 @@ function ordersupplier_prepare_head($object)
$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][1] = $langs->trans('ContactsAddresses');
- $head[$h][2] = 'contact';
+ $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
+ $head[$h][1] = $langs->trans('ContactsAddresses');
+ $head[$h][2] = 'contact';
$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
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][1] = $langs->trans("Notes");
- $head[$h][2] = 'note';
+ $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
+ $head[$h][1] = $langs->trans("Notes");
+ $head[$h][2] = 'note';
$h++;
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index ad276af09fb..a0759939cfe 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -4008,36 +4008,36 @@ function colorArrayToHex($arraycolor,$colorifnotfound='888888')
if (! is_array($arraycolor)) return $colorifnotfound;
return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]);
}
-
-/**
- * Convert a currency code into its symbol
- *
- * @param string $currency_code Currency code
- * @return string Currency symbol encoded into UTF8
- */
-function getCurrencySymbol($currency_code)
-{
- global $db, $form;
-
- $currency_sign = '';
-
- if (! is_object($form)) $form = new Form($db);
-
- $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']))
- {
- foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
- {
+
+/**
+ * Convert a currency code into its symbol
+ *
+ * @param string $currency_code Currency code
+ * @return string Currency symbol encoded into UTF8
+ */
+function getCurrencySymbol($currency_code)
+{
+ global $db, $form;
+
+ $currency_sign = '';
+
+ if (! is_object($form)) $form = new Form($db);
+
+ $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']))
+ {
+ foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
+ {
$currency_sign .= mb_convert_encoding("{$unicode};", "UTF-8", 'HTML-ENTITIES');
- }
- }
- else
- {
- $currency_sign = $currency_code;
- }
-
- return $currency_sign;
+ }
+ }
+ else
+ {
+ $currency_sign = $currency_code;
+ }
+
+ return $currency_sign;
}
if (! function_exists('getmypid'))
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index 5a1866dbc99..cd52f577f5c 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -146,7 +146,7 @@ function dol_print_object_info($object)
$deltadateforclient=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
//$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
$deltadateforuser=round($deltadateforclient-$deltadateforserver);
- //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser;
+ //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser;
// Import key
if (isset($object->import_key))
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index b6dd10249e3..50753fc2818 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -40,11 +40,11 @@ function facture_prepare_head($object)
$head[$h][2] = 'compta';
$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][1] = $langs->trans('ContactsAddresses');
- $head[$h][2] = 'contact';
+ $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id;
+ $head[$h][1] = $langs->trans('ContactsAddresses');
+ $head[$h][2] = 'contact';
$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
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][1] = $langs->trans('Notes');
- $head[$h][2] = 'note';
+ $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id;
+ $head[$h][1] = $langs->trans('Notes');
+ $head[$h][2] = 'note';
$h++;
}
diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php
index 2a85bc12063..7f08403ccaa 100644
--- a/htdocs/core/lib/json.lib.php
+++ b/htdocs/core/lib/json.lib.php
@@ -25,60 +25,60 @@
if (! function_exists('json_encode'))
{
- /**
- * Implement json_encode for PHP that does not support it
- *
- * @param mixed $elements PHP Object to json encode
- * @return string Json encoded string
- */
- function json_encode($elements)
+ /**
+ * Implement json_encode for PHP that does not support it
+ *
+ * @param mixed $elements PHP Object to json encode
+ * @return string Json encoded string
+ */
+ function json_encode($elements)
{
return dol_json_encode($elements);
}
}
-/**
- * Implement json_encode for PHP that does not support it
- *
- * @param mixed $elements PHP Object to json encode
- * @return string Json encoded string
- */
-function dol_json_encode($elements)
-{
- $num = count($elements);
-
- // determine type
- if (is_numeric(key($elements)))
- {
- // indexed (list)
- $output = '[';
- for ($i = 0, $last = ($num - 1); isset($elements[$i]); ++$i)
- {
- if (is_array($elements[$i])) $output.= json_encode($elements[$i]);
- else $output .= _val($elements[$i]);
- if($i !== $last) $output.= ',';
- }
- $output.= ']';
- }
- else
- {
- // associative (object)
- $output = '{';
- $last = $num - 1;
- $i = 0;
- foreach($elements as $key => $value)
- {
- $output .= '"'.$key.'":';
- if (is_array($value)) $output.= json_encode($value);
- else $output .= _val($value);
- if ($i !== $last) $output.= ',';
- ++$i;
- }
- $output.= '}';
- }
-
- // return
- return $output;
+/**
+ * Implement json_encode for PHP that does not support it
+ *
+ * @param mixed $elements PHP Object to json encode
+ * @return string Json encoded string
+ */
+function dol_json_encode($elements)
+{
+ $num = count($elements);
+
+ // determine type
+ if (is_numeric(key($elements)))
+ {
+ // indexed (list)
+ $output = '[';
+ for ($i = 0, $last = ($num - 1); isset($elements[$i]); ++$i)
+ {
+ if (is_array($elements[$i])) $output.= json_encode($elements[$i]);
+ else $output .= _val($elements[$i]);
+ if($i !== $last) $output.= ',';
+ }
+ $output.= ']';
+ }
+ else
+ {
+ // associative (object)
+ $output = '{';
+ $last = $num - 1;
+ $i = 0;
+ foreach($elements as $key => $value)
+ {
+ $output .= '"'.$key.'":';
+ if (is_array($value)) $output.= json_encode($value);
+ else $output .= _val($value);
+ if ($i !== $last) $output.= ',';
+ ++$i;
+ }
+ $output.= '}';
+ }
+
+ // return
+ return $output;
}
/**
@@ -189,69 +189,69 @@ function _val($val)
if (! function_exists('json_decode'))
{
- /**
- * Implement json_decode for PHP that does not support it
- *
- * @param string $json Json encoded to PHP Object or Array
- * @param bool $assoc False return an object, true return an array
- * @return mixed Object or Array
- */
- function json_decode($json, $assoc=false)
+ /**
+ * Implement json_decode for PHP that does not support it
+ *
+ * @param string $json Json encoded to PHP Object or Array
+ * @param bool $assoc False return an object, true return an array
+ * @return mixed Object or Array
+ */
+ function json_decode($json, $assoc=false)
{
return dol_json_decode($json, $assoc);
}
}
-/**
- * Implement json_decode for PHP that does not support it
- *
- * @param string $json Json encoded to PHP Object or Array
- * @param bool $assoc False return an object, true return an array
- * @return mixed Object or Array
- */
-function dol_json_decode($json, $assoc=false)
-{
- $comment = false;
-
- $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length
- for ($i=0; $i<$strLength; $i++)
- {
- if (! $comment)
- {
- if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array(';
- else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')';
- else if ($json[$i] == ':') $out.= ' => ';
- else $out.=$json[$i];
- }
- else $out.= $json[$i];
- if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment;
- }
-
- $out=_unval($out);
-
- // Return an array
+/**
+ * Implement json_decode for PHP that does not support it
+ *
+ * @param string $json Json encoded to PHP Object or Array
+ * @param bool $assoc False return an object, true return an array
+ * @return mixed Object or Array
+ */
+function dol_json_decode($json, $assoc=false)
+{
+ $comment = false;
+
+ $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length
+ for ($i=0; $i<$strLength; $i++)
+ {
+ if (! $comment)
+ {
+ if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array(';
+ else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')';
+ else if ($json[$i] == ':') $out.= ' => ';
+ else $out.=$json[$i];
+ }
+ else $out.= $json[$i];
+ if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment;
+ }
+
+ $out=_unval($out);
+
+ // Return an array
if ($out != '') eval('$array = '.$out.';');
- else $array=array();
-
- // Return an object
- if (! $assoc)
- {
- if (! empty($array))
- {
- $object = false;
-
- foreach ($array as $key => $value)
- {
- $object->{$key} = $value;
- }
-
- return $object;
- }
-
- return false;
- }
-
- return $array;
+ else $array=array();
+
+ // Return an object
+ if (! $assoc)
+ {
+ if (! empty($array))
+ {
+ $object = false;
+
+ foreach ($array as $key => $value)
+ {
+ $object->{$key} = $value;
+ }
+
+ return $object;
+ }
+
+ return false;
+ }
+
+ return $array;
}
/**
diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php
index 8cc3d939a00..0ba1d9451dc 100644
--- a/htdocs/core/lib/order.lib.php
+++ b/htdocs/core/lib/order.lib.php
@@ -68,11 +68,11 @@ function commande_prepare_head($object)
$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][1] = $langs->trans('ContactsAddresses');
- $head[$h][2] = 'contact';
+ $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
+ $head[$h][1] = $langs->trans('ContactsAddresses');
+ $head[$h][2] = 'contact';
$h++;
}
@@ -91,11 +91,11 @@ function commande_prepare_head($object)
$head[$h][2] = 'documents';
$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][1] = $langs->trans('Notes');
- $head[$h][2] = 'note';
+ $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
+ $head[$h][1] = $langs->trans('Notes');
+ $head[$h][2] = 'note';
$h++;
}
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index cf0b8243ba3..e1f4b5a9fd1 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -714,7 +714,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
}
}
-/**
+/**
* Show linked objects for PDF generation
*
* @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 HookManager $hookmanager Hook manager object
* @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);
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"]))
{
- $posy+=3;
- $pdf->SetXY($posx,$posy);
+ $posy+=3;
+ $pdf->SetXY($posx,$posy);
$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)
{
- global $db, $form;
-
- $currency_sign = '';
-
- if (! is_object($form)) $form = new Form($db);
-
- $form->load_cache_currencies();
-
- 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)
- {
- $currency_sign.= $pdf->unichr($unicode);
- }
- }
- else
- {
- $currency_sign = $currency_code;
- }
-
+ global $db, $form;
+
+ $currency_sign = '';
+
+ if (! is_object($form)) $form = new Form($db);
+
+ $form->load_cache_currencies();
+
+ 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)
+ {
+ $currency_sign.= $pdf->unichr($unicode);
+ }
+ }
+ else
+ {
+ $currency_sign = $currency_code;
+ }
+
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);
}
}
- else if ($objecttype == 'contrat')
- {
- $outputlangs->load('contracts');
- $num=count($objects);
- for ($i=0;$i<$num;$i++)
+ else if ($objecttype == 'contrat')
+ {
+ $outputlangs->load('contracts');
+ $num=count($objects);
+ for ($i=0;$i<$num;$i++)
{
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract");
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref);
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract");
$linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date_contrat,'day','',$outputlangs);
- }
+ }
}
}
// For add external linked objects
if (is_object($hookmanager))
{
- $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs);
- $action='';
+ $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs);
+ $action='';
$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;
}
diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php
index de7470c07f0..23439d25806 100644
--- a/htdocs/core/lib/propal.lib.php
+++ b/htdocs/core/lib/propal.lib.php
@@ -65,9 +65,9 @@ function propal_prepare_head($object)
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
- $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id;
- $head[$h][1] = $langs->trans('ContactsAddresses');
- $head[$h][2] = 'contact';
+ $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id;
+ $head[$h][1] = $langs->trans('ContactsAddresses');
+ $head[$h][2] = 'contact';
$h++;
}
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index a5051caf0c2..79d1b0426ec 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -379,9 +379,9 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature
}
else
{
- $sql = "SELECT dbt.".$dbt_select;
- $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
- $sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
+ $sql = "SELECT dbt.".$dbt_select;
+ $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
+ $sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
}
}
diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php
index 74ac5d496e8..4762ac5f0c7 100644
--- a/htdocs/core/lib/security2.lib.php
+++ b/htdocs/core/lib/security2.lib.php
@@ -164,12 +164,12 @@ function dol_loginfunction($langs,$conf,$mysoc)
global $dolibarr_main_demo,$db;
global $smartphone,$hookmanager;
- // Instantiate hooks of thirdparty module only if not already define
- if (! is_object($hookmanager))
- {
- include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
- $hookmanager=new HookManager($db);
- }
+ // Instantiate hooks of thirdparty module only if not already define
+ if (! is_object($hookmanager))
+ {
+ include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
+ $hookmanager=new HookManager($db);
+ }
$hookmanager->initHooks(array('mainloginpage'));
$langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang'));
@@ -239,8 +239,8 @@ function dol_loginfunction($langs,$conf,$mysoc)
}
// Execute hook getLoginPageOptions
- // Should be an array with differents options in $hookmanager->resArray
- $parameters=array('entity' => $_POST['entity']);
+ // Should be an array with differents options in $hookmanager->resArray
+ $parameters=array('entity' => $_POST['entity']);
$hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks
// Login
diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php
index 4003db49467..8db20829196 100644
--- a/htdocs/core/lib/sendings.lib.php
+++ b/htdocs/core/lib/sendings.lib.php
@@ -47,13 +47,13 @@ function shipping_prepare_head($object)
if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)
{
- // delivery link
+ // delivery link
$object->fetchObjectLinked($object->id,$object->element);
if (! empty($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][2] = 'delivery';
+ $head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linkedObjectsIds['delivery'][0];
+ $head[$h][1] = $langs->trans("DeliveryCard");
+ $head[$h][2] = 'delivery';
$h++;
}
}
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index 3ac5bf24abc..e7661306fdd 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -1370,7 +1370,7 @@ abstract class DolibarrModules
{
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'];
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";
diff --git a/htdocs/core/modules/commande/doc/pdf_edison.modules.php b/htdocs/core/modules/commande/doc/pdf_edison.modules.php
index fcf5d698c85..4056826b423 100644
--- a/htdocs/core/modules/commande/doc/pdf_edison.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_edison.modules.php
@@ -300,7 +300,7 @@ class pdf_edison extends ModelePDFCommandes
// Actions on extra fields (by external module or standard code)
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->initHooks(array('pdfgeneration'));
@@ -651,7 +651,7 @@ class pdf_edison extends ModelePDFCommandes
$posy+=1;
-
+
// Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'L', $default_font_size, $hookmanager);
}
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index 4c4697a8bbf..cebcf34f615 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -929,8 +929,8 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetTextColor(0,0,60);
$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
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index 6ad16f9b993..f2ce637eec3 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -982,9 +982,9 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
}
- $posy+=2;
-
- // Show list of linked objects
+ $posy+=2;
+
+ // Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);
if ($showaddress)
diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php
index 269b64faf60..a627ccdc3fb 100644
--- a/htdocs/core/modules/societe/modules_societe.class.php
+++ b/htdocs/core/modules/societe/modules_societe.class.php
@@ -417,13 +417,13 @@ function thirdparty_doc_create($db, &$object, $message, $modele, $outputlangs)
{
$outputlangs->charset_output=$sav_charset_output;
- // Appel des triggers
- include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
- $interface=new Interfaces($db);
- $result=$interface->run_triggers('COMPANY_BUILDDOC',$object,$user,$langs,$conf);
- if ($result < 0) {
- $error++; $this->errors=$interface->errors;
- }
+ // Appel des triggers
+ include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+ $interface=new Interfaces($db);
+ $result=$interface->run_triggers('COMPANY_BUILDDOC',$object,$user,$langs,$conf);
+ if ($result < 0) {
+ $error++; $this->errors=$interface->errors;
+ }
// Fin appel triggers
return 1;
diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php
index 5724411047c..9da5a265c6f 100644
--- a/htdocs/core/photos_resize.php
+++ b/htdocs/core/photos_resize.php
@@ -42,7 +42,7 @@ require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
$langs->load("products");
$langs->load("other");
-$id=GETPOST('id','int');
+$id=GETPOST('id','int');
$action=GETPOST('action','alpha');
$modulepart=GETPOST('modulepart','alpha')?GETPOST('modulepart','alpha'):'produit|service';
$original_file = isset($_REQUEST["file"])?urldecode($_REQUEST["file"]):'';
@@ -65,12 +65,12 @@ if (! $accessallowed)
}
$object = new Product($db);
-if ($id > 0)
-{
+if ($id > 0)
+{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db,'Failed to load object');
- $dir=$conf->product->multidir_output[$object->entity]; // By default
- if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity];
+ $dir=$conf->product->multidir_output[$object->entity]; // By default
+ if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity];
if ($object->type == 1) $dir=$conf->service->multidir_output[$object->entity];
}
diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php
index 35f173fc572..53b19977b7d 100644
--- a/htdocs/core/tpl/contacts.tpl.php
+++ b/htdocs/core/tpl/contacts.tpl.php
@@ -16,17 +16,17 @@
*
*/
-$module = $object->element;
-$permission=(isset($permission)?$permission:$user->rights->$module->creer); // If already defined by caller page
-
-// Special cases
-if ($module == 'propal') { $permission=$user->rights->propale->creer; }
-elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; }
-elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
+$module = $object->element;
+$permission=(isset($permission)?$permission:$user->rights->$module->creer); // If already defined by caller page
+
+// Special cases
+if ($module == 'propal') { $permission=$user->rights->propale->creer; }
+elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; }
+elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; }
$companystatic=new Societe($db);
-$contactstatic=new Contact($db);
+$contactstatic=new Contact($db);
$userstatic=new User($db);
?>
@@ -73,8 +73,8 @@ $userstatic=new User($db);
use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) { ?>
'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
+ $events=array();
+ $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);
?>
@@ -113,12 +113,12 @@ $userstatic=new User($db);
liste_contact(-1,$source);
- $num=count($tab);
-
- $i = 0;
- while ($i < $num) {
+ foreach(array('internal','external') as $source) {
+ $tab = $object->liste_contact(-1,$source);
+ $num=count($tab);
+
+ $i = 0;
+ while ($i < $num) {
$var = !$var;
?>
@@ -129,36 +129,36 @@ $userstatic=new User($db);
0)
- {
- $companystatic->fetch($tab[$i]['socid']);
- echo $companystatic->getNomUrl(1);
- }
- if ($tab[$i]['socid'] < 0)
- {
- echo $conf->global->MAIN_INFO_SOCIETE_NOM;
- }
- if (! $tab[$i]['socid'])
- {
- echo ' ';
+ if ($tab[$i]['socid'] > 0)
+ {
+ $companystatic->fetch($tab[$i]['socid']);
+ echo $companystatic->getNomUrl(1);
+ }
+ if ($tab[$i]['socid'] < 0)
+ {
+ echo $conf->global->MAIN_INFO_SOCIETE_NOM;
+ }
+ if (! $tab[$i]['socid'])
+ {
+ echo ' ';
}
?>
id=$tab[$i]['id'];
- $userstatic->lastname=$tab[$i]['lastname'];
- $userstatic->firstname=$tab[$i]['firstname'];
- echo $userstatic->getNomUrl(1);
- }
- if ($tab[$i]['source']=='external')
- {
- $contactstatic->id=$tab[$i]['id'];
- $contactstatic->lastname=$tab[$i]['lastname'];
- $contactstatic->firstname=$tab[$i]['firstname'];
- echo $contactstatic->getNomUrl(1);
+ if ($tab[$i]['source']=='internal')
+ {
+ $userstatic->id=$tab[$i]['id'];
+ $userstatic->lastname=$tab[$i]['lastname'];
+ $userstatic->firstname=$tab[$i]['firstname'];
+ echo $userstatic->getNomUrl(1);
+ }
+ if ($tab[$i]['source']=='external')
+ {
+ $contactstatic->id=$tab[$i]['id'];
+ $contactstatic->lastname=$tab[$i]['lastname'];
+ $contactstatic->firstname=$tab[$i]['firstname'];
+ echo $contactstatic->getNomUrl(1);
}
?>
diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php
index b0f72b159df..49950cc315a 100644
--- a/htdocs/core/tpl/login.tpl.php
+++ b/htdocs/core/tpl/login.tpl.php
@@ -35,7 +35,7 @@ print ''."\n";
if (constant('JS_JQUERY_UI')) print ' '."\n"; // JQuery
else print ' '."\n"; // JQuery
// 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';
print ''."\n";
if (constant('JS_JQUERY')) print ''."\n";
diff --git a/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php b/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php
index dc577289df6..ab78856e65f 100755
--- a/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php
+++ b/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php
@@ -111,37 +111,37 @@ class InterfacePaypalWorkflow
}
else
{
- require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
-
- $soc = new Societe($this->db);
-
- // Parse element/subelement (ex: project_task)
- $element = $path = $filename = $object->source;
- if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs))
- {
- $element = $path = $regs[1];
- $filename = $regs[2];
- }
- // For compatibility
- if ($element == 'order') {
- $path = $filename = 'commande';
- }
- if ($element == 'invoice') {
- $path = 'compta/facture'; $filename = 'facture';
- }
-
- dol_include_once('/'.$path.'/class/'.$filename.'.class.php');
-
- $classname = ucfirst($filename);
- $obj = new $classname($this->db);
-
- $ret = $obj->fetch('',$object->ref);
- if ($ret < 0) return -1;
-
- // Add payer id
- $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
-
- // Add transaction id
+ require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
+
+ $soc = new Societe($this->db);
+
+ // Parse element/subelement (ex: project_task)
+ $element = $path = $filename = $object->source;
+ if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs))
+ {
+ $element = $path = $regs[1];
+ $filename = $regs[2];
+ }
+ // For compatibility
+ if ($element == 'order') {
+ $path = $filename = 'commande';
+ }
+ if ($element == 'invoice') {
+ $path = 'compta/facture'; $filename = 'facture';
+ }
+
+ dol_include_once('/'.$path.'/class/'.$filename.'.class.php');
+
+ $classname = ucfirst($filename);
+ $obj = new $classname($this->db);
+
+ $ret = $obj->fetch('',$object->ref);
+ if ($ret < 0) return -1;
+
+ // Add payer id
+ $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
+
+ // Add transaction id
$obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]);
}