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

This commit is contained in:
jfefe 2013-02-20 11:15:15 +01:00
commit 1941efa45a
247 changed files with 5197 additions and 7194 deletions

View File

@ -4,12 +4,19 @@ English Dolibarr ChangeLog
***** ChangeLog for 3.4 compared to 3.3 *****
For users:
- New: Some performance enhancements
- New: Some performance enhancements.
- New: Can attach files onto trip and expenses modules.
- New: Add option MAIN_PDF_TITLE_BACKGROUND_COLOR
- New: Can define a hierarchical responsible on user
- New: Merge tab customer and prospect
For developers:
- System of menu managers has been rewritten to reduce code to do same things.
- An external module can force its theme.
- Add function dol_set_focus('#xxx').
For translators:
- Update language files.
***** ChangeLog for 3.3 compared to 3.2.3 *****

View File

@ -33,11 +33,11 @@ complete release of Dolibarr, step by step.
- Check all files are commited.
- Update version/info in /ChangeLog and /filefunc.inc.php
- Update version number with x.x.x-y in htdocs/filefunc.inc.php
- Update version number with x.x.x-y in build/makepack-dolibarr.pl
- Update version number with x.x.x-y in build/debian/changelog
- Update version number with x.x.x-y in build/exe/doliwamp/doliwamp.iss
- Update version number with x.x.x-y in build/rpm/*.spec
- Update version number with x.x.x in htdocs/filefunc.inc.php
- Update version number with x.x.x in build/makepack-dolibarr.pl
- Update version number with x.x.x in build/debian/changelog
- Update version number with x.x.x in build/exe/doliwamp/doliwamp.iss
- Update version number with x.x.x in build/rpm/*.spec
- Update PAD files.
- Commit all changes.
- Add a Tag (DOLIBARR_x_y)

View File

@ -35,9 +35,9 @@
<Program_Info>
<Program_Name>Dolibarr</Program_Name>
<Program_Version>3.3.0</Program_Version>
<Program_Release_Month>08</Program_Release_Month>
<Program_Release_Day>10</Program_Release_Day>
<Program_Release_Year>2012</Program_Release_Year>
<Program_Release_Month>02</Program_Release_Month>
<Program_Release_Day>17</Program_Release_Day>
<Program_Release_Year>2013</Program_Release_Year>
<Program_Cost_Dollars />
<Program_Cost_Other_Code />
<Program_Cost_Other />

View File

@ -35,9 +35,9 @@
<Program_Info>
<Program_Name>DoliWamp</Program_Name>
<Program_Version>3.3.0</Program_Version>
<Program_Release_Month>08</Program_Release_Month>
<Program_Release_Day>10</Program_Release_Day>
<Program_Release_Year>2012</Program_Release_Year>
<Program_Release_Month>02</Program_Release_Month>
<Program_Release_Day>17</Program_Release_Day>
<Program_Release_Year>2013</Program_Release_Year>
<Program_Cost_Dollars />
<Program_Cost_Other_Code />
<Program_Cost_Other />

View File

@ -333,5 +333,5 @@ fi
%changelog
* Mon Jan 14 2013 Laurent Destailleur 3.4.0-0.1.a
* Sun Feb 17 2013 Laurent Destailleur 3.4.0-0.1.a
- Initial version (#723326)

View File

@ -522,5 +522,5 @@ fi
%changelog
* Mon Jan 14 2013 Laurent Destailleur 3.4.0-0.1.a
* Sun Feb 17 2013 Laurent Destailleur 3.4.0-0.1.a
- Initial version (#723326)

View File

@ -322,5 +322,5 @@ fi
%changelog
* Mon Jan 14 2013 Laurent Destailleur 3.4.0-0.1.a
* Sun Feb 17 2013 Laurent Destailleur 3.4.0-0.1.a
- Initial version (#723326)

View File

@ -333,5 +333,5 @@ fi
%changelog
* Mon Jan 14 2013 Laurent Destailleur 3.4.0-0.1.a
* Sun Feb 17 2013 Laurent Destailleur 3.4.0-0.1.a
- Initial version (#723326)

View File

@ -106,7 +106,7 @@ class modMyModule extends DolibarrModules
// Constants
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0)
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
// );
$this->const = array();

View File

@ -189,7 +189,7 @@ if (! empty($conf->banque->enabled))
else
{
print '<td align="right" colspan="2">';
print $langs->trans("WarningModuleNotActive",$langs->transnoentities("Module85Name")).' '.img_warning("","");
print $langs->trans("WarningModuleNotActive",$langs->transnoentities("Module85Name"));
print '</td>';
}
print "</tr>\n";

View File

@ -51,7 +51,7 @@ class Adherent extends CommonObject
var $login;
var $pass;
var $societe;
var $adresse;
//var $adresse;
var $address;
var $cp;
var $zip;
@ -394,7 +394,7 @@ class Adherent extends CommonObject
*/
function update($user,$notrigger=0,$nosyncuser=0,$nosyncuserpass=0,$nosyncthirdparty=0,$action='update')
{
global $conf, $langs;
global $conf, $langs, $hookmanager;
$nbrowsaffected=0;
$error=0;
@ -429,7 +429,7 @@ class Adherent extends CommonObject
$sql.= ", login=" .($this->login?"'".$this->db->escape($this->login)."'":"null");
$sql.= ", societe=" .($this->societe?"'".$this->db->escape($this->societe)."'":"null");
$sql.= ", fk_soc=" .($this->fk_soc > 0?"'".$this->fk_soc."'":"null");
$sql.= ", adresse=" .($this->address?"'".$this->db->escape($this->address)."'":"null");
$sql.= ", address=" .($this->address?"'".$this->db->escape($this->address)."'":"null");
$sql.= ", cp=" .($this->zip?"'".$this->db->escape($this->zip)."'":"null");
$sql.= ", ville=" .($this->town?"'".$this->db->escape($this->town)."'":"null");
$sql.= ", pays=" .($this->country_id>0?"'".$this->country_id."'":"null");
@ -462,8 +462,6 @@ class Adherent extends CommonObject
$nbrowsaffected+=$this->db->affected_rows($resql);
// Actions on extra fields (by external module)
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager->initHooks(array('memberdao'));
$parameters=array('id'=>$this->id);
$action='';
@ -538,8 +536,6 @@ class Adherent extends CommonObject
$luser->office_phone=$this->phone;
$luser->user_mobile=$this->phone_mobile;
$luser->note=$this->note;
$luser->fk_member=$this->id;
$result=$luser->update($user,0,1,1); // Use nosync to 1 to avoid cyclic updates
@ -1023,7 +1019,7 @@ class Adherent extends CommonObject
{
global $langs;
$sql = "SELECT d.rowid, d.civilite, d.prenom as firstname, d.nom as lastname, d.societe, d.fk_soc, d.statut, d.public, d.adresse as address, d.cp as zip, d.ville as town, d.note,";
$sql = "SELECT d.rowid, d.civilite, d.prenom as firstname, d.nom as lastname, d.societe, d.fk_soc, d.statut, d.public, d.address, d.cp as zip, d.ville as town, d.note,";
$sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,";
$sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,";
$sql.= " d.datec as datec,";
@ -1069,7 +1065,7 @@ class Adherent extends CommonObject
$this->pass = $obj->pass;
$this->societe = $obj->societe;
$this->fk_soc = $obj->fk_soc;
$this->adresse = $obj->address; // deprecated
//$this->adresse = $obj->address; // deprecated
$this->address = $obj->address;
$this->cp = $obj->zip; // deprecated
$this->zip = $obj->zip;
@ -1828,7 +1824,7 @@ class Adherent extends CommonObject
if ($this->login && ! empty($conf->global->LDAP_MEMBER_FIELD_LOGIN)) $info[$conf->global->LDAP_MEMBER_FIELD_LOGIN] = $this->login;
if ($this->pass && ! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte
if ($this->poste && ! empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste;
if ($this->adresse && ! empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->adresse;
if ($this->address && ! empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address;
if ($this->cp && ! empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->cp;
if ($this->ville && ! empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->ville;
if ($this->country_code && ! empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code;

View File

@ -98,6 +98,8 @@ class AdherentType extends CommonObject
*/
function update($user)
{
global $hookmanager;
$this->libelle=trim($this->libelle);
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
@ -114,8 +116,6 @@ class AdherentType extends CommonObject
if ($result)
{
// Actions on extra fields (by external module or standard code)
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager->initHooks(array('membertypedao'));
$parameters=array('membertype'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks

View File

@ -107,8 +107,6 @@ if ($rowid)
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('membercard'));
@ -261,7 +259,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
$object->pass = trim($_POST["pass"]);
$object->societe = trim($_POST["societe"]);
$object->adresse = trim($_POST["address"]); // deprecated
//$object->adresse = trim($_POST["address"]); // deprecated
$object->address = trim($_POST["address"]);
$object->cp = trim($_POST["zipcode"]); // deprecated
$object->zip = trim($_POST["zipcode"]);
@ -442,7 +440,7 @@ if ($action == 'add' && $user->rights->adherent->creer)
$object->firstname = $prenom;
$object->lastname = $nom;
$object->societe = $societe;
$object->adresse = $address; // deprecated
//$object->adresse = $address; // deprecated
$object->address = $address;
$object->cp = $zip; // deprecated
$object->zip = $zip;

View File

@ -104,7 +104,7 @@ if ($sall)
$sql.=" AND (";
if (is_numeric($sall)) $sql.= "d.rowid = ".$sall." OR ";
$sql.=" d.prenom LIKE '%".$sall."%' OR d.nom LIKE '%".$sall."%' OR d.societe LIKE '%".$sall."%'";
$sql.=" OR d.email LIKE '%".$sall."%' OR d.login LIKE '%".$sall."%' OR d.adresse LIKE '%".$sall."%'";
$sql.=" OR d.email LIKE '%".$sall."%' OR d.login LIKE '%".$sall."%' OR d.address LIKE '%".$sall."%'";
$sql.=" OR d.ville LIKE '%".$sall."%' OR d.note LIKE '%".$sall."%')";
}
if ($type > 0)

View File

@ -67,8 +67,6 @@ if (GETPOST('button_removefilter'))
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('membertypecard'));
/*
@ -418,7 +416,7 @@ if ($rowid > 0)
if ($sall)
{
$sql.= " AND (d.prenom LIKE '%".$sall."%' OR d.nom LIKE '%".$sall."%' OR d.societe LIKE '%".$sall."%'";
$sql.= " OR d.email LIKE '%".$sall."%' OR d.login LIKE '%".$sall."%' OR d.adresse LIKE '%".$sall."%'";
$sql.= " OR d.email LIKE '%".$sall."%' OR d.login LIKE '%".$sall."%' OR d.address LIKE '%".$sall."%'";
$sql.= " OR d.ville LIKE '%".$sall."%' OR d.note LIKE '%".$sall."%')";
}
if ($status != '')

View File

@ -646,13 +646,13 @@ else
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyAddress").'</td><td>' . nl2br($conf->global->MAIN_INFO_SOCIETE_ADRESSE) . '</td></tr>';
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyAddress").'</td><td>' . nl2br(empty($conf->global->MAIN_INFO_SOCIETE_ADRESSE)?'':$conf->global->MAIN_INFO_SOCIETE_ADRESSE) . '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyZip").'</td><td>' . $conf->global->MAIN_INFO_SOCIETE_CP . '</td></tr>';
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyZip").'</td><td>' . (empty($conf->global->MAIN_INFO_SOCIETE_CP)?'':$conf->global->MAIN_INFO_SOCIETE_CP) . '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyTown").'</td><td>' . $conf->global->MAIN_INFO_SOCIETE_VILLE . '</td></tr>';
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyTown").'</td><td>' . (empty($conf->global->MAIN_INFO_SOCIETE_VILLE)?'':$conf->global->MAIN_INFO_SOCIETE_VILLE) . '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyCountry").'</td><td>';

View File

@ -35,7 +35,7 @@ $rowid=GETPOST('rowid','int');
$entity=GETPOST('entity','int');
$action=GETPOST('action','alpha');
$update=GETPOST('update','alpha');
$delete=GETPOST('delete','alpha');
$delete=GETPOST('delete'); // Do not use alpha here
$debug=GETPOST('debug','int');
$consts=GETPOST('const');
$constname=GETPOST('constname','alpha');
@ -47,6 +47,7 @@ $typeconst=array('yesno' => 'yesno', 'texte' => 'texte', 'chaine' => 'chaine');
$mesg='';
/*
* Actions
*/
@ -68,46 +69,70 @@ if ($action == 'add')
if (! $error)
{
if (dolibarr_set_const($db, $constname, $constvalue, $typeconst[$consttype], 1, $constnote, $entity) < 0)
if (dolibarr_set_const($db, $constname, $constvalue, $typeconst[$consttype], 1, $constnote, $entity) >= 0)
{
setEventMessage($langs->trans("RecordSaved"));
}
else
{
dol_print_error($db);
}
}
}
if (! empty($consts) && $update == $langs->trans("Modify"))
// Mass update
if (! empty($consts) && $action == 'update')
{
$nbmodified=0;
foreach($consts as $const)
{
if (! empty($const["check"]))
{
if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) < 0)
if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) >= 0)
{
$nbmodified++;
}
else
{
dol_print_error($db);
}
}
}
if ($nbmodified > 0) setEventMessage($langs->trans("RecordSaved"));
$action='';
}
// Delete several lines at once
if (! empty($consts) && $delete == $langs->trans("Delete"))
// Mass delete
if (! empty($consts) && $action == 'delete')
{
$nbdeleted=0;
foreach($consts as $const)
{
if (! empty($const["check"])) // Is checkbox checked
{
if (dolibarr_del_const($db, $const["rowid"], -1) < 0)
if (dolibarr_del_const($db, $const["rowid"], -1) >= 0)
{
$nbdeleted++;
}
else
{
dol_print_error($db);
}
}
}
if ($nbdeleted > 0) setEventMessage($langs->trans("RecordDeleted"));
$action='';
}
// Delete line from delete picto
if ($action == 'delete')
{
if (dolibarr_del_const($db, $rowid, $entity) < 0)
if (dolibarr_del_const($db, $rowid, $entity) >= 0)
{
setEventMessage($langs->trans("RecordDeleted"));
}
else
{
dol_print_error($db);
}
@ -130,11 +155,13 @@ jQuery(document).ready(function() {
jQuery("#delconst").hide();
jQuery(".checkboxfordelete").click(function() {
jQuery("#delconst").show();
jQuery("#action").val('delete');
});
jQuery(".inputforupdate").keypress(function() {
var field_id = jQuery(this).attr("id");
var row_num = field_id.split("_");
jQuery("#updateconst").show();
jQuery("#action").val('update');
jQuery("#check_" + row_num[1]).attr("checked",true);
});
});
@ -195,7 +222,8 @@ print '</form>';
print "\n";
print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && $debug)?'?debug=1':'').'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" id="action" name="action" value="">';
// Show constants
$sql = "SELECT";

View File

@ -64,8 +64,6 @@ $pageprev = $page - 1;
$pagenext = $page + 1;
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('admin'));
// This page is a generic page to edit dictionnaries
@ -734,7 +732,7 @@ if ($id)
if (in_array('region_id',$fieldlist)) { print '<td>&nbsp;</td>'; continue; } // For region page, we do not show the country input
$valuetoshow=$langs->trans("Country");
}
if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=MAIN_LABEL_MENTION_NPR; $align="center"; }
if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; }
if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); }
if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); }
if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); }
@ -848,7 +846,7 @@ if ($id)
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label")."*"; }
if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
if ($fieldlist[$field]=='pays') { $valuetoshow=$langs->trans("Country"); }
if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=MAIN_LABEL_MENTION_NPR; $align="center"; }
if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; }
if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); }
if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); }
if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); }

View File

@ -105,6 +105,24 @@ print_fiche_titre($langs->trans("MailingSetup"),$linkback,'setup');
dol_htmloutput_mesg($mesg);
if (! empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#generate_token").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
action: \'getrandompassword\',
generic: true
},
function(token) {
$("#MAILING_EMAIL_UNSUBSCRIBE_KEY").val(token);
});
});
});';
print '</script>';
}
print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -155,7 +173,9 @@ print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("ActivateCheckReadKey").'</td><td>';
print '<input size="32" type="text" name="MAILING_EMAIL_UNSUBSCRIBE_KEY" '.$readonly.' value="'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY.'">';
print '<input size="32" type="text" name="MAILING_EMAIL_UNSUBSCRIBE_KEY" id="MAILING_EMAIL_UNSUBSCRIBE_KEY" '.$readonly.' value="'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY.'">';
if (! empty($conf->use_javascript_ajax))
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
print '</td></tr>';
print '</table>';

View File

@ -68,7 +68,7 @@ error_reporting($err);
if ($action == 'update' && empty($_POST["cancel"]))
{
$_SESSION["mainmenu"]="home"; // Le gestionnaire de menu a pu changer
dolibarr_set_const($db, "MAIN_MENU_STANDARD", $_POST["MAIN_MENU_STANDARD"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MENU_SMARTPHONE", $_POST["MAIN_MENU_SMARTPHONE"],'chaine',0,'',$conf->entity);
@ -77,33 +77,37 @@ if ($action == 'update' && empty($_POST["cancel"]))
// Define list of menu handlers to initialize
$listofmenuhandler=array();
$listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENU_STANDARD"])]=1;
$listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_STANDARD"])]=1;
if (isset($_POST["MAIN_MENU_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENU_SMARTPHONE"])]=1;
if (isset($_POST["MAIN_MENUFRONT_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_SMARTPHONE"])]=1;
$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',$_POST["MAIN_MENU_STANDARD"])]=1;
$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',$_POST["MAIN_MENUFRONT_STANDARD"])]=1;
if (isset($_POST["MAIN_MENU_SMARTPHONE"])) $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',$_POST["MAIN_MENU_SMARTPHONE"])]=1;
if (isset($_POST["MAIN_MENUFRONT_SMARTPHONE"])) $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',$_POST["MAIN_MENUFRONT_SMARTPHONE"])]=1;
// Initialize menu handlers
foreach ($listofmenuhandler as $key => $val)
{
// Load sql init_menu_handler.sql file
$dir = "/core/menus/";
$file='init_menu_'.$key.'.sql';
$fullpath=dol_buildpath($dir.$file);
if (file_exists($fullpath))
{
$db->begin();
$result=run_sql($fullpath,1,'',1,$key,'none');
if ($result > 0)
$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
foreach($dirmenus as $dirmenu)
{
$file='init_menu_'.$key.'.sql';
$fullpath=dol_buildpath($dirmenu.$file);
//print 'action='.$action.' Search menu into fullpath='.$fullpath.'<br>';exit;
if (file_exists($fullpath))
{
$db->commit();
}
else
{
$error++;
$errmsgs[]='Failed to initialize menu '.$key.'.';
$db->rollback();
$db->begin();
$result=run_sql($fullpath,1,'',1,$key,'none');
if ($result > 0)
{
$db->commit();
}
else
{
$error++;
$errmsgs[]='Failed to initialize menu '.$key.'.';
$db->rollback();
}
}
}
}

View File

@ -47,20 +47,24 @@ $mesg=GETPOST('mesg');
$menu_handler_top=$conf->global->MAIN_MENU_STANDARD;
$menu_handler_smartphone=$conf->global->MAIN_MENU_SMARTPHONE;
$menu_handler_top=preg_replace('/_backoffice.php/i','',$menu_handler_top);
$menu_handler_top=preg_replace('/_frontoffice.php/i','',$menu_handler_top);
$menu_handler_smartphone=preg_replace('/_backoffice.php/i','',$menu_handler_smartphone);
$menu_handler_smartphone=preg_replace('/_frontoffice.php/i','',$menu_handler_smartphone);
$menu_handler_top=preg_replace('/(_backoffice\.php|_menu\.php)/i','',$menu_handler_top);
$menu_handler_top=preg_replace('/(_frontoffice\.php|_menu\.php)/i','',$menu_handler_top);
$menu_handler_smartphone=preg_replace('/(_backoffice\.php|_menu\.php)/i','',$menu_handler_smartphone);
$menu_handler_smartphone=preg_replace('/(_frontoffice\.php|_menu\.php)/i','',$menu_handler_smartphone);
$menu_handler=$menu_handler_top;
if (GETPOST("handler_origine")) $menu_handler=GETPOST("handler_origine");
if (GETPOST("menu_handler")) $menu_handler=GETPOST("menu_handler");
$menu_handler_to_search=preg_replace('/(_backoffice|_menu)?(\.php)?/i','',$menu_handler);
$menu_handler_to_search=preg_replace('/(_frontoffice|_menu)?(\.php)?/i','',$menu_handler);
/*
* Actions
*/
* Actions
*/
if ($action == 'up')
{
@ -89,7 +93,7 @@ if ($action == 'up')
$sql = "SELECT m.rowid, m.position";
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
$sql.= " WHERE (m.position < ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid < ".$_GET["menuId"]."))";
$sql.= " AND m.menu_handler='".$menu_handler."'";
$sql.= " AND m.menu_handler='".$menu_handler_to_search."'";
$sql.= " AND m.entity = ".$conf->entity;
$sql.= " AND m.type = '".$current['type']."'";
$sql.= " AND m.fk_menu = '".$current['fk_menu']."'";
@ -145,7 +149,7 @@ elseif ($action == 'down')
$sql = "SELECT m.rowid, m.position";
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
$sql.= " WHERE (m.position > ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid > ".$_GET["menuId"]."))";
$sql.= " AND m.menu_handler='".$menu_handler."'";
$sql.= " AND m.menu_handler='".$menu_handler_to_search."'";
$sql.= " AND m.entity = ".$conf->entity;
$sql.= " AND m.type = '".$current['type']."'";
$sql.= " AND m.fk_menu = '".$current['fk_menu']."'";
@ -204,9 +208,11 @@ elseif ($action == 'confirm_delete' && $confirm == 'yes')
$form=new Form($db);
$formadmin=new FormAdmin($db);
$arrayofjs=array('/admin/menus/menu.js.php?lang='.$langs->defaultlang);
llxHeader('',$langs->trans("Menus"),'','',0,0,$arrayofjs);
$arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js?lang='.$langs->defaultlang);
$arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css?lang='.$langs->defaultlang);
llxHeader('',$langs->trans("Menus"),'','',0,0,$arrayofjs,$arrayofcss);
print_fiche_titre($langs->trans("Menus"),'','setup');
@ -255,7 +261,7 @@ if ($action == 'delete')
print '<form name="newmenu" class="nocellnopadd" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" action="change_menu_handler">';
print $langs->trans("MenuHandler").': ';
print $formadmin->select_menu_families($menu_handler,'menu_handler',array_merge($dirstandard,$dirsmartphone));
print $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/',$menu_handler)?'':'_menu'),'menu_handler',array_merge($dirstandard,$dirsmartphone));
print ' &nbsp; <input type="submit" class="button" value="'.$langs->trans("Refresh").'">';
print '</form>';
@ -294,7 +300,7 @@ if ($conf->use_javascript_ajax)
$sql = "SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu";
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
$sql.= " WHERE menu_handler = '".$menu_handler."'";
$sql.= " WHERE menu_handler = '".$menu_handler_to_search."'";
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND fk_menu >= 0";
$sql.= " ORDER BY m.position, m.rowid"; // Order is position then rowid (because we need a sort criteria when position is same)

View File

@ -1,225 +0,0 @@
<?php
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/menus/menu.js.php
* \brief File for js menu
*/
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled to increase speed. Language code is found on url.
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1);
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1);
if (! defined('NOLOGIN')) define('NOLOGIN',1);
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1);
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
session_cache_limiter(FALSE);
require_once '../../master.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
// Define css type
header('Content-type: application/javascript');
// Important: Following code is to avoid page request by browser and PHP CPU at
// each Dolibarr page access.
if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
else header('Cache-Control: no-cache');
// On the fly GZIP compression for all pages (if browser support it). Must set the bit 3 of constant to 1.
if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x04)) { ob_start("ob_gzhandler"); }
if (GETPOST('lang')) $langs->setDefaultLang(GETPOST('lang')); // If language was forced on URL
if (GETPOST('theme')) $conf->theme=GETPOST('theme'); // If theme was forced on URL
$langs->load("main",0,0);
?>
// Tests pour navigateurs
var OPE = (window.opera) ? true : false;
var IE = (document.all && !OPE) ? true : false;
var MOZ = (!IE && !OPE) ? true : false;
// -----------------------------------------------------
// Fonction d'initialisation de l'arbre
function arbre() {
// Choix de la balise contenant le texte. (strong par defaut).
balise = "STRONG";
// Presentation de l'arbre au depart : deployee ('yes') ou fermee ('no')
extend = "no";
// Textes du lien plier / deplier
plier_text = '<?php echo $langs->transnoentities("UndoExpandAll"); ?>';
plier_title = 'Replier tous les noeuds de l\'arbre'
deplier_text = '<?php echo $langs->transnoentities("ExpandAll"); ?>';
deplier_title = 'Deplier tous les noeuds de l\'arbre'
// Recuperation de tous les arbres de la page
uls = getElBy('ul','class','arbre');
for (uli=0;uli < uls.length;uli++)
{
ul = uls[uli];
linkSwitch(ul);
processULEL(ul);
plier(ul,'replier');
}
}
// -------------------------------------------------------
// Creation des liens plier /deplier tout
function linkSwitch(ul) {
var a=document.createElement('a');
a.setAttribute('href','#');
if (extend=='yes') {
a.appendChild(document.createTextNode(plier_text));
a.setAttribute('title',plier_title);
}
else {
a.appendChild(document.createTextNode(deplier_text));
a.setAttribute('title',deplier_title);
}
var parbre = document.createElement('p');
parbre.setAttribute('class','arbre-switch');
parbre.appendChild(a);
ul.parentNode.insertBefore(parbre,ul);
listenlink(ul);
}
// Gestion des Clics sur les liens plier / deplier tout
function listenlink(ul) {
var link = ul.previousSibling.childNodes[0];
link.onclick = function() {
if (this.childNodes[0].nodeValue == plier_text) {
plier(ul,'replier');
this.childNodes[0].nodeValue = deplier_text;
this.setAttribute('title',deplier_title);
}
else {
plier(ul,'deplier');
this.childNodes[0].nodeValue = plier_text;
this.setAttribute('title',plier_title);
}
return false;
}
}
// Action Plier / deplier tout
function plier(ul,act) {
for (var i=0; i < ul.childNodes.length; i++) {
var li = ul.childNodes[i];
if (li.nodeName == 'LI') {
for (var j=0; j < li.childNodes.length; j++) {
var child = li.childNodes[j];
if (child.nodeName==balise) {
var strong = child;
}
if (child.nodeName=='UL') {
if (act=='replier') {
child.className='hide';
strong.className='arbre-plier';
}
else {
child.className='';
strong.className='arbre-deplier';
}
var sub = child;
plier(sub,act);
}
}
}
}
}
// ---------------------------------------------------------
// Analyse de l'arbre
function processULEL(ul) {
if (!ul.childNodes || ul.childNodes.length == 0) return;
// Iterate LIs
for (var itemi=0;itemi < ul.childNodes.length;itemi++) {
var item = ul.childNodes[itemi];
if (item.nodeName == "LI") {
// Contenu des balises LI
var a;
var subul;
subul = "";
for (var sitemi=0;sitemi < item.childNodes.length;sitemi++) {
// Uniquement pour moz-firefox
if (MOZ) {item.style.background = "";}
// Enfants des li : balise ou sous-ul
var sitem = item.childNodes[sitemi];
switch (sitem.nodeName) {
case balise:
a = sitem;
break;
case "UL":
subul = sitem;
if (extend != "yes") {sitem.className = 'hide';}
processULEL(subul);
break;
}
}
if (subul) {
if (extend!="yes") {
a.className='arbre-plier';
}
else {
a.className='arbre-deplier';
subul.className='';
}
associateEL(a,subul);
}
}
}
}
// Swicth des noeuds
function associateEL(a,ul) {
a.onclick = function () {
this.className = (ul.className=='hide') ? 'arbre-deplier' : 'arbre-plier';
ul.className = (ul.className=='hide') ? '' : 'hide';
return false;
}
}
// -----------------------------------------------------
// Nom : GetElBy(tag,attr,val)
// By : Rui Nibau
// Date : aout 2005
// Func : Tableau des elements 'tag' dont l'attribut 'attr' a la valeur 'val'.
// -----------------------------------------------------
function getElBy(tag,attr,val) {
var dbRes = [];
var dbEl = document.getElementsByTagName(tag);
for (e=0; e < dbEl.length; e++) {
if (attr == 'class') {if (dbEl[e].className==val) {dbRes.push(dbEl[e]);}}
else {if (dbEl[e].getAttribute(attr)==val) {dbRes.push(dbEl[e]);}}
}
return dbRes;
}
// -----------------------------------------------------
// A l'affichage de la page, lancer la fonction arbre
window.onload = function() {
arbre();
}
function imgDel(id)
{
var delId='del'+id;
var imgDel = document.getElementById('del'+id);
if (imgDel != null) imgDel.style.display='block';
return true;
}

View File

@ -265,8 +265,6 @@ $head[$h][2] = 'marketplace';
$h++;
// Show warning about external users
print showModulesExludedForExternal($modules).'<br>'."\n";
print "<br>\n";
@ -500,6 +498,10 @@ else
dol_fiche_end();
// Show warning about external users
print showModulesExludedForExternal($modules).'<br>'."\n";
llxFooter();
$db->close();

View File

@ -86,8 +86,6 @@ if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('categorycard'));

View File

@ -47,6 +47,7 @@ class Categorie
var $import_key;
var $cats=array(); // Tableau en memoire des categories
var $motherof=array();
/**
@ -543,6 +544,40 @@ class Categorie
}
/**
* Load this->motherof that is array(id_son=>id_parent, ...)
*
* @return int <0 if KO, >0 if OK
*/
private function load_motherof()
{
global $conf;
$this->motherof=array();
// Load array[child]=parent
$sql = "SELECT fk_parent as id_parent, rowid as id_son";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
$sql.= " WHERE fk_parent != 0";
$sql.= " AND entity = ".$conf->entity;
dol_syslog(get_class($this)."::load_motherof sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
while ($obj= $this->db->fetch_object($resql))
{
$this->motherof[$obj->id_son]=$obj->id_parent;
}
return 1;
}
else
{
dol_print_error($this->db);
return -1;
}
}
/**
* Reconstruit l'arborescence des categories sous la forme d'un tableau
* Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec:
@ -554,13 +589,16 @@ class Categorie
* fullpath = chemin complet compose des id
*
* @param string $type Type of categories (0=product, 1=suppliers, 2=customers, 3=members)
* @param int $markafterid Mark all categories after this leaf in category tree.
* @return array Array of categories
* @param int $markafterid Removed all categories including the leaf $markafterid in category tree.
* @return array Array of categories. this->cats and this->motherof are set.
*/
function get_full_arbo($type,$markafterid=0)
{
$this->cats = array();
// Init this->motherof that is array(id_son=>id_parent, ...)
$this->load_motherof();
// Init $this->cats array
$sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.fk_parent"; // Distinct reduce pb with old tables with duplicates
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c";
@ -592,10 +630,11 @@ class Categorie
dol_syslog(get_class($this)."::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG);
foreach($this->cats as $key => $val)
{
//print 'key='.$key.'<br>'."\n";
$this->build_path_from_id_categ($key,0); // Process a branch from the root category key (this category has no parent)
}
// Exclude tree for $markafterid
// Exclude leaf including $markafterid from tree
if ($markafterid)
{
//print "Look to discard category ".$markafterid."\n";
@ -608,8 +647,6 @@ class Categorie
if (preg_match('/'.$keyfilter1.'/',$val['fullpath']) || preg_match('/'.$keyfilter2.'/',$val['fullpath'])
|| preg_match('/'.$keyfilter3.'/',$val['fullpath']) || preg_match('/'.$keyfilter4.'/',$val['fullpath']))
{
//print "Categ discarded ".$this->cats[$key]['fullpath']."\n";
//$this->cats[$key]['marked']=1;
unset($this->cats[$key]);
}
}
@ -630,51 +667,38 @@ class Categorie
* @param int $protection Deep counter to avoid infinite loop
* @return void
*/
function build_path_from_id_categ($id_categ,$protection=0)
function build_path_from_id_categ($id_categ,$protection=1000)
{
dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG);
//if (! empty($this->cats[$id_categ]['fullpath']))
//{
// Already defined
// dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING);
// return;
//}
if (! empty($this->cats[$id_categ]['fullpath']))
{
// Already defined
dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING);
return;
}
// First build full array $motherof
//$this->load_motherof(); // Disabled because already done by caller of build_path_from_id_categ
// Define fullpath and fulllabel
if (! empty($this->cats[$id_categ]['fk_parent']))
$this->cats[$id_categ]['fullpath'] = '_'.$id_categ;
$this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label'];
$i=0; $cursor_categ=$id_categ;
//print 'Work for id_categ='.$id_categ.'<br>'."\n";
while ((empty($protection) || $i < $protection) && ! empty($this->motherof[$cursor_categ]))
{
$this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['fk_parent']]['fullpath'];
$this->cats[$id_categ]['fullpath'].= '_'.$id_categ;
$this->cats[$id_categ]['fulllabel'] = $this->cats[$this->cats[$id_categ]['fk_parent']]['fulllabel'];
$this->cats[$id_categ]['fulllabel'].= ' >> '.$this->cats[$id_categ]['label'];
}
else
{
$this->cats[$id_categ]['fullpath'] = '_'.$id_categ;
$this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label'];
//print '&nbsp; cursor_categ='.$cursor_categ.' i='.$i.' '.$this->motherof[$cursor_categ].'<br>'."\n";
$this->cats[$id_categ]['fullpath'] = '_'.$this->motherof[$cursor_categ].$this->cats[$id_categ]['fullpath'];
$this->cats[$id_categ]['fulllabel'] = $this->cats[$this->motherof[$cursor_categ]]['label'].' >> '.$this->cats[$id_categ]['fulllabel'];
//print '&nbsp; Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].' '.$this->cats[$id_categ]['fulllabel'].'<br>'."\n";
$i++; $cursor_categ=$this->motherof[$cursor_categ];
}
//print 'Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].'<br>'."\n";
// We count number of _ to have level
$this->cats[$id_categ]['level']=dol_strlen(preg_replace('/[^_]/i','',$this->cats[$id_categ]['fullpath']));
/*
// Process all childs on several levels of this category
$protection++;
if ($protection > 10) return; // On ne traite pas plus de 10 niveaux de profondeurs
if (empty($this->cats[$id_categ]['id_children'])) return;
foreach($this->cats[$id_categ]['id_children'] as $key => $idchild)
{
// Protection when a category has itself as a child (should not happen)
if ($idchild == $id_categ)
{
dol_syslog(get_class($this)."::build_path_from_id_categ bad couple (".$idchild.",".$id_categ.") in association table: An entry should not have itself has child", LOG_WARNING);
continue;
}
$this->build_path_from_id_categ($idchild,$protection);
}
*/
return;
}

View File

@ -42,7 +42,7 @@ $type = GETPOST('type','alpha');
$urlfrom = GETPOST('urlfrom','alpha');
$socid=GETPOST('socid','int');
$nom=GETPOST('nom');
$label=GETPOST('label');
$description=GETPOST('description');
$visible=GETPOST('visible');
$parent=GETPOST('parent');
@ -107,7 +107,7 @@ if ($action == 'add' && $user->rights->categorie->creer)
$object = new Categorie($db);
$object->label = $nom;
$object->label = $label;
$object->description = $description;
$object->socid = ($socid ? $socid : 'null');
$object->visible = $visible;
@ -191,6 +191,8 @@ if ($user->rights->categorie->creer)
*/
if ($action == 'create' || $_POST["addcat"] == 'addcat')
{
dol_set_focus('#label');
print '<form action="'.$_SERVER['PHP_SELF'].'?type='.$type.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="urlfrom" value="'.$urlfrom.'">';
@ -198,7 +200,6 @@ if ($user->rights->categorie->creer)
print '<input type="hidden" name="addcat" value="addcat">';
print '<input type="hidden" name="id" value="'.GETPOST('origin').'">';
print '<input type="hidden" name="type" value="'.$type.'">';
print '<input type="hidden" name="nom" value="'.dol_escape_htmltag($nom).'">';
if ($origin) print '<input type="hidden" name="origin" value="'.$origin.'">';
if ($catorigin) print '<input type="hidden" name="catorigin" value="'.$catorigin.'">';
@ -210,7 +211,7 @@ if ($user->rights->categorie->creer)
// Ref
print '<tr>';
print '<td width="25%" class="fieldrequired">'.$langs->trans("Ref").'</td><td><input name="nom" size="25" value="'.$nom.'">';
print '<td width="25%" class="fieldrequired">'.$langs->trans("Ref").'</td><td><input id="label" name="label" size="25" value="'.$label.'">';
print'</td></tr>';
// Description
@ -237,7 +238,8 @@ if ($user->rights->categorie->creer)
}
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -209,12 +209,15 @@ foreach($fulltree as $key => $val)
// Define showline
$showline=0;
//var_dump($expandedsectionarray);
// If directory is son of expanded directory, we show line
if (isset($val['fk_parent']) && in_array($val['fk_parent'],$expandedsectionarray)) $showline=4;
// If directory is parent of selected directory or is selected directory, we show line
elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
// If we are level one we show line
elseif ($val['level'] < 2) $showline=1;
//print 'xxx '.$val['level'].' - '.$fullpathselected.' - '.$val['fullpath'].' - '.$val['fk_parent'].' showline='.$showline.'<br>'."\n";
if ($showline)
{

View File

@ -1,79 +0,0 @@
<?php
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/categories/liste.php
* \ingroup category
* \brief Page liste des categories
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
if (!$user->rights->categorie->lire) accessforbidden();
llxHeader("","",$langs->trans("Categories"));
print_fiche_titre($langs->trans("CatList"));
print '<table border="0" width="100%" class="notopnoleftnoright">';
print '<tr><td valign="top" width="30%" class="notopnoleft">';
$c = new Categorie($db);
$cats = $c->get_all_categories();
if ($cats != -1)
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="right">'.$langs->trans("Type").'</td>';
print '</tr>';
$var=true;
foreach ($cats as $cat)
{
$var = ! $var;
print "\t<tr ".$bc[$var].">\n";
print "\t\t<td><a href='viewcat.php?id=".$cat->id."'>".$cat->label."</a></td>\n";
print "\t\t<td>".dol_trunc($cat->description,36)."</td>\n";
print '<td align="right">';
if ($cat->type == 0) print $langs->trans("Product");
elseif ($cat->type == 1) print $langs->trans("Supplier");
elseif ($cat->type == 2) print $langs->trans("Customer");
else print $cat->type;
print "</td>\n";
print "\t</tr>\n";
}
print "</table>";
}
else
{
dol_print_error();
}
print '</td></tr></table>';
$db->close();
llxFooter();
?>

View File

@ -106,8 +106,8 @@ class ActionComm extends CommonObject
*/
function add($user,$notrigger=0)
{
global $langs,$conf;
global $langs,$conf,$hookmanager;
$error=0;
$now=dol_now();
@ -210,8 +210,6 @@ class ActionComm extends CommonObject
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm","id");
// Actions on extra fields (by external module or standard code)
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager->initHooks(array('actioncommdao'));
$parameters=array('actcomm'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
@ -430,7 +428,7 @@ class ActionComm extends CommonObject
*/
function update($user,$notrigger=0)
{
global $langs,$conf;
global $langs,$conf,$hookmanager;
$error=0;
@ -482,8 +480,6 @@ class ActionComm extends CommonObject
{
// Actions on extra fields (by external module or standard code)
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager->initHooks(array('actioncommdao'));
$parameters=array('actcomm'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks

View File

@ -66,8 +66,6 @@ $extrafields = new ExtraFields($db);
//var_dump($_POST);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('actioncard'));
@ -185,7 +183,7 @@ if ($action == 'add_action')
if (! empty($conf->phenix->enabled) && GETPOST('add_phenix') == 'on') $actioncomm->use_phenix=1;
// Check parameters
if ($actioncomm->type_code == 'AC_RDV' && ($datep == '' || $datef == ''))
if ($actioncomm->type_code == 'AC_RDV' && ($datep == '' || ($datef == '' && empty($fulldayevent))))
{
$error++;
$action = 'create';
@ -409,6 +407,8 @@ if ($action == 'create')
if ($result < 0) dol_print_error($db,$contact->error);
}
dol_set_focus("#label");
if (! empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript">';
@ -482,7 +482,7 @@ if ($action == 'create')
else print '<input type="hidden" name="actioncode" value="AC_OTH">';
// Title
print '<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").'</td><td><input type="text" name="label" size="60" value="'.GETPOST('label').'"></td></tr>';
print '<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").'</td><td><input type="text" id="label" name="label" size="60" value="'.GETPOST('label').'"></td></tr>';
// Full day
print '<tr><td class="fieldrequired">'.$langs->trans("EventOnFullDay").'</td><td><input type="checkbox" id="fullday" name="fullday" '.(GETPOST('fullday')?' checked="checked"':'').'></td></tr>';
@ -561,7 +561,7 @@ if ($action == 'create')
} else {
print $form->select_company('','socid','',1,1);
}
}
print '</td></tr>';

View File

@ -753,7 +753,7 @@ if (empty($action) || $action == 'show_month') // View by month
$newparam=preg_replace('/month=[0-9]+&?/i','',$newparam);
$newparam=preg_replace('/year=[0-9]+&?/i','',$newparam);
$newparam=preg_replace('/showbirthday_=/i','showbirthday=',$newparam); // Restore correct parameter
echo '<table width="100%" class="nocellnopadd">';
echo '<table width="100%" class="nocellnopadd cal_month">';
echo ' <tr class="liste_titre">';
$i=0;
while ($i < 7)
@ -778,6 +778,7 @@ if (empty($action) || $action == 'show_month') // View by month
if ($tmpday <= 0)
{
$style='cal_other_month cal_past';
if ($iter_day == 6) $style.=' cal_other_month_right';
echo ' <td class="'.$style.'" width="14%" valign="top" nowrap="nowrap">';
show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
echo " </td>\n";
@ -788,6 +789,7 @@ if (empty($action) || $action == 'show_month') // View by month
$curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year);
$style='cal_current_month';
if ($iter_day == 6) $style.=' cal_current_month_right';
$today=0;
if ($todayarray['mday']==$tmpday && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1;
if ($today) $style='cal_today';
@ -801,6 +803,7 @@ if (empty($action) || $action == 'show_month') // View by month
else
{
$style='cal_other_month';
if ($iter_day == 6) $style.=' cal_other_month_right';
echo ' <td class="'.$style.'" width="14%" valign="top" nowrap="nowrap">';
show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
echo "</td>\n";
@ -821,7 +824,7 @@ elseif ($action == 'show_week') // View by week
$newparam=preg_replace('/month=[0-9]+&?/i','',$newparam);
$newparam=preg_replace('/year=[0-9]+&?/i','',$newparam);
$newparam=preg_replace('/showbirthday_=/i','showbirthday=',$newparam); // Restore correct parameter
echo '<table width="100%" class="nocellnopadd">';
echo '<table width="100%" class="nocellnopadd cal_month">';
echo ' <tr class="liste_titre">';
$i=0;
while ($i < 7)
@ -845,6 +848,7 @@ elseif ($action == 'show_week') // View by week
$curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year);
$style='cal_current_month';
if ($iter_day == 6) $style.=' cal_other_month_right';
$today=0;
$todayarray=dol_getdate($now,'fast');
if ($todayarray['mday']==$tmpday && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1;
@ -857,6 +861,7 @@ elseif ($action == 'show_week') // View by week
else
{
$style='cal_current_month';
if ($iter_day == 6) $style.=' cal_other_month_right';
echo ' <td class="'.$style.'" width="14%" valign="top" nowrap="nowrap">';
show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
echo "</td>\n";
@ -941,7 +946,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
print '<div id="dayevent_'.sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day).'" class="dayevent">'."\n";
$curtime = dol_mktime(0, 0, 0, $month, $day, $year);
print '<table class="nobordernopadding" width="100%">';
print '<tr style="background: #EEEEEE"><td align="left" nowrap="nowrap">';
print '<tr><td align="left" nowrap="nowrap">';
print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?';
print 'action=show_day&day='.str_pad($day, 2, "0", STR_PAD_LEFT).'&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year;
print $newparam;
@ -960,7 +965,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
print '</a>';
}
print '</td></tr>';
print '<tr height="'.$minheight.'"><td valign="top" colspan="2" nowrap="nowrap">';
print '<tr height="'.$minheight.'"><td valign="top" colspan="2" nowrap="nowrap" style="padding-bottom: 2px;">';
//$curtime = dol_mktime (0, 0, 0, $month, $day, $year);
$i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array();
@ -1004,8 +1009,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
// Show rect of event
print '<div id="event_'.$ymd.'_'.$i.'" class="event '.$cssclass.'">';
print '<table class="cal_event" style="background: #'.$color.'; -moz-border-radius:4px;" width="100%"><tr>';
print '<td nowrap="nowrap">';
print '<ul class="cal_event"><li class="cal_event">';
print '<table class="cal_event" style="background: #'.$color.'; -moz-border-radius:4px; background: -webkit-gradient(linear, left top, left bottom, from(#'.$color.'), to(#'.dol_color_minus($color,1).')); " width="100%"><tr>';
print '<td nowrap="nowrap" class="cal_event">';
if ($event->type_code == 'BIRTHDAY') // It's a birthday
{
print $event->getNomUrl(1,$maxnbofchar,'cal_event','birthday','contact');
@ -1130,6 +1136,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') print $event->getLibStatut(3,1);
else print '&nbsp;';
print '</td></tr></table>';
print '</li></ul>';
print '</div>';
$i++;
}
@ -1174,4 +1181,13 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
print '</div>'."\n";
}
function dol_color_minus($color, $minus)
{
$newcolor=$color;
$newcolor[0]=((hexdec($newcolor[0])-$minus)<0)?0:dechex((hexdec($newcolor[0])-$minus));
$newcolor[2]=((hexdec($newcolor[2])-$minus)<0)?0:dechex((hexdec($newcolor[2])-$minus));
$newcolor[4]=((hexdec($newcolor[4])-$minus)<0)?0:dechex((hexdec($newcolor[4])-$minus));
return $newcolor;
}
?>

View File

@ -143,6 +143,7 @@ if ($socid) $param.="&socid=".$socid;
if ($showbirthday) $param.="&showbirthday=1";
if ($pid) $param.="&projectid=".$pid;
if ($type) $param.="&type=".$type;
if ($actioncode) $param.="&actioncode=".$actioncode;
$sql = "SELECT s.nom as societe, s.rowid as socid, s.client,";
$sql.= " a.id, a.datep as dp, a.datep2 as dp2,";

View File

@ -46,8 +46,6 @@ $origin=GETPOST('origin','alpha');
$originid=GETPOST('originid','int');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('propalcard'));
/*

View File

@ -55,16 +55,11 @@ $result = restrictedArea($user, 'societe',$socid,'');
llxHeader('','Contacts');
if ($type == "c")
if ($type == "c" || $type == "p")
{
$label = $langs->trans("Customers");
$urlfiche="fiche.php";
}
if ($type == "p")
{
$label = $langs->trans("Prospects");
$urlfiche="prospect/fiche.php";
}
if ($type == "f")
{
$label = $langs->trans("Suppliers");

View File

@ -31,6 +31,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
@ -109,6 +110,24 @@ if ($action == 'setassujtva' && $user->rights->societe->creer)
if (! $result) dol_print_error($result);
}
// set prospect level
if ($action == 'setprospectlevel' && $user->rights->societe->creer)
{
$object->fetch($id);
$object->fk_prospectlevel=GETPOST('prospect_level_id','alpha');
$result=$object->set_prospect_level($user);
if ($result < 0) setEventMessage($object->error,'errors');
}
// Update communication level
if ($action == 'cstc')
{
$object->fetch($id);
$object->stcomm_id=GETPOST('stcomm','int');
$result=$object->set_commnucation_level($user);
if ($result < 0) setEventMessage($object->error,'errors');
}
/*
@ -121,6 +140,7 @@ llxHeader('',$langs->trans('CustomerCard'));
$contactstatic = new Contact($db);
$userstatic=new User($db);
$form = new Form($db);
$formcompany=new FormCompany($db);
if ($mode == 'search')
@ -176,6 +196,11 @@ if ($id > 0)
$object->next_prev_filter="te.client in (1,3)";
print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','','');
print '</td></tr>';
// Prospect/Customer
print '<tr><td width="30%">'.$langs->trans('ProspectCustomer').'</td><td width="70%" colspan="3">';
print $object->getLibCustProspStatut();
print '</td></tr>';
// Prefix
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
@ -359,6 +384,34 @@ if ($id > 0)
print '</td><td colspan="3">'.$object->price_level."</td>";
print '</tr>';
}
// Level of prospect
if ($object->client == 2 || $object->client == 3)
{
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans('ProspectLevel');
print '<td>';
if ($action != 'editlevel' && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editlevel&amp;socid='.$object->id.'">'.img_edit($langs->trans('Modify'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editlevel')
$formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_prospectlevel,'prospect_level_id',1);
else
print $object->getLibProspLevel();
print "</td>";
print '</tr>';
// Status
print '<tr><td>'.$langs->trans("StatusProsp").'</td><td colspan="2">'.$object->getLibProspCommStatut(4).'</td>';
print '<td>';
if ($object->stcomm_id != -1) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=-1&amp;action=cstc">'.img_action(0,-1).'</a>';
if ($object->stcomm_id != 0) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=0&amp;action=cstc">'.img_action(0,0).'</a>';
if ($object->stcomm_id != 1) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=1&amp;action=cstc">'.img_action(0,1).'</a>';
if ($object->stcomm_id != 2) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=2&amp;action=cstc">'.img_action(0,2).'</a>';
if ($object->stcomm_id != 3) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=3&amp;action=cstc">'.img_action(0,3).'</a>';
print '</td></tr>';
}
// Sales representative
include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php';
@ -742,7 +795,7 @@ if ($id > 0)
if (! empty($conf->propal->enabled) && $user->rights->propal->creer)
{
$langs->load("propal");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddProp").'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddProp").'</a>';
}
if (! empty($conf->commande->enabled) && $user->rights->commande->creer)

View File

@ -315,9 +315,7 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
print '<tr '.$bc[$var].'>';
print '<td nowrap="nowrap">'.$companystatic->getNomUrl(1,'customer',48).'</td>';
print '<td align="right" nowrap>';
if ($objp->client == 2 || $objp->client == 3) print $langs->trans("Prospect");
if ($objp->client == 3) print ' / ';
if ($objp->client == 1 || $objp->client == 3) print $langs->trans("Customer");
print $companystatic->getLibCustProspStatut();
print "</td>";
print '<td align="right" nowrap>'.dol_print_date($db->jdate($objp->tms),'day')."</td>";
print '</tr>';

View File

@ -58,8 +58,6 @@ $search_categ = GETPOST("search_categ",'int');
$catid = GETPOST("catid",'int');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('customerlist'));

View File

@ -47,8 +47,6 @@ $result=$object->fetch($id);
$extrafields = new ExtraFields($db);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('mailingcard'));
// Tableau des substitutions possibles

File diff suppressed because it is too large Load Diff

View File

@ -90,7 +90,7 @@ class Propal extends CommonObject
var $fk_delivery_address; // deprecated (for compatibility)
var $fk_address;
var $address_type;
var $adresse;
var $address;
var $availability_id;
var $availability_code;
var $demand_reason_id;
@ -789,7 +789,7 @@ class Propal extends CommonObject
if (! $error && $this->fk_delivery_address)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET fk_adresse_livraison = ".$this->fk_delivery_address;
$sql.= " SET fk_delivery_address = ".$this->fk_delivery_address;
$sql.= " WHERE ref = '".$this->ref."'";
$sql.= " AND entity = ".$conf->entity;
@ -867,12 +867,11 @@ class Propal extends CommonObject
* Load an object from its id and create a new one in database
*
* @param int $socid Id of thirdparty
* @param HookManager $hookmanager Hook manager instance
* @return int New id of clone
*/
function createFromClone($socid=0,$hookmanager=false)
function createFromClone($socid=0)
{
global $user,$langs,$conf;
global $user,$langs,$conf,$hookmanager;
$error=0;
$now=dol_now();
@ -986,7 +985,7 @@ class Propal extends CommonObject
$sql.= ", p.note as note_private, p.note_public";
$sql.= ", p.fk_projet, p.fk_statut";
$sql.= ", p.fk_user_author, p.fk_user_valid, p.fk_user_cloture";
$sql.= ", p.fk_adresse_livraison";
$sql.= ", p.fk_delivery_address";
$sql.= ", p.fk_availability";
$sql.= ", p.fk_input_reason";
$sql.= ", p.fk_cond_reglement";
@ -1050,8 +1049,8 @@ class Propal extends CommonObject
$this->demand_reason_id = $obj->fk_input_reason;
$this->demand_reason_code = $obj->demand_reason_code;
$this->demand_reason = $obj->demand_reason;
$this->fk_delivery_address = $obj->fk_adresse_livraison; // TODO obsolete
$this->fk_address = $obj->fk_adresse_livraison;
//$this->fk_delivery_address = $obj->fk_adresse_livraison; // TODO obsolete
$this->fk_address = $obj->fk_delivery_address;
$this->mode_reglement_id = $obj->fk_mode_reglement;
$this->mode_reglement_code = $obj->mode_reglement_code;

View File

@ -77,8 +77,6 @@ $result = restrictedArea($user, $module, $objectid, $dbtable);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('propalcard'));
@ -324,14 +322,7 @@ if ($result)
print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
print '</td></tr></table>';
if ($objp->client == 1)
{
$url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->rowid;
}
else
{
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$objp->rowid;
}
$url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->rowid;
// Company
$companystatic->id=$objp->rowid;

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com>
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -37,6 +38,7 @@ print_titre($langs->trans('RelatedCommercialProposals'));
</tr>
<?php
$var=true;
$total=0;
foreach($linkedObjectBlock as $object)
{
$var=!$var;

View File

@ -148,9 +148,9 @@ class Prospect extends Societe
*
* @return string Libelle
*/
function getLibLevel()
function getLibProspLevel()
{
return $this->LibLevel($this->fk_prospectlevel);
return $this->LibProspLevel($this->fk_prospectlevel);
}
/**
@ -159,7 +159,7 @@ class Prospect extends Societe
* @param int $fk_prospectlevel Prospect level
* @return string Libelle du niveau
*/
function LibLevel($fk_prospectlevel)
function LibProspLevel($fk_prospectlevel)
{
global $langs;

View File

@ -1,343 +0,0 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/comm/prospect/fiche.php
* \ingroup prospect
* \brief Page de la fiche prospect
*/
require_once '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/comm/prospect/class/prospect.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$langs->load('companies');
$langs->load('projects');
$langs->load('propal');
$action=GETPOST('action', 'alpha');
// Security check
$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe', $socid, '&societe');
$object = new Prospect($db);
/*
* Actions
*/
if ($action == 'cstc')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["stcomm"];
$sql .= " WHERE rowid = ".$socid;
$db->query($sql);
}
// set prospect level
if ($action == 'setprospectlevel' && $user->rights->societe->creer)
{
$object->fetch($socid);
$object->fk_prospectlevel=$_POST['prospect_level_id'];
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_prospectlevel='".$_POST['prospect_level_id'];
$sql.= " WHERE rowid = ".$socid;
$result = $db->query($sql);
if (! $result) dol_print_error($result);
}
/*********************************************************************************
*
* Mode fiche
*
*********************************************************************************/
llxHeader();
$now = dol_now();
$form=new Form($db);
$formcompany=new FormCompany($db);
if ($socid > 0)
{
$actionstatic=new ActionComm($db);
$result = $object->fetch($socid);
if ($result < 0)
{
dol_print_error($db);
exit;
}
/*
* Affichage onglets
*/
$head = societe_prepare_head($object);
dol_fiche_head($head, 'prospect', $langs->trans("ThirdParty"),0,'company');
print '<table width="100%" class="notopnoleftnoright">';
print '<tr><td valign="top" width="50%" class="notopnoleft">';
print '<table class="border" width="100%">';
print '<tr><td width="25%">'.$langs->trans("ThirdPartyName").'</td><td colspan="3">';
$object->next_prev_filter="te.client in (2,3)";
print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','','');
print '</td></tr>';
// Address
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">';
dol_print_address($object->address,'gmap','thirdparty',$object->id);
print "</td></tr>";
// Zip / Town
print '<tr><td nowrap="nowrap">'.$langs->trans('Zip').' / '.$langs->trans("Town").'</td><td colspan="3">'.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'</td>';
print '</tr>';
// Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
$img=picto_from_langcode($object->country_code);
if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
else print ($img?$img.' ':'').$object->country;
print '</td></tr>';
// Phone
print '<tr><td>'.$langs->trans("Phone").'</td><td style="min-width: 25%;">'.dol_print_phone($object->tel,$object->country_code,0,$object->id,'AC_TEL').'</td>';
print '<td>'.$langs->trans("Fax").'</td><td style="min-width: 25%;">'.dol_print_phone($object->fax,$object->country_code).'</td></tr>';
// EMail
print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($object->email,0,$object->id,'AC_EMAIL').'</td></tr>';
// Web
print '<tr><td>'.$langs->trans("Web")."</td><td colspan=\"3\"><a href=\"http://$object->url\">$object->url</a></td></tr>";
// Level of prospect
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans('ProspectLevelShort');
print '<td>';
if ($action != 'editlevel' && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editlevel&amp;socid='.$object->id.'">'.img_edit($langs->trans('Modify'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editlevel')
$formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_prospectlevel,'prospect_level_id',1);
else
print $object->getLibLevel();
print "</td>";
print '</tr>';
// Multiprice level
if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans("PriceLevel");
print '<td><td align="right">';
if ($user->rights->societe->creer)
{
print '<a href="'.DOL_URL_ROOT.'/comm/multiprix.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
}
print '</td></tr></table>';
print '</td><td colspan="3">'.$object->price_level."</td>";
print '</tr>';
}
// Status
print '<tr><td>'.$langs->trans("StatusProsp").'</td><td colspan="2">'.$object->getLibProspStatut(4).'</td>';
print '<td>';
if ($object->stcomm_id != -1) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=-1&amp;action=cstc">'.img_action(0,-1).'</a>';
if ($object->stcomm_id != 0) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=0&amp;action=cstc">'.img_action(0,0).'</a>';
if ($object->stcomm_id != 1) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=1&amp;action=cstc">'.img_action(0,1).'</a>';
if ($object->stcomm_id != 2) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=2&amp;action=cstc">'.img_action(0,2).'</a>';
if ($object->stcomm_id != 3) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=3&amp;action=cstc">'.img_action(0,3).'</a>';
print '</td></tr>';
// Sales representative
include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php';
// Module Adherent
if (! empty($conf->adherent->enabled))
{
$langs->load("members");
$langs->load("users");
print '<tr><td width="25%" valign="top">'.$langs->trans("LinkedToDolibarrMember").'</td>';
print '<td colspan="3">';
$adh=new Adherent($db);
$result=$adh->fetch('','',$object->id);
if ($result > 0)
{
$adh->ref=$adh->getFullName($langs);
print $adh->getNomUrl(1);
}
else
{
print $langs->trans("UserNotLinkedToMember");
}
print '</td>';
print "</tr>\n";
}
print '</table>';
print "</td>\n";
print '<td valign="top" width="50%" class="notopnoleftnoright">';
// Nbre max d'elements des petites listes
$MAXLIST=5;
$tableaushown=0;
// Lien recap
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("Summary").'</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/comm/prospect/recap-prospect.php?socid='.$object->id.'">'.$langs->trans("ShowProspectPreview").'</a></td></tr></table></td>';
print '</tr>';
print '</table>';
print '<br>';
/*
* Last proposals
*/
if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
{
$propal_static=new Propal($db);
$sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, ";
$sql.= " p.datep as dp, p.fin_validite as datelimite,";
$sql.= " c.label as statut, c.id as statutid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
$sql.= ", ".MAIN_DB_PREFIX."c_propalst as c";
$sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND p.fk_statut = c.id";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND s.rowid = ".$object->id;
$sql.= " ORDER BY p.datep DESC";
$resql=$db->query($sql);
if ($resql)
{
$var=true;
$i = 0;
$num = $db->num_rows($resql);
if ($num > 0)
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal.php?socid='.$object->id.'">'.$langs->trans("AllPropals").' ('.$num.')</a></td>';
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
print '</tr></table></td>';
print '</tr>';
}
while ($i < $num && $i < $MAXLIST)
{
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print "<td><a href=\"../propal.php?id=$objp->propalid\">";
print img_object($langs->trans("ShowPropal"),"propal");
print " ".$objp->ref."</a>\n";
if ($db->jdate($objp->dp) < ($now - $conf->propal->cloture->warning_delay) && $objp->fk_statut == 1)
{
print " ".img_warning();
}
print "</td><td align=\"right\">".dol_print_date($db->jdate($objp->dp),"day")."</td>\n";
print "<td align=\"right\">".price($objp->total_ht)."</td>\n";
print "<td align=\"right\">".$propal_static->LibStatut($objp->fk_statut,5)."</td></tr>\n";
$i++;
}
$db->free();
if ($num > 0) print "</table>";
}
else
{
dol_print_error($db);
}
}
print "</td></tr>";
print "</table>\n";
dol_fiche_end();
/*
* Barre d'action
*/
print '<div class="tabsAction">';
if (! empty($conf->propal->enabled) && $user->rights->propale->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddProp").'</a>';
}
// Add action
if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
{
if ($user->rights->agenda->myactions->create)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$object->id.'">'.$langs->trans("AddAction").'</a>';
}
else
{
print '<a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a>';
}
}
print '</div>';
print '<br>';
if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB))
{
print '<br>';
// List of contacts
show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
}
if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
{
print load_fiche_titre($langs->trans("ActionsOnCompany"),'','');
// List of todo actions
show_actions_todo($conf,$langs,$db,$object);
// List of done actions
show_actions_done($conf,$langs,$db,$object);
}
}
llxFooter();
$db->close();
?>

View File

@ -148,8 +148,6 @@ $sts = array(-1,0,1,2,3);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('prospectlist'));
@ -391,6 +389,7 @@ if ($resql)
$prospectstatic->id=$obj->rowid;
$prospectstatic->nom=$obj->nom;
$prospectstatic->status=$obj->status;
$prospectstatic->fk_prospectlevel=$obj->fk_prospectlevel;
print $prospectstatic->getNomUrl(1,'prospect');
print '</td>';
print "<td>".$obj->zip."&nbsp;</td>";
@ -400,7 +399,7 @@ if ($resql)
print '<td align="center">'.dol_print_date($db->jdate($obj->datec)).'</td>';
// Level
print '<td align="center">';
print $prospectstatic->LibLevel($obj->fk_prospectlevel);
print $prospectstatic->getLibProspLevel();
print "</td>";
// Statut
print '<td align="center" nowrap="nowrap">';
@ -421,7 +420,7 @@ if ($resql)
print '</td>';
print '<td align="right">';
print $prospectstatic->getLibStatut(3);
print $prospectstatic->LibStatut($prospectstatic->status,3);
print '</td>';
$parameters=array('obj' => $obj);

View File

@ -66,7 +66,7 @@ class Commande extends CommonOrder
var $demand_reason_id;
var $demand_reason_code;
var $fk_delivery_address;
var $adresse;
var $address;
var $date; // Date commande
var $date_commande; // Date commande (deprecated)
var $date_livraison; // Date livraison souhaitee
@ -631,7 +631,7 @@ class Commande extends CommonOrder
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande (";
$sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, note_public, ref_client, ref_int";
$sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_availability, fk_input_reason, date_livraison, fk_adresse_livraison";
$sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_availability, fk_input_reason, date_livraison, fk_delivery_address";
$sql.= ", remise_absolue, remise_percent";
$sql.= ", entity";
$sql.= ")";
@ -794,12 +794,11 @@ class Commande extends CommonOrder
* Load an object from its id and create a new one in database
*
* @param int $socid Id of thirdparty
* @param HookManager $hookmanager Hook manager instance
* @return int New id of clone
*/
function createFromClone($socid=0,$hookmanager=false)
function createFromClone($socid=0)
{
global $conf,$user,$langs;
global $conf,$user,$langs,$hookmanager;
$error=0;
@ -880,8 +879,7 @@ class Commande extends CommonOrder
*/
function createFromProposal($object)
{
global $conf,$user,$langs;
global $hookmanager;
global $conf,$user,$langs,$hookmanager;
$error=0;
@ -945,11 +943,6 @@ class Commande extends CommonOrder
if ($ret > 0)
{
// Actions hooked (by external module)
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('orderdao'));
$parameters=array('objFrom'=>$object);
@ -1247,7 +1240,7 @@ class Commande extends CommonOrder
$sql.= ', c.date_commande';
$sql.= ', c.date_livraison';
$sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed';
$sql.= ', c.note as note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_adresse_livraison, c.extraparams';
$sql.= ', c.note as note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_delivery_address, c.extraparams';
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc';
$sql.= ', ca.code as availability_code';
@ -1308,7 +1301,7 @@ class Commande extends CommonOrder
$this->demand_reason_id = $obj->fk_input_reason;
$this->demand_reason_code = $obj->demand_reason_code;
$this->date_livraison = $this->db->jdate($obj->date_livraison);
$this->fk_delivery_address = $obj->fk_adresse_livraison;
$this->fk_delivery_address = $obj->fk_delivery_address;
$this->extraparams = (array) json_decode($obj->extraparams, true);

View File

@ -84,8 +84,6 @@ if ($id > 0 || ! empty($ref))
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('ordercard'));
@ -107,7 +105,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->
{
if ($object->id > 0)
{
$result=$object->createFromClone($socid, $hookmanager);
$result=$object->createFromClone($socid);
if ($result > 0)
{
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
@ -174,7 +172,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($object->id); // Reload to get new records
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
@ -204,7 +202,7 @@ else if ($action == 'add' && $user->rights->commande->creer)
$action='create';
$error++;
}
if ($socid<1)
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Customer")),'errors');
@ -506,7 +504,7 @@ else if ($action == 'setconditions' && $user->rights->commande->creer)
}
$ret=$object->fetch($object->id); // Reload to get new records
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
}
@ -745,7 +743,7 @@ else if ($action == 'addline' && $user->rights->commande->creer)
}
$ret=$object->fetch($object->id); // Reload to get new records
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
unset($_POST['qty']);
@ -872,7 +870,7 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('
}
$ret=$object->fetch($object->id); // Reload to get new records
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
unset($_POST['qty']);
@ -931,7 +929,7 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->co
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
}
@ -970,7 +968,7 @@ else if ($action == 'confirm_modif' && $user->rights->commande->creer)
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($object->id); // Reload to get new records
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
}
@ -1023,7 +1021,7 @@ else if ($action == 'up' && $user->rights->commande->creer)
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid'));
exit;
@ -1043,7 +1041,7 @@ else if ($action == 'down' && $user->rights->commande->creer)
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid'));
exit;
@ -1072,7 +1070,7 @@ else if ($action == 'builddoc') // In get or post
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
$result=commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
$result=commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0)
{
@ -1493,7 +1491,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
print "<tr><td>".$langs->trans("DefaultContact").'</td><td colspan="2">';
$form->select_contacts($soc->id,$setcontact,'contactidp',1,$srccontactslist);
print '</td></tr>';
// Ligne info remises tiers
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="2">';
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
@ -1686,7 +1684,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
print '<table class="noborder" width="100%">';
$objectsrc->printOriginLinesList($hookmanager);
$objectsrc->printOriginLinesList();
print '</table>';
}
@ -2168,7 +2166,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
// Show object lines
if (! empty($object->lines))
$ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager);
$ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1);
/*
* Form to add new line
@ -2182,18 +2180,18 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
if ($conf->global->MAIN_FEATURES_LEVEL > 1)
{
// Add free or predefined products/services
$object->formAddObjectLine(1,$mysoc,$soc,$hookmanager);
$object->formAddObjectLine(1,$mysoc,$soc);
}
else
{
// Add free products/services
$object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager);
$object->formAddFreeProduct(1,$mysoc,$soc);
// Add predefined products/services
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
{
$var=!$var;
$object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager);
$object->formAddPredefinedProduct(1,$mysoc,$soc);
}
}
@ -2356,7 +2354,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
$genallowed=$user->rights->commande->creer;
$delallowed=$user->rights->commande->supprimer;
$somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$hookmanager);
$somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
/*
* Linked object block
@ -2399,7 +2397,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
$outputlangs->setDefaultLang($newlang);
}
$result=commande_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
$result=commande_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0)
{
dol_print_error($db,$result);
@ -2420,12 +2418,11 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
$formmail->fromname = $user->getFullName($langs);
$formmail->frommail = $user->email;
$formmail->withfrom=1;
$formmail->withto=GETPOST('sendto')?GETPOST('sendto'):1;
$formmail->withtosocid=$soc->id;
$formmail->withtocc=1;
$formmail->withtoccsocid=0;
$liste=array();
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value;
$formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$liste;
$formmail->withtocc=$liste;
$formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
$formmail->withtocccsocid=0;
$formmail->withtopic=$langs->trans('SendOrderRef','__ORDERREF__');
$formmail->withfile=2;
$formmail->withbody=1;

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com>
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -38,6 +39,7 @@ print_titre($langs->trans('RelatedOrders'));
</tr>
<?php
$var=true;
$total=0;
foreach($linkedObjectBlock as $object)
{
$var=!$var;

View File

@ -0,0 +1,171 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/deplacement/document.php
* \ingroup deplacement
* \brief Page of linked files onto trip and expenses
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.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/lib/trip.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$langs->load("other");
$langs->load("trips");
$langs->load("companies");
$langs->load("interventions");
$id = GETPOST('id','int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'deplacement', $id, '');
// 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 Deplacement($db);
$object->fetch($id, $ref);
$upload_dir = $conf->deplacement->dir_output.'/'.dol_sanitizeFileName($object->ref);
$modulepart='trip';
/*
* Actions
*/
if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_add_file_process($upload_dir,0,1,'userfile');
}
// Delete
else if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->id > 0)
{
$langs->load("other");
$object->fetch_thirdparty();
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}
/*
* View
*/
$form = new Form($db);
llxHeader("","",$langs->trans("TripCard"));
if ($object->id)
{
$object->fetch_thirdparty();
$head=trip_prepare_head($object, $user);
dol_fiche_head($head, 'documents', $langs->trans("TripCard"), 0, 'trip');
// 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 '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/deplacement/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
print '</td></tr>';
// Societe
//print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>";
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
/*
* Confirmation suppression fichier
*/
if ($action == 'delete')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
if ($ret == 'html') print '<br>';
}
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/deplacement/document.php?id='.$object->id,'',0,0,$user->rights->deplacement->creer,50,$object);
// List of document
$param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'deplacement',$param);
}
else
{
print $langs->trans("UnkownError");
}
llxFooter();
$db->close();
?>

View File

@ -49,8 +49,6 @@ $mesg = '';
$object = new Deplacement($db);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('tripsandexpensescard'));
@ -522,7 +520,7 @@ else if ($id)
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$parameters=array('colspan' => ' colspan="3"', 'showblocbydefault' => 1);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
print "</table><br>";
@ -578,7 +576,8 @@ else if ($id)
}
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -42,7 +42,7 @@ class Don extends CommonObject
var $prenom;
var $nom;
var $societe;
var $adresse;
var $address;
var $cp;
var $ville;
var $pays;
@ -188,7 +188,7 @@ class Don extends CommonObject
$this->amount = 100;
$this->public = 1;
$this->societe = 'The Company';
$this->adresse = 'Twist road';
$this->address = 'Twist road';
$this->cp = '99999';
$this->ville = 'Town';
$this->note_public='SPECIMEN';
@ -217,7 +217,7 @@ class Don extends CommonObject
}
}
if (dol_strlen(trim($this->adresse)) == 0)
if (dol_strlen(trim($this->address)) == 0)
{
$error_string[$err] = "L'adresse saisie est invalide";
$err++;
@ -297,7 +297,7 @@ class Don extends CommonObject
global $conf;
// Clean parameters
$this->address=($this->address>0?$this->address:$this->adresse);
$this->address=($this->address>0?$this->address:$this->address);
$this->zip=($this->zip>0?$this->zip:$this->cp);
$this->town=($this->town>0?$this->town:$this->ville);
$this->country_id=($this->country_id>0?$this->country_id:$this->fk_pays);
@ -313,7 +313,7 @@ class Don extends CommonObject
$sql.= ", prenom";
$sql.= ", nom";
$sql.= ", societe";
$sql.= ", adresse";
$sql.= ", address";
$sql.= ", cp";
$sql.= ", ville";
$sql.= ", pays";
@ -334,7 +334,7 @@ class Don extends CommonObject
$sql.= ", '".$this->db->escape($this->prenom)."'";
$sql.= ", '".$this->db->escape($this->nom)."'";
$sql.= ", '".$this->db->escape($this->societe)."'";
$sql.= ", '".$this->db->escape($this->adresse)."'";
$sql.= ", '".$this->db->escape($this->address)."'";
$sql.= ", '".$this->db->escape($this->zip)."'";
$sql.= ", '".$this->db->escape($this->town)."'";
$sql.= ", '".$this->db->escape($this->country)."'"; // TODO use country_id
@ -382,7 +382,7 @@ class Don extends CommonObject
function update($user)
{
// Clean parameters
$this->address=($this->address>0?$this->address:$this->adresse);
$this->address=($this->address>0?$this->address:$this->address);
$this->zip=($this->zip>0?$this->zip:$this->cp);
$this->town=($this->town>0?$this->town:$this->ville);
$this->country_id=($this->country_id>0?$this->country_id:$this->fk_pays);
@ -394,7 +394,7 @@ class Don extends CommonObject
$sql .= ",prenom = '".$this->db->escape($this->prenom)."'";
$sql .= ",nom='".$this->db->escape($this->nom)."'";
$sql .= ",societe='".$this->db->escape($this->societe)."'";
$sql .= ",adresse='".$this->db->escape($this->address)."'";
$sql .= ",address='".$this->db->escape($this->address)."'";
$sql .= ",cp='".$this->db->escape($this->zip)."'";
$sql .= ",ville='".$this->db->escape($this->town)."'";
$sql .= ",pays='".$this->db->escape($this->country)."'"; // TODO use country_id
@ -463,7 +463,7 @@ class Don extends CommonObject
global $conf;
$sql = "SELECT d.rowid, d.datec, d.tms as datem, d.datedon,";
$sql.= " d.prenom, d.nom, d.societe, d.amount, d.fk_statut, d.adresse, d.cp, d.ville, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.phone, d.phone_mobile, d.fk_don_projet,";
$sql.= " d.prenom, d.nom, d.societe, d.amount, d.fk_statut, d.address, d.cp, d.ville, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.phone, d.phone_mobile, d.fk_don_projet,";
$sql.= " p.title as project_label";
$sql.= " FROM ".MAIN_DB_PREFIX."don as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_don_projet";
@ -487,7 +487,7 @@ class Don extends CommonObject
$this->nom = $obj->nom;
$this->societe = $obj->societe;
$this->statut = $obj->fk_statut;
$this->adresse = $obj->adresse;
$this->address = $obj->address;
$this->cp = $obj->cp;
$this->ville = $obj->ville;
$this->zip = $obj->cp;

View File

@ -50,8 +50,6 @@ $donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOS
$result = restrictedArea($user, 'don', $id);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('doncard'));
@ -90,7 +88,7 @@ if ($action == 'update')
$don->prenom = $_POST["prenom"];
$don->nom = $_POST["nom"];
$don->societe = $_POST["societe"];
$don->adresse = $_POST["adresse"];
$don->address = $_POST["address"];
$don->amount = price2num($_POST["amount"]);
$don->cp = $_POST["zipcode"];
$don->ville = $_POST["town"];
@ -142,7 +140,7 @@ if ($action == 'add')
$don->prenom = $_POST["prenom"];
$don->nom = $_POST["nom"];
$don->societe = $_POST["societe"];
$don->adresse = $_POST["adresse"];
$don->address = $_POST["address"];
$don->amount = price2num($_POST["amount"]);
$don->cp = $_POST["zipcode"];
$don->ville = $_POST["town"];
@ -302,7 +300,7 @@ if ($action == 'create')
print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td><input type="text" name="prenom" value="'.$_POST["prenom"].'" size="40"></td></tr>';
print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td><input type="text" name="nom" value="'.$_POST["nom"].'" size="40"></td></tr>';
print "<tr>".'<td>'.$langs->trans("Address").'</td><td>';
print '<textarea name="adresse" wrap="soft" cols="40" rows="3">'.$_POST["adresse"].'</textarea></td></tr>';
print '<textarea name="address" wrap="soft" cols="40" rows="3">'.$_POST["address"].'</textarea></td></tr>';
// Zip / Town
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
@ -392,7 +390,7 @@ if (! empty($id) && $action == 'edit')
print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td><input type="text" name="prenom" size="40" value="'.$don->prenom.'"></td></tr>';
print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td><input type="text" name="nom" size="40" value="'.$don->nom.'"></td></tr>';
print "<tr>".'<td>'.$langs->trans("Address").'</td><td>';
print '<textarea name="adresse" wrap="soft" cols="40" rows="'.ROWS_3.'">'.$don->adresse.'</textarea></td></tr>';
print '<textarea name="address" wrap="soft" cols="40" rows="'.ROWS_3.'">'.$don->address.'</textarea></td></tr>';
// Zip / Town
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
@ -487,7 +485,7 @@ if (! empty($id) && $action != 'edit')
print "<tr>".'<td>'.$langs->trans("Company").'</td><td>'.$don->societe.'</td></tr>';
print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td>'.$don->prenom.'</td></tr>';
print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td>'.$don->nom.'</td></tr>';
print "<tr>".'<td>'.$langs->trans("Address").'</td><td>'.dol_nl2br($don->adresse).'</td></tr>';
print "<tr>".'<td>'.$langs->trans("Address").'</td><td>'.dol_nl2br($don->address).'</td></tr>';
// Zip / Town
print "<tr>".'<td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>'.$don->cp.($don->cp && $don->ville?' / ':'').$don->ville.'</td></tr>';

View File

@ -95,8 +95,6 @@ if ($id > 0 || ! empty($ref))
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('invoicecard'));
@ -119,7 +117,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->c
{
if ($object->fetch($id) > 0)
{
$result=$object->createFromClone($socid, $hookmanager);
$result=$object->createFromClone($socid);
if ($result > 0)
{
header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result);
@ -193,7 +191,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
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, $hidedetails, $hidedesc, $hideref, $hookmanager);
$result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
if ($result >= 0)
{
@ -396,7 +394,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
else
@ -473,7 +471,7 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
}
@ -1186,7 +1184,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
}
$ret=$object->fetch($id); // Reload to get new records
facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
unset($_POST['qty']);
@ -1316,7 +1314,7 @@ else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['sa
}
$ret=$object->fetch($id); // Reload to get new records
facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
unset($_POST['qty']);
@ -1362,7 +1360,7 @@ else if ($action == 'up' && $user->rights->facture->creer)
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']);
exit;
@ -1384,7 +1382,7 @@ else if ($action == 'down' && $user->rights->facture->creer)
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']);
exit;
@ -1616,7 +1614,7 @@ else if ($action == 'builddoc') // En get ou en post
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
$result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
$result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0)
{
dol_print_error($db,$result);
@ -1917,14 +1915,6 @@ if ($action == 'create')
print $desc;
print '</td></tr>'."\n";
// Deposit
print '<tr height="18"><td width="16px" valign="middle">';
print '<input type="radio" name="type" value="3"'.(GETPOST('type')==3?' checked="checked"':'').'>';
print '</td><td valign="middle">';
$desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1);
print $desc;
print '</td></tr>'."\n";
// Proforma
if (! empty($conf->global->FACTURE_USE_PROFORMAT))
{
@ -1936,7 +1926,18 @@ if ($action == 'create')
print '</td></tr>'."\n";
}
if ($socid>0)
if (empty($origin))
{
// Deposit
print '<tr height="18"><td width="16px" valign="middle">';
print '<input type="radio" name="type" value="3"'.(GETPOST('type')==3?' checked="checked"':'').'>';
print '</td><td valign="middle">';
$desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1);
print $desc;
print '</td></tr>'."\n";
}
if ($socid > 0)
{
// Replacement
print '<tr height="18"><td valign="middle">';
@ -1961,8 +1962,11 @@ if ($action == 'create')
$desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1);
print $desc;
print '</td></tr>'."\n";
}
// Credit note
if (empty($origin) && $socid > 0)
{
// Credit note
print '<tr height="18"><td valign="middle">';
print '<input type="radio" name="type" value="2"'.(GETPOST('type')==2?' checked=true':'');
if (! $optionsav) print ' disabled="disabled"';
@ -1986,11 +1990,12 @@ if ($action == 'create')
$desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1);
print $desc;
print '</td></tr>'."\n";
}
}
print '</table>';
print '</td></tr>';
if($socid>0)
if ($socid > 0)
{
// Discounts for third party
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="2">';
@ -2188,7 +2193,7 @@ if ($action == 'create')
print '<table class="noborder" width="100%">';
$objectsrc->printOriginLinesList($hookmanager);
$objectsrc->printOriginLinesList();
print '</table>';
}
@ -3056,7 +3061,7 @@ else if ($id > 0 || ! empty($ref))
// Show object lines
if (! empty($object->lines))
$ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager);
$ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1);
/*
* Form to add new line
@ -3068,18 +3073,18 @@ else if ($id > 0 || ! empty($ref))
if ($conf->global->MAIN_FEATURES_LEVEL > 1)
{
// Add free or predefined products/services
$object->formAddObjectLine(1,$mysoc,$soc,$hookmanager);
$object->formAddObjectLine(1,$mysoc,$soc);
}
else
{
// Add free products/services
$object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager);
$object->formAddFreeProduct(1,$mysoc,$soc);
// Add predefined products/services
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
{
$var=!$var;
$object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager);
$object->formAddPredefinedProduct(1,$mysoc,$soc);
}
}
@ -3319,7 +3324,7 @@ else if ($id > 0 || ! empty($ref))
$delallowed=$user->rights->facture->supprimer;
print '<br>';
print $formfile->showdocuments('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$hookmanager);
print $formfile->showdocuments('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
$somethingshown=$formfile->numoffiles;
/*
@ -3384,7 +3389,7 @@ else if ($id > 0 || ! empty($ref))
$outputlangs->setDefaultLang($newlang);
}
$result=facture_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
$result=facture_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0)
{
dol_print_error($db,$result);
@ -3405,12 +3410,11 @@ else if ($id > 0 || ! empty($ref))
$formmail->fromname = $user->getFullName($langs);
$formmail->frommail = $user->email;
$formmail->withfrom=1;
$formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"];
$formmail->withtosocid=$soc->id;
$formmail->withtocc=1;
$formmail->withtoccsocid=0;
$liste=array();
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value;
$formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$liste;
$formmail->withtocc=$liste;
$formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
$formmail->withtocccsocid=0;
$formmail->withtopic=$langs->transnoentities($topicmail,'__FACREF__');
$formmail->withfile=2;
$formmail->withbody=1;

View File

@ -541,7 +541,7 @@ class Facture extends CommonInvoice
* @param HookManager $hookmanager Hook manager instance
* @return int New id of clone
*/
function createFromClone($socid=0,$hookmanager=false)
function createFromClone($socid=0)
{
global $conf,$user,$langs;
@ -637,7 +637,7 @@ class Facture extends CommonInvoice
*/
function createFromOrder($object)
{
global $conf,$user,$langs;
global $conf,$user,$langs,$hookmanager;
$error=0;
@ -701,8 +701,6 @@ class Facture extends CommonInvoice
if ($ret > 0)
{
// Actions hooked (by external module)
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager->initHooks(array('invoicedao'));
$parameters=array('objFrom'=>$object);
@ -1831,6 +1829,8 @@ class Facture extends CommonInvoice
if ($error == 0)
{
$this->brouillon = 1;
$this->statut = 0;
$this->db->commit();
return 1;
}

View File

@ -97,8 +97,6 @@ $usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MA
$object=new Facture($db);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('invoicecard'));
$now=dol_now();

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com>
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -38,6 +39,7 @@ else print_titre($langs->trans("RelatedBill"));
</tr>
<?php
$var=true;
$total=0;
foreach($linkedObjectBlock as $object)
{
$var=!$var;

View File

@ -112,7 +112,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture->
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs);
}
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id);

View File

@ -94,7 +94,7 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' &&
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs);
}
header('Location: fiche.php?id='.$paiement->id);

View File

@ -41,8 +41,6 @@ if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('taxvatcard'));

View File

@ -210,7 +210,7 @@ class Contact extends CommonObject
*/
function update($id, $user=0, $notrigger=0, $action='update')
{
global $conf, $langs;
global $conf, $langs, $hookmanager;
$error=0;
@ -266,8 +266,6 @@ class Contact extends CommonObject
unset($this->state);
// Actions on extra fields (by external module or standard code)
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager->initHooks(array('contactdao'));
$parameters=array('socid'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
@ -522,7 +520,7 @@ class Contact extends CommonObject
$this->prenom = $obj->firstname; // TODO deprecated
$this->address = $obj->address;
$this->adresse = $obj->address; // TODO deprecated
//$this->adresse = $obj->address; // TODO deprecated
$this->cp = $obj->zip; // TODO deprecated
$this->zip = $obj->zip;
$this->ville = $obj->town; // TODO deprecated

View File

@ -65,8 +65,6 @@ if (! empty($canvas))
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', '', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('contactcard'));
@ -385,7 +383,7 @@ else
});
$("#copyaddressfromsoc").click(function() {
$(\'textarea[name="address"]\').text("'.dol_escape_js($objsoc->address).'");
$(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).'");
$(\'input[name="zipcode"]\').val("'.dol_escape_js($objsoc->zip).'");
$(\'input[name="town"]\').val("'.dol_escape_js($objsoc->town).'");
$(\'select[name="country_id"]\').val("'.dol_escape_js($objsoc->country_id).'");

View File

@ -65,16 +65,11 @@ $offset = $limit * $page;
$langs->load("companies");
$titre = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses"));
if ($type == "c")
if ($type == "c" || $type=="p")
{
$titre.=' ('.$langs->trans("ThirdPartyCustomers").')';
$urlfiche="fiche.php";
}
else if ($type == "p")
{
$titre.=' ('.$langs->trans("ThirdPartyProspects").')';
$urlfiche="prospect/fiche.php";
}
else if ($type == "f")
{
$titre.=' ('.$langs->trans("ThirdPartySuppliers").')';

View File

@ -5,6 +5,7 @@
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
*
* 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
@ -27,7 +28,7 @@
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
require_once(DOL_DOCUMENT_ROOT ."/margin/lib/margins.lib.php");
/**
* Class to manage contracts
@ -402,7 +403,7 @@ class Contrat extends CommonObject
// Selectionne les lignes contrats liees a un produit
$sql = "SELECT p.label, p.description as product_desc, p.ref,";
$sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.remise_percent, d.subprice,";
$sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,";
$sql.= " d.total_ht,";
$sql.= " d.total_tva,";
$sql.= " d.total_localtax1,";
@ -451,6 +452,10 @@ class Contrat extends CommonObject
$line->fk_product = $objp->fk_product;
$line->info_bits = $objp->info_bits;
$line->fk_fournprice = $objp->fk_fournprice;
$marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
$line->pa_ht = $marginInfos[0];
$line->fk_user_author = $objp->fk_user_author;
$line->fk_user_ouverture= $objp->fk_user_ouverture;
$line->fk_user_cloture = $objp->fk_user_cloture;
@ -856,7 +861,7 @@ class Contrat extends CommonObject
* @param int $info_bits Bits de type de lignes
* @return int <0 si erreur, >0 si ok
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0, $info_bits=0)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0)
{
global $user, $langs, $conf;
@ -875,6 +880,7 @@ class Contrat extends CommonObject
if (! $pu_ttc) $pu_ttc=0;
$pu_ht=price2num($pu_ht);
$pu_ttc=price2num($pu_ttc);
$pa_ht=price2num($pa_ht);
$txtva=price2num($txtva);
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
@ -908,13 +914,21 @@ class Contrat extends CommonObject
$price = $pu_ht - $remise;
}
if (empty($pa_ht)) $pa_ht=0;
// si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente
if ($pa_ht == 0) {
if ($pu_ht > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$pa_ht = $pu_ht * (1 - $remise_percent / 100);
}
// Insertion dans la base
$sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet";
$sql.= " (fk_contrat, label, description, fk_product, qty, tva_tx,";
$sql.= " localtax1_tx, localtax2_tx, remise_percent, subprice,";
$sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,";
$sql.= " info_bits,";
$sql.= " price_ht, remise"; // TODO A virer
$sql.= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht";
if ($date_start > 0) { $sql.= ",date_ouverture_prevue"; }
if ($date_end > 0) { $sql.= ",date_fin_validite"; }
$sql.= ") VALUES ($this->id, '', '" . $this->db->escape($desc) . "',";
@ -926,7 +940,11 @@ class Contrat extends CommonObject
$sql.= " ".price2num($remise_percent).",".price2num($pu_ht).",";
$sql.= " ".price2num($total_ht).",".price2num($total_tva).",".price2num($total_localtax1).",".price2num($total_localtax2).",".price2num($total_ttc).",";
$sql.= " '".$info_bits."',";
$sql.= " ".price2num($price).",".price2num($remise); // TODO A virer
$sql.= " ".price2num($price).",".price2num($remise).",";
if (isset($fk_fournprice)) $sql.= ' '.$fk_fournprice.',';
else $sql.= ' null,';
if (isset($pa_ht)) $sql.= ' '.price2num($pa_ht);
else $sql.= ' null';
if ($date_start > 0) { $sql.= ",'".$this->db->idate($date_start)."'"; }
if ($date_end > 0) { $sql.= ",'".$this->db->idate($date_end)."'"; }
$sql.= ")";
@ -983,7 +1001,7 @@ class Contrat extends CommonObject
* @param int $info_bits Bits de type de lignes
* @return int < 0 si erreur, > 0 si ok
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0, $localtax2tx=0, $date_debut_reel='', $date_fin_reel='', $price_base_type='HT', $info_bits=0)
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0, $localtax2tx=0, $date_debut_reel='', $date_fin_reel='', $price_base_type='HT', $info_bits=0, $fk_fournprice=null, $pa_ht = 0)
{
global $user, $conf, $langs;
@ -995,6 +1013,7 @@ class Contrat extends CommonObject
$tvatx = price2num($tvatx);
$localtax1tx = price2num($localtax1tx);
$localtax2tx = price2num($localtax2tx);
$pa_ht=price2num($pa_ht);
$subprice = $price;
$remise = 0;
@ -1016,7 +1035,7 @@ class Contrat extends CommonObject
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $localtaxtx1, $txlocaltaxtx2, 0, $price_base_type, $info_bits, 1);
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtaxtx1, $txlocaltaxtx2, 0, $price_base_type, $info_bits, 1);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
@ -1032,6 +1051,14 @@ class Contrat extends CommonObject
$price = $pu_ht - $remise;
}
if (empty($pa_ht)) $pa_ht=0;
// si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente
if ($pa_ht == 0) {
if ($pu_ht > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$pa_ht = $pu_ht * (1 - $remise_percent / 100);
}
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".$this->db->escape($desc)."'";
$sql.= ",price_ht='" . price2num($price)."'";
$sql.= ",subprice='" . price2num($subprice)."'";
@ -1046,6 +1073,8 @@ class Contrat extends CommonObject
$sql.= ", total_localtax1='".price2num($total_localtax1)."'";
$sql.= ", total_localtax2='".price2num($total_localtax2)."'";
$sql.= ", total_ttc='". price2num($total_ttc)."'";
$sql.= ", fk_product_fournisseur_price='".$fk_fournprice."'";
$sql.= ", buy_price_ht='".price2num($pa_ht)."'";
if ($date_start > 0) { $sql.= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; }
else { $sql.=",date_ouverture_prevue=null"; }
if ($date_end > 0) { $sql.= ",date_fin_validite='".$this->db->idate($date_end)."'"; }
@ -1610,6 +1639,9 @@ class ContratLigne
var $total_localtax2;
var $total_ttc;
var $fk_fournprice;
var $pa_ht;
var $info_bits;
var $fk_user_author;
var $fk_user_ouverture;
@ -1769,6 +1801,8 @@ class ContratLigne
$sql.= " t.total_localtax1,";
$sql.= " t.total_localtax2,";
$sql.= " t.total_ttc,";
$sql.= " t.fk_product_fournisseur_price as fk_fournprice,";
$sql.= " t.buy_price_ht as pa_ht,";
$sql.= " t.info_bits,";
$sql.= " t.fk_user_author,";
$sql.= " t.fk_user_ouverture,";
@ -1819,6 +1853,9 @@ class ContratLigne
$this->fk_user_ouverture = $obj->fk_user_ouverture;
$this->fk_user_cloture = $obj->fk_user_cloture;
$this->commentaire = $obj->commentaire;
$this->fk_fournprice = $obj->fk_fournprice;
$marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->fk_fournprice, $obj->pa_ht);
$this->pa_ht = $marginInfos[0];
}
$this->db->free($resql);
@ -1887,6 +1924,14 @@ class ContratLigne
$this->total_localtax1= $tabprice[9];
$this->total_localtax2= $tabprice[10];
if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigné et utilisé pour calcul des marges alors prix achat = prix vente
if ($this->pa_ht == 0) {
if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
}
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET";
$sql.= " fk_contrat='".$this->fk_contrat."',";
@ -1913,6 +1958,8 @@ class ContratLigne
$sql.= " total_localtax1='".$this->total_localtax1."',";
$sql.= " total_localtax2='".$this->total_localtax2."',";
$sql.= " total_ttc='".$this->total_ttc."',";
$sql.= " fk_product_fournisseur_price='".$this->fk_fournprice."',";
$sql.= " buy_price_ht='".price2num($this->pa_ht)."',";
$sql.= " info_bits='".$this->info_bits."',";
$sql.= " fk_user_author=".($this->fk_user_author >= 0?$this->fk_user_author:"NULL").",";
$sql.= " fk_user_ouverture=".($this->fk_user_ouverture > 0?$this->fk_user_ouverture:"NULL").",";

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
*
* 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
@ -59,8 +60,6 @@ $result=restrictedArea($user,'contrat',$id);
$usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('contractcard'));
$object = new Contrat($db);
@ -211,7 +210,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")),'errors');
$error++;
}
if (! $error)
{
$ret=$object->fetch($id);
@ -307,6 +306,13 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
$localtax1_tx=get_localtax($tva_tx,1,$object->societe);
$localtax2_tx=get_localtax($tva_tx,2,$object->societe);
// ajout prix achat
$fk_fournprice = $_POST['fournprice'];
if ( ! empty($_POST['buying_price']) )
$pa_ht = $_POST['buying_price'];
else
$pa_ht = null;
$info_bits=0;
if ($tva_npr) $info_bits |= 0x01;
@ -331,7 +337,9 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
$date_end,
$price_base_type,
$pu_ttc,
$info_bits
$info_bits,
$fk_fournprice,
$pa_ht
);
}
@ -355,13 +363,18 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
}
*/
unset($_POST['qty']);
unset($_POST['type']);
unset($_POST['idprod']);
unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['tva_tx']);
unset($_POST['dp_desc']);
unset($_POST['qty']);
unset($_POST['type']);
unset($_POST['idprod']);
unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['product_ref']);
unset($_POST['product_label']);
unset($_POST['product_desc']);
unset($_POST['fournprice']);
unset($_POST['buying_price']);
}
else
{
@ -391,6 +404,13 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST(
$localtax1_tx=get_localtax(GETPOST('eltva_tx'),1,$object->thirdparty);
$localtax2_tx=get_localtax(GETPOST('eltva_tx'),2,$object->thirdparty);
// ajout prix d'achat
$fk_fournprice = $_POST['fournprice'];
if ( ! empty($_POST['buying_price']) )
$pa_ht = $_POST['buying_price'];
else
$pa_ht = null;
$objectline->description=GETPOST('product_desc');
$objectline->price_ht=GETPOST('elprice');
$objectline->subprice=GETPOST('elprice');
@ -404,6 +424,8 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST(
$objectline->date_fin_validite=$date_end_update;
$objectline->date_cloture=$date_end_real_update;
$objectline->fk_user_cloture=$user->id;
$objectline->fk_fournprice=$fk_fournprice;
$objectline->pa_ht=$pa_ht;
// TODO verifier price_min si fk_product et multiprix
@ -874,7 +896,7 @@ else
$sql.= " cd.tva_tx, cd.remise_percent, cd.info_bits, cd.subprice,";
$sql.= " cd.date_ouverture_prevue as date_debut, cd.date_ouverture as date_debut_reelle,";
$sql.= " cd.date_fin_validite as date_fin, cd.date_cloture as date_fin_reelle,";
$sql.= " cd.commentaire as comment,";
$sql.= " cd.commentaire as comment, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht,";
$sql.= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype";
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
@ -891,6 +913,8 @@ else
print '<td width="50" align="right">'.$langs->trans("PriceUHT").'</td>';
print '<td width="30" align="center">'.$langs->trans("Qty").'</td>';
print '<td width="50" align="right">'.$langs->trans("ReductionShort").'</td>';
if ($conf->margin->enabled)
print '<td width="50" align="right">'.$langs->trans("BuyingPrice").'</td>';
print '<td width="30">&nbsp;</td>';
print "</tr>\n";
@ -934,6 +958,10 @@ else
{
print '<td>&nbsp;</td>';
}
if ($conf->margin->enabled)
print '<td align="right" nowrap="nowrap">'.price($objp->pa_ht).'</td>';
// Icon move, update et delete (statut contrat 0=brouillon,1=valide,2=ferme)
print '<td align="right" nowrap="nowrap">';
if ($user->rights->contrat->creer && count($arrayothercontracts) && ($object->statut >= 0))
@ -969,7 +997,7 @@ else
if ($objp->subprice >= 0)
{
print '<tr '.$bc[$var].'>';
print '<td colspan="6">';
print '<td colspan="'.($conf->margin->enabled?7:6).'">';
// Date planned
print $langs->trans("DateStartPlanned").': ';
@ -1000,6 +1028,8 @@ else
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updateligne">';
print '<input type="hidden" name="elrowid" value="'.GETPOST('rowid').'">';
print '<input type="hidden" name="idprod" value="'.($objp->fk_product?$objp->fk_product:'0').'">';
print '<input type="hidden" name="fournprice" value="'.($objp->fk_fournprice?$objp->fk_fournprice:'0').'">';
// Ligne carac
print "<tr $bc[$var]>";
print '<td>';
@ -1032,12 +1062,18 @@ else
print '<td align="right"><input size="5" type="text" name="elprice" value="'.price($objp->subprice).'"></td>';
print '<td align="center"><input size="2" type="text" name="elqty" value="'.$objp->qty.'"></td>';
print '<td align="right" nowrap="nowrap"><input size="1" type="text" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>';
if ($conf->margin->enabled) {
print '<td align="right">';
if ($objp->fk_product)
print '<select id="fournprice" name="fournprice"></select>';
print '<input id="buying_price" type="text" size="5" name="buying_price" value="'.price($objp->pa_ht,0,'',0).'"></td>';
}
print '<td align="center" rowspan="2" valign="middle"><input type="submit" class="button" name="save" value="'.$langs->trans("Modify").'">';
print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</td>';
// Ligne dates prevues
print "<tr $bc[$var]>";
print '<td colspan="5">';
print '<td colspan="'.($conf->margin->enabled?6:5).'">';
print $langs->trans("DateStartPlanned").' ';
$form->select_date($db->jdate($objp->date_debut),"date_start_update",$usehm,$usehm,($db->jdate($objp->date_debut)>0?0:1),"update");
print '<br>'.$langs->trans("DateEndPlanned").' ';
@ -1058,7 +1094,7 @@ else
if ($object->statut > 0)
{
print '<tr '.$bc[false].'>';
print '<td colspan="6"><hr></td>';
print '<td colspan="'.($conf->margin->enabled?7:6).'"><hr></td>';
print "</tr>\n";
}
@ -1215,7 +1251,7 @@ else
print '</tr>';
print '<tr '.$bc[$var].'><td>'.$langs->trans("Comment").'</td><td colspan="3"><input size="80" type="text" name="comment" value="'.GETPOST('comment').'"></td></tr>';
print '<tr '.$bc[$var].'><td>'.$langs->trans("Comment").'</td><td colspan="'.($conf->margin->enabled?4:3).'"><input size="80" type="text" name="comment" value="'.$_POST["comment"].'"></td></tr>';
print '</table>';
@ -1284,7 +1320,7 @@ else
if ($user->rights->contrat->creer && ($object->statut >= 0))
{
$dateSelector=1;
print '<br>';
print '<table id="tablelines" class="noborder" width="100%">'; // Array with (n*2)+1 lines
@ -1300,28 +1336,28 @@ else
if ($conf->global->MAIN_FEATURES_LEVEL > 1)
{
// Add free or predefined products/services
$object->formAddObjectLine($dateSelector,$mysoc,$object->thirdparty,$hookmanager);
$object->formAddObjectLine($dateSelector,$mysoc,$object->thirdparty);
}
else
{
// Add free products/services
$object->formAddFreeProduct($dateSelector,$mysoc,$object->thirdparty,$hookmanager);
$object->formAddFreeProduct($dateSelector,$mysoc,$object->thirdparty);
// Add predefined products/services
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
{
$var=!$var;
$object->formAddPredefinedProduct($dateSelector,$mysoc,$object->thirdparty,$hookmanager);
$object->formAddPredefinedProduct($dateSelector,$mysoc,$object->thirdparty);
}
}
$parameters=array();
$reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
}
// Restore correct setup
$conf->product->enabled = $savproductenabled;
print '</form>';
print '</table>';
@ -1397,3 +1433,59 @@ llxFooter();
$db->close();
?>
<?php
if ($conf->margin->enabled) {
?>
<script type="text/javascript">
<?php if ($action == 'editline') { ?>
$(document).ready(function() {
var idprod = $("input[name='idprod']").val();
var fournprice = $("input[name='fournprice']").val();
if (idprod > 0) {
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': idprod}, function(data) {
if (data.length > 0) {
var options = '';
var trouve=false;
$(data).each(function() {
options += '<option value="'+this.id+'" price="'+this.price+'"';
if (fournprice > 0) {
if (this.id == fournprice) {
options += ' selected';
$("#buying_price").val(this.price);
trouve = true;
}
}
options += '>'+this.label+'</option>';
});
options += '<option value=null'+(trouve?'':' selected')+'><?php echo $langs->trans("InputPrice"); ?></option>';
$("#fournprice").html(options);
if (trouve) {
$("#buying_price").hide();
$("#fournprice").show();
}
else {
$("#buying_price").show();
}
$("#fournprice").change(function() {
var selval = $(this).find('option:selected').attr("price");
if (selval)
$("#buying_price").val(selval).hide();
else
$('#buying_price').show();
});
}
else {
$("#fournprice").hide();
$('#buying_price').show();
}
},
'json');
}
else {
$("#fournprice").hide();
$('#buying_price').show();
}
});
<?php } ?>
</script>
<?php } ?>

View File

@ -28,6 +28,7 @@ $extrasize=GETPOST('size');
if (GETPOST('type')=='double' && strpos($extrasize,',')===false) $extrasize='24,8';
if (GETPOST('type')=='date') $extrasize='';
if (GETPOST('type')=='datetime') $extrasize='';
if (GETPOST('type')=='select') $extrasize='';
// Add attribute
@ -58,13 +59,29 @@ if ($action == 'add')
$mesg=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
$action = 'create';
}
if (GETPOST('type')=='select' && !GETPOST('param'))
{
$error++;
$langs->load("errors");
$mesg=$langs->trans("ErrorNoValueForSelectType");
$action = 'create';
}
if (! $error)
{
// Type et taille non encore pris en compte => varchar(255)
if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
{
$result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0));
// Construct array for parameter (value of select list)
$parameters = GETPOST('param');
$parameters_array = explode("\r\n",$parameters);
foreach($parameters_array as $param_ligne)
{
list($key,$value) = explode(',',$param_ligne);
$params['options'][$key] = $value;
}
$result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$default_value,$params);
if ($result > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
@ -119,7 +136,16 @@ if ($action == 'update')
{
if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
{
$result=$extrafields->update($_POST['attrname'],$_POST['label'],$_POST['type'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0));
$pos = GETPOST('pos','int');
// Construct array for parameter (value of select list)
$parameters = GETPOST('param');
$parameters_array = explode("\r\n",$parameters);
foreach($parameters_array as $param_ligne)
{
list($key,$value) = explode(',',$param_ligne);
$params['options'][$key] = $value;
}
$result=$extrafields->update($_POST['attrname'],$_POST['label'],$_POST['type'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$pos,$params);
if ($result > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);

View File

@ -89,11 +89,11 @@ class box_prospect extends ModeleBoxes
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg,
'url' => DOL_URL_ROOT."/comm/prospect/fiche.php?socid=".$objp->socid);
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => $objp->nom,
'url' => DOL_URL_ROOT."/comm/prospect/fiche.php?socid=".$objp->socid);
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid);
$this->info_box_contents[$i][2] = array('td' => 'align="right"',
'text' => dol_print_date($datem, "day"));

View File

@ -1020,7 +1020,7 @@ class CMailFile
/**
* Return an address for SMTP protocol
*
* @param string $adresses Example: 'John Doe <john@doe.com>' or 'john@doe.com'
* @param string $address Example: 'John Doe <john@doe.com>' or 'john@doe.com'
* @param int $format 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between "
* @param int $encode 1=Encode name to RFC2822
* @return string If format 0: '<john@doe.com>' or 'John Doe <john@doe.com>' or '=?UTF-8?B?Sm9obiBEb2U=?= <john@doe.com>'
@ -1028,13 +1028,13 @@ class CMailFile
* If format 2: 'john@doe.com'
* If format 3: '<john@doe.com>' or '"John Doe" <john@doe.com>' or '"=?UTF-8?B?Sm9obiBEb2U=?=" <john@doe.com>'
*/
function getValidAddress($adresses,$format,$encode='')
function getValidAddress($address,$format,$encode='')
{
global $conf;
$ret='';
$arrayaddress=explode(',',$adresses);
$arrayaddress=explode(',',$address);
// Boucle sur chaque composant de l'adresse
foreach($arrayaddress as $val)

View File

@ -134,7 +134,7 @@ abstract class CommonDocGenerator
$object->state=getState($object->state_code,0);
}
return array(
$array_thirdparty = array(
'company_name'=>$object->name,
'company_email'=>$object->email,
'company_phone'=>$object->phone,
@ -163,6 +163,25 @@ abstract class CommonDocGenerator
'company_idprof6'=>$object->idprof6,
'company_note'=>$object->note
);
// Retrieve extrafields
if(is_array($object->array_options) && count($object->array_options))
{
if(!class_exists('Extrafields'))
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label('company',true);
foreach($extrafields->attribute_label as $key=>$label)
{
if($extrafields->attribute_type[$key] == 'price')
{
$object->array_options['options_'.$key] = price($object->array_options['options_'.$key]).' '.$outputlangs->getCurrencySymbol($conf->currency);
}
$array_thirdparty=array_merge($array_thirdparty,array('company_options_'.$key => $object->array_options['options_'.$key]));
}
}
return $array_thirdparty;
}
/**

View File

@ -964,7 +964,7 @@ abstract class CommonObject
*/
function setDeliveryAddress($id)
{
$fieldname = 'fk_adresse_livraison';
$fieldname = 'fk_delivery_address';
if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address';
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".$id;
@ -1023,7 +1023,7 @@ abstract class CommonObject
/**
* Save a new position (field rang) for details lines.
* You can choose to ser position for lines with already a position or lines wihtout any position defined.
* You can choose to set position for lines with already a position or lines without any position defined.
* Call this function only for table that contains a field fk_parent_line.
*
* @param boolean $renum true to renum all already ordered lines, false to renum only not already ordered lines.
@ -1064,7 +1064,7 @@ abstract class CommonObject
// counter that parents.
$rows=array();
// We frist search all lines that are parent lines (for multilevel details lines)
// We first search all lines that are parent lines (for multilevel details lines)
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
$sql.= ' AND fk_parent_line IS NULL';
@ -1080,10 +1080,10 @@ abstract class CommonObject
{
$row = $this->db->fetch_row($resql);
$rows[] = $row[0]; // Add parent line into array rows
$childrens = $this->getChildrensOfLine($row[0]);
if (! empty($childrens))
$childrens = $this->getChildrenOfLine($row[0]);
if (! empty($children))
{
foreach($childrens as $child)
foreach($children as $child)
{
array_push($rows, $child);
}
@ -1108,12 +1108,12 @@ abstract class CommonObject
}
/**
* Get childrens of line
* Get children of line
*
* @param int $id Id of parent line
* @return array Array with list of child lines id
* @return array Array with list of children lines id
*/
function getChildrensOfLine($id)
function getChildrenOfLine($id)
{
$rows=array();
@ -1122,7 +1122,7 @@ abstract class CommonObject
$sql.= ' AND fk_parent_line = '.$id;
$sql.= ' ORDER BY rang ASC';
dol_syslog(get_class($this)."::getChildrenOfLines search children lines for line ".$id." sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::getChildrenOfLine search children lines for line ".$id." sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
@ -2463,21 +2463,16 @@ abstract class CommonObject
* TODO Move this into html.class.php
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
*
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function showLinkedObjectBlock($hookmanager=false)
function showLinkedObjectBlock()
{
global $conf,$langs,$bc;
global $conf,$langs,$hookmanager;
global $bc;
$this->fetchObjectLinked();
// Bypass the default method
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('commonobject'));
$parameters=array();
$reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$this,$action); // Note that $action and $object may have been modified by hook
@ -2547,13 +2542,12 @@ abstract class CommonObject
* @param int $dateSelector 1=Show also date range input fields
* @param Societe $seller Object thirdparty who sell
* @param Societe $buyer Object thirdparty who buy
* @param HookManager $hookmanager Hook manager instance
* @return void
* @deprecated
*/
function formAddPredefinedProduct($dateSelector,$seller,$buyer,$hookmanager=false)
function formAddPredefinedProduct($dateSelector,$seller,$buyer)
{
global $conf,$langs,$object;
global $conf,$langs,$object,$hookmanager;
global $form,$bcnd,$var;
// Use global variables + $dateSelector + $seller and $buyer
@ -2568,13 +2562,12 @@ abstract class CommonObject
* @param int $dateSelector 1=Show also date range input fields
* @param Societe $seller Object thirdparty who sell
* @param Societe $buyer Object thirdparty who buy
* @param HookManager $hookmanager Hook manager instance
* @return void
* @deprecated
*/
function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false)
function formAddFreeProduct($dateSelector,$seller,$buyer)
{
global $conf,$langs,$object;
global $conf,$langs,$object,$hookmanager;
global $form,$bcnd,$var;
// Use global variables + $dateSelector + $seller and $buyer
@ -2590,12 +2583,11 @@ abstract class CommonObject
* @param int $dateSelector 1=Show also date range input fields
* @param Societe $seller Object thirdparty who sell
* @param Societe $buyer Object thirdparty who buy
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function formAddObjectLine($dateSelector,$seller,$buyer,$hookmanager=false)
function formAddObjectLine($dateSelector,$seller,$buyer)
{
global $conf,$user,$langs,$object;
global $conf,$user,$langs,$object,$hookmanager;
global $form,$bcnd,$var;
// Output template part (modules that overwrite templates must declare this into descriptor)
@ -2629,12 +2621,11 @@ abstract class CommonObject
* @param string $buyer Object of buyer third party
* @param string $selected Object line selected
* @param int $dateSelector 1=Show also date range input fields
* @param HookManager $hookmanager Hookmanager
* @return void
*/
function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0, $hookmanager=false)
function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0)
{
global $conf,$langs;
global $conf,$langs,$hookmanager;
print '<tr class="liste_titre nodrag nodrop">';
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
@ -2702,12 +2693,11 @@ abstract class CommonObject
* @param string $seller Object of seller third party
* @param string $buyer Object of buyer third party
* @param string $selected Object line selected
* @param HookManager $hookmanager Hook manager
* @return void
*/
function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$hookmanager=false)
function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0)
{
global $conf,$langs,$user;
global $conf,$langs,$user,$hookmanager;
global $form,$bc,$bcdd;
$element=$this->element;
@ -2812,12 +2802,11 @@ abstract class CommonObject
* If lines are into a template, title must also be into a template
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
*
* @param HookManager $hookmanager Hook manager
* @return void
*/
function printOriginLinesList($hookmanager=false)
function printOriginLinesList()
{
global $langs;
global $langs, $hookmanager;
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Ref').'</td>';

View File

@ -454,7 +454,7 @@ class Conf
throw new Exception('Log handler does not extend LogHandlerInterface');
}
$this->loghandlers[]=$loghandlerinstance;
if (empty($conf->loghandlers[$handler])) $this->loghandlers[$handler]=$loghandlerinstance;
}
}
}

View File

@ -38,10 +38,16 @@ class ExtraFields
var $attribute_label;
// Tableau contenant le nom des champs en clef et la taille de ces champs en value
var $attribute_size;
// Tableau contenant le nom des choix en clef et la valeur de ces choix en value
var $attribute_choice;
// Array to store if attribute is unique or not
var $attribute_unique;
// Array to store if attribute is required or not
var $attribute_required;
// Array to store parameters of attribute (used in select type)
var $attribute_param;
// Int to store position of attribute
var $attribute_pos;
var $error;
var $errno;
@ -56,7 +62,8 @@ class ExtraFields
'boolean'=>'Boolean',
'price'=>'ExtrafieldPrice',
'phone'=>'ExtrafieldPhone',
'mail'=>'ExtrafieldMail'
'mail'=>'ExtrafieldMail',
'select' => 'ExtrafieldSelect'
);
/**
@ -87,20 +94,22 @@ class ExtraFields
* @param string $elementtype Element type ('member', 'product', 'company', ...)
* @param int $unique Is field unique or not
* @param int $required Is field required or not
* @param array $param Params for field
* @return int <=0 if KO, >0 if OK
*/
function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0)
function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0,$default_value='', $param=0)
{
if (empty($attrname)) return -1;
if (empty($label)) return -1;
// Create field into database
$result=$this->create($attrname,$type,$size,$elementtype, $unique, $required);
$result=$this->create($attrname,$type,$size,$elementtype, $unique, $required, $default_value,$param);
$err1=$this->errno;
if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS')
{
// Add declaration of field into table
$result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required);
$result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param);
$err2=$this->errno;
if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS'))
{
@ -126,12 +135,15 @@ class ExtraFields
* @param string $elementtype Element type ('member', 'product', 'company', 'contact', ...)
* @param int $unique Is field unique or not
* @param int $required Is field required or not
* @param string $default_value Default value for field
* @param array $param Params for field (ex for select list : array('options'=>array('value'=>'label of option'))
*
* @return int <=0 if KO, >0 if OK
*/
private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0)
private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='')
{
$table=$elementtype.'_extrafields';
// Special case for not normalized table names
if ($elementtype == 'member') $table='adherent_extrafields';
elseif ($elementtype == 'company') $table='societe_extrafields';
@ -151,11 +163,20 @@ class ExtraFields
}elseif($type=='mail') {
$typedb='varchar';
$lengthdb='128';
} elseif ($type=='select') {
$typedb='text';
$lengthdb='';
} else {
$typedb=$type;
$lengthdb=$length;
}
$field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required?'NOT NULL':'NULL'));
$field_desc = array(
'type'=>$typedb,
'value'=>$lengthdb,
'null'=>($required?'NOT NULL':'NULL'),
'default' => $default_value
);
$result=$this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc);
if ($result > 0)
{
@ -190,19 +211,33 @@ class ExtraFields
* @param string $elementtype Element type ('member', 'product', 'company', ...)
* @param int $unique Is field unique or not
* @param int $required Is field required or not
* @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @return int <=0 if KO, >0 if OK
*/
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0)
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0,$param)
{
global $conf;
// Clean parameters
if (empty($pos)) $pos=0;
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired)";
if(is_array($param) and count($param) > 0)
{
$params = $this->db->escape(serialize($param));
}
elseif (strlen($param) > 0)
{
$params = trim($param);
}
else
{
$params='';
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param)";
$sql.= " VALUES('".$attrname."',";
$sql.= " '".$this->db->escape($label)."',";
$sql.= " '".$type."',";
@ -211,7 +246,8 @@ class ExtraFields
$sql.= " ".$conf->entity.",";
$sql.= " '".$elementtype."',";
$sql.= " '".$unique."',";
$sql.= " '".$required."'";
$sql.= " '".$required."',";
$sql.= " '".$params."'";
$sql.=')';
dol_syslog(get_class($this)."::create_label sql=".$sql);
@ -311,9 +347,11 @@ class ExtraFields
* @param string $elementtype Element type ('member', 'product', 'company', 'contact', ...)
* @param int $unique Is field unique or not
* @param int $required Is field required or not
* @param int $pos Position of attribute
* @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @return int >0 if OK, <=0 if KO
*/
function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0)
function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos,$param='')
{
$table=$elementtype.'_extrafields';
@ -336,6 +374,9 @@ class ExtraFields
}elseif($type=='mail') {
$typedb='varchar';
$lengthdb='128';
} elseif ($type=='select') {
$typedb='text';
$lengthdb='';
} else {
$typedb=$type;
$lengthdb=$length;
@ -346,7 +387,7 @@ class ExtraFields
{
if ($label)
{
$result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required);
$result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param);
}
if ($result > 0)
{
@ -392,9 +433,11 @@ class ExtraFields
* @param string $elementtype Element type ('member', 'product', 'company', ...)
* @param int $unique Is field unique or not
* @param int $required Is field required or not
* @param int $pos Position of attribute
* @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @return int <=0 if KO, >0 if OK
*/
private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0)
private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='')
{
global $conf;
dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required);
@ -402,7 +445,12 @@ class ExtraFields
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
{
$this->db->begin();
if(is_array($param) && count($param) > 0)
{
$param = serialize($param);
}
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields";
$sql_del.= " WHERE name = '".$attrname."'";
$sql_del.= " AND entity = ".$conf->entity;
@ -418,7 +466,9 @@ class ExtraFields
$sql.= " size,";
$sql.= " elementtype,";
$sql.= " fieldunique,";
$sql.= " fieldrequired";
$sql.= " fieldrequired,";
$sql.= " pos,";
$sql.= " param";
$sql.= ") VALUES (";
$sql.= "'".$attrname."',";
$sql.= " ".$conf->entity.",";
@ -427,7 +477,9 @@ class ExtraFields
$sql.= " '".$size."',";
$sql.= " '".$elementtype."',";
$sql.= " '".$unique."',";
$sql.= " '".$required."'";
$sql.= " '".$required."',";
$sql.= " '".$pos."',";
$sql.= " '".$param."'";
$sql.= ")";
dol_syslog(get_class($this)."::update_label sql=".$sql);
$resql2=$this->db->query($sql);
@ -480,7 +532,7 @@ class ExtraFields
if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
return $array_name_label;
$sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired";
$sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields";
$sql.= " WHERE entity = ".$conf->entity;
if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'";
@ -502,6 +554,8 @@ class ExtraFields
$this->attribute_elementtype[$tab->name]=$tab->elementtype;
$this->attribute_unique[$tab->name]=$tab->fieldunique;
$this->attribute_required[$tab->name]=$tab->fieldrequired;
$this->attribute_param[$tab->name]=unserialize($tab->param);
$this->attribute_pos[$tab->name]=$tab->pos;
}
}
return $array_name_label;
@ -531,6 +585,7 @@ class ExtraFields
$elementtype=$this->attribute_elementtype[$key];
$unique=$this->attribute_unique[$key];
$required=$this->attribute_required[$key];
$param=$this->attribute_param[$key];
if ($type == 'date')
{
$showsize=10;
@ -593,6 +648,15 @@ class ExtraFields
{
$out='<input type="text" name="options_'.$key.'" size="6" value="'.price($value).'"> '.$langs->getCurrencySymbol($conf->currency);
}
elseif ($type == 'select')
{
$out='<select name="options_'.$key.'">';
foreach ($param['options'] as $key=>$value )
{
$out.='<option value="'.$key.'">'.$value.'</option>';
}
$out.='</select>';
}
// Add comments
if ($type == 'date') $out.=' (YYYY-MM-DD)';
elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)';
@ -609,7 +673,7 @@ class ExtraFields
*/
function showOutputField($key,$value,$moreparam='')
{
global $conf;
global $conf,$langs;
$label=$this->attribute_label[$key];
$type=$this->attribute_type[$key];
@ -617,6 +681,7 @@ class ExtraFields
$elementtype=$this->attribute_elementtype[$key];
$unique=$this->attribute_unique[$key];
$required=$this->attribute_required[$key];
$params=$this->attribute_param[$key];
if ($type == 'date')
{
$showsize=10;
@ -649,6 +714,10 @@ class ExtraFields
{
$value=price($value).' '.$langs->getCurrencySymbol($conf->currency);
}
elseif ($type == 'select')
{
$value=$params['options'][$value];
}
else
{
$showsize=round($size);

View File

@ -178,6 +178,8 @@ class HookManager
// TODO. remove this. result must not be a string. we must use $actionclassinstance->resprint to return a string
if (! is_array($result) && ! is_numeric($result)) $this->resPrint.=$result;
}
//print "method=".$method." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." result=".$result." resaction=".$resaction;
}
}
}

View File

@ -688,8 +688,21 @@ class Form
if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT && ! $forcecombo)
{
//$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2);
$out.= ajax_combobox($htmlname, $event);
$out.= ajax_combobox($htmlname, $event, $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
/*
if ($selected && empty($selected_input_value))
{
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$product = new Product($this->db);
$product->fetch($selected);
$selected_input_value=$product->ref;
}
// mode=1 means customers products
$ajaxoptions=array();
$urloption='htmlname='.$htmlname.'&outjson=1&filter='.urlencode($filter).'&showtype='.$showtype;
$out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
$out.='<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'" />';
*/
}
$out.= '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">';
@ -810,11 +823,13 @@ class Form
* @param string $showfunction Add function into label
* @param string $moreclass Add more class to class style
* @param string $showsoc Add company into label
* @param int $forcecombo Force to use combo box
* @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @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='', $showsoc=0)
function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $showsoc=0, $forcecombo=0, $event=array())
{
print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass, $showsoc);
print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass, $showsoc, $forcecombo, $event);
return $this->num;
}
@ -831,9 +846,11 @@ class Form
* @param string $moreclass Add more class to class style
* @param bool $options_only Return options only (for ajax treatment)
* @param string $showsoc Add company into label
* @param int $forcecombo Force to use combo box
* @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @return int <0 if KO, Nb of contact in list if OK
*/
function selectcontacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $options_only=false, $showsoc=0)
function selectcontacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $options_only=false, $showsoc=0, $forcecombo=0, $event=array())
{
global $conf,$langs;
@ -860,6 +877,11 @@ class Form
{
$num=$this->db->num_rows($resql);
if ($conf->use_javascript_ajax && $conf->global->CONTACT_USE_SEARCH_TO_SELECT && ! $forcecombo)
{
$out.= ajax_combobox($htmlname, $event);
}
if ($htmlname != 'none' || $options_only) $out.= '<select class="flat'.($moreclass?' '.$moreclass:'').'" id="'.$htmlname.'" name="'.$htmlname.'">';
if ($showempty == 1) $out.= '<option value="0"'.($selected=='0'?' selected="selected"':'').'></option>';
if ($showempty == 2) $out.= '<option value="0"'.($selected=='0'?' selected="selected"':'').'>'.$langs->trans("Internal").'</option>';
@ -946,10 +968,10 @@ class Form
* @param int $disabled If select list must be disabled
* @param array $include Array list of users id to include
* @param int $enableonly Array list of users id to be enabled. All other must be disabled
* @param int $force_entity Possibility to force entity
* @param int $force_entity 0 or Id of environment to force
* @return void
*/
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=false)
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0)
{
print $this->select_dolusers($selected,$htmlname,$show_empty,$exclude,$disabled,$include,$enableonly,$force_entity);
}
@ -964,15 +986,15 @@ class Form
* @param int $disabled If select list must be disabled
* @param array $include Array list of users id to include
* @param int $enableonly Array list of users id to be enabled. All other must be disabled
* @param int $force_entity Possibility to force entity
* @param int $force_entity 0 or Id of environment to force
* @return string HTML select string
*/
function select_dolusers($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=false)
function select_dolusers($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0)
{
global $conf,$user,$langs;
// If no preselected user defined, we take current user
if ($selected < -1 && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected=$user->id;
if ((is_numeric($selected) && ($selected < -1 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected=$user->id;
// Permettre l'exclusion d'utilisateurs
if (is_array($exclude)) $excludeUsers = implode("','",$exclude);
@ -1021,7 +1043,7 @@ class Form
if ($num)
{
$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled?' disabled="disabled"':'').'>';
if ($show_empty) $out.= '<option value="-1"'.($selected==-1?' selected="selected"':'').'>&nbsp;</option>'."\n";
if ($show_empty) $out.= '<option value="-1"'.((empty($selected) || $selected==-1)?' selected="selected"':'').'>&nbsp;</option>'."\n";
$userstatic=new User($this->db);
@ -1158,7 +1180,7 @@ class Form
$sql.= ", pl.label as label_translated";
}
// Price by quantity
if (! empty($conf->global->PRODUIT_PRICE_BY_QTY))
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
{
$sql.= ", (SELECT pp.rowid FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid";
if ($price_level >= 1) $sql.= " AND price_level=".$price_level;
@ -3005,14 +3027,14 @@ class Form
{
global $conf,$langs,$user;
$langs->load_cache_currencies();
$langs->load_cache_currencies('');
$out='';
if ($selected=='euro' || $selected=='euros') $selected='EUR'; // Pour compatibilite
$out.= '<select class="flat" name="'.$htmlname.'">';
foreach ($this->cache_currencies as $code_iso => $currency)
foreach ($langs->cache_currencies as $code_iso => $currency)
{
if ($selected && $selected == $code_iso)
{
@ -3924,17 +3946,17 @@ class Form
/**
* Return select list of groups
*
* @param string $selected Id group preselected
* @param string $htmlname Field name in form
* @param int $show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
* @param string $exclude Array list of groups id to exclude
* @param string $selected Id group preselected
* @param string $htmlname Field name in form
* @param int $show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
* @param string $exclude Array list of groups id to exclude
* @param int $disabled If select list must be disabled
* @param string $include Array list of groups id to include
* @param string $include Array list of groups id to include
* @param int $enableonly Array list of groups id to be enabled. All other must be disabled
* @param int $force_entity Possibility to force entity
* @param int $force_entity 0 or Id of environment to force
* @return void
*/
function select_dolgroups($selected='', $htmlname='groupid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity='')
function select_dolgroups($selected='', $htmlname='groupid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0)
{
global $conf,$user,$langs;

View File

@ -135,9 +135,10 @@ class FormActions
* @param Object $object Object
* @param string $typeelement 'invoice','propal','order','invoice_supplier','order_supplier','fichinter'
* @param int $socid socid of user
* @param int $forceshowtitle Show title even if there is no actions to show
* @return int <0 if KO, >=0 if OK
*/
function showactions($object,$typeelement,$socid=0)
function showactions($object,$typeelement,$socid=0,$forceshowtitle=0)
{
global $langs,$conf,$user;
global $bc;
@ -148,7 +149,7 @@ class FormActions
if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions');
$num = count($listofactions);
if ($num)
if ($num || $forceshowtitle)
{
if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill');
elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill');

View File

@ -121,7 +121,7 @@ class FormAdmin
global $langs,$conf;
// Clean parameters
if ($selected == 'eldy.php') $selected='eldy_backoffice.php'; // For compatibility
// Check parameters
if (! is_array($dirmenuarray)) return -1;
@ -143,7 +143,11 @@ class FormAdmin
if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && substr($file, 0, 5) != 'index')
{
if (preg_match('/lib\.php$/i',$file)) continue; // We exclude library files
$filelib=preg_replace('/\.php$/i','',$file);
if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i',$file)) continue; // We exclude all menu manager files
if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i',$file)) continue; // We exclude all menu manager files
if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i',$file)) continue; // We exclude all menu manager files
$filelib=preg_replace('/\.php$/i','',$file);
$prefix='';
// 0=Recommanded, 1=Experimental, 2=Developpement, 3=Other
if (preg_match('/^eldy/i',$file)) $prefix='0';

View File

@ -161,13 +161,12 @@ class FormFile
* @param string $title Title to show on top of form
* @param string $buttonlabel Label on submit button
* @param string $codelang Default language code to use on lang combo box if multilang is enabled
* @param HookManager $hookmanager Object hookmanager with instance of external modules hook classes
* @return int <0 if KO, number of shown files if OK
*/
function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$hookmanager=false)
function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='')
{
$this->numoffiles=0;
print $this->showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed,$modelselected,$allowgenifempty,$forcenomultilang,$iconPDF,$maxfilenamelength,$noform,$param,$title,$buttonlabel,$codelang,$hookmanager);
print $this->showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed,$modelselected,$allowgenifempty,$forcenomultilang,$iconPDF,$maxfilenamelength,$noform,$param,$title,$buttonlabel,$codelang);
return $this->numoffiles;
}
@ -191,15 +190,15 @@ class FormFile
* @param string $title Title to show on top of form
* @param string $buttonlabel Label on submit button
* @param string $codelang Default language code to use on lang combo box if multilang is enabled
* @param HookManager $hookmanager Object hookmanager with instance of external modules hook classes
* @return string Output string with HTML array of documents (might be empty string)
*/
function showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$hookmanager=false)
function showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='')
{
// filedir = conf->...dir_ouput."/".get_exdir(id)
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
global $langs,$bc,$conf;
global $langs,$conf,$hookmanager;
global $bc;
// For backward compatibility
if (! empty($iconPDF)) {
@ -590,18 +589,10 @@ class FormFile
*/
function list_of_documents($filearray,$object,$modulepart,$param='',$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0,$textifempty='',$maxlength=0,$title='',$url='')
{
global $user, $conf, $langs;
global $bc, $hookmanager;
global $user, $conf, $langs, $hookmanager;
global $bc;
global $sortfield, $sortorder, $maxheightmini;
if (! is_object($hookmanager))
{
if (! class_exists('HookManager')) {
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
}
$hookmanager->initHooks(array('formfile'));
$parameters=array(

View File

@ -49,6 +49,7 @@ class FormMail
var $withto;
var $withtofree;
var $withtocc;
var $withtoccc;
var $withtopic;
var $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files
var $withbody;
@ -216,423 +217,413 @@ class FormMail
*/
function get_form($addfileaction='addfile',$removefileaction='removefile')
{
global $conf, $langs, $user;
global $conf, $langs, $user, $hookmanager;
$langs->load("other");
$langs->load("mails");
$out='';
$hookmanager->initHooks(array('formmail'));
// Define list of attached files
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]);
if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]);
if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]);
$parameters=array(
'addfileaction' => $addfileaction,
'removefileaction'=> $removefileaction
);
$reshook=$hookmanager->executeHooks('getFormMail', $parameters, $this);
$form=new Form($this->db);
$out.= "\n<!-- Debut form mail -->\n";
if ($this->withform)
if (!empty($reshook))
{
$out.= '<form method="POST" name="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">'."\n";
$out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
return $hookmanager->resPrint;
}
foreach ($this->param as $key=>$value)
else
{
$out.= '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'" />'."\n";
$out='';
// Define list of attached files
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]);
if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]);
if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]);
$form=new Form($this->db);
$out.= "\n<!-- Debut form mail -->\n";
if ($this->withform)
{
$out.= '<form method="POST" name="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">'."\n";
$out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
}
foreach ($this->param as $key=>$value)
{
$out.= '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'" />'."\n";
}
$out.= '<table class="border" width="100%">'."\n";
// Substitution array
if (! empty($this->withsubstit))
{
$out.= '<tr><td colspan="2">';
$help="";
foreach($this->substit as $key => $val)
{
$help.=$key.' -> '.$langs->trans($val).'<br>';
}
$out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help);
$out.= "</td></tr>\n";
}
// From
if (! empty($this->withfrom))
{
if (! empty($this->withfromreadonly))
{
$out.= '<input type="hidden" id="fromname" name="fromname" value="'.$this->fromname.'" />';
$out.= '<input type="hidden" id="frommail" name="frommail" value="'.$this->frommail.'" />';
$out.= '<tr><td width="180">'.$langs->trans("MailFrom").'</td><td>';
if ($this->fromtype == 'user' && $this->fromid > 0)
{
$langs->load("users");
$fuser=new User($this->db);
$fuser->fetch($this->fromid);
$out.= $fuser->getNomUrl(1);
}
else
{
$out.= $this->fromname;
}
if ($this->frommail)
{
$out.= " &lt;".$this->frommail."&gt;";
}
else
{
if ($this->fromtype)
{
$langs->load("errors");
$out.= '<font class="warning"> &lt;'.$langs->trans("ErrorNoMailDefinedForThisUser").'&gt; </font>';
}
}
$out.= "</td></tr>\n";
$out.= "</td></tr>\n";
}
else
{
$out.= "<tr><td>".$langs->trans("MailFrom")."</td><td>";
$out.= $langs->trans("Name").':<input type="text" id="fromname" name="fromname" size="32" value="'.$this->fromname.'" />';
$out.= '&nbsp; &nbsp; ';
$out.= $langs->trans("EMail").':&lt;<input type="text" id="frommail" name="frommail" size="32" value="'.$this->frommail.'" />&gt;';
$out.= "</td></tr>\n";
}
}
// Replyto
if (! empty($this->withreplyto))
{
if ($this->withreplytoreadonly)
{
$out.= '<input type="hidden" id="replyname" name="replyname" value="'.$this->replytoname.'" />';
$out.= '<input type="hidden" id="replymail" name="replymail" value="'.$this->replytomail.'" />';
$out.= "<tr><td>".$langs->trans("MailReply")."</td><td>".$this->replytoname.($this->replytomail?(" &lt;".$this->replytomail."&gt;"):"");
$out.= "</td></tr>\n";
}
}
// Errorsto
if (! empty($this->witherrorsto))
{
//if (! $this->errorstomail) $this->errorstomail=$this->frommail;
$errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail);
if ($this->witherrorstoreadonly)
{
$out.= '<input type="hidden" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />';
$out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
$out.= $errorstomail;
$out.= "</td></tr>\n";
}
else
{
$out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
$out.= '<input size="30" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />';
$out.= "</td></tr>\n";
}
}
// To
if (! empty($this->withto) || is_array($this->withto))
{
$out.= '<tr><td width="180">';
if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
else $out.= $langs->trans("MailTo");
$out.= '</td><td>';
if ($this->withtoreadonly)
{
if (! empty($this->toname) && ! empty($this->tomail))
{
$out.= '<input type="hidden" id="toname" name="toname" value="'.$this->toname.'" />';
$out.= '<input type="hidden" id="tomail" name="tomail" value="'.$this->tomail.'" />';
if ($this->totype == 'thirdparty')
{
$soc=new Societe($this->db);
$soc->fetch($this->toid);
$out.= $soc->getNomUrl(1);
}
else if ($this->totype == 'contact')
{
$contact=new Contact($this->db);
$contact->fetch($this->toid);
$out.= $contact->getNomUrl(1);
}
else
{
$out.= $this->toname;
}
$out.= ' &lt;'.$this->tomail.'&gt;';
if ($this->withtofree)
{
$out.= '<br>'.$langs->trans("or").' <input size="'.(is_array($this->withto)?"30":"60").'" id="sendto" name="sendto" value="'.(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"").'" />';
}
}
else
{
$out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:"";
}
}
else
{
if (! empty($this->withtofree))
{
$out.= '<input size="'.(is_array($this->withto)?"30":"60").'" id="sendto" name="sendto" value="'.(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"").'" />';
}
if (! empty($this->withto) && is_array($this->withto))
{
if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1);
}
if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method.
{
$liste=array();
$soc=new Societe($this->db);
$soc->fetch($this->withtosocid);
foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value)
{
$liste[$key]=$value;
}
if ($this->withtofree) $out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1);
}
}
$out.= "</td></tr>\n";
}
// CC
if (! empty($this->withtocc) || is_array($this->withtocc))
{
$out.= '<tr><td width="180">';
$out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
$out.= '</td><td>';
if ($this->withtoccreadonly)
{
$out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:"";
}
else
{
$out.= '<input size="'.(is_array($this->withtocc)?"30":"60").'" id="sendtocc" name="sendtocc" value="'.((! is_array($this->withtocc) && ! is_numeric($this->withtocc))? (isset($_POST["sendtocc"])?$_POST["sendtocc"]:$this->withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />';
if (! empty($this->withtocc) && is_array($this->withtocc))
{
$out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1);
}
}
$out.= "</td></tr>\n";
}
// CCC
if (! empty($this->withtoccc) || is_array($this->withtoccc))
{
$out.= '<tr><td width="180">';
$out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
$out.= '</td><td>';
if (! empty($this->withtocccreadonly))
{
$out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:"";
}
else
{
$out.= '<input size="'.(is_array($this->withtoccc)?"30":"60").'" id="sendtoccc" name="sendtoccc" value="'.((! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))? (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:$this->withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />';
if (! empty($this->withtoccc) && is_array($this->withtoccc))
{
$out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1);
}
}
//if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1);
$out.= "</td></tr>\n";
}
// Ask delivery receipt
if (! empty($this->withdeliveryreceipt))
{
$out.= '<tr><td width="180">'.$langs->trans("DeliveryReceipt").'</td><td>';
if (! empty($this->withdeliveryreceiptreadonly))
{
$out.= yn($this->withdeliveryreceipt);
}
else
{
$out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1);
}
$out.= "</td></tr>\n";
}
// Topic
if (! empty($this->withtopic))
{
$this->withtopic=make_substitutions($this->withtopic,$this->substit);
$out.= '<tr>';
$out.= '<td width="180">'.$langs->trans("MailTopic").'</td>';
$out.= '<td>';
if ($this->withtopicreadonly)
{
$out.= $this->withtopic;
$out.= '<input type="hidden" size="60" id="subject" name="subject" value="'.$this->withtopic.'" />';
}
else
{
$out.= '<input type="text" size="60" id="subject" name="subject" value="'. (isset($_POST["subject"])?$_POST["subject"]:$this->withtopic) .'" />';
}
$out.= "</td></tr>\n";
}
// Attached files
if (! empty($this->withfile))
{
$out.= '<tr>';
$out.= '<td width="180">'.$langs->trans("MailFile").'</td>';
$out.= '<td>';
// TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
$out.= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
$out.= '<script type="text/javascript" language="javascript">';
$out.= 'jQuery(document).ready(function () {';
$out.= ' jQuery(".removedfile").click(function() {';
$out.= ' jQuery(".removedfilehidden").val(jQuery(this).val());';
$out.= ' });';
$out.= '})';
$out.= '</script>'."\n";
if (count($listofpaths))
{
foreach($listofpaths as $key => $val)
{
$out.= '<div id="attachfile_'.$key.'">';
$out.= img_mime($listofnames[$key]).' '.$listofnames[$key];
if (! $this->withfilereadonly)
{
$out.= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key+1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
//$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>';
}
$out.= '<br></div>';
}
}
else
{
$out.= $langs->trans("NoAttachedFiles").'<br>';
}
if ($this->withfile == 2) // Can add other files
{
$out.= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
$out.= ' ';
$out.= '<input type="submit" class="button" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />';
}
$out.= "</td></tr>\n";
}
// Message
if (! empty($this->withbody))
{
$defaultmessage="";
// TODO A partir du type, proposer liste de messages dans table llx_models
if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); }
elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); }
elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); }
elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); }
elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); }
elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); }
elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); }
elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); }
elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; }
// Complete substitution array
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL))
{
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
$langs->load('paypal');
if ($this->param["models"]=='order_send')
{
$url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']);
$this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url);
}
if ($this->param["models"]=='facture_send')
{
$url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']);
$this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url);
}
}
$defaultmessage=make_substitutions($defaultmessage,$this->substit);
if (isset($_POST["message"])) $defaultmessage=$_POST["message"];
$defaultmessage=str_replace('\n',"\n",$defaultmessage);
$out.= '<tr>';
$out.= '<td width="180" valign="top">'.$langs->trans("MailText").'</td>';
$out.= '<td>';
if ($this->withbodyreadonly)
{
$out.= nl2br($defaultmessage);
$out.= '<input type="hidden" id="message" name="message" value="'.$defaultmessage.'" />';
}
else
{
if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes';
// Editor wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72);
$out.= $doleditor->Create(1);
}
$out.= "</td></tr>\n";
}
if (! empty($this->withform))
{
$out.= '<tr><td align="center" colspan="2"><center>';
$out.= '<input class="button" type="submit" id="sendmail" name="sendmail" value="'.$langs->trans("SendMail").'"';
// Add a javascript test to avoid to forget to submit file before sending email
if ($this->withfile == 2 && $conf->use_javascript_ajax)
{
$out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"';
}
$out.= ' />';
if ($this->withcancel)
{
$out.= ' &nbsp; &nbsp; ';
$out.= '<input class="button" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'" />';
}
$out.= '</center></td></tr>'."\n";
}
$out.= '</table>'."\n";
if (! empty($this->withform)) $out.= '</form>'."\n";
$out.= "<!-- Fin form mail -->\n";
return $out;
}
$out.= '<table class="border" width="100%">'."\n";
// Substitution array
if (! empty($this->withsubstit))
{
$out.= '<tr><td colspan="2">';
$help="";
foreach($this->substit as $key => $val)
{
$help.=$key.' -> '.$langs->trans($val).'<br>';
}
$out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help);
$out.= "</td></tr>\n";
}
// From
if (! empty($this->withfrom))
{
if (! empty($this->withfromreadonly))
{
$out.= '<input type="hidden" id="fromname" name="fromname" value="'.$this->fromname.'" />';
$out.= '<input type="hidden" id="frommail" name="frommail" value="'.$this->frommail.'" />';
$out.= '<tr><td width="180">'.$langs->trans("MailFrom").'</td><td>';
if ($this->fromtype == 'user' && $this->fromid > 0)
{
$langs->load("users");
$fuser=new User($this->db);
$fuser->fetch($this->fromid);
$out.= $fuser->getNomUrl(1);
}
else
{
$out.= $this->fromname;
}
if ($this->frommail)
{
$out.= " &lt;".$this->frommail."&gt;";
}
else
{
if ($this->fromtype)
{
$langs->load("errors");
$out.= '<font class="warning"> &lt;'.$langs->trans("ErrorNoMailDefinedForThisUser").'&gt; </font>';
}
}
$out.= "</td></tr>\n";
$out.= "</td></tr>\n";
}
else
{
$out.= "<tr><td>".$langs->trans("MailFrom")."</td><td>";
$out.= $langs->trans("Name").':<input type="text" id="fromname" name="fromname" size="32" value="'.$this->fromname.'" />';
$out.= '&nbsp; &nbsp; ';
$out.= $langs->trans("EMail").':&lt;<input type="text" id="frommail" name="frommail" size="32" value="'.$this->frommail.'" />&gt;';
$out.= "</td></tr>\n";
}
}
// Replyto
if (! empty($this->withreplyto))
{
if ($this->withreplytoreadonly)
{
$out.= '<input type="hidden" id="replyname" name="replyname" value="'.$this->replytoname.'" />';
$out.= '<input type="hidden" id="replymail" name="replymail" value="'.$this->replytomail.'" />';
$out.= "<tr><td>".$langs->trans("MailReply")."</td><td>".$this->replytoname.($this->replytomail?(" &lt;".$this->replytomail."&gt;"):"");
$out.= "</td></tr>\n";
}
}
// Errorsto
if (! empty($this->witherrorsto))
{
//if (! $this->errorstomail) $this->errorstomail=$this->frommail;
$errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail);
if ($this->witherrorstoreadonly)
{
$out.= '<input type="hidden" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />';
$out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
$out.= $errorstomail;
$out.= "</td></tr>\n";
}
else
{
$out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
$out.= '<input size="30" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />';
$out.= "</td></tr>\n";
}
}
// To
if (! empty($this->withto) || is_array($this->withto))
{
$out.= '<tr><td width="180">';
if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
else $out.= $langs->trans("MailTo");
$out.= '</td><td>';
if ($this->withtoreadonly)
{
if (! empty($this->toname) && ! empty($this->tomail))
{
$out.= '<input type="hidden" id="toname" name="toname" value="'.$this->toname.'" />';
$out.= '<input type="hidden" id="tomail" name="tomail" value="'.$this->tomail.'" />';
if ($this->totype == 'thirdparty')
{
$soc=new Societe($this->db);
$soc->fetch($this->toid);
$out.= $soc->getNomUrl(1);
}
else if ($this->totype == 'contact')
{
$contact=new Contact($this->db);
$contact->fetch($this->toid);
$out.= $contact->getNomUrl(1);
}
else
{
$out.= $this->toname;
}
$out.= ' &lt;'.$this->tomail.'&gt;';
if ($this->withtofree)
{
$out.= '<br>'.$langs->trans("or").' <input size="'.(is_array($this->withto)?"30":"60").'" id="sendto" name="sendto" value="'.(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"").'" />';
}
}
else
{
$out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:"";
}
}
else
{
if (! empty($this->withtofree))
{
$out.= '<input size="'.(is_array($this->withto)?"30":"60").'" id="sendto" name="sendto" value="'.(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"").'" />';
}
if (! empty($this->withto) && is_array($this->withto))
{
if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1);
}
if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method.
{
$liste=array();
$soc=new Societe($this->db);
$soc->fetch($this->withtosocid);
foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value)
{
$liste[$key]=$value;
}
if ($this->withtofree) $out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1);
}
}
$out.= "</td></tr>\n";
}
// CC
if (! empty($this->withtocc) || is_array($this->withtocc))
{
$out.= '<tr><td width="180">';
$out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
$out.= '</td><td>';
if ($this->withtoccreadonly)
{
$out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:"";
}
else
{
$out.= '<input size="'.(is_array($this->withtocc)?"30":"60").'" id="sendtocc" name="sendtocc" value="'.((! is_array($this->withtocc) && ! is_numeric($this->withtocc))? (isset($_POST["sendtocc"])?$_POST["sendtocc"]:$this->withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />';
if (! empty($this->withto) && is_array($this->withto))
{
$out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1);
}
if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method.
{
$liste=array();
$soc=new Societe($this->db);
$soc->fetch($this->withtoccsocid);
foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value)
{
$liste[$key]=$value;
}
$out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1);
}
}
$out.= "</td></tr>\n";
}
// CCC
if (! empty($this->withtoccc) || is_array($this->withtoccc))
{
$out.= '<tr><td width="180">';
$out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
$out.= '</td><td>';
if (! empty($this->withtocccreadonly))
{
$out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:"";
}
else
{
$out.= '<input size="'.(is_array($this->withtoccc)?"30":"60").'" id="sendtoccc" name="sendtoccc" value="'.((! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))? (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:$this->withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />';
if (! empty($this->withto) && is_array($this->withto))
{
$out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1);
}
if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method.
{
$liste=array();
$soc=new Societe($this->db);
$soc->fetch($this->withtosocid);
foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value)
{
$liste[$key]=$value;
}
$out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1);
}
}
//if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1);
$out.= "</td></tr>\n";
}
// Ask delivery receipt
if (! empty($this->withdeliveryreceipt))
{
$out.= '<tr><td width="180">'.$langs->trans("DeliveryReceipt").'</td><td>';
if (! empty($this->withdeliveryreceiptreadonly))
{
$out.= yn($this->withdeliveryreceipt);
}
else
{
$out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1);
}
$out.= "</td></tr>\n";
}
// Topic
if (! empty($this->withtopic))
{
$this->withtopic=make_substitutions($this->withtopic,$this->substit);
$out.= '<tr>';
$out.= '<td width="180">'.$langs->trans("MailTopic").'</td>';
$out.= '<td>';
if ($this->withtopicreadonly)
{
$out.= $this->withtopic;
$out.= '<input type="hidden" size="60" id="subject" name="subject" value="'.$this->withtopic.'" />';
}
else
{
$out.= '<input type="text" size="60" id="subject" name="subject" value="'. (isset($_POST["subject"])?$_POST["subject"]:$this->withtopic) .'" />';
}
$out.= "</td></tr>\n";
}
// Attached files
if (! empty($this->withfile))
{
$out.= '<tr>';
$out.= '<td width="180">'.$langs->trans("MailFile").'</td>';
$out.= '<td>';
// TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
$out.= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
$out.= '<script type="text/javascript" language="javascript">';
$out.= 'jQuery(document).ready(function () {';
$out.= ' jQuery(".removedfile").click(function() {';
$out.= ' jQuery(".removedfilehidden").val(jQuery(this).val());';
$out.= ' });';
$out.= '})';
$out.= '</script>'."\n";
if (count($listofpaths))
{
foreach($listofpaths as $key => $val)
{
$out.= '<div id="attachfile_'.$key.'">';
$out.= img_mime($listofnames[$key]).' '.$listofnames[$key];
if (! $this->withfilereadonly)
{
$out.= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key+1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
//$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>';
}
$out.= '<br></div>';
}
}
else
{
$out.= $langs->trans("NoAttachedFiles").'<br>';
}
if ($this->withfile == 2) // Can add other files
{
$out.= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
$out.= ' ';
$out.= '<input type="submit" class="button" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />';
}
$out.= "</td></tr>\n";
}
// Message
if (! empty($this->withbody))
{
$defaultmessage="";
// TODO A partir du type, proposer liste de messages dans table llx_models
if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); }
elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); }
elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); }
elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); }
elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); }
elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); }
elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); }
elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); }
elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; }
// Complete substitution array
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL))
{
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
$langs->load('paypal');
if ($this->param["models"]=='order_send')
{
$url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']);
$this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url);
}
if ($this->param["models"]=='facture_send')
{
$url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']);
$this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url);
}
}
$defaultmessage=make_substitutions($defaultmessage,$this->substit);
if (isset($_POST["message"])) $defaultmessage=$_POST["message"];
$defaultmessage=str_replace('\n',"\n",$defaultmessage);
$out.= '<tr>';
$out.= '<td width="180" valign="top">'.$langs->trans("MailText").'</td>';
$out.= '<td>';
if ($this->withbodyreadonly)
{
$out.= nl2br($defaultmessage);
$out.= '<input type="hidden" id="message" name="message" value="'.$defaultmessage.'" />';
}
else
{
if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes';
// Editor wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72);
$out.= $doleditor->Create(1);
}
$out.= "</td></tr>\n";
}
if (! empty($this->withform))
{
$out.= '<tr><td align="center" colspan="2"><center>';
$out.= '<input class="button" type="submit" id="sendmail" name="sendmail" value="'.$langs->trans("SendMail").'"';
// Add a javascript test to avoid to forget to submit file before sending email
if ($this->withfile == 2 && $conf->use_javascript_ajax)
{
$out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"';
}
$out.= ' />';
if ($this->withcancel)
{
$out.= ' &nbsp; &nbsp; ';
$out.= '<input class="button" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'" />';
}
$out.= '</center></td></tr>'."\n";
}
$out.= '</table>'."\n";
if (! empty($this->withform)) $out.= '</form>'."\n";
$out.= "<!-- Fin form mail -->\n";
return $out;
}
}

View File

@ -41,7 +41,9 @@ class DoliDBPgsql
//! Database label
static $label='PostgreSQL'; // Label of manager
//! Charset
var $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value
var $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value
//! Collate used to force collate when creating database
var $forcecollate=''; // Can't be static as it may be forced with a dynamic value
//! Version min database
static $versionmin=array(8,4,0); // Version min database

View File

@ -771,7 +771,11 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
*/
(function( $ ) {
$.widget( "ui.combobox", {
options: {
minLengthToAutocomplete: 0,
},
_create: function() {
var savMinLengthToAutocomplete = this.options.minLengthToAutocomplete;
var self = this,
select = this.element.hide(),
selected = select.children( ":selected" ),
@ -781,7 +785,7 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
.val( value )
.autocomplete({
delay: 0,
minLength: 0,
minLength: this.options.minLengthToAutocomplete,
source: function( request, response ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
response( select.children( "option" ).map(function() {
@ -854,7 +858,9 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
}
// pass empty string as value to search for, displaying all results
input.autocomplete({ minLength: 0 });
input.autocomplete( "search", "" );
input.autocomplete({ minLength: savMinLengthToAutocomplete });
input.focus();
});
},

View File

@ -303,11 +303,12 @@ function ajax_dialog($title,$message,$w=350,$h=150)
* @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @return string Return html string to convert a select field into a combo
*/
function ajax_combobox($htmlname, $event=array())
function ajax_combobox($htmlname, $event=array(), $minLengthToAutocomplete=0)
{
$msg = '<script type="text/javascript">
$(function() {
$("#'.$htmlname.'").combobox({
minLengthToAutocomplete : '.$minLengthToAutocomplete.',
selected : function(event,ui) {
var obj = '.json_encode($event).';
$.each(obj, function(key,values) {

View File

@ -42,19 +42,12 @@ function societe_prepare_head($object)
$head[$h][2] = 'card';
$h++;
// TODO Remove tests on object->object. Functions must be called with a company object directly
if (($object->client==2 || $object->client==3
|| (isset($object->object) && $object->object->client==2) || (isset($object->object) && $object->object->client==3)) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
{
$head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Prospect");
$head[$h][2] = 'prospect';
$h++;
}
if ($object->client==1 || $object->client==3 || (isset($object->object) && $object->object->client==1) || (isset($object->object) && $object->object->client==3))
if ($object->client==1 || $object->client==2 || $object->client==3 || (isset($object->object) && $object->object->client==1) || (isset($object->object) && $object->object->client==3))
{
$head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Customer");
if ($object->client==2 || $object->client==3) $head[$h][1] = $langs->trans("Prospect");
if ($object->client==3) $head[$h][1] .= '/';
if ($object->client==1 || $object->client==3) $head[$h][1] .= $langs->trans("Customer");
$head[$h][2] = 'customer';
$h++;
}

View File

@ -52,6 +52,10 @@ function emailing_prepare_head($object)
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing');
complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing','remove');
return $head;
}

View File

@ -65,15 +65,8 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
$path=preg_replace('/([\\/]+)$/i','',$path);
$newpath=dol_osencode($path);
if (! $nohook) {
if (! is_object($hookmanager))
{
if (! class_exists('HookManager')) {
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
}
}
if (! $nohook)
{
$hookmanager->initHooks(array('fileslib'));
$parameters=array(
@ -271,6 +264,7 @@ function dol_mimetype($file,$default='application/octet-stream',$mode=0)
if (preg_match('/\.(h)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='h'; }
if (preg_match('/\.(java|jsp)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='java'; }
if (preg_match('/\.php([0-9]{1})?$/i',$tmpfile)) { $mime='text/plain'; $imgmime='php.png'; $srclang='php'; }
if (preg_match('/\.phtml$/i',$tmpfile)) { $mime='text/plain'; $imgmime='php.png'; $srclang='php'; }
if (preg_match('/\.(pl|pm)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='pl.png'; $srclang='perl'; }
if (preg_match('/\.sql$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='sql'; }
if (preg_match('/\.js$/i',$tmpfile)) { $mime='text/x-javascript'; $imgmime='jscript.png'; $srclang='js'; }
@ -653,14 +647,6 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
return -2;
}
if (! is_object($hookmanager))
{
if (! class_exists('HookManager')) {
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
}
$hookmanager=new HookManager($db);
}
$hookmanager->initHooks(array('fileslib'));
$parameters=array('filename' => $file_name, 'varfiles' => $varfiles, 'allowoverwrite' => $allowoverwrite);
@ -722,14 +708,6 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
if (empty($nohook))
{
if (! is_object($hookmanager))
{
if (! class_exists('HookManager')) {
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
}
}
$hookmanager->initHooks(array('fileslib'));
$parameters=array(

View File

@ -51,15 +51,18 @@ function getStaticMember($class, $member)
$classObj = new ReflectionClass($class);
$result = null;
$found=0;
foreach($classObj->getStaticProperties() as $prop => $value)
{
if($prop == $member)
if ($prop == $member)
{
$result = $value;
$found++;
break;
}
}
if (! $found) dol_print_error('','Try to get a static member "'.$member.'" in class "'.$class.'" that does not exists or is not static.');
return $result;
}
@ -670,7 +673,7 @@ function dol_get_fiche_end($notab=0)
function dol_format_address($object)
{
$ret='';
$countriesusingstate=array('US','IN','GB');
$countriesusingstate=array('US','IN','GB','ES');
// Address
$ret .= $object->address;
@ -693,6 +696,16 @@ function dol_format_address($object)
}
if ($object->zip) $ret .= ($ret ? "\n" : '' ).$object->zip;
}
else if (in_array($object->country_code,array('ES'))) // title firstname name \n address lines \n zip town \n state \n country
{
$ret .= ($ret ? "\n" : '' ).$object->zip;
$ret .= ' '.$object->town;
if ($object->state && in_array($object->country_code,$countriesusingstate))
{
$ret.="\n".$object->state;
}
}
else // Other: title firstname name \n address lines \n zip town \n country
{
$ret .= ($ret ? "\n" : '' ).$object->zip;
@ -2122,7 +2135,7 @@ function dol_print_error($db='',$error='')
$out.="<br>\n";
$out.="<b>".$langs->trans("RequestedUrl").":</b> ".$_SERVER["REQUEST_URI"]."<br>\n";;
$out.="<b>".$langs->trans("Referer").":</b> ".(isset($_SERVER["HTTP_REFERER"])?$_SERVER["HTTP_REFERER"]:'')."<br>\n";;
$out.="<b>".$langs->trans("MenuManager").":</b> ".$conf->standard_menu."<br>\n";
$out.="<b>".$langs->trans("MenuManager").":</b> ".(isset($conf->standard_menu)?$conf->standard_menu:'')."<br>\n";
$out.="<br>\n";
$syslog.="url=".$_SERVER["REQUEST_URI"];
$syslog.=", query_string=".$_SERVER["QUERY_STRING"];
@ -4221,6 +4234,18 @@ function colorArrayToHex($arraycolor,$colorifnotfound='888888')
return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]);
}
/**
* Set focus onto field with selector
*
* @param string $selector Selector ('#id')
* @return string HTML code to set focus
*/
function dol_set_focus($selector)
{
print '<!-- Set focus onto a specific field -->'."\n";
print '<script type="text/javascript" language="javascript">jQuery(document).ready(function() { jQuery("'.$selector.'").focus(); });</script>'."\n";
}
if (! function_exists('getmypid'))
{

View File

@ -265,7 +265,8 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
if ($mode == 'target' && ! is_object($targetcompany)) return -1;
if ($mode == 'delivery' && ! is_object($deliverycompany)) return -1;
if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) $sourcecompany->departement=getState($sourcecompany->state_id);
if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) $sourcecompany->departement=getState($sourcecompany->state_id); //TODO: Deprecated
if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state=getState($sourcecompany->state_id);
if (! empty($targetcompany->state_id) && empty($targetcompany->departement)) $targetcompany->departement=getState($targetcompany->state_id);
if ($mode == 'source')
@ -792,12 +793,11 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
* @param float $h Cell minimum height. The cell extends automatically if needed.
* @param int $align Align
* @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)
{
$linkedobjects = pdf_getLinkedObjects($object,$outputlangs,$hookmanager);
$linkedobjects = pdf_getLinkedObjects($object,$outputlangs);
if (! empty($linkedobjects))
{
foreach($linkedobjects as $linkedobject)
@ -833,12 +833,11 @@ function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$al
* @param int $hideref Hide reference
* @param int $hidedesc Hide description
* @param int $issupplierline Is it a line for a supplier object ?
* @param HookManager $hookmanager Instance of HookManager
* @return void
*/
function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hideref=0,$hidedesc=0,$issupplierline=0,$hookmanager=false)
function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hideref=0,$hidedesc=0,$issupplierline=0)
{
global $db, $conf, $langs;
global $db, $conf, $langs, $hookmanager;
if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{
@ -1002,9 +1001,11 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0)
{
if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
global $hookmanager;
if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
{
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
@ -1024,12 +1025,13 @@ function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0,$hookmanager=fals
* @param int $i Current line number
* @param Translate $outputlangs Object langs for output
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0)
{
if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
global $hookmanager;
if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
{
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
@ -1048,12 +1050,13 @@ function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0,$hookmanager=fals
* @param int $i Current line number
* @param Translate $outputlangs Object langs for output
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0)
{
if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
global $hookmanager;
if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
{
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
@ -1072,12 +1075,13 @@ function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0,$hookman
* @param int $i Current line number
* @param Translate $outputlangs Object langs for output
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0)
{
if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
global $hookmanager;
if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
{
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
@ -1098,12 +1102,11 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0,$hookmanager=
* @param int $i Current line number
* @param Translate $outputlangs Object langs for output
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0)
{
global $conf;
global $conf, $hookmanager;
$sign=1;
if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
@ -1133,7 +1136,9 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanage
*/
function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0)
{
if (! empty($object->hooks) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
global $hookmanager;
if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
{
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
@ -1155,11 +1160,12 @@ function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0)
* @param int $i Current line number
* @param Translate $outputlangs Object langs for output
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0)
{
global $hookmanager;
if ($object->lines[$i]->special_code != 3)
{
if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
@ -1184,11 +1190,12 @@ function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0,$hookmanager=fals
* @param int $i Current line number
* @param Translate $outputlangs Object langs for output
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0)
{
global $hookmanager;
if ($object->lines[$i]->special_code != 3)
{
if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
@ -1213,11 +1220,12 @@ function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0,$hookmanage
* @param int $i Current line number
* @param Translate $outputlangs Object langs for output
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0)
{
global $hookmanager;
if ($object->lines[$i]->special_code != 3)
{
if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
@ -1242,11 +1250,12 @@ function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0,$hookmana
* @param int $i Current line number
* @param Translate $outputlangs Object langs for output
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0)
{
global $hookmanager;
if ($object->lines[$i]->special_code != 3)
{
if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
@ -1271,11 +1280,12 @@ function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0,$hookm
* @param int $i Current line number
* @param Translate $outputlangs Object langs for output
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0)
{
global $hookmanager;
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if ($object->lines[$i]->special_code != 3)
@ -1302,12 +1312,11 @@ function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0,$hookma
* @param int $i Current line number
* @param Translate $outputlangs Object langs for output
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false)
function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0)
{
global $conf;
global $conf, $hookmanager;
$sign=1;
if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
@ -1344,13 +1353,15 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0,$hookman
*/
function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0)
{
global $hookmanager;
if ($object->lines[$i]->special_code == 3)
{
return $outputlangs->transnoentities("Option");
}
else
{
if (! empty($object->hooks) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
{
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
@ -1373,11 +1384,12 @@ function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0)
* @param Object $object Object
* @param string $type Type
* @param Translate $outputlangs Object langs for output
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false)
function pdf_getTotalQty($object,$type,$outputlangs)
{
global $hookmanager;
$total=0;
$nblignes=count($object->lines);
@ -1390,7 +1402,7 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false)
{
$total += $object->lines[$i]->qty;
}
else if ($type==9 && ! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
else if ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
{
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
@ -1415,11 +1427,12 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false)
*
* @param object $object Object
* @param Translate $outputlangs Object lang for output
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function pdf_getLinkedObjects($object,$outputlangs,$hookmanager=false)
function pdf_getLinkedObjects($object,$outputlangs)
{
global $hookmanager;
$linkedobjects=array();
$object->fetchObjectLinked();

View File

@ -131,11 +131,6 @@ function dol_loginfunction($langs,$conf,$mysoc)
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);
}
$hookmanager->initHooks(array('mainloginpage'));
$langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang'));

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2007-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,6 +23,8 @@
*/
// ------------------------------- Used by category tree view -----------------
/**
* Return if a child id is in descendance of parentid
*
@ -145,7 +147,7 @@ function tree_showpad(&$fulltree,$key,$silent=0)
/**
* Show an element with correct offset
*
* @param array $tab Array of all elements
* @param array $tab Array of element
* @param int $rang Level of offset
* @return void
*/
@ -153,62 +155,15 @@ function tree_showline($tab,$rang)
{
global $conf, $rangLast, $idLast, $menu_handler;
if ($conf->use_javascript_ajax)
{
if($rang == $rangLast)
{
print '<script type="text/javascript">imgDel('.$idLast.');</script>';
//print '<a href="'.DOL_URL_ROOT.'/admin/menus/index.php?menu_handler=eldy&action=delete&menuId='.$idLast.'">aa</a>';
}
elseif($rang > $rangLast)
{
print '<li><ul>';
}
elseif($rang < $rangLast)
{
print '<script type="text/javascript">imgDel('.$idLast.')</script>';
for($i=$rang; $i < $rangLast; $i++)
{
print '</ul></li>';
echo "\n";
}
}
}
else
{
if($rang > $rangLast)
{
print '<li><ul>';
}
elseif($rang < $rangLast)
{
for($i=$rang; $i < $rangLast; $i++)
{
print '</ul></li>';
echo "\n";
}
}
}
print '<li id=li'.$tab['rowid'].'>';
// Content of line
print '<strong> &nbsp;<a href="edit.php?menu_handler='.$menu_handler.'&action=edit&menuId='.$tab['rowid'].'">'.$tab['title'].'</a></strong>';
print '<div class="menuEdit"><a href="edit.php?menu_handler='.$menu_handler.'&action=edit&menuId='.$tab['rowid'].'">'.img_edit('default',0,'class="menuEdit" id="edit'.$tab['rowid'].'"').'</a></div>';
print '<div class="menuNew"><a href="edit.php?menu_handler='.$menu_handler.'&action=create&menuId='.$tab['rowid'].'">'.img_edit_add('default',0,'class="menuNew" id="new'.$tab['rowid'].'"').'</a></div>';
print '<div class="menuDel"><a href="index.php?menu_handler='.$menu_handler.'&action=delete&menuId='.$tab['rowid'].'">'.img_delete('default',0,'class="menuDel" id="del'.$tab['rowid'].'"').'</a></div>';
print '<div class="menuFleche"><a href="index.php?menu_handler='.$menu_handler.'&action=up&menuId='.$tab['rowid'].'">'.img_picto("Monter","1uparrow").'</a><a href="index.php?menu_handler='.$menu_handler.'&action=down&menuId='.$tab['rowid'].'">'.img_picto("Descendre","1downarrow").'</a></div>';
print '</li>';
echo "\n";
print '<table class="nobordernopadding centpercent"><tr><td>';
print '<strong> &nbsp; <a href="edit.php?menu_handler='.$menu_handler.'&action=edit&menuId='.$tab['rowid'].'">'.$tab['title'].'</a></strong>';
print '</td><td align="right">';
print '<a href="edit.php?menu_handler='.$menu_handler.'&action=edit&menuId='.$tab['rowid'].'">'.img_edit('default',0,'class="menuEdit" id="edit'.$tab['rowid'].'"').'</a> ';
print '<a href="edit.php?menu_handler='.$menu_handler.'&action=create&menuId='.$tab['rowid'].'">'.img_edit_add('default',0,'class="menuNew" id="new'.$tab['rowid'].'"').'</a> ';
print '<a href="index.php?menu_handler='.$menu_handler.'&action=delete&menuId='.$tab['rowid'].'">'.img_delete('default',0,'class="menuDel" id="del'.$tab['rowid'].'"').'</a> ';
print '<a href="index.php?menu_handler='.$menu_handler.'&action=up&menuId='.$tab['rowid'].'">'.img_picto("Monter","1uparrow").'</a><a href="index.php?menu_handler='.$menu_handler.'&action=down&menuId='.$tab['rowid'].'">'.img_picto("Descendre","1downarrow").'</a>';
print '</td></tr></table>';
$rangLast = $rang;
$idLast = $tab['rowid'];
@ -218,41 +173,63 @@ function tree_showline($tab,$rang)
/**
* Recursive function to output menu tree
*
* @param array $tab Array of elements
* @param array $tab Array of all elements
* @param int $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>)
* @param int $rang Level of element
* @return void
*/
function tree_recur($tab,$pere,$rang)
{
if (empty($pere['rowid'])) print '<ul class="arbre">';
if (empty($pere['rowid']))
{
// Test also done with jstree and dynatree (not able to have <a> inside label)
print '<script type="text/javascript" language="javascript">
$(document).ready(function(){
$("#iddivjstree").treeview({
collapsed: true,
animated: "fast",
persist: "location"
});
})
</script>';
print '<ul id="iddivjstree" style="min-height:300px;">';
}
if ($rang > 10) return; // Protection contre boucle infinie
//ballayage du tableau
$sizeoftab=count($tab);
$ulprinted=0;
for ($x=0; $x < $sizeoftab; $x++)
{
//var_dump($tab[$x]);exit;
// If an element has $pere for parent
if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid'])
{
if (empty($ulprinted) && ! empty($pere['rowid'])) { print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; }
print "\n".'<li>';
// We shot it with an offset
tree_showline($tab[$x],$rang);
// And now we search all its sons of lower level
tree_recur($tab,$tab[$x],$rang+1);
print '</li>';
}
elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu'])
{
if (empty($ulprinted) && ! empty($pere['rowid'])) { print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; }
print "\n".'<li>';
// We shot it with an offset
tree_showline($tab[$x],$rang);
// And now we search all its sons of lower level
tree_recur($tab,$tab[$x],$rang+1);
print '</li>';
}
}
if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; }
if (empty($pere['rowid'])) print '</ul>';
}

View File

@ -45,11 +45,16 @@ function trip_prepare_head($object)
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'trip');
$head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/document.php?id='.$object->id;
$head[$h][1] = $langs->trans("Documents");
$head[$h][2] = 'documents';
$h++;
$head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'trip','remove');
return $head;

View File

@ -148,6 +148,8 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
// ldap2dolibarr synchronisation
if ($login && ! empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')
{
dol_syslog("functions_ldap::check_user_password_ldap Sync ldap2dolibarr");
// On charge les attributs du user ldap
if ($ldapdebug) print "DEBUG: login ldap = ".$login."<br>\n";
$resultFetchLdapUser = $ldap->fetch($login,$userSearchFilter);
@ -164,6 +166,7 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
$resultFetchUser=$user->fetch('',$login,$sid);
if ($resultFetchUser > 0)
{
dol_syslog("functions_ldap::check_user_password_ldap Sync user found id=".$user->id);
// On verifie si le login a change et on met a jour les attributs dolibarr
if ($user->login != $ldap->login && $ldap->login)
{
@ -171,7 +174,8 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
$user->update($user);
// TODO Que faire si update echoue car on update avec un login deja existant.
}
//$resultUpdate = $user->update_ldap2dolibarr();
//$resultUpdate = $user->update_ldap2dolibarr($ldap);
}
}
}

View File

@ -1,62 +0,0 @@
<?php
/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/menus/smartphone/smartphone_backoffice.php
* \brief Gestionnaire nomme smartphone du menu smartphone
*/
/**
* Class to manage smartphone menu smartphone (for internal users)
*/
class MenuSmart
{
var $db;
var $require_left=array("smartphone_backoffice"); // Si doit etre en phase avec un gestionnaire de menu particulier
var $hideifnotallowed=0; // Put 0 for back office menu, 1 for front office menu
var $atarget=""; // Valeur du target a utiliser dans les liens
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
function __construct($db)
{
$this->db=$db;
}
/**
* Show menu
*
* @param string $limitmenuto To limit menu to a top or left menu value
* @return void
*/
function showmenu($limitmenuto)
{
require_once DOL_DOCUMENT_ROOT.'/core/menus/smartphone/smartphone.lib.php';
print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed,$limitmenuto);
}
}
?>

View File

@ -17,46 +17,57 @@
*/
/**
* \file htdocs/core/menus/smartphone/smartphone_frontoffice.php
* \brief Gestionnaire nomme smartphone du menu smartphone
* \file htdocs/core/menus/smartphone/smartphone_menu.php
* \brief Menu smartphone manager
*/
/**
* Class to manage smartphone menu smartphone (for external users)
* Class to manage smartphone menu smartphone
*/
class MenuSmart
{
var $require_left=array("smartphone_frontoffice"); // Si doit etre en phase avec un gestionnaire de menu particulier
var $hideifnotallowed=1; // Put 0 for back office menu, 1 for front office menu
var $atarget=""; // Valeur du target a utiliser dans les liens
var $name="smartphone";
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param DoliDB $db Database handler
* @param int $type_user Type of user
*/
function __construct($db)
function __construct($db, $type_user)
{
$this->db=$db;
}
/**
* Show menu
* Show menu
*
* @param string $limitmenuto To limit menu to a top or left menu value
* @return void
* @param string $mode 'top' or 'left'
* @return int Number of menu entries shown
*/
function showmenu($limitmenuto)
function showmenu($mode)
{
require_once DOL_DOCUMENT_ROOT.'/core/menus/smartphone/smartphone.lib.php';
global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/menus/smartphone/smartphone.lib.php';
print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed,$limitmenuto);
if ($this->type_user == 1)
{
$conf->global->MAIN_SEARCHFORM_SOCIETE=0;
$conf->global->MAIN_SEARCHFORM_CONTACT=0;
}
print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed,$mode);
return 1;
}
}
?>
?>

View File

@ -1,75 +0,0 @@
<?php
/* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008-2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/menus/standard/auguria_backoffice.php
* \brief Gestionnaire nomme Auguria du menu du haut
*
* \remarks La construction d'un gestionnaire pour le menu du haut est simple:
* \remarks Toutes les entrees de menu a faire apparaitre dans la barre du haut
* \remarks doivent etre affichees par <a class="tmenu" href="...?mainmenu=...">...</a>
* \remarks ou si menu selectionne <a class="tmenusel" href="...?mainmenu=...">...</a>
*/
/**
* Classe permettant la gestion du menu du haut Auguria
*/
class MenuManager
{
var $db;
var $require_left=array("auguria_backoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier
var $type_user=0; // Put 0 for internal users, 1 for external users
var $atarget=""; // Valeur du target a utiliser dans les liens
var $menu_array;
var $menu_array_after;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db=$db;
}
/**
* Show menu
*
* @param string $mode 'top' or 'left'
* @return int Number of menu entries shown
*/
function showmenu($mode)
{
require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php';
$res='ErrorBadParameterForMode';
if ($mode == 'top') $res=print_auguria_menu($this->db,$this->atarget,$this->type_user);
if ($mode == 'left') $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after);
return $res;
}
}
?>

View File

@ -18,26 +18,21 @@
*/
/**
* \file htdocs/core/menus/standard/auguria_frontoffice.php
* \brief Gestionnaire nomme Auguria du menu du haut
*
* \remarks La construction d'un gestionnaire pour le menu du haut est simple:
* \remarks Toutes les entrees de menu a faire apparaitre dans la barre du haut
* \remarks doivent etre affichees par <a class="tmenu" href="...?mainmenu=...">...</a>
* \remarks ou si menu selectionne <a class="tmenusel" href="...?mainmenu=...">...</a>
* \file htdocs/core/menus/standard/auguria_menu.php
* \brief Menu auguria manager
*/
/**
* Classe permettant la gestion du menu du haut Auguria
* Class to manage menu Auguria
*/
class MenuManager
{
var $db;
var $require_left=array("auguria_backoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier
var $type_user=1; // Put 0 for internal users, 1 for external users
var $atarget=""; // Valeur du target a utiliser dans les liens
var $type_user; // Put 0 for internal users, 1 for external users
var $atarget=""; // Valeur du target a utiliser dans les liens
var $name="auguria";
var $menu_array;
var $menu_array_after;
@ -45,11 +40,13 @@ class MenuManager
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param DoliDB $db Database handler
* @param int $type_user Type of user
*/
function __construct($db)
function __construct($db, $type_user)
{
$this->db=$db;
$this->type_user=$type_user;
$this->db=$db;
}
@ -65,9 +62,12 @@ class MenuManager
require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php';
$conf->global->MAIN_SEARCHFORM_SOCIETE=0;
$conf->global->MAIN_SEARCHFORM_CONTACT=0;
if ($this->type_user == 1)
{
$conf->global->MAIN_SEARCHFORM_SOCIETE=0;
$conf->global->MAIN_SEARCHFORM_CONTACT=0;
}
$res='ErrorBadParameterForMode';
if ($mode == 'top') $res=print_auguria_menu($this->db,$this->atarget,$this->type_user);
if ($mode == 'left') $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after);

View File

@ -68,7 +68,7 @@ function print_eldy_menu($db,$atarget,$type_user)
// Third parties
$tmpentry=array('enabled'=>($conf->societe->enabled || $conf->fournisseur->enabled), 'perms'=>($user->rights->societe->lire || $user->rights->fournisseur->lire), 'module'=>'societe|fournisseur');
$tmpentry=array('enabled'=>(! empty($conf->societe->enabled) || ! empty($conf->fournisseur->enabled)), 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), 'module'=>'societe|fournisseur');
$showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal);
if ($showmode)
{
@ -110,7 +110,7 @@ function print_eldy_menu($db,$atarget,$type_user)
}
// Products-Services
$tmpentry=array('enabled'=>($conf->product->enabled || $conf->service->enabled), 'perms'=>($user->rights->produit->lire || $user->rights->service->lire), 'module'=>'product|service');
$tmpentry=array('enabled'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'perms'=>(! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)), 'module'=>'product|service');
$showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal);
if ($showmode)
{
@ -160,7 +160,7 @@ function print_eldy_menu($db,$atarget,$type_user)
if (! empty($conf->fournisseur->enabled)) $menuqualified++;
if (! empty($conf->contrat->enabled)) $menuqualified++;
if (! empty($conf->ficheinter->enabled)) $menuqualified++;
$tmpentry=array('enabled'=>$menuqualified, 'perms'=>($user->rights->societe->lire || $user->rights->societe->contact->lire), 'module'=>'propal|commande|fournisseur|contrat|ficheinter');
$tmpentry=array('enabled'=>$menuqualified, 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), 'module'=>'propal|commande|fournisseur|contrat|ficheinter');
$showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal);
if ($showmode)
{
@ -201,7 +201,7 @@ function print_eldy_menu($db,$atarget,$type_user)
// Financial
$tmpentry=array('enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->don->enabled) || ! empty($conf->tax->enabled)),
'perms'=>($user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire || $user->rights->facture->lire || $user->rights->deplacement->lire || $user->rights->don->lire || $user->rights->tax->charges->lire),
'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->plancompte->lire) || ! empty($user->rights->facture->lire) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire)),
'module'=>'comptabilite|accounting|facture|deplacement|don|tax');
$showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal);
if ($showmode)
@ -243,7 +243,7 @@ function print_eldy_menu($db,$atarget,$type_user)
// Bank
$tmpentry=array('enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)),
'perms'=>($user->rights->banque->lire || $user->rights->prelevement->lire),
'perms'=>(! empty($user->rights->banque->lire) || ! empty($user->rights->prelevement->lire)),
'module'=>'banque|prelevement');
$showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal);
if ($showmode)
@ -286,7 +286,7 @@ function print_eldy_menu($db,$atarget,$type_user)
// Projects
$tmpentry=array('enabled'=>(! empty($conf->projet->enabled)),
'perms'=>($user->rights->projet->lire),
'perms'=>(! empty($user->rights->projet->lire)),
'module'=>'projet');
$showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal);
if ($showmode)
@ -328,7 +328,7 @@ function print_eldy_menu($db,$atarget,$type_user)
// Tools
$tmpentry=array('enabled'=>(! empty($conf->mailing->enabled) || ! empty($conf->export->enabled) || ! empty($conf->import->enabled)),
'perms'=>($user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run),
'perms'=>(! empty($user->rights->mailing->lire) || ! empty($user->rights->export->lire) || ! empty($user->rights->import->run)),
'module'=>'mailing|export|import');
$showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal);
if ($showmode)
@ -400,7 +400,7 @@ function print_eldy_menu($db,$atarget,$type_user)
// Members
$tmpentry=array('enabled'=>(! empty($conf->adherent->enabled)),
'perms'=>($user->rights->adherent->lire),
'perms'=>(! empty($user->rights->adherent->lire)),
'module'=>'adherent');
$showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal);
if ($showmode)
@ -836,7 +836,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
{
$langs->load("propal");
$newmenu->add("/comm/propal/index.php?leftmenu=propals", $langs->trans("Prop"), 0, $user->rights->propale->lire, '', $mainmenu, 'propals');
$newmenu->add("/societe/societe.php?leftmenu=propals", $langs->trans("NewPropal"), 1, $user->rights->propale->creer);
$newmenu->add("/comm/propal.php?action=create&amp;leftmenu=propals", $langs->trans("NewPropal"), 1, $user->rights->propale->creer);
$newmenu->add("/comm/propal/list.php?leftmenu=propals", $langs->trans("List"), 1, $user->rights->propale->lire);
if ($leftmenu=="propals") $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=0", $langs->trans("PropalsDraft"), 2, $user->rights->propale->lire);
if ($leftmenu=="propals") $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=1", $langs->trans("PropalsOpened"), 2, $user->rights->propale->lire);

View File

@ -1,74 +0,0 @@
<?php
/* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/menus/standard/eldy_backoffice.php
* \brief Gestionnaire nomme eldy du menu du haut
*
* \remarks La construction d'un gestionnaire pour le menu du haut est simple:
* \remarks Toutes les entrees de menu a faire apparaitre dans la barre du haut
* \remarks doivent etre affichees par <a class="tmenu" href="...?mainmenu=...">...</a>
* \remarks ou si menu selectionne <a class="tmenusel" href="...?mainmenu=...">...</a>
*/
/**
* Classe to manage menu Eldy
*/
class MenuManager
{
var $db;
var $require_left=array("eldy_backoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier
var $type_user=0; // Put 0 for internal users, 1 for external users
var $atarget=""; // Valeur du target a utiliser dans les liens
var $menu_array;
var $menu_array_after;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db=$db;
}
/**
* Show menu
*
* @param string $mode 'top' or 'left'
* @return int Number of menu entries shown
*/
function showmenu($mode)
{
require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php';
$res='ErrorBadParameterForMode';
if ($mode == 'top') $res=print_eldy_menu($this->db,$this->atarget,$this->type_user);
if ($mode == 'left') $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after);
return $res;
}
}
?>

View File

@ -17,26 +17,21 @@
*/
/**
* \file htdocs/core/menus/standard/eldy_frontoffice.php
* \brief Gestionnaire nomme eldy du menu du haut
*
* \remarks La construction d'un gestionnaire pour le menu du haut est simple:
* \remarks Toutes les entrees de menu a faire apparaitre dans la barre du haut
* \remarks doivent etre affichees par <a class="tmenu" href="...?mainmenu=...">...</a>
* \remarks ou si menu selectionne <a class="tmenusel" href="...?mainmenu=...">...</a>
* \file htdocs/core/menus/standard/eldy_menu.php
* \brief Menu eldy manager
*/
/**
* Class to manage menu Eldy (for external users)
* Class to manage menu Eldy
*/
class MenuManager
{
var $db;
var $require_left=array("eldy_frontoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier
var $type_user=1; // Put 0 for internal users, 1 for external users
var $type_user; // Put 0 for internal users, 1 for external users
var $atarget=""; // Valeur du target a utiliser dans les liens
var $name="eldy";
var $menu_array;
var $menu_array_after;
@ -44,10 +39,12 @@ class MenuManager
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param DoliDB $db Database handler
* @param int $type_user Type of user
*/
function __construct($db)
function __construct($db, $type_user)
{
$this->type_user=$type_user;
$this->db=$db;
}
@ -55,8 +52,8 @@ class MenuManager
/**
* Show menu
*
* @param string $mode 'top' or 'left'
* @return int Number of menu entries shown
* @param string $mode 'top' or 'left'
* @return int Number of menu entries shown
*/
function showmenu($mode)
{
@ -64,8 +61,11 @@ class MenuManager
require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php';
$conf->global->MAIN_SEARCHFORM_SOCIETE=0;
$conf->global->MAIN_SEARCHFORM_CONTACT=0;
if ($this->type_user == 1)
{
$conf->global->MAIN_SEARCHFORM_SOCIETE=0;
$conf->global->MAIN_SEARCHFORM_CONTACT=0;
}
$res='ErrorBadParameterForMode';
if ($mode == 'top') $res=print_eldy_menu($this->db,$this->atarget,$this->type_user);

View File

@ -26,7 +26,6 @@
class MenuManager
{
var $db;
var $require_left=array("empty"); // If this top menu handler must be used with a particular left menu handler
var $type_user=0; // Put 0 for internal users, 1 for external users
var $atarget=""; // To store arget to use in menu links

View File

@ -97,7 +97,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
{
global $conf;
return array(
$resarray=array(
'object_id'=>$object->id,
'object_ref'=>$object->ref,
'object_ref_ext'=>$object->ref_ext,
@ -120,6 +120,15 @@ class doc_generic_order_odt extends ModelePDFCommandes
'object_note_private'=>$object->note,
'object_note'=>$object->note_public,
);
// Add vat by rates
foreach ($object->lines as $line)
{
if (empty($resarray['object_total_vat_'.$line->tva_tx])) $resarray['object_total_vat_'.$line->tva_tx]=0;
$resarray['object_total_vat_'.$line->tva_tx]+=$line->total_tva;
}
return $resarray;
}
/**
@ -238,12 +247,11 @@ class doc_generic_order_odt extends ModelePDFCommandes
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
* @param object $hookmanager Hookmanager object
* @return int 1 if OK, <=0 if KO
*/
function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
{
global $user,$langs,$conf,$mysoc;
global $user,$langs,$conf,$mysoc,$hookmanager;
if (empty($srctemplatepath))
{

View File

@ -133,12 +133,11 @@ class pdf_einstein extends ModelePDFCommandes
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
* @param object $hookmanager Hookmanager object
* @return int 1=OK, 0=KO
*/
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
{
global $user,$langs,$conf,$mysoc,$db;
global $user,$langs,$conf,$mysoc,$db,$hookmanager;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@ -230,7 +229,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager);
$this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
@ -284,7 +283,7 @@ class pdf_einstein extends ModelePDFCommandes
$showpricebeforepagebreak=1;
$pdf->startTransaction();
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
$pageposafter=$pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
@ -292,7 +291,7 @@ class pdf_einstein extends ModelePDFCommandes
$pageposafter=$pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
@ -300,7 +299,7 @@ class pdf_einstein extends ModelePDFCommandes
{
$pdf->AddPage('','',true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pagenb+1);
}
}
@ -331,18 +330,18 @@ class pdf_einstein extends ModelePDFCommandes
// VAT Rate
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxtva, $curY);
$pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
}
// Unit price before discount
$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxup, $curY);
$pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0);
// Quantity
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager);
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R'); // Enough for 6 chars
@ -350,12 +349,12 @@ class pdf_einstein extends ModelePDFCommandes
if ($object->lines[$i]->remise_percent)
{
$pdf->SetXY($this->posxdiscount-2, $curY);
$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager);
$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
$pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
}
// Total HT line
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->postotalht, $curY);
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
@ -426,7 +425,7 @@ class pdf_einstein extends ModelePDFCommandes
$pagenb++;
$pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{
@ -443,7 +442,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
}
@ -973,6 +972,9 @@ class pdf_einstein extends ModelePDFCommandes
$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
}
$pdf->SetDrawColor(128,128,128);
@ -1041,12 +1043,11 @@ class pdf_einstein extends ModelePDFCommandes
* @param Object $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @param object $hookmanager Hookmanager object
* @return void
*/
function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager)
function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
global $conf,$langs;
global $conf,$langs,$hookmanager;
$outputlangs->load("main");
$outputlangs->load("bills");
@ -1125,7 +1126,7 @@ class pdf_einstein extends ModelePDFCommandes
$posy+=2;
// Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
if ($showaddress)
{

View File

@ -157,12 +157,11 @@ abstract class ModeleNumRefCommandes
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
* @param HookManager $hookmanager Hook manager instance
* @return int 0 if KO, 1 if OK
*/
function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false)
function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
{
global $conf,$user,$langs;
global $conf,$user,$langs,$hookmanager;
$langs->load("orders");
$error=0;
@ -223,7 +222,7 @@ function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output=$outputlangs->charset_output;
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0)
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0)
{
$outputlangs->charset_output=$sav_charset_output;

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