phpBMS

Changeset 701 for trunk

Show
Ignore:
Timestamp:
01/01/10 14:34:39 (2 years ago)
Author:
nate
Message:
  • Removed references to 'deposits' and replaced them with references to 'credits' (in relation to ar items and receipts).
  • Made sure that the type field for aritems should be able to take 'credit' but not 'deposit', and the update will change the references from deposit to credit (this time on the database side).
  • Fixed bugs with generateuuids.php and with the load open items button on the receipts add-edit.
Location:
trunk/phpbms
Files:
11 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/install/generateuuids.php

    r698 r701  
    209209            $this->updateFields("invoicestatushistory", array("invoiceid"=>$this->invoiceList, "invoicestatusid"=>$this->invoiceStatsList, "assignedtoid"=>$this->userList)); 
    210210            $this->updateFields("addresstorecord", array("tabledefid"=>$this->tabledefList, "recordid"=>$this->clientList, "addressid"=>$this->addressList)); 
    211             $this->updateFields("receiptitems", array("receiptid"=>$this->recieptList, "aritemid"=>$this->aritemList)); 
    212             $this->updateFields("receipts", array("clientid"=>$this->clientList, "payementmethodid"=>$this->paymentList)); 
     211            $this->updateFields("receiptitems", array("receiptid"=>$this->receiptList, "aritemid"=>$this->aritemList)); 
     212            $this->updateFields("receipts", array("clientid"=>$this->clientList, "paymentmethodid"=>$this->paymentList)); 
    213213            $this->updateFields("aritems", array("clientid"=>$this->clientList)); 
    214214            $this->updateFields("prerequisites", array("parentid"=>$this->productList, "childid"=>$this->productList)); 
  • trunk/phpbms/modules/bms/aritems_view.php

    r643 r701  
    4242        include("modules/bms/include/aritems.php"); 
    4343 
    44         $aritems = new phpbmstable($db,"tbld:c595dbe7-6c77-1e02-5e81-c2e215736e9c"); 
     44        $aritems = new aritems($db,"tbld:c595dbe7-6c77-1e02-5e81-c2e215736e9c"); 
    4545        $therecord = $aritems->processAddEditPage(); 
    4646 
     
    8686                $theform->addField($theinput); 
    8787 
    88                 $theinput = new inputField("relatedid",$therecord["relatedid"],"related record id",true,NULL,14,64); 
     88                $theinput = new inputField("relatedid",$therecord["relatedid"],"related record id",true,NULL,42,64); 
    8989                $theinput->setAttribute("class","uneditable"); 
    9090                $theinput->setAttribute("readonly","readonly"); 
     
    137137                        <p><?php $theform->showField("type"); ?></p> 
    138138 
    139                         <p><?php $theform->showField("relatedid"); ?> <button type="button" title="view related record" class="graphicButtons buttonInfo" id="viewRelatedButton"><span>View Record</span></button></p> 
     139                        <p> 
     140            <input type="hidden" id="editrelatedid" name="editrelatedid" value="<?php echo($therecord["editrelatedid"]); ?>" /> 
     141            <?php $theform->showField("relatedid"); ?> 
     142            <button type="button" title="view related record" class="graphicButtons buttonInfo" id="viewRelatedButton"> 
     143                <span>View Record</span> 
     144            </button> 
     145            </p> 
    140146 
    141147                </fieldset> 
  • trunk/phpbms/modules/bms/include/aritems.php

    r698 r701  
    3737 +-------------------------------------------------------------------------+ 
    3838*/ 
     39 
     40if(class_exists("phpbmsTable")){ 
     41        class aritems extends phpbmsTable{ 
     42                 
     43                function getRecord($id, $useUuid = false){ 
     44                         
     45                        $therecord = parent::getRecord($id, $useUuid); 
     46                         
     47                        /** 
     48                          *   If type is credit, get the receipt id 
     49                          *   else get the invoice id 
     50                          */ 
     51                        if($therecord["type"] == "credit") 
     52                                $therecord["editrelatedid"] = getId($this->db, "tbld:43678406-be25-909b-c715-7e2afc7db601", $therecord["relatedid"]); 
     53                        else 
     54                                $therecord["editrelatedid"] = getId($this->db, "tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883", $therecord["relatedid"]); 
     55                                 
     56                        return $therecord; 
     57                         
     58                }//end function --getRecord-- 
     59                 
     60        }//end class 
     61}//end if 
     62 
    3963class relatedClient{ 
    4064 
     
    119143                "; 
    120144 
    121                         if($this->aritem["type"] == "deposit") 
     145                        if($this->aritem["type"] == "credit") 
    122146                                $querystatement.=" 
    123147                                        AND receipts.uuid != '".mysql_real_escape_string($this->aritem["relatedid"])."'"; 
     
    147171                $this->totals = $this->db->fetchArray($totalresult); 
    148172 
    149                 if($this->aritem["type"] == "deposit") 
     173                if($this->aritem["type"] == "credit") 
    150174                        $this->totals["applied"] = $this->totals["applied"] + $this->aritem["amount"]; 
    151175 
     
    203227                                                                $therecord["name"] = "other"; 
    204228 
    205                                                         if($therecord["id"] == $this->aritem["relatedid"] && $this->aritem["type"] == "deposit") 
     229                                                        if($therecord["id"] == $this->aritem["relatedid"] && $this->aritem["type"] == "credit") 
    206230                                                                $therecord["applied"] = -1 * $therecord["applied"]; 
    207231 
  • trunk/phpbms/modules/bms/include/receipts.php

    r672 r701  
    5555                                        `receiptitems`.`discount`, 
    5656                                        `receiptitems`.`taxadjustment`, 
    57                                         IF(`aritems`.`type` = 'credit', 'deposit', `aritems`.`type`) AS `type`, 
     57                                        `aritems`.`type`, 
    5858                                        `aritems`.`relatedid`, 
    5959                                        `aritems`.`itemdate`, 
     
    9898                                        $dueDate = "&nbsp;"; 
    9999 
    100                                 if($therecord["type"] == "deposit" && $therecord["relatedid"] == $receiptid){ 
     100                                if($therecord["type"] == "credit" && $therecord["relatedid"] == $receiptid){ 
    101101                                        $therecord["relatedid"] = ""; 
    102102                                        $therecord["amount"] = 0; 
     
    149149                        $this->db->query($deletestatement); 
    150150 
    151                         //remove any ar deposits created by ths receipt 
     151                        //remove any ar credits created by ths receipt 
    152152                        $deletestatement = "DELETE FROM aritems WHERE relatedid = '".mysql_real_escape_string($receiptid)."' AND `type` = 'credit'"; 
    153153                        $this->db->query($deletestatement); 
     
    155155                        foreach($itemlist as $itemRecord){ 
    156156 
    157                                 //if no ar uuid, or the deposit is from this record, we need to create the ar item 
    158                                 if(!$itemRecord["aritemid"] || ($itemRecord["relatedid"] == $receiptid && $itemRecord["type"] == "deposit") ){ 
     157                                //if no ar uuid, or the credit is from this record, we need to create the ar item 
     158                                if(!$itemRecord["aritemid"] || ($itemRecord["relatedid"] == $receiptid && $itemRecord["type"] == "credit") ){ 
    159159 
    160160                                        $arrecord = array(); 
     
    638638                                        aritems 
    639639                                WHERE 
    640                                         `type` = 'deposit' 
     640                                        `type` = 'credit' 
    641641                                        AND (".str_replace("uuid", "relatedid", $newWhere).")"; 
    642642 
     
    827827                                                aritems.status, 
    828828                                                aritems.relatedid, 
    829                                                 IF(`aritems`.`type` = 'credit', 'deposit', `aritems`.`type`) AS `type` 
     829                                                `aritems`.`type` 
    830830                                        FROM 
    831831                                                `receiptitems` INNER JOIN `aritems` ON `receiptitems`.`aritemid` = `aritems`.`uuid` 
     
    838838                                while($itemrecord = $this->db->fetchArray($itemsresult)){ 
    839839 
    840                                         if($itemrecord["relatedid"] == $therecord["uuid"] && $itemrecord["type"] == "deposit") 
     840                                        if($itemrecord["relatedid"] == $therecord["uuid"] && $itemrecord["type"] == "credit") 
    841841                                                $paid = $itemrecord["paid"]; 
    842842                                        else 
  • trunk/phpbms/modules/bms/install/updatev0.9.sql

    r485 r701  
    124124UPDATE `invoicestatuses` SET `name`="Shipped", `setreadytopost`=1 WHERE id = 4; 
    125125UPDATE `invoices` SET `readytopost`=1 WHERE `type`="Invoice"; 
    126 CREATE TABLE `aritems` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `clientid` int(10) unsigned NOT NULL, `type` ENUM('invoice','deposit','service charge') NOT NULL, `status` ENUM('open','closed') NOT NULL, `itemdate` DATE NOT NULL, `relatedid` int(10) unsigned default NULL, `amount` double NOT NULL default '0', `paid` double NOT NULL default '0', `aged1` tinyint(3) unsigned NOT NULL default '0', `aged2` tinyint(3) unsigned NOT NULL default '0', `aged3` tinyint(3) unsigned NOT NULL default '0', `title` varchar(255) default NULL, `posted` tinyint(3) unsigned NOT NULL default '0', `createdby` int(10) unsigned NOT NULL, `creationdate` datetime NOT NULL, `modifiedby` int(10) unsigned default NULL, `modifieddate` timestamp NOT NULL, PRIMARY KEY  (`id`)); 
     126CREATE TABLE `aritems` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `clientid` int(10) unsigned NOT NULL, `type` ENUM('invoice','credit','service charge') NOT NULL, `status` ENUM('open','closed') NOT NULL, `itemdate` DATE NOT NULL, `relatedid` int(10) unsigned default NULL, `amount` double NOT NULL default '0', `paid` double NOT NULL default '0', `aged1` tinyint(3) unsigned NOT NULL default '0', `aged2` tinyint(3) unsigned NOT NULL default '0', `aged3` tinyint(3) unsigned NOT NULL default '0', `title` varchar(255) default NULL, `posted` tinyint(3) unsigned NOT NULL default '0', `createdby` int(10) unsigned NOT NULL, `creationdate` datetime NOT NULL, `modifiedby` int(10) unsigned default NULL, `modifieddate` timestamp NOT NULL, PRIMARY KEY  (`id`)); 
    127127CREATE TABLE `receipts` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `clientid` int(10) unsigned NOT NULL, `amount` double NOT NULL default '0', `receiptdate` date NOT NULL, `status` enum('open','collected') NOT NULL default 'open', `readytopost` tinyint(3) unsigned NOT NULL default '0', `posted` tinyint(3) unsigned NOT NULL default '0', `paymentmethodid` int(10) unsigned NOT NULL default '0', `ccnumber` varchar(64) default NULL, `ccexpiration` varchar(10) default NULL, `ccverification` varchar(4) default NULL, `bankname` varchar(64) default NULL, `checkno` varchar(32) default NULL, `routingnumber` int(10) unsigned default NULL,`accountnumber` int(10) unsigned default NULL, `transactionid` varchar(64) default NULL, `paymentother` varchar(128) default NULL, `memo` text, `createdby` int(11) NOT NULL default '0', `creationdate` datetime NOT NULL default '0000-00-00 00:00:00', `modifiedby` int(10) unsigned default NULL, `modifieddate` timestamp NOT NULL, PRIMARY KEY  (`id`)); 
    128128INSERT INTO `settings` (`name`,`value`) VALUES ('term1_days','30'); 
  • trunk/phpbms/modules/bms/install/updatev0.98.sql

    r698 r701  
    3939    ADD COLUMN `uuid` VARCHAR(64) NOT NULL, 
    4040    MODIFY `clientid` VARCHAR(64) NOT NULL, 
    41     MODIFY `relatedid` VARCHAR(64); 
     41    MODIFY `relatedid` VARCHAR(64), 
     42    MODIFY `type` ENUM('invoice','credit','service charge', 'deposit') NOT NULL; 
     43UPDATE `aritems` SET `type`='credit' WHERE `type`='deposit'; 
     44ALTER TABLE `aritems` 
     45    MODIFY `type` ENUM('invoice','credit','service charge') NOT NULL; 
    4246--end aritems ALTER-- 
    4347--attachements ALTER-- 
  • trunk/phpbms/modules/bms/javascript/aritem.js

    r311 r701  
    4141                 
    4242                var type = getObjectFromID("type"); 
    43                 var relatedid = getObjectFromID("relatedid") 
     43                var relatedid = getObjectFromID("editrelatedid") 
    4444                var id = getObjectFromID("id"); 
    4545                 
     
    4949                var theURL = ""; 
    5050                 
    51                 if(type.value == "deposit") 
     51                if(type.value == "credit") 
    5252                        theURL += receiptEdit.value; 
    5353                else 
  • trunk/phpbms/modules/bms/javascript/receipt.js

    r657 r701  
    591591                var theID, docDue, amountToApply, refid, theType; 
    592592 
    593                 //first find all non-zero deposits and add it to the total; 
     593                //first find all non-zero credits and add it to the total; 
    594594                for(var i=0; i< appliedFields.length; i++){ 
    595595 
     
    597597                        theType = getObjectFromID(theID+"Type"); 
    598598 
    599                         if(theType.value == "deposit"){ 
     599                        if(theType.value == "credit"){ 
    600600 
    601601                                docDue = currencyToNumber(getObjectFromID(theID + "DocDue").value) + currencyToNumber(appliedFields[i].value); 
     
    706706                        ]; 
    707707 
    708                 var depositSelect = getObjectFromID("newItemDepositARID"); 
    709                 console.log(depositSelect); 
    710                 if(!depositSelect){ 
    711  
    712                         var depositP = getObjectFromID("newItemDepositExistingP"); 
    713                         var depositExistingCheckbox = getObjectFromID("newItemDepositExisting"); 
    714                         depositExistingCheckbox.disabled = true; 
    715                         depositP.className = "disabledtext"; 
     708                var creditSelect = getObjectFromID("newItemCreditARID"); 
     709                 
     710                if(!creditSelect){ 
     711 
     712                        var creditP = getObjectFromID("newItemCreditExistingP"); 
     713                        var creditExistingCheckbox = getObjectFromID("newItemCreditExisting"); 
     714                        creditExistingCheckbox.disabled = true; 
     715                        creditP.className = "disabledtext"; 
    716716 
    717717                }//endif 
     
    728728 
    729729                var type = getObjectFromID("newItemType"); 
    730                 var newItemDepositExisting = getObjectFromID("newItemDepositExisting"); 
     730                var newItemCreditExisting = getObjectFromID("newItemCreditExisting"); 
    731731 
    732732                var theSelect = null; 
    733733 
    734734                switch(type.value){ 
    735                         case "deposit": 
    736                                 if(newItemDepositExisting.checked) 
    737                                         theSelect = getObjectFromID("newItemDepositARID"); 
     735                        case "credit": 
     736                                if(newItemCreditExisting.checked) 
     737                                        theSelect = getObjectFromID("newItemCreditARID"); 
    738738                                break; 
    739739 
     
    795795                                invoiceid:null, 
    796796                                uuid:null, 
    797                                 type: 'deposit', 
     797                                type: 'credit', 
    798798                                relatedid: null, 
    799799                                itemdate: dateToString(new Date(), 'SQL'), 
     
    813813                checkbox = e.src(); 
    814814 
    815                 var newItemDepositFieldset = getObjectFromID("newItemDepositFieldset"); 
     815                var newItemCreditFieldset = getObjectFromID("newItemCreditFieldset"); 
    816816                var newItemInvoiceFieldset = getObjectFromID("newItemInvoiceFieldset"); 
    817817                var newItemServiceChargeFieldset = getObjectFromID("newItemServiceChargeFieldset"); 
     
    821821 
    822822                        case "invoice": 
    823                                 newItemDepositFieldset.style.display = "none"; 
     823                                newItemCreditFieldset.style.display = "none"; 
    824824                                newItemServiceChargeFieldset.style.display = "none"; 
    825825                                newItemInvoiceFieldset.style.display = "block"; 
     
    834834 
    835835                        case "service charge": 
    836                                 newItemDepositFieldset.style.display = "none"; 
     836                                newItemCreditFieldset.style.display = "none"; 
    837837                                newItemServiceChargeFieldset.style.display = "block"; 
    838838                                newItemInvoiceFieldset.style.display = "none"; 
     
    849849                                break; 
    850850 
    851                         case "deposit": 
    852                                 newItemDepositFieldset.style.display = "block"; 
     851                        case "credit": 
     852                                newItemCreditFieldset.style.display = "block"; 
    853853                                newItemServiceChargeFieldset.style.display = "none"; 
    854854                                newItemInvoiceFieldset.style.display = "none"; 
  • trunk/phpbms/modules/bms/receipts_addedit.php

    r636 r701  
    4040        include("modules/bms/include/receipts.php"); 
    4141 
     42        if(!isset($_GET["backurl"])) 
     43                $backurl = NULL; 
     44        else{ 
     45                $backurl = $_GET["backurl"]; 
     46                if(isset($_GET["refid"])) 
     47                        $backurl .= "?refid=".$_GET["refid"]; 
     48        } 
     49         
    4250        if(!isset($_GET["id"])) 
    4351                $_GET["id"] = 0; 
     
    4755                $_SERVER['HTTP_REFERER'] = $_POST["referrer"]; 
    4856 
    49         $thetable = new receipts($db,"tbld:43678406-be25-909b-c715-7e2afc7db601"); 
     57        $thetable = new receipts($db,"tbld:43678406-be25-909b-c715-7e2afc7db601", $backurl); 
    5058        $therecord = $thetable->processAddEditPage(); 
    5159 
  • trunk/phpbms/modules/bms/receipts_aritem_ajax.php

    r636 r701  
    2121                                        `aritems`.`relatedid`, 
    2222                                        `aritems`.`itemdate`, 
    23                                         IF(`aritems`.`type` = 'credit', 'deposit', `aritems`.`type`) AS `type`, 
     23                                        `aritems`.`type`, 
    2424                                        `aritems`.`amount`, 
    2525                                        `aritems`.`paid` 
     
    4848                                        `aritems`.`relatedid`, 
    4949                                        `aritems`.`itemdate`, 
    50                                         IF(`aritems`.`type` = 'credit', 'deposit', `aritems`.`type`) AS `type`, 
     50                                        `aritems`.`type`, 
    5151                                        `aritems`.`amount`, 
    5252                                        `aritems`.`paid` 
     
    114114 
    115115                        $queryType = $type; 
    116                         if($type == "deposit") 
     116                        if($type == "credit") 
    117117                                $queryType = "credit"; 
    118118 
     
    139139                        "; 
    140140 
    141                                 if($type == "deposit") 
     141                                if($type == "credit") 
    142142                                        $querystatement .= "itemdate"; 
    143143                                else 
     
    189189                                <p> 
    190190                                        <select id="newItemType"> 
    191                                                 <option value="deposit">deposit</option> 
     191                                                <option value="credit">credit</option> 
    192192                                                <option value="invoice">invoice</option> 
    193193                                                <option value="service charge">service charge</option> 
     
    197197                        </fieldset> 
    198198 
    199                         <fieldset id="newItemDepositFieldset"> 
    200                                 <legend>Deposits</legend> 
    201  
    202                                 <p id="newItemDepositNewP"> 
    203                                         <input type="radio" class="radiochecks" name="newItemDepositType" id="newItemDepositNew" checked="checked"/> 
    204                                         <label for="newItemDepositNew">new</label> 
    205                                 </p> 
    206  
    207                                 <p id="newItemDepositExistingP"> 
    208                                         <input type="radio" class="radiochecks" name="newItemDepositType" id="newItemDepositExisting"/> 
    209                                         <label for="newItemDepositExisting">existing deposit</label> 
     199                        <fieldset id="newItemCreditFieldset"> 
     200                                <legend>Credits</legend> 
     201 
     202                                <p id="newItemCreditNewP"> 
     203                                        <input type="radio" class="radiochecks" name="newItemCreditType" id="newItemCreditNew" checked="checked"/> 
     204                                        <label for="newItemCreditNew">new</label> 
     205                                </p> 
     206 
     207                                <p id="newItemCreditExistingP"> 
     208                                        <input type="radio" class="radiochecks" name="newItemCreditType" id="newItemCreditExisting"/> 
     209                                        <label for="newItemCreditExisting">existing credit</label> 
    210210                                </p> 
    211211 
    212212                                <p id="newItemExisingListP"> 
    213                                         <?php $this->_showOpenARSelect($clientid, "deposit"); ?> 
     213                                        <?php $this->_showOpenARSelect($clientid, "credit"); ?> 
    214214                                </p> 
    215215                        </fieldset> 
  • trunk/phpbms/modules/bms/report/receipts_pdf.php

    r693 r701  
    490490                                $line["duedate"] = ""; 
    491491 
    492                         if($line["type"] == "deposit" && $line["relatedid"] == $this->receiptrecord["id"]){ 
     492                        if($line["type"] == "credit" && $line["relatedid"] == $this->receiptrecord["id"]){ 
    493493                                $line["relatedid"] = ""; 
    494494                                $line["amount"] = 0; 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.