} print '<td align="right">' . $langs->trans("AmountTTC") . '</td>'; print '<td align="right">' . $langs->trans("ToBill") . '</td>'; print '<td align="center" width="16"> </td>'; print '</tr>'; $tot_ht = $tot_ttc = $tot_tobill = 0; $societestatic = new Societe($db); while ($i < $num) { $obj = $db->fetch_object($resql); print "<tr " . $bc[$var] . ">"; print '<td class="nowrap">'; $commandestatic->id = $obj->rowid; $commandestatic->ref = $obj->ref; print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<td width="110" class="nobordernopadding nowrap">'; print $commandestatic->getNomUrl(1); print '</td>'; print '<td width="20" class="nobordernopadding nowrap">'; print ' '; print '</td>'; print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">'; $filename = dol_sanitizeFileName($obj->ref); $filedir = $conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $obj->rowid; print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print '</td></tr></table>'; print '</td>'; print '<td align="left">'; $societestatic->id = $obj->socid; $societestatic->nom = $obj->nom; $societestatic->client = 1;
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>'; print '<td colspan="3">'.$delivery->ref.'</td></tr>'; // Client print '<tr><td width="20%">'.$langs->trans("Customer").'</td>'; print '<td align="3">'.$soc->getNomUrl(1).'</td>'; print "</tr>"; // Document origine if ($typeobject == 'commande' && $expedition->origin_id && $conf->commande->enabled) { print '<tr><td>'.$langs->trans("RefOrder").'</td>'; $order=new Commande($db); $order->fetch($expedition->origin_id); print '<td colspan="3">'; print $order->getNomUrl(1,'commande'); print "</td>\n"; print '</tr>'; } if ($typeobject == 'propal' && $expedition->origin_id && $conf->propal->enabled) { $propal=new Propal($db); $propal->fetch($expedition->origin_id); print '<tr><td>'.$langs->trans("RefProposal").'</td>'; print '<td colspan="3">'; print $propal->getNomUrl(1,'expedition'); print "</td>\n"; print '</tr>'; } // Ref client
function get_format_libelle_commande($fk) { global $db; if ($fk > 0) { $o = new Commande($db); if ($o->fetch($fk) > 0) { return $o->getNomUrl(1); } else { return $fk; } } return ''; }
print '<tr><td width="20%">' . $langs->trans("Ref") . '</td>'; print '<td colspan="3">'; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); print '</td></tr>'; // Customer print '<tr><td width="20%">' . $langs->trans("Customer") . '</td>'; print '<td colspan="3">' . $soc->getNomUrl(1) . '</td>'; print "</tr>"; // Linked documents if ($typeobject == 'commande' && $object->{$typeobject}->id && !empty($conf->commande->enabled)) { print '<tr><td>'; $objectsrc = new Commande($db); $objectsrc->fetch($object->{$typeobject}->id); print $langs->trans("RefOrder") . '</td>'; print '<td colspan="3">'; print $objectsrc->getNomUrl(1, 'commande'); print "</td>\n"; print '</tr>'; } if ($typeobject == 'propal' && $object->{$typeobject}->id && !empty($conf->propal->enabled)) { print '<tr><td>'; $objectsrc = new Propal($db); $objectsrc->fetch($object->{$typeobject}->id); print $langs->trans("RefProposal") . '</td>'; print '<td colspan="3">'; print $objectsrc->getNomUrl(1, 'expedition'); print "</td>\n"; print '</tr>'; } // Ref customer print '<tr><td>' . $langs->trans("RefCustomer") . '</td>';
print '<tr ' . $bc[$var] . '>'; print '<td class="nowrap">'; $generic_commande->id = $objp->rowid; $generic_commande->ref = $objp->ref; $generic_commande->statut = $objp->fk_statut; $generic_commande->date_commande = $db->jdate($objp->date_commande); $generic_commande->date_livraison = $db->jdate($objp->date_delivery); $generic_commande->ref_client = $objp->ref_client; $generic_commande->total_ht = $objp->total_ht; $generic_commande->total_tva = $objp->total_tva; $generic_commande->total_ttc = $objp->total_ttc; $generic_commande->lines = array(); $generic_commande->getLinesArray(); print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<td class="nobordernopadding nowrap">'; print $generic_commande->getNomUrl(1, $viewstatut != 2 ? 0 : $objp->fk_statut); print '</td>'; // Show shippable Icon (create subloop, so may be slow) if ($conf->stock->enabled) { $langs->load("stocks"); if ($objp->fk_statut > 0 && $objp->fk_statut < 3) { $notshippable = 0; $warning = 0; $text_info = ''; $nbprod = 0; $numlines = count($generic_commande->lines); // Loop on each line of order for ($lig = 0; $lig < $numlines; $lig++) { if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { $nbprod++; // order contains real products
$langs->load("orders"); $i = 0; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td colspan="3">' . $langs->trans("OrdersToProcess") . '</td></tr>'; $var = True; while ($i < $num) { $var = !$var; $obj = $db->fetch_object($resql); print "<tr " . $bc[$var] . ">"; print '<td class="nowrap">'; $orderstatic->id = $obj->rowid; $orderstatic->ref = $obj->ref; $orderstatic->statut = $obj->fk_statut; $orderstatic->facturee = 0; print $orderstatic->getNomUrl(1); print '</td>'; print '<td>'; $companystatic->name = $obj->name; $companystatic->id = $obj->socid; print $companystatic->getNomUrl(1, 'customer', 32); print '</td>'; print '<td align="right">'; print $orderstatic->getLibStatut(3); print '</td>'; print '</tr>'; $i++; } print "</table><br>"; } }
function enteteexpedition(&$expedition) { global $langs, $db, $user, $hookmanager, $conf; $form = new Form($db); $soc = new Societe($db); $soc->fetch($expedition->socid); if (!empty($expedition->origin)) { $typeobject = $expedition->origin; $origin = $expedition->origin; $expedition->fetch_origin(); } print '<table class="border" width="100%">'; $linkback = '<a href="' . DOL_URL_ROOT . '/expedition/liste.php">' . $langs->trans("BackToList") . '</a>'; // Ref print '<tr><td width="20%">' . $langs->trans("Ref") . '</td>'; print '<td colspan="3">'; print $form->showrefnav($expedition, 'ref', $linkback, 1, 'ref', 'ref'); print '</td></tr>'; // Customer print '<tr><td width="20%">' . $langs->trans("Customer") . '</td>'; print '<td colspan="3">' . $soc->getNomUrl(1) . '</td>'; print "</tr>"; // Linked documents if ($typeobject == 'commande' && $expedition->{$typeobject}->id && !empty($conf->commande->enabled)) { print '<tr><td>'; $objectsrc = new Commande($db); $objectsrc->fetch($expedition->{$typeobject}->id); print $langs->trans("RefOrder") . '</td>'; print '<td colspan="3">'; print $objectsrc->getNomUrl(1, 'commande'); print "</td>\n"; print '</tr>'; } if ($typeobject == 'propal' && $expedition->{$typeobject}->id && !empty($conf->propal->enabled)) { print '<tr><td>'; $objectsrc = new Propal($db); $objectsrc->fetch($expedition->{$typeobject}->id); print $langs->trans("RefProposal") . '</td>'; print '<td colspan="3">'; print $objectsrc->getNomUrl(1, 'expedition'); print "</td>\n"; print '</tr>'; } // Ref customer print '<tr><td>' . $langs->trans("RefCustomer") . '</td>'; print '<td colspan="3">' . $expedition->ref_customer . "</a></td>\n"; print '</tr>'; // Date creation print '<tr><td>' . $langs->trans("DateCreation") . '</td>'; print '<td colspan="3">' . dol_print_date($expedition->date_creation, "day") . "</td>\n"; print '</tr>'; // Delivery date planed print '<tr><td height="10">'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans('DateDeliveryPlanned'); print '</td>'; print '</tr></table>'; print '</td><td colspan="2">'; print $expedition->date_delivery ? dol_print_date($expedition->date_delivery, 'dayhourtext') : ' '; print '</td>'; print '</tr>'; // Status print '<tr><td>' . $langs->trans("Status") . '</td>'; print '<td colspan="3">' . $expedition->getLibStatut(4) . "</td>\n"; print '</tr>'; // Sending method print '<tr><td height="10">'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans('SendingMethod'); print '</td>'; print '</tr></table>'; print '</td><td colspan="2">'; if ($expedition->shipping_method_id > 0) { // Get code using getLabelFromKey $code = $langs->getLabelFromKey($db, $expedition->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); print $langs->trans("SendingMethod" . strtoupper($code)); } print '</td>'; print '</tr>'; print "</table>\n"; }
print '<form name="orders2invoice" action="orderstoinvoice.php" method="GET">'; $var = true; $generic_commande = new Commande($db); while ($i < $num) { $objp = $db->fetch_object($resql); $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td class="nowrap">'; $generic_commande->id = $objp->rowid; $generic_commande->ref = $objp->ref; $generic_commande->statut = $objp->fk_statut; $generic_commande->date_commande = $db->jdate($objp->date_commande); $generic_commande->date_livraison = $db->jdate($objp->date_livraison); print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<td class="nobordernopadding nowrap">'; print $generic_commande->getNomUrl(1, $objp->fk_statut); print '</td>'; print '<td width="20" class="nobordernopadding nowrap">'; if ($generic_commande->hasDelay()) { print img_picto($langs->trans("Late"), "warning"); } print '</td>'; print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">'; $filename = dol_sanitizeFileName($objp->ref); $filedir = $conf->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref); $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objp->rowid; print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print '</td></tr></table>'; print '</td>'; print '<td>' . $objp->ref_client . '</td>'; // Order date
/** * Show html area with actions done * * @param Conf $conf Object conf * @param Translate $langs Object langs * @param DoliDB $db Object db * @param Object $object Object third party or member * @param Contact $objcon Object contact * @param int $noprint Return string but does not output it * @return mixed Return html part or void if noprint is 1 * TODO change function to be able to list event linked to an object. */ function show_actions_done($conf, $langs, $db, $object, $objcon = '', $noprint = 0) { global $bc, $user; // Check parameters if (!is_object($object)) { dol_print_error('', 'BadParameter'); } $out = ''; $histo = array(); $numaction = 0; $now = dol_now('tzuser'); if (!empty($conf->agenda->enabled)) { // Recherche histo sur actioncomm $sql = "SELECT a.id, a.label,"; $sql .= " a.datep as dp,"; $sql .= " a.datep2 as dp2,"; $sql .= " a.note, a.percent,"; $sql .= " a.fk_element, a.elementtype,"; $sql .= " a.fk_user_author, a.fk_contact,"; $sql .= " c.code as acode, c.libelle,"; $sql .= " u.login, u.rowid as user_id"; if (get_class($object) == 'Adherent') { $sql .= ", m.lastname, m.firstname"; } if (get_class($object) == 'Societe') { $sql .= ", sp.lastname, sp.firstname"; } $sql .= " FROM " . MAIN_DB_PREFIX . "c_actioncomm as c, " . MAIN_DB_PREFIX . "user as u, " . MAIN_DB_PREFIX . "actioncomm as a"; if (get_class($object) == 'Adherent') { $sql .= ", " . MAIN_DB_PREFIX . "adherent as m"; } if (get_class($object) == 'Societe') { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople as sp ON a.fk_contact = sp.rowid"; } $sql .= " WHERE u.rowid = a.fk_user_author"; $sql .= " AND a.entity IN (" . getEntity('agenda', 1) . ")"; if (get_class($object) == 'Adherent') { $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; } if (get_class($object) == 'Adherent' && $object->id) { $sql .= " AND a.fk_element = " . $object->id; } if (get_class($object) == 'Societe' && $object->id) { $sql .= " AND a.fk_soc = " . $object->id; } if (is_object($objcon) && $objcon->id) { $sql .= " AND a.fk_contact = " . $objcon->id; } $sql .= " AND c.id=a.fk_action"; $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '" . $db->idate($now) . "'))"; $sql .= " ORDER BY a.datep DESC, a.id DESC"; dol_syslog("company.lib::show_actions_done sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $i = 0; $num = $db->num_rows($resql); $var = true; while ($i < $num) { $obj = $db->fetch_object($resql); $histo[$numaction] = array('type' => 'action', 'id' => $obj->id, 'datestart' => $db->jdate($obj->dp), 'date' => $db->jdate($obj->dp2), 'note' => $obj->label, 'percent' => $obj->percent, 'acode' => $obj->acode, 'libelle' => $obj->libelle, 'userid' => $obj->user_id, 'login' => $obj->login, 'contact_id' => $obj->fk_contact, 'lastname' => $obj->lastname, 'firstname' => $obj->firstname, 'fk_element' => $obj->fk_element, 'elementtype' => $obj->elementtype); $numaction++; $i++; } } else { dol_print_error($db); } } if (!empty($conf->mailing->enabled) && !empty($objcon->email)) { $langs->load("mails"); // Recherche histo sur mailing $sql = "SELECT m.rowid as id, mc.date_envoi as da, m.titre as note, '100' as percentage,"; $sql .= " 'AC_EMAILING' as acode,"; $sql .= " u.rowid as user_id, u.login"; // User that valid action $sql .= " FROM " . MAIN_DB_PREFIX . "mailing as m, " . MAIN_DB_PREFIX . "mailing_cibles as mc, " . MAIN_DB_PREFIX . "user as u"; $sql .= " WHERE mc.email = '" . $db->escape($objcon->email) . "'"; // Search is done on email. $sql .= " AND mc.statut = 1"; $sql .= " AND u.rowid = m.fk_user_valid"; $sql .= " AND mc.fk_mailing=m.rowid"; $sql .= " ORDER BY mc.date_envoi DESC, m.rowid DESC"; dol_syslog("company.lib::show_actions_done sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $i = 0; $num = $db->num_rows($resql); $var = true; while ($i < $num) { $obj = $db->fetch_object($resql); $histo[$numaction] = array('type' => 'mailing', 'id' => $obj->id, 'date' => $db->jdate($obj->da), 'note' => $obj->note, 'percent' => $obj->percentage, 'acode' => $obj->acode, 'userid' => $obj->user_id, 'login' => $obj->login); $numaction++; $i++; } $db->free($resql); } else { dol_print_error($db); } } if (!empty($conf->agenda->enabled) || !empty($conf->mailing->enabled) && !empty($objcon->email)) { require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; $actionstatic = new ActionComm($db); $userstatic = new User($db); $contactstatic = new Contact($db); // TODO uniformize $propalstatic = new Propal($db); $orderstatic = new Commande($db); $facturestatic = new Facture($db); $out .= "\n"; $out .= '<table class="noborder" width="100%">'; $out .= '<tr class="liste_titre">'; $out .= '<td colspan="2">'; if (get_class($object) == 'Societe') { $out .= '<a href="' . DOL_URL_ROOT . '/comm/action/listactions.php?socid=' . $object->id . '&status=done">'; } $out .= $langs->trans("ActionsDoneShort"); if (get_class($object) == 'Societe') { $out .= '</a>'; } $out .= '</td>'; $out .= '<td colspan="5" align="right">'; $permok = $user->rights->agenda->myactions->create; if ((!empty($object->id) || !empty($objcon->id)) && $permok) { $out .= '<a href="' . DOL_URL_ROOT . '/comm/action/fiche.php?action=create'; if (get_class($object) == 'Societe') { $out .= '&socid=' . $object->id; } $out .= (!empty($objcon->id) ? '&contactid=' . $objcon->id : '') . '&backtopage=1&percentage=-1">'; $out .= $langs->trans("AddAnAction") . ' '; $out .= img_picto($langs->trans("AddAnAction"), 'filenew'); $out .= "</a>"; } $out .= '</td>'; $out .= '</tr>'; foreach ($histo as $key => $value) { $var = !$var; $out .= "<tr " . $bc[$var] . ">"; // Champ date $out .= '<td width="120" class="nowrap">'; if ($histo[$key]['date']) { $out .= dol_print_date($histo[$key]['date'], 'dayhour'); } else { if ($histo[$key]['datestart']) { $out .= dol_print_date($histo[$key]['datestart'], 'dayhour'); } } $out .= "</td>\n"; // Picto $out .= '<td width="16"> </td>'; // Action $out .= '<td>'; if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') { $actionstatic->type_code = $histo[$key]['acode']; $transcode = $langs->trans("Action" . $histo[$key]['acode']); $libelle = $transcode != "Action" . $histo[$key]['acode'] ? $transcode : $histo[$key]['libelle']; //$actionstatic->libelle=$libelle; $actionstatic->libelle = $histo[$key]['note']; $actionstatic->id = $histo[$key]['id']; $out .= $actionstatic->getNomUrl(1, 40); } if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { $out .= '<a href="' . DOL_URL_ROOT . '/comm/mailing/fiche.php?id=' . $histo[$key]['id'] . '">' . img_object($langs->trans("ShowEMailing"), "email") . ' '; $transcode = $langs->trans("Action" . $histo[$key]['acode']); $libelle = $transcode != "Action" . $histo[$key]['acode'] ? $transcode : 'Send mass mailing'; $out .= dol_trunc($libelle, 40); } $out .= '</td>'; // Title of event //$out.='<td>'.dol_trunc($histo[$key]['note'], 40).'</td>'; // Objet lie // TODO uniformize $out .= '<td>'; if (isset($histo[$key]['elementtype'])) { if ($histo[$key]['elementtype'] == 'propal' && !empty($conf->propal->enabled)) { $propalstatic->ref = $langs->trans("ProposalShort"); $propalstatic->id = $histo[$key]['fk_element']; $out .= $propalstatic->getNomUrl(1); } elseif ($histo[$key]['elementtype'] == 'commande' && !empty($conf->commande->enabled)) { $orderstatic->ref = $langs->trans("Order"); $orderstatic->id = $histo[$key]['fk_element']; $out .= $orderstatic->getNomUrl(1); } elseif ($histo[$key]['elementtype'] == 'facture' && !empty($conf->facture->enabled)) { $facturestatic->ref = $langs->trans("Invoice"); $facturestatic->id = $histo[$key]['fk_element']; $facturestatic->type = $histo[$key]['ftype']; $out .= $facturestatic->getNomUrl(1, 'compta'); } else { $out .= ' '; } } else { $out .= ' '; } $out .= '</td>'; // Contact pour cette action if (!empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) { $contactstatic->lastname = $histo[$key]['lastname']; $contactstatic->firstname = $histo[$key]['firstname']; $contactstatic->id = $histo[$key]['contact_id']; $out .= '<td width="120">' . $contactstatic->getNomUrl(1, '', 10) . '</td>'; } else { $out .= '<td> </td>'; } // Auteur $out .= '<td class="nowrap" width="80">'; $userstatic->id = $histo[$key]['userid']; $userstatic->login = $histo[$key]['login']; $out .= $userstatic->getLoginUrl(1); $out .= '</td>'; // Statut $out .= '<td class="nowrap" width="20">' . $actionstatic->LibStatut($histo[$key]['percent'], 3) . '</td>'; $out .= "</tr>\n"; $i++; } $out .= "</table>\n"; $out .= "<br>\n"; } if ($noprint) { return $out; } else { print $out; } }
$generic_commande->id = $objp->rowid; $generic_commande->ref = $objp->ref; $shippableOrder->isOrderShippable($objp->rowid); if (!empty($search_status)) { $result = $shippableOrder->orderStockStatus(true, 'code'); if (!in_array($result, $search_status)) { $BdisplayLine = false; } } if ($BdisplayLine == true) { $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td class="nowrap">'; print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<td class="nobordernopadding nowrap">'; print $generic_commande->getNomUrl(1); print '</td>'; print '<td style="min-width: 20px" class="nobordernopadding nowrap">'; if ($objp->fk_statut > 0 && $objp->fk_statut < 3 && max($db->jdate($objp->date_commande), $db->jdate($objp->date_livraison)) < $now - $conf->commande->client->warning_delay) { print img_picto($langs->trans("Late"), "warning"); } if (!empty($objp->note_private)) { print ' <span class="note">'; print '<a href="' . DOL_URL_ROOT . '/commande/note.php?id=' . $objp->rowid . '">' . img_picto($langs->trans("ViewPrivateNote"), 'object_generic') . '</a>'; print '</span>'; } print '</td>'; print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">'; $filename = dol_sanitizeFileName($objp->ref); $filedir = $conf->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref); $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objp->rowid;
/** * Load data for box to show them later * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $user, $langs, $db, $conf; $this->max = $max; include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $commandestatic = new Commande($db); $societestatic = new Societe($db); $userstatic = new User($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLast" . ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified") . "CustomerOrders", $max)); if ($user->rights->commande->lire) { $sql = "SELECT s.nom as name"; $sql .= ", s.rowid as socid"; $sql .= ", s.code_client"; $sql .= ", s.logo"; $sql .= ", c.ref, c.tms"; $sql .= ", c.rowid"; $sql .= ", c.date_commande"; $sql .= ", c.ref_client"; $sql .= ", c.fk_statut"; $sql .= ", c.fk_user_valid"; $sql .= ", c.facture"; $sql .= ", c.total_ht"; $sql .= ", c.tva as total_tva"; $sql .= ", c.total_ttc"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; $sql .= ", " . MAIN_DB_PREFIX . "commande as c"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " AND c.entity = " . $conf->entity; if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) { $sql .= " AND c.fk_statut = 1"; } if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) { $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; } else { $sql .= " ORDER BY c.tms DESC, c.ref DESC "; } $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $line = 0; while ($line < $num) { $objp = $db->fetch_object($result); $date = $db->jdate($objp->date_commande); $datem = $db->jdate($objp->tms); $commandestatic->id = $objp->rowid; $commandestatic->ref = $objp->ref; $commandestatic->ref_client = $objp->ref_client; $commandestatic->total_ht = $objp->total_ht; $commandestatic->total_tva = $objp->total_tva; $commandestatic->total_ttc = $objp->total_ttc; $societestatic->id = $objp->socid; $societestatic->name = $objp->name; $societestatic->code_client = $objp->code_client; $societestatic->logo = $objp->logo; $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $commandestatic->getNomUrl(1), 'asis' => 1); $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $societestatic->getNomUrl(1), 'asis' => 1); $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency)); if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { if ($objp->fk_user_valid > 0) { $userstatic->fetch($objp->fk_user_valid); } $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => $objp->fk_user_valid > 0 ? $userstatic->getNomUrl(1) : '', 'asis' => 1); } $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => dol_print_date($date, 'day')); $this->info_box_contents[$line][] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3)); $line++; } if ($num == 0) { $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedOrders")); } $db->free($result); } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { $this->info_box_contents[0][0] = array('align' => 'left', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }
function _task(&$db, $id_task, $values = array()) { global $user, $langs, $conf; $task = new Task($db); if ($id_task) { $task->fetch($id_task); $task->fetch_optionals($id_task); } if (!empty($values)) { _set_values($task, $values); if ($values['status'] == 'inprogress') { if ($task->progress == 0) { $task->progress = 5; } else { if ($task->progress == 100) { $task->progress = 95; } } } else { if ($values['status'] == 'finish') { $task->progress = 100; } else { if ($values['status'] == 'todo') { $task->progress = 0; } } } $task->status = $values['status']; $task->update($user); } $task->date_delivery = 0; if ($task->date_end > 0 && $task->planned_workload > 0) { $velocity = scrum_getVelocity($db, $task->fk_project); $task->date_delivery = _get_delivery_date_with_velocity($db, $task, $velocity); } $dayInSecond = 86400; if ($conf->global->TIMESHEET_WORKING_HOUR_PER_DAY) { $dayInSecond = 60 * 60 * $conf->global->TIMESHEET_WORKING_HOUR_PER_DAY; } $task->aff_time = convertSecondToTime($task->duration_effective, 'all', $dayInSecond); $task->aff_planned_workload = convertSecondToTime($task->planned_workload, 'all', $dayInSecond); $task->time_rest = $task->planned_workload * (1 - $task->progress / 100); $task->aff_time_rest = $langs->trans('TimeRest') . ' : ' . convertSecondToTime($task->time_rest, 'all', $dayInSecond); $task->long_description = $task->divers = ''; if ((int) $task->array_options['options_fk_of'] > 0 && $conf->of->enabled) { if (!isset($PDOdb)) { $PDOdb = new TPDOdb(); } $of = new TAssetOF(); $of->withChild = false; $of->load($PDOdb, $task->array_options['options_fk_of']); $link_of = !empty($conf->of->enabled) ? dol_buildpath('/of/fiche_of.php?id=' . $task->array_options['options_fk_of'], 1) : ''; if ($of->fk_soc > 0) { $soc = new Societe($db); $soc->fetch($of->fk_soc); } $task->divers .= '[<a href="' . $link_of . '">' . $of->numero . '</a>] ' . (!empty($soc) ? $soc->getNomUrl() : '') . '<br />'; if ($of->fk_commande > 0) { dol_include_once('/commande/class/commande.class.php'); $commande = new Commande($db); $commande->fetch($of->fk_commande); $task->divers .= $commande->getNomUrl(1) . '<br />'; } } if ((int) $task->array_options['options_fk_product'] > 0 && (empty($conf->global->SCRUMBOARD_ICON_SET) || $conf->global->SCRUMBOARD_ICON_SET != 'null')) { dol_include_once('/product/class/product.class.php'); $product = new Product($db); if ($product->fetch((int) $task->array_options['options_fk_product']) > 0) { $task->divers .= '[' . $product->getNomUrl() . ' ' . $product->label . ']<br />'; $nb_picto = $product->id % 49 - 1; $y_picto = floor($nb_picto / 7); $x_picto = $nb_picto - $y_picto * 7; $w_cell = 27; $h_cell = 28; $task->divers .= '<div class="picto" style="float:left; margin-left:3px; background-image:url(./img/' . (!empty($conf->global->SCRUMBOARD_ICON_SET) ? $conf->global->SCRUMBOARD_ICON_SET : 'animal-icons-mini') . '.png);background-position:' . $w_cell * -$x_picto . 'px ' . $h_cell * -$y_picto . 'px;width:' . $w_cell . 'px; height:' . $h_cell . 'px;"></div>'; //var_dump(array($nb_picto,$y_picto, $x_picto,$task->divers)); } } if (!empty($task->note_private)) { $task->divers .= '<br />' . $task->note_private; } if ($task->date_start > 0) { $task->long_description .= $langs->trans('TaskDateStart') . ' : ' . dol_print_date($task->date_start) . '<br />'; } if ($task->date_end > 0) { $task->long_description .= $langs->trans('TaskDateEnd') . ' : ' . dol_print_date($task->date_end) . '<br />'; } if ($task->date_delivery > 0 && $task->date_delivery > $task->date_end) { $task->long_description .= $langs->trans('TaskDateShouldDelivery') . ' : ' . dol_print_date($task->date_delivery) . '<br />'; } $task->long_description .= $task->description; $task->project = new Project($db); $task->project->fetch($task->fk_project); $task->project->fetch_optionals($task->fk_project, 'color'); if (!empty($conf->global->SCRUM_SHOW_LINKED_CONTACT)) { getTContact($task); } return _as_array($task); }
function _fiche(&$PDOdb, &$assetOf, $mode = 'edit', $fk_product_to_add = 0, $fk_nomenclature = 0) { global $langs, $db, $conf, $user, $hookmanager; /*************************************************** * PAGE * * Put here all code to build page ****************************************************/ $parameters = array('id' => $assetOf->getId()); $reshook = $hookmanager->executeHooks('doActions', $parameters, $assetOf, $mode); // Note that $action and $object may have been modified by hook //pre($assetOf,true); llxHeader('', $langs->trans('OFAsset'), '', ''); print dol_get_fiche_head(ofPrepareHead($assetOf, 'assetOF'), 'fiche', $langs->trans('OFAsset')); ?> <style type="text/css"> #assetChildContener .OFMaster { background:#fff; -webkit-box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.52); -moz-box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.52); box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.52); margin-bottom:20px; } </style> <div class="OFContent" rel="<?php echo $assetOf->getId(); ?> "> <?php $TPrixFournisseurs = array(); //$form=new TFormCore($_SERVER['PHP_SELF'],'formeq'.$assetOf->getId(),'POST'); //Affichage des erreurs if (!empty($assetOf->errors)) { ?> <br><div class="error"> <?php foreach ($assetOf->errors as $error) { echo $error . "<br>"; setEventMessage($error, 'errors'); } $assetOf->errors = array(); ?> </div><br> <?php } $form = new TFormCore(); $form->Set_typeaff($mode); $doliform = new Form($db); if (!empty($_REQUEST['fk_product'])) { echo $form->hidden('fk_product', $_REQUEST['fk_product']); } $TBS = new TTemplateTBS(); $liste = new TListviewTBS('asset'); $TBS->TBS->protect = false; $TBS->TBS->noerr = true; $PDOdb = new TPDOdb(); $TNeeded = array(); $TToMake = array(); $TNeeded = _fiche_ligne($form, $assetOf, "NEEDED"); $TToMake = _fiche_ligne($form, $assetOf, "TO_MAKE"); $TIdCommandeFourn = $assetOf->getElementElement($PDOdb); $HtmlCmdFourn = ''; if (count($TIdCommandeFourn)) { foreach ($TIdCommandeFourn as $idcommandeFourn) { $cmd = new CommandeFournisseur($db); $cmd->fetch($idcommandeFourn); $HtmlCmdFourn .= $cmd->getNomUrl(1) . " - " . $cmd->getLibStatut(0); } } ob_start(); $doliform->select_produits('', 'fk_product', '', $conf->product->limit_size, 0, -1, 2, '', 3, array()); $select_product = ob_get_clean(); $Tid = array(); //$Tid[] = $assetOf->rowid; if ($assetOf->getId() > 0) { $assetOf->getListeOFEnfants($PDOdb, $Tid); } $TWorkstation = array(); foreach ($assetOf->TAssetWorkstationOF as $k => &$TAssetWorkstationOF) { $ws =& $TAssetWorkstationOF->ws; $TWorkstation[] = array('libelle' => '<a href="' . dol_buildpath('workstation/workstation.php?id=' . $ws->rowid . '&action=view', 2) . '">' . $ws->name . '</a>', 'fk_user' => visu_checkbox_user($PDOdb, $form, $ws->fk_usergroup, $TAssetWorkstationOF->users, 'TAssetWorkstationOF[' . $k . '][fk_user][]', $assetOf->status), 'fk_project_task' => visu_project_task($db, $TAssetWorkstationOF->fk_project_task, $form->type_aff, 'TAssetWorkstationOF[' . $k . '][progress]'), 'fk_task' => visu_checkbox_task($PDOdb, $form, $TAssetWorkstationOF->fk_asset_workstation, $TAssetWorkstationOF->tasks, 'TAssetWorkstationOF[' . $k . '][fk_task][]', $assetOf->status), 'nb_hour' => $assetOf->status == 'DRAFT' && $mode == "edit" ? $form->texte('', 'TAssetWorkstationOF[' . $k . '][nb_hour]', $TAssetWorkstationOF->nb_hour, 3, 10) : ($conf->global->ASSET_USE_CONVERT_TO_TIME ? convertSecondToTime($TAssetWorkstationOF->nb_hour * 3600) : price($TAssetWorkstationOF->nb_hour)), 'nb_hour_real' => $assetOf->status == 'OPEN' && $mode == "edit" ? $form->texte('', 'TAssetWorkstationOF[' . $k . '][nb_hour_real]', $TAssetWorkstationOF->nb_hour_real, 3, 10) : ($conf->global->ASSET_USE_CONVERT_TO_TIME ? convertSecondToTime($TAssetWorkstationOF->nb_hour_real * 3600) : price($TAssetWorkstationOF->nb_hour_real)), 'nb_days_before_beginning' => $assetOf->status == 'DRAFT' && $mode == "edit" ? $form->texte('', 'TAssetWorkstationOF[' . $k . '][nb_days_before_beginning]', $TAssetWorkstationOF->nb_days_before_beginning, 3, 10) : $TAssetWorkstationOF->nb_days_before_beginning, 'delete' => $mode == 'edit' && $assetOf->status == 'DRAFT' ? '<a href="javascript:deleteWS(' . $assetOf->getId() . ',' . $TAssetWorkstationOF->getId() . ');">' . img_picto('Supprimer', 'delete.png') . '</a>' : '', 'note_private' => $assetOf->status == 'DRAFT' && $mode == 'edit' ? $form->zonetexte('', 'TAssetWorkstationOF[' . $k . '][note_private]', $TAssetWorkstationOF->note_private, 50, 1) : $TAssetWorkstationOF->note_private, 'rang' => $assetOf->status == 'DRAFT' && $mode == "edit" ? $form->texte('', 'TAssetWorkstationOF[' . $k . '][rang]', $TAssetWorkstationOF->rang, 3, 10) : $TAssetWorkstationOF->rang, 'id' => $ws->getId()); } $client = new Societe($db); if ($assetOf->fk_soc > 0) { $client->fetch($assetOf->fk_soc); } $commande = new Commande($db); if ($assetOf->fk_commande > 0) { $commande->fetch($assetOf->fk_commande); } $TOFParent = array_merge(array(0 => ''), $assetOf->getCanBeParent($PDOdb)); $hasParent = false; if (!empty($assetOf->fk_assetOf_parent)) { $TAssetOFParent = new TAssetOF(); $TAssetOFParent->load($PDOdb, $assetOf->fk_assetOf_parent); $hasParent = true; } $parameters = array('id' => $assetOf->getId()); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $assetOf, $mode); // Note that $action and $object may have been modified by hook if ($fk_product_to_add > 0) { $product_to_add = new Product($db); $product_to_add->fetch($fk_product_to_add); $link_product_to_add = $product_to_add->getNomUrl(1) . ' ' . $product_to_add->label; $quantity_to_create = $form->texte('', 'quantity_to_create', 1, 3, 255); } else { $link_product_to_add = ''; $quantity_to_create = ''; } print $TBS->render('tpl/fiche_of.tpl.php', array('TNeeded' => $TNeeded, 'TTomake' => $TToMake, 'workstation' => $TWorkstation), array('assetOf' => array('id' => $assetOf->getId(), 'numero' => $assetOf->getId() > 0 ? '<a href="fiche_of.php?id=' . $assetOf->getId() . '">' . $assetOf->getNumero($PDOdb) . '</a>' : $assetOf->getNumero($PDOdb), 'ordre' => $form->combo('', 'ordre', TAssetOf::$TOrdre, $assetOf->ordre), 'fk_commande' => $assetOf->fk_commande == 0 ? '' : $commande->getNomUrl(1), 'commande_fournisseur' => $HtmlCmdFourn, 'date_besoin' => $form->calendrier('', 'date_besoin', $assetOf->date_besoin, 12, 12), 'date_lancement' => $form->calendrier('', 'date_lancement', $assetOf->date_lancement, 12, 12), 'temps_estime_fabrication' => price($assetOf->temps_estime_fabrication, 0, '', 1, -1, 2), 'temps_reel_fabrication' => price($assetOf->temps_reel_fabrication, 0, '', 1, -1, 2), 'fk_soc' => $mode == 'edit' ? $doliform->select_company($assetOf->fk_soc, 'fk_soc', 'client=1', 1) : ($client->id ? $client->getNomUrl(1) : ''), 'fk_project' => custom_select_projects(-1, $assetOf->fk_project, 'fk_project', $mode), 'note' => $form->zonetexte('', 'note', $assetOf->note, 80, 5), 'quantity_to_create' => $quantity_to_create, 'product_to_create' => $link_product_to_add, 'status' => $form->combo('', 'status', TAssetOf::$TStatus, $assetOf->status), 'statustxt' => TAssetOf::$TStatus[$assetOf->status], 'idChild' => !empty($Tid) ? '"' . implode('","', $Tid) . '"' : '', 'url' => dol_buildpath('/of/fiche_of.php', 2), 'url_liste' => $assetOf->getId() ? dol_buildpath('/of/fiche_of.php?id=' . $assetOf->getId(), 2) : dol_buildpath('/of/liste_of.php', 2), 'fk_product_to_add' => $fk_product_to_add, 'fk_nomenclature' => $fk_nomenclature, 'fk_assetOf_parent' => $assetOf->fk_assetOf_parent ? $assetOf->fk_assetOf_parent : '', 'link_assetOf_parent' => $hasParent ? '<a href="' . dol_buildpath('/of/fiche_of.php?id=' . $TAssetOFParent->rowid, 2) . '">' . $TAssetOFParent->numero . '</a>' : '', 'total_cost' => price($assetOf->total_cost, 0, '', 1, -1, 2), 'total_estimated_cost' => price($assetOf->total_estimated_cost, 0, '', 1, -1, 2), 'mo_cost' => price($assetOf->mo_cost, 0, '', 1, -1, 2), 'mo_estimated_cost' => price($assetOf->mo_estimated_cost, 0, '', 1, -1, 2), 'compo_cost' => price($assetOf->compo_cost, 0, '', 1, -1, 2), 'compo_estimated_cost' => price($assetOf->compo_estimated_cost, 0, '', 1, -1, 2), 'current_cost_for_to_make' => price($assetOf->current_cost_for_to_make, 0, '', 1, -1, 2)), 'view' => array('mode' => $mode, 'status' => $assetOf->status, 'allow_delete_of_finish' => $user->rights->of->of->allow_delete_of_finish, 'ASSET_USE_MOD_NOMENCLATURE' => (int) $conf->nomenclature->enabled, 'OF_MINIMAL_VIEW_CHILD_OF' => (int) $conf->global->OF_MINIMAL_VIEW_CHILD_OF, 'select_product' => $select_product, 'select_workstation' => $form->combo('', 'fk_asset_workstation', TWorkstation::getWorstations($PDOdb), -1), 'actionChild' => $mode == 'edit' ? __get('actionChild', 'edit') : __get('actionChild', 'view'), 'use_lot_in_of' => (int) (!empty($conf->asset->enabled) && !empty($conf->global->USE_LOT_IN_OF)), 'use_project_task' => (int) $conf->global->ASSET_USE_PROJECT_TASK, 'defined_user_by_workstation' => (int) $conf->global->ASSET_DEFINED_USER_BY_WORKSTATION, 'defined_task_by_workstation' => (int) $conf->global->ASSET_DEFINED_OPERATION_BY_WORKSTATION, 'defined_workstation_by_needed' => (int) $conf->global->ASSET_DEFINED_WORKSTATION_BY_NEEDED, 'defined_manual_wharehouse' => (int) $conf->global->ASSET_MANUAL_WAREHOUSE, 'hasChildren' => (int) (!empty($Tid)), 'user_id' => $user->id, 'workstation_module_activate' => (int) $conf->workstation->enabled, 'show_cost' => (int) $user->rights->of->of->price), 'rights' => array('show_ws_time' => $user->rights->of->of->show_ws_time))); echo $form->end_form(); llxFooter('$Date: 2011/07/31 22:21:57 $ - $Revision: 1.19 $'); }