Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

If, elseif, else... suggestion please?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-17-2005, 08:27 PM
 
x-online x-online is offline
 

Senior Member
  
Join Date: Apr 2004
Location: Australia, Sydney
Posts: 189
 

Default If, elseif, else... suggestion please?

Hi, somehow i got confused half way thru the codes...

here is what i wanted it to work (include/history_order.php)
Code:
if ($mode == "invoice" or $mode == "invoice_no_cc" or $mode == "label") { header("Content-Type: text/html"); header("Content-Disposition: inline; filename=invoice.txt"); $orders = explode(",", $orderid); if ($orders) { $orders_data = array(); foreach ($orders as $orderid) { $order_data = func_order_data($orderid); # # Security check if order owned by another customer # if ($current_area == 'C' && $order_data["userinfo"]["login"] != $login) { func_header_location("error_message.php?access_denied&id=34"); } $order = $order_data["order"]; $customer = $order_data["userinfo"]; $products = func_translate_products($order_data["products"], ($userinfo['language']?$userinfo['language']:$config['default_customer_language'])); $giftcerts = $order_data["giftcerts"]; $orders_data[] = array ("order" => $order, "customer" => $customer, "products" => $products, "giftcerts" => $giftcerts); } $smarty->assign("orders_data", $orders_data); $_tmp_smarty_debug = $smarty->debugging; $smarty->debugging = false; if ($mode == "invoice") { if ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"]))) $smarty->assign("show_order_details", "Y"); func_display("main/order_invoice_print.tpl",$smarty); } elseif ($mode == "invoice_no_cc") ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"]))) $smarty->assign("show_order_details", "Y"); func_display("main/order_invoice_no_cc_print.tpl",$smarty); } elseif ($mode == "label") func_display("main/order_labels_print.tpl",$smarty); $smarty->debugging = $_tmp_smarty_debug; } exit;

This is the area i stuffed up:
if ($mode == "invoice") {
if ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"])))
$smarty->assign("show_order_details", "Y");
func_display("main/order_invoice_print.tpl",$smarty);
} elseif ($mode == "invoice_no_cc")
($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"])))
$smarty->assign("show_order_details", "Y");
func_display("main/order_invoice_no_cc_print.tpl",$smarty);
} elseif ($mode == "label")
func_display("main/order_labels_print.tpl",$smarty);


I can't make it works... right now my code is only this:
Code:
if ($mode == "invoice") { if ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"]))) $smarty->assign("show_order_details", "Y"); func_display("main/order_invoice_print.tpl",$smarty); } elseif ($mode == "invoice_no_cc") func_display("main/order_invoice_no_cc_print.tpl",$smarty);

Any idea please?
__________________
X-Cart version 4.x (Most likely will be the latest version)
Reply With Quote
  #2  
Old 01-18-2005, 04:12 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

post what you want it to do and ill see whats what
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #3  
Old 01-18-2005, 02:40 PM
 
x-online x-online is offline
 

Senior Member
  
Join Date: Apr 2004
Location: Australia, Sydney
Posts: 189
 

Default Thanks...

Hi sorry for confused message at the top..
what i tried to do is...
in order > click on the ID to go to the details >
there is a "print invoice" button.
I actually made 2 print invoice buttons there.
One with CC and one without CC in it.

So... i then cut the 'label' section out for now as i can't make it 3 statements like eg. if not A go B if not B go C etc.
i stucked with 2 statement (if not A go B if not B toughluck.... )


Here the current file (include/history_order.php):
Code:
<?php /*****************************************************************************\ # # $Id: history_order.php,v 1.22.2.5 2004/11/01 11:41:13 svowl Exp $ # # Collect infos about ordered products # if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); } if (empty($mode)) $mode = ""; if ($mode == "invoice" or $mode == "invoice_no_cc" or $mode == "label") { header("Content-Type: text/html"); header("Content-Disposition: inline; filename=invoice.txt"); $orders = explode(",", $orderid); if ($orders) { $orders_data = array(); foreach ($orders as $orderid) { $order_data = func_order_data($orderid); # # Security check if order owned by another customer # if ($current_area == 'C' && $order_data["userinfo"]["login"] != $login) { func_header_location("error_message.php?access_denied&id=34"); } $order = $order_data["order"]; $customer = $order_data["userinfo"]; $products = func_translate_products($order_data["products"], ($userinfo['language']?$userinfo['language']:$config['default_customer_language'])); $giftcerts = $order_data["giftcerts"]; $orders_data[] = array ("order" => $order, "customer" => $customer, "products" => $products, "giftcerts" => $giftcerts); } $smarty->assign("orders_data", $orders_data); $_tmp_smarty_debug = $smarty->debugging; $smarty->debugging = false; if ($mode == "invoice") { if ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"]))) $smarty->assign("show_order_details", "Y"); func_display("main/order_invoice_print.tpl",$smarty); } elseif ($mode == "invoice_no_cc") func_display("main/order_invoice_no_cc_print.tpl",$smarty); $smarty->debugging = $_tmp_smarty_debug; } exit; } else { $order_data = func_order_data($orderid); # # Security check if order owned by another customer # if ($current_area == 'C' && $order_data["userinfo"]["login"] != $login) { func_header_location("error_message.php?access_denied&id=35"); } $smarty->assign("order", $order_data["order"]); $smarty->assign("customer", $order_data["userinfo"]); $order_data["products"] = func_translate_products($order_data["products"], ($order_data["userinfo"]['language']?$order_data["userinfo"]['language']:$config['default_customer_language'])); $smarty->assign("products", $order_data["products"]); $smarty->assign("giftcerts", $order_data["giftcerts"]); if ($order_data) { $owner_condition = ""; if ($current_area == "C") $owner_condition = " AND $sql_tbl[orders].login='".$login."'"; elseif ($current_area == "P" && !$single_mode ) { $owner_condition = " AND $sql_tbl[order_details].provider='".$login."'"; } # find next $tmp = func_query_first("SELECT $sql_tbl[orders].orderid FROM $sql_tbl[orders], $sql_tbl[order_details] WHERE $sql_tbl[orders].orderid>'".$orderid."' AND $sql_tbl[order_details].orderid=$sql_tbl[orders].orderid $owner_condition ORDER BY $sql_tbl[orders].orderid ASC LIMIT 1"); if (!empty($tmp["orderid"])) $smarty->assign("orderid_next", $tmp["orderid"]); # find prev $tmp = func_query_first("SELECT $sql_tbl[orders].orderid FROM $sql_tbl[orders], $sql_tbl[order_details] WHERE $sql_tbl[orders].orderid<'".$orderid."' AND $sql_tbl[order_details].orderid=$sql_tbl[orders].orderid $owner_condition ORDER BY $sql_tbl[orders].orderid DESC LIMIT 1"); if (!empty($tmp["orderid"])) $smarty->assign("orderid_prev", $tmp["orderid"]); } } $location[] = array(func_get_langvar_by_name("lbl_orders_management"), "orders.php"); $location[] = array(func_get_langvar_by_name("lbl_order_details_label"), ""); if(!empty($active_modules['RMA'])) { include $xcart_dir."/modules/RMA/add_returns.php"; } if(!empty($active_modules['Anti_Fraud'])) { include $xcart_dir."/modules/Anti_Fraud/order.php"; } ?>

The original file is:
Code:
<?php /*****************************************************************************\ \*****************************************************************************/ # # $Id: history_order.php,v 1.22.2.5 2004/11/01 11:41:13 svowl Exp $ # # Collect infos about ordered products # if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); } if (empty($mode)) $mode = ""; if ($mode == "invoice" or $mode == "invoice_no_cc" or $mode == "label") { header("Content-Type: text/html"); header("Content-Disposition: inline; filename=invoice.txt"); $orders = explode(",", $orderid); if ($orders) { $orders_data = array(); foreach ($orders as $orderid) { $order_data = func_order_data($orderid); # # Security check if order owned by another customer # if ($current_area == 'C' && $order_data["userinfo"]["login"] != $login) { func_header_location("error_message.php?access_denied&id=34"); } $order = $order_data["order"]; $customer = $order_data["userinfo"]; $products = func_translate_products($order_data["products"], ($userinfo['language']?$userinfo['language']:$config['default_customer_language'])); $giftcerts = $order_data["giftcerts"]; $orders_data[] = array ("order" => $order, "customer" => $customer, "products" => $products, "giftcerts" => $giftcerts); } $smarty->assign("orders_data", $orders_data); $_tmp_smarty_debug = $smarty->debugging; $smarty->debugging = false; if ($mode == "invoice") { if ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"]))) $smarty->assign("show_order_details", "Y"); func_display("main/order_invoice_print.tpl",$smarty); } elseif ($mode == "label") func_display("main/order_labels_print.tpl",$smarty); $smarty->debugging = $_tmp_smarty_debug; } exit; } else { $order_data = func_order_data($orderid); # # Security check if order owned by another customer # if ($current_area == 'C' && $order_data["userinfo"]["login"] != $login) { func_header_location("error_message.php?access_denied&id=35"); } $smarty->assign("order", $order_data["order"]); $smarty->assign("customer", $order_data["userinfo"]); $order_data["products"] = func_translate_products($order_data["products"], ($order_data["userinfo"]['language']?$order_data["userinfo"]['language']:$config['default_customer_language'])); $smarty->assign("products", $order_data["products"]); $smarty->assign("giftcerts", $order_data["giftcerts"]); if ($order_data) { $owner_condition = ""; if ($current_area == "C") $owner_condition = " AND $sql_tbl[orders].login='".$login."'"; elseif ($current_area == "P" && !$single_mode ) { $owner_condition = " AND $sql_tbl[order_details].provider='".$login."'"; } # find next $tmp = func_query_first("SELECT $sql_tbl[orders].orderid FROM $sql_tbl[orders], $sql_tbl[order_details] WHERE $sql_tbl[orders].orderid>'".$orderid."' AND $sql_tbl[order_details].orderid=$sql_tbl[orders].orderid $owner_condition ORDER BY $sql_tbl[orders].orderid ASC LIMIT 1"); if (!empty($tmp["orderid"])) $smarty->assign("orderid_next", $tmp["orderid"]); # find prev $tmp = func_query_first("SELECT $sql_tbl[orders].orderid FROM $sql_tbl[orders], $sql_tbl[order_details] WHERE $sql_tbl[orders].orderid<'".$orderid."' AND $sql_tbl[order_details].orderid=$sql_tbl[orders].orderid $owner_condition ORDER BY $sql_tbl[orders].orderid DESC LIMIT 1"); if (!empty($tmp["orderid"])) $smarty->assign("orderid_prev", $tmp["orderid"]); } } $location[] = array(func_get_langvar_by_name("lbl_orders_management"), "orders.php"); $location[] = array(func_get_langvar_by_name("lbl_order_details_label"), ""); if(!empty($active_modules['RMA'])) { include $xcart_dir."/modules/RMA/add_returns.php"; } if(!empty($active_modules['Anti_Fraud'])) { include $xcart_dir."/modules/Anti_Fraud/order.php"; } ?>

The different between the two are:
- added
Code:
} elseif ($mode == "invoice_no_cc") func_display("main/order_invoice_no_cc_print.tpl",$smarty)
- delete
Code:
} elseif ($mode == "label") func_display("main/order_labels_print.tpl",$smarty);
because i don't know how to have 3 statements (eg. if, elseif, else)

Can someone tell me how to put these 3 statements together?
Code:
if ($mode == "invoice") { if ($current_area == "A" || ($current_area == "P" && !empty($active_modules["Simple_Mode"]))) $smarty->assign("show_order_details", "Y"); func_display("main/order_invoice_print.tpl",$smarty); } elseif ($mode == "label") func_display("main/order_labels_print.tpl",$smarty); } elseif ($mode == "invoice_no_cc") func_display("main/order_invoice_no_cc_print.tpl",$smarty);
__________________
X-Cart version 4.x (Most likely will be the latest version)
Reply With Quote
  #4  
Old 01-19-2005, 05:45 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

ive done something similar in the past but like this

create an extra button to print your invoice and add an extra var

ie - orders.php?orderid=blah&showcc=Y

then on the invoice wrap the cc code part in this

Code:
{if $smarty.get.showwcc eq "Y"} cc details {/if}

this is a very basic example and the button code is made up but should give you an idea of how to achieve it
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #5  
Old 01-19-2005, 06:03 AM
 
x-online x-online is offline
 

Senior Member
  
Join Date: Apr 2004
Location: Australia, Sydney
Posts: 189
 

Default Thanks

Thanks Heaps Shan,

As the code for both invoice and no invoice's buttons are already in place and functioning.. Can i use the code i put in earlier but with the label?

I am not expert with php yet so i dont't know how to add the -var you was talking about.

Thank you for your idea tho.

Once this mod done i will post the complete 'how to' for people to use them
__________________
X-Cart version 4.x (Most likely will be the latest version)
Reply With Quote
  #6  
Old 01-19-2005, 06:07 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

you can even wrap the cc code in smarty that checks to see if the user is an admin user rather then a customer and show it that way
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:49 AM.

   

 
X-Cart forums © 2001-2020