function write_customer($email, $name, $company, $address, $phone, $fax, $currency) { global $paypal_sales_type_id, $paypal_tax_group_id, $paypal_salesman, $paypal_area, $paypal_location, $paypal_credit_status, $paypal_shipper; global $SysPrefs; log_message("Memory, write_customer start:" . memory_get_usage()); $customer_id = find_customer_by_email($email); if (empty($customer_id)) { $customer_id = find_customer_by_name($company); } if (empty($customer_id)) { //it is a new customer begin_transaction(); add_customer($company, substr($company, 0, 30), $address, '', $currency, 0, 0, $paypal_credit_status, -1, 0, 0, $SysPrefs->default_credit_limit(), $paypal_sales_type_id, 'PayPal'); $customer_id = db_insert_id(); add_branch($customer_id, $company, substr($company, 0, 30), $address, $paypal_salesman, $paypal_area, $paypal_tax_group_id, '', get_company_pref('default_sales_discount_act'), get_company_pref('debtors_act'), get_company_pref('default_prompt_payment_act'), $paypal_location, $address, 0, 0, $paypal_shipper, 'PayPal'); $selected_branch = db_insert_id(); $nameparts = explode(" ", $name); $firstname = ""; for ($i = 0; $i < count($nameparts) - 1; $i++) { if (!empty($firstname)) { $firstname .= " "; } $firstname .= $nameparts[$i]; } $lastname = $nameparts[count($nameparts) - 1]; add_crm_person('paypal', $firstname, $lastname, $address, $phone, '', $fax, $email, '', ''); add_crm_contact('customer', 'general', $selected_branch, db_insert_id()); commit_transaction(); } else { $selected_branch = 0; } log_message("Memory, write_customer end:" . memory_get_usage()); return array($customer_id, $selected_branch); }
function handle_submit(&$selected_id) { global $path_to_root, $Ajax, $auto_create_branch; if (!can_process()) { return; } if ($selected_id) { update_customer($_POST['customer_id'], $_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['tax_id'], $_POST['curr_code'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['credit_status'], $_POST['payment_terms'], input_num('discount') / 100, input_num('pymt_discount') / 100, input_num('credit_limit'), $_POST['sales_type'], $_POST['notes']); update_record_status($_POST['customer_id'], $_POST['inactive'], 'debtors_master', 'debtor_no'); $Ajax->activate('customer_id'); // in case of status change display_notification(_("Customer has been updated.")); } else { //it is a new customer begin_transaction(); add_customer($_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['tax_id'], $_POST['curr_code'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['credit_status'], $_POST['payment_terms'], input_num('discount') / 100, input_num('pymt_discount') / 100, input_num('credit_limit'), $_POST['sales_type'], $_POST['notes']); $selected_id = $_POST['customer_id'] = db_insert_id(); if (isset($auto_create_branch) && $auto_create_branch == 1) { add_branch($selected_id, $_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['salesman'], $_POST['area'], $_POST['tax_group_id'], '', get_company_pref('default_sales_discount_act'), get_company_pref('debtors_act'), get_company_pref('default_prompt_payment_act'), $_POST['location'], $_POST['address'], 0, 0, $_POST['ship_via'], $_POST['notes']); $selected_branch = db_insert_id(); add_crm_person($_POST['CustName'], $_POST['cust_ref'], '', $_POST['address'], $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], '', ''); add_crm_contact('cust_branch', 'general', $selected_branch, db_insert_id()); } commit_transaction(); display_notification(_("A new customer has been added.")); if (isset($auto_create_branch) && $auto_create_branch == 1) { display_notification(_("A default Branch has been automatically created, please check default Branch values by using link below.")); } $Ajax->activate('_page_body'); } }
function create_member($gatech_email, $first_name, $last_name, $password) { $insert_member = <<<SQL insert into tb_member ( first_name, last_name, gatech_email_address, display_email_address, password_hash ) values ( ?first_name?, ?last_name?, ?gatech_email?, ?gatech_email?, crypt( ?password?, gen_salt( 'bf' ) ) ) returning member SQL; $params = ['first_name' => $first_name, 'last_name' => $last_name, 'gatech_email' => $gatech_email, 'password' => $password]; begin_transaction(); $insert = query_execute($insert_member, $params); if (query_success($insert)) { $member_created = query_fetch_one($insert); $member_pk = $member_created['member']; $insert_role = <<<SQL insert into tb_member_role ( member, role ) values ( ?member?, ?role? ) SQL; $params = ['member' => $member_pk, 'role' => ROLE_MEMBER]; $result = query_execute($insert_role, $params); if (query_success($result)) { commit_transaction(); return $member_pk; } } rollback_transaction(); return false; }
function UpdatePlanetBatimentQueueList($planetid) { $RetValue = false; $now = time(); begin_transaction(); $CurrentPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $planetid . "' FOR UPDATE", 'planets', true); if (!$CurrentPlanet || $CurrentPlanet['b_building'] == 0 || $CurrentPlanet['b_building'] > $now) { rollback(); return false; } $CurrentUser = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $CurrentPlanet['id_owner'] . "' LOCK IN SHARE MODE", 'users', true); if (!$CurrentUser) { return false; } PlanetResourceUpdate($CurrentUser, $CurrentPlanet, $CurrentPlanet['b_building'], false); CheckPlanetBuildingQueue($CurrentPlanet, $CurrentUser); commit(); }
function handle_process() { begin_transaction(); // clear all the allocations for this payment/credit clear_cust_alloctions($_SESSION['alloc']->type, $_SESSION['alloc']->trans_no); // now add the new allocations $total_allocated = 0; foreach ($_SESSION['alloc']->allocs as $allocn_item) { if ($allocn_item->current_allocated > 0) { add_cust_allocation($allocn_item->current_allocated, $_SESSION['alloc']->type, $_SESSION['alloc']->trans_no, $allocn_item->type, $allocn_item->type_no, $_SESSION['alloc']->date_); update_debtor_trans_allocation($allocn_item->type, $allocn_item->type_no, $allocn_item->current_allocated); $total_allocated += $allocn_item->current_allocated; } } /*end of the loop through the array of allocations made */ update_debtor_trans_allocation($_SESSION['alloc']->type, $_SESSION['alloc']->trans_no, $total_allocated); commit_transaction(); clear_allocations(); }
function handle_submit() { global $path_to_root; if (!can_process()) { return; } if (!isset($_POST['New'])) { $sql = "UPDATE debtors_master SET name=" . db_escape($_POST['CustName']) . ", \n\t\t\taddress=" . db_escape($_POST['address']) . ", \n\t\t\ttax_id=" . db_escape($_POST['tax_id']) . ", \n\t\t\tcurr_code=" . db_escape($_POST['curr_code']) . ", \n\t\t\temail=" . db_escape($_POST['email']) . ", \n\t\t\tdimension_id=" . db_escape($_POST['dimension_id']) . ", \n\t\t\tdimension2_id=" . db_escape($_POST['dimension2_id']) . ", \n credit_status=" . db_escape($_POST['credit_status']) . ", \n payment_terms=" . db_escape($_POST['payment_terms']) . ", \n discount=" . input_num('discount') / 100 . ", \n pymt_discount=" . input_num('pymt_discount') / 100 . ", \n credit_limit=" . input_num('credit_limit') . ", \n sales_type = " . db_escape($_POST['sales_type']) . " \n WHERE debtor_no = '" . $_POST['customer_id'] . "'"; db_query($sql, "The customer could not be updated"); display_notification(tr("Customer has been updated.")); clear_fields(); } else { //it is a new customer begin_transaction(); $sql = "INSERT INTO debtors_master (name, address, tax_id, email, dimension_id, dimension2_id, \n\t\t\tcurr_code, credit_status, payment_terms, discount, pymt_discount,credit_limit, \n\t\t\tsales_type) VALUES (" . db_escape($_POST['CustName']) . ", " . db_escape($_POST['address']) . ", " . db_escape($_POST['tax_id']) . "," . db_escape($_POST['email']) . ", " . db_escape($_POST['dimension_id']) . ", " . db_escape($_POST['dimension2_id']) . ", " . db_escape($_POST['curr_code']) . ", \n\t\t\t" . db_escape($_POST['credit_status']) . ", " . db_escape($_POST['payment_terms']) . ", " . input_num('discount') / 100 . ", \n\t\t\t" . input_num('pymt_discount') / 100 . ", " . input_num('credit_limit') . ", " . db_escape($_POST['sales_type']) . ")"; db_query($sql, "The customer could not be added"); $new_customer_id = db_insert_id(); commit_transaction(); display_notification(tr("A new customer has been added.")); hyperlink_params($path_to_root . "/sales/manage/customer_branches.php", tr("Add branches for this customer"), "debtor_no={$new_customer_id}"); clear_fields(); } }
display_error(_("You have to select supplier.")); set_focus('person_id'); $input_error = 1; } if (!db_has_currency_rates(get_bank_account_currency($_POST['bank_account']), $_POST['date_'], true)) { $input_error = 1; } if (isset($_POST['settled_amount']) && in_array(get_post('PayType'), array(PT_SUPPLIER, PT_CUSTOMER)) && input_num('settled_amount') <= 0) { display_error(_("Settled amount have to be positive number.")); set_focus('person_id'); $input_error = 1; } return $input_error; } if (isset($_POST['Process']) && !check_trans()) { begin_transaction(); $_SESSION['pay_items'] =& $_SESSION['pay_items']; $new = $_SESSION['pay_items']->order_id == 0; add_new_exchange_rate(get_bank_account_currency(get_post('bank_account')), get_post('date_'), input_num('_ex_rate')); $trans = write_bank_transaction($_SESSION['pay_items']->trans_type, $_SESSION['pay_items']->order_id, $_POST['bank_account'], $_SESSION['pay_items'], $_POST['date_'], $_POST['PayType'], $_POST['person_id'], get_post('PersonDetailID'), $_POST['ref'], $_POST['memo_'], true, input_num('settled_amount', null)); $trans_type = $trans[0]; $trans_no = $trans[1]; new_doc_date($_POST['date_']); $_SESSION['pay_items']->clear_items(); unset($_SESSION['pay_items']); commit_transaction(); if ($new) { meta_forward($_SERVER['PHP_SELF'], $trans_type == ST_BANKPAYMENT ? "AddedID={$trans_no}" : "AddedDep={$trans_no}"); } else { meta_forward($_SERVER['PHP_SELF'], $trans_type == ST_BANKPAYMENT ? "UpdatedID={$trans_no}" : "UpdatedDep={$trans_no}"); }
function handle_commit_order() { $cart =& $_SESSION['PO']; if (can_commit()) { copy_to_cart(); if ($cart->trans_type != ST_PURCHORDER) { // for direct grn/invoice set same dates for lines as for whole document foreach ($cart->line_items as $line_no => $line) { $cart->line_items[$line_no]->req_del_date = $cart->orig_order_date; } } if ($cart->order_no == 0) { // new po/grn/invoice /*its a new order to be inserted */ $ref = $cart->reference; if ($cart->trans_type != ST_PURCHORDER) { $cart->reference = 'auto'; begin_transaction(); // all db changes as single transaction for direct document } $order_no = add_po($cart); new_doc_date($cart->orig_order_date); $cart->order_no = $order_no; if ($cart->trans_type == ST_PURCHORDER) { unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedID={$order_no}"); } //Direct GRN if ($cart->trans_type == ST_SUPPRECEIVE) { $cart->reference = $ref; } if ($cart->trans_type != ST_SUPPINVOICE) { $cart->Comments = $cart->reference; } //grn does not hold supp_ref foreach ($cart->line_items as $key => $line) { $cart->line_items[$key]->receive_qty = $line->quantity; } $grn_no = add_grn($cart); if ($cart->trans_type == ST_SUPPRECEIVE) { commit_transaction(); // save PO+GRN unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedGRN={$grn_no}"); } // Direct Purchase Invoice $inv = new supp_trans(ST_SUPPINVOICE); $inv->Comments = $cart->Comments; $inv->supplier_id = $cart->supplier_id; $inv->tran_date = $cart->orig_order_date; $inv->due_date = $cart->due_date; $inv->reference = $ref; $inv->supp_reference = $cart->supp_ref; $inv->tax_included = $cart->tax_included; $supp = get_supplier($cart->supplier_id); $inv->tax_group_id = $supp['tax_group_id']; $inv->ov_amount = $inv->ov_gst = $inv->ov_discount = 0; $total = 0; foreach ($cart->line_items as $key => $line) { $inv->add_grn_to_trans($line->grn_item_id, $line->po_detail_rec, $line->stock_id, $line->item_description, $line->receive_qty, 0, $line->receive_qty, $line->price, $line->price, true, get_standard_cost($line->stock_id), ''); $inv->ov_amount += round2($line->receive_qty * $line->price, user_price_dec()); } $inv->tax_overrides = $cart->tax_overrides; if (!$inv->tax_included) { $taxes = $inv->get_taxes($inv->tax_group_id, 0, false); foreach ($taxes as $taxitem) { $total += isset($taxitem['Override']) ? $taxitem['Override'] : $taxitem['Value']; } } $inv->ex_rate = $cart->ex_rate; $inv_no = add_supp_invoice($inv); commit_transaction(); // save PO+GRN+PI // FIXME payment for cash terms. (Needs cash account selection) unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedPI={$inv_no}"); } else { // order modification $order_no = update_po($cart); unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedID={$order_no}&Updated=1"); } } }
// print_r($host_message_cache); break; } } #print_r ($host_message_cache); exit; // We now have all of the information in the $host_message_cache. Loop over // each message for each host and modify the database accordingly by // updating the message parent row's stats and deleting child rows. // We are doing a lot of database modification. It should all be part of the same transaction. print "\n\n"; print "Debug: Log table analysis complete.\n"; print "Debug: Exact log message matches: {$exact_matches}\n"; print "Debug: Similar log message matches: {$similar_matches}\n"; print "Debug: Starting log table modifications...\n"; $db_time_start = get_microtime(); begin_transaction($dbLink); foreach ($host_message_cache as $host => $messages) { foreach ($messages as $message => $message_data) { if (!$message_data['child_seqs']) { continue; } // Solitary message with no associations. // Bugfix: http://code.google.com/p/php-syslog-ng/issues/detail?id=70 // $count = count($message_data['child_seqs']) + 1; // Children + parent $parent_seq = $message_data['parent_seq']; $query_count = "SELECT counter FROM " . DEFAULTLOGTABLE . " WHERE seq = '{$parent_seq}'"; $result_count = perform_query($query_count, $dbLink); $row_count = fetch_array($result_count); $r_counter = $row_count['counter']; if ($r_counter == '' || $r_counter == 0) { $count = count($message_data['child_seqs']) + 1;
function do_subscriptions_table() { global $postgres; printf("\tCleaning postgres-table\n"); pg_exec($postgres, "DELETE FROM ltrSubscriptions") or die("Error while cleaning table"); printf("\tReading from MySQL...\n"); $query = "SELECT ltrSubscriptions.Trail, auth_user.user_id FROM ltrSubscriptions, auth_user WHERE auth_user.username = ltrSubscriptions.Username"; $res = mysql_query($query) or die("Could not query subscriptions\n\n"); begin_transaction(); while ($row = mysql_fetch_array($res)) { if ($row['Trail'] == 32) { continue; } if ($row['Trail'] == 97) { continue; } if ($row['Trail'] == 106) { continue; } if ($row['Trail'] == 40) { continue; } if ($row['Trail'] == 526) { continue; } if ($row['Trail'] == 176) { continue; } if ($row['Trail'] == 927) { continue; } if ($row['Trail'] == 735) { continue; } foreach ($row as $key => $value) { $row[$key] = addslashes($value); } $query = sprintf("\n INSERT INTO\n ltrSubscriptions\n (User_ID, Trail)\n VALUES\n ('%s', %d)\n ", $row['user_id'], $row['Trail']); $pg_res = pg_exec($postgres, $query); if (!$pg_res) { end_transaction(false); die("SQL-Error! Query:\n\n{$query}\n\n"); } else { printf("\tInserted Subscription: (Trail=%d uid=%s)", $row['Trail'], $row['user_id'] . "\n"); } } mysql_free_result($res); end_transaction(); }
function HandleTechnologieBuild(&$CurrentPlanet, &$CurrentUser) { global $resource; if ($CurrentUser['b_tech_planet'] != 0) { // Y a une technologie en cours sur une de mes colonies if ($CurrentUser['b_tech_planet'] != $CurrentPlanet['id']) { // Et ce n'est pas sur celle ci !! $WorkingPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $CurrentUser['b_tech_planet'] . "';", 'planets', true); } if (isset($WorkingPlanet) && $WorkingPlanet) { $ThePlanet = $WorkingPlanet; } else { $ThePlanet = $CurrentPlanet; } $now = time(); if ($ThePlanet['b_tech'] <= $now && $ThePlanet['b_tech_id'] != 0) { begin_transaction(); $Me = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $CurrentUser['id'] . "' FOR UPDATE", 'users', true); if ($Me['b_tech_planet'] == $CurrentUser['b_tech_planet']) { $Result['WorkOn'] = ""; $Result['OnWork'] = false; return $Result; } $ThePlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $ThePlanet['id'] . "' FOR UPDATE", 'planets', true); if ($ThePlanet['b_tech'] > $now || $ThePlanet['b_tech_id'] == 0) { $Result['WorkOn'] = $ThePlanet; $Result['OnWork'] = true; return $Result; } // La recherche en cours est terminée ... $CurrentUser[$resource[$ThePlanet['b_tech_id']]]++; // Mise a jour de la planete sur laquelle la technologie a été recherchée $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`b_tech` = '0', "; $QryUpdatePlanet .= "`b_tech_id` = '0' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $ThePlanet['id'] . "';"; doquery($QryUpdatePlanet, 'planets'); // Mes a jour de la techno sur l'enregistrement Utilisateur // Et tant qu'a faire des stats points $QryUpdateUser = "******"; $QryUpdateUser .= "`" . $resource[$ThePlanet['b_tech_id']] . "` = '" . $CurrentUser[$resource[$ThePlanet['b_tech_id']]] . "', "; $QryUpdateUser .= "`b_tech_planet` = '0' "; $QryUpdateUser .= "WHERE "; $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';"; doquery($QryUpdateUser, 'users'); $ThePlanet["b_tech_id"] = 0; if (isset($WorkingPlanet)) { $WorkingPlanet = $ThePlanet; } else { $CurrentPlanet = $ThePlanet; } $Result['WorkOn'] = ""; $Result['OnWork'] = false; commit(); } elseif ($ThePlanet["b_tech_id"] == 0) { assert(false); // Il n'y a rien a l'ouest ... // Pas de Technologie en cours devait y avoir un bug lors de la derniere connexion // On met l'enregistrement informant d'une techno en cours de recherche a jours doquery("UPDATE {{table}} SET `b_tech_planet` = '0' WHERE `id` = '" . $CurrentUser['id'] . "';", 'users'); $Result['WorkOn'] = ""; $Result['OnWork'] = false; } else { // Bin on bosse toujours ici ... Alors ne nous derangez pas !!! $Result['WorkOn'] = $ThePlanet; $Result['OnWork'] = true; } } else { $Result['WorkOn'] = ""; $Result['OnWork'] = false; } return $Result; }
/** * BatimentBuildingPage.php * * @version 1.1 * @copyright 2008 by Chlorel for XNova */ function BatimentBuildingPage(&$CurrentPlanet, $CurrentUser) { global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET; // Tables of buildings by type of possible planet $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44); $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43); // Boucle d'interpretation des eventuelles commandes if (isset($_GET['cmd'])) { // On passe une commande $bThisIsCheated = false; $bDoItNow = false; $TheCommand = $_GET['cmd']; //$ListID = $_GET['listid']; if (isset($_GET['building'])) { $Element = $_GET['building']; if (!strchr($Element, " ")) { if (!strchr($Element, ",")) { if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) { $bDoItNow = true; } else { $bThisIsCheated = true; } } else { $bThisIsCheated = true; } } else { $bThisIsCheated = true; } } elseif (isset($_GET['listid'])) { $bDoItNow = true; } if ($bDoItNow == true) { begin_transaction(); $CurrentPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $CurrentPlanet['id'] . "' FOR UPDATE;", 'planets', true); switch ($TheCommand) { case 'cancel': // Interrompre le premier batiment de la queue CancelBuildingFromQueue($CurrentPlanet, $CurrentUser); break; case 'remove': // Supprimer un element de la queue (mais pas le premier) // $RemID -> element de la liste a supprimer RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $_GET['listid']); break; case 'insert': // Insere un element dans la queue AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true); break; case 'destroy': // Detruit un batiment deja construit sur la planete ! AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false); break; default: break; } // switch PlanetResourceUpdate($CurrentUser, $CurrentPlanet, time()); SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser); BuildingSavePlanetRecord($CurrentPlanet); commit(); } elseif ($bThisIsCheated == true) { ResetThisFuckingCheater($CurrentUser['id']); } } CheckPlanetUsedFields($CurrentPlanet); PlanetResourceUpdate($CurrentUser, $CurrentPlanet, time()); $Queue = ShowBuildingQueue($CurrentPlanet, $CurrentUser); // Record what has changed in planet! // BuildingSavePlanetRecord ( $CurrentPlanet ); // Record what has been any changes in users // BuildingSaveUserRecord ( $CurrentUser ); if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) { $CanBuildElement = true; } else { $CanBuildElement = false; } $SubTemplate = gettemplate('buildings_builds_row'); $BuildingPage = ""; foreach ($lang['tech'] as $Element => $ElementName) { if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) { $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet); if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) { $RoomIsOk = true; } else { $RoomIsOk = false; } if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false); $parse = array(); $parse['dpath'] = $dpath; $parse['i'] = $Element; $BuildingLevel = $CurrentPlanet[$resource[$Element]]; $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")"; $parse['n'] = $ElementName; $parse['descriptions'] = $lang['res']['descriptions'][$Element]; $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); $parse['time'] = ShowBuildTime($ElementBuildTime); $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element); $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element); $parse['click'] = ''; $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1; if ($Element == 31) { // Sp�cial Laboratoire if ($CurrentUser["b_tech_planet"] != 0 && $game_config['BuildLabWhileRun'] != 1) { // Variable qui contient le parametre // On verifie si on a le droit d'evoluer pendant les recherches (Setting dans config) $parse['click'] = "<font color=#FF0000>" . $lang['in_working'] . "</font>"; } } if ($parse['click'] != '') { // Bin on ne fait rien, vu que l'on l'a deja fait au dessus !! } elseif ($RoomIsOk && $CanBuildElement) { if ($Queue['lenght'] == 0) { if ($NextBuildLevel == 1) { if ($HaveRessources == true) { $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildFirstLevel'] . "</font></a>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>"; } } else { if ($HaveRessources == true) { $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>"; } } } else { $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['InBuildQueue'] . "</font></a>"; } } elseif ($RoomIsOk && !$CanBuildElement) { if ($NextBuildLevel == 1) { $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>"; } } else { $parse['click'] = "<font color=#FF0000>" . $lang['NoMoreSpace'] . "</font>"; } $BuildingPage .= parsetemplate($SubTemplate, $parse); } } } $parse = $lang; // Faut il afficher la liste de construction ?? if ($Queue['lenght'] > 0) { $parse['BuildListScript'] = InsertBuildListScript("buildings"); $parse['BuildList'] = $Queue['buildlist']; } else { $parse['BuildListScript'] = ""; $parse['BuildList'] = ""; } $parse['planet_field_current'] = $CurrentPlanet["field_current"]; $parse['planet_field_max'] = $CurrentPlanet['field_max'] + $CurrentPlanet[$resource[33]] * 5; $parse['field_libre'] = $parse['planet_field_max'] - $CurrentPlanet['field_current']; $parse['BuildingsList'] = $BuildingPage; $page = parsetemplate(gettemplate('buildings_builds'), $parse); display($page, ''); }