| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | +-------------------------------------------------------------------------+ |
|---|
| 4 | | Copyright (c) 2004 - 2010, Kreotek LLC | |
|---|
| 5 | | All rights reserved. | |
|---|
| 6 | +-------------------------------------------------------------------------+ |
|---|
| 7 | | | |
|---|
| 8 | | Redistribution and use in source and binary forms, with or without | |
|---|
| 9 | | modification, are permitted provided that the following conditions are | |
|---|
| 10 | | met: | |
|---|
| 11 | | | |
|---|
| 12 | | - Redistributions of source code must retain the above copyright | |
|---|
| 13 | | notice, this list of conditions and the following disclaimer. | |
|---|
| 14 | | | |
|---|
| 15 | | - Redistributions in binary form must reproduce the above copyright | |
|---|
| 16 | | notice, this list of conditions and the following disclaimer in the | |
|---|
| 17 | | documentation and/or other materials provided with the distribution. | |
|---|
| 18 | | | |
|---|
| 19 | | - Neither the name of Kreotek LLC nor the names of its contributore may | |
|---|
| 20 | | be used to endorse or promote products derived from this software | |
|---|
| 21 | | without specific prior written permission. | |
|---|
| 22 | | | |
|---|
| 23 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
|---|
| 24 | | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
|---|
| 25 | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | |
|---|
| 26 | | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
|---|
| 27 | | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
|---|
| 28 | | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
|---|
| 29 | | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
|---|
| 30 | | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
|---|
| 31 | | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
|---|
| 32 | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
|---|
| 33 | | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
|---|
| 34 | | | |
|---|
| 35 | +-------------------------------------------------------------------------+ |
|---|
| 36 | */ |
|---|
| 37 | include("../../include/session.php"); |
|---|
| 38 | include("include/fields.php"); |
|---|
| 39 | include("modules/recurringinvoices/include/recurringinvoices.php"); |
|---|
| 40 | |
|---|
| 41 | if(!isset($_GET["id"])) |
|---|
| 42 | $_GET["id"] = 0; |
|---|
| 43 | $_GET["id"] = (int) $_GET["id"]; |
|---|
| 44 | |
|---|
| 45 | if(isset($_POST["referrer"])) |
|---|
| 46 | $_SERVER['HTTP_REFERER'] = $_POST["referrer"]; |
|---|
| 47 | |
|---|
| 48 | $thetable = new recurringinvoice($db,$_GET["id"]); |
|---|
| 49 | $therecord = $thetable->process(); |
|---|
| 50 | |
|---|
| 51 | //set the page title |
|---|
| 52 | $refquery=" |
|---|
| 53 | SELECT |
|---|
| 54 | `invoices`.`id`, |
|---|
| 55 | if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) as name, |
|---|
| 56 | `invoices`.`type`, |
|---|
| 57 | `invoices`.`invoicedate` |
|---|
| 58 | FROM |
|---|
| 59 | `invoices` INNER JOIN `clients` ON `invoices`.`clientid`=clients.uuid |
|---|
| 60 | WHERE |
|---|
| 61 | `invoices`.`id`=".$_GET["id"]; |
|---|
| 62 | |
|---|
| 63 | $refquery=$db->query($refquery); |
|---|
| 64 | $refrecord=$db->fetchArray($refquery); |
|---|
| 65 | |
|---|
| 66 | $invoiceDate = stringToDate($refrecord["invoicedate"],"SQL"); |
|---|
| 67 | |
|---|
| 68 | $pageTitle="Invoice Recurrence: ".$refrecord["id"].": ".$refrecord["name"]; |
|---|
| 69 | $phpbms->cssIncludes[] = "pages/recurringinvoices.css"; |
|---|
| 70 | $phpbms->jsIncludes[] = "modules/recurringinvoices/javascript/recurringinvoices.js"; |
|---|
| 71 | |
|---|
| 72 | //Form Elements |
|---|
| 73 | //============================================================== |
|---|
| 74 | $theform = new phpbmsForm(); |
|---|
| 75 | |
|---|
| 76 | $theinput = new inputCheckbox("recurr","","recurr invoice",($invoiceDate == NULL)); |
|---|
| 77 | $theform->addField($theinput); |
|---|
| 78 | |
|---|
| 79 | $temparray = array("Daily"=>"Daily", "Weekly"=>"Weekly", "Monthly"=>"Monthly", "Yearly"=>"Yearly"); |
|---|
| 80 | $theinput = new inputBasiclist("type",$therecord["type"],$temparray,"frequency"); |
|---|
| 81 | $theinput->setAttribute("onchange","changeType();"); |
|---|
| 82 | $theform->addField($theinput); |
|---|
| 83 | |
|---|
| 84 | $theinput = new inputField("every",$therecord["every"],"frequency of repeating",false,"integer",2,4,false); |
|---|
| 85 | $theform->addField($theinput); |
|---|
| 86 | |
|---|
| 87 | $theinput = new inputBasiclist("monthlyontheweek",$therecord["ontheweek"],$thetable->weekArray,"on the week of",false); |
|---|
| 88 | $theinput2 = new inputBasiclist("yearlyontheweek",$therecord["ontheweek"],$thetable->weekArray,"on the week of",false); |
|---|
| 89 | if(!$therecord["ontheday"]) { |
|---|
| 90 | $theinput->setAttribute("disabled","disabled"); |
|---|
| 91 | $theinput2->setAttribute("disabled","disabled"); |
|---|
| 92 | |
|---|
| 93 | $weekNumber = ceil(date("d",$invoiceDate)/7); |
|---|
| 94 | if($weekNumber > 4) $weekNumber = 5; |
|---|
| 95 | |
|---|
| 96 | $theinput->value = $weekNumber; |
|---|
| 97 | $theinput2->value = $weekNumber; |
|---|
| 98 | |
|---|
| 99 | } |
|---|
| 100 | $theform->addField($theinput); |
|---|
| 101 | $theform->addField($theinput2); |
|---|
| 102 | |
|---|
| 103 | $temparray = array(); |
|---|
| 104 | for($i=1; $i<8; $i++) |
|---|
| 105 | $temparray[nl_langinfo(constant("DAY_".$i))] = ($i==1)?(7):($i-1); |
|---|
| 106 | $theinput = new inputBasiclist("monthlyontheday",$therecord["ontheday"],$temparray,"on the day",false); |
|---|
| 107 | $theinput2 = new inputBasiclist("yearlyontheday",$therecord["ontheday"],$temparray,"on the day",false); |
|---|
| 108 | if(!$therecord["ontheday"]){ |
|---|
| 109 | $theinput->setAttribute("disabled","disabled"); |
|---|
| 110 | $theinput2->setAttribute("disabled","disabled"); |
|---|
| 111 | $theinput->value = @strftime("%u",$invoiceDate); |
|---|
| 112 | $theinput2->value = @strftime("%u",$invoiceDate); |
|---|
| 113 | } |
|---|
| 114 | $theform->addField($theinput); |
|---|
| 115 | $theform->addField($theinput2); |
|---|
| 116 | |
|---|
| 117 | $temparray = array("never"=>"never", "after"=>"after", "on date"=>"on date"); |
|---|
| 118 | $thevalue = "never"; |
|---|
| 119 | if($therecord["id"]){ |
|---|
| 120 | if($therecord["times"]) |
|---|
| 121 | $thevalue = "after"; |
|---|
| 122 | elseif($therecord["until"]) |
|---|
| 123 | $thevalue = "on date"; |
|---|
| 124 | } |
|---|
| 125 | $theinput = new inputBasiclist("end",$thevalue,$temparray,"end"); |
|---|
| 126 | $theinput->setAttribute("onchange","changeEnd();"); |
|---|
| 127 | $theform->addField($theinput); |
|---|
| 128 | |
|---|
| 129 | $theinput = new inputField("times",$therecord["times"],"repeat until number of times",false,"integer",3,5,false); |
|---|
| 130 | $theform->addField($theinput); |
|---|
| 131 | |
|---|
| 132 | $theinput = new inputDatePicker("until", $therecord["until"], "repeat until date" ,false, 10, 15, false); |
|---|
| 133 | $theform->addField($theinput); |
|---|
| 134 | |
|---|
| 135 | $theinput = new inputCheckbox("includepaymenttype",$therecord["includepaymenttype"], "include payment type from original invoice"); |
|---|
| 136 | $theform->addField($theinput); |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | $theinput = new inputSmartSearch($db, "assignedtoid", "Pick Active User", $therecord["assignedtoid"], "assigned to", false, 36); |
|---|
| 140 | $theinput->setAttribute("size","30"); |
|---|
| 141 | $theform->addField($theinput); |
|---|
| 142 | |
|---|
| 143 | //$thetable->getCustomFieldInfo(); |
|---|
| 144 | //$theform->prepCustomFields($db, $thetable->customFieldsQueryResult, $therecord); |
|---|
| 145 | $theform->jsMerge(); |
|---|
| 146 | //============================================================== |
|---|
| 147 | |
|---|
| 148 | include("header.php"); |
|---|
| 149 | |
|---|
| 150 | $phpbms->showTabs("invoices entry","tab:d303321e-7ff5-fe4b-29ec-fe3eb0305576",$_GET["id"]); |
|---|
| 151 | ?><div class="bodyline"> |
|---|
| 152 | <form action="<?php echo htmlentities($_SERVER["REQUEST_URI"]) ?>" |
|---|
| 153 | method="post" name="record" id="record" |
|---|
| 154 | onsubmit="return false;"> |
|---|
| 155 | <div id="topButtons"> |
|---|
| 156 | <input type="button" class="Buttons" id="update1" name="update" value="save" onclick="submitForm('update');"/> |
|---|
| 157 | <?php if(strpos($_SERVER['HTTP_REFERER'],"search.php") != false){?> |
|---|
| 158 | <input type="button" class="Buttons" id="cancel1" name="cancel" value="cancel" onclick="submitForm('cancel');"/> |
|---|
| 159 | <?php }?> |
|---|
| 160 | </div> |
|---|
| 161 | <h1 id="h1Title"><span><?php echo $pageTitle ?></span></h1> |
|---|
| 162 | <input type="hidden" id="id" name="id" value="<?php echo $therecord["id"]?>"/> |
|---|
| 163 | <input type="hidden" id="eachlist" name="eachlist" value=""/> |
|---|
| 164 | <input type="hidden" id="command" name="command" /> |
|---|
| 165 | <input type="hidden" id="referrer" name="referrer" value="<?php echo str_replace("&","&",$_SERVER['HTTP_REFERER'])?>" /> |
|---|
| 166 | <fieldset> |
|---|
| 167 | <legend>Invoice Recurrence</legend> |
|---|
| 168 | |
|---|
| 169 | <p><?php $theform->showField("recurr")?></p> |
|---|
| 170 | |
|---|
| 171 | <?php if($invoiceDate == NULL){?> |
|---|
| 172 | <p class="notes">The invoice cannot be repeated until an invoice date has been set.</p> |
|---|
| 173 | <?php }?> |
|---|
| 174 | </fieldset> |
|---|
| 175 | |
|---|
| 176 | <div id="recurrDetails"> |
|---|
| 177 | <div id="rightSideDiv"> |
|---|
| 178 | <fieldset> |
|---|
| 179 | <legend>Repeat Statistics</legend> |
|---|
| 180 | <p> |
|---|
| 181 | first recurred<br /> |
|---|
| 182 | <input readonly="readonly" class="uneditable" type="text" size="12" value="<?php if($therecord["lastrepeat"]) echo formatFromSQLDate($therecord["firstrepeat"])?>"/> |
|---|
| 183 | </p> |
|---|
| 184 | <p> |
|---|
| 185 | last recurred<br /> |
|---|
| 186 | <input readonly="readonly" class="uneditable" type="text" size="12" value="<?php if($therecord["lastrepeat"]) echo formatFromSQLDate($therecord["lastrepeat"])?>"/> |
|---|
| 187 | </p> |
|---|
| 188 | <p> |
|---|
| 189 | number of recurrences to date<br/> |
|---|
| 190 | <input readonly="readonly" class="uneditable" type="text" size="4" value="<?php echo $therecord["timesrepeated"]?>"/> |
|---|
| 191 | </p> |
|---|
| 192 | </fieldset> |
|---|
| 193 | </div> |
|---|
| 194 | |
|---|
| 195 | <div id="leftSideDiv"> |
|---|
| 196 | <fieldset> |
|---|
| 197 | <legend>recurrence options</legend> |
|---|
| 198 | |
|---|
| 199 | <p> |
|---|
| 200 | invoice date<br/> |
|---|
| 201 | <input type="text" size="12" class="uneditable" readonly="readonly" value="<?php echo dateToString($invoiceDate) ?>" /> |
|---|
| 202 | </p> |
|---|
| 203 | |
|---|
| 204 | <p><?php $theform->showField("type")?></p> |
|---|
| 205 | |
|---|
| 206 | <p>every <?php $theform->showField("every")?> <span id="typeText">day(s)</span></p> |
|---|
| 207 | |
|---|
| 208 | <div id="DailyDiv"></div> |
|---|
| 209 | |
|---|
| 210 | <div id="WeeklyDiv"> |
|---|
| 211 | <p><?php $thetable->showWeeklyOptions($therecord,$invoiceDate)?></p> |
|---|
| 212 | </div> |
|---|
| 213 | |
|---|
| 214 | <div id="MonthlyDiv"> |
|---|
| 215 | <p><input type="radio" id="monthlyEach" name="monthlyWhat" onchange="monthlyChange();" value="1" <?php if(!$therecord["ontheday"]) echo 'checked="checked"'?> /><label for="monthlyEach"> each</label></p> |
|---|
| 216 | |
|---|
| 217 | <p><?php $thetable->showMonthlyOptions($therecord,$invoiceDate)?></p> |
|---|
| 218 | |
|---|
| 219 | <p><input type="radio" id="monthlyOnThe" name="monthlyWhat" onchange="monthlyChange();" value="2" <?php if($therecord["ontheday"]) echo 'checked="checked"'?> /><label for="monthlyOnThe"> on the</label></p> |
|---|
| 220 | <p> |
|---|
| 221 | <?php $theform->showField("monthlyontheweek");?> |
|---|
| 222 | <?php $theform->showField("monthlyontheday");?> |
|---|
| 223 | </p> |
|---|
| 224 | </div> |
|---|
| 225 | |
|---|
| 226 | <div id="YearlyDiv"> |
|---|
| 227 | <p><?php $thetable->showYearlyOptions($therecord,$invoiceDate)?></p> |
|---|
| 228 | |
|---|
| 229 | <p><input id="yearlyOnThe" type="checkbox" name="yearlyOnThe" onclick="yearlyOnTheChecked();" value="1" <?php if($therecord["type"]=="Yearly" && $therecord["ontheday"]) echo 'checked="checked"'?>/><label for="yearlyOnThe"> on the</label></p> |
|---|
| 230 | <p> |
|---|
| 231 | <?php $theform->showField("yearlyontheweek");?> |
|---|
| 232 | <?php $theform->showField("yearlyontheday");?> |
|---|
| 233 | </p> |
|---|
| 234 | |
|---|
| 235 | </div> |
|---|
| 236 | </fieldset> |
|---|
| 237 | |
|---|
| 238 | <fieldset> |
|---|
| 239 | <legend>end</legend> |
|---|
| 240 | <p> |
|---|
| 241 | <?php $theform->showField("end")?> |
|---|
| 242 | <span id="afterSpan" style="display:none"> |
|---|
| 243 | <?php $theform->showField("times")?> <label for="times">time(s)</label> |
|---|
| 244 | </span> |
|---|
| 245 | <span id="ondateSpan" style="display:none"> |
|---|
| 246 | <?php $theform->showField("until")?> |
|---|
| 247 | </span> |
|---|
| 248 | </p> |
|---|
| 249 | </fieldset> |
|---|
| 250 | |
|---|
| 251 | <fieldset> |
|---|
| 252 | <legend>New Order Options</legend> |
|---|
| 253 | |
|---|
| 254 | <p><?php $theform->showfield("includepaymenttype");?></p> |
|---|
| 255 | |
|---|
| 256 | <p><?php $thetable->showStatusDropDown($therecord["statusid"]);?></p> |
|---|
| 257 | |
|---|
| 258 | <div class="fauxP"><?php $theform->showField("assignedtoid");?></div> |
|---|
| 259 | |
|---|
| 260 | |
|---|
| 261 | <p><?php $thetable->showRolesDropDown($therecord["notificationroleid"]);?></p> |
|---|
| 262 | |
|---|
| 263 | </fieldset> |
|---|
| 264 | |
|---|
| 265 | <p class="notes"> |
|---|
| 266 | Note: Recurring invoices utilizes the scheduler function of phpBMS, which relies |
|---|
| 267 | on an external scheduler program (like cron). Make sure these functions are enabled or |
|---|
| 268 | the invoices will not repeat. |
|---|
| 269 | </p> |
|---|
| 270 | |
|---|
| 271 | </div> |
|---|
| 272 | </div> |
|---|
| 273 | |
|---|
| 274 | |
|---|
| 275 | <div align="right"> |
|---|
| 276 | <input type="button" class="Buttons" id="update2" name="update" value="save" onclick="submitForm('update');"/> |
|---|
| 277 | <?php if(strpos($_SERVER['HTTP_REFERER'],"search.php") != false){?> |
|---|
| 278 | <input type="button" class="Buttons" id="cancel2" name="cancel" value="cancel" onclick="submitForm('cancel');"/> |
|---|
| 279 | <?php }?> |
|---|
| 280 | </div> |
|---|
| 281 | </form> |
|---|
| 282 | </div> |
|---|
| 283 | <?php include("footer.php")?> |
|---|