| '.$langs->trans("CreatedBy").' | ';
diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php
index 51f9a83ed3c..61e366d0ce5 100644
--- a/htdocs/compta/prelevement/class/rejetprelevement.class.php
+++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php
@@ -87,7 +87,7 @@ class RejetPrelevement
dol_syslog("RejetPrelevement::Create id $id");
$bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT;
- $facs = $this->getListInvoices();
+ $facs = $this->getListInvoices(1);
$this->db->begin();
@@ -132,7 +132,7 @@ class RejetPrelevement
for ($i = 0; $i < $num; $i++)
{
$fac = new Facture($this->db);
- $fac->fetch($facs[$i]);
+ $fac->fetch($facs[$i][0]);
// Make a negative payment
$pai = new Paiement($this->db);
@@ -144,7 +144,7 @@ class RejetPrelevement
* PHP installs sends only the part integer negative
*/
- $pai->amounts[$facs[$i]] = price2num($fac->total_ttc * -1);
+ $pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * -1);
$pai->datepaye = $date_rejet;
$pai->paiementid = 3; // type of payment: withdrawal
$pai->num_paiement = $fac->ref;
@@ -152,7 +152,7 @@ class RejetPrelevement
if ($pai->create($this->user) < 0) // we call with no_commit
{
$error++;
- dol_syslog("RejetPrelevement::Create Error creation payment invoice ".$facs[$i]);
+ dol_syslog("RejetPrelevement::Create Error creation payment invoice ".$facs[$i][0]);
}
else
{
@@ -269,22 +269,24 @@ class RejetPrelevement
}
/**
- * Retrieve the list of invoices
+ * Retrieve the list of invoices
+ * @param int $amounts If you want to get the amount of the order for each invoice
*
- * @return void
+ * @return Array List of invoices related to the withdrawal line
+ * @TODO A withdrawal line is today linked to one and only one invoice. So the function should return only one object ?
*/
- private function getListInvoices()
+ private function getListInvoices($amounts=0)
{
global $conf;
$arr = array();
//Returns all invoices of a withdrawal
- $sql = "SELECT f.rowid as facid";
+ $sql = "SELECT f.rowid as facid, pl.amount";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture as pf";
- $sql.= ", ".MAIN_DB_PREFIX."facture as f";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_lignes as pl ON (pf.fk_prelevement_lignes = pl.rowid)";
$sql.= " WHERE pf.fk_prelevement_lignes = ".$this->id;
- $sql.= " AND pf.fk_facture = f.rowid";
$sql.= " AND f.entity = ".$conf->entity;
$resql=$this->db->query($sql);
@@ -298,7 +300,14 @@ class RejetPrelevement
while ($i < $num)
{
$row = $this->db->fetch_row($resql);
- $arr[$i] = $row[0];
+ if (!$amounts) $arr[$i] = $row[0];
+ else
+ {
+ $arr[$i] = array(
+ $row[0],
+ $row[1]
+ );
+ }
$i++;
}
}
diff --git a/htdocs/contact/exportimport.php b/htdocs/contact/exportimport.php
index bcb3b9c2be0..c76655f5099 100644
--- a/htdocs/contact/exportimport.php
+++ b/htdocs/contact/exportimport.php
@@ -33,80 +33,80 @@ $id = GETPOST('id', 'int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
+$contact = new Contact($db);
+
/*
* View
*/
+$form = new Form($db);
+
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
-$form = new Form($db);
-
-$contact = new Contact($db);
-$contact->fetch($id, $user);
-
-
-$head = contact_prepare_head($contact);
-
-dol_fiche_head($head, 'exportimport', $title, 0, 'contact');
-
-
-/*
- * Fiche en mode visu
- */
-print '';
-
-$linkback = ''.$langs->trans("BackToList").'';
-
-// Ref
-print '| '.$langs->trans("Ref").' | ';
-print $form->showrefnav($contact, 'id', $linkback);
-print ' | ';
-
-// Name
-print '| '.$langs->trans("Lastname").' / '.$langs->trans("Label").' | '.$contact->lastname.' | ';
-print ''.$langs->trans("Firstname").' | '.$contact->firstname.' | ';
-
-// Company
-if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
+if ($id > 0)
{
- if ($contact->socid > 0)
- {
- $objsoc = new Societe($db);
- $objsoc->fetch($contact->socid);
+ $contact->fetch($id, $user);
- print '| '.$langs->trans("Company").' | '.$objsoc->getNomUrl(1).' | ';
- }
- else
- {
- print '| '.$langs->trans("Company").' | ';
- print $langs->trans("ContactNotLinkedToCompany");
- print ' | ';
- }
+ $head = contact_prepare_head($contact);
+
+ dol_fiche_head($head, 'exportimport', $title, 0, 'contact');
+
+
+ /*
+ * Fiche en mode visu
+ */
+ print '';
+
+ $linkback = ''.$langs->trans("BackToList").'';
+
+ // Ref
+ print '| '.$langs->trans("Ref").' | ';
+ print $form->showrefnav($contact, 'id', $linkback);
+ print ' | ';
+
+ // Name
+ print '| '.$langs->trans("Lastname").' / '.$langs->trans("Label").' | '.$contact->lastname.' | ';
+ print ''.$langs->trans("Firstname").' | '.$contact->firstname.' | ';
+
+ // Company
+ if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
+ {
+ if ($contact->socid > 0)
+ {
+ $objsoc = new Societe($db);
+ $objsoc->fetch($contact->socid);
+
+ print '| '.$langs->trans("Company").' | '.$objsoc->getNomUrl(1).' | ';
+ }
+ else
+ {
+ print '| '.$langs->trans("Company").' | ';
+ print $langs->trans("ContactNotLinkedToCompany");
+ print ' | ';
+ }
+ }
+
+ // Civility
+ print '| '.$langs->trans("UserTitle").' | ';
+ print $contact->getCivilityLabel();
+ print ' | ';
+
+ print ' ';
+
+ print '';
+
+ print ' ';
+
+ print $langs->trans("ExportCardToFormat").': ';
+ print '';
+ print img_picto($langs->trans("VCard"),'vcard.png').' ';
+ print $langs->trans("VCard");
+ print '';
}
-// Civility
-print '| '.$langs->trans("UserTitle").' | ';
-print $contact->getCivilityLabel();
-print ' | ';
-
-print ' ';
-
-print '';
-
-print ' ';
-
-print $langs->trans("ExportCardToFormat").': ';
-print '';
-print img_picto($langs->trans("VCard"),'vcard.png').' ';
-print $langs->trans("VCard");
-print '';
-
-
-
-
$db->close();
llxFooter();
diff --git a/htdocs/contact/info.php b/htdocs/contact/info.php
index 51a80d8d994..5d4904faa87 100644
--- a/htdocs/contact/info.php
+++ b/htdocs/contact/info.php
@@ -35,6 +35,8 @@ $contactid = GETPOST("id",'int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'contact', $contactid, 'socpeople&societe');
+$contact = new Contact($db);
+
/*
@@ -43,23 +45,25 @@ $result = restrictedArea($user, 'contact', $contactid, 'socpeople&societe');
llxHeader('',$langs->trans("ContactsAddresses"),'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
+if ($contactid > 0)
+{
+ $result = $contact->fetch($contactid, $user);
-$contact = new Contact($db);
-$contact->fetch($contactid, $user);
-$contact->info($contactid);
+ $contact->info($contactid);
-$head = contact_prepare_head($contact);
+ $head = contact_prepare_head($contact);
-dol_fiche_head($head, 'info', $langs->trans("ContactsAddresses"), 0, 'contact');
+ dol_fiche_head($head, 'info', $langs->trans("ContactsAddresses"), 0, 'contact');
-print '';
+ print '';
-dol_print_object_info($contact);
+ dol_print_object_info($contact);
-print "";
+ print "";
+}
llxFooter();
diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php
index 1681324323a..79e6246fc60 100644
--- a/htdocs/contact/ldap.php
+++ b/htdocs/contact/ldap.php
@@ -40,37 +40,40 @@ if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
$contact = new Contact($db);
-$contact->fetch($id, $user);
-
-/*
- * Actions
- */
-
-if ($action == 'dolibarr2ldap')
+if ($id > 0)
{
- $message="";
+ $contact->fetch($id, $user);
- $db->begin();
+ /*
+ * Actions
+ */
- $ldap=new Ldap();
- $result=$ldap->connect_bind();
-
- $info=$contact->_load_ldap_info();
- $dn=$contact->_load_ldap_dn($info);
- $olddn=$dn; // We can say that old dn = dn as we force synchro
-
- $result=$ldap->update($dn,$info,$user,$olddn);
-
- if ($result >= 0)
+ if ($action == 'dolibarr2ldap')
{
- $message.=''.$langs->trans("ContactSynchronized").' ';
- $db->commit();
- }
- else
- {
- $message.=''.$ldap->error.' ';
- $db->rollback();
+ $message="";
+
+ $db->begin();
+
+ $ldap=new Ldap();
+ $result=$ldap->connect_bind();
+
+ $info=$contact->_load_ldap_info();
+ $dn=$contact->_load_ldap_dn($info);
+ $olddn=$dn; // We can say that old dn = dn as we force synchro
+
+ $result=$ldap->update($dn,$info,$user,$olddn);
+
+ if ($result >= 0)
+ {
+ $message.=''.$langs->trans("ContactSynchronized").' ';
+ $db->commit();
+ }
+ else
+ {
+ $message.=''.$ldap->error.' ';
+ $db->rollback();
+ }
}
}
@@ -79,135 +82,137 @@ if ($action == 'dolibarr2ldap')
* View
*/
+$form = new Form($db);
+
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
-$form = new Form($db);
-
-$head = contact_prepare_head($contact);
-
-dol_fiche_head($head, 'ldap', $title, 0, 'contact');
-
-
-print '';
-
-// Ref
-print '| '.$langs->trans("Ref").' | ';
-print $form->showrefnav($contact,'id');
-print ' | ';
-
-// Name
-print '| '.$langs->trans("Lastname").' / '.$langs->trans("Label").' | '.$contact->lastname.' | ';
-print ''.$langs->trans("Firstname").' | '.$contact->firstname.' | ';
-
-// Company
-if ($contact->socid > 0)
+if ($id > 0)
{
- $objsoc = new Societe($db);
- $objsoc->fetch($contact->socid);
+ $head = contact_prepare_head($contact);
- print '| '.$langs->trans("Company").' | '.$objsoc->getNomUrl(1).' | ';
-}
-else
-{
- print '| '.$langs->trans("Company").' | ';
- print $langs->trans("ContactNotLinkedToCompany");
+ dol_fiche_head($head, 'ldap', $title, 0, 'contact');
+
+
+ print '';
+
+ // Ref
+ print '| '.$langs->trans("Ref").' | ';
+ print $form->showrefnav($contact,'id');
print ' | ';
-}
-// Civility
-print '| '.$langs->trans("UserTitle").' | ';
-print $contact->getCivilityLabel();
-print ' | ';
+ // Name
+ print '| '.$langs->trans("Lastname").' / '.$langs->trans("Label").' | '.$contact->lastname.' | ';
+ print ''.$langs->trans("Firstname").' | '.$contact->firstname.' | ';
-// LDAP DN
-print '| LDAP '.$langs->trans("LDAPContactDn").' | '.$conf->global->LDAP_CONTACT_DN." | \n";
-
-// LDAP Cle
-print '| LDAP '.$langs->trans("LDAPNamingAttribute").' | '.$conf->global->LDAP_KEY_CONTACTS." | \n";
-
-// LDAP Server
-print '| LDAP '.$langs->trans("LDAPPrimaryServer").' | '.$conf->global->LDAP_SERVER_HOST." | \n";
-print '| LDAP '.$langs->trans("LDAPSecondaryServer").' | '.$conf->global->LDAP_SERVER_HOST_SLAVE." | \n";
-print '| LDAP '.$langs->trans("LDAPServerPort").' | '.$conf->global->LDAP_SERVER_PORT." | \n";
-
-print ' ';
-
-print '';
-
-
-dol_htmloutput_mesg($message);
-
-
-/*
- * Barre d'actions
- */
-
-print '\n";
-
-if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') print " \n";
-
-
-
-// Affichage attributs LDAP
-print_titre($langs->trans("LDAPInformationsForThisContact"));
-
-print '';
-
-print '';
-print '| '.$langs->trans("LDAPAttributes").' | ';
-print ''.$langs->trans("Value").' | ';
-print ' ';
-
-// Lecture LDAP
-$ldap=new Ldap();
-$result=$ldap->connect_bind();
-if ($result > 0)
-{
- $info=$contact->_load_ldap_info();
- $dn=$contact->_load_ldap_dn($info,1);
- $search = "(".$contact->_load_ldap_dn($info,2).")";
- $records=$ldap->getAttribute($dn,$search);
-
- //var_dump($records);
-
- // Affichage arbre
- if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0))
+ // Company
+ if ($contact->socid > 0)
{
- if (! is_array($records))
- {
- print '| '.$langs->trans("ErrorFailedToReadLDAP").' | ';
- }
- else
- {
- $result=show_ldap_content($records,0,$records['count'],true);
- }
+ $objsoc = new Societe($db);
+ $objsoc->fetch($contact->socid);
+
+ print '| '.$langs->trans("Company").' | '.$objsoc->getNomUrl(1).' | ';
}
else
{
- print '| '.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.') | ';
+ print '| '.$langs->trans("Company").' | ';
+ print $langs->trans("ContactNotLinkedToCompany");
+ print ' | ';
}
- $ldap->unbind();
- $ldap->close();
+ // Civility
+ print '| '.$langs->trans("UserTitle").' | ';
+ print $contact->getCivilityLabel();
+ print ' | ';
+
+ // LDAP DN
+ print '| LDAP '.$langs->trans("LDAPContactDn").' | '.$conf->global->LDAP_CONTACT_DN." | \n";
+
+ // LDAP Cle
+ print '| LDAP '.$langs->trans("LDAPNamingAttribute").' | '.$conf->global->LDAP_KEY_CONTACTS." | \n";
+
+ // LDAP Server
+ print '| LDAP '.$langs->trans("LDAPPrimaryServer").' | '.$conf->global->LDAP_SERVER_HOST." | \n";
+ print '| LDAP '.$langs->trans("LDAPSecondaryServer").' | '.$conf->global->LDAP_SERVER_HOST_SLAVE." | \n";
+ print '| LDAP '.$langs->trans("LDAPServerPort").' | '.$conf->global->LDAP_SERVER_PORT." | \n";
+
+ print ' ';
+
+ print '';
+
+
+ dol_htmloutput_mesg($message);
+
+
+ /*
+ * Barre d'actions
+ */
+
+ print '\n";
+
+ if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') print " \n";
+
+
+
+ // Affichage attributs LDAP
+ print_titre($langs->trans("LDAPInformationsForThisContact"));
+
+ print '';
+
+ print '';
+ print '| '.$langs->trans("LDAPAttributes").' | ';
+ print ''.$langs->trans("Value").' | ';
+ print ' ';
+
+ // Lecture LDAP
+ $ldap=new Ldap();
+ $result=$ldap->connect_bind();
+ if ($result > 0)
+ {
+ $info=$contact->_load_ldap_info();
+ $dn=$contact->_load_ldap_dn($info,1);
+ $search = "(".$contact->_load_ldap_dn($info,2).")";
+ $records=$ldap->getAttribute($dn,$search);
+
+ //var_dump($records);
+
+ // Affichage arbre
+ if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0))
+ {
+ if (! is_array($records))
+ {
+ print '| '.$langs->trans("ErrorFailedToReadLDAP").' | ';
+ }
+ else
+ {
+ $result=show_ldap_content($records,0,$records['count'],true);
+ }
+ }
+ else
+ {
+ print '| '.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.') | ';
+ }
+
+ $ldap->unbind();
+ $ldap->close();
+ }
+ else
+ {
+ dol_print_error('',$ldap->error);
+ }
+
+
+ print ' ';
+
}
-else
-{
- dol_print_error('',$ldap->error);
-}
-
-
-print ' | ';
-
-
$db->close();
diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php
index 92ba03e9861..bd74fc75ef8 100644
--- a/htdocs/contact/perso.php
+++ b/htdocs/contact/perso.php
@@ -38,210 +38,213 @@ if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
$object = new Contact($db);
-/*
- * Action
- */
+$result = $object->fetch($id, $user);
-if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer)
+if ($id > 0)
{
- $ret = $object->fetch($id);
+ /*
+ * Action
+ */
- // Note: Correct date should be completed with location to have exact GM time of birth.
- $object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]);
- $object->birthday_alert = $_POST["birthday_alert"];
+ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer)
+ {
+ // Note: Correct date should be completed with location to have exact GM time of birth.
+ $object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]);
+ $object->birthday_alert = $_POST["birthday_alert"];
- $result = $object->update_perso($id, $user);
- if ($result > 0)
- {
- $object->old_name='';
- $object->old_firstname='';
- }
- else
- {
- $error = $object->error;
- }
+ $result = $object->update_perso($id, $user);
+ if ($result > 0)
+ {
+ $object->old_name='';
+ $object->old_firstname='';
+ }
+ else
+ {
+ $error = $object->error;
+ }
+ }
}
-
/*
* View
*/
+$form = new Form($db);
+
$now=dol_now();
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
-$form = new Form($db);
-
-$object->fetch($id, $user);
-
-$head = contact_prepare_head($object);
-
-dol_fiche_head($head, 'perso', $title, 0, 'contact');
-
-if ($action == 'edit')
+if ($id > 0)
{
- /*
- * Fiche en mode edition
- */
+ $head = contact_prepare_head($object);
- print ' |