|
@@ -4712,6 +4712,159 @@ class Form
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Show block with links to link to other objects.
|
|
|
+ *
|
|
|
+ * @param CommonObject $object Object we want to show links to
|
|
|
+ * @param Societe $thirdparty Object thirdparty
|
|
|
+ * @param array $restrictlinksto Restrict links to some elements, for exemple array('order') or array('supplier_order')
|
|
|
+ * @return int <0 if KO, >0 if OK
|
|
|
+ */
|
|
|
+ function showLinkToObjectBlock($object, $restrictlinksto=array())
|
|
|
+ {
|
|
|
+ global $conf, $langs, $hookmanager;
|
|
|
+ global $bc;
|
|
|
+
|
|
|
+ $linktoelem='';
|
|
|
+
|
|
|
+ if (! is_object($object->thirdparty)) $object->fetch_thirdparty();
|
|
|
+
|
|
|
+
|
|
|
+ if (((! is_array($restrictlinksto)) || in_array('order',$restrictlinksto))
|
|
|
+ && ! empty($conf->commande->enabled))
|
|
|
+ {
|
|
|
+ $linktoelem.=($linktoelem?' ':'').'<a href="#" id="linktoorder">' . $langs->trans('LinkedOrder') . '</a>';
|
|
|
+
|
|
|
+ print '
|
|
|
+ <script type="text/javascript" language="javascript">
|
|
|
+ jQuery(document).ready(function() {
|
|
|
+ jQuery("#linktoorder").click(function() {
|
|
|
+ jQuery("#orderlist").toggle();
|
|
|
+ jQuery("#linktoorder").toggle();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ </script>
|
|
|
+ ';
|
|
|
+
|
|
|
+ print '<div id="orderlist"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display:none"':'').'>';
|
|
|
+
|
|
|
+ $sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_client, c.total_ht";
|
|
|
+ $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
|
|
|
+ $sql .= ", " . MAIN_DB_PREFIX . "commande as c";
|
|
|
+ $sql .= ' WHERE c.fk_soc = s.rowid AND c.fk_soc = ' . $object->thirdparty->id . '';
|
|
|
+
|
|
|
+ $resqlorderlist = $this->db->query($sql);
|
|
|
+ if ($resqlorderlist)
|
|
|
+ {
|
|
|
+ $num = $this->db->num_rows($resqlorderlist);
|
|
|
+ $i = 0;
|
|
|
+
|
|
|
+ print '<br><form action="" method="POST" name="LinkedOrder">';
|
|
|
+ print '<table class="noborder">';
|
|
|
+ print '<tr class="liste_titre">';
|
|
|
+ print '<td class="nowrap"></td>';
|
|
|
+ print '<td align="center">' . $langs->trans("Ref") . '</td>';
|
|
|
+ print '<td align="left">' . $langs->trans("RefCustomer") . '</td>';
|
|
|
+ print '<td align="left">' . $langs->trans("AmountHTShort") . '</td>';
|
|
|
+ print '<td align="left">' . $langs->trans("Company") . '</td>';
|
|
|
+ print '</tr>';
|
|
|
+ while ($i < $num)
|
|
|
+ {
|
|
|
+ $objp = $this->db->fetch_object($resqlorderlist);
|
|
|
+
|
|
|
+ $var = ! $var;
|
|
|
+ print '<tr ' . $bc [$var] . '>';
|
|
|
+ print '<td aling="left">';
|
|
|
+ print '<input type="radio" name="linkedOrder" value=' . $objp->rowid . '>';
|
|
|
+ print '<td align="center">' . $objp->ref . '</td>';
|
|
|
+ print '<td>' . $objp->ref_client . '</td>';
|
|
|
+ print '<td>' . price($objp->total_ht) . '</td>';
|
|
|
+ print '<td>' . $objp->name . '</td>';
|
|
|
+ print '</td>';
|
|
|
+ print '</tr>';
|
|
|
+
|
|
|
+ $i ++;
|
|
|
+ }
|
|
|
+ print '</table>';
|
|
|
+ print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('ToLink') . '"> <input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '"></div>';
|
|
|
+ print '</form>';
|
|
|
+ $this->db->free($resqlorderlist);
|
|
|
+ } else {
|
|
|
+ dol_print_error($this->db);
|
|
|
+ }
|
|
|
+
|
|
|
+ print '</div>';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (((! is_array($restrictlinksto)) || in_array('supplier_order',$restrictlinksto))
|
|
|
+ && ! empty($conf->fournisseur->enabled))
|
|
|
+ {
|
|
|
+ $linktoelem.=($linktoelem?' ':'').'<a href="#" id="linktoorder">' . $langs->trans('LinkedOrder') . '</a>';
|
|
|
+
|
|
|
+ print '
|
|
|
+ <script type="text/javascript" language="javascript">
|
|
|
+ jQuery(document).ready(function() {
|
|
|
+ jQuery("#linktoorder").click(function() {
|
|
|
+ jQuery("#orderlist").toggle();
|
|
|
+ jQuery("#linktoorder").toggle();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ </script>
|
|
|
+ ';
|
|
|
+
|
|
|
+ print '<div id="orderlist"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display:none"':'').'>';
|
|
|
+
|
|
|
+ $sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_supplier, c.total_ht";
|
|
|
+ $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
|
|
|
+ $sql .= ", " . MAIN_DB_PREFIX . "commande_fournisseur as c";
|
|
|
+ $sql .= ' WHERE c.fk_soc = s.rowid AND c.fk_soc = ' . $object->thirdparty->id;
|
|
|
+
|
|
|
+ $resqlorderlist = $this->db->query($sql);
|
|
|
+ if ($resqlorderlist)
|
|
|
+ {
|
|
|
+ $num = $this->db->num_rows($resqlorderlist);
|
|
|
+ $i = 0;
|
|
|
+
|
|
|
+ print '<br><form action="" method="POST" name="LinkedOrder">';
|
|
|
+ print '<table class="noborder">';
|
|
|
+ print '<tr class="liste_titre">';
|
|
|
+ print '<td class="nowrap"></td>';
|
|
|
+ print '<td align="center">' . $langs->trans("Ref") . '</td>';
|
|
|
+ print '<td align="left">' . $langs->trans("RefSupplier") . '</td>';
|
|
|
+ print '<td align="left">' . $langs->trans("AmountHTShort") . '</td>';
|
|
|
+ print '<td align="left">' . $langs->trans("Company") . '</td>';
|
|
|
+ print '</tr>';
|
|
|
+ while ($i < $num) {
|
|
|
+ $objp = $this->db->fetch_object($resqlorderlist);
|
|
|
+ if ($objp->socid == $societe->id) {
|
|
|
+ $var = ! $var;
|
|
|
+ print '<tr ' . $bc [$var] . '>';
|
|
|
+ print '<td aling="left">';
|
|
|
+ print '<input type="radio" name="linkedOrder" value=' . $objp->rowid . '>';
|
|
|
+ print '<td align="center">' . $objp->ref . '</td>';
|
|
|
+ print '<td>' . $objp->ref_supplier . '</td>';
|
|
|
+ print '<td>' . price($objp->total_ht) . '</td>';
|
|
|
+ print '<td>' . $objp->name . '</td>';
|
|
|
+ print '</td>';
|
|
|
+ print '</tr>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $i ++;
|
|
|
+ }
|
|
|
+ print '</table>';
|
|
|
+ print '<br><div class="center"><input type="submit" class="button" value="' . $langs->trans('ToLink') . '"> <input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '"></div>';
|
|
|
+ print '</form>';
|
|
|
+ $this->db->free($resqlorderlist);
|
|
|
+ } else {
|
|
|
+ dol_print_error($this->db);
|
|
|
+ }
|
|
|
+
|
|
|
+ print '</div>';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return $linktoelem;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Return an html string with a select combo box to choose yes or no
|