diff --git a/ChangeLog b/ChangeLog
index 3273f75ad78..94d75666284 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,7 @@ For users:
- New: Can insert links into elements lines. Also reported into PDF.
- New: When a member is validated, we can subscribe to mailing-lists
according to its type.
+- New: Add link to third party into sells and purchase journal.
- Fix: No images into product description lines as PDF generation does
not work with this.
diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php
index 8b9ba496dad..7d92395b4af 100755
--- a/htdocs/compta/journal/purchasesjournal.php
+++ b/htdocs/compta/journal/purchasesjournal.php
@@ -26,6 +26,7 @@ require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/report.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php");
+require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.class.php");
$langs->load("companies");
$langs->load("other");
@@ -38,20 +39,16 @@ if ($user->societe_id > 0)
}
-/*******************************************************************
- * ACTIONS
- *
- * Put here all code to do according to value of "action" parameter
- ********************************************************************/
+/*
+ * Actions
+ */
+
+// None
-
-
-/***************************************************
- * PAGE
- *
- * Put here all code to build page
- ****************************************************/
+/*
+ * View
+ */
llxHeader('','','');
@@ -86,7 +83,9 @@ $idpays = $p[0];
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.libelle,";
$sql.= " fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,";
-$sql.= " s.code_compta_fournisseur, p.accountancy_code_buy , ct.accountancy_code";
+$sql.= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur,";
+$sql.= " p.rowid as pid, p.ref as ref, p.accountancy_code_buy,";
+$sql.= " ct.accountancy_code";
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det fd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '".$idpays."'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product";
@@ -107,6 +106,7 @@ if ($result)
$tabht = array();
$tabtva = array();
$tabttc = array();
+ $tabcompany = array();
$i=0;
while ($i < $num)
@@ -129,6 +129,7 @@ if ($result)
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
+ $tabcompany[$obj->rowid]=array('id'=>$obj->socid,'name'=>$obj->name);
$i++;
}
@@ -154,6 +155,7 @@ $var=true;
$r='';
$invoicestatic=new FactureFournisseur($db);
+$companystatic=new Fournisseur($db);
foreach ($tabfac as $key => $val)
{
@@ -197,15 +199,21 @@ foreach ($tabfac as $key => $val)
//print "
".$conf->global->COMPTA_JOURNAL_BUY." | ";
print "".$val["date"]." | ";
print "".$invoicestatic->getNomUrl(1)." | ";
-
+
foreach ($tabttc[$key] as $k => $mt)
{
- print "".$k." | ".$langs->trans("ThirdParty")." | ";
+ $companystatic->id=$tabcompany[$key]['id'];
+ $companystatic->name=$tabcompany[$key]['name'];
+
+ print "".$k;
+ print " | ".$langs->trans("ThirdParty");
+ print ' ('.$companystatic->getNomUrl(0,'supplier',16).')';
+ print " | ";
print ''.($mt<0?-price(-$mt):'')." | ";
print ''.($mt>=0?price($mt):'')." | ";
}
print "";
-
+
$var = !$var;
}
diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php
index 1a0e273776a..36085033987 100755
--- a/htdocs/compta/journal/sellsjournal.php
+++ b/htdocs/compta/journal/sellsjournal.php
@@ -26,6 +26,7 @@ require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/report.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
+require_once(DOL_DOCUMENT_ROOT."/societe/class/client.class.php");
$langs->load("companies");
@@ -38,26 +39,22 @@ if ($user->societe_id > 0)
accessforbidden();
}
+/*
+ * Actions
+ */
-/*******************************************************************
-* ACTIONS
-*
-* Put here all code to do according to value of "action" parameter
-********************************************************************/
+// None
-/***************************************************
-* PAGE
-*
-* Put here all code to build page
-****************************************************/
-llxHeader('','','');
+/*
+ * View
+ */
$form=new Form($db);
-// Put here content of your page
-// ...
+llxHeader('',$langs->trans("SellsJournal"),'');
+
$year_current = strftime("%Y",dol_now());
$pastmonth = strftime("%m",dol_now()) - 1;
@@ -87,7 +84,9 @@ $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_PAYS);
$idpays = $p[0];
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.ref_client , fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,";
-$sql.= " p.accountancy_code_sell, s.code_compta , ct.accountancy_code";
+$sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.client,";
+$sql.= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell,";
+$sql.= " ct.accountancy_code";
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet fd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product";
$sql.= " JOIN ".MAIN_DB_PREFIX."facture f ON f.rowid = fd.fk_facture";
@@ -95,7 +94,7 @@ $sql.= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '".$idpays."'";
$sql.= " WHERE f.fk_statut > 0 AND f.entity = ".$conf->entity;
if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
-$sql .= " order by f.rowid";
+$sql.= " ORDER BY f.rowid";
$result = $db->query($sql);
if ($result)
@@ -104,6 +103,7 @@ if ($result)
$tabht = array();
$tabtva = array();
$tabttc = array();
+ $tabcompany = array();
$num = $db->num_rows($result);
$i=0;
@@ -130,7 +130,7 @@ if ($result)
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
-
+ $tabcompany[$obj->rowid]=array('id'=>$obj->socid,'name'=>$obj->name,'client'=>$obj->client);
$i++;
}
}
@@ -157,6 +157,7 @@ $var=true;
$r='';
$invoicestatic=new Facture($db);
+$companystatic=new Client($db);
foreach ($tabfac as $key => $val)
{
@@ -171,7 +172,13 @@ foreach ($tabfac as $key => $val)
print "".$invoicestatic->getNomUrl(1)." | ";
foreach ($tabttc[$key] as $k => $mt)
{
- print "".$k." | ".$langs->trans("ThirdParty")." | ".($mt>=0?price($mt):'')." | ".($mt<0?price(-$mt):'')." | ";
+ $companystatic->id=$tabcompany[$key]['id'];
+ $companystatic->name=$tabcompany[$key]['name'];
+ $companystatic->client=$tabcompany[$key]['client'];
+ print "".$k;
+ print " | ".$langs->trans("ThirdParty");
+ print ' ('.$companystatic->getNomUrl(0,'customer',16).')';
+ print " | ".($mt>=0?price($mt):'')." | ".($mt<0?price(-$mt):'')." | ";
}
print "";
// product
@@ -183,7 +190,8 @@ foreach ($tabfac as $key => $val)
//print "".$conf->global->COMPTA_JOURNAL_SELL." | ";
print "".$val["date"]." | ";
print "".$invoicestatic->getNomUrl(1)." | ";
- print "".$k." | ".$langs->trans("Products")." | ".($mt<0?price(-$mt):'')." | ".($mt>=0?price($mt):'')." | ";
+ print "".$k;
+ print " | ".$langs->trans("Products")." | ".($mt<0?price(-$mt):'')." | ".($mt>=0?price($mt):'')." | ";
}
}
// vat
@@ -196,7 +204,8 @@ foreach ($tabfac as $key => $val)
//print "".$conf->global->COMPTA_JOURNAL_SELL." | ";
print "".$val["date"]." | ";
print "".$invoicestatic->getNomUrl(1)." | ";
- print "".$k." | ".$langs->trans("VAT")." | ".($mt<0?price(-$mt):'')." | ".($mt>=0?price($mt):'')." | ";
+ print "".$k;
+ print " | ".$langs->trans("VAT")." | ".($mt<0?price(-$mt):'')." | ".($mt>=0?price($mt):'')." | ";
}
}