Last active
December 29, 2015 18:49
-
-
Save nbrew/7713188 to your computer and use it in GitHub Desktop.
SO #20294398
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //error_reporting(0); | |
| include("_models.header.php"); | |
| $model= $_GET["modelname"]; | |
| $timestamp= date("Y-m-d h:i:s"); | |
| mysql_query("UPDATE groupshows SET showended='".$timestamp."' WHERE model='".$model."' AND showended='0'"); | |
| mysql_query("UPDATE groupshows SET ended='1', started='0' WHERE model='".$model."' AND customer='0'"); | |
| //udregn show cost | |
| $result=mysql_query("SELECT * FROM groupshows where model ='".$model."' AND customer='0'"); | |
| while($row=mysql_fetch_array($result)) | |
| { | |
| $id=$row["groupshowid"]; | |
| $result2=mysql_query("SELECT * FROM groupshows where groupshowid='".$id."' and cost='0' limit 1"); | |
| while($row2=mysql_fetch_array($result2)) | |
| { | |
| $customer=$row2["customer"]; | |
| $cost=$row2["cost"]; | |
| $startime=$row2["showstarted"]; | |
| $endtime=$row2["showended"]; | |
| if ($cost=='0') { | |
| $to_time = strtotime($endtime); | |
| //echo "endtime $to_time<br>"; | |
| $from_time = strtotime($starttime); | |
| //echo "start $from_time<br>"; | |
| $timespend=round(abs($to_time - $from_time) / 60,2); | |
| $timespend2=date("Y-m-d h:i:s",$timespend); | |
| //echo "timespend $timespend<br>"; | |
| $cost=number_format($timespend,0)*0.39; | |
| $cost2=$cost/100; | |
| //echo "cost $cost<br>"; | |
| //echo "Show started $starttime Show ended $timestamp<br>"; | |
| $Earn=number_format($cost, 2)/100; | |
| //echo "<b>total cost $ $cost2</b>"; | |
| mysql_query("UPDATE groupshows SET cost=cost + '".$cost."' Where customer='".$customer."' AND cost='0'"); | |
| } | |
| // result is a mysql result resource (and can't be incremented like this) | |
| // $result++; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment