if ($object->fk_cash == '9' || $object->fk_cash == '10') { echo "Moreno Valley #199 <br>San Juan de los Lagos, Jal.<br>01(395) 785 3005"; } ?> <br><br> <?php // Variables $object = new Ticket($db); $result = $object->fetch($id, $ref); $userstatic = new User($db); $userstatic->fetch($object->user_close); print $langs->trans("Vendor") . ': ' . $userstatic->firstname . ' ' . $userstatic->lastname . '<br><br>'; if (!empty($object->fk_place)) { $place = new Place($db); $place->fetch($object->fk_place); print $langs->trans("Place") . ': ' . $place->name . "</p>"; } ?> </div> </div> <div><?php // Recuperation et affichage de la date et de l'heure $now = dol_now(); $label = $object->ref; $facture = new Facture($db); if ($object->fk_facture) { $facture->fetch($object->fk_facture); $label = $facture->ref; }
/** * Fill the body of email's message with a facture * * @param int $id * * @return string String with ticket data */ public static function fillMailFactureBody($id) { global $db, $conf, $langs, $mysoc; $langs->Load("rewards@rewards"); $facture = new Facture($db); $res = $facture->fetch($id); $mysoc = new Societe($db); $mysoc->fetch($facture->socid); $userstatic = new User($db); $userstatic->fetch($facture->user_valid); $label = $facture->ref; $message = $conf->global->MAIN_INFO_SOCIETE_NOM . " \n" . $conf->global->MAIN_INFO_SOCIETE_ADRESSE . " \n" . $conf->global->MAIN_INFO_SOCIETE_CP . ' ' . $conf->global->MAIN_INFO_SOCIETE_VILLE . " \n\n"; $message .= $label . " \n" . dol_print_date($facture->date_creation, 'dayhourtext') . " \n"; $message .= $langs->transnoentities("Vendor") . ': ' . $userstatic->fistname . " " . $userstatic->lastname . "\n"; $sql = "SELECT fk_place,fk_cash FROM " . MAIN_DB_PREFIX . "pos_facture WHERE fk_facture =" . $facture->id; $result = $db->query($sql); if ($result) { $objp = $db->fetch_object($result); if ($objp->fk_place > 0) { $place = new Place($db); $place->fetch($objp->fk_place); $message .= $langs->trans("Place") . ': ' . $place->name . "\n"; } } $message .= "\n"; $message .= $langs->transnoentities("Label") . "\t\t\t\t\t\t" . $langs->transnoentities("Qty") . "/" . $langs->transnoentities("Price") . "\t\t" . $langs->transnoentities("Total") . "\n"; //$facture->getLinesArray(); if (!empty($facture->lines)) { $subtotal = 0; foreach ($facture->lines as $line) { $espacio = ''; $totalline = $line->qty * $line->subprice; if (empty($line->libelle)) { $line->libelle = $line->description; } while (dol_strlen(dol_trunc($line->libelle, 30) . $espacio) < 29) { $espacio .= " \t"; } $message .= dol_trunc($line->libelle, 33) . $espacio; $message .= "\t\t" . $line->qty . " * " . price($line->subprice) . "\t\t" . price($line->total_ht) . ' ' . $langs->trans(currency_name($conf->currency)) . "\n"; $subtotal[$line->tva_tx] += $line->total_ht; $subtotaltva[$line->tva_tx] += $line->total_tva; if (!empty($line->total_localtax1)) { $localtax1 = $line->localtax1_tx; } if (!empty($line->total_localtax2)) { $localtax2 = $line->localtax2_tx; } } } else { $message .= $langs->transnoentities("ErrNoArticles") . "\n"; } $message .= $langs->transnoentities("TotalTTC") . ":\t" . price($facture->total_ttc) . " " . $langs->trans(currency_name($conf->currency)) . "\n"; $message .= "\n" . $langs->trans("TotalHT") . "\t" . $langs->trans("VAT") . "\t" . $langs->trans("TotalVAT") . "\n"; if (!empty($subtotal)) { foreach ($subtotal as $totkey => $totval) { if ($tvakey > 0) { $message .= price($subtotal[$totkey], "", "", "", "", 2) . "\t\t\t" . price($totkey, "", "", "", "", 2) . "%\t" . price($subtotaltva[$totkey], "", "", "", "", 2) . "\n"; } } } $message .= "-------------------------------\n"; $message .= price($facture->total_ht, "", "", "", "", 2) . "\t\t\t----\t" . price($facture->total_tva, "", "", "", "", 2) . "\n"; if ($facture->total_localtax1 != 0) { $message .= $langs->transcountrynoentities("TotalLT1", $mysoc->country_code) . " " . price($localtax1, "", "", "", "", 2) . "%\t" . price($facture->total_localtax1, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n"; } if ($facture->total_localtax2 != 0) { $message .= $langs->transcountrynoentities("TotalLT2", $mysoc->country_code) . " " . price($localtax2, "", "", "", "", 2) . "%\t" . price($facture->total_localtax2, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n"; } $message .= "\n\n"; $terminal = new Cash($db); $sql = 'SELECT fk_cash, customer_pay FROM ' . MAIN_DB_PREFIX . 'pos_facture WHERE fk_facture = ' . $facture->id; $resql = $db->query($sql); $obj = $db->fetch_object($resql); $customer_pay = $obj->customer_pay; $terminal->fetch($obj > fk_cash); if (!empty($conf->rewards->enabled)) { $rewards = new Rewards($db); $points = $rewards->getInvoicePoints($facture->id); } if ($facture->type == 0) { $pay = $facture->getSommePaiement(); if (!empty($conf->rewards->enabled)) { $usepoints = abs($rewards->getInvoicePoints($facture->id, 1)); $moneypoints = abs($usepoints * $conf->global->REWARDS_DISCOUNT); //falta fer algo per aci if ($customer_pay > $pay - $moneypoints) { $pay = $customer_pay; } else { $pay = $pay - $moneypoints; } } else { if ($customer_pay > $pay) { $pay = $customer_pay; } } } if ($facture->type == 2) { $customer_pay = $customer_pay * -1; $pay = $facture->getSommePaiement(); if (!empty($conf->rewards->enabled)) { $usepoints = abs($rewards->getInvoicePoints($facture->id, 1)); $moneypoints = abs($usepoints * $conf->global->REWARDS_DISCOUNT); //falta fer algo per aci if ($customer_pay > $pay - $moneypoints) { $pay = $customer_pay; } else { $pay = $pay - $moneypoints; } } else { if ($customer_pay > $pay) { $pay = $customer_pay; } } } $diff_payment = $facture->total_ttc - $moneypoints - $pay; $listofpayments = $facture->getListOfPayments(); foreach ($listofpayments as $paym) { if ($paym['type'] != 'PNT') { if ($paym['type'] != 'LIQ') { $message .= $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . "\t" . price($paym['amount'], "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n"; } else { $message .= $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . "\t" . price($paym['amount'] - ($diff_payment < 0 ? $diff_payment : 0), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n"; } } } if (!empty($conf->rewards->enabled)) { if ($moneypoints > 0) { $message .= $usepoints . " " . $langs->trans("Points") . "\t" . price($moneypoints, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n"; } } $message .= ($diff_payment < 0 ? $langs->trans("CustomerRet") : $langs->trans("CustomerDeb")) . "\t" . price(abs($diff_payment), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n"; if ($points != 0 && !empty($conf->rewards->enabled)) { $message .= $langs->trans("TotalPointsInvoice") . "\t" . price($points, "", "", "", "", 2) . " " . $langs->trans('Points') . "\n"; $total_points = $rewards->getCustomerPoints($facture->socid); $message .= $langs->trans("DispoPoints") . "\t" . price($total_points, "", "", "", "", 2) . " " . $langs->trans('Points') . "\n"; } $message .= $conf->global->POS_PREDEF_MSG; return $message; }
$facture = new Facture($db); if ($ticket->fk_facture) { $facture->fetch($ticket->fk_facture); $label = $facture->ref; } $json_data['type'] = $pending_print[0][0]; $json_data['ref'] = $label; $json_data['mysoc_name'] = $mysoc->name ? $mysoc->name : ""; $json_data['mysoc_address'] = $mysoc->address ? $mysoc->address : ""; $json_data['mysoc_town'] = ($mysoc->zip ? $mysoc->zip : "") . ' ' . ($mysoc->town ? $mysoc->town : ""); $json_data['mysoc_idprof'] = $mysoc->idprof1 ? $mysoc->idprof1 : ""; $json_data['datetime'] = dol_print_date($facture->date_closed, 'dayhourtext'); $json_data['vendor'] = $langs->transnoentities("Vendor") . ': ' . $userstatic->firstname . " " . $userstatic->lastname; if (!empty($ticket->fk_place)) { $place = new Place($db); $place->fetch($ticket->fk_place); $json_data['place'] = $langs->trans("Place") . ': ' . $place->name; } else { $json_data['place'] = ""; } $json_data["gift"] = $langs->trans("GiftTicket"); $json_data['header_lines'] = str_pad(substr($langs->transnoentities("Label"), 0, 23), 25, ' ', STR_PAD_RIGHT) . str_pad(substr($langs->transnoentities("Qty"), 0, 5), 6, ' ', STR_PAD_LEFT) . str_pad(substr($langs->transnoentities("Total"), 0, 5), 12, ' ', STR_PAD_LEFT); $rows = array(); //$ticket->getLinesArray(); if (!empty($ticket->lines)) { //$subtotal=0; foreach ($ticket->lines as $line) { $totalline = $line->qty * $line->subprice; if (empty($line->libelle)) { $line->libelle = $line->description; }
$userstatic->fetch($object->user_valid); print $langs->trans("Vendor") . ': ' . $userstatic->firstname . ' ' . $userstatic->lastname . '<br><br>'; $client = new Societe($db); $client->fetch($object->socid); print $client->nom . '<br>'; print $client->idprof1 . '<br>'; print $client->address . '<br>'; print $client->zip . ' ' . $client->town . '<br>'; print $client->state . '</p>'; $sql = "SELECT fk_place,fk_cash FROM " . MAIN_DB_PREFIX . "pos_facture WHERE fk_facture =" . $object->id; $result = $db->query($sql); if ($result) { $objp = $db->fetch_object($result); if ($objp->fk_place > 0) { $place = new Place($db); $place->fetch($objp->fk_place); print $langs->trans("Place") . ': ' . $place->name . '</p>'; } } ?> </div> </div> <?php if ($result) { if (!empty($object->lines)) { $onediscount = false; foreach ($object->lines as $line) { if ($line->remise_percent) { $onediscount = true; }
} //$result=restrictedArea($user,'banque',$id,'bank_account','','',$fieldid); $year_start = GETPOST('year_start'); $year_current = strftime("%Y", time()); if (!$year_start) { $year_start = $year_current - 2; $year_end = $year_current; } else { $year_end = $year_start + 2; } $helpurl = 'EN:Module_DoliPos|FR:Module_DoliPos_FR|ES:Módulo_DoliPos'; llxHeader('', '', $helpurl); $form = new Form($db); // Get account informations $acct = new Place($db); $result = $acct->fetch($id, $ref); # Ce rapport de tresorerie est base sur llx_bank (car doit inclure les transactions sans facture) # plutot que sur llx_paiement + llx_paiementfourn $sql = "SELECT SUM(total_ttc) as total"; $sql .= ", date_format(date_creation,'%Y-%m') as dm"; $sql .= " FROM " . MAIN_DB_PREFIX . "pos_ticket"; //$sql.= " WHERE fk_cash = ".$id; $sql .= " WHERE entity = " . $conf->entity; $sql .= " AND fk_statut in (1,2,3,4)"; if ($acct->id) { $sql .= " AND fk_place IN (" . $acct->id . ")"; } $sql .= " GROUP BY dm"; $sql .= " UNION SELECT sum(fac.total_ttc) as total"; $sql .= ", date_format(datec,'%Y-%m') as dm"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture as fac, " . MAIN_DB_PREFIX . "pos_facture as pf";
} if ($sortfield == 'amount_ttc' && $sortorder == 'asc') { asort($amount); $arrayforsort = $amount; } if ($sortfield == 'amount_ttc' && $sortorder == 'desc') { arsort($amount); $arrayforsort = $amount; } foreach ($arrayforsort as $key => $value) { $var = !$var; print "<tr " . $bc[$var] . ">"; // Place //$fullname=$name[$key]; $place = new Place($db); $place->fetch($key); /*if ($key > 0) { $linkname='<a href="'.DOL_URL_ROOT.'/societe/soc.php?socid='.$key.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$fullname.'</a>'; }*/ print "<td>" . $place->getNomUrl(1) . "</td>\n"; // Amount print '<td align="right">'; $url = dol_buildpath('/pos/backend/listefac.php?placeid=' . $key, 1); if ($key > 0) { print '<a href="' . $url . '">'; } else { print '<a href="#">'; } print price($amount[$key]); print '</a>'; print '</td>';
/** * Delete ticket and all the lines * @return number <0 if KO, >0 if OK */ function delete_ticket() { dol_include_once('/pos/class/place.class.php'); global $user, $langs, $conf, $db; $sql = "DELETE FROM " . MAIN_DB_PREFIX . "pos_ticketdet WHERE fk_ticket=" . $this->id; $resql = $this->db->query($sql); if ($resql) { $sql = "DELETE FROM " . MAIN_DB_PREFIX . "pos_ticket"; $sql .= " WHERE rowid= " . $this->id; $sql .= " AND entity = " . $conf->entity; $resql = $this->db->query($sql); if ($resql) { if ($this->statut == 0) { $place = new Place($db); $place->fetch($this->fk_place); $place->free_place(); } $this->db->commit(); return 1; } else { $this->db->rollback(); return -1; } } else { $this->db->rollback(); return -1; } }