My:Abs
Версия от 14:53, 14 сентября 2011; WikiSysop (обсуждение | вклад)
<obj> <sts ini="1" cur="1"> <s nm="1" res="10"> <!-- Up --> <e kn="mOv" go="2"/> <e kn="mDn" go="3"/> </s> <s nm="2" res="11"> <!-- Ov --> <e kn="mDn" go="3"/> </s> <s nm="3" res="12"> <!-- Up --> <e kn="mUp" go="1"/> </s> </sts> </obj>
<? // ---------------------------------------------------------------------- читаем файл: @$product_filter = $_POST[ProductListBox]; $cur_file=0; // номер файла foreach ($file_names as $name){ $file = @fopen ($name,"r"); if($file){ // читаем файл построчно, разбивая на поля $cur_file++; $cur_line=0; // номер линии while ($ln = fgetcsv($file,10240,"\t")) if(count($ln)){ $cur_line++; if($cur_line == 1) continue; // пропускаем первую линию с заголовком файла TODO: проверить формат! $k=0; // тип файла (какие колонки брать) $pID = $ln[$k==0? 2: -1]; // productID $pType = $ln[$k==0? 6: -1]; // ProductTypeId $vendor = $ln[$k==0? 3: -1]; // VendorName $version = $ln[$k==0? 5: -1]; // Version $dtBeg = $ln[$k==0? 9: -1]; // BeginDate $dtEnd = $ln[$k==0? 10: -1]; // EndDate $country = $ln[$k==0? 12: -1]; // CountryCode $currCust = $ln[$k==0? 11: -1]; // CustomerCurrency $currRlty = $ln[$k==0? 13: -1]; // RoyaltyCurrency $priceMrk = $ln[$k==0? 15: -1]; // CustomerPrice $priceOur = $ln[$k==0? 8: -1]; // RoyaltyPrice $units = $ln[$k==0? 7: -1]; // Units $appleID = $ln[$k==0? 14: -1]; // AppleId $promo = $ln[$k==0? 16: -1]; // PromoCode // ProductTypeId содержит 7 это апдейтиы - убирать $dt = date("omd", strtotime($dtBeg)); // 09/01/2011 $lst_productID [$pID]++; // VendorId $lst_countryID [$country]++; // CountryCode $lst_currencyID[$currRlty]++; if( !is_array($product_filter) || in_array("!All", $product_filter, true) || in_array($pID, $product_filter, true) ){ $ammount = $priceOur*$units*$rates[$currRlty]; // получаемая нами сумма RoyaltyPrice*Units*Curs[CustomerCurrency]; $sales[$dt][0] += $ammount; $sales[$dt][1] += $units; $salesCountry[$country] += $ammount; // продажи по странам $unitsCountry[$country] += $units; // Загрузки по странам } } fclose ($file); } else $info .= "Can't open file".$name."\n"; } $lst_productID["!All"]=1; // список всех ID продуктов $lst_countryID["!All"]=1; // список всех ID стран ksort($lst_productID); // сортировка по ключу ksort($lst_countryID); reset($lst_productID); // установить внутренний указатель массива на его первый элемент reset($lst_countryID); ?>