function CheckLoginParams($login, $password) { $pass = crypt($password, SALT_VALUE); $SqlText = "SELECT username,password FROm users WHERE username='******' AND password='******'"; $result = GetOneRow($SqlText); if (!is_null($result)) { if ($login == $result['username'] && $pass == $result['password']) { return true; } else { return false; } } else { return false; } }
function GetNewsById($NewsId) { $SqlText = "select NewsId,newsHeader,NewsPreview,NewsText,tags,publishdate from news WHERE NewsId=" . $NewsId; return GetOneRow($SqlText); }
function details($lot) { $sum_crdb = 0; $sum_of_fees; $item = GetOneRow("*, state.c_description as state, condi.c_description as conditio", "item inner join (select code, c_description from `condition` where type='S')state on(item.i_state=state.code) inner join (select code, c_description from `condition` where type='C')condi on(item.i_condition=condi.code)", "where lot=" . $lot); /*$fees=GetAllRows('*', 'cre_deb', "where lot=".$lot." and cd_note in('Paypal fee', 'Ebay fee', 'Ebay shipping fee','Handling fee', 'Handling loss' )");*/ $cred_db = GetAllRows('*', 'cre_deb', "where lot=" . $lot); /* $item['list_date'] $item['i_note'] $item['ebay_str_cost'] $item['case_open'] $item['repair_needed'] $item['part_of'] */ $output = "<table>\r\n\t\t<tr>\r\n\t\t<td>\r\n\t\t<table border='1'>\r\n\t\t<tr>\r\n\t\t\t<td>\r\n\t\t\t\tLot #\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . $item['lot'] . "\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td>\r\n\t\t\t\tItem Desciption\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . $item['item_description'] . "\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td>\r\n\t\t\t\tCurrent Condition\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . $item['conditio'] . "\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td>\r\n\t\t\t\tCurrent State\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . $item['state'] . "\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td>\r\n\t\t\t\tItem initial Cost\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . $item['cost'] . "\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td>\r\n\t\t\t\tItem Initial Shipping cost\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . $item['c_shipping'] . "\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td>\r\n\t\t\t\tInitial Quanity\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . $item['quanity'] . "\r\n\t\t\t</td>\r\n\t\t</tr>"; if ($item['quanity'] > 1) { $output .= "<tr>\r\n\t\t\t<td>\r\n\t\t\t\tQuanity Sold:\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . $item['sold_quanity'] . "\r\n\t\t\t</td>\r\n\t\t</tr>"; } $output .= "<tr>\r\n\t\t\t<td>\r\n\t\t\t\tHas Item Sold?\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . yesno($item['sold']) . "\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t</tr>\r\n\t\t\t<td>\r\n\t\t\t\tPrice sold @\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t\$" . $item['sold_price'] . "\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t</tr>\r\n\t\t\t<td>\r\n\t\t\t\tShipping via ebay\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . $item['s_shipping'] . "\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t</tr>\r\n\t\t\t<td>\r\n\t\t\t\tActual shipping cost\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . $item['actual_shipping'] . "\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t</tr>\r\n\t\t\t<td>\r\n\t\t\t\tItem Paid for\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . yesno($item['paid']) . "\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t</tr>\r\n\t\t\t<td>\r\n\t\t\t\tItem in need of repair?\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . yesno($item['repair_needed']) . "\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t</table>"; if ($item['part_of'] != 0) { $output .= "Part of <br />" . main_view('item.*, `condition`.c_description as descript', " inner join `condition` on code=i_state and type='S'", "lot='" . $item['part_of'] . "'", '', true); } if ($cred_db[0] != NULL) { $output .= CreDebView(true, $item['lot'], $cred_db, $sum_crdb, true); $fees = get_fees($cred_db); $handling_fee = isset($fees['Handling fee']) ? $fees['Handling fee'][0] : -1 * $fees['Handling loss'][0]; $fee_info = "<tr>\r\n\t\t\t\t<td>\r\n\t\t\t\t\tEbay Sell Fee\r\n\t\t\t\t</td>\r\n\t\t\t\t<td>\r\n\t\t\t\t\t\$" . $fees['Ebay fee'][0] . "\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>\r\n\t\t\t\t\tEbay Shipping Fee\r\n\t\t\t\t</td>\r\n\t\t\t\t<td>\r\n\t\t\t\t\t\$" . $fees['Ebay shipping fee'][0] . "\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>\r\n\t\t\t\t\tPaypal Fee\r\n\t\t\t\t</td>\r\n\t\t\t\t<td>\r\n\t\t\t\t\t\$" . $fees['Paypal fee'][0] . "\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>\r\n\t\t\t\t\tHandling Fee/Debit\r\n\t\t\t\t</td>\r\n\t\t\t\t<td>\r\n\t\t\t\t\t\$" . $handling_fee . "\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>\r\n\t\t\t\t\tOther Credit/Debit\r\n\t\t\t\t</td>\r\n\t\t\t\t<td>\r\n\t\t\t\t\t\$" . number_format($sum_crdb + ($fees['Ebay shipping fee'][0] + $fees['Paypal fee'][0] + $fees['Ebay fee'][0]) + $handling_fee * -1, 2) . "\r\n\t\t\t\t</td>\r\n\t\t\t</tr>"; //$sum=$sum+$fees['Paypal fee'][0]+$fees['Ebay fee'][0]+$fees['Ebay shipping fee'][0]+$handling_fee; } $total = $item['sold_price'] + $sum_crdb - ($item['cost'] + $item['c_shipping'] + $item['ebay_str_cost']) < 0.01 ? '0.00' : $item['sold_price'] + $sum_crdb - ($item['cost'] + $item['c_shipping'] + $item['ebay_str_cost']); $output .= "Total Profit/Loss for lot<br />\r\n\t\t<table border='1'>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>\r\n\t\t\t\t\tTotal Cost\r\n\t\t\t\t</td>\r\n\t\t\t\t<td>\r\n\t\t\t\t\t\$" . ($item['cost'] + $item['c_shipping']) . "\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>\r\n\t\t\t\t\tEbay list Fee\r\n\t\t\t\t</td>\r\n\t\t\t\t<td>\r\n\t\t\t\t\t\$" . $item['ebay_str_cost'] . "\r\n\t\t\t\t</td>\r\n\t\t\t</tr>"; //$output .= $c; if (isset($fee_info)) { $output .= $fee_info; } $output .= "<tr>\r\n\t\t\t\t<td>\r\n\t\t\t\t\tSold price\r\n\t\t\t\t</td>\r\n\t\t\t\t<td>\r\n\t\t\t\t\t\$" . $item['sold_price'] . "\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>\r\n\t\t\t\t\tTotal\r\n\t\t\t\t</td>\r\n\t\t\t\t<td>\r\n\t\t\t\t\t\$" . number_format($item['sold_price'] + $sum_crdb - ($item['cost'] + $item['c_shipping'] + $item['ebay_str_cost']), 2) . "\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t\t</td>\r\n\t\t</tr>\r\n\t</table>"; echo $output; }
function GivingItem() { $giver = $_POST['give']; $receiver = $_POST['receive']; if ($_POST['quanity'] >= 1) { $select = "((a.cost+a.c_shipping)/a.quanity)*" . $_POST['quanity'] . "-IFNULL(e.total,0) as totals "; $from = "item a left outer join (select sum(credit-debit) as total, lot from cre_deb where lot in('193') and locate('Giving lot(193) to lot(', cd_note)=0 group by lot)e on(a.lot=e.lot)"; updatetable('item', 'set sold_quanity=sold_quanity+' . $_POST['quanity']); } else { $select = "a.cost+a.c_shipping-IFNULL(e.total,0) as totals"; $from = "item a left outer join (select sum(credit-debit) as total, lot \n\t\t\tfrom cre_deb where lot in('" . $giver . "') group by lot) e on(a.lot=e.lot)"; } $item_cost_g = GetOneRow($select, $from, "where a.lot in('" . $giver . "')"); //echo $item_cost_g['totals']."<br />"; if ($item_cost_g['totals'] > 0) { $credit1 = $debit2 = 0; $debit1 = $credit2 = $item_cost_g['totals']; } elseif ($item_cost_g['totals'] < 0) { $debit1 = $credit2 = 0; $credit1 = $debit2 = -1 * $item_cost_b['totals']; } else { //=0 $credit1 = $debit1 = $credit2 = $debit2 = 0; } $value = "(lot, credit,debit,cd_note) values('" . $receiver . "',\n\t" . $credit1 . "," . $debit1 . ",'Receiveed lot to(" . $receiver . ") from lot(" . $giver . ")'),\n\t('" . $giver . "'," . $credit2 . "," . $debit2 . ",'Giving lot(" . $giver . ") to lot(" . $receiver . ")')"; echo $value . "<br />"; if (insertinto('cre_deb', $value)) { echo "Success!"; } //$values2=set i_state= }