<?php

include_once"base_connect.php";

switch ($part) {
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
case "add_customer":

if(isset($type) && $type=="edit"){
$edit="1";
$lead_id=$id;
}
else{
$edit="0";
$lead_id="0";
}

$dropdowns=array(


);



$dropdowns2=array(
);

$mask1="'mask': '(999)-(9999999)'";
$mask2="'alias': 'numeric','digits': 2,'digitsOptional': false, 'placeholder': '0'";

$textfields=array(

array(
'label'=>'Business Name',
'fname'=>company,
'class'=>'col-md-12',
'encoding'=>'0',
'format'=>'words',
'hint'=>'Business Name',
'masking'=>'off',
'required'=>'1'),


array(
'label'=>'Contact Person / Owner Name',
'fname'=>person,
'class'=>'col-md-6',
'encoding'=>'0',
'format'=>'words',
'masking'=>'off',
'required'=>'1'),


array(
'label'=>'Address',
'fname'=>address,
'class'=>'col-md-6',
'encoding'=>'0',
'format'=>'words',
'required'=>'1'),

array(
'label'=>'City',
'fname'=>city,
'class'=>'col-md-6',
'placeholder'=>'Rawalpindi',
'encoding'=>'0',
'format'=>'words',
'required'=>'1'),

array(
'label'=>'Country',
'fname'=>country,
'class'=>'col-md-6',
'encoding'=>'0',
'placeholder'=>'Pakistan',
'format'=>'words',
'required'=>'1'),

array(
'label'=>'Cell',
'fname'=>cell,
'class'=>'col-md-12',
'encoding'=>'0',
'format'=>'words',
'required'=>'1'),




);


$integerfields=array(
);


$wysiwygfields=array(

);

$wysiwygfields_choice=array(


);



$checkboxfields=array(
);


$timepickfields=array(
);

$directfields=array(
array(
'fname'=>'posted_by',
'value'=>$user_id
)

);


$update_settings=array(
'update_flag'=>"Lead Edited",
'update_ref'=>"ims_update",
'update_email'=>0
);



$edit=array(
'edit'=>$edit,
'lead_id'=>$lead_id,
'e_ref'=>routine_customer_alias,
'table'=>main_table
);


$values=array(
'texts'=>$textfields,
'integers'=>$integerfields,
'dropdowns'=>$dropdowns,
'dropdowns2'=>$dropdowns2,
'checkboxes'=>$checkboxfields,
'timepicks'=>$timepickfields,
'wysiwygs'=>$wysiwygfields,
'wysiwygs_choice'=>$wysiwygfields_choice,
'directfields'=>$directfields,
'update_settings'=>$update_settings,
'datedfield'=>dated,
'dated_table'=>main_table,
'prefix'=>'APP-',
'redirect'=>"/list/customers/",
'form_table'=>main_table,
'form_heading'=>"Entry",
'alias'=>"customer_entry"
);

make_form($values,1,$edit);
break;
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
case "add_invoice":

if(isset($type) && $type=="edit"){
$edit="1";
$lead_id=$id;
}
else{
$edit="0";
$lead_id="0";
}

$dropdowns=array(

'drops3'=>array(
'label'=>'Invoice Type',
'table'=>sub_table2,
'table_title'=>sub_table_title,
'table_id_col'=>sub_table_id,
'this_table_field'=>invoice_type,
'ref'=>'invoice_type',
'remote_tbl_title_col'=>sub_table_title,
'add_new'=>'1',
'other_id_col'=>'0',
'encoding'=>'0'),

'drops4'=>array(
'label'=>'Package Type',
'table'=>sub_table2,
'table_title'=>sub_table_title,
'table_id_col'=>sub_table_id,
'this_table_field'=>package_type,
'ref'=>'package_type',
'remote_tbl_title_col'=>sub_table_title,
'add_new'=>'1',
'other_id_col'=>'0',
'encoding'=>'0'),

'drops6'=>array(
'label'=>'Customer Name',
'table'=>main_table,
'table_title'=>company,
'table_id_col'=>id_col,
'this_table_field'=>customer_id,
'ref'=>'customer_entry',
'remote_tbl_title_col'=>company,
'add_new'=>'0',
'other_id_col'=>'0',
'encoding'=>'0'),


);



$dropdowns2=array(
);

$mask1="'mask': '(999)-(9999999)'";
$mask2="'alias': 'numeric','digits': 2,'digitsOptional': false, 'placeholder': '0'";

$textfields=array(

array(
'label'=>'Ref No.',
'fname'=>ref_no,
'class'=>'col-md-12',
'encoding'=>'0',
'placeholder'=>'5D-PK 1-91-B',
'format'=>'words',
'hint'=>'RP-SP',
'masking'=>'off',
'required'=>'1'),




);


$integerfields=array(
);


$wysiwygfields=array(

);

$wysiwygfields_choice=array(


);



$checkboxfields=array(
);


$timepickfields=array(
);

$directfields=array(
array(
'fname'=>'posted_by',
'value'=>$user_id
)

);


$update_settings=array(
'update_flag'=>"Lead Edited",
'update_ref'=>"ims_update",
'update_email'=>0
);



$edit=array(
'edit'=>$edit,
'lead_id'=>$lead_id,
'e_ref'=>routine_invoice_alias,
'table'=>main_table
);


$values=array(
'texts'=>$textfields,
'integers'=>$integerfields,
'dropdowns'=>$dropdowns,
'dropdowns2'=>$dropdowns2,
'checkboxes'=>$checkboxfields,
'timepicks'=>$timepickfields,
'wysiwygs'=>$wysiwygfields,
'wysiwygs_choice'=>$wysiwygfields_choice,
'directfields'=>$directfields,
'update_settings'=>$update_settings,
'datedfield'=>dated,
'dated_table'=>main_table,
'prefix'=>'APP-',
'redirect'=>"/list/invoices/",
'form_table'=>main_table,
'form_heading'=>"Entry",
'alias'=>"invoice_entry"
);

make_form($values,1,$edit);
break;
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
case "add_custom_invoice":

if(isset($type) && $type=="edit"){
$edit="1";
$lead_id=$id;
}
else{
$edit="0";
$lead_id="0";
}

$dropdowns=array(

'drops3'=>array(
'label'=>'Invoice Type',
'table'=>sub_table2,
'table_title'=>sub_table_title,
'table_id_col'=>sub_table_id,
'this_table_field'=>invoice_type,
'ref'=>'invoice_type',
'remote_tbl_title_col'=>sub_table_title,
'add_new'=>'0',
'other_id_col'=>'0',
'encoding'=>'0'),

'drops4'=>array(
'label'=>'Package Type',
'table'=>sub_table2,
'table_title'=>sub_table_title,
'table_id_col'=>sub_table_id,
'this_table_field'=>package_type,
'ref'=>'package_type',
'remote_tbl_title_col'=>sub_table_title,
'add_new'=>'0',
'other_id_col'=>'0',
'encoding'=>'0'),

'drops4r'=>array(
'label'=>'Breakup Type',
'table'=>sub_table2,
'table_title'=>sub_table_title,
'table_id_col'=>sub_table_id,
'this_table_field'=>breakup_type,
'ref'=>'breakup_type',
'remote_tbl_title_col'=>sub_table_title,
'add_new'=>'0',
'other_id_col'=>'0',
'encoding'=>'0'),

'drops6'=>array(
'label'=>'Customer Name',
'table'=>main_table,
'table_title'=>company,
'table_id_col'=>id_col,
'this_table_field'=>customer_id,
'ref'=>'customer_entry',
'remote_tbl_title_col'=>company,
'add_new'=>'0',
'other_id_col'=>'0',
'encoding'=>'0'),


);



$dropdowns2=array(
);

$mask1="'mask': '(999)-(9999999)'";
$mask2="'alias': 'numeric','digits': 2,'digitsOptional': false, 'placeholder': '0'";

$textfields=array(

array(
'label'=>'Ref No.',
'fname'=>ref_no,
'class'=>'col-md-12',
'encoding'=>'0',
'placeholder'=>'5D-PK 1-91-B',
'format'=>'words',
'hint'=>'RP-SP',
'masking'=>'off',
'required'=>'1'),

array(
'label'=>'This Invoice Total',
'fname'=>facebook,
'class'=>'col-md-6',
'encoding'=>'0',
'format'=>'words',
'masking'=>'off',
'required'=>'1'),

array(
'label'=>'Discount',
'fname'=>website,
'class'=>'col-md-6',
'encoding'=>'0',
'addon'=>'%',
'format'=>'words',
'masking'=>'off',
'required'=>'1'),

array(
'label'=>'Phases 3',
'fname'=>domain,
'class'=>'col-md-12',
'encoding'=>'0',
'placeholder'=>'2',
'format'=>'words',
'masking'=>'off',
'required'=>'1'),

);


$integerfields=array(
);


$wysiwygfields=array(
);



$wysiwygfields_choice=array(
array(
'table_id'=>id_col,
'fname'=>description,
'required'=>'1',
'drop_down'=>'1',
'text_area_label'=>'Invoice Template',
'select_label'=>'Please Choose a Template',
'select_alias'=>routine_template_alias,
'table'=>main_table,
'drop_table'=>sub_table2,
'drop_table_id'=>sub_table_id,
'drop_table_value'=>sub_table_url8,
'drop_table_title'=>sub_table_title,
'drop_table_ref'=>sub_table_ref,
'drop_table_status'=>sub_table_status));



$checkboxfields=array(
);


$timepickfields=array(
);

$directfields=array(
array(
'fname'=>'posted_by',
'value'=>$user_id
)

);


$update_settings=array(
'update_flag'=>"Lead Edited",
'update_ref'=>"ims_update",
'update_email'=>0
);



$edit=array(
'edit'=>$edit,
'lead_id'=>$lead_id,
'e_ref'=>routine_invoice_alias,
'table'=>main_table
);


$values=array(
'texts'=>$textfields,
'integers'=>$integerfields,
'dropdowns'=>$dropdowns,
'dropdowns2'=>$dropdowns2,
'checkboxes'=>$checkboxfields,
'timepicks'=>$timepickfields,
'wysiwygs'=>$wysiwygfields,
'wysiwygs_choice'=>$wysiwygfields_choice,
'directfields'=>$directfields,
'update_settings'=>$update_settings,
'datedfield'=>dated,
'dated_table'=>main_table,
'prefix'=>'APP-',
'redirect'=>"/list/invoices/",
'form_table'=>main_table,
'form_heading'=>"Entry",
'alias'=>"invoice_entry"
);

make_form($values,1,$edit);
break;
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
//////////////////////// CASE STARTS  ////////////////////////
case "view_lead":

if($legend=="1"){
$e_ref=routine_quick_entry_alias;
$alias_ref="quick_lead_entry";	
}
else{
$e_ref=routine_entry_alias;
$alias_ref="lead_entry";		
}




$settings=array
(
'table'=>main_table,
'child_table'=>sub_table,
'child_table_id_col'=>sub_table_id,
'child_table_title'=>sub_table_title,
'id_col'=>id_col,
'heading'=>'View Details',
'ref'=>$e_ref);
$arraycols=array(

'labels'=>array(
'Name',
'Department',


),

'fields'=>array(
title,
cell,
)
);


$remote_arraycols=array(

'labels'=>array(
'Industry',


),

'fields'=>array(
business_type,
)
);


$links_array=array(

'labels'=>array(
'address','email'),

'urls'=>array(
"/ty/".$id,title)
);

$parameters=array(
'heading'=>'View Record',
'settings'=>$settings,
'fields'=>$arraycols,
'remote_cols'=>$remote_arraycols,
//'links'=>$links_array,
'btn_id'=>'sum_val',
'id'=>$id,
);



//$parameters['legend'] = $id; 


view_record_adv_with_updates_v2($parameters);

break;
/////////////////////////// CASE ENDS  ////////////////////////
case "view_record":

$settings=array
(
'table'=>main_table,
'child_table'=>sub_table,
'child_table_id_col'=>sub_table_id,
'child_table_title'=>sub_table_title,
'id_col'=>id_col,
'heading'=>'View Details',
'ref'=>routine_entry_alias);
$arraycols=array(

'labels'=>array(
'Business Name',
'Cell',
'Owner Name',
'Available Domain',
'Address',
'email',
'Facebook',
'Website',


),

'fields'=>array(
title,
cell,
person,
domain,
address,
email,
facebook,
website,
)
);


$remote_arraycols=array(

'labels'=>array(
'Industry',


),

'fields'=>array(
business_type,
)
);


$links_array=array(

'labels'=>array(
'address','email'),

'urls'=>array(
"/ty/".$id,title)
);

$parameters=array(
'heading'=>'View Details',
'settings'=>$settings,
'fields'=>$arraycols,
'remote_cols'=>$remote_arraycols,
//'links'=>$links_array,
'btn_id'=>'sum_val',
'id'=>$id,
);



//$parameters['legend'] = $id; 


view_details_v2($parameters);




break;

//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
case "add_template":

if(isset($type) && $type=="edit"){
$edit="1";
$lead_id=$id;
}
else{
$edit="0";
$lead_id="0";
}

$dropdowns=array(


);



$dropdowns2=array(
);

$mask1="'mask': '(999)-(9999999)'";
$mask2="'alias': 'numeric','digits': 2,'digitsOptional': false, 'placeholder': '0'";

$textfields=array(

array(
'label'=>'Template Title',
'fname'=>sub_table_title,
'class'=>'col-md-12',
'encoding'=>'0',
'format'=>'words',
'masking'=>'off',
'required'=>'1'),

);


$integerfields=array(
);


$wysiwygfields=array(
array(
'label'=>'Content','height'=>"112",
'fname'=>sub_table_url8,
'toolbar'=>"all",
'placeholder'=>'
<table class="table"><tbody><tr><td><p><b>BRAND DESIGN / IDENTITY DESIGN</b></p><ul><li>LOGO / INSIGNIA DESIGN</li><li>COLOR THEME</li><li>3 Concepts , 3 Revisions&nbsp;<br></li></ul></td><td style="text-align: center; "><p><br></p><p>PKR 84,000*</p></td></tr><tr><td><p>1 Month Validity</p></td><td style="text-align: center; "><p>.</p></td></tr></tbody></table>',
'required'=>'1'));

$wysiwygfields_choice=array(


);



$checkboxfields=array(
);


$timepickfields=array(
);

$directfields=array(
array(
'fname'=>'sub_url4',
'value'=>$user_id
)

);


$update_settings=array(
'update_flag'=>"Lead Edited",
'update_ref'=>"ims_update",
'update_email'=>0
);



$edit=array(
'edit'=>$edit,
'lead_id'=>$lead_id,
'e_ref'=>routine_template_alias,
'table'=>main_table
);


$values=array(
'texts'=>$textfields,
'integers'=>$integerfields,
'dropdowns'=>$dropdowns,
'dropdowns2'=>$dropdowns2,
'checkboxes'=>$checkboxfields,
'timepicks'=>$timepickfields,
'wysiwygs'=>$wysiwygfields,
'wysiwygs_choice'=>$wysiwygfields_choice,
'directfields'=>$directfields,
'update_settings'=>$update_settings,
'datedfield'=>dated,
'dated_table'=>main_table,
'prefix'=>'APP-',
'redirect'=>"/list/templates/",
'form_table'=>sub_table2,
'form_heading'=>"Entry",
'alias'=>"template_type"
);

make_form($values,1,$edit);
break;
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_

//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_

default;

echo "<h2>i2d App Builder Service Views Does not Exist!</h2>";

}

/////////////////////////////////////////////////////////////////////////////
include_once"../includes/app_bottom.php";


?>