campo-sirio/db/dbcv09.cpp
alex a0a36d6b33 Patch level : XX.282
Files correlati     :
Ricompilazione Demo : [ ]
Commento            : Riportata la versione 01.05 patch 282


git-svn-id: svn://10.65.10.50/trunk@8019 c028cbd2-c16b-5b4b-a496-9718f37d4682
1999-04-06 15:34:39 +00:00

441 lines
10 KiB
C++
Executable File

#include "dbcv09.h"
// ******************************************
// ******************************************
int location2metod(long location)
{
switch (location)
{
case 0: return 0;
case 1530: return 1;
case 59: return 2;
case 2008: return 3;
case 63: return 4;
case 872: return 5;
case 66: return 6;
case 1700: return 7;
case 115: return 8;
case 935: return 9;
case 911: return 10;
case 1812: return 11;
case 230: return 12;
case 433: return 13;
case 272: return 14;
case 1382: return 15;
case 467: return 16;
case 1352: return 17;
case 233: return 18;
case 498: return 19;
case 651: return 20;
case 511: return 21;
case 519: return 22;
case 2017: return 23;
case 798: return 24;
case 582: return 25;
case 618: return 26;
case 1190: return 27;
case 1360: return 28;
case 1727: return 29;
case 2081: return 30;
case 1330: return 31;
case 565: return 32;
case 2079: return 33;
case 2194: return 34;
case 229: return 35;
case 2280: return 36;
case 60: return 37;
case 50037: return 38;
case 1154: return 39;
case 2153: return 40;
case -1: return 41; // M&M srl
case 1569: return 42;
case 2237: return 43;
case -2: return 44; // rotolito
case -3: return 45; // sconfezionamento
}
return 99; // terzista generico
}
const char * descr_method(int method)
{
switch (method)
{
case 1: return ("Areosol lab. Italia");
case 2: return ("Areosol serivce Italia");
case 3: return ("Bertoncini");
case 4: return ("Bregaglio");
case 5: return ("CABL service");
case 6: return ("CIP4");
case 7: return ("Stabilimenti Cover di PD/PR");
case 8: return ("Deskin");
case 9: return ("Farmol Safca");
case 10: return ("FATAI Nyl");
case 11: return ("Hydra Farm.");
case 12: return ("IMAPACK");
case 13: return ("Interchem Italia");
case 14: return ("Ivers Lee Italia");
case 15: return ("Liquichim");
case 16: return ("Manilab");
case 17: return ("MP");
case 18: return ("Niada");
case 19: return ("Noviplast");
case 20: return ("OCE");
case 21: return ("Pantapack");
case 22: return ("PimepackDue");
case 23: return ("Pernici Cereira");
case 24: return ("Re.Le.Vi.");
case 25: return ("Synthesis");
case 26: return ("Treccificio BS");
case 27: return ("Tosvar Areosol");
case 28: return ("Unifill");
case 29: return ("Unispray");
case 30: return ("Artical");
case 31: return ("La cosmografica");
case 32: return ("Chizzoni");
case 33: return ("E.Bonetto Lito");
case 34: return ("CT Service srl");
case 35: return ("M&M sas");
case 36: return ("Brelil");
case 37: return ("Akronimex");
case 38: return ("Globol UK");
case 39: return ("LIto Sestese");
case 40: return ("Serialfa");
case 41: return ("M&M"); // M&M srl
case 42: return ("M&M srl");
case 43: return ("ERREDI ser. srl");
case 44: return ("Rotolito"); // rotolito
}
return "-- Unknown --";
}
void num_mag2main_imp(int magno, TString & codimp)
{
switch (magno)
{
case 91:
case 93:
case 26:
codimp="SE";
break;
case 92:
case 28:
codimp="TS";
break;
default:
codimp="XX";
}
}
void complete_gmc(TString & gmc,const char *iclas)
{
TString des;
TString16 subgmc(iclas);
char type;
if (subgmc=="AM") {
type = 'H';
des="Ambipur";
} else if (subgmc=="IN") {
type = 'H';
des="Ambipur";
} else if (subgmc=="KM") {
type = 'H';
des="Kiwi Mobili";
} else if (subgmc=="KS") {
type = 'H';
des="Kiwi Shoecare";
} else if (subgmc=="OS") {
type = 'H';
des="Shoe care generico";
} else if (subgmc=="PV") {
type = 'H';
des="Pulizia vetri";
} else if (subgmc=="HA") {
type = 'H';
des="House care generico";
} else if (subgmc=="OC") {
type = 'O';
des="Oral care generico";
} else if (subgmc=="SB") {
type = 'O';
des="Oral care Smithcline Beecham";
} else if (subgmc=="AV") {
type = 'P';
des="Acqua Velva";
} else if (subgmc=="BA") {
type = 'P';
des="Badedas";
} else if (subgmc=="BR") {
type = 'P';
des="Brylcreem";
} else if (subgmc=="DE") {
type = 'P';
des="Depilzero ";
} else if (subgmc=="FB") {
type = 'P';
des="Fissan Baby";
} else if (subgmc=="FO") {
type = 'P';
des="Fissan body generico";
} else if (subgmc=="GL") {
type = 'P';
des="Glysolid";
} else if (subgmc=="GP") {
type = 'P';
des="General purpose personal case";
} else if (subgmc=="OB") {
type = 'P';
des="Personal care generico";
} else if (subgmc=="QU") {
type = 'P';
des="Quickies";
} else if (subgmc=="SA") {
type = 'P';
des="Savane";
} else if (subgmc=="SO") {
type = 'P';
des="Super soap";
} else if (subgmc=="SX") {
type = 'P';
des="Sanex";
} else if (subgmc=="WI") {
type = 'P';
des="Williams";
} else
return;
gmc << type << 'C';
if (cache().get("GMC",gmc).empty())
{
cache().discard("GMC",gmc);
TTable ttt("GMC");
ttt.put("CODTAB",gmc);
ttt.put("S0",type=='H' ? "House care" : (type=='P' ? "Personal care" :"Oral care"));
ttt.write();
}
gmc << subgmc;
if (cache().get("GMC",gmc).empty())
{
cache().discard("GMC",gmc);
TTable ttt("GMC");
ttt.put("CODTAB",gmc);
ttt.put("S0",des);
ttt.write();
}
}
const char * check_clasdog(long stdo)
{
static TString cld;
if (stdo)
{
cld.format("%010ld",stdo);
if (cache().get("%CLD",cld).empty())
{
cache().discard("%CLD",cld);
TTable ttt("%CLD");
ttt.put("CODTAB",cld);
ttt.put("S0","???");
ttt.write();
}
}
else
cld.cut(0);
return cld;
}
void codimp2codmagdep(TString &codimp,int terzista, TString &codmag)
{
if (terzista>0)
{
codimp << format("3%02d",terzista);
codmag = codimp;
} else {
codmag = codimp;
codmag << 1;
}
}
void num_mag2cod_imp(int magno, TString & codimp)
{
switch (magno)
{
case 91:
case 93:
codimp="SE3";
break;
case 26:
codimp="SE";
break;
case 92:
codimp="TS3";
break;
case 28:
codimp="TS";
break;
default:
codimp="XX";
}
}
void add_stdlabors(const char * item, long wrkc, int bomm)
{
int type=int (wrkc/100);
if ( type == 1010 || (bomm != 0 && bomm != 99)) // non e' una linea di confezionamento di Segrate o terzista
{
TLocalisamfile rdist(LF_RDIST);
TString stdlav;
rdist.put("CODDIST",item);
rdist.read(_isgteq);
int nrig=0;
while (!rdist.eof() && rdist.get("CODDIST")==item)
{
if (rdist.get("TIPO")=="L") break;
rdist.next();
nrig++;
}
if (rdist.eof() || rdist.get("CODDIST")!=item)
{
// nessuna lavorazione precedentemente inserita
int lineno;
if (type == 1010 )
lineno=int (wrkc - type*100);
else
lineno= 100;
int pzxca;
switch (lineno)
{
case 1:
stdlav="L_ALCOL1";
pzxca=12;
break;
case 2:
stdlav="L_DOCCIA";
pzxca=12;
break;
case 4:
stdlav="L_GLYSOL";
pzxca=12;
break;
case 5:
stdlav="L_BRYLCR";
pzxca=12;
break;
case 6:
stdlav="L_BAGNOS";
pzxca=12;
break;
case 7:
stdlav="L_SAPONE";
pzxca=12;
break;
case 8:
stdlav="L_SAPRIC";
pzxca=12;
break;
case 9:
stdlav="L_DENTIF";
pzxca=12;
break;
case 10:
stdlav="L_PENTO";
pzxca=12;
break;
case 14:
stdlav="L_ALCOL2";
pzxca=12;
break;
// lavorazioni terzisti
case 100:
stdlav="L_RICONF";
pzxca=12;
break;
default:
error_box("Linea sconosciuta per l'articolo %s:%d",item,lineno);
lineno=0;
}
TString16 um=cache().get(LF_DIST,item).get("UM");
if (lineno && !um.empty())
{
TToken_string key(item);
key.add("1",1);
if (cache().get(LF_UMART,key).get("UM")=="CA")
stdlav<< "_CA" << pzxca;
else
stdlav<< "_SL";
real fc;
if (cache().get(LF_UMART,key).get("UM")==um)
{
fc=cache().get(LF_UMART,key).get_real("FC");
} else {
key.add("2",1);
fc=cache().get(LF_UMART,key).get_real("FC");
}
if (!cache().get("LAV",stdlav).empty())
{
rdist.put("CODDIST",item);
rdist.put("NRIG",nrig+1);
rdist.put("TIPO","L");
rdist.put("CODCOMP",stdlav);
rdist.put("UM",um);
rdist.put("EXPR",fc.string());
rdist.write();
} else {
error_box("Impossibile trovare la lavorazione %s per l'articolo %s. Inserimento automatico", (const char *)stdlav, item);
cache().discard("LAV",stdlav);
TTable ttt("LAV");
ttt.put("CODTAB",stdlav);
ttt.put("S0","???");
ttt.write();
}
}
}
}
}
void round_date(TDate& date, bool up)
{
// Dimensione del bucke in giorni
const int bucket_size = 7;
// Riporta la data al primo lunedi prima dell'inizio
const int wday = date.wday();
if (wday > 1) date -= wday-1;
if (up) // Arrotonda alla fine del bucket
date += (bucket_size - 1);
else // Arrotonda all'inizio del bucket
date = date ;
}
void crea_mag3()
{
TString codmag;TString desc;
TTable mag("MAG");
mag.put("CODTAB","SE3");
mag.put("B0","X");
mag.put("S0","Terzisti di Segrate (ex mag. 91-93)");
mag.write();
mag.put("CODTAB","TS3");
mag.put("B0","X");
mag.put("S0","Terzisti di Trieste (ex mag. 92)");
mag.write();
for (int t=1 ; t<45;t++)
{
desc=descr_method(t);
codmag.format("SE3%02d",t);
mag.put("CODTAB",codmag);
mag.put("S0",desc);
mag.write();
codmag.format("TS3%02d",t);
mag.put("CODTAB",codmag);
mag.put("S0",desc);
mag.write();
}
}