lindem Posted August 22, 2007 Share Posted August 22, 2007 Hello. I need to add the "$description" from the table "tplinvoiceitems" into the boleto.php. Does anyone to give a help with this? The code is (boleto.php): <? include("../../../dbconnect.php"); include("../../../includes/functions.php"); include("../../../includes/clientfunctions.php"); $gwresult = mysql_query("SELECT * FROM tblpaymentgateways WHERE gateway='boleto' ORDER BY `id` ASC"); while($data = mysql_fetch_array($gwresult)) { $gVgwsetting = $data["setting"]; $gVgwvalue = $data["value"]; $GATEWAY["$gVgwsetting"]="$gVgwvalue"; } $query = "SELECT * FROM tblinvoices WHERE id='$invoiceid'"; $result=mysql_query($query); $data = mysql_fetch_array($result); $id = $data["id"]; $userid = $data["userid"]; $date = $data["date"]; $duedate = $data["duedate"]; $subtotal = $data["subtotal"]; $credit = $data["credit"]; $tax = $data["tax"]; $taxrate = $data["taxrate"]; $total = $data["total"]; if (($_SESSION["uid"]!=$userid)OR(!$id)) { echo "Invalid Access Attempt"; exit; } $clientsdetails = getClientsDetails($userid); $year = substr($duedate,0,4); $month = substr($duedate,5,2); $day = substr($duedate,8,2); Regards. 0 Quote Link to comment Share on other sites More sharing options...
trine Posted August 22, 2007 Share Posted August 22, 2007 do you need just the first item or all items in the description (because one invoice may have multiple line items). here is the query: SELECT `description` FROM `tblinvoiceitems` WHERE `invoiceid`= '$invoiceid' now depending on what your needs are, the code will vary. 0 Quote Link to comment Share on other sites More sharing options...
lindem Posted August 22, 2007 Author Share Posted August 22, 2007 Let me explain the whole thing then... <? include("../../../dbconnect.php"); include("../../../includes/functions.php"); include("../../../includes/clientfunctions.php"); $gwresult = mysql_query("SELECT * FROM tblpaymentgateways WHERE gateway='boleto' ORDER BY `id` ASC"); while($data = mysql_fetch_array($gwresult)) { $gVgwsetting = $data["setting"]; $gVgwvalue = $data["value"]; $GATEWAY["$gVgwsetting"]="$gVgwvalue"; } $query = "SELECT * FROM tblinvoices WHERE id='$invoiceid'"; $result=mysql_query($query); $data = mysql_fetch_array($result); $id = $data["id"]; $userid = $data["userid"]; $date = $data["date"]; $duedate = $data["duedate"]; $subtotal = $data["subtotal"]; $credit = $data["credit"]; $tax = $data["tax"]; $taxrate = $data["taxrate"]; $total = $data["total"]; if (($_SESSION["uid"]!=$userid)OR(!$id)) { echo "Invalid Access Attempt"; exit; } $clientsdetails = getClientsDetails($userid); $year = substr($duedate,0,4); $month = substr($duedate,5,2); $day = substr($duedate,8,2); $banco = $GATEWAY["banco"]; $dias_de_prazo_para_pagamento = 0; // No need for this, since the due date will be the same as the invoice's $taxa_boleto = $GATEWAY["taxa"]; // FIELD NAME IN ADMIN: Taxa do boleto $data_venc = date("d/m/Y",mktime(0,0,0,$month,$day,$year)); // It has to be the same as the invoice due date $valor_cobrado = $total; $valor_boleto=number_format($valor_cobrado+$taxa_boleto, 2, ',', ''); $dadosboleto["nosso_numero"] = $invoiceid; // It's the variable nosso_numero for all banks $dadosboleto["numero_documento"] = $invoiceid; $dadosboleto["data_vencimento"] = $data_venc; $dadosboleto["data_documento"] = date("d/m/Y"); $dadosboleto["data_processamento"] = date("d/m/Y"); $dadosboleto["valor_boleto"] = $valor_boleto; // DADOS DO SEU CLIENTE $dadosboleto["sacado"] = $clientsdetails["firstname"]." ".$clientsdetails["lastname"]; $dadosboleto["endereco1"] = $clientsdetails["address1"]; $dadosboleto["endereco2"] = $clientsdetails["city"].", ".$clientsdetails["state"].", ".$clientsdetails["postcode"]; // INFORMACOES PARA O CLIENTE // The information below needs to be configurable in the admin, it's some optional information for client's receipt (top portion of the boleto and intructions for cashier in the boleto itself. $dadosboleto["demonstrativo1"] = $description; // FIELD DESCRIPTION: Linha 1 do Recibo do Sacado $dadosboleto["demonstrativo2"] = "Mensalidade referente a nonon nonooon nononon"; // FIELD DESCRIPTION: Linha 2 do Recibo do Sacado ?> And I need to make the description of the invoice appears where is: $dadosboleto["demonstrativo1"] = $description; Many thanks for your help trine! 0 Quote Link to comment Share on other sites More sharing options...
trine Posted August 22, 2007 Share Posted August 22, 2007 lindem, again, do you need only 1 item description or all. for the first match only: $query = "SELECT `description` FROM `tblinvoiceitems` WHERE invoiceid= '$invoiceid' LIMIT 1"; $result = mysql_query($query); $data = mysql_fetch_array($result); $description .= $data["description"]; for all matches: $query = "SELECT `description` FROM `tblinvoiceitems` WHERE `invoiceid`= '$invoiceid'"; $result = mysql_query($query); while ($data = mysql_fetch_array($result)){ $description .= $data["description"] . ", "; } $description = trim($description); 0 Quote Link to comment Share on other sites More sharing options...
lindem Posted August 22, 2007 Author Share Posted August 22, 2007 THANK YOU!!! I DIDN`T KNOW IT WAS SO SIMPLE! I DON`T KNOW WHY THE SUPPORT TOLD ME THAT IT WOULD BE IMPOSSIBLE TO DO, MAYBE BECAUSE I`M WAITING MY 15 DAYS EXPIRES TO BUY MY FULL LICENSE... 0 Quote Link to comment Share on other sites More sharing options...
trine Posted August 22, 2007 Share Posted August 22, 2007 yes, very easy! Maybe they misunderstood what you needed ? 0 Quote Link to comment Share on other sites More sharing options...
lindem Posted August 22, 2007 Author Share Posted August 22, 2007 let`s beleive they did, because it wouldn`t be nice from them 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.