<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once "../php/factory.php";
require_once "../php/uf_utilities.php";
require_once "../class/NWX_Database.cls.php";
require_once "../class/NWX_NAVWebX.cls.php";
require_once "../config/db.config";
require_once "../config/constant.config";
require_once "../config/setup.config.php";
$index = $_POST['transactionIndex'];
$nav_obj = new NWX_NAVWebX($servername, $username, $password, $dbname, C_TABLELIST, C_NWXCOLUMNAMELIST);
$nav_obj->s_salesType = "ORDER";
switch ($index) {
    case C_TRANSACTIONINDEX["SO_CREATE_HEADER"]:
        /* New Sales Order Header */
        $A_columnList = array();
        $A_aliasPattern = array();
        $A_flippedResultSet = array();
        $resultSet = array();
        $S_commaSeparatedKey = "";
        $S_commaSeparatedValue = "";
        $_POST["CNL_1501"] = "NULL";
        $nav_obj->A_propertyList = $_POST;
        $salesType = $nav_obj->s_salesType;
        $latestID = $nav_obj->nwx_dbc_create_sales_header();
        if ($nav_obj->s_transSucceeded == DBO_SUCCESS_CREATE) {
            $A_aliasPattern = C_TRANSLATION_DICTIONARY["TR002"];
            $A_columnList = $nav_obj->nwx_translate_alias_to_column($A_aliasPattern);
            $resultSet = $nav_obj->nwx_dbc_get_header_row($latestID, $A_columnList);
        $salesType = "ORDER";
        $tableSOColumn = $nav_obj->A_columnNameDictionary['CNL_1603'];
        $tableSOTypeCol = $nav_obj->A_columnNameDictionary['CNL_1602'];
        $nav_obj->s_nwxQueryCondition = "`" . $tableSOColumn . "` LIKE \n\t\t\t\t\t\t\t\t\t\t\t'%" . $salesNumber . "%' AND\n\t\t\t\t\t\t\t\t\t\t\t`" . $tableSOTypeCol . "` = '{$salesType}'";
        $entryDetailDataTable = $nav_obj->nwx_create_editable_table($s_tableIndexAlias, $A_columnIndexAlias, $A_tableHeader, $tableAttrib, "", $tHeadRowDataAttrib, $rowDataAttrib, "", __MODALOPENERDETAIL_UPDATE_ATTRIB);
        print $entryDetailDataTable;
        break;
    case C_SCREENINDEX['SO_MOD_DETAIL']:
        /* Sales Detail data entry form */
        $salesRef = $_POST["salesRef"];
        $salesNumber = $_POST["salesNumber"];
        $A_dictionary = array();
        $A_aliasDictionary = array();
        $A_columnValues = array();
        $A_selectColumn = array();
        $nav_obj = new NWX_NAVWebX($servername, $username, $password, $dbname, C_TABLELIST, C_NWXCOLUMNAMELIST);
        $salesReference = $salesRef;
        $colName = $nav_obj->A_columnNameDictionary["CNL_1601"];
        $nav_obj->s_nwxTableName = $nav_obj->A_tableNameDictionary["TBS_06"];
        $nav_obj->s_nwxQueryCondition = " `" . $colName . "`= " . $salesReference;
        $nav_obj->A_formColumnArray = C_NWXCOLUMHTMLINPUT_M1;
        $set1 = $nav_obj->nwx_preinsert_form_input(C_INPUTPATTERN["P003"]);
        $entryDetailForm = '<form ' . __FORMATTRIB_M2 . '>
									<div class="row" style="auto:scroll;">
										<div class="col-lg-12">
											' . $set1 . '
										</div>
									</div>
								</form>';
        print "<div class='container-fluid'>";
        print "\t\t<div class='row'>";
     $tableAttrib = " id='' class='table table-striped' ";
     // $tableAttrib = " id='transScreenOpener' class='table table-striped' data-toggle='modal' data-target='#myModal' data-backdrop='static' ";
     // $trowAttrib  = ' id="transScreenOpener" data-toggle="modal" data-target="#mdl_headerModal" data-backdrop="static" ';
     // $trowAttrib  = ' id="transScreenOpener" data-toggle="modal" data-target="#mdl_detailModal" data-backdrop="static" ';
     $trowAttrib = ' ';
     // $trowAttrib  = '   ';
     print um_table_creator($tableDef, $tabHeader, $tableAttrib, $trowAttrib);
     break;
 case '3':
     $nav_obj = new NWX_NAVWebX($servername, $username, $password, $dbname);
     $tableID = C_TABLELIST[$nwxTableIndex];
     print $nav_obj->nwx_generate_sequence($tableID);
     break;
 case '4':
     /* Header and detail data entry form */
     $nav_obj = new NWX_NAVWebX($servername, $username, $password, $dbname);
     /* $A_labelList			= C_NWXCOLUMNLABELLIST;
     			$A_inputPattern  		= C_INPUTPATTERN["P002"];
     			$dataTableID			= "tbl_entryHeader";
     			$tableAttrib 			= " id='".$dataTableID."' class='".__TABLECLASS_M1."' ";
     			$tHeadRowDataAttrib 	= " class='text-nowrap'";
     			$updateButton		    = " <div class='col-lg-8'>
     										</div>
     										<div class='col-lg-4'>
     											<input type ='button' 
     												   value='Add Detail'
     												   ".__MODALOPENERDETAIL_ATTRIB.">
     										</div>";
     			
     			$nav_obj->A_tableNameDictionary  = C_TABLELIST;
     			$nav_obj->A_columnNameDictionary = C_NWXCOLUMNAMELIST;
<?php

require_once "../class/NWX_Database.cls.php";
require_once "../class/NWX_NAVWebX.cls.php";
require_once "../config/db.config";
require_once "../config/constant.config";
require_once "../config/setup.config.php";
require_once "../php/uf_utilities.php";
// $db_obj  = new NWX_Database($servername,$username,$password,$dbname);
$nav_obj = new NWX_NAVWebX($servername, $username, $password, $dbname, C_TABLELIST, C_NWXCOLUMNAMELIST);
// $tableDef =$db_obj->nwx_dbc_select("nwx05_sales_header");
// $tableAttrib = 'id="example" class="table table-hover" cellspacing="0" width="100%" border="1"';
// $x = $nav_obj->nwx_dbc_get_col_prop('nwx02_item','n002_item_id');
// $x = $db_obj->nwx_dbc_if_autoincrement('nwx02_item','n002_item_id');
// $x = $db_obj->nwx_dbc_get_table_columns('nwx02_item');
$x = $nav_obj->nwx_generate_sequence('nwx06_sales_line');
print "<pre>";
print_r($nav_obj->nwx_dbc_get_last_detail_number('SN20160121_1'));
/* print "<pre>";
$x = $nav_obj->nwx_create_datatable("TBS_06","P001");
print "<pre>";

for($x=1;$x<=15;$x++){
	$ind = $x>9?$x:'0'.$x;
	$index = "CNL_15".$ind;
	print $index;
	print C_NWXCOLUMHTMLINPUT_M1[$index];
	
}
print  $x;
 */