<?php
/*
  $Id: catalog/admin/includes/functions/proforma.php, 20:57:52 NCB Exp $
 	Proforma v1.0 PLUS (Shareware Version)
 	COPYRIGHT (c) 2008 OPEN SOURCE SERVICES. ALL RIGHTS RESERVED.
  Support and Forum at http://www.open-source-services.com/Forum/Proforma-PF-v1.0-PLUS-Shareware-Version-osCommerce/
  Upgrade at http://www.open-source-services.com/Products/OSS-Premium-Add-Ons/Proforma-v1.0-PLUS.html?flypage=0
*/
require(DIR_WS_FUNCTIONS . 'proforma_data_access.php');

function saveEdContent($name, $content) {
	saveUnitContent($name, $content);
}

function getAllUnits(){
	return getAllFormsAndContent();
}

function deleteUnit($name) {
	delUnit($name);
}

function saveSettings($arr_settings){
	saveUnitSettings($arr_settings);
}

function getAllPos(){
	return getAllPositions();
}

function getPosCode($name){
	$code = "<?php require_once(DIR_WS_FUNCTIONS . 'proforma.php'); doProformaContent('" . $name . "'); ?>";
	return $code;
}

function delPos($name){
	deletePosition($name);
}

function saveNewPos($name){
	saveNewPosition($name);
}

function posInUse($pos_name){
	return positionInUse($pos_name);
}

function vsort($array, $id="id", $sort_ascending=true, $is_object_array = false) {
        $temp_array = array();
        while(count($array)>0) {
            $lowest_id = 0;
            $index=0;
            if($is_object_array){
                foreach ($array as $item) {
                    if (isset($item->$id)) {
                                        if ($array[$lowest_id]->$id) {
                        if ($item->$id<$array[$lowest_id]->$id) {
                            $lowest_id = $index;
                        }
                        }
                                    }
                    $index++;
                }
            }else{
                foreach ($array as $item) {
                    if (isset($item[$id])) {
                        if ($array[$lowest_id][$id]) {
                        if ($item[$id]<$array[$lowest_id][$id]) {
                            $lowest_id = $index;
                        }
                        }
                                    }
                    $index++;
                }                             
            }
            $temp_array[] = $array[$lowest_id];
            $array = array_merge(array_slice($array, 0,$lowest_id), array_slice($array, $lowest_id+1));
        }
                if ($sort_ascending) {
            return $temp_array;
                } else {
                    return array_reverse($temp_array);
                }
    }   

function getAllListingFields(){
	return array(TABLE_HEADING_PF_NAME, TABLE_HEADING_PF_GROUP, TABLE_HEADING_PF_POSITION, TABLE_HEADING_PF_PAGES, TABLE_HEADING_PF_PLACEMENT, TABLE_HEADING_PF_TYPE, TABLE_HEADING_PF_ACTIVE);
}

?>