diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/CallRelatedList.php b/oss/vtiger/trunk/modules/PurchaseOrder/CallRelatedList.php
new file mode 100644
index 00000000..7be43571
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/CallRelatedList.php
@@ -0,0 +1,81 @@
+retrieve_entity_info($RECORD,$currentmodule);
+ $focus->id = $RECORD;
+ $focus->name=$focus->column_fields['subject'];
+ $log->debug("id is ".$focus->id);
+ $log->debug("name is ".$focus->name);
+ }
+
+ global $mod_strings,$currentModule;
+ global $app_strings;
+ global $theme;
+ $theme_path="themes/".$theme."/";
+ $image_path=$theme_path."images/";
+
+ $smarty = new vtigerCRM_Smarty;
+
+ if (isset($focus->name)) $smarty->assign("NAME", $focus->name);
+ $related_array=getRelatedLists($currentModule,$focus);
+ $smarty->assign("RELATEDLISTS", $related_array);
+
+ require_once('include/ListView/RelatedListViewSession.php');
+ if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) {
+ $relationId = vtlib_purify($_REQUEST['relation_id']);
+ RelatedListViewSession::addRelatedModuleToSession($relationId,
+ vtlib_purify($_REQUEST['selected_header']));
+ }
+ $open_related_modules = RelatedListViewSession::getRelatedModulesFromSession();
+ $smarty->assign("SELECTEDHEADERS", $open_related_modules);
+
+ $smarty->assign("CATEGORY",$category);
+ if(isset($_REQUEST['mode']) && $_REQUEST['mode'] != ' ') {
+ $smarty->assign("OP_MODE",vtlib_purify($_REQUEST['mode']));
+ }
+ $smarty->assign("TODO_PERMISSION",CheckFieldPermission('parent_id','Calendar'));
+ $smarty->assign("EVENT_PERMISSION",CheckFieldPermission('parent_id','Events'));
+ $smarty->assign("ID",$focus->id);
+
+ // Module Sequence Numbering
+ $mod_seq_field = getModuleSequenceField($currentModule);
+ if ($mod_seq_field != null) {
+ $mod_seq_id = $focus->column_fields[$mod_seq_field['name']];
+ } else {
+ $mod_seq_id = $focus->id;
+ }
+ $smarty->assign('MOD_SEQ_ID', $mod_seq_id);
+ // END
+
+ $smarty->assign("MODULE",$currentmodule);
+ $smarty->assign("SINGLE_MOD",$mod_strings['PurchaseOrder']);
+ $smarty->assign("UPDATEINFO",updateInfo($focus->id));
+ $smarty->assign("MOD",$mod_strings);
+ $smarty->assign("APP",$app_strings);
+ $smarty->assign("THEME", $theme);
+ $smarty->assign("IMAGE_PATH", $image_path);
+
+ $check_button = Button_Check($module);
+ $smarty->assign("CHECK", $check_button);
+ $smarty->display("RelatedLists.tpl");
+}
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/CreatePDF.php b/oss/vtiger/trunk/modules/PurchaseOrder/CreatePDF.php
new file mode 100644
index 00000000..ebef95d4
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/CreatePDF.php
@@ -0,0 +1,18 @@
+loadRecord(vtlib_purify($_REQUEST['record']));
+
+$controller->Output('PurchaseOrder.pdf', 'D');//added file name to make it work in IE, also forces the download giving the user the option to save
+exit();
+?>
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/CustomView.php b/oss/vtiger/trunk/modules/PurchaseOrder/CustomView.php
new file mode 100644
index 00000000..93231ed6
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/CustomView.php
@@ -0,0 +1,14 @@
+
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/Delete.php b/oss/vtiger/trunk/modules/PurchaseOrder/Delete.php
new file mode 100644
index 00000000..f9294af9
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/Delete.php
@@ -0,0 +1,38 @@
+
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/DetailView.php b/oss/vtiger/trunk/modules/PurchaseOrder/DetailView.php
new file mode 100644
index 00000000..e9c1b9ce
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/DetailView.php
@@ -0,0 +1,142 @@
+retrieve_entity_info($_REQUEST['record'],"PurchaseOrder");
+ $focus->id = $_REQUEST['record'];
+ $focus->name=$focus->column_fields['subject'];
+}
+
+if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
+ $focus->id = "";
+}
+
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+
+$log->info("Order detail view");
+
+$smarty = new vtigerCRM_Smarty;
+
+$smarty->assign("MOD", $mod_strings);
+$smarty->assign("APP", $app_strings);
+
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", $image_path);
+$smarty->assign("MODULE",$currentModule);
+$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
+if (isset($focus->name)) $smarty->assign("NAME", $focus->name);
+else $smarty->assign("NAME", "");
+
+$smarty->assign("BLOCKS", getBlocks($currentModule,"detail_view",'',$focus->column_fields));
+$smarty->assign("UPDATEINFO",updateInfo($focus->id));
+
+$smarty->assign("CUSTOMFIELD", $cust_fld);
+$smarty->assign("ID", vtlib_purify($_REQUEST['record']));
+
+// Module Sequence Numbering
+$mod_seq_field = getModuleSequenceField($currentModule);
+if ($mod_seq_field != null) {
+ $mod_seq_id = $focus->column_fields[$mod_seq_field['name']];
+} else {
+ $mod_seq_id = $focus->id;
+}
+$smarty->assign('MOD_SEQ_ID', $mod_seq_id);
+// END
+
+$smarty->assign("SINGLE_MOD", 'PurchaseOrder');
+$category = getParentTab();
+$smarty->assign("CATEGORY",$category);
+
+if(isPermitted("PurchaseOrder","EditView",$_REQUEST['record']) == 'yes')
+ $smarty->assign("EDIT_DUPLICATE","permitted");
+
+$smarty->assign("CREATEPDF","permitted");
+
+if(isPermitted("PurchaseOrder","Delete",$_REQUEST['record']) == 'yes')
+ $smarty->assign("DELETE","permitted");
+
+
+//Get the associated Products and then display above Terms and Conditions
+$smarty->assign("ASSOCIATED_PRODUCTS",getDetailAssociatedProducts('PurchaseOrder',$focus));
+
+ $tabid = getTabid("PurchaseOrder");
+ $validationData = getDBValidationData($focus->tab_name,$tabid);
+ $data = split_validationdataArray($validationData);
+
+ $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
+ $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
+ $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
+
+$check_button = Button_Check($module);
+$smarty->assign("CHECK", $check_button);
+$smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST['record']));
+$smarty->assign("TODO_PERMISSION",CheckFieldPermission('parent_id','Calendar'));
+$smarty->assign("EVENT_PERMISSION",CheckFieldPermission('parent_id','Events'));
+
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
+
+if($singlepane_view == 'true')
+{
+ $related_array = getRelatedLists($currentModule,$focus);
+ $smarty->assign("RELATEDLISTS", $related_array);
+
+ require_once('include/ListView/RelatedListViewSession.php');
+ if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) {
+ RelatedListViewSession::addRelatedModuleToSession(vtlib_purify($_REQUEST['relation_id']),
+ vtlib_purify($_REQUEST['selected_header']));
+ }
+ $open_related_modules = RelatedListViewSession::getRelatedModulesFromSession();
+ $smarty->assign("SELECTEDHEADERS", $open_related_modules);
+}
+
+$smarty->assign("SinglePane_View", $singlepane_view);
+
+if(PerformancePrefs::getBoolean('DETAILVIEW_RECORD_NAVIGATION', true) && isset($_SESSION[$currentModule.'_listquery'])){
+ $recordNavigationInfo = ListViewSession::getListViewNavigation($focus->id);
+ VT_detailViewNavigation($smarty,$recordNavigationInfo,$focus->id);
+}
+
+// Record Change Notification
+$focus->markAsViewed($current_user->id);
+// END
+
+// Gather the custom link information to display
+include_once('vtlib/Vtiger/Link.php');
+$customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action']));
+$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params));
+// END
+
+$smarty->assign('DETAILVIEW_AJAX_EDIT', PerformancePrefs::getBoolean('DETAILVIEW_AJAX_EDIT', true));
+
+$smarty->display("Inventory/InventoryDetailView.tpl");
+
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/DetailViewAjax.php b/oss/vtiger/trunk/modules/PurchaseOrder/DetailViewAjax.php
new file mode 100644
index 00000000..3b5df873
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/DetailViewAjax.php
@@ -0,0 +1,55 @@
+retrieve_entity_info($crmid,"PurchaseOrder");
+
+ //Added code for auto product stock updation on receiving goods
+ $prev_postatus = $modObj->column_fields['postatus'];
+ if($fieldname == 'postatus' && $prev_postatus != $fieldvalue && $fieldvalue == 'Received Shipment')
+ {
+ $modObj->update_prod_stock = 'true';
+ }
+
+ $modObj->column_fields[$fieldname] = $fieldvalue;
+ $modObj->id = $crmid;
+ $modObj->mode = "edit";
+ $modObj->save("PurchaseOrder");
+ if($modObj->id != "")
+ {
+ echo ":#:SUCCESS";
+ }else
+ {
+ echo ":#:FAILURE";
+ }
+ }else
+ {
+ echo ":#:FAILURE";
+ }
+} elseif($ajaxaction == "LOADRELATEDLIST" || $ajaxaction == "DISABLEMODULE"){
+ require_once 'include/ListView/RelatedListViewContents.php';
+}
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/EditView.php b/oss/vtiger/trunk/modules/PurchaseOrder/EditView.php
new file mode 100644
index 00000000..6b288805
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/EditView.php
@@ -0,0 +1,254 @@
+assign("SEARCH", $searchurl);
+//4600 ends
+
+global $current_user;
+$currencyid=fetchCurrency($current_user->id);
+$rate_symbol = getCurrencySymbolandCRate($currencyid);
+$rate = $rate_symbol['rate'];
+if(isset($_REQUEST['record']) && $_REQUEST['record'] != '')
+{
+ $focus->id = $_REQUEST['record'];
+ $focus->mode = 'edit';
+ $focus->retrieve_entity_info($_REQUEST['record'],"PurchaseOrder");
+ $focus->name=$focus->column_fields['subject'];
+}
+if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
+ $smarty->assign("DUPLICATE_FROM", $focus->id);
+ $PO_associated_prod = getAssociatedProducts("PurchaseOrder",$focus);
+ $focus->id = "";
+ $focus->mode = '';
+}
+if(empty($_REQUEST['record']) && $focus->mode != 'edit'){
+ setObjectValuesFromRequest($focus);
+}
+if(isset($_REQUEST['product_id']) && $_REQUEST['product_id'] !='')
+{
+ $focus->column_fields['product_id'] = $_REQUEST['product_id'];
+ $log->debug("Purchase Order EditView: Product Id from the request is ".$_REQUEST['product_id']);
+ $associated_prod = getAssociatedProducts("Products",$focus,$focus->column_fields['product_id']);
+ for ($i=1; $i<=count($associated_prod);$i++) {
+ $associated_prod_id = $associated_prod[$i]['hdnProductId'.$i];
+ $associated_prod_prices = getPricesForProducts($currencyid,array($associated_prod_id),'Products');
+ $associated_prod[$i]['listPrice'.$i] = $associated_prod_prices[$associated_prod_id];
+ }
+ $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
+ $smarty->assign("AVAILABLE_PRODUCTS", 'true');
+}
+if(!empty($_REQUEST['parent_id']) && !empty($_REQUEST['return_module']))
+{
+ if ($_REQUEST['return_module'] == 'Services') {
+ $focus->column_fields['product_id'] = $_REQUEST['parent_id'];
+ $log->debug("Service Id from the request is ".$_REQUEST['parent_id']);
+ $associated_prod = getAssociatedProducts("Services",$focus,$focus->column_fields['product_id']);
+ for ($i=1; $i<=count($associated_prod);$i++) {
+ $associated_prod_id = $associated_prod[$i]['hdnProductId'.$i];
+ $associated_prod_prices = getPricesForProducts($currencyid,array($associated_prod_id),'Services');
+ $associated_prod[$i]['listPrice'.$i] = $associated_prod_prices[$associated_prod_id];
+ }
+ $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
+ $smarty->assign("AVAILABLE_PRODUCTS", 'true');
+ }
+}
+
+// Get vtiger_vendor address if vtiger_vendorid is given
+if(isset($_REQUEST['vendor_id']) && $_REQUEST['vendor_id']!='' && $_REQUEST['record']==''){
+ require_once('modules/Vendors/Vendors.php');
+ $vend_focus = new Vendors();
+
+ $vend_focus->retrieve_entity_info($_REQUEST['vendor_id'],"Vendors");
+ $focus->column_fields['bill_city']=$vend_focus->column_fields['city'];
+ $focus->column_fields['ship_city']=$vend_focus->column_fields['city'];
+ $focus->column_fields['bill_street']=$vend_focus->column_fields['street'];
+ $focus->column_fields['ship_street']=$vend_focus->column_fields['street'];
+ $focus->column_fields['bill_state']=$vend_focus->column_fields['state'];
+ $focus->column_fields['ship_state']=$vend_focus->column_fields['state'];
+ $focus->column_fields['bill_code']=$vend_focus->column_fields['postalcode'];
+ $focus->column_fields['ship_code']=$vend_focus->column_fields['postalcode'];
+ $focus->column_fields['bill_country']=$vend_focus->column_fields['country'];
+ $focus->column_fields['ship_country']=$vend_focus->column_fields['country'];
+ $focus->column_fields['bill_pobox']=$vend_focus->column_fields['pobox'];
+ $focus->column_fields['ship_pobox']=$vend_focus->column_fields['pobox'];
+}
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+
+$disp_view = getView($focus->mode);
+$mode = $focus->mode;
+if($disp_view == 'edit_view')
+ $smarty->assign("BLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields));
+else
+{
+ $bas_block = getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'BAS');
+ $adv_block = getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'ADV');
+
+ $blocks['basicTab'] = $bas_block;
+ if(is_array($adv_block ))
+ $blocks['moreTab'] = $adv_block;
+
+ $smarty->assign("BLOCKS",$blocks);
+ $smarty->assign("BLOCKS_COUNT",count($blocks));
+}
+$smarty->assign("OP_MODE",$disp_view);
+
+$smarty->assign("MODULE",$currentModule);
+$smarty->assign("SINGLE_MOD",'PurchaseOrder');
+$category = getParentTab();
+$smarty->assign("CATEGORY",$category);
+
+
+$smarty->assign("MOD", $mod_strings);
+$smarty->assign("APP", $app_strings);
+
+$log->info("Order view");
+
+if (isset($focus->name)) $smarty->assign("NAME", $focus->name);
+else $smarty->assign("NAME", "");
+
+if($focus->mode == 'edit')
+{
+ $smarty->assign("UPDATEINFO",updateInfo($focus->id));
+ $associated_prod = getAssociatedProducts("PurchaseOrder",$focus);
+ $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
+ $smarty->assign("MODE", $focus->mode);
+}
+elseif(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true')
+{
+ $smarty->assign("ASSOCIATEDPRODUCTS", $PO_associated_prod);
+ $smarty->assign("AVAILABLE_PRODUCTS", 'true');
+ $smarty->assign("MODE", $focus->mode);
+
+}
+elseif((isset($_REQUEST['product_id']) && $_REQUEST['product_id'] != '')) {
+ $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
+ $InvTotal = getInventoryTotal($_REQUEST['return_module'],$_REQUEST['return_id']);
+ $smarty->assign("MODE", $focus->mode);
+
+ //this is to display the Product Details in first row when we create new PO from Product relatedlist
+ if($_REQUEST['return_module'] == 'Products')
+ {
+ $smarty->assign("PRODUCT_ID",vtlib_purify($_REQUEST['product_id']));
+ $smarty->assign("PRODUCT_NAME",getProductName($_REQUEST['product_id']));
+ $smarty->assign("UNIT_PRICE",vtlib_purify($_REQUEST['product_id']));
+ $smarty->assign("QTY_IN_STOCK",getPrdQtyInStck($_REQUEST['product_id']));
+ $smarty->assign("VAT_TAX",getProductTaxPercentage("VAT",$_REQUEST['product_id']));
+ $smarty->assign("SALES_TAX",getProductTaxPercentage("Sales",$_REQUEST['product_id']));
+ $smarty->assign("SERVICE_TAX",getProductTaxPercentage("Service",$_REQUEST['product_id']));
+ }
+}
+
+
+if(isset($cust_fld))
+{
+ $smarty->assign("CUSTOMFIELD", $cust_fld);
+}
+
+
+
+if(isset($_REQUEST['return_module'])) $smarty->assign("RETURN_MODULE", vtlib_purify($_REQUEST['return_module']));
+else $smarty->assign("RETURN_MODULE","PurchaseOrder");
+if(isset($_REQUEST['return_action'])) $smarty->assign("RETURN_ACTION", vtlib_purify($_REQUEST['return_action']));
+if(isset($_REQUEST['return_id'])) $smarty->assign("RETURN_ID", vtlib_purify($_REQUEST['return_id']));
+if (isset($_REQUEST['return_viewname'])) $smarty->assign("RETURN_VIEWNAME", vtlib_purify($_REQUEST['return_viewname']));
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", $image_path);
+$smarty->assign("MODULE","PurchaseOrder");
+$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
+$smarty->assign("ID", $focus->id);
+
+
+$smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']);
+$smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
+
+//if create PO, get all available product taxes and shipping & Handling taxes
+if($focus->mode != 'edit')
+{
+ $tax_details = getAllTaxes('available');
+ $sh_tax_details = getAllTaxes('available','sh');
+}
+else
+{
+ $tax_details = getAllTaxes('available','',$focus->mode,$focus->id);
+ $sh_tax_details = getAllTaxes('available','sh','edit',$focus->id);
+}
+$smarty->assign("GROUP_TAXES",$tax_details);
+$smarty->assign("SH_TAXES",$sh_tax_details);
+
+
+
+ $tabid = getTabid("PurchaseOrder");
+ $validationData = getDBValidationData($focus->tab_name,$tabid);
+ $data = split_validationdataArray($validationData);
+
+ $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
+ $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
+ $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
+
+$check_button = Button_Check($module);
+$smarty->assign("CHECK", $check_button);
+$smarty->assign("DUPLICATE",vtlib_purify($_REQUEST['isDuplicate']));
+
+global $adb;
+// Module Sequence Numbering
+$mod_seq_field = getModuleSequenceField($currentModule);
+if($focus->mode != 'edit' && $mod_seq_field != null) {
+ $autostr = getTranslatedString('MSG_AUTO_GEN_ON_SAVE');
+ $mod_seq_string = $adb->pquery("SELECT prefix, cur_id from vtiger_modentity_num where semodule = ? and active=1",array($currentModule));
+ $mod_seq_prefix = $adb->query_result($mod_seq_string,0,'prefix');
+ $mod_seq_no = $adb->query_result($mod_seq_string,0,'cur_id');
+ if($adb->num_rows($mod_seq_string) == 0 || $focus->checkModuleSeqNumber($focus->table_name, $mod_seq_field['column'], $mod_seq_prefix.$mod_seq_no))
+ echo '
'. getTranslatedString('LBL_DUPLICATE'). ' '. getTranslatedString($mod_seq_field['label'])
+ .' - '. getTranslatedString('LBL_CLICK') .' '.getTranslatedString('LBL_HERE').' '
+ . getTranslatedString('LBL_TO_CONFIGURE'). ' '. getTranslatedString($mod_seq_field['label']) .'';
+ else
+ $smarty->assign("MOD_SEQ_ID",$autostr);
+} else {
+ $smarty->assign("MOD_SEQ_ID", $focus->column_fields[$mod_seq_field['name']]);
+}
+// END
+
+$smarty->assign("CURRENCIES_LIST", getAllCurrencies());
+if($focus->mode == 'edit' || $_REQUEST['isDuplicate'] == 'true') {
+ $inventory_cur_info = getInventoryCurrencyInfo('PurchaseOrder', $focus->id);
+ $smarty->assign("INV_CURRENCY_ID", $inventory_cur_info['currency_id']);
+} else {
+ $smarty->assign("INV_CURRENCY_ID", $currencyid);
+}
+
+if($focus->mode == 'edit')
+ $smarty->display('Inventory/InventoryEditView.tpl');
+else
+ $smarty->display('Inventory/InventoryCreateView.tpl');
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/ListTopPurchaseOrder.php b/oss/vtiger/trunk/modules/PurchaseOrder/ListTopPurchaseOrder.php
new file mode 100644
index 00000000..ec33c104
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/ListTopPurchaseOrder.php
@@ -0,0 +1,169 @@
+$title,'Header'=>$listview_header,'Entries'=>$listview_entries) where as listview_header and listview_entries are arrays of header and entity values which are returned from function getListViewHeader and getListViewEntries
+ */
+function getTopPurchaseOrder($maxval,$calCnt)
+{
+ require_once("data/Tracker.php");
+ require_once('modules/PurchaseOrder/PurchaseOrder.php');
+ require_once('include/logging.php');
+ require_once('include/ListView/ListView.php');
+ require_once('include/utils/utils.php');
+ require_once('modules/CustomView/CustomView.php');
+
+ global $current_language,$current_user,$list_max_entries_per_page,$theme,$adb;
+ $current_module_strings = return_module_language($current_language, 'PurchaseOrder');
+
+ $log = LoggerManager::getLogger('po_list');
+
+ $url_string = '';
+ $sorder = '';
+ $oCustomView = new CustomView("PurchaseOrder");
+ $customviewcombo_html = $oCustomView->getCustomViewCombo();
+ if(isset($_REQUEST['viewname']) == false || $_REQUEST['viewname']=='')
+ {
+ if($oCustomView->setdefaultviewid != "")
+ {
+ $viewid = $oCustomView->setdefaultviewid;
+ }else
+ {
+ $viewid = "0";
+ }
+ }
+
+ $theme_path="themes/".$theme."/";
+ $image_path=$theme_path."images/";
+
+ //Retreive the list from Database
+ //<<<<<<<<>>>>>>>>
+ $date_var = date('Y-m-d');
+ $currentModule = 'PurchaseOrder';
+ $viewId = getCvIdOfAll($currentModule);
+ $queryGenerator = new QueryGenerator($currentModule, $current_user);
+ $queryGenerator->initForCustomViewById($viewId);
+ $meta = $queryGenerator->getMeta($currentModule);
+ $accessibleFieldNameList = array_keys($meta->getModuleFields());
+ $customViewFields = $queryGenerator->getCustomViewFields();
+ $fields = $queryGenerator->getFields();
+ $newFields = array_diff($fields, $customViewFields);
+ $widgetFieldsList = array('subject','vendor_id','contact_id','total');
+ $widgetFieldsList = array_intersect($accessibleFieldNameList, $widgetFieldsList);
+ $widgetSelectedFields = array_chunk(array_intersect($customViewFields, $widgetFieldsList), 2);
+ //select the first chunk of two fields
+ $widgetSelectedFields = $widgetSelectedFields[0];
+ if(count($widgetSelectedFields) < 2) {
+ $widgetSelectedFields = array_chunk(array_merge($widgetSelectedFields, $accessibleFieldNameList), 2);
+ //select the first chunk of two fields
+ $widgetSelectedFields = $widgetSelectedFields[0];
+ }
+ $newFields = array_merge($newFields, $widgetSelectedFields);
+ $queryGenerator->setFields($newFields);
+ $_REQUEST = getTopPurchaseOrderSearch($_REQUEST, array(
+ 'assigned_user_id'=>$current_user->column_fields['user_name'],
+ 'duedate'=>$date_var));
+ $queryGenerator->addUserSearchConditions($_REQUEST);
+ $search_qry = '&query=true'.getSearchURL($_REQUEST);
+ $query = $queryGenerator->getQuery();
+
+ //<<<<<<<>>>>>>>>
+
+ $query .= " LIMIT " . $adb->sql_escape_string($maxval);
+
+ if($calCnt == 'calculateCnt') {
+ $list_result_rows = $adb->query(mkCountQuery($query));
+ return $adb->query_result($list_result_rows, 0, 'count');
+ }
+
+ $list_result = $adb->query($query);
+
+ //Retreiving the no of rows
+ $noofrows = $adb->num_rows($list_result);
+
+ //Retreiving the start value from request
+ if(isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
+ $start = vtlib_purify($_REQUEST['start']);
+ } else {
+ $start = 1;
+ }
+
+ //Retreive the Navigation array
+ $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
+
+ if ($navigation_array['start'] == 1)
+ {
+ if($noofrows != 0)
+ $start_rec = $navigation_array['start'];
+ else
+ $start_rec = 0;
+ if($noofrows > $list_max_entries_per_page)
+ {
+ $end_rec = $navigation_array['start'] + $list_max_entries_per_page - 1;
+ }
+ else
+ {
+ $end_rec = $noofrows;
+ }
+
+ }
+ else
+ {
+ if($navigation_array['next'] > $list_max_entries_per_page)
+ {
+ $start_rec = $navigation_array['next'] - $list_max_entries_per_page;
+ $end_rec = $navigation_array['next'] - 1;
+ }
+ else
+ {
+ $start_rec = $navigation_array['prev'] + $list_max_entries_per_page;
+ $end_rec = $noofrows;
+ }
+ }
+
+ $focus = new PurchaseOrder();
+
+ //Retreive the List View Table Header
+ $title=array('myTopPurchaseOrders.gif',$current_module_strings['LBL_MY_TOP_PO'],'home_mytoppo');
+ $controller = new ListViewController($adb, $current_user, $queryGenerator);
+ $controller->setHeaderSorting(false);
+ $header = $controller->getListViewHeader($focus,$currentModule,$url_string,$sorder,
+ $order_by, true);
+
+ $entries = $controller->getListViewEntries($focus,$currentModule,$list_result,
+ $navigation_array, true);
+
+ $values=Array('ModuleName'=>'PurchaseOrder','Title'=>$title,'Header'=>$header,'Entries'=>$entries,'search_qry'=>$search_qry);
+ if ( ($display_empty_home_blocks && $noofrows == 0 ) || ($noofrows>0) )
+ return $values;
+}
+
+function getTopPurchaseOrderSearch($output, $input) {
+ $output['smodule'] = 'PO';
+ $output['query'] = 'true';
+ $output['Fields0'] = 'assigned_user_id';
+ $output['Condition0'] = 'e';
+ $output['Srch_value0'] = $input['assigned_user_id'];
+ $output['Fields1'] = 'duedate';
+ $output['Condition1'] = 'h';
+ $output['Srch_value1'] = $input['duedate'];
+ $output['searchtype'] = 'advance';
+ $output['search_cnt'] = '2';
+ $output['matchtype'] = 'all';
+ return $output;
+}
+
+?>
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/ListView.php b/oss/vtiger/trunk/modules/PurchaseOrder/ListView.php
new file mode 100644
index 00000000..dbc3f603
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/ListView.php
@@ -0,0 +1,227 @@
+initSortbyField('PurchaseOrder');
+// END
+$smarty = new vtigerCRM_Smarty;
+$other_text = Array();
+
+if(!$_SESSION['lvs'][$currentModule])
+{
+ unset($_SESSION['lvs']);
+ $modObj = new ListViewSession();
+ $modObj->sorder = $sorder;
+ $modObj->sortby = $order_by;
+ $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
+}
+
+if($_REQUEST['errormsg'] != '')
+{
+ $errormsg = vtlib_purify($_REQUEST['errormsg']);
+ $smarty->assign("ERROR","The User does not have permission to Change/Delete ".$errormsg." ".$currentModule);
+}else
+{
+ $smarty->assign("ERROR","");
+}
+//<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
+$sorder = $focus->getSortOrder();
+$order_by = $focus->getOrderBy();
+
+$_SESSION['PURCHASEORDER_ORDER_BY'] = $order_by;
+$_SESSION['PURCHASEORDER_SORT_ORDER'] = $sorder;
+//<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
+
+//<<<>>>>>>
+$oCustomView = new CustomView("PurchaseOrder");
+$viewid = $oCustomView->getViewId($currentModule);
+$customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
+$viewnamedesc = $oCustomView->getCustomViewByCvid($viewid);
+
+//Added to handle approving or denying status-public by the admin in CustomView
+$statusdetails = $oCustomView->isPermittedChangeStatus($viewnamedesc['status']);
+$smarty->assign("CUSTOMVIEW_PERMISSION",$statusdetails);
+
+//To check if a user is able to edit/delete a customview
+$edit_permit = $oCustomView->isPermittedCustomView($viewid,'EditView',$currentModule);
+$delete_permit = $oCustomView->isPermittedCustomView($viewid,'Delete',$currentModule);
+$smarty->assign("CV_EDIT_PERMIT",$edit_permit);
+$smarty->assign("CV_DELETE_PERMIT",$delete_permit);
+
+//<<<<>>>>
+$smarty->assign("CHANGE_OWNER",getUserslist());
+$smarty->assign("CHANGE_GROUP_OWNER",getGroupslist());
+
+if(isPermitted('PurchaseOrder','Delete','') == 'yes')
+{
+ $other_text['del'] = $app_strings[LBL_MASS_DELETE];
+}
+if(isPermitted('PurchaseOrder','EditView','') == 'yes')
+{
+ $other_text['mass_edit'] = $app_strings[LBL_MASS_EDIT];
+ $other_text['c_owner'] = $app_strings[LBL_CHANGE_OWNER];
+}
+if($viewnamedesc['viewname'] == 'All')
+{
+ $smarty->assign("ALL", 'All');
+}
+
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+$smarty->assign("MOD", $mod_strings);
+$smarty->assign("APP", $app_strings);
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH",$image_path);
+$smarty->assign("MODULE",$currentModule);
+$smarty->assign("SINGLE_MOD",'PurchaseOrder');
+$smarty->assign("CUSTOMVIEW_OPTION",$customviewcombo_html);
+$smarty->assign("VIEWID", $viewid);
+$category = getParentTab();
+$smarty->assign("CATEGORY",$category);
+$smarty->assign("BUTTONS", $other_text);
+$smarty->assign("CUSTOMVIEW", $custom_view_strings);
+//Retreive the list from Database
+//<<<<<<<<>>>>>>>>
+global $current_user;
+$queryGenerator = new QueryGenerator($currentModule, $current_user);
+if ($viewid != "0") {
+ $queryGenerator->initForCustomViewById($viewid);
+} else {
+ $queryGenerator->initForDefaultCustomView();
+}
+//<<<<<<<>>>>>>>>
+
+// Enabling Module Search
+$url_string = '';
+if($_REQUEST['query'] == 'true') {
+ $queryGenerator->addUserSearchConditions($_REQUEST);
+ $ustring = getSearchURL($_REQUEST);
+ $url_string .= "&query=true$ustring";
+ $smarty->assign('SEARCH_URL', $url_string);
+}
+
+$query = $queryGenerator->getQuery();
+
+if(isset($order_by) && $order_by != '')
+{
+ if($order_by == 'smownerid')
+ {
+ if( $adb->dbType == "pgsql")
+ $query .= ' GROUP BY user_name';
+ $query .= ' ORDER BY user_name '.$sorder;
+ }
+ else
+ {
+ $tablename = getTableNameForField('PurchaseOrder',$order_by);
+ $tablename = (($tablename != '')?($tablename."."):'');
+ if( $adb->dbType == "pgsql")
+ $query .= ' GROUP BY '.$tablename.$order_by;
+
+ $query .= ' ORDER BY '.$tablename.$order_by.' '.$sorder;
+ }
+}
+
+//Postgres 8 fixes
+if( $adb->dbType == "pgsql")
+ $query = fixPostgresQuery( $query, $log, 0);
+
+if(PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true){
+ $count_result = $adb->query( mkCountQuery( $query));
+ $noofrows = $adb->query_result($count_result,0,"count");
+}else{
+ $noofrows = null;
+}
+
+$queryMode = (isset($_REQUEST['query']) && $_REQUEST['query'] == 'true');
+$start = ListViewSession::getRequestCurrentPage($currentModule, $query, $viewid, $queryMode);
+
+$navigation_array = VT_getSimpleNavigationValues($start,$list_max_entries_per_page,$noofrows);
+
+$limit_start_rec = ($start-1) * $list_max_entries_per_page;
+
+if( $adb->dbType == "pgsql")
+ $list_result = $adb->pquery($query. " OFFSET $limit_start_rec LIMIT $list_max_entries_per_page", array());
+else
+ $list_result = $adb->pquery($query. " LIMIT $limit_start_rec, $list_max_entries_per_page", array());
+
+$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec,$noofrows);
+$smarty->assign('recordListRange',$recordListRangeMsg);
+
+//Retreive the List View Table Header
+if($viewid !='')
+$url_string .="&viewname=".$viewid;
+
+$controller = new ListViewController($adb, $current_user, $queryGenerator);
+$listview_header = $controller->getListViewHeader($focus,$currentModule,$url_string,$sorder,
+ $order_by);
+$smarty->assign("LISTHEADER", $listview_header);
+
+$listview_header_search = $controller->getBasicSearchFieldInfoList();
+$smarty->assign("SEARCHLISTHEADER",$listview_header_search);
+
+$listview_entries = $controller->getListViewEntries($focus,$currentModule,$list_result,
+ $navigation_array);
+$smarty->assign("LISTENTITY", $listview_entries);
+$smarty->assign("SELECT_SCRIPT", $view_script);
+
+//Added to select Multiple records in multiple pages
+$smarty->assign("SELECTEDIDS", vtlib_purify($_REQUEST['selobjs']));
+$smarty->assign("ALLSELECTEDIDS", vtlib_purify($_REQUEST['allselobjs']));
+$smarty->assign("CURRENT_PAGE_BOXES", implode(array_keys($listview_entries),";"));
+
+$navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string,"PurchaseOrder","index",$viewid);
+$alphabetical = AlphabeticalSearch($currentModule,'index','subject','true','basic',"","","","",$viewid);
+$fieldnames = $controller->getAdvancedSearchOptionString();
+$criteria = getcriteria_options();
+$smarty->assign("CRITERIA", $criteria);
+$smarty->assign("FIELDNAMES", $fieldnames);
+$smarty->assign("ALPHABETICAL", $alphabetical);
+$smarty->assign("NAVIGATION", $navigationOutput);
+
+$check_button = Button_Check($module);
+$smarty->assign("CHECK", $check_button);
+
+ListViewSession::setSessionQuery($currentModule,$query,$viewid);
+
+// Gather the custom link information to display
+include_once('vtlib/Vtiger/Link.php');
+$customlink_params = Array('MODULE'=>$currentModule, 'ACTION'=>vtlib_purify($_REQUEST['action']), 'CATEGORY'=> $category);
+$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('LISTVIEWBASIC','LISTVIEW'), $customlink_params));
+// END
+
+if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
+ $smarty->display("ListViewEntries.tpl");
+else
+ $smarty->display("ListView.tpl");
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/ListViewPagging.php b/oss/vtiger/trunk/modules/PurchaseOrder/ListViewPagging.php
new file mode 100644
index 00000000..333f1768
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/ListViewPagging.php
@@ -0,0 +1,11 @@
+
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/MassEdit.php b/oss/vtiger/trunk/modules/PurchaseOrder/MassEdit.php
new file mode 100644
index 00000000..348dab37
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/MassEdit.php
@@ -0,0 +1,45 @@
+mode = '';
+$mode = 'mass_edit';
+$disp_view = getView($focus->mode);
+
+$smarty = new vtigerCRM_Smarty;
+$smarty->assign("BLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields));
+$smarty->assign("IDS",$_REQUEST['idstring']);
+$smarty->assign("MASS_EDIT","1");
+$smarty->assign("MODULE",$currentModule);
+$smarty->assign("APP",$app_strings);
+$smarty->assign("CATEGORY",getParentTab());
+
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", $image_path);
+
+// Field Validation Information
+$tabid = getTabid($currentModule);
+$validationData = getDBValidationData($focus->tab_name,$tabid);
+$validationArray = split_validationdataArray($validationData);
+
+$smarty->assign("VALIDATION_DATA_FIELDNAME",$validationArray['fieldname']);
+$smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$validationArray['datatype']);
+$smarty->assign("VALIDATION_DATA_FIELDLABEL",$validationArray['fieldlabel']);
+
+$smarty->display('MassEditForm.tpl');
+
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/MassEditSave.php b/oss/vtiger/trunk/modules/PurchaseOrder/MassEditSave.php
new file mode 100644
index 00000000..0e1f2a6f
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/MassEditSave.php
@@ -0,0 +1,67 @@
+retrieve_entity_info($recordid, $currentModule);
+ $focus->mode = 'edit';
+ $focus->id = $recordid;
+ foreach($focus->column_fields as $fieldname => $val)
+ {
+ if(isset($_REQUEST[$fieldname."_mass_edit_check"]))
+ {
+ if($fieldname == 'assigned_user_id'){
+ if($_REQUEST['assigntype'] == 'U') {
+ $value = $_REQUEST['assigned_user_id'];
+ } elseif($_REQUEST['assigntype'] == 'T') {
+ $value = $_REQUEST['assigned_group_id'];
+ }
+ } else {
+ if(is_array($_REQUEST[$fieldname]))
+ $value = $_REQUEST[$fieldname];
+ else
+ $value = trim($_REQUEST[$fieldname]);
+ }
+ $focus->column_fields[$fieldname] = $value;
+ }
+ else{
+ $focus->column_fields[$fieldname] = decode_html($focus->column_fields[$fieldname]);
+ }
+ }
+ $focus->save($currentModule);
+ }
+ }
+}
+
+$parenttab = getParentTab();
+header("Location: index.php?module=$return_module&action=$return_action&parenttab=$parenttab$rstart");
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/Popup.php b/oss/vtiger/trunk/modules/PurchaseOrder/Popup.php
new file mode 100644
index 00000000..18d2d154
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/Popup.php
@@ -0,0 +1,13 @@
+
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/PurchaseOrder.js b/oss/vtiger/trunk/modules/PurchaseOrder/PurchaseOrder.js
new file mode 100644
index 00000000..8d72c9b5
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/PurchaseOrder.js
@@ -0,0 +1,33 @@
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is: vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+ *
+ ********************************************************************************/
+
+document.write("";
+exit();
+?>
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/Settings.php b/oss/vtiger/trunk/modules/PurchaseOrder/Settings.php
new file mode 100644
index 00000000..980dd078
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/Settings.php
@@ -0,0 +1,13 @@
+
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/TagCloud.php b/oss/vtiger/trunk/modules/PurchaseOrder/TagCloud.php
new file mode 100644
index 00000000..859b11ff
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/TagCloud.php
@@ -0,0 +1,12 @@
+
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/UnifiedSearch.php b/oss/vtiger/trunk/modules/PurchaseOrder/UnifiedSearch.php
new file mode 100644
index 00000000..9a37320c
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/UnifiedSearch.php
@@ -0,0 +1,11 @@
+
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/index.php b/oss/vtiger/trunk/modules/PurchaseOrder/index.php
new file mode 100644
index 00000000..f28f3a9b
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/index.php
@@ -0,0 +1,53 @@
+
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/language/en_us.lang.php b/oss/vtiger/trunk/modules/PurchaseOrder/language/en_us.lang.php
new file mode 100644
index 00000000..911742c7
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/language/en_us.lang.php
@@ -0,0 +1,203 @@
+'PurchaseOrder',
+'LBL_RELATED_PRODUCTS'=>'Product Details',
+'LBL_MODULE_TITLE'=>'Purchase Order: Home',
+'LBL_SEARCH_FORM_TITLE'=>'Purchase Order Search',
+'LBL_LIST_FORM_TITLE'=>'Purchase Order List',
+'LBL_NEW_FORM_TITLE'=>'New Purchase Order',
+'LBL_MEMBER_ORG_FORM_TITLE'=>'Member Organizations',
+
+'LBL_LIST_ACCOUNT_NAME'=>'Account Name',
+'LBL_LIST_CITY'=>'City',
+'LBL_LIST_WEBSITE'=>'Website',
+'LBL_LIST_STATE'=>'State',
+'LBL_LIST_PHONE'=>'Phone',
+'LBL_LIST_EMAIL_ADDRESS'=>'Email Address',
+'LBL_LIST_CONTACT_NAME'=>'Contact Name',
+
+//DON'T CONVERT THESE THEY ARE MAPPINGS
+'db_name' => 'LBL_LIST_ACCOUNT_NAME',
+'db_website' => 'LBL_LIST_WEBSITE',
+'db_billing_address_city' => 'LBL_LIST_CITY',
+
+//END DON'T CONVERT
+
+'LBL_ACCOUNT'=>'Account:',
+'LBL_ACCOUNT_NAME'=>'Account Name:',
+'LBL_PHONE'=>'Phone:',
+'LBL_WEBSITE'=>'Website:',
+'LBL_FAX'=>'Fax:',
+'LBL_TICKER_SYMBOL'=>'Ticker Symbol:',
+'LBL_OTHER_PHONE'=>'Other Phone:',
+'LBL_ANY_PHONE'=>'Any Phone:',
+'LBL_MEMBER_OF'=>'Member of:',
+'LBL_EMAIL'=>'Email:',
+'LBL_EMPLOYEES'=>'Employees:',
+'LBL_OTHER_EMAIL_ADDRESS'=>'Other Email:',
+'LBL_ANY_EMAIL'=>'Any Email:',
+'LBL_OWNERSHIP'=>'Ownership:',
+'LBL_RATING'=>'Rating:',
+'LBL_INDUSTRY'=>'Industry:',
+'LBL_SIC_CODE'=>'SIC Code:',
+'LBL_TYPE'=>'Type:',
+'LBL_ANNUAL_REVENUE'=>'Annual Revenue:',
+'LBL_ADDRESS_INFORMATION'=>'Address Information',
+'LBL_Quote_INFORMATION'=>'Account Information',
+'LBL_CUSTOM_INFORMATION'=>'Custom Information',
+'LBL_BILLING_ADDRESS'=>'Billing Address:',
+'LBL_SHIPPING_ADDRESS'=>'Shipping Address:',
+'LBL_ANY_ADDRESS'=>'Any Address:',
+'LBL_CITY'=>'City:',
+'LBL_STATE'=>'State:',
+'LBL_POSTAL_CODE'=>'Postal Code:',
+'LBL_COUNTRY'=>'Country:',
+'LBL_DESCRIPTION_INFORMATION'=>'Description Information',
+'LBL_TERMS_INFORMATION'=>'Terms & Conditions',
+'LBL_DESCRIPTION'=>'Description:',
+'NTC_COPY_BILLING_ADDRESS'=>'Copy billing address to shipping address',
+'NTC_COPY_SHIPPING_ADDRESS'=>'Copy shipping address to billing address',
+'NTC_REMOVE_MEMBER_ORG_CONFIRMATION'=>'Are you sure you want to remove this record as a member organization?',
+'LBL_DUPLICATE'=>'Potential Duplicate Accounts',
+'MSG_DUPLICATE' => 'Creating this vtiger_account may vtiger_potentialy create a duplicate vtiger_account. You may either select an vtiger_account from the list below or you may click on Create New Account to continue creating a new vtiger_account with the previously entered data.',
+
+'LBL_INVITEE'=>'Contacts',
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
+
+'LBL_SELECT_ACCOUNT'=>'Select Account',
+'LBL_GENERAL_INFORMATION'=>'General Information',
+
+//for v4 release added
+'LBL_NEW_POTENTIAL'=>'New Potential',
+'LBL_POTENTIAL_TITLE'=>'Potentials',
+
+'LBL_NEW_TASK'=>'New Task',
+'LBL_TASK_TITLE'=>'Tasks',
+'LBL_NEW_CALL'=>'New Call',
+'LBL_CALL_TITLE'=>'Calls',
+'LBL_NEW_MEETING'=>'New Meeting',
+'LBL_MEETING_TITLE'=>'Meetings',
+'LBL_NEW_EMAIL'=>'New Email',
+'LBL_EMAIL_TITLE'=>'Emails',
+'LBL_NEW_CONTACT'=>'New Contact',
+'LBL_CONTACT_TITLE'=>'Contacts',
+
+//Added vtiger_fields after RC1 - Release
+'LBL_ALL'=>'All',
+'LBL_PROSPECT'=>'Prospect',
+'LBL_INVESTOR'=>'Investor',
+'LBL_RESELLER'=>'Reseller',
+'LBL_PARTNER'=>'Partner',
+
+// Added for 4GA
+'LBL_TOOL_FORM_TITLE'=>'Account Tools',
+//Added for 4GA
+'Subject'=>'Subject',
+'Quote Name'=>'Quote Name',
+'Vendor Name'=>'Vendor Name',
+'Requisition No'=>'Requisition No',
+'Tracking Number'=>'Tracking Number',
+'Contact Name'=>'Contact Name',
+'Due Date'=>'Due Date',
+'Carrier'=>'Carrier',
+'Type'=>'Type',
+'Sales Tax'=>'Sales Tax',
+'Sales Commission'=>'Sales Commission',
+'Excise Duty'=>'Excise Duty',
+'Total'=>'Total',
+'Product Name'=>'Product Name',
+'Assigned To'=>'Assigned To',
+'Billing Address'=>'Billing Address',
+'Shipping Address'=>'Shipping Address',
+'Billing City'=>'Billing City',
+'Billing State'=>'Billing State',
+'Billing Code'=>'Billing Postal Code',
+'Billing Country'=>'Billing Country',
+'Billing Po Box'=>'Billing PO Box',
+'Shipping Po Box'=>'Shipping PO Box',
+'Shipping City'=>'Shipping City',
+'Shipping State'=>'Shipping State',
+'Shipping Code'=>'Shipping Postal Code',
+'Shipping Country'=>'Shipping Country',
+'City'=>'City',
+'State'=>'State',
+'Code'=>'Code',
+'Country'=>'Country',
+'Created Time'=>'Created Time',
+'Modified Time'=>'Modified Time',
+'Description'=>'Description',
+'Potential Name'=>'Potential Name',
+'Customer No'=>'Customer No',
+'Purchase Order'=>'Purchase Order',
+'Vendor Terms'=>'Vendor Terms',
+'Pending'=>'Pending',
+'Account Name'=>'Account Name',
+'Terms & Conditions'=>'Terms & Conditions',
+//Quote Info
+'LBL_PO_INFORMATION'=>'Purchase Order Information',
+'LBL_PO'=>'Purchase Order:',
+
+ //Added for 4.2 GA
+'LBL_SO_FORM_TITLE'=>'Sales',
+'LBL_PO_FORM_TITLE'=>'Purchase',
+'LBL_SUBJECT_TITLE'=>'Subject',
+'LBL_VENDOR_NAME_TITLE'=>'Vendor Name',
+'LBL_TRACKING_NO_TITLE'=>'Tracking No:',
+'LBL_PO_SEARCH_TITLE'=>'Purchase Order Search',
+'LBL_SO_SEARCH_TITLE'=>'Sales Order Search',
+'LBL_QUOTE_NAME_TITLE'=>'Quote Name',
+'Order No'=>'Order No',
+'Status'=>'Status',
+'PurchaseOrder'=>'Purchase Order',
+'LBL_MY_TOP_PO'=>'My Top Open Purchase Orders',
+
+//Added for existing Picklist Entries
+
+'FedEx'=>'FedEx',
+'UPS'=>'UPS',
+'USPS'=>'USPS',
+'DHL'=>'DHL',
+'BlueDart'=>'BlueDart',
+
+'Created'=>'Created',
+'Approved'=>'Approved',
+'Delivered'=>'Delivered',
+'Cancelled'=>'Cancelled',
+'Received Shipment'=>'Received Shipment',
+
+//Added for Reports (5.0.4)
+'Tax Type'=>'Tax Type',
+'Discount Percent'=>'Discount Percent',
+'Discount Amount'=>'Discount Amount',
+'Terms & Conditions'=>'Terms & Conditions',
+'Adjustment'=>'Adjustment',
+'Sub Total'=>'Sub Total',
+'S&H Amount'=>'S&H Amount',
+
+//Added after 5.0.4 GA
+'PurchaseOrder No'=>'PurchaseOrder No',
+
+);
+
+?>
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/language/zh_cn.lang.php b/oss/vtiger/trunk/modules/PurchaseOrder/language/zh_cn.lang.php
new file mode 100644
index 00000000..cc61aeee
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/language/zh_cn.lang.php
@@ -0,0 +1,201 @@
+ '采购订单',
+'LBL_RELATED_PRODUCTS' => '产品细节',
+'LBL_MODULE_TITLE' => '采购订单:首页',
+'LBL_SEARCH_FORM_TITLE' => '搜寻采购订单',
+'LBL_LIST_FORM_TITLE' => '采购订单列表',
+'LBL_NEW_FORM_TITLE' => '新增采购订单',
+'LBL_MEMBER_ORG_FORM_TITLE' => '成员组织',
+
+'LBL_LIST_ACCOUNT_NAME' => '客户名称',
+'LBL_LIST_CITY' => '乡镇市区',
+'LBL_LIST_WEBSITE' => '网站',
+'LBL_LIST_STATE' => '县市',
+'LBL_LIST_PHONE' => '电话',
+'LBL_LIST_EMAIL_ADDRESS' => '电子邮件',
+'LBL_LIST_CONTACT_NAME' => '联络人名称',
+
+//DON'T CONVERT THESE THEY ARE MAPPINGS
+'db_name' => 'LBL_LIST_ACCOUNT_NAME',
+'db_website' => 'LBL_LIST_WEBSITE',
+'db_billing_address_city' => 'LBL_LIST_CITY',
+
+//END DON'T CONVERT
+
+'LBL_ACCOUNT' => '客户:',
+'LBL_ACCOUNT_NAME' => '客户名称:',
+'LBL_PHONE' => '电话:',
+'LBL_WEBSITE' => '网站:',
+'LBL_FAX' => '传真:',
+'LBL_TICKER_SYMBOL' => '传票符号:',
+'LBL_OTHER_PHONE' => '其它电话:',
+'LBL_ANY_PHONE' => '其它电话:',
+'LBL_MEMBER_OF' => '群组:',
+'LBL_EMAIL' => '电子信箱:',
+'LBL_EMPLOYEES' => '员工人数:',
+'LBL_OTHER_EMAIL_ADDRESS' => '其它电子信箱:',
+'LBL_ANY_EMAIL' => '其它电子信箱:',
+'LBL_OWNERSHIP' => '负责人:',
+'LBL_RATING' => '评分:',
+'LBL_INDUSTRY' => '产业别:',
+'LBL_SIC_CODE' => '统一编号:',
+'LBL_TYPE' => '类型:',
+'LBL_ANNUAL_REVENUE' => '年收入:',
+'LBL_ADDRESS_INFORMATION' => '住址信息',
+'LBL_Quote_INFORMATION' => '客户信息',
+'LBL_CUSTOM_INFORMATION' => '自订信息',
+'LBL_BILLING_ADDRESS' => '发票住址:',
+'LBL_SHIPPING_ADDRESS' => '送货住址:',
+'LBL_ANY_ADDRESS' => '其它住址:',
+'LBL_CITY' => '乡镇市区:',
+'LBL_STATE' => '县市:',
+'LBL_POSTAL_CODE' => '邮政编码:',
+'LBL_COUNTRY' => '国家:',
+'LBL_DESCRIPTION_INFORMATION' => '说明信息',
+'LBL_TERMS_INFORMATION' => '期限与条件',
+'LBL_DESCRIPTION' => '说明:',
+'NTC_COPY_BILLING_ADDRESS' => '复制发票地址到送货地址',
+'NTC_COPY_SHIPPING_ADDRESS' => '复制送货地址到送货发票地址',
+'NTC_REMOVE_MEMBER_ORG_CONFIRMATION' => '您确定要删除这笔数据?',
+'LBL_DUPLICATE' => '客户数据重复',
+'MSG_DUPLICATE' => '建立这个客户数据可能与现有数据重复,您可以选择将数据归属于下面其中一个项目中,或是点选建立新客户来透过刚刚输入的数据建立新项目。',
+
+'LBL_INVITEE' => '联络人',
+'ERR_DELETE_RECORD' => '必须指定数据编号才能删除客户。',
+'LBL_SELECT_ACCOUNT' => '选择客户',
+'LBL_GENERAL_INFORMATION' => '一般信息',
+
+//for v4 release added
+'LBL_NEW_POTENTIAL' => '新潜在机会',
+'LBL_POTENTIAL_TITLE' => '潜在机会',
+
+'LBL_NEW_TASK' => '新任务',
+'LBL_TASK_TITLE' => '任务',
+'LBL_NEW_CALL' => ' 安排电话联系',
+'LBL_CALL_TITLE' => '电话联系',
+'LBL_NEW_MEETING' => '新增会议',
+'LBL_MEETING_TITLE' => '会议',
+'LBL_NEW_EMAIL' => '寄发电子邮件',
+'LBL_EMAIL_TITLE' => '电子邮件',
+'LBL_NEW_CONTACT' => '新增联络人',
+'LBL_CONTACT_TITLE' => '联络人',
+
+//Added vtiger_fields after RC1 - Release
+ 'LBL_ALL' => '全部',
+'LBL_PROSPECT' => '预期',
+'LBL_INVESTOR' => '投资者',
+'LBL_RESELLER' => '经销商',
+'LBL_PARTNER' => '合作伙伴',
+
+// Added for 4GA
+ 'LBL_TOOL_FORM_TITLE' => '客户管理工具',
+//Added for 4GA
+ 'Subject' => '主旨',
+'Quote Name' => '报价单名称',
+'Vendor Name' => '厂商名称',
+'Requisition No' => '申请书编号',
+'Tracking Number' => '追踪编号',
+'Contact Name' => '联络人名称',
+'Due Date' => '到期日',
+'Carrier' => '货运商',
+'Type' => '类型',
+'Sales Tax' => '销售税额',
+'Sales Commission' => '销售佣金',
+'Excise Duty' => '货物税',
+'Total' => '总计',
+'Product Name' => '产品名称',
+'Assigned To' => '负责人',
+'Billing Address' => '付款住址',
+'Shipping Address' => '送货住址',
+'Billing City' => '[付款住址]乡镇市区',
+'Billing State' => '[付款住址]县市',
+'Billing Code' => '[付款住址]邮政编码',
+'Billing Country' => '[付款住址]国家',
+'Billing Po Box' => '[付款住址]采购订单信箱',
+'Shipping Po Box' => '[送货住址]采购订单信箱',
+'Shipping City' => '[送货住址]乡镇市区',
+'Shipping State' => '[送货住址]县市',
+'Shipping Code' => '[送货住址]邮政编码',
+'Shipping Country' => '[送货住址]国家',
+'City' => '乡镇市区',
+'State' => '县市',
+'Code' => '邮政编码',
+'Country' => '国家',
+'Created Time' => '建立时间',
+'Modified Time' => '修改时间',
+'Description' => '说明',
+'Potential Name' => '潜在机会名称',
+'Customer No' => '客户编号',
+'Purchase Order' => '采购订单',
+'Vendor Terms' => '厂商条件',
+'Pending' => '等待',
+'Account Name' => '客户名称',
+'Terms & Conditions' => '期限与条件',
+//Quote Info
+'LBL_PO_INFORMATION' => '采购订单信息',
+'LBL_PO' => '采购订单:',
+
+ //Added for 4.2 GA
+'LBL_SO_FORM_TITLE' => '业务',
+'LBL_PO_FORM_TITLE' => '采购',
+'LBL_SUBJECT_TITLE' => '主旨',
+'LBL_VENDOR_NAME_TITLE' => '厂商名称',
+'LBL_TRACKING_NO_TITLE' => '追踪编号',
+'LBL_PO_SEARCH_TITLE' => '搜寻采购订单',
+'LBL_SO_SEARCH_TITLE' => '搜寻销售订单',
+'LBL_QUOTE_NAME_TITLE' => '报价单名称',
+'Order Id' => '订单编号',
+'Status' => '状态',
+'PurchaseOrder' => '采购订单',
+'LBL_MY_TOP_PO' => '进行中的最佳采购订单',
+
+//Added for existing Picklist Entries
+
+'FedEx'=>'FedEx',
+'UPS'=>'UPS',
+'USPS'=>'USPS',
+'DHL'=>'DHL',
+'BlueDart'=>'BlueDart',
+
+'Created' => '建立日期',
+'Approved' => '审核日期',
+'Delivered' => '递送日期',
+'Cancelled' => '取消日期',
+'Received Shipment' => '收件日期',
+
+//Added for Reports (5.0.4)
+'Tax Type'=>'Tax Type',
+'Discount Percent'=>'Discount Percent',
+'Discount Amount'=>'Discount Amount',
+'Terms & Conditions'=>'Terms & Conditions',
+'Adjustment'=>'Adjustment',
+'Sub Total'=>'Sub Total',
+'S&H Amount'=>'S&H Amount',
+
+//Added after 5.0.4 GA
+'PurchaseOrder No'=>'PurchaseOrder No',
+);
+
+?>
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/pdf_templates/footer.php b/oss/vtiger/trunk/modules/PurchaseOrder/pdf_templates/footer.php
new file mode 100644
index 00000000..e5b2b016
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/pdf_templates/footer.php
@@ -0,0 +1,35 @@
+addDescBlock($description, $app_strings["Description"], $descBlock);
+
+/* ************** End Description *********************** */
+
+
+
+/* **************** Begin Terms ****************** */
+$termBlock=array("107",$top,"53", $num);
+$pdf->addDescBlock($conditions, $app_strings["Terms & Conditions"], $termBlock);
+
+/* ************** End Terms *********************** */
+
+
+?>
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/pdf_templates/header.php b/oss/vtiger/trunk/modules/PurchaseOrder/pdf_templates/header.php
new file mode 100644
index 00000000..00186cf4
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/pdf_templates/header.php
@@ -0,0 +1,103 @@
+addImage( $logo_name, $imageBlock);
+
+// x,y,width
+if($org_phone != '')
+ $phone ="\n".$app_strings["Phone"].":".$org_phone;
+$companyBlockPositions=array( "10","23","62" );
+$companyText=$org_address."\n".$org_city.", ".$org_state." ".$org_code." ".$org_country." ".$phone."\n".$org_website;
+$pdf->addTextBlock( $org_name, $companyText ,$companyBlockPositions );
+
+// ************** End company information *******************
+
+
+
+// ************* Begin Top-Right Header ***************
+// title
+$titleBlock=array("147","7");
+$pdf->title( $app_strings["PurchaseOrder"],"", $titleBlock );
+
+$soBubble=array("168","17","12");
+$pdf->addBubbleBlock($reqno, $app_strings["Req. No."], $soBubble);
+
+$poBubble=array("114","17","12");
+$pdf->addBubbleBlock($trno, $app_strings["Tracking No."], $poBubble);
+
+// page number
+$pageBubble=array("147","17",0);
+$pdf->addBubbleBlock($page_num, $app_strings["Page"], $pageBubble);
+// ************** End Top-Right Header *****************
+
+
+
+// ************** Begin Addresses **************
+// shipping Address
+$shipLocation = array("147","40","61");
+if(trim($ship_street)!='')
+ $shipText = $ship_street."\n";
+if(trim($ship_city) !='')
+ $shipText .= $ship_city.", ";
+if(trim($ship_state)!='' || trim($ship_code)!= '')
+ $shipText .= $ship_state." ".$ship_code."\n";
+
+ $shipText .=$ship_country;
+$pdf->addTextBlock( $app_strings["Shipping Address"].":", $shipText, $shipLocation );
+
+// billing Address
+$billPositions = array("10","51","61");
+if(trim($bill_street)!='')
+ $billText = $bill_street."\n";
+if(trim($bill_city) !='')
+ $billText .= $bill_city.", ";
+if(trim($bill_state)!='' || trim($bill_code)!= '')
+ $billText .= $bill_state." ".$bill_code."\n";
+
+ $billText .=$bill_country;
+$pdf->addTextBlock($app_strings["Billing Address"].":",$billText, $billPositions);
+// ********** End Addresses ******************
+
+
+
+/* ******** Begin Invoice Data ************************ */
+// issue date block
+$issueBlock=array("80","37");
+$pdf->addRecBlock(getDisplayDate(date("Y-m-d")), $app_strings["Issue Date"],$issueBlock);
+
+// due date block
+$dueBlock=array("81","52");
+$pdf->addRecBlock($valid_till, $app_strings["Due Date"],$dueBlock);
+
+// terms block
+$termBlock=array("10","67");
+$pdf->addRecBlock($vendor_name, $app_strings["Vendor Name"], $termBlock);
+
+// Contact Name block
+$conBlock=array("79","67");
+$pdf->addRecBlock($contact_name, $app_strings["Contact Name"],$conBlock);
+
+
+// vtiger_invoice number block
+$invBlock=array("145","65");
+$pdf->addRecBlock($po_no, $app_strings["PO Number"],$invBlock);
+
+/* ************ End Invoice Data ************************ */
+
+
+
+?>
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/pdf_templates/lastpage/body.php b/oss/vtiger/trunk/modules/PurchaseOrder/pdf_templates/lastpage/body.php
new file mode 100644
index 00000000..fc4720c1
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/pdf_templates/lastpage/body.php
@@ -0,0 +1,62 @@
+watermark( $app_strings["Thank You"], $waterMarkPositions, $waterMarkRotate );
+$waterMarkPositions=array("30","130");
+$pdf->watermark( $app_strings["For Your Business"], $waterMarkPositions, $waterMarkRotate );
+
+// blowing bubbles
+$Bubble=array("10","80","170","4");
+$pdf->addBubble("", "", $Bubble);
+
+$Bubble=array("168","131","12");
+//$pdf->addBubbleBlock("Neat Look", "For A", $Bubble);
+$Bubble=array("10","131","12");
+//$pdf->addBubbleBlock("The Corners", "Line Up", $Bubble);
+
+
+/* ************* Begin Totals ************************** */
+$totalBlock=array("59","135");
+$names=array($app_strings["Subtotal"],$app_strings["Tax"],$app_strings["Adjustment"],$app_strings["Total"]);
+$totals=array($price_subtotal,$price_salestax,$price_adjustment,$price_total);
+$pdf->addTotalsRec($names,$totals,$totalBlock);
+/* ************* End Totals *************************** */
+
+// lets add an image :)
+$imageBlock=array("15","95","8","8");
+$pdf->addImage( "sale.jpeg", $imageBlock);
+$imageBlock=array("185","95","8","8");
+$pdf->addImage( "sale.jpeg", $imageBlock);
+
+// descriptions that change sizes!
+$descc=count(explode("\n",$description));
+$condc=count(explode("\n",$conditions));
+if( (strlen($description) > 256) || (strlen($conditions) > 256) || $condc >6 || $descc > 6 )
+ $num=255;
+else
+ $num=150;
+
+/* **************** Begin Description ****************** */
+$descBlock=array("10","160","53", $num);
+$pdf->addDescBlock($description, $app_strings["Description"], $descBlock);
+
+
+$termBlock=array("107","160","53", $num);
+$pdf->addDescBlock($conditions, $app_strings["Terms & Conditions"], $termBlock);
+
+/* ************** End Terms *********************** */
+
+
+?>
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/pdf_templates/lastpage/footer.php b/oss/vtiger/trunk/modules/PurchaseOrder/pdf_templates/lastpage/footer.php
new file mode 100644
index 00000000..fbc268a3
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/pdf_templates/lastpage/footer.php
@@ -0,0 +1,60 @@
+drawLine($linePos);
+ $i = (($i+$width)+$pad)-1;
+}
+
+
+// company addy
+if($org_phone != '')
+$phone="\n".$app_strings["Phone"].": ".$org_phone;
+if($org_fax != '')
+ $fax ="\n".$app_strings["Fax"].": ".$org_fax;
+$companyBlockPositions=array( "10","220","60" );
+$companyText=$org_address."\n".$org_city.", ".$org_state." ".$org_code." ".$org_country." ".$phone." ".$fax."\n".$org_website ;
+$pdf->addTextBlock( $org_name, $companyText ,$companyBlockPositions );
+
+
+// billing Address
+$billPositions = array("85","235","60");
+if(trim($bill_street)!='')
+ $billText = $bill_street."\n";
+if(trim($bill_city) !='')
+ $billText .= $bill_city.", ";
+if(trim($bill_state)!='' || trim($bill_code)!= '')
+ $billText .= $bill_state." ".$bill_code."\n";
+
+ $billText .=$bill_country;
+$pdf->addTextBlock($app_strings["Billing Address"].":",$billText, $billPositions);
+
+// totals
+$totalBlock=array("145","235","10", "110");
+$totalText=$app_strings["Subtotal"].": ".$price_subtotal."\n".
+ $app_strings["Tax"].": ".$price_salestax."\n".
+ $app_strings["Adjustment"].": ".$price_adjustment."\n".
+ $app_strings["Total"].": ".$price_total;
+$pdf->addDescBlock($totalText, $app_strings["Total Due"], $totalBlock);
+
+$blurbBlock=array("10","265","150", "60");
+$blockText=$app_strings["Detach_Info"];
+$pdf->addDescBlock($blockText, $app_strings["Instructions"], $blurbBlock);
+
+?>
diff --git a/oss/vtiger/trunk/modules/PurchaseOrder/updateRelations.php b/oss/vtiger/trunk/modules/PurchaseOrder/updateRelations.php
new file mode 100644
index 00000000..b2fe9cbc
--- /dev/null
+++ b/oss/vtiger/trunk/modules/PurchaseOrder/updateRelations.php
@@ -0,0 +1,47 @@
+pquery("insert into vtiger_senotesrel values (?,?)", array($forCRMRecord,$id));
+ else {
+ $focus->save_related_module($currentModule, $forCRMRecord, $dest_mod, $id);
+ }
+ }
+}
+
+header("Location: index.php?action=$action&module=$currentModule&record=".$forCRMRecord."&parenttab=".$parenttab);
+
+?>
\ No newline at end of file