phpBMS

Changeset 515

Show
Ignore:
Timestamp:
05/05/09 12:26:06 (3 years ago)
Author:
nate
Message:
  • removed widget's default import
  • For new tabledefs, the import command is disabled by default
  • Products should now use the general import page.
Location:
trunk/phpbms
Files:
15 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/include/imports.php

    r485 r515  
    1616                var $pageType = "main"; 
    1717 
     18 
    1819                function phpbmsImport($table, $importType = "csv"){ 
    1920 
     
    3132                        //Won't display db errors, just log them. 
    3233                        $this->table->db->showError = false; 
    33                         if(isset($_POST["pageType"])) 
    34                                 $this->pageType = $_POST["pageType"]; 
    35  
    36                         if(isset($_POST["tempFileID"])) 
    37                                 $this->tempFileID = ((int)$_POST["tempFileID"]); 
    3834 
    3935                }//end method --imports-- 
     
    258254                                                        $verify = $this->table->verifyVariables($trimmedRowData); 
    259255                                                        if(!count($verify)) 
    260                                                                 $theid = $this->table->insertRecord($trimmedRowData); 
     256                                                                $theid = $this->table->insertRecord($trimmedRowData, NULL, true); 
    261257                                                }else 
    262258                                                        $this->error .= '<li> incorrect amount of fields for line number '.$rowNum.'.</li>'; 
     
    332328                        $this->table->getTableInfo(); 
    333329 
     330                        if(isset($_POST["pageType"])) 
     331                                $this->pageType = $_POST["pageType"]; 
     332 
     333                        if(isset($_POST["tempFileID"])) 
     334                                $this->tempFileID = ((int)$_POST["tempFileID"]); 
     335 
    334336                        if(!isset($_POST["command"])){ 
    335337 
  • trunk/phpbms/include/session.php

    r485 r515  
    515515                        $error = new appError(-353,"You must remove the install directory and all modules' install directories before phpBMS can run.","Main Install Directory Present",true,true,true,$errorFormat); 
    516516 
    517                 $thedir= @ opendir("modules"); 
    518  
    519                 while($entry = readdir($thedir)){ 
    520  
    521                         if($entry != "." && $entry != ".." && $entry != "base" && $entry != "sample" && is_dir("modules/".$entry)){ 
    522  
    523                                 if(file_exists("modules/".$entry."/install") && is_dir("modules/".$entry."/install")){ 
    524  
    525                                         $error = new appError(-354,"You must remove the install directory and all modules' install directories before phpBMS can run.","Module '".$entry."' Install Directory Present",true,true,true,$errorFormat); 
     517                if(file_exists("modules") && is_dir("modules")){ 
     518 
     519                        $thedir = @ opendir("modules"); 
     520 
     521                        while($entry = readdir($thedir)){ 
     522 
     523                                if($entry != "." && $entry != ".." && $entry != "base" && $entry != "sample" && is_dir("modules/".$entry)){ 
     524 
     525                                        if(file_exists("modules/".$entry."/install") && is_dir("modules/".$entry."/install")){ 
     526 
     527                                                $error = new appError(-354,"You must remove the install directory and all modules' install directories before phpBMS can run.","Module '".$entry."' Install Directory Present",true,true,true,$errorFormat); 
     528 
     529                                        }//endif 
    526530 
    527531                                }//endif 
    528532 
    529                         }//endif 
     533                        }//end while 
    530534 
    531535                }//end if 
  • trunk/phpbms/include/tables.php

    r513 r515  
    345345 
    346346 
    347                 function insertRecord($variables,$createdby = NULL, $overrideID = false){ 
     347                function insertRecord($variables,$createdby = NULL, $overrideID = false, $replace = false){ 
    348348 
    349349                        if($createdby === NULL) 
     
    396396                        $insertvalues = substr($insertvalues, 0, strlen($insertvalues)-2); 
    397397 
    398                         $insertstatement = "INSERT INTO ".$this->maintable." (".$fieldlist.") VALUES (".$insertvalues.")"; 
     398                        if($replace) 
     399                                $insertstatement = "REPLACE"; 
     400                        else 
     401                                $insertstatement = "INSERT"; 
     402 
     403                        $insertstatement .= " INTO ".$this->maintable." (".$fieldlist.") VALUES (".$insertvalues.")"; 
    399404                        $insertresult = $this->db->query($insertstatement); 
    400405 
  • trunk/phpbms/install/tableoptions.sql

    r495 r515  
    8989INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('205', 'printex', '1', '0', '0', '0', '0'); 
    9090INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('205', 'select', '1', '0', '0', '0', '0'); 
    91 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('205', 'import', '1', '0', '0', '-100', '0'); 
  • trunk/phpbms/modules/base/general_import.php

    r485 r515  
    9191        $pageTitle = ($therecord["title"])?$therecord["title"]:"General Table Import"; 
    9292 
    93         // Next, we set up to include any 
    94         // additional css or javascript files we will be using 
    95         //  This does nto include any field-type specific js (like datepicker) 
    96         // as they are automatically icluded when you define the special fields you 
    97         // will be using below. 
    9893        $phpbms->cssIncludes[] = "pages/imports.css"; 
    9994        //$phpbms->jsIncludes[] = "modules/[modulename]/javascript/[tablename].js"; 
    10095 
    101         // if you need to define a body onlload function, do so with the phpbms property 
    102  
    103         //              $phpbms->onload[] = "initializePage()"; 
    104  
    105  
    106         // Next we need to define any special fields that will be used in the form 
    107         // A list of field objects (with documentation)is available in the /include/fields.php 
    108         // file. 
    109  
    110         // We need to define them here in the head 
    111         // so that any necessay javascript is loaded appropriately. 
    11296 
    11397                //Form Elements 
     
    117101                $theform = new importForm(); 
    118102                $theform->enctype = "multipart/form-data"; 
    119                 //if you need to set specific form vaiables (like enctype, or extra onsubmit 
    120                 // you can set those form properties here. 
    121  
    122103 
    123104                // lastly, use the jsMerge method to create the final Javascript formatting 
     
    153134                                </p> 
    154135 
     136 
    155137                                <div id="info0" class="info"> 
    156138                                        <p> 
     
    172154                                                (e.g. use English, US style dates if that is what the bms is configured to). 
    173155                                        </p> 
     156 
    174157                                </div> 
    175158                        </div> 
  • trunk/phpbms/modules/base/include/files.php

    r485 r515  
    135135 
    136136 
    137                 function insertRecord($variables, $createdby = NULL){ 
     137                function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false){ 
    138138 
    139                         $newid = parent::insertRecord($variables, $createdby); 
     139                        $newid = parent::insertRecord($variables, $createdby, $overrideID, $replace); 
    140140 
    141141                        //restore the fields 
  • trunk/phpbms/modules/base/include/notes.php

    r485 r515  
    785785 
    786786 
    787                 function insertRecord($variables, $createdby = NULL){ 
    788  
    789                         $newid = parent::insertRecord($variables, $createdby); 
     787                function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false){ 
     788 
     789                        $newid = parent::insertRecord($variables, $createdby, $overrideID, $replace); 
    790790 
    791791                        if(isset($variables["completed"]) && isset($variables["repeating"])) 
  • trunk/phpbms/modules/base/include/roles.php

    r485 r515  
    3939if(class_exists("phpbmsTable")){ 
    4040        class roles extends phpbmsTable{ 
    41                  
    42                 function updateRecord($variables, $modifiedby = NULL){   
     41 
     42                function updateRecord($variables, $modifiedby = NULL){ 
    4343                        parent::updateRecord($variables, $modifiedby); 
    4444 
     
    4646                                $this->assignUsers($variables["id"],$variables["newusers"]); 
    4747                } 
    48          
    49          
    50                 function insertRecord($variables, $createdby = NULL){    
    51                         $theid = parent::insertRecord($variables, $createdby); 
    52                          
     48 
     49 
     50                function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false){ 
     51                        $theid = parent::insertRecord($variables, $createdby, $overrideID, $replace); 
     52 
    5353                        if(isset($variables["userschanged"])) 
    5454                                if($variables["userschanged"]==1) 
    5555                                        $this->assignUsers($theid,$variables["newusers"]); 
    56                                  
     56 
    5757                        return $theid; 
    5858                } 
    59          
    60          
     59 
     60 
    6161                function assignUsers($id,$users){ 
    6262                        $querystatement="DELETE FROM rolestousers WHERE roleid=".$id; 
    6363                        $queryresult=$this->db->query($querystatement); 
    64          
     64 
    6565                        $newusers=explode(",",$users); 
    66          
     66 
    6767                        foreach($newusers as $theuser) 
    6868                                if($theuser!=""){ 
     
    7171                                } 
    7272                } 
    73          
    74          
     73 
     74 
    7575                function displayUsers($id,$type){ 
    7676                        $querystatement="SELECT users.id,concat(users.firstname,' ',users.lastname) as name 
    77                                                         FROM users INNER JOIN rolestousers ON rolestousers.userid=users.id  
     77                                                        FROM users INNER JOIN rolestousers ON rolestousers.userid=users.id 
    7878                                                        WHERE rolestousers.roleid=".((int) $id); 
    7979                        $assignedquery=$this->db->query($querystatement); 
    80          
     80 
    8181                        $thelist=array(); 
    82                          
     82 
    8383                        if($type=="available"){ 
    8484                                $excludelist=array(); 
    8585                                while($therecord=$this->db->fetchArray($assignedquery)) 
    8686                                        $excludelist[]=$therecord["id"]; 
    87                                          
     87 
    8888                                $querystatement="SELECT id,concat(users.firstname,' ',users.lastname) as name FROM users WHERE revoked=0 AND portalaccess=0"; 
    8989                                $availablequery=$this->db->query($querystatement); 
    90          
     90 
    9191                                while($therecord=$this->db->fetchArray($availablequery)) 
    9292                                        if(!in_array($therecord["id"],$excludelist)) 
    93                                                 $thelist[]=$therecord;           
    94                         } else  
     93                                                $thelist[]=$therecord; 
     94                        } else 
    9595                                while($therecord=$this->db->fetchArray($assignedquery)) 
    9696                                        $thelist[]=$therecord; 
    97                                          
     97 
    9898                        foreach($thelist as $theoption){ 
    9999                                ?>      <option value="<?php echo $theoption["id"]?>"><?php echo htmlQuotes($theoption["name"])?></option> 
    100                 <?php  
     100                <?php 
    101101                        } 
    102102                }//end function 
    103          
     103 
    104104        }//end class 
    105105}//end if 
  • trunk/phpbms/modules/base/include/tabledefs.php

    r510 r515  
    325325 
    326326                        $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`) 
    327                         VALUES (".$newid.",'import','1',0,0,'-100');"; 
     327                        VALUES (".$newid.",'import','0',0,0,'-100');"; 
    328328                        $this->db->query($querystatement); 
    329329 
  • trunk/phpbms/modules/base/include/users.php

    r491 r515  
    147147 
    148148 
    149                 function insertRecord($variables, $createdby = NULL){ 
     149                function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false){ 
    150150 
    151151                        $this->fields["password"]["type"] = "password"; 
    152152                        unset($this->fields["lastlogin"]); 
    153153 
    154                         $theid = parent::insertRecord($variables, $createdby); 
     154                        $theid = parent::insertRecord($variables, $createdby, $overrideID, $replace); 
    155155 
    156156                        //reset field information 
  • trunk/phpbms/modules/bms/clients_import.php

    r485 r515  
    9696                        $thetable = new clients($db,2,$backurl); 
    9797                        $import = new clientsImport($thetable, $importType); 
    98  
    99         //and if you are setting the backurl, make sure you pass that as well 
    100         // like this: 
    101  
    102         //              $thetable = new [tablename]($db,[table definition id],$backurl); 
    103  
    104  
     98                         
    10599        //Next we process the form (if submitted) and 
    106100        // return the current record as an array ($therecord) 
     
    115109        $pageTitle = ($therecord["title"])?$therecord["title"]:"General Table Import"; 
    116110 
    117         // Next, we set up to include any 
    118         // additional css or javascript files we will be using 
    119         //  This does nto include any field-type specific js (like datepicker) 
    120         // as they are automatically icluded when you define the special fields you 
    121         // will be using below. 
    122111        $phpbms->cssIncludes[] = "pages/imports.css"; 
    123112        $phpbms->jsIncludes[] = "modules/bms/javascript/clients_import.js"; 
    124113 
    125         // if you need to define a body onlload function, do so with the phpbms property 
    126  
    127         //              $phpbms->onload[] = "initializePage()"; 
    128  
    129  
    130         // Next we need to define any special fields that will be used in the form 
    131         // A list of field objects (with documentation)is available in the /include/fields.php 
    132         // file. 
    133114 
    134115        // We need to define them here in the head 
     
    154135                $theform->addField($theinput); 
    155136 
    156                 // if you neeed to add additional attributes toa field, it's easy. 
    157                 //$theinput = new inputBasicList("type",$therecord["type"],array("Quote"=>"Quote","Order"=>"Order","Invoice"=>"Invoice","VOID"=>"VOID"), $displayName = NULL, $displayLabel = true); 
    158                 //$theinput->setAttribute("onchange","checkType(this)"); 
    159                 //$theinput->setAttribute("class","important"); 
    160                 //$theform->addField($theinput); 
    161137 
    162138                // lastly, use the jsMerge method to create the final Javascript formatting 
  • trunk/phpbms/modules/bms/include/addresstorecord.php

    r485 r515  
    245245 
    246246 
    247                 function insertRecord($variables, $createdby = NULL){ 
     247                function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false){ 
    248248 
    249249                        //$variables = $this->prepareVariables($variables); 
     
    257257                        } else { 
    258258 
    259                                 $newid = parent::insertRecord($variables, $createdby); 
     259                                $newid = parent::insertRecord($variables, $createdby, $overrideID, $replace); 
    260260 
    261261                                //create the addresstorecord 
  • trunk/phpbms/modules/bms/include/invoices.php

    r503 r515  
    769769 
    770770 
    771                 function insertRecord($variables, $createdby = NULL){ 
     771                function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false){ 
    772772 
    773773                        if($createdby === NULL) 
     
    776776                        //$variables = $this->prepareVariables($variables); 
    777777 
    778                         $newid = parent::insertRecord($variables, $createdby); 
     778                        $newid = parent::insertRecord($variables, $createdby, $overrideID, $replace); 
    779779 
    780780                        if($variables["billingsaveoptions"] != "orderOnly" || $variables["shiptosaveoptions"] != "orderOnly"){ 
  • trunk/phpbms/modules/bms/include/receipts.php

    r501 r515  
    403403 
    404404 
    405                 function insertRecord($variables, $createdby = NULL){ 
    406  
    407                         $newid = parent::insertRecord($variables, $createdby); 
     405                function insertRecord($variables, $createdby = NULL, $overrideID = false, $replace = false){ 
     406 
     407                        $newid = parent::insertRecord($variables, $createdby, $overrideID, $replace); 
    408408 
    409409                        if($variables["itemschanged"]==1){ 
  • trunk/phpbms/modules/bms/install/tabledefs.sql

    r506 r515  
    11INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `canpost`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('2', 'Clients', 'table', '2', 'clients', '((clients INNER JOIN addresstorecord on clients.id = addresstorecord.recordid AND addresstorecord.tabledefid=2 AND addresstorecord.primary=1) INNER JOIN addresses ON  addresstorecord.addressid = addresses.id)', 'modules/bms/clients_addedit.php', '0', 'modules/bms/clients_addedit.php', '0', 'modules/bms/clients_import.php', '-100', '0', '-100', '-100', 'inactivate', '0', 'clients.id=-100', 'clients.company, clients.lastname, clients.firstname', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 
    22INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `canpost`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('3', 'Sales Orders', 'table', '2', 'invoices', '(((invoices INNER JOIN clients ON invoices.clientid=clients.id) INNER JOIN invoicestatuses ON invoices.statusid=invoicestatuses.id) LEFT JOIN paymentmethods ON invoices.paymentmethodid = paymentmethods.id)', 'modules/bms/invoices_addedit.php', '0', 'modules/bms/invoices_addedit.php', '0', NULL, '-100', '0', '-100', '-100', 'void', '1', 'invoices.type+0<3 OR (invoices.type = \'Invoice\' AND invoices.totalti != invoices.amountpaid)', 'invoices.id', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 
    3 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `canpost`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('4', 'Products', 'table', '2', 'products', '(products inner join productcategories on products.categoryid=productcategories.id)', 'modules/bms/products_addedit.php', '0', 'modules/bms/products_addedit.php', '0', 'modules/bms/products_import.php', '-100', '0', '-100', '-100', 'inactivate', '0', 'products.id =-100', 'products.partnumber', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 
     3INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `canpost`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('4', 'Products', 'table', '2', 'products', '(products inner join productcategories on products.categoryid=productcategories.id)', 'modules/bms/products_addedit.php', '0', 'modules/bms/products_addedit.php', '0', '', '-100', '0', '-100', '-100', 'inactivate', '0', 'products.id =-100', 'products.partnumber', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 
    44INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `canpost`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('5', 'Line Items', 'table', '2', 'lineitems', '((lineitems left join products on lineitems.productid=products.id) inner join invoices on lineitems.invoiceid=invoices.id)', 'N/A', '0', 'N/A', '0', NULL, '-100', '0', '-100', '-100', 'NA', '0', 'lineitems.id =-1', 'lineitems.invoiceid,lineitems.id', '', '', '', 1, NOW(), 1, NOW()); 
    55INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `canpost`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('6', 'Tax Areas', 'table', '2', 'tax', 'tax', 'modules/bms/tax_addedit.php', '0', 'modules/bms/tax_addedit.php', '0', NULL, '-100', '0', '-100', '-100', 'inactivate', '0', 'tax.inactive=0', 'tax.name', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 
Scanned by Orvant Copyright © 2010 Kreotek, LLC. All Rights reserved.