Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#26 04-29-2012 18:02:35

innerwolf
Member
From: Leicester UK
Registered: 03-21-2007
Posts: 118
Website

Re: Problems with Version 6.0x in PHP 5.3+

I'm still trying to solve a php 5.3 for the short term while I update the site.

Can anyone help with what might not be 5.3 compliant with this code? I'm sure it must be this file that is stopping me from printing out invoices. Or have a method of running a check on the code?

// +------------------------------------------------------------------+
// | Class Definition                                           [KHXC]|
// +------------------------------------------------------------------+

class GBU_Advorders_batchshipinvoice extends GBU_Advorders {

var $class   = 'GBU_Advorders_batchshipinvoice';
var $version = '6.0.0';
var $cerror;

var $KHXC_DB;
var $KHXC_File;
var $KHXC_Display;
var $KHXC_Form;

var $app;

// +------------------------------------------------------------------+
// | Constructor Function                                       [KHXC]|
// +------------------------------------------------------------------+

function GBU_Advorders_batchshipinvoice () {

// +--
// | This is the class constructor function.
// +--

if ($this->debug) {$this->debugger("constructor: Accessed.");}

// +--
// | Determine the application we're running under and set the $app
// | class var to that app.
// +--

$this->app = $this->app_id(__FILE__);

if ($this->debug) {$this->debugger("constructor: Determined application id as '{$this->app}'");}

// +--
// | Quick object load: KHXC_DB
// +--

$this->KHXC_DB =& $this->quick_object('KHXC_DB','khxc','KHXC_DB_1');

if ($this->IsError($this->KHXC_DB)) {$this->cerror = $this->KHXC_DB; return;}

// +--
// | Quick object load: KHXC_Display
// +--

$this->KHXC_Display =& $this->quick_object('KHXC_Display','khxc');

if ($this->IsError($this->KHXC_Display)) {$this->cerror = $this->KHXC_Display; return;}

// +--
// | Quick object load: KHXC_File
// +--

$this->KHXC_File =& $this->quick_object('KHXC_File','khxc');

if ($this->IsError($this->KHXC_File)) {$this->cerror = $this->KHXC_File; return;}

// +--
// | Quick object load: KHXC_Form
// +--

$this->KHXC_Form =& $this->quick_object('KHXC_Form','khxc');

if ($this->IsError($this->KHXC_Form)) {$this->cerror = $this->KHXC_Form; return;}

// +--
// | Quick object load: GBU_Order
// +--

$this->GBU_Order =& $this->quick_object('GBU_Order',$this->app);

if ($this->IsError($this->GBU_Order)) {$this->cerror = $this->GBU_Order; return;}

// +--
// | Return $this.
// +--

return;

} // End of function.

// +------------------------------------------------------------------+
// | Function: showform                                               |
// +------------------------------------------------------------------+

function showform () {


// +--
// | We need to see which printable inovice we are using.
// +--

$table = 'khxc_namespaces';

$colstring = $this->KHXC_DB->table_column_string($table);

if (($this->IsError($colstring)) || (empty($colstring))) {return 1;}

$sql = "SELECT {$colstring} FROM $table WHERE (";
$sql .= 'namespace=' . $this->KHXC_DB->quote('printinvoice') . ') AND (' . 'app=' .  $this->KHXC_DB->quote($this->app) . ')';
          
// +--
// | Execute the SQL.
// +--

$result = $this->KHXC_DB->sql_do(array('table' => $table,
                                       'sql'   => $sql,
                                       'order' => array('id' => 'ASC')));
// +--
// | Return if there are no results or an error.
// +--

if (($this->IsError($result)) || (empty($result))) {

   if ($this->debug) {$this->debugger("showform: Error or empty result set returned for .");}

   return 1;
} // End of if statement.

// +--
// | Loop through the results and pick the printable invoice type.
// +--
$batchshipinvoice = 0;

foreach ($result as $num => $row) {

   if ($row['pointer'] <> 'GBU_Order::printinvoice()') {$batchshipinvoice = 1;}

} // End of foreach statement.

// +--
// | Display the form to allow you to select the state prov drop down.
// +--

$def_form  = $this->KHXC_Form->def_form(array('app'  => $this->app,
                                              'form' => $this->app . '.batchshipinvoice'));

if ($this->IsError($def_form)) {return $def_form;}

$spec_form = $this->KHXC_Form->spec_form($def_form);

if ($this->IsError($spec_form)) {return $spec_form;}
foreach ($spec_form['fields'] as $num => $field) {

     if ($field['id'] == $this->app . '.batchshipinvoice.select') {
    
          $spec_form['fields'][$num]['defaultvalue'] = $batchshipinvoice;

     } // End of if statement.

} // End of foreach statement.

$result = $this->KHXC_Form->print_form($spec_form);


if ($this->IsError($result)) {return $result;}

// +--
// | Log that we were here.
// +--

if ($this->debug) {$this->debugger("showform: Displayed export form.");}

// +--
// | Return true.
// +--

return 1;

} // End of function.

// +------------------------------------------------------------------+
// | Function: doform                                                 |
// +------------------------------------------------------------------+

function doform () {

// +--
// | This function changes the state province box
// +--

$select = $this->globals('khxc_cgi.' . $this->app . '--batchshipinvoice--select');


// +--
// | Update all form feilds to show drop down if true else textbox
// +--

$table  = 'khxc_namespaces';

if ($select){
    $data   = array('pointer' => 'GBU_Advorders::GBU_Advorders_batchshipinvoice::printinvoice()');
} else {
    $data   = array('pointer' => 'GBU_Order::printinvoice()');

}


// Update Form Fields
$where  = '(namespace=' . $this->KHXC_DB->quote('printinvoice') . ') AND (' . 'app=' .  $this->KHXC_DB->quote($this->app) . ')';
$update_clause = $this->KHXC_DB->clause_update(array('table' => $table,
                                                     'data'  => $data));

if (!($this->IsError($update_clause))) {

     $sql = $update_clause . ' WHERE ' . $where;

     $this->KHXC_DB->sql_do(array('sql'   => $sql,
                                  'table' => $table));

} // End of if statement.
// +--
// | Print the confirm and return true.
// +--

$this->print_message($this->app,'batchshipinvoiceconf');

return $this->exec_namespace(array('app'       => $this->app,
                                   'namespace' => 'batchshipinvoice',
                                   'type'      => '*',
                                   'params'    => null));

// +--
// | Return true.
// +--

return 1;

} // End of function.
// +------------------------------------------------------------------+
// | Function: printinvoice                                           |
// +------------------------------------------------------------------+

function printinvoice () {

// +--
// | This function looks up information for an order and returns it
// | to the calling function.
// +--

$order_number = $this->globals('khxc.ref');

// +--
// | Return an error if the order number is blank.
// +--

if (empty($order_number)) {

     if ($this->debug) {$this->debugger("printinvoice: No order number made available to lookup order.  Printing message.");}

     $this->print_message($this->app,'orderlookuperr');

     return 1;

} // End of if statement.

// +--
// | Look up the order.  Return any errors encountered.
// +--

$result = $this->GBU_Order->orderlookup($order_number);

if ($this->IsError($result)) {

     if ($this->debug) {$this->debugger("printinvoice: Error encountered while looking up order.  Printing message.");}

     $this->print_message($this->app,'orderlookuperr');

     return 1;

} // End of if statement.

// +--
// | Set our global display flag up so KHXC_Display knows to
// | use the print only skin file.
// +--

$this->globals('khxc_display.printable',1);

// +--
// | Globalize our result and print the invoice header and
// | order summary include.
// +--
$eutax_text = $this->eutaxpricetext();
$this->globals('eutax_text',$eutax_text);
$this->globals('ecom.order_summary',$result);


$this->KHXC_Display->include_file($this->app,'batchordersummaryprint.php');

$this->KHXC_Display->include_file($this->app,'batchinvoicefooter.php');

if ($this->debug) {$this->debugger("printinvoice: Order summary printed for order '{$order_number}'.");}

// +--
// | Return true.
// +--

return 1;

} // End of function.
// +------------------------------------------------------------------+
// | Function: batchshipinvoiceprint                                  |
// +------------------------------------------------------------------+

function batchshipinvoiceprint () {
// +--
// | Pull the orders.
// +--
$eol      = $this->globals('khxc.eol');

$table = $this->app . '_orders';

$column_string = $this->KHXC_DB->table_column_string($table);

if ($this->IsError($column_string)) {return $column_string;}

$sql   = "SELECT {$column_string} FROM {$table} WHERE ";
$sql  .= "(status='NS' OR status='PS' OR status='C') AND (batchshipinvoiceprint<>" . $this->KHXC_DB->quote(1) . ')';

$result = $this->KHXC_DB->sql_do(array('sql'   => $sql,
                                       'table' => $table,
                                       'order' => array('epochorder' => 'DESC')));
               
if (!($this->IsError($result)) && (!empty($result))) {
    $count = 0;
    foreach ($result as $num => $order) {
       $count++;
    }
    $count1 = 0;
    foreach ($result as $num => $order) {
        $count1++;
        // Print the invoice for this order.
        $this->globals('khxc.ref',$order['id']);
        $this->exec_namespace(array('app'       => $this->app,
                                    'namespace' => 'printinvoice',
                                    'type'      => '*',
                                    'params'    => array('ref' => $order['id'])));
        print '</div>' . $eol;
        print '</div>' . $eol;
        if ($count <> $count1) {
            print '<br style="page-break-after:always;" />' . $eol;
            print '<div id="khxc_printable">' . $eol;
            print '<div id="skin_content">' . $eol;
        }
    }

} else {
   // +--
   // | Set our global display flag up so KHXC_Display knows to
   // | use the print only skin file.
   // +--

   $this->globals('khxc_display.printable',1);

   print 'No invoices to batch print.' . $eol;
}
// +--
// | Update all of our orders that we process so they're marked and
// | we don't export them again.
// +--

$table  = $this->app . '_orders';

$data   = array('batchshipinvoiceprint' => 1);

$where  = "(status='NS' OR status='PS' OR status='C') AND (batchshipinvoiceprint<>" . $this->KHXC_DB->quote(1) . ')';

$update_clause = $this->KHXC_DB->clause_update(array('table' => $table,
                                                     'data'  => $data));

if (!($this->IsError($update_clause))) {

     $sql = $update_clause . ' WHERE ' . $where;

     $this->KHXC_DB->sql_do(array('sql'   => $sql,
                                  'table' => $table));

} // End of if statement.


// +--
// | Return true.
// +--

return 1;

} // End of function.
// +------------------------------------------------------------------+
// | Function: return_wmessage                                        |
// +------------------------------------------------------------------+

function return_wmessage ($message = '') {

// +--
// | This function prints a generic error message and returns to
// | the doform() method.
// +--

if (!(empty($message))) {

     $this->print_message($this->app,$message);

} // End of if statement.

return $this->showform();

} // End of function.

// +------------------------------------------------------------------+
// | Function: qbquote                                                |
// +------------------------------------------------------------------+

function qbquote ($string = '') {

// +--
// | This function quotes a string for insertion into a Quickbooks
// | export file.
// +--

return preg_replace("/\t/",'',$string);

} // End of function.

// +------------------------------------------------------------------+
// | End of Class                                               [KHXC]|
// +------------------------------------------------------------------+

} // End of class.

// +------------------------------------------------------------------+
// | End Of File                                                [KHXC]|
// +------------------------------------------------------------------+

?>


wwwbritishdog.net - Dog Training Equipment and all that stuff
wwwinnerwolf.co.uk - For Dog and Owners, that Love the Great Outdoors
wwwpickledshrimp.co.uk - Kitewing, If there's Wind, Wing it!

Offline

 

#27 04-29-2012 18:46:42

dh783
Moderator
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: Problems with Version 6.0x in PHP 5.3+

What error are you getting? Are you sure this script is causing the problem as it seems to be an extension scrip of  another class?

John

Offline

 

#28 04-30-2012 02:56:50

innerwolf
Member
From: Leicester UK
Registered: 03-21-2007
Posts: 118
Website

Re: Problems with Version 6.0x in PHP 5.3+

It s just a blank sheet that I'm getting, not a script error. Everything else on the site is working okay after inplementing the changes on the doc, but this. I've looked for and slpit() canges, namespaces or =& news but non of those are in this script so I'm stumped.


wwwbritishdog.net - Dog Training Equipment and all that stuff
wwwinnerwolf.co.uk - For Dog and Owners, that Love the Great Outdoors
wwwpickledshrimp.co.uk - Kitewing, If there's Wind, Wing it!

Offline

 

#29 04-30-2012 03:07:06

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Problems with Version 6.0x in PHP 5.3+

Nothing in what you posted should be causing any problems and there are no syntax errors in what you posted either. I suspect your problem is elsewhere.

Offline

 

#30 04-30-2012 03:25:45

innerwolf
Member
From: Leicester UK
Registered: 03-21-2007
Posts: 118
Website

Re: Problems with Version 6.0x in PHP 5.3+

Okay, thank you. Any suggestions as to where this might be? This is an extention that was added by GBW.


wwwbritishdog.net - Dog Training Equipment and all that stuff
wwwinnerwolf.co.uk - For Dog and Owners, that Love the Great Outdoors
wwwpickledshrimp.co.uk - Kitewing, If there's Wind, Wing it!

Offline

 

Board footer